@getopenpay/openpay-js-react 0.0.12 → 0.0.13-alpha.fd11f67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +724 -708
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsx as
|
|
1
|
+
import _r, { createContext as gr, useContext as xr, useState as N, useMemo as Oe, useCallback as Te, useRef as Zt, useEffect as qe } from "react";
|
|
2
|
+
import { jsx as ae } from "react/jsx-runtime";
|
|
3
3
|
const jt = gr({
|
|
4
4
|
formId: "",
|
|
5
5
|
formHeight: "",
|
|
@@ -8,34 +8,34 @@ const jt = gr({
|
|
|
8
8
|
registerIframe: () => {
|
|
9
9
|
},
|
|
10
10
|
baseUrl: ""
|
|
11
|
-
}),
|
|
12
|
-
const r =
|
|
11
|
+
}), br = () => {
|
|
12
|
+
const r = xr(jt);
|
|
13
13
|
if (!r)
|
|
14
14
|
throw new Error("useOpenPayElements must be used within an OpenPayElementsProvider");
|
|
15
15
|
return r;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
for (var
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
return (
|
|
17
|
+
var I = [];
|
|
18
|
+
for (var ht = 0; ht < 256; ++ht)
|
|
19
|
+
I.push((ht + 256).toString(16).slice(1));
|
|
20
|
+
function kr(r, e = 0) {
|
|
21
|
+
return (I[r[e + 0]] + I[r[e + 1]] + I[r[e + 2]] + I[r[e + 3]] + "-" + I[r[e + 4]] + I[r[e + 5]] + "-" + I[r[e + 6]] + I[r[e + 7]] + "-" + I[r[e + 8]] + I[r[e + 9]] + "-" + I[r[e + 10]] + I[r[e + 11]] + I[r[e + 12]] + I[r[e + 13]] + I[r[e + 14]] + I[r[e + 15]]).toLowerCase();
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
23
|
+
var Be, wr = new Uint8Array(16);
|
|
24
|
+
function Er() {
|
|
25
|
+
if (!Be && (Be = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Be))
|
|
26
26
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
27
|
-
return
|
|
27
|
+
return Be(wr);
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var Tr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
30
30
|
const Ot = {
|
|
31
|
-
randomUUID:
|
|
31
|
+
randomUUID: Tr
|
|
32
32
|
};
|
|
33
33
|
function Mt(r, e, t) {
|
|
34
34
|
if (Ot.randomUUID && !e && !r)
|
|
35
35
|
return Ot.randomUUID();
|
|
36
36
|
r = r || {};
|
|
37
|
-
var n = r.random || (r.rng ||
|
|
38
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
37
|
+
var n = r.random || (r.rng || Er)();
|
|
38
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, kr(n);
|
|
39
39
|
}
|
|
40
40
|
var x;
|
|
41
41
|
(function(r) {
|
|
@@ -73,14 +73,14 @@ var x;
|
|
|
73
73
|
}
|
|
74
74
|
r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
75
75
|
})(x || (x = {}));
|
|
76
|
-
var
|
|
76
|
+
var mt;
|
|
77
77
|
(function(r) {
|
|
78
78
|
r.mergeShapes = (e, t) => ({
|
|
79
79
|
...e,
|
|
80
80
|
...t
|
|
81
81
|
// second overwrites first
|
|
82
82
|
});
|
|
83
|
-
})(
|
|
83
|
+
})(mt || (mt = {}));
|
|
84
84
|
const h = x.arrayToEnum([
|
|
85
85
|
"string",
|
|
86
86
|
"nan",
|
|
@@ -102,7 +102,7 @@ const h = x.arrayToEnum([
|
|
|
102
102
|
"never",
|
|
103
103
|
"map",
|
|
104
104
|
"set"
|
|
105
|
-
]),
|
|
105
|
+
]), se = (r) => {
|
|
106
106
|
switch (typeof r) {
|
|
107
107
|
case "undefined":
|
|
108
108
|
return h.undefined;
|
|
@@ -140,8 +140,8 @@ const h = x.arrayToEnum([
|
|
|
140
140
|
"invalid_intersection_types",
|
|
141
141
|
"not_multiple_of",
|
|
142
142
|
"not_finite"
|
|
143
|
-
]),
|
|
144
|
-
class
|
|
143
|
+
]), Sr = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
144
|
+
class U extends Error {
|
|
145
145
|
constructor(e) {
|
|
146
146
|
super(), this.issues = [], this.addIssue = (n) => {
|
|
147
147
|
this.issues = [...this.issues, n];
|
|
@@ -178,7 +178,7 @@ class M extends Error {
|
|
|
178
178
|
return s(this), n;
|
|
179
179
|
}
|
|
180
180
|
static assert(e) {
|
|
181
|
-
if (!(e instanceof
|
|
181
|
+
if (!(e instanceof U))
|
|
182
182
|
throw new Error(`Not a ZodError: ${e}`);
|
|
183
183
|
}
|
|
184
184
|
toString() {
|
|
@@ -200,8 +200,8 @@ class M extends Error {
|
|
|
200
200
|
return this.flatten();
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const
|
|
203
|
+
U.create = (r) => new U(r);
|
|
204
|
+
const xe = (r, e) => {
|
|
205
205
|
let t;
|
|
206
206
|
switch (r.code) {
|
|
207
207
|
case d.invalid_type:
|
|
@@ -257,14 +257,14 @@ const _e = (r, e) => {
|
|
|
257
257
|
}
|
|
258
258
|
return { message: t };
|
|
259
259
|
};
|
|
260
|
-
let
|
|
260
|
+
let Ut = xe;
|
|
261
261
|
function Cr(r) {
|
|
262
|
-
|
|
262
|
+
Ut = r;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
264
|
+
function He() {
|
|
265
|
+
return Ut;
|
|
266
266
|
}
|
|
267
|
-
const
|
|
267
|
+
const Ke = (r) => {
|
|
268
268
|
const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
|
|
269
269
|
...s,
|
|
270
270
|
path: a
|
|
@@ -284,9 +284,9 @@ const Ye = (r) => {
|
|
|
284
284
|
path: a,
|
|
285
285
|
message: o
|
|
286
286
|
};
|
|
287
|
-
},
|
|
288
|
-
function
|
|
289
|
-
const t =
|
|
287
|
+
}, Or = [];
|
|
288
|
+
function f(r, e) {
|
|
289
|
+
const t = He(), n = Ke({
|
|
290
290
|
issueData: e,
|
|
291
291
|
data: r.data,
|
|
292
292
|
path: r.path,
|
|
@@ -294,13 +294,13 @@ function l(r, e) {
|
|
|
294
294
|
r.common.contextualErrorMap,
|
|
295
295
|
r.schemaErrorMap,
|
|
296
296
|
t,
|
|
297
|
-
t ===
|
|
297
|
+
t === xe ? void 0 : xe
|
|
298
298
|
// then global default map
|
|
299
299
|
].filter((s) => !!s)
|
|
300
300
|
});
|
|
301
301
|
r.common.issues.push(n);
|
|
302
302
|
}
|
|
303
|
-
class
|
|
303
|
+
class A {
|
|
304
304
|
constructor() {
|
|
305
305
|
this.value = "valid";
|
|
306
306
|
}
|
|
@@ -328,7 +328,7 @@ class N {
|
|
|
328
328
|
value: i
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
|
-
return
|
|
331
|
+
return A.mergeObjectSync(e, n);
|
|
332
332
|
}
|
|
333
333
|
static mergeObjectSync(e, t) {
|
|
334
334
|
const n = {};
|
|
@@ -343,12 +343,12 @@ class N {
|
|
|
343
343
|
}
|
|
344
344
|
const v = Object.freeze({
|
|
345
345
|
status: "aborted"
|
|
346
|
-
}),
|
|
347
|
-
function
|
|
346
|
+
}), _e = (r) => ({ status: "dirty", value: r }), Z = (r) => ({ status: "valid", value: r }), yt = (r) => r.status === "aborted", vt = (r) => r.status === "dirty", Re = (r) => r.status === "valid", Ie = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
347
|
+
function Ye(r, e, t, n) {
|
|
348
348
|
if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
349
349
|
return e.get(r);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function Dt(r, e, t, n, s) {
|
|
352
352
|
if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
353
353
|
return e.set(r, t), t;
|
|
354
354
|
}
|
|
@@ -356,8 +356,8 @@ var m;
|
|
|
356
356
|
(function(r) {
|
|
357
357
|
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
358
358
|
})(m || (m = {}));
|
|
359
|
-
var
|
|
360
|
-
class
|
|
359
|
+
var Se, Ce;
|
|
360
|
+
class K {
|
|
361
361
|
constructor(e, t, n, s) {
|
|
362
362
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
|
|
363
363
|
}
|
|
@@ -375,12 +375,12 @@ const Rt = (r, e) => {
|
|
|
375
375
|
get error() {
|
|
376
376
|
if (this._error)
|
|
377
377
|
return this._error;
|
|
378
|
-
const t = new
|
|
378
|
+
const t = new U(r.common.issues);
|
|
379
379
|
return this._error = t, this._error;
|
|
380
380
|
}
|
|
381
381
|
};
|
|
382
382
|
};
|
|
383
|
-
function
|
|
383
|
+
function _(r) {
|
|
384
384
|
if (!r)
|
|
385
385
|
return {};
|
|
386
386
|
const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
|
|
@@ -392,7 +392,7 @@ function g(r) {
|
|
|
392
392
|
return i.code === "invalid_enum_value" ? { message: p ?? o.defaultError } : typeof o.data > "u" ? { message: (u = p ?? n) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (c = p ?? t) !== null && c !== void 0 ? c : o.defaultError };
|
|
393
393
|
}, description: s };
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class g {
|
|
396
396
|
constructor(e) {
|
|
397
397
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
|
|
398
398
|
}
|
|
@@ -400,13 +400,13 @@ class _ {
|
|
|
400
400
|
return this._def.description;
|
|
401
401
|
}
|
|
402
402
|
_getType(e) {
|
|
403
|
-
return
|
|
403
|
+
return se(e.data);
|
|
404
404
|
}
|
|
405
405
|
_getOrReturnCtx(e, t) {
|
|
406
406
|
return t || {
|
|
407
407
|
common: e.parent.common,
|
|
408
408
|
data: e.data,
|
|
409
|
-
parsedType:
|
|
409
|
+
parsedType: se(e.data),
|
|
410
410
|
schemaErrorMap: this._def.errorMap,
|
|
411
411
|
path: e.path,
|
|
412
412
|
parent: e.parent
|
|
@@ -414,11 +414,11 @@ class _ {
|
|
|
414
414
|
}
|
|
415
415
|
_processInputParams(e) {
|
|
416
416
|
return {
|
|
417
|
-
status: new
|
|
417
|
+
status: new A(),
|
|
418
418
|
ctx: {
|
|
419
419
|
common: e.parent.common,
|
|
420
420
|
data: e.data,
|
|
421
|
-
parsedType:
|
|
421
|
+
parsedType: se(e.data),
|
|
422
422
|
schemaErrorMap: this._def.errorMap,
|
|
423
423
|
path: e.path,
|
|
424
424
|
parent: e.parent
|
|
@@ -453,7 +453,7 @@ class _ {
|
|
|
453
453
|
schemaErrorMap: this._def.errorMap,
|
|
454
454
|
parent: null,
|
|
455
455
|
data: e,
|
|
456
|
-
parsedType:
|
|
456
|
+
parsedType: se(e)
|
|
457
457
|
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
458
458
|
return Rt(s, a);
|
|
459
459
|
}
|
|
@@ -474,7 +474,7 @@ class _ {
|
|
|
474
474
|
schemaErrorMap: this._def.errorMap,
|
|
475
475
|
parent: null,
|
|
476
476
|
data: e,
|
|
477
|
-
parsedType:
|
|
477
|
+
parsedType: se(e)
|
|
478
478
|
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (Ie(s) ? s : Promise.resolve(s));
|
|
479
479
|
return Rt(n, a);
|
|
480
480
|
}
|
|
@@ -502,10 +502,10 @@ class _ {
|
|
|
502
502
|
return this._refinement(e);
|
|
503
503
|
}
|
|
504
504
|
optional() {
|
|
505
|
-
return
|
|
505
|
+
return H.create(this, this._def);
|
|
506
506
|
}
|
|
507
507
|
nullable() {
|
|
508
|
-
return
|
|
508
|
+
return de.create(this, this._def);
|
|
509
509
|
}
|
|
510
510
|
nullish() {
|
|
511
511
|
return this.nullable().optional();
|
|
@@ -514,7 +514,7 @@ class _ {
|
|
|
514
514
|
return F.create(this, this._def);
|
|
515
515
|
}
|
|
516
516
|
promise() {
|
|
517
|
-
return
|
|
517
|
+
return ke.create(this, this._def);
|
|
518
518
|
}
|
|
519
519
|
or(e) {
|
|
520
520
|
return Ze.create([this, e], this._def);
|
|
@@ -524,7 +524,7 @@ class _ {
|
|
|
524
524
|
}
|
|
525
525
|
transform(e) {
|
|
526
526
|
return new B({
|
|
527
|
-
...
|
|
527
|
+
..._(this._def),
|
|
528
528
|
schema: this,
|
|
529
529
|
typeName: y.ZodEffects,
|
|
530
530
|
effect: { type: "transform", transform: e }
|
|
@@ -533,23 +533,23 @@ class _ {
|
|
|
533
533
|
default(e) {
|
|
534
534
|
const t = typeof e == "function" ? e : () => e;
|
|
535
535
|
return new $e({
|
|
536
|
-
...
|
|
536
|
+
..._(this._def),
|
|
537
537
|
innerType: this,
|
|
538
538
|
defaultValue: t,
|
|
539
539
|
typeName: y.ZodDefault
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
brand() {
|
|
543
|
-
return new
|
|
543
|
+
return new xt({
|
|
544
544
|
typeName: y.ZodBranded,
|
|
545
545
|
type: this,
|
|
546
|
-
...
|
|
546
|
+
..._(this._def)
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
catch(e) {
|
|
550
550
|
const t = typeof e == "function" ? e : () => e;
|
|
551
551
|
return new Ve({
|
|
552
|
-
...
|
|
552
|
+
..._(this._def),
|
|
553
553
|
innerType: this,
|
|
554
554
|
catchValue: t,
|
|
555
555
|
typeName: y.ZodCatch
|
|
@@ -575,39 +575,39 @@ class _ {
|
|
|
575
575
|
return this.safeParse(null).success;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
let
|
|
580
|
-
const
|
|
578
|
+
const Rr = /^c[^\s-]{8,}$/i, Ir = /^[0-9a-z]+$/, Nr = /^[0-9A-HJKMNP-TV-Z]{26}$/, Ar = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Pr = /^[a-z0-9_-]{21}$/i, Zr = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, jr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Mr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
579
|
+
let pt;
|
|
580
|
+
const Ur = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Dr = /^(([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})))$/, Lr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Lt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", $r = new RegExp(`^${Lt}$`);
|
|
581
581
|
function $t(r) {
|
|
582
582
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
583
583
|
return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function Vr(r) {
|
|
586
586
|
return new RegExp(`^${$t(r)}$`);
|
|
587
587
|
}
|
|
588
588
|
function Vt(r) {
|
|
589
|
-
let e = `${
|
|
589
|
+
let e = `${Lt}T${$t(r)}`;
|
|
590
590
|
const t = [];
|
|
591
591
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
return !!((e === "v4" || !e) &&
|
|
593
|
+
function zr(r, e) {
|
|
594
|
+
return !!((e === "v4" || !e) && Ur.test(r) || (e === "v6" || !e) && Dr.test(r));
|
|
595
595
|
}
|
|
596
|
-
class z extends
|
|
596
|
+
class z extends g {
|
|
597
597
|
_parse(e) {
|
|
598
598
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
599
599
|
const a = this._getOrReturnCtx(e);
|
|
600
|
-
return
|
|
600
|
+
return f(a, {
|
|
601
601
|
code: d.invalid_type,
|
|
602
602
|
expected: h.string,
|
|
603
603
|
received: a.parsedType
|
|
604
604
|
}), v;
|
|
605
605
|
}
|
|
606
|
-
const n = new
|
|
606
|
+
const n = new A();
|
|
607
607
|
let s;
|
|
608
608
|
for (const a of this._def.checks)
|
|
609
609
|
if (a.kind === "min")
|
|
610
|
-
e.data.length < a.value && (s = this._getOrReturnCtx(e, s),
|
|
610
|
+
e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
611
611
|
code: d.too_small,
|
|
612
612
|
minimum: a.value,
|
|
613
613
|
type: "string",
|
|
@@ -616,7 +616,7 @@ class z extends _ {
|
|
|
616
616
|
message: a.message
|
|
617
617
|
}), n.dirty());
|
|
618
618
|
else if (a.kind === "max")
|
|
619
|
-
e.data.length > a.value && (s = this._getOrReturnCtx(e, s),
|
|
619
|
+
e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
620
620
|
code: d.too_big,
|
|
621
621
|
maximum: a.value,
|
|
622
622
|
type: "string",
|
|
@@ -626,14 +626,14 @@ class z extends _ {
|
|
|
626
626
|
}), n.dirty());
|
|
627
627
|
else if (a.kind === "length") {
|
|
628
628
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
629
|
-
(i || o) && (s = this._getOrReturnCtx(e, s), i ?
|
|
629
|
+
(i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
|
|
630
630
|
code: d.too_big,
|
|
631
631
|
maximum: a.value,
|
|
632
632
|
type: "string",
|
|
633
633
|
inclusive: !0,
|
|
634
634
|
exact: !0,
|
|
635
635
|
message: a.message
|
|
636
|
-
}) : o &&
|
|
636
|
+
}) : o && f(s, {
|
|
637
637
|
code: d.too_small,
|
|
638
638
|
minimum: a.value,
|
|
639
639
|
type: "string",
|
|
@@ -642,43 +642,43 @@ class z extends _ {
|
|
|
642
642
|
message: a.message
|
|
643
643
|
}), n.dirty());
|
|
644
644
|
} else if (a.kind === "email")
|
|
645
|
-
|
|
645
|
+
jr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
646
646
|
validation: "email",
|
|
647
647
|
code: d.invalid_string,
|
|
648
648
|
message: a.message
|
|
649
649
|
}), n.dirty());
|
|
650
650
|
else if (a.kind === "emoji")
|
|
651
|
-
|
|
651
|
+
pt || (pt = new RegExp(Mr, "u")), pt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
652
652
|
validation: "emoji",
|
|
653
653
|
code: d.invalid_string,
|
|
654
654
|
message: a.message
|
|
655
655
|
}), n.dirty());
|
|
656
656
|
else if (a.kind === "uuid")
|
|
657
|
-
|
|
657
|
+
Ar.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
658
658
|
validation: "uuid",
|
|
659
659
|
code: d.invalid_string,
|
|
660
660
|
message: a.message
|
|
661
661
|
}), n.dirty());
|
|
662
662
|
else if (a.kind === "nanoid")
|
|
663
|
-
|
|
663
|
+
Pr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
664
664
|
validation: "nanoid",
|
|
665
665
|
code: d.invalid_string,
|
|
666
666
|
message: a.message
|
|
667
667
|
}), n.dirty());
|
|
668
668
|
else if (a.kind === "cuid")
|
|
669
|
-
|
|
669
|
+
Rr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
670
670
|
validation: "cuid",
|
|
671
671
|
code: d.invalid_string,
|
|
672
672
|
message: a.message
|
|
673
673
|
}), n.dirty());
|
|
674
674
|
else if (a.kind === "cuid2")
|
|
675
|
-
|
|
675
|
+
Ir.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
676
676
|
validation: "cuid2",
|
|
677
677
|
code: d.invalid_string,
|
|
678
678
|
message: a.message
|
|
679
679
|
}), n.dirty());
|
|
680
680
|
else if (a.kind === "ulid")
|
|
681
|
-
|
|
681
|
+
Nr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
682
682
|
validation: "ulid",
|
|
683
683
|
code: d.invalid_string,
|
|
684
684
|
message: a.message
|
|
@@ -687,49 +687,49 @@ class z extends _ {
|
|
|
687
687
|
try {
|
|
688
688
|
new URL(e.data);
|
|
689
689
|
} catch {
|
|
690
|
-
s = this._getOrReturnCtx(e, s),
|
|
690
|
+
s = this._getOrReturnCtx(e, s), f(s, {
|
|
691
691
|
validation: "url",
|
|
692
692
|
code: d.invalid_string,
|
|
693
693
|
message: a.message
|
|
694
694
|
}), n.dirty();
|
|
695
695
|
}
|
|
696
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s),
|
|
696
|
+
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
697
697
|
validation: "regex",
|
|
698
698
|
code: d.invalid_string,
|
|
699
699
|
message: a.message
|
|
700
|
-
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s),
|
|
700
|
+
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
701
701
|
code: d.invalid_string,
|
|
702
702
|
validation: { includes: a.value, position: a.position },
|
|
703
703
|
message: a.message
|
|
704
|
-
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s),
|
|
704
|
+
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
705
705
|
code: d.invalid_string,
|
|
706
706
|
validation: { startsWith: a.value },
|
|
707
707
|
message: a.message
|
|
708
|
-
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s),
|
|
708
|
+
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
709
709
|
code: d.invalid_string,
|
|
710
710
|
validation: { endsWith: a.value },
|
|
711
711
|
message: a.message
|
|
712
|
-
}), n.dirty()) : a.kind === "datetime" ? Vt(a).test(e.data) || (s = this._getOrReturnCtx(e, s),
|
|
712
|
+
}), n.dirty()) : a.kind === "datetime" ? Vt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
713
713
|
code: d.invalid_string,
|
|
714
714
|
validation: "datetime",
|
|
715
715
|
message: a.message
|
|
716
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
716
|
+
}), n.dirty()) : a.kind === "date" ? $r.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
717
717
|
code: d.invalid_string,
|
|
718
718
|
validation: "date",
|
|
719
719
|
message: a.message
|
|
720
|
-
}), n.dirty()) : a.kind === "time" ?
|
|
720
|
+
}), n.dirty()) : a.kind === "time" ? Vr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
721
721
|
code: d.invalid_string,
|
|
722
722
|
validation: "time",
|
|
723
723
|
message: a.message
|
|
724
|
-
}), n.dirty()) : a.kind === "duration" ?
|
|
724
|
+
}), n.dirty()) : a.kind === "duration" ? Zr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
725
725
|
validation: "duration",
|
|
726
726
|
code: d.invalid_string,
|
|
727
727
|
message: a.message
|
|
728
|
-
}), n.dirty()) : a.kind === "ip" ?
|
|
728
|
+
}), n.dirty()) : a.kind === "ip" ? zr(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
729
729
|
validation: "ip",
|
|
730
730
|
code: d.invalid_string,
|
|
731
731
|
message: a.message
|
|
732
|
-
}), n.dirty()) : a.kind === "base64" ? Lr.test(e.data) || (s = this._getOrReturnCtx(e, s),
|
|
732
|
+
}), n.dirty()) : a.kind === "base64" ? Lr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
733
733
|
validation: "base64",
|
|
734
734
|
code: d.invalid_string,
|
|
735
735
|
message: a.message
|
|
@@ -948,53 +948,53 @@ z.create = (r) => {
|
|
|
948
948
|
checks: [],
|
|
949
949
|
typeName: y.ZodString,
|
|
950
950
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
951
|
-
...
|
|
951
|
+
..._(r)
|
|
952
952
|
});
|
|
953
953
|
};
|
|
954
|
-
function
|
|
954
|
+
function Fr(r, e) {
|
|
955
955
|
const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
|
|
956
956
|
return a % i / Math.pow(10, s);
|
|
957
957
|
}
|
|
958
|
-
class
|
|
958
|
+
class ie extends g {
|
|
959
959
|
constructor() {
|
|
960
960
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
961
961
|
}
|
|
962
962
|
_parse(e) {
|
|
963
963
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
964
964
|
const a = this._getOrReturnCtx(e);
|
|
965
|
-
return
|
|
965
|
+
return f(a, {
|
|
966
966
|
code: d.invalid_type,
|
|
967
967
|
expected: h.number,
|
|
968
968
|
received: a.parsedType
|
|
969
969
|
}), v;
|
|
970
970
|
}
|
|
971
971
|
let n;
|
|
972
|
-
const s = new
|
|
972
|
+
const s = new A();
|
|
973
973
|
for (const a of this._def.checks)
|
|
974
|
-
a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n),
|
|
974
|
+
a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
975
975
|
code: d.invalid_type,
|
|
976
976
|
expected: "integer",
|
|
977
977
|
received: "float",
|
|
978
978
|
message: a.message
|
|
979
|
-
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n),
|
|
979
|
+
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
980
980
|
code: d.too_small,
|
|
981
981
|
minimum: a.value,
|
|
982
982
|
type: "number",
|
|
983
983
|
inclusive: a.inclusive,
|
|
984
984
|
exact: !1,
|
|
985
985
|
message: a.message
|
|
986
|
-
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n),
|
|
986
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
987
987
|
code: d.too_big,
|
|
988
988
|
maximum: a.value,
|
|
989
989
|
type: "number",
|
|
990
990
|
inclusive: a.inclusive,
|
|
991
991
|
exact: !1,
|
|
992
992
|
message: a.message
|
|
993
|
-
}), s.dirty()) : a.kind === "multipleOf" ?
|
|
993
|
+
}), s.dirty()) : a.kind === "multipleOf" ? Fr(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
994
994
|
code: d.not_multiple_of,
|
|
995
995
|
multipleOf: a.value,
|
|
996
996
|
message: a.message
|
|
997
|
-
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n),
|
|
997
|
+
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
998
998
|
code: d.not_finite,
|
|
999
999
|
message: a.message
|
|
1000
1000
|
}), s.dirty()) : x.assertNever(a);
|
|
@@ -1013,7 +1013,7 @@ class ce extends _ {
|
|
|
1013
1013
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1014
1014
|
}
|
|
1015
1015
|
setLimit(e, t, n, s) {
|
|
1016
|
-
return new
|
|
1016
|
+
return new ie({
|
|
1017
1017
|
...this._def,
|
|
1018
1018
|
checks: [
|
|
1019
1019
|
...this._def.checks,
|
|
@@ -1027,7 +1027,7 @@ class ce extends _ {
|
|
|
1027
1027
|
});
|
|
1028
1028
|
}
|
|
1029
1029
|
_addCheck(e) {
|
|
1030
|
-
return new
|
|
1030
|
+
return new ie({
|
|
1031
1031
|
...this._def,
|
|
1032
1032
|
checks: [...this._def.checks, e]
|
|
1033
1033
|
});
|
|
@@ -1121,41 +1121,41 @@ class ce extends _ {
|
|
|
1121
1121
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
|
-
|
|
1124
|
+
ie.create = (r) => new ie({
|
|
1125
1125
|
checks: [],
|
|
1126
1126
|
typeName: y.ZodNumber,
|
|
1127
1127
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1128
|
-
...
|
|
1128
|
+
..._(r)
|
|
1129
1129
|
});
|
|
1130
|
-
class
|
|
1130
|
+
class oe extends g {
|
|
1131
1131
|
constructor() {
|
|
1132
1132
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1133
1133
|
}
|
|
1134
1134
|
_parse(e) {
|
|
1135
1135
|
if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== h.bigint) {
|
|
1136
1136
|
const a = this._getOrReturnCtx(e);
|
|
1137
|
-
return
|
|
1137
|
+
return f(a, {
|
|
1138
1138
|
code: d.invalid_type,
|
|
1139
1139
|
expected: h.bigint,
|
|
1140
1140
|
received: a.parsedType
|
|
1141
1141
|
}), v;
|
|
1142
1142
|
}
|
|
1143
1143
|
let n;
|
|
1144
|
-
const s = new
|
|
1144
|
+
const s = new A();
|
|
1145
1145
|
for (const a of this._def.checks)
|
|
1146
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n),
|
|
1146
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1147
1147
|
code: d.too_small,
|
|
1148
1148
|
type: "bigint",
|
|
1149
1149
|
minimum: a.value,
|
|
1150
1150
|
inclusive: a.inclusive,
|
|
1151
1151
|
message: a.message
|
|
1152
|
-
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n),
|
|
1152
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1153
1153
|
code: d.too_big,
|
|
1154
1154
|
type: "bigint",
|
|
1155
1155
|
maximum: a.value,
|
|
1156
1156
|
inclusive: a.inclusive,
|
|
1157
1157
|
message: a.message
|
|
1158
|
-
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n),
|
|
1158
|
+
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1159
1159
|
code: d.not_multiple_of,
|
|
1160
1160
|
multipleOf: a.value,
|
|
1161
1161
|
message: a.message
|
|
@@ -1175,7 +1175,7 @@ class de extends _ {
|
|
|
1175
1175
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1176
1176
|
}
|
|
1177
1177
|
setLimit(e, t, n, s) {
|
|
1178
|
-
return new
|
|
1178
|
+
return new oe({
|
|
1179
1179
|
...this._def,
|
|
1180
1180
|
checks: [
|
|
1181
1181
|
...this._def.checks,
|
|
@@ -1189,7 +1189,7 @@ class de extends _ {
|
|
|
1189
1189
|
});
|
|
1190
1190
|
}
|
|
1191
1191
|
_addCheck(e) {
|
|
1192
|
-
return new
|
|
1192
|
+
return new oe({
|
|
1193
1193
|
...this._def,
|
|
1194
1194
|
checks: [...this._def.checks, e]
|
|
1195
1195
|
});
|
|
@@ -1246,38 +1246,38 @@ class de extends _ {
|
|
|
1246
1246
|
return e;
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
|
|
1249
|
+
oe.create = (r) => {
|
|
1250
1250
|
var e;
|
|
1251
|
-
return new
|
|
1251
|
+
return new oe({
|
|
1252
1252
|
checks: [],
|
|
1253
1253
|
typeName: y.ZodBigInt,
|
|
1254
1254
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
1255
|
-
...
|
|
1255
|
+
..._(r)
|
|
1256
1256
|
});
|
|
1257
1257
|
};
|
|
1258
|
-
class Ne extends
|
|
1258
|
+
class Ne extends g {
|
|
1259
1259
|
_parse(e) {
|
|
1260
1260
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1261
1261
|
const n = this._getOrReturnCtx(e);
|
|
1262
|
-
return
|
|
1262
|
+
return f(n, {
|
|
1263
1263
|
code: d.invalid_type,
|
|
1264
1264
|
expected: h.boolean,
|
|
1265
1265
|
received: n.parsedType
|
|
1266
1266
|
}), v;
|
|
1267
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return Z(e.data);
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
1271
|
Ne.create = (r) => new Ne({
|
|
1272
1272
|
typeName: y.ZodBoolean,
|
|
1273
1273
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1274
|
-
...
|
|
1274
|
+
..._(r)
|
|
1275
1275
|
});
|
|
1276
|
-
class
|
|
1276
|
+
class pe extends g {
|
|
1277
1277
|
_parse(e) {
|
|
1278
1278
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1279
1279
|
const a = this._getOrReturnCtx(e);
|
|
1280
|
-
return
|
|
1280
|
+
return f(a, {
|
|
1281
1281
|
code: d.invalid_type,
|
|
1282
1282
|
expected: h.date,
|
|
1283
1283
|
received: a.parsedType
|
|
@@ -1285,21 +1285,21 @@ class he extends _ {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
if (isNaN(e.data.getTime())) {
|
|
1287
1287
|
const a = this._getOrReturnCtx(e);
|
|
1288
|
-
return
|
|
1288
|
+
return f(a, {
|
|
1289
1289
|
code: d.invalid_date
|
|
1290
1290
|
}), v;
|
|
1291
1291
|
}
|
|
1292
|
-
const n = new
|
|
1292
|
+
const n = new A();
|
|
1293
1293
|
let s;
|
|
1294
1294
|
for (const a of this._def.checks)
|
|
1295
|
-
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s),
|
|
1295
|
+
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1296
1296
|
code: d.too_small,
|
|
1297
1297
|
message: a.message,
|
|
1298
1298
|
inclusive: !0,
|
|
1299
1299
|
exact: !1,
|
|
1300
1300
|
minimum: a.value,
|
|
1301
1301
|
type: "date"
|
|
1302
|
-
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s),
|
|
1302
|
+
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1303
1303
|
code: d.too_big,
|
|
1304
1304
|
message: a.message,
|
|
1305
1305
|
inclusive: !0,
|
|
@@ -1313,7 +1313,7 @@ class he extends _ {
|
|
|
1313
1313
|
};
|
|
1314
1314
|
}
|
|
1315
1315
|
_addCheck(e) {
|
|
1316
|
-
return new
|
|
1316
|
+
return new pe({
|
|
1317
1317
|
...this._def,
|
|
1318
1318
|
checks: [...this._def.checks, e]
|
|
1319
1319
|
});
|
|
@@ -1345,130 +1345,130 @@ class he extends _ {
|
|
|
1345
1345
|
return e != null ? new Date(e) : null;
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
|
|
1348
|
+
pe.create = (r) => new pe({
|
|
1349
1349
|
checks: [],
|
|
1350
1350
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1351
1351
|
typeName: y.ZodDate,
|
|
1352
|
-
...
|
|
1352
|
+
..._(r)
|
|
1353
1353
|
});
|
|
1354
|
-
class
|
|
1354
|
+
class Je extends g {
|
|
1355
1355
|
_parse(e) {
|
|
1356
1356
|
if (this._getType(e) !== h.symbol) {
|
|
1357
1357
|
const n = this._getOrReturnCtx(e);
|
|
1358
|
-
return
|
|
1358
|
+
return f(n, {
|
|
1359
1359
|
code: d.invalid_type,
|
|
1360
1360
|
expected: h.symbol,
|
|
1361
1361
|
received: n.parsedType
|
|
1362
1362
|
}), v;
|
|
1363
1363
|
}
|
|
1364
|
-
return
|
|
1364
|
+
return Z(e.data);
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
|
-
|
|
1367
|
+
Je.create = (r) => new Je({
|
|
1368
1368
|
typeName: y.ZodSymbol,
|
|
1369
|
-
...
|
|
1369
|
+
..._(r)
|
|
1370
1370
|
});
|
|
1371
|
-
class Ae extends
|
|
1371
|
+
class Ae extends g {
|
|
1372
1372
|
_parse(e) {
|
|
1373
1373
|
if (this._getType(e) !== h.undefined) {
|
|
1374
1374
|
const n = this._getOrReturnCtx(e);
|
|
1375
|
-
return
|
|
1375
|
+
return f(n, {
|
|
1376
1376
|
code: d.invalid_type,
|
|
1377
1377
|
expected: h.undefined,
|
|
1378
1378
|
received: n.parsedType
|
|
1379
1379
|
}), v;
|
|
1380
1380
|
}
|
|
1381
|
-
return
|
|
1381
|
+
return Z(e.data);
|
|
1382
1382
|
}
|
|
1383
1383
|
}
|
|
1384
1384
|
Ae.create = (r) => new Ae({
|
|
1385
1385
|
typeName: y.ZodUndefined,
|
|
1386
|
-
...
|
|
1386
|
+
..._(r)
|
|
1387
1387
|
});
|
|
1388
|
-
class Pe extends
|
|
1388
|
+
class Pe extends g {
|
|
1389
1389
|
_parse(e) {
|
|
1390
1390
|
if (this._getType(e) !== h.null) {
|
|
1391
1391
|
const n = this._getOrReturnCtx(e);
|
|
1392
|
-
return
|
|
1392
|
+
return f(n, {
|
|
1393
1393
|
code: d.invalid_type,
|
|
1394
1394
|
expected: h.null,
|
|
1395
1395
|
received: n.parsedType
|
|
1396
1396
|
}), v;
|
|
1397
1397
|
}
|
|
1398
|
-
return
|
|
1398
|
+
return Z(e.data);
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
1401
|
Pe.create = (r) => new Pe({
|
|
1402
1402
|
typeName: y.ZodNull,
|
|
1403
|
-
...
|
|
1403
|
+
..._(r)
|
|
1404
1404
|
});
|
|
1405
|
-
class
|
|
1405
|
+
class be extends g {
|
|
1406
1406
|
constructor() {
|
|
1407
1407
|
super(...arguments), this._any = !0;
|
|
1408
1408
|
}
|
|
1409
1409
|
_parse(e) {
|
|
1410
|
-
return
|
|
1410
|
+
return Z(e.data);
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
|
-
|
|
1413
|
+
be.create = (r) => new be({
|
|
1414
1414
|
typeName: y.ZodAny,
|
|
1415
|
-
...
|
|
1415
|
+
..._(r)
|
|
1416
1416
|
});
|
|
1417
|
-
class
|
|
1417
|
+
class he extends g {
|
|
1418
1418
|
constructor() {
|
|
1419
1419
|
super(...arguments), this._unknown = !0;
|
|
1420
1420
|
}
|
|
1421
1421
|
_parse(e) {
|
|
1422
|
-
return
|
|
1422
|
+
return Z(e.data);
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
|
|
1425
|
+
he.create = (r) => new he({
|
|
1426
1426
|
typeName: y.ZodUnknown,
|
|
1427
|
-
...
|
|
1427
|
+
..._(r)
|
|
1428
1428
|
});
|
|
1429
|
-
class
|
|
1429
|
+
class te extends g {
|
|
1430
1430
|
_parse(e) {
|
|
1431
1431
|
const t = this._getOrReturnCtx(e);
|
|
1432
|
-
return
|
|
1432
|
+
return f(t, {
|
|
1433
1433
|
code: d.invalid_type,
|
|
1434
1434
|
expected: h.never,
|
|
1435
1435
|
received: t.parsedType
|
|
1436
1436
|
}), v;
|
|
1437
1437
|
}
|
|
1438
1438
|
}
|
|
1439
|
-
|
|
1439
|
+
te.create = (r) => new te({
|
|
1440
1440
|
typeName: y.ZodNever,
|
|
1441
|
-
...
|
|
1441
|
+
..._(r)
|
|
1442
1442
|
});
|
|
1443
|
-
class
|
|
1443
|
+
class Ge extends g {
|
|
1444
1444
|
_parse(e) {
|
|
1445
1445
|
if (this._getType(e) !== h.undefined) {
|
|
1446
1446
|
const n = this._getOrReturnCtx(e);
|
|
1447
|
-
return
|
|
1447
|
+
return f(n, {
|
|
1448
1448
|
code: d.invalid_type,
|
|
1449
1449
|
expected: h.void,
|
|
1450
1450
|
received: n.parsedType
|
|
1451
1451
|
}), v;
|
|
1452
1452
|
}
|
|
1453
|
-
return
|
|
1453
|
+
return Z(e.data);
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
|
-
|
|
1456
|
+
Ge.create = (r) => new Ge({
|
|
1457
1457
|
typeName: y.ZodVoid,
|
|
1458
|
-
...
|
|
1458
|
+
..._(r)
|
|
1459
1459
|
});
|
|
1460
|
-
class F extends
|
|
1460
|
+
class F extends g {
|
|
1461
1461
|
_parse(e) {
|
|
1462
1462
|
const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
|
|
1463
1463
|
if (t.parsedType !== h.array)
|
|
1464
|
-
return
|
|
1464
|
+
return f(t, {
|
|
1465
1465
|
code: d.invalid_type,
|
|
1466
1466
|
expected: h.array,
|
|
1467
1467
|
received: t.parsedType
|
|
1468
1468
|
}), v;
|
|
1469
1469
|
if (s.exactLength !== null) {
|
|
1470
1470
|
const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
|
|
1471
|
-
(i || o) && (
|
|
1471
|
+
(i || o) && (f(t, {
|
|
1472
1472
|
code: i ? d.too_big : d.too_small,
|
|
1473
1473
|
minimum: o ? s.exactLength.value : void 0,
|
|
1474
1474
|
maximum: i ? s.exactLength.value : void 0,
|
|
@@ -1478,14 +1478,14 @@ class F extends _ {
|
|
|
1478
1478
|
message: s.exactLength.message
|
|
1479
1479
|
}), n.dirty());
|
|
1480
1480
|
}
|
|
1481
|
-
if (s.minLength !== null && t.data.length < s.minLength.value && (
|
|
1481
|
+
if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
|
|
1482
1482
|
code: d.too_small,
|
|
1483
1483
|
minimum: s.minLength.value,
|
|
1484
1484
|
type: "array",
|
|
1485
1485
|
inclusive: !0,
|
|
1486
1486
|
exact: !1,
|
|
1487
1487
|
message: s.minLength.message
|
|
1488
|
-
}), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (
|
|
1488
|
+
}), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
|
|
1489
1489
|
code: d.too_big,
|
|
1490
1490
|
maximum: s.maxLength.value,
|
|
1491
1491
|
type: "array",
|
|
@@ -1493,9 +1493,9 @@ class F extends _ {
|
|
|
1493
1493
|
exact: !1,
|
|
1494
1494
|
message: s.maxLength.message
|
|
1495
1495
|
}), n.dirty()), t.common.async)
|
|
1496
|
-
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new
|
|
1497
|
-
const a = [...t.data].map((i, o) => s.type._parseSync(new
|
|
1498
|
-
return
|
|
1496
|
+
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new K(t, i, t.path, o)))).then((i) => A.mergeArray(n, i));
|
|
1497
|
+
const a = [...t.data].map((i, o) => s.type._parseSync(new K(t, i, t.path, o)));
|
|
1498
|
+
return A.mergeArray(n, a);
|
|
1499
1499
|
}
|
|
1500
1500
|
get element() {
|
|
1501
1501
|
return this._def.type;
|
|
@@ -1528,14 +1528,14 @@ F.create = (r, e) => new F({
|
|
|
1528
1528
|
maxLength: null,
|
|
1529
1529
|
exactLength: null,
|
|
1530
1530
|
typeName: y.ZodArray,
|
|
1531
|
-
...
|
|
1531
|
+
..._(e)
|
|
1532
1532
|
});
|
|
1533
|
-
function
|
|
1533
|
+
function ve(r) {
|
|
1534
1534
|
if (r instanceof E) {
|
|
1535
1535
|
const e = {};
|
|
1536
1536
|
for (const t in r.shape) {
|
|
1537
1537
|
const n = r.shape[t];
|
|
1538
|
-
e[t] =
|
|
1538
|
+
e[t] = H.create(ve(n));
|
|
1539
1539
|
}
|
|
1540
1540
|
return new E({
|
|
1541
1541
|
...r._def,
|
|
@@ -1543,10 +1543,10 @@ function ye(r) {
|
|
|
1543
1543
|
});
|
|
1544
1544
|
} else return r instanceof F ? new F({
|
|
1545
1545
|
...r._def,
|
|
1546
|
-
type:
|
|
1547
|
-
}) : r instanceof
|
|
1546
|
+
type: ve(r.element)
|
|
1547
|
+
}) : r instanceof H ? H.create(ve(r.unwrap())) : r instanceof de ? de.create(ve(r.unwrap())) : r instanceof Y ? Y.create(r.items.map((e) => ve(e))) : r;
|
|
1548
1548
|
}
|
|
1549
|
-
class E extends
|
|
1549
|
+
class E extends g {
|
|
1550
1550
|
constructor() {
|
|
1551
1551
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1552
1552
|
}
|
|
@@ -1559,26 +1559,26 @@ class E extends _ {
|
|
|
1559
1559
|
_parse(e) {
|
|
1560
1560
|
if (this._getType(e) !== h.object) {
|
|
1561
1561
|
const c = this._getOrReturnCtx(e);
|
|
1562
|
-
return
|
|
1562
|
+
return f(c, {
|
|
1563
1563
|
code: d.invalid_type,
|
|
1564
1564
|
expected: h.object,
|
|
1565
1565
|
received: c.parsedType
|
|
1566
1566
|
}), v;
|
|
1567
1567
|
}
|
|
1568
1568
|
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1569
|
-
if (!(this._def.catchall instanceof
|
|
1569
|
+
if (!(this._def.catchall instanceof te && this._def.unknownKeys === "strip"))
|
|
1570
1570
|
for (const c in s.data)
|
|
1571
1571
|
i.includes(c) || o.push(c);
|
|
1572
1572
|
const u = [];
|
|
1573
1573
|
for (const c of i) {
|
|
1574
|
-
const p = a[c],
|
|
1574
|
+
const p = a[c], k = s.data[c];
|
|
1575
1575
|
u.push({
|
|
1576
1576
|
key: { status: "valid", value: c },
|
|
1577
|
-
value: p._parse(new
|
|
1577
|
+
value: p._parse(new K(s, k, s.path, c)),
|
|
1578
1578
|
alwaysSet: c in s.data
|
|
1579
1579
|
});
|
|
1580
1580
|
}
|
|
1581
|
-
if (this._def.catchall instanceof
|
|
1581
|
+
if (this._def.catchall instanceof te) {
|
|
1582
1582
|
const c = this._def.unknownKeys;
|
|
1583
1583
|
if (c === "passthrough")
|
|
1584
1584
|
for (const p of o)
|
|
@@ -1587,7 +1587,7 @@ class E extends _ {
|
|
|
1587
1587
|
value: { status: "valid", value: s.data[p] }
|
|
1588
1588
|
});
|
|
1589
1589
|
else if (c === "strict")
|
|
1590
|
-
o.length > 0 && (
|
|
1590
|
+
o.length > 0 && (f(s, {
|
|
1591
1591
|
code: d.unrecognized_keys,
|
|
1592
1592
|
keys: o
|
|
1593
1593
|
}), n.dirty());
|
|
@@ -1595,11 +1595,11 @@ class E extends _ {
|
|
|
1595
1595
|
} else {
|
|
1596
1596
|
const c = this._def.catchall;
|
|
1597
1597
|
for (const p of o) {
|
|
1598
|
-
const
|
|
1598
|
+
const k = s.data[p];
|
|
1599
1599
|
u.push({
|
|
1600
1600
|
key: { status: "valid", value: p },
|
|
1601
1601
|
value: c._parse(
|
|
1602
|
-
new
|
|
1602
|
+
new K(s, k, s.path, p)
|
|
1603
1603
|
//, ctx.child(key), value, getParsedType(value)
|
|
1604
1604
|
),
|
|
1605
1605
|
alwaysSet: p in s.data
|
|
@@ -1609,15 +1609,15 @@ class E extends _ {
|
|
|
1609
1609
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1610
1610
|
const c = [];
|
|
1611
1611
|
for (const p of u) {
|
|
1612
|
-
const
|
|
1612
|
+
const k = await p.key, T = await p.value;
|
|
1613
1613
|
c.push({
|
|
1614
|
-
key:
|
|
1614
|
+
key: k,
|
|
1615
1615
|
value: T,
|
|
1616
1616
|
alwaysSet: p.alwaysSet
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
1619
1619
|
return c;
|
|
1620
|
-
}).then((c) =>
|
|
1620
|
+
}).then((c) => A.mergeObjectSync(n, c)) : A.mergeObjectSync(n, u);
|
|
1621
1621
|
}
|
|
1622
1622
|
get shape() {
|
|
1623
1623
|
return this._def.shape();
|
|
@@ -1780,7 +1780,7 @@ class E extends _ {
|
|
|
1780
1780
|
* @deprecated
|
|
1781
1781
|
*/
|
|
1782
1782
|
deepPartial() {
|
|
1783
|
-
return
|
|
1783
|
+
return ve(this);
|
|
1784
1784
|
}
|
|
1785
1785
|
partial(e) {
|
|
1786
1786
|
const t = {};
|
|
@@ -1799,7 +1799,7 @@ class E extends _ {
|
|
|
1799
1799
|
t[n] = this.shape[n];
|
|
1800
1800
|
else {
|
|
1801
1801
|
let a = this.shape[n];
|
|
1802
|
-
for (; a instanceof
|
|
1802
|
+
for (; a instanceof H; )
|
|
1803
1803
|
a = a._def.innerType;
|
|
1804
1804
|
t[n] = a;
|
|
1805
1805
|
}
|
|
@@ -1815,25 +1815,25 @@ class E extends _ {
|
|
|
1815
1815
|
E.create = (r, e) => new E({
|
|
1816
1816
|
shape: () => r,
|
|
1817
1817
|
unknownKeys: "strip",
|
|
1818
|
-
catchall:
|
|
1818
|
+
catchall: te.create(),
|
|
1819
1819
|
typeName: y.ZodObject,
|
|
1820
|
-
...
|
|
1820
|
+
..._(e)
|
|
1821
1821
|
});
|
|
1822
1822
|
E.strictCreate = (r, e) => new E({
|
|
1823
1823
|
shape: () => r,
|
|
1824
1824
|
unknownKeys: "strict",
|
|
1825
|
-
catchall:
|
|
1825
|
+
catchall: te.create(),
|
|
1826
1826
|
typeName: y.ZodObject,
|
|
1827
|
-
...
|
|
1827
|
+
..._(e)
|
|
1828
1828
|
});
|
|
1829
1829
|
E.lazycreate = (r, e) => new E({
|
|
1830
1830
|
shape: r,
|
|
1831
1831
|
unknownKeys: "strip",
|
|
1832
|
-
catchall:
|
|
1832
|
+
catchall: te.create(),
|
|
1833
1833
|
typeName: y.ZodObject,
|
|
1834
|
-
...
|
|
1834
|
+
..._(e)
|
|
1835
1835
|
});
|
|
1836
|
-
class Ze extends
|
|
1836
|
+
class Ze extends g {
|
|
1837
1837
|
_parse(e) {
|
|
1838
1838
|
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
1839
1839
|
function s(a) {
|
|
@@ -1843,8 +1843,8 @@ class Ze extends _ {
|
|
|
1843
1843
|
for (const o of a)
|
|
1844
1844
|
if (o.result.status === "dirty")
|
|
1845
1845
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1846
|
-
const i = a.map((o) => new
|
|
1847
|
-
return
|
|
1846
|
+
const i = a.map((o) => new U(o.ctx.common.issues));
|
|
1847
|
+
return f(t, {
|
|
1848
1848
|
code: d.invalid_union,
|
|
1849
1849
|
unionErrors: i
|
|
1850
1850
|
}), v;
|
|
@@ -1890,8 +1890,8 @@ class Ze extends _ {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
if (a)
|
|
1892
1892
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1893
|
-
const o = i.map((u) => new
|
|
1894
|
-
return
|
|
1893
|
+
const o = i.map((u) => new U(u));
|
|
1894
|
+
return f(t, {
|
|
1895
1895
|
code: d.invalid_union,
|
|
1896
1896
|
unionErrors: o
|
|
1897
1897
|
}), v;
|
|
@@ -1904,14 +1904,14 @@ class Ze extends _ {
|
|
|
1904
1904
|
Ze.create = (r, e) => new Ze({
|
|
1905
1905
|
options: r,
|
|
1906
1906
|
typeName: y.ZodUnion,
|
|
1907
|
-
...
|
|
1907
|
+
..._(e)
|
|
1908
1908
|
});
|
|
1909
|
-
const
|
|
1910
|
-
class
|
|
1909
|
+
const ee = (r) => r instanceof Ue ? ee(r.schema) : r instanceof B ? ee(r.innerType()) : r instanceof De ? [r.value] : r instanceof ce ? r.options : r instanceof Le ? x.objectValues(r.enum) : r instanceof $e ? ee(r._def.innerType) : r instanceof Ae ? [void 0] : r instanceof Pe ? [null] : r instanceof H ? [void 0, ...ee(r.unwrap())] : r instanceof de ? [null, ...ee(r.unwrap())] : r instanceof xt || r instanceof ze ? ee(r.unwrap()) : r instanceof Ve ? ee(r._def.innerType) : [];
|
|
1910
|
+
class tt extends g {
|
|
1911
1911
|
_parse(e) {
|
|
1912
1912
|
const { ctx: t } = this._processInputParams(e);
|
|
1913
1913
|
if (t.parsedType !== h.object)
|
|
1914
|
-
return
|
|
1914
|
+
return f(t, {
|
|
1915
1915
|
code: d.invalid_type,
|
|
1916
1916
|
expected: h.object,
|
|
1917
1917
|
received: t.parsedType
|
|
@@ -1925,7 +1925,7 @@ class rt extends _ {
|
|
|
1925
1925
|
data: t.data,
|
|
1926
1926
|
path: t.path,
|
|
1927
1927
|
parent: t
|
|
1928
|
-
}) : (
|
|
1928
|
+
}) : (f(t, {
|
|
1929
1929
|
code: d.invalid_union_discriminator,
|
|
1930
1930
|
options: Array.from(this.optionsMap.keys()),
|
|
1931
1931
|
path: [n]
|
|
@@ -1951,7 +1951,7 @@ class rt extends _ {
|
|
|
1951
1951
|
static create(e, t, n) {
|
|
1952
1952
|
const s = /* @__PURE__ */ new Map();
|
|
1953
1953
|
for (const a of t) {
|
|
1954
|
-
const i =
|
|
1954
|
+
const i = ee(a.shape[e]);
|
|
1955
1955
|
if (!i.length)
|
|
1956
1956
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1957
1957
|
for (const o of i) {
|
|
@@ -1960,23 +1960,23 @@ class rt extends _ {
|
|
|
1960
1960
|
s.set(o, a);
|
|
1961
1961
|
}
|
|
1962
1962
|
}
|
|
1963
|
-
return new
|
|
1963
|
+
return new tt({
|
|
1964
1964
|
typeName: y.ZodDiscriminatedUnion,
|
|
1965
1965
|
discriminator: e,
|
|
1966
1966
|
options: t,
|
|
1967
1967
|
optionsMap: s,
|
|
1968
|
-
...
|
|
1968
|
+
..._(n)
|
|
1969
1969
|
});
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
|
-
function
|
|
1973
|
-
const t =
|
|
1972
|
+
function _t(r, e) {
|
|
1973
|
+
const t = se(r), n = se(e);
|
|
1974
1974
|
if (r === e)
|
|
1975
1975
|
return { valid: !0, data: r };
|
|
1976
1976
|
if (t === h.object && n === h.object) {
|
|
1977
1977
|
const s = x.objectKeys(e), a = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
|
|
1978
1978
|
for (const o of a) {
|
|
1979
|
-
const u =
|
|
1979
|
+
const u = _t(r[o], e[o]);
|
|
1980
1980
|
if (!u.valid)
|
|
1981
1981
|
return { valid: !1 };
|
|
1982
1982
|
i[o] = u.data;
|
|
@@ -1987,7 +1987,7 @@ function mt(r, e) {
|
|
|
1987
1987
|
return { valid: !1 };
|
|
1988
1988
|
const s = [];
|
|
1989
1989
|
for (let a = 0; a < r.length; a++) {
|
|
1990
|
-
const i = r[a], o = e[a], u =
|
|
1990
|
+
const i = r[a], o = e[a], u = _t(i, o);
|
|
1991
1991
|
if (!u.valid)
|
|
1992
1992
|
return { valid: !1 };
|
|
1993
1993
|
s.push(u.data);
|
|
@@ -1995,13 +1995,13 @@ function mt(r, e) {
|
|
|
1995
1995
|
return { valid: !0, data: s };
|
|
1996
1996
|
} else return t === h.date && n === h.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
1997
1997
|
}
|
|
1998
|
-
class je extends
|
|
1998
|
+
class je extends g {
|
|
1999
1999
|
_parse(e) {
|
|
2000
2000
|
const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
|
|
2001
|
-
if (
|
|
2001
|
+
if (yt(a) || yt(i))
|
|
2002
2002
|
return v;
|
|
2003
|
-
const o =
|
|
2004
|
-
return o.valid ? ((
|
|
2003
|
+
const o = _t(a.value, i.value);
|
|
2004
|
+
return o.valid ? ((vt(a) || vt(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(n, {
|
|
2005
2005
|
code: d.invalid_intersection_types
|
|
2006
2006
|
}), v);
|
|
2007
2007
|
};
|
|
@@ -2031,26 +2031,26 @@ je.create = (r, e, t) => new je({
|
|
|
2031
2031
|
left: r,
|
|
2032
2032
|
right: e,
|
|
2033
2033
|
typeName: y.ZodIntersection,
|
|
2034
|
-
...
|
|
2034
|
+
..._(t)
|
|
2035
2035
|
});
|
|
2036
|
-
class
|
|
2036
|
+
class Y extends g {
|
|
2037
2037
|
_parse(e) {
|
|
2038
2038
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2039
2039
|
if (n.parsedType !== h.array)
|
|
2040
|
-
return
|
|
2040
|
+
return f(n, {
|
|
2041
2041
|
code: d.invalid_type,
|
|
2042
2042
|
expected: h.array,
|
|
2043
2043
|
received: n.parsedType
|
|
2044
2044
|
}), v;
|
|
2045
2045
|
if (n.data.length < this._def.items.length)
|
|
2046
|
-
return
|
|
2046
|
+
return f(n, {
|
|
2047
2047
|
code: d.too_small,
|
|
2048
2048
|
minimum: this._def.items.length,
|
|
2049
2049
|
inclusive: !0,
|
|
2050
2050
|
exact: !1,
|
|
2051
2051
|
type: "array"
|
|
2052
2052
|
}), v;
|
|
2053
|
-
!this._def.rest && n.data.length > this._def.items.length && (
|
|
2053
|
+
!this._def.rest && n.data.length > this._def.items.length && (f(n, {
|
|
2054
2054
|
code: d.too_big,
|
|
2055
2055
|
maximum: this._def.items.length,
|
|
2056
2056
|
inclusive: !0,
|
|
@@ -2059,31 +2059,31 @@ class J extends _ {
|
|
|
2059
2059
|
}), t.dirty());
|
|
2060
2060
|
const a = [...n.data].map((i, o) => {
|
|
2061
2061
|
const u = this._def.items[o] || this._def.rest;
|
|
2062
|
-
return u ? u._parse(new
|
|
2062
|
+
return u ? u._parse(new K(n, i, n.path, o)) : null;
|
|
2063
2063
|
}).filter((i) => !!i);
|
|
2064
|
-
return n.common.async ? Promise.all(a).then((i) =>
|
|
2064
|
+
return n.common.async ? Promise.all(a).then((i) => A.mergeArray(t, i)) : A.mergeArray(t, a);
|
|
2065
2065
|
}
|
|
2066
2066
|
get items() {
|
|
2067
2067
|
return this._def.items;
|
|
2068
2068
|
}
|
|
2069
2069
|
rest(e) {
|
|
2070
|
-
return new
|
|
2070
|
+
return new Y({
|
|
2071
2071
|
...this._def,
|
|
2072
2072
|
rest: e
|
|
2073
2073
|
});
|
|
2074
2074
|
}
|
|
2075
2075
|
}
|
|
2076
|
-
|
|
2076
|
+
Y.create = (r, e) => {
|
|
2077
2077
|
if (!Array.isArray(r))
|
|
2078
2078
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2079
|
-
return new
|
|
2079
|
+
return new Y({
|
|
2080
2080
|
items: r,
|
|
2081
2081
|
typeName: y.ZodTuple,
|
|
2082
2082
|
rest: null,
|
|
2083
|
-
...
|
|
2083
|
+
..._(e)
|
|
2084
2084
|
});
|
|
2085
2085
|
};
|
|
2086
|
-
class Me extends
|
|
2086
|
+
class Me extends g {
|
|
2087
2087
|
get keySchema() {
|
|
2088
2088
|
return this._def.keyType;
|
|
2089
2089
|
}
|
|
@@ -2093,7 +2093,7 @@ class Me extends _ {
|
|
|
2093
2093
|
_parse(e) {
|
|
2094
2094
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2095
2095
|
if (n.parsedType !== h.object)
|
|
2096
|
-
return
|
|
2096
|
+
return f(n, {
|
|
2097
2097
|
code: d.invalid_type,
|
|
2098
2098
|
expected: h.object,
|
|
2099
2099
|
received: n.parsedType
|
|
@@ -2101,30 +2101,30 @@ class Me extends _ {
|
|
|
2101
2101
|
const s = [], a = this._def.keyType, i = this._def.valueType;
|
|
2102
2102
|
for (const o in n.data)
|
|
2103
2103
|
s.push({
|
|
2104
|
-
key: a._parse(new
|
|
2105
|
-
value: i._parse(new
|
|
2104
|
+
key: a._parse(new K(n, o, n.path, o)),
|
|
2105
|
+
value: i._parse(new K(n, n.data[o], n.path, o)),
|
|
2106
2106
|
alwaysSet: o in n.data
|
|
2107
2107
|
});
|
|
2108
|
-
return n.common.async ?
|
|
2108
|
+
return n.common.async ? A.mergeObjectAsync(t, s) : A.mergeObjectSync(t, s);
|
|
2109
2109
|
}
|
|
2110
2110
|
get element() {
|
|
2111
2111
|
return this._def.valueType;
|
|
2112
2112
|
}
|
|
2113
2113
|
static create(e, t, n) {
|
|
2114
|
-
return t instanceof
|
|
2114
|
+
return t instanceof g ? new Me({
|
|
2115
2115
|
keyType: e,
|
|
2116
2116
|
valueType: t,
|
|
2117
2117
|
typeName: y.ZodRecord,
|
|
2118
|
-
...
|
|
2118
|
+
..._(n)
|
|
2119
2119
|
}) : new Me({
|
|
2120
2120
|
keyType: z.create(),
|
|
2121
2121
|
valueType: e,
|
|
2122
2122
|
typeName: y.ZodRecord,
|
|
2123
|
-
...
|
|
2123
|
+
..._(t)
|
|
2124
2124
|
});
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
|
-
class
|
|
2127
|
+
class Xe extends g {
|
|
2128
2128
|
get keySchema() {
|
|
2129
2129
|
return this._def.keyType;
|
|
2130
2130
|
}
|
|
@@ -2134,14 +2134,14 @@ class Qe extends _ {
|
|
|
2134
2134
|
_parse(e) {
|
|
2135
2135
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2136
2136
|
if (n.parsedType !== h.map)
|
|
2137
|
-
return
|
|
2137
|
+
return f(n, {
|
|
2138
2138
|
code: d.invalid_type,
|
|
2139
2139
|
expected: h.map,
|
|
2140
2140
|
received: n.parsedType
|
|
2141
2141
|
}), v;
|
|
2142
2142
|
const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], c) => ({
|
|
2143
|
-
key: s._parse(new
|
|
2144
|
-
value: a._parse(new
|
|
2143
|
+
key: s._parse(new K(n, o, n.path, [c, "key"])),
|
|
2144
|
+
value: a._parse(new K(n, u, n.path, [c, "value"]))
|
|
2145
2145
|
}));
|
|
2146
2146
|
if (n.common.async) {
|
|
2147
2147
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2166,30 +2166,30 @@ class Qe extends _ {
|
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
|
-
|
|
2169
|
+
Xe.create = (r, e, t) => new Xe({
|
|
2170
2170
|
valueType: e,
|
|
2171
2171
|
keyType: r,
|
|
2172
2172
|
typeName: y.ZodMap,
|
|
2173
|
-
...
|
|
2173
|
+
..._(t)
|
|
2174
2174
|
});
|
|
2175
|
-
class
|
|
2175
|
+
class me extends g {
|
|
2176
2176
|
_parse(e) {
|
|
2177
2177
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2178
2178
|
if (n.parsedType !== h.set)
|
|
2179
|
-
return
|
|
2179
|
+
return f(n, {
|
|
2180
2180
|
code: d.invalid_type,
|
|
2181
2181
|
expected: h.set,
|
|
2182
2182
|
received: n.parsedType
|
|
2183
2183
|
}), v;
|
|
2184
2184
|
const s = this._def;
|
|
2185
|
-
s.minSize !== null && n.data.size < s.minSize.value && (
|
|
2185
|
+
s.minSize !== null && n.data.size < s.minSize.value && (f(n, {
|
|
2186
2186
|
code: d.too_small,
|
|
2187
2187
|
minimum: s.minSize.value,
|
|
2188
2188
|
type: "set",
|
|
2189
2189
|
inclusive: !0,
|
|
2190
2190
|
exact: !1,
|
|
2191
2191
|
message: s.minSize.message
|
|
2192
|
-
}), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (
|
|
2192
|
+
}), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (f(n, {
|
|
2193
2193
|
code: d.too_big,
|
|
2194
2194
|
maximum: s.maxSize.value,
|
|
2195
2195
|
type: "set",
|
|
@@ -2207,17 +2207,17 @@ class pe extends _ {
|
|
|
2207
2207
|
}
|
|
2208
2208
|
return { status: t.value, value: c };
|
|
2209
2209
|
}
|
|
2210
|
-
const o = [...n.data.values()].map((u, c) => a._parse(new
|
|
2210
|
+
const o = [...n.data.values()].map((u, c) => a._parse(new K(n, u, n.path, c)));
|
|
2211
2211
|
return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2212
2212
|
}
|
|
2213
2213
|
min(e, t) {
|
|
2214
|
-
return new
|
|
2214
|
+
return new me({
|
|
2215
2215
|
...this._def,
|
|
2216
2216
|
minSize: { value: e, message: m.toString(t) }
|
|
2217
2217
|
});
|
|
2218
2218
|
}
|
|
2219
2219
|
max(e, t) {
|
|
2220
|
-
return new
|
|
2220
|
+
return new me({
|
|
2221
2221
|
...this._def,
|
|
2222
2222
|
maxSize: { value: e, message: m.toString(t) }
|
|
2223
2223
|
});
|
|
@@ -2229,34 +2229,34 @@ class pe extends _ {
|
|
|
2229
2229
|
return this.min(1, e);
|
|
2230
2230
|
}
|
|
2231
2231
|
}
|
|
2232
|
-
|
|
2232
|
+
me.create = (r, e) => new me({
|
|
2233
2233
|
valueType: r,
|
|
2234
2234
|
minSize: null,
|
|
2235
2235
|
maxSize: null,
|
|
2236
2236
|
typeName: y.ZodSet,
|
|
2237
|
-
...
|
|
2237
|
+
..._(e)
|
|
2238
2238
|
});
|
|
2239
|
-
class ge extends
|
|
2239
|
+
class ge extends g {
|
|
2240
2240
|
constructor() {
|
|
2241
2241
|
super(...arguments), this.validate = this.implement;
|
|
2242
2242
|
}
|
|
2243
2243
|
_parse(e) {
|
|
2244
2244
|
const { ctx: t } = this._processInputParams(e);
|
|
2245
2245
|
if (t.parsedType !== h.function)
|
|
2246
|
-
return
|
|
2246
|
+
return f(t, {
|
|
2247
2247
|
code: d.invalid_type,
|
|
2248
2248
|
expected: h.function,
|
|
2249
2249
|
received: t.parsedType
|
|
2250
2250
|
}), v;
|
|
2251
2251
|
function n(o, u) {
|
|
2252
|
-
return
|
|
2252
|
+
return Ke({
|
|
2253
2253
|
data: o,
|
|
2254
2254
|
path: t.path,
|
|
2255
2255
|
errorMaps: [
|
|
2256
2256
|
t.common.contextualErrorMap,
|
|
2257
2257
|
t.schemaErrorMap,
|
|
2258
|
-
|
|
2259
|
-
|
|
2258
|
+
He(),
|
|
2259
|
+
xe
|
|
2260
2260
|
].filter((c) => !!c),
|
|
2261
2261
|
issueData: {
|
|
2262
2262
|
code: d.invalid_arguments,
|
|
@@ -2265,14 +2265,14 @@ class ge extends _ {
|
|
|
2265
2265
|
});
|
|
2266
2266
|
}
|
|
2267
2267
|
function s(o, u) {
|
|
2268
|
-
return
|
|
2268
|
+
return Ke({
|
|
2269
2269
|
data: o,
|
|
2270
2270
|
path: t.path,
|
|
2271
2271
|
errorMaps: [
|
|
2272
2272
|
t.common.contextualErrorMap,
|
|
2273
2273
|
t.schemaErrorMap,
|
|
2274
|
-
|
|
2275
|
-
|
|
2274
|
+
He(),
|
|
2275
|
+
xe
|
|
2276
2276
|
].filter((c) => !!c),
|
|
2277
2277
|
issueData: {
|
|
2278
2278
|
code: d.invalid_return_type,
|
|
@@ -2281,26 +2281,26 @@ class ge extends _ {
|
|
|
2281
2281
|
});
|
|
2282
2282
|
}
|
|
2283
2283
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2284
|
-
if (this._def.returns instanceof
|
|
2284
|
+
if (this._def.returns instanceof ke) {
|
|
2285
2285
|
const o = this;
|
|
2286
|
-
return
|
|
2287
|
-
const c = new
|
|
2288
|
-
throw c.addIssue(n(u,
|
|
2289
|
-
}),
|
|
2290
|
-
return await o._def.returns._def.type.parseAsync(
|
|
2291
|
-
throw c.addIssue(s(
|
|
2286
|
+
return Z(async function(...u) {
|
|
2287
|
+
const c = new U([]), p = await o._def.args.parseAsync(u, a).catch(($) => {
|
|
2288
|
+
throw c.addIssue(n(u, $)), c;
|
|
2289
|
+
}), k = await Reflect.apply(i, this, p);
|
|
2290
|
+
return await o._def.returns._def.type.parseAsync(k, a).catch(($) => {
|
|
2291
|
+
throw c.addIssue(s(k, $)), c;
|
|
2292
2292
|
});
|
|
2293
2293
|
});
|
|
2294
2294
|
} else {
|
|
2295
2295
|
const o = this;
|
|
2296
|
-
return
|
|
2296
|
+
return Z(function(...u) {
|
|
2297
2297
|
const c = o._def.args.safeParse(u, a);
|
|
2298
2298
|
if (!c.success)
|
|
2299
|
-
throw new
|
|
2300
|
-
const p = Reflect.apply(i, this, c.data),
|
|
2301
|
-
if (!
|
|
2302
|
-
throw new
|
|
2303
|
-
return
|
|
2299
|
+
throw new U([n(u, c.error)]);
|
|
2300
|
+
const p = Reflect.apply(i, this, c.data), k = o._def.returns.safeParse(p, a);
|
|
2301
|
+
if (!k.success)
|
|
2302
|
+
throw new U([s(p, k.error)]);
|
|
2303
|
+
return k.data;
|
|
2304
2304
|
});
|
|
2305
2305
|
}
|
|
2306
2306
|
}
|
|
@@ -2313,7 +2313,7 @@ class ge extends _ {
|
|
|
2313
2313
|
args(...e) {
|
|
2314
2314
|
return new ge({
|
|
2315
2315
|
...this._def,
|
|
2316
|
-
args:
|
|
2316
|
+
args: Y.create(e).rest(he.create())
|
|
2317
2317
|
});
|
|
2318
2318
|
}
|
|
2319
2319
|
returns(e) {
|
|
@@ -2330,14 +2330,14 @@ class ge extends _ {
|
|
|
2330
2330
|
}
|
|
2331
2331
|
static create(e, t, n) {
|
|
2332
2332
|
return new ge({
|
|
2333
|
-
args: e ||
|
|
2334
|
-
returns: t ||
|
|
2333
|
+
args: e || Y.create([]).rest(he.create()),
|
|
2334
|
+
returns: t || he.create(),
|
|
2335
2335
|
typeName: y.ZodFunction,
|
|
2336
|
-
...
|
|
2336
|
+
..._(n)
|
|
2337
2337
|
});
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
class
|
|
2340
|
+
class Ue extends g {
|
|
2341
2341
|
get schema() {
|
|
2342
2342
|
return this._def.getter();
|
|
2343
2343
|
}
|
|
@@ -2346,16 +2346,16 @@ class De extends _ {
|
|
|
2346
2346
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
|
-
|
|
2349
|
+
Ue.create = (r, e) => new Ue({
|
|
2350
2350
|
getter: r,
|
|
2351
2351
|
typeName: y.ZodLazy,
|
|
2352
|
-
...
|
|
2352
|
+
..._(e)
|
|
2353
2353
|
});
|
|
2354
|
-
class
|
|
2354
|
+
class De extends g {
|
|
2355
2355
|
_parse(e) {
|
|
2356
2356
|
if (e.data !== this._def.value) {
|
|
2357
2357
|
const t = this._getOrReturnCtx(e);
|
|
2358
|
-
return
|
|
2358
|
+
return f(t, {
|
|
2359
2359
|
received: t.data,
|
|
2360
2360
|
code: d.invalid_literal,
|
|
2361
2361
|
expected: this._def.value
|
|
@@ -2367,40 +2367,40 @@ class Le extends _ {
|
|
|
2367
2367
|
return this._def.value;
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
|
-
|
|
2370
|
+
De.create = (r, e) => new De({
|
|
2371
2371
|
value: r,
|
|
2372
2372
|
typeName: y.ZodLiteral,
|
|
2373
|
-
...
|
|
2373
|
+
..._(e)
|
|
2374
2374
|
});
|
|
2375
2375
|
function zt(r, e) {
|
|
2376
|
-
return new
|
|
2376
|
+
return new ce({
|
|
2377
2377
|
values: r,
|
|
2378
2378
|
typeName: y.ZodEnum,
|
|
2379
|
-
...
|
|
2379
|
+
..._(e)
|
|
2380
2380
|
});
|
|
2381
2381
|
}
|
|
2382
|
-
class
|
|
2382
|
+
class ce extends g {
|
|
2383
2383
|
constructor() {
|
|
2384
|
-
super(...arguments),
|
|
2384
|
+
super(...arguments), Se.set(this, void 0);
|
|
2385
2385
|
}
|
|
2386
2386
|
_parse(e) {
|
|
2387
2387
|
if (typeof e.data != "string") {
|
|
2388
2388
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2389
|
-
return
|
|
2389
|
+
return f(t, {
|
|
2390
2390
|
expected: x.joinValues(n),
|
|
2391
2391
|
received: t.parsedType,
|
|
2392
2392
|
code: d.invalid_type
|
|
2393
2393
|
}), v;
|
|
2394
2394
|
}
|
|
2395
|
-
if (
|
|
2395
|
+
if (Ye(this, Se) || Dt(this, Se, new Set(this._def.values)), !Ye(this, Se).has(e.data)) {
|
|
2396
2396
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2397
|
-
return
|
|
2397
|
+
return f(t, {
|
|
2398
2398
|
received: t.data,
|
|
2399
2399
|
code: d.invalid_enum_value,
|
|
2400
2400
|
options: n
|
|
2401
2401
|
}), v;
|
|
2402
2402
|
}
|
|
2403
|
-
return
|
|
2403
|
+
return Z(e.data);
|
|
2404
2404
|
}
|
|
2405
2405
|
get options() {
|
|
2406
2406
|
return this._def.values;
|
|
@@ -2424,79 +2424,79 @@ class ue extends _ {
|
|
|
2424
2424
|
return e;
|
|
2425
2425
|
}
|
|
2426
2426
|
extract(e, t = this._def) {
|
|
2427
|
-
return
|
|
2427
|
+
return ce.create(e, {
|
|
2428
2428
|
...this._def,
|
|
2429
2429
|
...t
|
|
2430
2430
|
});
|
|
2431
2431
|
}
|
|
2432
2432
|
exclude(e, t = this._def) {
|
|
2433
|
-
return
|
|
2433
|
+
return ce.create(this.options.filter((n) => !e.includes(n)), {
|
|
2434
2434
|
...this._def,
|
|
2435
2435
|
...t
|
|
2436
2436
|
});
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
class
|
|
2439
|
+
Se = /* @__PURE__ */ new WeakMap();
|
|
2440
|
+
ce.create = zt;
|
|
2441
|
+
class Le extends g {
|
|
2442
2442
|
constructor() {
|
|
2443
|
-
super(...arguments),
|
|
2443
|
+
super(...arguments), Ce.set(this, void 0);
|
|
2444
2444
|
}
|
|
2445
2445
|
_parse(e) {
|
|
2446
2446
|
const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
2447
2447
|
if (n.parsedType !== h.string && n.parsedType !== h.number) {
|
|
2448
2448
|
const s = x.objectValues(t);
|
|
2449
|
-
return
|
|
2449
|
+
return f(n, {
|
|
2450
2450
|
expected: x.joinValues(s),
|
|
2451
2451
|
received: n.parsedType,
|
|
2452
2452
|
code: d.invalid_type
|
|
2453
2453
|
}), v;
|
|
2454
2454
|
}
|
|
2455
|
-
if (
|
|
2455
|
+
if (Ye(this, Ce) || Dt(this, Ce, new Set(x.getValidEnumValues(this._def.values))), !Ye(this, Ce).has(e.data)) {
|
|
2456
2456
|
const s = x.objectValues(t);
|
|
2457
|
-
return
|
|
2457
|
+
return f(n, {
|
|
2458
2458
|
received: n.data,
|
|
2459
2459
|
code: d.invalid_enum_value,
|
|
2460
2460
|
options: s
|
|
2461
2461
|
}), v;
|
|
2462
2462
|
}
|
|
2463
|
-
return
|
|
2463
|
+
return Z(e.data);
|
|
2464
2464
|
}
|
|
2465
2465
|
get enum() {
|
|
2466
2466
|
return this._def.values;
|
|
2467
2467
|
}
|
|
2468
2468
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2469
|
+
Ce = /* @__PURE__ */ new WeakMap();
|
|
2470
|
+
Le.create = (r, e) => new Le({
|
|
2471
2471
|
values: r,
|
|
2472
2472
|
typeName: y.ZodNativeEnum,
|
|
2473
|
-
...
|
|
2473
|
+
..._(e)
|
|
2474
2474
|
});
|
|
2475
|
-
class
|
|
2475
|
+
class ke extends g {
|
|
2476
2476
|
unwrap() {
|
|
2477
2477
|
return this._def.type;
|
|
2478
2478
|
}
|
|
2479
2479
|
_parse(e) {
|
|
2480
2480
|
const { ctx: t } = this._processInputParams(e);
|
|
2481
2481
|
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
2482
|
-
return
|
|
2482
|
+
return f(t, {
|
|
2483
2483
|
code: d.invalid_type,
|
|
2484
2484
|
expected: h.promise,
|
|
2485
2485
|
received: t.parsedType
|
|
2486
2486
|
}), v;
|
|
2487
2487
|
const n = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
2488
|
-
return
|
|
2488
|
+
return Z(n.then((s) => this._def.type.parseAsync(s, {
|
|
2489
2489
|
path: t.path,
|
|
2490
2490
|
errorMap: t.common.contextualErrorMap
|
|
2491
2491
|
})));
|
|
2492
2492
|
}
|
|
2493
2493
|
}
|
|
2494
|
-
|
|
2494
|
+
ke.create = (r, e) => new ke({
|
|
2495
2495
|
type: r,
|
|
2496
2496
|
typeName: y.ZodPromise,
|
|
2497
|
-
...
|
|
2497
|
+
..._(e)
|
|
2498
2498
|
});
|
|
2499
|
-
class B extends
|
|
2499
|
+
class B extends g {
|
|
2500
2500
|
innerType() {
|
|
2501
2501
|
return this._def.schema;
|
|
2502
2502
|
}
|
|
@@ -2506,7 +2506,7 @@ class B extends _ {
|
|
|
2506
2506
|
_parse(e) {
|
|
2507
2507
|
const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
2508
2508
|
addIssue: (i) => {
|
|
2509
|
-
|
|
2509
|
+
f(n, i), i.fatal ? t.abort() : t.dirty();
|
|
2510
2510
|
},
|
|
2511
2511
|
get path() {
|
|
2512
2512
|
return n.path;
|
|
@@ -2523,7 +2523,7 @@ class B extends _ {
|
|
|
2523
2523
|
path: n.path,
|
|
2524
2524
|
parent: n
|
|
2525
2525
|
});
|
|
2526
|
-
return u.status === "aborted" ? v : u.status === "dirty" || t.value === "dirty" ?
|
|
2526
|
+
return u.status === "aborted" ? v : u.status === "dirty" || t.value === "dirty" ? _e(u.value) : u;
|
|
2527
2527
|
});
|
|
2528
2528
|
{
|
|
2529
2529
|
if (t.value === "aborted")
|
|
@@ -2533,7 +2533,7 @@ class B extends _ {
|
|
|
2533
2533
|
path: n.path,
|
|
2534
2534
|
parent: n
|
|
2535
2535
|
});
|
|
2536
|
-
return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ?
|
|
2536
|
+
return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? _e(o.value) : o;
|
|
2537
2537
|
}
|
|
2538
2538
|
}
|
|
2539
2539
|
if (s.type === "refinement") {
|
|
@@ -2577,41 +2577,41 @@ B.create = (r, e, t) => new B({
|
|
|
2577
2577
|
schema: r,
|
|
2578
2578
|
typeName: y.ZodEffects,
|
|
2579
2579
|
effect: e,
|
|
2580
|
-
...
|
|
2580
|
+
..._(t)
|
|
2581
2581
|
});
|
|
2582
2582
|
B.createWithPreprocess = (r, e, t) => new B({
|
|
2583
2583
|
schema: e,
|
|
2584
2584
|
effect: { type: "preprocess", transform: r },
|
|
2585
2585
|
typeName: y.ZodEffects,
|
|
2586
|
-
...
|
|
2586
|
+
..._(t)
|
|
2587
2587
|
});
|
|
2588
|
-
class
|
|
2588
|
+
class H extends g {
|
|
2589
2589
|
_parse(e) {
|
|
2590
|
-
return this._getType(e) === h.undefined ?
|
|
2590
|
+
return this._getType(e) === h.undefined ? Z(void 0) : this._def.innerType._parse(e);
|
|
2591
2591
|
}
|
|
2592
2592
|
unwrap() {
|
|
2593
2593
|
return this._def.innerType;
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
2596
|
-
|
|
2596
|
+
H.create = (r, e) => new H({
|
|
2597
2597
|
innerType: r,
|
|
2598
2598
|
typeName: y.ZodOptional,
|
|
2599
|
-
...
|
|
2599
|
+
..._(e)
|
|
2600
2600
|
});
|
|
2601
|
-
class
|
|
2601
|
+
class de extends g {
|
|
2602
2602
|
_parse(e) {
|
|
2603
|
-
return this._getType(e) === h.null ?
|
|
2603
|
+
return this._getType(e) === h.null ? Z(null) : this._def.innerType._parse(e);
|
|
2604
2604
|
}
|
|
2605
2605
|
unwrap() {
|
|
2606
2606
|
return this._def.innerType;
|
|
2607
2607
|
}
|
|
2608
2608
|
}
|
|
2609
|
-
|
|
2609
|
+
de.create = (r, e) => new de({
|
|
2610
2610
|
innerType: r,
|
|
2611
2611
|
typeName: y.ZodNullable,
|
|
2612
|
-
...
|
|
2612
|
+
..._(e)
|
|
2613
2613
|
});
|
|
2614
|
-
class $e extends
|
|
2614
|
+
class $e extends g {
|
|
2615
2615
|
_parse(e) {
|
|
2616
2616
|
const { ctx: t } = this._processInputParams(e);
|
|
2617
2617
|
let n = t.data;
|
|
@@ -2629,9 +2629,9 @@ $e.create = (r, e) => new $e({
|
|
|
2629
2629
|
innerType: r,
|
|
2630
2630
|
typeName: y.ZodDefault,
|
|
2631
2631
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2632
|
-
...
|
|
2632
|
+
..._(e)
|
|
2633
2633
|
});
|
|
2634
|
-
class Ve extends
|
|
2634
|
+
class Ve extends g {
|
|
2635
2635
|
_parse(e) {
|
|
2636
2636
|
const { ctx: t } = this._processInputParams(e), n = {
|
|
2637
2637
|
...t,
|
|
@@ -2650,7 +2650,7 @@ class Ve extends _ {
|
|
|
2650
2650
|
status: "valid",
|
|
2651
2651
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2652
2652
|
get error() {
|
|
2653
|
-
return new
|
|
2653
|
+
return new U(n.common.issues);
|
|
2654
2654
|
},
|
|
2655
2655
|
input: n.data
|
|
2656
2656
|
})
|
|
@@ -2658,7 +2658,7 @@ class Ve extends _ {
|
|
|
2658
2658
|
status: "valid",
|
|
2659
2659
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2660
2660
|
get error() {
|
|
2661
|
-
return new
|
|
2661
|
+
return new U(n.common.issues);
|
|
2662
2662
|
},
|
|
2663
2663
|
input: n.data
|
|
2664
2664
|
})
|
|
@@ -2672,13 +2672,13 @@ Ve.create = (r, e) => new Ve({
|
|
|
2672
2672
|
innerType: r,
|
|
2673
2673
|
typeName: y.ZodCatch,
|
|
2674
2674
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2675
|
-
...
|
|
2675
|
+
..._(e)
|
|
2676
2676
|
});
|
|
2677
|
-
class
|
|
2677
|
+
class Qe extends g {
|
|
2678
2678
|
_parse(e) {
|
|
2679
2679
|
if (this._getType(e) !== h.nan) {
|
|
2680
2680
|
const n = this._getOrReturnCtx(e);
|
|
2681
|
-
return
|
|
2681
|
+
return f(n, {
|
|
2682
2682
|
code: d.invalid_type,
|
|
2683
2683
|
expected: h.nan,
|
|
2684
2684
|
received: n.parsedType
|
|
@@ -2687,12 +2687,12 @@ class et extends _ {
|
|
|
2687
2687
|
return { status: "valid", value: e.data };
|
|
2688
2688
|
}
|
|
2689
2689
|
}
|
|
2690
|
-
|
|
2690
|
+
Qe.create = (r) => new Qe({
|
|
2691
2691
|
typeName: y.ZodNaN,
|
|
2692
|
-
...
|
|
2692
|
+
..._(r)
|
|
2693
2693
|
});
|
|
2694
|
-
const
|
|
2695
|
-
class
|
|
2694
|
+
const Br = Symbol("zod_brand");
|
|
2695
|
+
class xt extends g {
|
|
2696
2696
|
_parse(e) {
|
|
2697
2697
|
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
2698
2698
|
return this._def.type._parse({
|
|
@@ -2705,7 +2705,7 @@ class vt extends _ {
|
|
|
2705
2705
|
return this._def.type;
|
|
2706
2706
|
}
|
|
2707
2707
|
}
|
|
2708
|
-
class Fe extends
|
|
2708
|
+
class Fe extends g {
|
|
2709
2709
|
_parse(e) {
|
|
2710
2710
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2711
2711
|
if (n.common.async)
|
|
@@ -2715,7 +2715,7 @@ class Fe extends _ {
|
|
|
2715
2715
|
path: n.path,
|
|
2716
2716
|
parent: n
|
|
2717
2717
|
});
|
|
2718
|
-
return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(),
|
|
2718
|
+
return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(), _e(a.value)) : this._def.out._parseAsync({
|
|
2719
2719
|
data: a.value,
|
|
2720
2720
|
path: n.path,
|
|
2721
2721
|
parent: n
|
|
@@ -2745,7 +2745,7 @@ class Fe extends _ {
|
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
2747
|
}
|
|
2748
|
-
class ze extends
|
|
2748
|
+
class ze extends g {
|
|
2749
2749
|
_parse(e) {
|
|
2750
2750
|
const t = this._def.innerType._parse(e), n = (s) => (Re(s) && (s.value = Object.freeze(s.value)), s);
|
|
2751
2751
|
return Ie(t) ? t.then((s) => n(s)) : n(t);
|
|
@@ -2757,177 +2757,178 @@ class ze extends _ {
|
|
|
2757
2757
|
ze.create = (r, e) => new ze({
|
|
2758
2758
|
innerType: r,
|
|
2759
2759
|
typeName: y.ZodReadonly,
|
|
2760
|
-
...
|
|
2760
|
+
..._(e)
|
|
2761
2761
|
});
|
|
2762
2762
|
function Ft(r, e = {}, t) {
|
|
2763
|
-
return r ?
|
|
2763
|
+
return r ? be.create().superRefine((n, s) => {
|
|
2764
2764
|
var a, i;
|
|
2765
2765
|
if (!r(n)) {
|
|
2766
2766
|
const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, c = typeof o == "string" ? { message: o } : o;
|
|
2767
2767
|
s.addIssue({ code: "custom", ...c, fatal: u });
|
|
2768
2768
|
}
|
|
2769
|
-
}) :
|
|
2769
|
+
}) : be.create();
|
|
2770
2770
|
}
|
|
2771
|
-
const
|
|
2771
|
+
const Wr = {
|
|
2772
2772
|
object: E.lazycreate
|
|
2773
2773
|
};
|
|
2774
2774
|
var y;
|
|
2775
2775
|
(function(r) {
|
|
2776
2776
|
r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
|
|
2777
2777
|
})(y || (y = {}));
|
|
2778
|
-
const
|
|
2778
|
+
const qr = (r, e = {
|
|
2779
2779
|
message: `Input not instance of ${r.name}`
|
|
2780
|
-
}) => Ft((t) => t instanceof r, e), Bt = z.create, Wt =
|
|
2780
|
+
}) => Ft((t) => t instanceof r, e), Bt = z.create, Wt = ie.create, Hr = Qe.create, Kr = oe.create, qt = Ne.create, Yr = pe.create, Jr = Je.create, Gr = Ae.create, Xr = Pe.create, Qr = be.create, en = he.create, tn = te.create, rn = Ge.create, nn = F.create, sn = E.create, an = E.strictCreate, on = Ze.create, cn = tt.create, dn = je.create, un = Y.create, ln = Me.create, fn = Xe.create, hn = me.create, pn = ge.create, mn = Ue.create, yn = De.create, vn = ce.create, _n = Le.create, gn = ke.create, It = B.create, xn = H.create, bn = de.create, kn = B.createWithPreprocess, wn = Fe.create, En = () => Bt().optional(), Tn = () => Wt().optional(), Sn = () => qt().optional(), Cn = {
|
|
2781
2781
|
string: (r) => z.create({ ...r, coerce: !0 }),
|
|
2782
|
-
number: (r) =>
|
|
2782
|
+
number: (r) => ie.create({ ...r, coerce: !0 }),
|
|
2783
2783
|
boolean: (r) => Ne.create({
|
|
2784
2784
|
...r,
|
|
2785
2785
|
coerce: !0
|
|
2786
2786
|
}),
|
|
2787
|
-
bigint: (r) =>
|
|
2788
|
-
date: (r) =>
|
|
2789
|
-
},
|
|
2790
|
-
var
|
|
2787
|
+
bigint: (r) => oe.create({ ...r, coerce: !0 }),
|
|
2788
|
+
date: (r) => pe.create({ ...r, coerce: !0 })
|
|
2789
|
+
}, On = v;
|
|
2790
|
+
var l = /* @__PURE__ */ Object.freeze({
|
|
2791
2791
|
__proto__: null,
|
|
2792
|
-
defaultErrorMap:
|
|
2792
|
+
defaultErrorMap: xe,
|
|
2793
2793
|
setErrorMap: Cr,
|
|
2794
|
-
getErrorMap:
|
|
2795
|
-
makeIssue:
|
|
2796
|
-
EMPTY_PATH:
|
|
2797
|
-
addIssueToContext:
|
|
2798
|
-
ParseStatus:
|
|
2794
|
+
getErrorMap: He,
|
|
2795
|
+
makeIssue: Ke,
|
|
2796
|
+
EMPTY_PATH: Or,
|
|
2797
|
+
addIssueToContext: f,
|
|
2798
|
+
ParseStatus: A,
|
|
2799
2799
|
INVALID: v,
|
|
2800
|
-
DIRTY:
|
|
2801
|
-
OK:
|
|
2802
|
-
isAborted:
|
|
2803
|
-
isDirty:
|
|
2800
|
+
DIRTY: _e,
|
|
2801
|
+
OK: Z,
|
|
2802
|
+
isAborted: yt,
|
|
2803
|
+
isDirty: vt,
|
|
2804
2804
|
isValid: Re,
|
|
2805
2805
|
isAsync: Ie,
|
|
2806
2806
|
get util() {
|
|
2807
2807
|
return x;
|
|
2808
2808
|
},
|
|
2809
2809
|
get objectUtil() {
|
|
2810
|
-
return
|
|
2810
|
+
return mt;
|
|
2811
2811
|
},
|
|
2812
2812
|
ZodParsedType: h,
|
|
2813
|
-
getParsedType:
|
|
2814
|
-
ZodType:
|
|
2813
|
+
getParsedType: se,
|
|
2814
|
+
ZodType: g,
|
|
2815
2815
|
datetimeRegex: Vt,
|
|
2816
2816
|
ZodString: z,
|
|
2817
|
-
ZodNumber:
|
|
2818
|
-
ZodBigInt:
|
|
2817
|
+
ZodNumber: ie,
|
|
2818
|
+
ZodBigInt: oe,
|
|
2819
2819
|
ZodBoolean: Ne,
|
|
2820
|
-
ZodDate:
|
|
2821
|
-
ZodSymbol:
|
|
2820
|
+
ZodDate: pe,
|
|
2821
|
+
ZodSymbol: Je,
|
|
2822
2822
|
ZodUndefined: Ae,
|
|
2823
2823
|
ZodNull: Pe,
|
|
2824
|
-
ZodAny:
|
|
2825
|
-
ZodUnknown:
|
|
2826
|
-
ZodNever:
|
|
2827
|
-
ZodVoid:
|
|
2824
|
+
ZodAny: be,
|
|
2825
|
+
ZodUnknown: he,
|
|
2826
|
+
ZodNever: te,
|
|
2827
|
+
ZodVoid: Ge,
|
|
2828
2828
|
ZodArray: F,
|
|
2829
2829
|
ZodObject: E,
|
|
2830
2830
|
ZodUnion: Ze,
|
|
2831
|
-
ZodDiscriminatedUnion:
|
|
2831
|
+
ZodDiscriminatedUnion: tt,
|
|
2832
2832
|
ZodIntersection: je,
|
|
2833
|
-
ZodTuple:
|
|
2833
|
+
ZodTuple: Y,
|
|
2834
2834
|
ZodRecord: Me,
|
|
2835
|
-
ZodMap:
|
|
2836
|
-
ZodSet:
|
|
2835
|
+
ZodMap: Xe,
|
|
2836
|
+
ZodSet: me,
|
|
2837
2837
|
ZodFunction: ge,
|
|
2838
|
-
ZodLazy:
|
|
2839
|
-
ZodLiteral:
|
|
2840
|
-
ZodEnum:
|
|
2841
|
-
ZodNativeEnum:
|
|
2842
|
-
ZodPromise:
|
|
2838
|
+
ZodLazy: Ue,
|
|
2839
|
+
ZodLiteral: De,
|
|
2840
|
+
ZodEnum: ce,
|
|
2841
|
+
ZodNativeEnum: Le,
|
|
2842
|
+
ZodPromise: ke,
|
|
2843
2843
|
ZodEffects: B,
|
|
2844
2844
|
ZodTransformer: B,
|
|
2845
|
-
ZodOptional:
|
|
2846
|
-
ZodNullable:
|
|
2845
|
+
ZodOptional: H,
|
|
2846
|
+
ZodNullable: de,
|
|
2847
2847
|
ZodDefault: $e,
|
|
2848
2848
|
ZodCatch: Ve,
|
|
2849
|
-
ZodNaN:
|
|
2850
|
-
BRAND:
|
|
2851
|
-
ZodBranded:
|
|
2849
|
+
ZodNaN: Qe,
|
|
2850
|
+
BRAND: Br,
|
|
2851
|
+
ZodBranded: xt,
|
|
2852
2852
|
ZodPipeline: Fe,
|
|
2853
2853
|
ZodReadonly: ze,
|
|
2854
2854
|
custom: Ft,
|
|
2855
|
-
Schema:
|
|
2856
|
-
ZodSchema:
|
|
2857
|
-
late:
|
|
2855
|
+
Schema: g,
|
|
2856
|
+
ZodSchema: g,
|
|
2857
|
+
late: Wr,
|
|
2858
2858
|
get ZodFirstPartyTypeKind() {
|
|
2859
2859
|
return y;
|
|
2860
2860
|
},
|
|
2861
2861
|
coerce: Cn,
|
|
2862
|
-
any:
|
|
2863
|
-
array:
|
|
2864
|
-
bigint:
|
|
2862
|
+
any: Qr,
|
|
2863
|
+
array: nn,
|
|
2864
|
+
bigint: Kr,
|
|
2865
2865
|
boolean: qt,
|
|
2866
|
-
date:
|
|
2867
|
-
discriminatedUnion:
|
|
2866
|
+
date: Yr,
|
|
2867
|
+
discriminatedUnion: cn,
|
|
2868
2868
|
effect: It,
|
|
2869
|
-
enum:
|
|
2870
|
-
function:
|
|
2871
|
-
instanceof:
|
|
2872
|
-
intersection:
|
|
2873
|
-
lazy:
|
|
2874
|
-
literal:
|
|
2875
|
-
map:
|
|
2876
|
-
nan:
|
|
2877
|
-
nativeEnum:
|
|
2878
|
-
never:
|
|
2879
|
-
null:
|
|
2880
|
-
nullable:
|
|
2869
|
+
enum: vn,
|
|
2870
|
+
function: pn,
|
|
2871
|
+
instanceof: qr,
|
|
2872
|
+
intersection: dn,
|
|
2873
|
+
lazy: mn,
|
|
2874
|
+
literal: yn,
|
|
2875
|
+
map: fn,
|
|
2876
|
+
nan: Hr,
|
|
2877
|
+
nativeEnum: _n,
|
|
2878
|
+
never: tn,
|
|
2879
|
+
null: Xr,
|
|
2880
|
+
nullable: bn,
|
|
2881
2881
|
number: Wt,
|
|
2882
|
-
object:
|
|
2883
|
-
oboolean:
|
|
2884
|
-
onumber:
|
|
2885
|
-
optional:
|
|
2886
|
-
ostring:
|
|
2887
|
-
pipeline:
|
|
2888
|
-
preprocess:
|
|
2882
|
+
object: sn,
|
|
2883
|
+
oboolean: Sn,
|
|
2884
|
+
onumber: Tn,
|
|
2885
|
+
optional: xn,
|
|
2886
|
+
ostring: En,
|
|
2887
|
+
pipeline: wn,
|
|
2888
|
+
preprocess: kn,
|
|
2889
2889
|
promise: gn,
|
|
2890
|
-
record:
|
|
2891
|
-
set:
|
|
2892
|
-
strictObject:
|
|
2890
|
+
record: ln,
|
|
2891
|
+
set: hn,
|
|
2892
|
+
strictObject: an,
|
|
2893
2893
|
string: Bt,
|
|
2894
|
-
symbol:
|
|
2894
|
+
symbol: Jr,
|
|
2895
2895
|
transformer: It,
|
|
2896
|
-
tuple:
|
|
2897
|
-
undefined:
|
|
2898
|
-
union:
|
|
2899
|
-
unknown:
|
|
2900
|
-
void:
|
|
2901
|
-
NEVER:
|
|
2896
|
+
tuple: un,
|
|
2897
|
+
undefined: Gr,
|
|
2898
|
+
union: on,
|
|
2899
|
+
unknown: en,
|
|
2900
|
+
void: rn,
|
|
2901
|
+
NEVER: On,
|
|
2902
2902
|
ZodIssueCode: d,
|
|
2903
|
-
quotelessJson:
|
|
2904
|
-
ZodError:
|
|
2903
|
+
quotelessJson: Sr,
|
|
2904
|
+
ZodError: U
|
|
2905
2905
|
});
|
|
2906
|
-
const
|
|
2907
|
-
var
|
|
2908
|
-
const Ht =
|
|
2906
|
+
const L = l.string().trim().min(1, { message: "Cannot be blank" }), M = l.string().trim().optional(), Nt = (r) => l.nullable(r.optional());
|
|
2907
|
+
var et = /* @__PURE__ */ ((r) => (r.FIRST_NAME = "firstName", r.LAST_NAME = "lastName", r.EMAIL = "email", r.ZIP_CODE = "zipCode", r.CITY = "city", r.STATE = "state", r.COUNTRY = "country", r.ADDRESS = "address", r.PHONE = "phone", r.PROMOTION_CODE = "promotionCode", r))(et || {});
|
|
2908
|
+
const Ht = l.nativeEnum(et);
|
|
2909
2909
|
var Kt = /* @__PURE__ */ ((r) => (r.CARD_NUMBER = "cardNumber", r.CARD_EXPIRY = "cardExpiry", r.CARD_CVC = "cardCvc", r))(Kt || {});
|
|
2910
|
-
const Yt =
|
|
2911
|
-
provider:
|
|
2912
|
-
processor_name: Nt(
|
|
2913
|
-
metadata: Nt(
|
|
2910
|
+
const Yt = l.nativeEnum(Kt), Rn = l.union([Ht, Yt]), Jt = l.object({
|
|
2911
|
+
provider: l.string(),
|
|
2912
|
+
processor_name: Nt(l.string()),
|
|
2913
|
+
metadata: Nt(l.record(l.string(), l.any()))
|
|
2914
2914
|
});
|
|
2915
|
-
|
|
2916
|
-
cardNumber:
|
|
2917
|
-
expiry:
|
|
2918
|
-
cvc:
|
|
2915
|
+
l.object({
|
|
2916
|
+
cardNumber: M,
|
|
2917
|
+
expiry: M,
|
|
2918
|
+
cvc: M
|
|
2919
2919
|
});
|
|
2920
|
-
|
|
2921
|
-
backgroundColor:
|
|
2922
|
-
color:
|
|
2923
|
-
fontFamily:
|
|
2924
|
-
fontSize:
|
|
2925
|
-
fontWeight:
|
|
2926
|
-
margin:
|
|
2927
|
-
padding:
|
|
2920
|
+
l.object({
|
|
2921
|
+
backgroundColor: M,
|
|
2922
|
+
color: M,
|
|
2923
|
+
fontFamily: M,
|
|
2924
|
+
fontSize: M,
|
|
2925
|
+
fontWeight: M,
|
|
2926
|
+
margin: M,
|
|
2927
|
+
padding: M
|
|
2928
2928
|
});
|
|
2929
|
-
const
|
|
2929
|
+
const b = l.enum([
|
|
2930
2930
|
// Element -> Form
|
|
2931
|
+
"LAYOUT",
|
|
2931
2932
|
"LOADED",
|
|
2932
2933
|
"BLUR",
|
|
2933
2934
|
"FOCUS",
|
|
@@ -2941,76 +2942,84 @@ const k = f.enum([
|
|
|
2941
2942
|
"VALIDATION_ERROR",
|
|
2942
2943
|
"TOKENIZE_ERROR",
|
|
2943
2944
|
"CHECKOUT_ERROR",
|
|
2945
|
+
"SETUP_PAYMENT_METHOD_SUCCESS",
|
|
2944
2946
|
// Form -> Element
|
|
2945
2947
|
"TOKENIZE",
|
|
2946
2948
|
"CHECKOUT",
|
|
2947
2949
|
"START_PAYMENT_FLOW"
|
|
2948
|
-
]),
|
|
2949
|
-
type:
|
|
2950
|
+
]), In = b.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), Nn = l.object({ type: In }), An = b.extract(["BLUR", "FOCUS", "CHANGE"]), Pn = l.object({
|
|
2951
|
+
type: An,
|
|
2950
2952
|
elementType: Yt
|
|
2951
|
-
}),
|
|
2952
|
-
type:
|
|
2953
|
-
message:
|
|
2954
|
-
}),
|
|
2955
|
-
type:
|
|
2956
|
-
elementType:
|
|
2957
|
-
errors:
|
|
2958
|
-
}), Dn =
|
|
2959
|
-
type:
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2953
|
+
}), Zn = b.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), jn = l.object({
|
|
2954
|
+
type: Zn,
|
|
2955
|
+
message: L
|
|
2956
|
+
}), Mn = b.extract(["VALIDATION_ERROR"]), Un = l.object({
|
|
2957
|
+
type: Mn,
|
|
2958
|
+
elementType: Rn,
|
|
2959
|
+
errors: l.array(l.string())
|
|
2960
|
+
}), Dn = l.object({
|
|
2961
|
+
type: l.literal(b.enum.LAYOUT),
|
|
2962
|
+
height: L
|
|
2963
|
+
}), Ln = l.object({
|
|
2964
|
+
type: l.literal(b.enum.LOADED),
|
|
2965
|
+
sessionId: L,
|
|
2966
|
+
totalAmountAtoms: l.number(),
|
|
2967
|
+
currency: M,
|
|
2968
|
+
checkoutPaymentMethods: l.array(Jt)
|
|
2969
|
+
}), $n = l.object({
|
|
2970
|
+
type: l.literal(b.enum.PAYMENT_FLOW_STARTED),
|
|
2971
|
+
nextActionMetadata: l.record(l.string(), l.any()),
|
|
2972
|
+
paymentFlowMetadata: l.any().optional(),
|
|
2973
|
+
startPFMetadata: l.optional(l.record(l.string(), l.any()))
|
|
2974
|
+
}), Vn = l.object({
|
|
2975
|
+
type: l.literal(b.enum.SETUP_PAYMENT_METHOD_SUCCESS),
|
|
2976
|
+
paymentMethodId: l.string()
|
|
2977
|
+
}), zn = l.object({
|
|
2978
|
+
firstName: L,
|
|
2979
|
+
lastName: L,
|
|
2980
|
+
email: L,
|
|
2981
|
+
zipCode: L,
|
|
2982
|
+
country: L,
|
|
2983
|
+
promotionCode: M
|
|
2984
|
+
}), Fn = b.extract(["TOKENIZE", "CHECKOUT", "START_PAYMENT_FLOW"]), Gt = l.object({
|
|
2985
|
+
type: Fn,
|
|
2986
|
+
sessionId: L,
|
|
2980
2987
|
checkoutPaymentMethod: Jt,
|
|
2981
|
-
paymentFlowMetadata:
|
|
2982
|
-
doNotUseLegacyCCFlow:
|
|
2983
|
-
existingCCPMId:
|
|
2984
|
-
}).extend(
|
|
2985
|
-
type:
|
|
2986
|
-
isReadyForCheckout:
|
|
2987
|
-
}),
|
|
2988
|
-
type:
|
|
2989
|
-
invoiceUrls:
|
|
2990
|
-
subscriptionIds:
|
|
2991
|
-
customerId:
|
|
2992
|
-
}),
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2988
|
+
paymentFlowMetadata: l.any().optional(),
|
|
2989
|
+
doNotUseLegacyCCFlow: l.boolean().optional(),
|
|
2990
|
+
existingCCPMId: M
|
|
2991
|
+
}).extend(zn.shape), Bn = l.object({
|
|
2992
|
+
type: l.literal(b.enum.TOKENIZE_SUCCESS),
|
|
2993
|
+
isReadyForCheckout: l.boolean()
|
|
2994
|
+
}), Wn = l.object({
|
|
2995
|
+
type: l.literal(b.enum.CHECKOUT_SUCCESS),
|
|
2996
|
+
invoiceUrls: l.array(l.string()),
|
|
2997
|
+
subscriptionIds: l.array(l.string()),
|
|
2998
|
+
customerId: l.string()
|
|
2999
|
+
}), qn = l.discriminatedUnion("type", [
|
|
3000
|
+
Nn,
|
|
3001
|
+
Pn,
|
|
3002
|
+
jn,
|
|
3003
|
+
Un,
|
|
2997
3004
|
Dn,
|
|
3005
|
+
Ln,
|
|
2998
3006
|
Gt,
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
+
Bn,
|
|
3008
|
+
Wn,
|
|
3009
|
+
$n,
|
|
3010
|
+
Vn
|
|
3011
|
+
]), Hn = l.object({
|
|
3012
|
+
payload: qn,
|
|
3013
|
+
nonce: L,
|
|
3014
|
+
formId: L,
|
|
3015
|
+
elementId: L
|
|
3007
3016
|
});
|
|
3008
|
-
|
|
3009
|
-
isLoading:
|
|
3010
|
-
isAvailable:
|
|
3011
|
-
startFlow:
|
|
3017
|
+
l.object({
|
|
3018
|
+
isLoading: l.boolean(),
|
|
3019
|
+
isAvailable: l.boolean(),
|
|
3020
|
+
startFlow: l.function(l.tuple([]), l.void())
|
|
3012
3021
|
});
|
|
3013
|
-
const
|
|
3022
|
+
const Kn = (r) => {
|
|
3014
3023
|
const e = {};
|
|
3015
3024
|
return Object.entries(r).forEach(([t, n]) => {
|
|
3016
3025
|
try {
|
|
@@ -3023,7 +3032,7 @@ const Wn = (r) => {
|
|
|
3023
3032
|
}, Xt = (r, e) => Array.from(r.querySelectorAll("input[data-opid]") ?? []).reduce((s, a) => {
|
|
3024
3033
|
const i = a.getAttribute("data-opid");
|
|
3025
3034
|
return i ? { ...s, [i]: a.value } : s;
|
|
3026
|
-
}, e),
|
|
3035
|
+
}, e), We = (r, e, t, n, s, a, i) => {
|
|
3027
3036
|
const o = Xt(t, {
|
|
3028
3037
|
type: r,
|
|
3029
3038
|
sessionId: e,
|
|
@@ -3031,19 +3040,19 @@ const Wn = (r) => {
|
|
|
3031
3040
|
paymentFlowMetadata: i,
|
|
3032
3041
|
doNotUseLegacyCCFlow: a
|
|
3033
3042
|
});
|
|
3034
|
-
(s.provider === "apple_pay" || s.provider === "google_pay") && (o[
|
|
3043
|
+
(s.provider === "apple_pay" || s.provider === "google_pay") && (o[et.ZIP_CODE] || (o[et.ZIP_CODE] = "00000"));
|
|
3035
3044
|
const u = Gt.safeParse(o);
|
|
3036
3045
|
if (u.success)
|
|
3037
3046
|
return u.data;
|
|
3038
3047
|
{
|
|
3039
|
-
const c = u.error.format(), p =
|
|
3040
|
-
for (const [
|
|
3041
|
-
n(
|
|
3048
|
+
const c = u.error.format(), p = Kn(c);
|
|
3049
|
+
for (const [k, T] of Object.entries(p))
|
|
3050
|
+
n(k, T, k);
|
|
3042
3051
|
return null;
|
|
3043
3052
|
}
|
|
3044
|
-
},
|
|
3053
|
+
}, Yn = (r) => {
|
|
3045
3054
|
try {
|
|
3046
|
-
return
|
|
3055
|
+
return Hn.parse(r);
|
|
3047
3056
|
} catch (e) {
|
|
3048
3057
|
throw e;
|
|
3049
3058
|
}
|
|
@@ -3055,17 +3064,17 @@ const Wn = (r) => {
|
|
|
3055
3064
|
elementId: t
|
|
3056
3065
|
};
|
|
3057
3066
|
r.postMessage(JSON.stringify(a), s);
|
|
3058
|
-
},
|
|
3067
|
+
}, Jn = "https://cde.openpaystaging.com", Gn = {
|
|
3059
3068
|
usd: "usd",
|
|
3060
3069
|
brl: "brl"
|
|
3061
|
-
},
|
|
3070
|
+
}, bt = async (r) => {
|
|
3062
3071
|
for (let t = 0; t < 10; t++)
|
|
3063
|
-
At() || await
|
|
3072
|
+
At() || await Qn(500);
|
|
3064
3073
|
if (!At())
|
|
3065
3074
|
throw new Error("Stripe JS not found.");
|
|
3066
3075
|
return new Stripe(r);
|
|
3067
|
-
},
|
|
3068
|
-
const n = await
|
|
3076
|
+
}, Xn = async (r, e, t) => {
|
|
3077
|
+
const n = await bt(r), s = Gn[t];
|
|
3069
3078
|
return n.paymentRequest({
|
|
3070
3079
|
// TODO: replace this with stripe account country as soon as we support it
|
|
3071
3080
|
country: "US",
|
|
@@ -3077,9 +3086,9 @@ const Wn = (r) => {
|
|
|
3077
3086
|
requestPayerName: !0,
|
|
3078
3087
|
requestPayerEmail: !0
|
|
3079
3088
|
});
|
|
3080
|
-
},
|
|
3089
|
+
}, Qn = (r) => new Promise((e) => {
|
|
3081
3090
|
setTimeout(e, r);
|
|
3082
|
-
}), At = () => "Stripe" in window,
|
|
3091
|
+
}), At = () => "Stripe" in window, es = async (r) => new Promise((e, t) => {
|
|
3083
3092
|
try {
|
|
3084
3093
|
r.on("paymentmethod", async (n) => {
|
|
3085
3094
|
e(n);
|
|
@@ -3089,12 +3098,12 @@ const Wn = (r) => {
|
|
|
3089
3098
|
} catch (n) {
|
|
3090
3099
|
t(n);
|
|
3091
3100
|
}
|
|
3092
|
-
}),
|
|
3101
|
+
}), ts = (r) => {
|
|
3093
3102
|
const e = r == null ? void 0 : r.stripe_pk;
|
|
3094
3103
|
if (typeof e != "string")
|
|
3095
3104
|
throw new Error("Invalid: stripe_pk not passed in checkout payment method");
|
|
3096
3105
|
return e;
|
|
3097
|
-
},
|
|
3106
|
+
}, rs = async (r, e) => {
|
|
3098
3107
|
const t = r.nextActionMetadata;
|
|
3099
3108
|
if (!r.paymentFlowMetadata || !r.paymentFlowMetadata.stripePmId)
|
|
3100
3109
|
throw new Error(`Invalid payment flow metadata format: ${JSON.stringify(r.paymentFlowMetadata)}`);
|
|
@@ -3102,22 +3111,22 @@ const Wn = (r) => {
|
|
|
3102
3111
|
throw new Error(`Invalid next action metadata format: ${JSON.stringify(t)}`);
|
|
3103
3112
|
if (e.paymentMethod.id !== r.paymentFlowMetadata.stripePmId)
|
|
3104
3113
|
throw new Error(`PM ID mismatch: ${e.paymentMethod.id} != ${r.paymentFlowMetadata.stripePmId}`);
|
|
3105
|
-
const s = await (await
|
|
3114
|
+
const s = await (await bt(t.stripe_pk)).confirmCardSetup(t.client_secret, {
|
|
3106
3115
|
payment_method: r.paymentFlowMetadata.stripePmId
|
|
3107
3116
|
});
|
|
3108
3117
|
if (s.error)
|
|
3109
3118
|
throw e.complete("fail"), new Error(`Payment failed: ${s.error.message ?? "unknown"}`);
|
|
3110
3119
|
e.complete("success");
|
|
3111
|
-
},
|
|
3120
|
+
}, ns = async (r) => {
|
|
3112
3121
|
var a, i, o, u;
|
|
3113
|
-
const e = r.nextActionMetadata, n = await (await
|
|
3122
|
+
const e = r.nextActionMetadata, n = await (await bt(e.stripe_pk)).confirmCardSetup(e.client_secret, {
|
|
3114
3123
|
payment_method: e.stripe_pm_id
|
|
3115
3124
|
}), s = (a = n.setupIntent) == null ? void 0 : a.status;
|
|
3116
3125
|
if (s !== "succeeded") throw s === "canceled" ? new Error("Payment cancelled, please click Submit again to pay") : new Error(
|
|
3117
3126
|
`${((i = n.error) == null ? void 0 : i.message) ?? ((u = (o = n.setupIntent) == null ? void 0 : o.last_setup_error) == null ? void 0 : u.message) ?? "Payment failed, please click submit again to pay."}`
|
|
3118
3127
|
);
|
|
3119
|
-
},
|
|
3120
|
-
const [e, t] =
|
|
3128
|
+
}, ss = (r = {}) => {
|
|
3129
|
+
const [e, t] = N(r), n = Oe(
|
|
3121
3130
|
() => ({
|
|
3122
3131
|
set: (a, i) => {
|
|
3123
3132
|
t((o) => ({
|
|
@@ -3144,13 +3153,13 @@ const Wn = (r) => {
|
|
|
3144
3153
|
};
|
|
3145
3154
|
return [e, s];
|
|
3146
3155
|
};
|
|
3147
|
-
function
|
|
3156
|
+
function as(r) {
|
|
3148
3157
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
3149
3158
|
}
|
|
3150
|
-
var
|
|
3159
|
+
var kt = { exports: {} }, is = _r;
|
|
3151
3160
|
function Qt(r, e, t) {
|
|
3152
3161
|
var n = typeof e == "function";
|
|
3153
|
-
|
|
3162
|
+
is.useEffect(function() {
|
|
3154
3163
|
var s, a = !0, i = r(function() {
|
|
3155
3164
|
return a;
|
|
3156
3165
|
});
|
|
@@ -3161,40 +3170,40 @@ function Qt(r, e, t) {
|
|
|
3161
3170
|
};
|
|
3162
3171
|
}, n ? t : e);
|
|
3163
3172
|
}
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
var
|
|
3167
|
-
const
|
|
3168
|
-
type:
|
|
3169
|
-
loc:
|
|
3170
|
-
msg:
|
|
3171
|
-
url:
|
|
3172
|
-
}),
|
|
3173
|
-
code:
|
|
3174
|
-
message:
|
|
3175
|
-
path:
|
|
3176
|
-
}),
|
|
3173
|
+
kt.exports = Qt;
|
|
3174
|
+
kt.exports.useAsyncEffect = Qt;
|
|
3175
|
+
var os = kt.exports;
|
|
3176
|
+
const cs = /* @__PURE__ */ as(os), ds = l.object({
|
|
3177
|
+
type: l.string(),
|
|
3178
|
+
loc: l.array(l.string()),
|
|
3179
|
+
msg: l.string(),
|
|
3180
|
+
url: l.string()
|
|
3181
|
+
}), us = l.array(ds), ls = l.object({
|
|
3182
|
+
code: l.string(),
|
|
3183
|
+
message: l.string(),
|
|
3184
|
+
path: l.array(l.string())
|
|
3185
|
+
}), fs = l.array(ls), hs = {
|
|
3177
3186
|
"failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
|
|
3178
|
-
},
|
|
3187
|
+
}, gt = (r) => {
|
|
3179
3188
|
const e = r.toLowerCase().trim();
|
|
3180
|
-
return
|
|
3181
|
-
},
|
|
3189
|
+
return hs[e] ?? r;
|
|
3190
|
+
}, ps = (r) => {
|
|
3182
3191
|
try {
|
|
3183
3192
|
return typeof JSON.parse(r) == "object";
|
|
3184
3193
|
} catch {
|
|
3185
3194
|
return !1;
|
|
3186
3195
|
}
|
|
3187
|
-
},
|
|
3188
|
-
${r.map((t) => `• ${
|
|
3189
|
-
`)}`,
|
|
3196
|
+
}, ms = (r) => r.length === 1 ? gt(r[0].msg) : `Please fix the following errors:
|
|
3197
|
+
${r.map((t) => `• ${gt(t.msg)}`).join(`
|
|
3198
|
+
`)}`, ys = (r) => `Encountered the following errors:
|
|
3190
3199
|
${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
|
|
3191
3200
|
`)}`, er = (r) => {
|
|
3192
3201
|
if (window.cur_error = r, r instanceof Error)
|
|
3193
|
-
if (
|
|
3202
|
+
if (ps(r.message)) {
|
|
3194
3203
|
const e = JSON.parse(r.message);
|
|
3195
|
-
return
|
|
3204
|
+
return us.safeParse(e).success ? ms(e) : fs.safeParse(e).success ? ys(e) : r.message;
|
|
3196
3205
|
} else
|
|
3197
|
-
return
|
|
3206
|
+
return gt(r.message);
|
|
3198
3207
|
if (typeof r == "object")
|
|
3199
3208
|
try {
|
|
3200
3209
|
return JSON.stringify(r);
|
|
@@ -3203,7 +3212,7 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
|
|
|
3203
3212
|
}
|
|
3204
3213
|
else
|
|
3205
3214
|
return r + "";
|
|
3206
|
-
},
|
|
3215
|
+
}, vs = l.enum(["apple_pay", "google_pay"]), _s = {
|
|
3207
3216
|
apple_pay: "applePay",
|
|
3208
3217
|
google_pay: "googlePay"
|
|
3209
3218
|
}, Pt = {
|
|
@@ -3211,31 +3220,31 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
|
|
|
3211
3220
|
isAvailable: !1,
|
|
3212
3221
|
startFlow: () => {
|
|
3213
3222
|
}
|
|
3214
|
-
},
|
|
3223
|
+
}, gs = {
|
|
3215
3224
|
isLoading: !1,
|
|
3216
3225
|
isAvailable: !1,
|
|
3217
3226
|
startFlow: () => {
|
|
3218
3227
|
}
|
|
3219
|
-
},
|
|
3220
|
-
const [o, u] =
|
|
3228
|
+
}, xs = (r, e, t, n, s, a, i) => {
|
|
3229
|
+
const [o, u] = ss({
|
|
3221
3230
|
apple_pay: Pt,
|
|
3222
3231
|
google_pay: Pt
|
|
3223
3232
|
}), c = r === void 0 || e === void 0 || t === void 0 || !n;
|
|
3224
|
-
return
|
|
3233
|
+
return cs(async () => {
|
|
3225
3234
|
if (!c)
|
|
3226
|
-
for (const p of
|
|
3227
|
-
const
|
|
3235
|
+
for (const p of vs.options) {
|
|
3236
|
+
const k = p.replace("_", "");
|
|
3228
3237
|
try {
|
|
3229
|
-
const T = t.find((
|
|
3238
|
+
const T = t.find((re) => re.provider === p && re.processor_name === "stripe");
|
|
3230
3239
|
if (!T)
|
|
3231
|
-
throw new Error(`${
|
|
3232
|
-
const
|
|
3233
|
-
if (!
|
|
3234
|
-
throw new Error(`Cannot make payment with ${
|
|
3235
|
-
const
|
|
3240
|
+
throw new Error(`${k} is not available as a checkout method`);
|
|
3241
|
+
const $ = ts(T.metadata), ue = await Xn($, r, e), C = await ue.canMakePayment();
|
|
3242
|
+
if (!C)
|
|
3243
|
+
throw new Error(`Cannot make payment with ${k} for this session`);
|
|
3244
|
+
const nt = async () => {
|
|
3236
3245
|
try {
|
|
3237
|
-
if (Xt(n, {}), a && !
|
|
3238
|
-
|
|
3246
|
+
if (Xt(n, {}), a && !We(
|
|
3247
|
+
b.enum.START_PAYMENT_FLOW,
|
|
3239
3248
|
// This is ok since we're just calling this function to use the validation function inside it
|
|
3240
3249
|
"dummy",
|
|
3241
3250
|
n,
|
|
@@ -3244,24 +3253,24 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
|
|
|
3244
3253
|
!1
|
|
3245
3254
|
))
|
|
3246
3255
|
return;
|
|
3247
|
-
|
|
3248
|
-
const
|
|
3249
|
-
s(
|
|
3250
|
-
} catch (
|
|
3251
|
-
i(er(
|
|
3256
|
+
ue.show();
|
|
3257
|
+
const re = await es(ue);
|
|
3258
|
+
s(re, T);
|
|
3259
|
+
} catch (re) {
|
|
3260
|
+
i(er(re));
|
|
3252
3261
|
}
|
|
3253
3262
|
};
|
|
3254
3263
|
u.set(p, {
|
|
3255
3264
|
isLoading: !1,
|
|
3256
|
-
isAvailable:
|
|
3257
|
-
startFlow:
|
|
3265
|
+
isAvailable: C[_s[p]],
|
|
3266
|
+
startFlow: nt
|
|
3258
3267
|
});
|
|
3259
3268
|
} catch {
|
|
3260
|
-
u.set(p,
|
|
3269
|
+
u.set(p, gs);
|
|
3261
3270
|
}
|
|
3262
3271
|
}
|
|
3263
3272
|
}, [c, t]), o;
|
|
3264
|
-
},
|
|
3273
|
+
}, Es = (r) => {
|
|
3265
3274
|
const {
|
|
3266
3275
|
children: e,
|
|
3267
3276
|
checkoutSecureToken: t,
|
|
@@ -3273,221 +3282,228 @@ ${r.map((t) => `- ${t.path.join("/")}: ${t.message}`).join(`
|
|
|
3273
3282
|
onLoadError: u,
|
|
3274
3283
|
onValidationError: c,
|
|
3275
3284
|
onCheckoutStarted: p,
|
|
3276
|
-
onCheckoutSuccess:
|
|
3285
|
+
onCheckoutSuccess: k,
|
|
3277
3286
|
onCheckoutError: T,
|
|
3278
|
-
|
|
3279
|
-
|
|
3287
|
+
onSetupPaymentMethodSuccess: $,
|
|
3288
|
+
baseUrl: ue
|
|
3289
|
+
} = r, C = ue ?? Jn, [nt, re] = N(void 0), [st, tr] = N([]), [rr, nr] = N("1px"), [at, sr] = N(!1), [J, we] = N(void 0), [wt, ye] = N(!1), [le, ar] = N([]), [ne, ir] = N({}), [Et, it] = N(0), [Tt, G] = N(!1), [W, or] = N(void 0), [ot, cr] = N(void 0), [ct, dr] = N(void 0), [X, ur] = N(void 0), [dt, lr] = N(void 0), Q = Oe(() => `opjs-form-${Mt()}`, []), q = Zt(null), ut = Te(
|
|
3280
3290
|
(O) => {
|
|
3281
|
-
if (O.origin !==
|
|
3282
|
-
const D = O.source,
|
|
3283
|
-
if (
|
|
3291
|
+
if (O.origin !== C || !O.source) return;
|
|
3292
|
+
const D = O.source, R = Yn(JSON.parse(O.data)), V = R.elementId;
|
|
3293
|
+
if (R.formId !== Q || !V || R.nonce in st)
|
|
3284
3294
|
return;
|
|
3285
|
-
|
|
3286
|
-
const w =
|
|
3287
|
-
if (
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3295
|
+
tr((P) => [...P, R.nonce]);
|
|
3296
|
+
const w = R.payload, j = w.type;
|
|
3297
|
+
if (j === b.enum.LAYOUT) {
|
|
3298
|
+
const P = w.height ? `${w.height}px` : "100%";
|
|
3299
|
+
nr(P);
|
|
3300
|
+
} else if (j === b.enum.FOCUS && s)
|
|
3301
|
+
s(R.elementId);
|
|
3302
|
+
else if (j === b.enum.BLUR && a)
|
|
3303
|
+
a(R.elementId);
|
|
3304
|
+
else if (j === b.enum.CHANGE && i)
|
|
3305
|
+
i(R.elementId);
|
|
3306
|
+
else if (j === b.enum.LOADED) {
|
|
3307
|
+
const P = le.find((S) => S.contentWindow === D);
|
|
3308
|
+
if (ye(!1), !P)
|
|
3296
3309
|
return;
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
else if (L === k.enum.PAYMENT_FLOW_STARTED) {
|
|
3303
|
-
if (!Q)
|
|
3310
|
+
ir((S) => ({ ...S, [V]: D })), dr(w.totalAmountAtoms), cr(w.currency), ur(w.checkoutPaymentMethods), W || or(w.sessionId);
|
|
3311
|
+
} else if (j === b.enum.TOKENIZE_STARTED)
|
|
3312
|
+
ye(!0), p && p();
|
|
3313
|
+
else if (j === b.enum.PAYMENT_FLOW_STARTED) {
|
|
3314
|
+
if (!J)
|
|
3304
3315
|
throw new Error("extraData not populated");
|
|
3305
3316
|
(async () => {
|
|
3306
3317
|
const S = w.nextActionMetadata.type;
|
|
3307
3318
|
if (S !== void 0) if (S === "stripe_3ds")
|
|
3308
|
-
await
|
|
3319
|
+
await ns(w);
|
|
3309
3320
|
else if (S === "stripe_payment_request") {
|
|
3310
|
-
if (!
|
|
3321
|
+
if (!dt)
|
|
3311
3322
|
throw new Error("Stripe PM not set");
|
|
3312
|
-
await
|
|
3323
|
+
await rs(w, dt);
|
|
3313
3324
|
} else
|
|
3314
3325
|
throw new Error(`Unknown next action type: ${S}`);
|
|
3315
3326
|
})().then(() => {
|
|
3316
|
-
var
|
|
3327
|
+
var fe;
|
|
3317
3328
|
let S;
|
|
3318
|
-
if (
|
|
3329
|
+
if (J.checkoutPaymentMethod.provider === "credit_card" && (S = (fe = w.startPFMetadata) == null ? void 0 : fe.cc_pm_id, !S))
|
|
3319
3330
|
throw new Error("CC PM ID not found");
|
|
3320
3331
|
Ee(
|
|
3321
3332
|
D,
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
{ ...
|
|
3325
|
-
|
|
3326
|
-
),
|
|
3333
|
+
Q,
|
|
3334
|
+
V,
|
|
3335
|
+
{ ...J, type: "CHECKOUT", doNotUseLegacyCCFlow: !0, existingCCPMId: S },
|
|
3336
|
+
C
|
|
3337
|
+
), G(!0), we(void 0), p && p();
|
|
3327
3338
|
}).catch((S) => {
|
|
3328
|
-
const
|
|
3329
|
-
|
|
3339
|
+
const fe = er(S);
|
|
3340
|
+
ye(!1), G(!1), T && T(fe);
|
|
3330
3341
|
});
|
|
3331
|
-
} else if (
|
|
3332
|
-
const
|
|
3333
|
-
!Tt && (S || w.isReadyForCheckout) ? (Ee(D,
|
|
3334
|
-
} else if (
|
|
3335
|
-
|
|
3336
|
-
else if (
|
|
3342
|
+
} else if (j === b.enum.TOKENIZE_SUCCESS && J) {
|
|
3343
|
+
const P = Et + 1, S = P === Object.keys(ne).length;
|
|
3344
|
+
!Tt && (S || w.isReadyForCheckout) ? (Ee(D, Q, V, J, C), G(!0), we(void 0)) : it(P);
|
|
3345
|
+
} else if (j === b.enum.CHECKOUT_SUCCESS)
|
|
3346
|
+
ye(!1), it(0), G(!1), k && k(w.invoiceUrls, w.subscriptionIds, w.customerId);
|
|
3347
|
+
else if (j === b.enum.SETUP_PAYMENT_METHOD_SUCCESS)
|
|
3348
|
+
ye(!1), it(0), G(!1), $ && $(w.paymentMethodId);
|
|
3349
|
+
else if (j === b.enum.LOAD_ERROR)
|
|
3337
3350
|
u && u(w.message);
|
|
3338
|
-
else if (
|
|
3339
|
-
const
|
|
3340
|
-
(
|
|
3341
|
-
} else if (
|
|
3351
|
+
else if (j === b.enum.VALIDATION_ERROR) {
|
|
3352
|
+
const P = J == null ? void 0 : J.checkoutPaymentMethod.provider;
|
|
3353
|
+
(P === "credit_card" || P === void 0) && c && c(w.elementType, w.errors, V);
|
|
3354
|
+
} else if (j === b.enum.TOKENIZE_ERROR || j === b.enum.CHECKOUT_ERROR)
|
|
3342
3355
|
if (w.message === "3DS_REQUIRED") {
|
|
3343
|
-
const
|
|
3344
|
-
if (!
|
|
3345
|
-
for (const [S,
|
|
3346
|
-
if (!
|
|
3347
|
-
const
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3356
|
+
const P = X == null ? void 0 : X.find((S) => S.provider === "credit_card");
|
|
3357
|
+
if (!W || !q.current || !c || !P) return;
|
|
3358
|
+
for (const [S, fe] of Object.entries(ne)) {
|
|
3359
|
+
if (!fe) continue;
|
|
3360
|
+
const ft = We(
|
|
3361
|
+
b.enum.START_PAYMENT_FLOW,
|
|
3362
|
+
W,
|
|
3363
|
+
q.current,
|
|
3351
3364
|
c,
|
|
3352
3365
|
// Only stripe supports frontend 3DS right now,
|
|
3353
3366
|
// so we pass processor_name: 'stripe' to tell delegator to only use stripe
|
|
3354
|
-
{ ...
|
|
3367
|
+
{ ...P, processor_name: "stripe" },
|
|
3355
3368
|
!1
|
|
3356
3369
|
);
|
|
3357
|
-
if (
|
|
3358
|
-
|
|
3370
|
+
if (ft) {
|
|
3371
|
+
G(!0), we(ft), Ee(fe, Q, S, ft, C);
|
|
3359
3372
|
break;
|
|
3360
3373
|
}
|
|
3361
3374
|
}
|
|
3362
3375
|
} else
|
|
3363
|
-
|
|
3376
|
+
ye(!1), G(!1), T && T(w.message);
|
|
3364
3377
|
},
|
|
3365
3378
|
[
|
|
3366
|
-
te,
|
|
3367
|
-
q,
|
|
3368
|
-
X,
|
|
3369
3379
|
Q,
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3380
|
+
W,
|
|
3381
|
+
st,
|
|
3382
|
+
J,
|
|
3383
|
+
le,
|
|
3384
|
+
ne,
|
|
3385
|
+
Et,
|
|
3373
3386
|
Tt,
|
|
3374
3387
|
a,
|
|
3375
3388
|
i,
|
|
3376
3389
|
s,
|
|
3377
3390
|
u,
|
|
3378
3391
|
p,
|
|
3379
|
-
|
|
3392
|
+
k,
|
|
3393
|
+
$,
|
|
3380
3394
|
T,
|
|
3381
3395
|
c,
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3396
|
+
C,
|
|
3397
|
+
dt,
|
|
3398
|
+
X
|
|
3385
3399
|
]
|
|
3386
|
-
),
|
|
3387
|
-
if (!
|
|
3388
|
-
const O =
|
|
3400
|
+
), fr = Te(() => {
|
|
3401
|
+
if (!q.current || !c || !W || !X) return;
|
|
3402
|
+
const O = X.find((R) => R.provider === "credit_card");
|
|
3389
3403
|
if (!O)
|
|
3390
3404
|
throw new Error("Card not available as a payment method in checkout");
|
|
3391
|
-
const D =
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3405
|
+
const D = We(
|
|
3406
|
+
b.enum.TOKENIZE,
|
|
3407
|
+
W,
|
|
3408
|
+
q.current,
|
|
3395
3409
|
c,
|
|
3396
3410
|
O,
|
|
3397
3411
|
!1
|
|
3398
3412
|
);
|
|
3399
3413
|
if (D) {
|
|
3400
|
-
for (const [
|
|
3401
|
-
|
|
3402
|
-
D.type =
|
|
3414
|
+
for (const [R, V] of Object.entries(ne))
|
|
3415
|
+
V && Ee(V, Q, R, D, C);
|
|
3416
|
+
D.type = b.enum.CHECKOUT, we(D);
|
|
3403
3417
|
}
|
|
3404
|
-
}, [
|
|
3418
|
+
}, [q, ne, Q, c, W, C, X]), lt = Te(
|
|
3405
3419
|
(O) => {
|
|
3406
|
-
|
|
3420
|
+
wt && O.preventDefault();
|
|
3407
3421
|
},
|
|
3408
|
-
[
|
|
3422
|
+
[wt]
|
|
3409
3423
|
);
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3424
|
+
qe(() => {
|
|
3425
|
+
if (at || !q.current) return;
|
|
3426
|
+
le.length > 0 && le.length === Object.keys(ne).length && (sr(!0), o && o(ct, ot));
|
|
3427
|
+
}, [le, ne, at, o, ct, ot]), qe(() => (re(window.location.origin), window.addEventListener("message", ut), window.addEventListener("beforeunload", lt), () => {
|
|
3428
|
+
window.removeEventListener("beforeunload", lt), window.removeEventListener("message", ut);
|
|
3429
|
+
}), [W, ut, lt]);
|
|
3430
|
+
const hr = Te(
|
|
3416
3431
|
(O) => {
|
|
3417
|
-
|
|
3432
|
+
le.find((R) => R.contentWindow === O.contentWindow) || ar((R) => [...R, O]);
|
|
3418
3433
|
},
|
|
3419
|
-
[
|
|
3420
|
-
),
|
|
3421
|
-
if (!(!
|
|
3422
|
-
for (const [
|
|
3423
|
-
if (
|
|
3424
|
-
const
|
|
3434
|
+
[le]
|
|
3435
|
+
), pr = async (O, D) => {
|
|
3436
|
+
if (!(!q.current || !c || !W || !X))
|
|
3437
|
+
for (const [R, V] of Object.entries(ne)) {
|
|
3438
|
+
if (!V) continue;
|
|
3439
|
+
const Ct = {
|
|
3425
3440
|
stripePmId: O.paymentMethod.id
|
|
3426
|
-
}, w =
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3441
|
+
}, w = We(
|
|
3442
|
+
b.enum.START_PAYMENT_FLOW,
|
|
3443
|
+
W,
|
|
3444
|
+
q.current,
|
|
3430
3445
|
c,
|
|
3431
3446
|
D,
|
|
3432
3447
|
!1,
|
|
3433
|
-
|
|
3448
|
+
Ct
|
|
3434
3449
|
);
|
|
3435
3450
|
if (w) {
|
|
3436
|
-
|
|
3451
|
+
lr(O), G(!0), we(w), Ee(V, Q, R, w, C);
|
|
3437
3452
|
break;
|
|
3438
3453
|
}
|
|
3439
3454
|
}
|
|
3440
|
-
},
|
|
3441
|
-
|
|
3442
|
-
},
|
|
3443
|
-
formId:
|
|
3444
|
-
formHeight:
|
|
3445
|
-
referer:
|
|
3455
|
+
}, mr = (O) => {
|
|
3456
|
+
G(!1), T && T(O);
|
|
3457
|
+
}, yr = {
|
|
3458
|
+
formId: Q,
|
|
3459
|
+
formHeight: rr,
|
|
3460
|
+
referer: nt,
|
|
3446
3461
|
checkoutSecureToken: t,
|
|
3447
|
-
registerIframe:
|
|
3448
|
-
baseUrl:
|
|
3449
|
-
},
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3462
|
+
registerIframe: hr,
|
|
3463
|
+
baseUrl: C
|
|
3464
|
+
}, St = xs(
|
|
3465
|
+
ct,
|
|
3466
|
+
ot,
|
|
3467
|
+
X,
|
|
3468
|
+
q.current,
|
|
3469
|
+
pr,
|
|
3455
3470
|
c,
|
|
3456
|
-
|
|
3457
|
-
),
|
|
3458
|
-
submit:
|
|
3459
|
-
applePay:
|
|
3460
|
-
googlePay:
|
|
3471
|
+
mr
|
|
3472
|
+
), vr = {
|
|
3473
|
+
submit: fr,
|
|
3474
|
+
applePay: St.apple_pay,
|
|
3475
|
+
googlePay: St.google_pay,
|
|
3476
|
+
loaded: at
|
|
3461
3477
|
};
|
|
3462
|
-
return /* @__PURE__ */
|
|
3463
|
-
},
|
|
3464
|
-
const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } =
|
|
3478
|
+
return /* @__PURE__ */ ae(jt.Provider, { value: yr, children: /* @__PURE__ */ ae("div", { className: n, ref: q, children: e(vr) }) });
|
|
3479
|
+
}, bs = (r) => JSON.stringify(r), rt = (r) => {
|
|
3480
|
+
const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = br(), [c, p] = N(!1), k = Zt(null), T = Oe(() => t ? bs(t) : "", [t]), $ = Oe(() => ({
|
|
3465
3481
|
border: "none",
|
|
3466
3482
|
width: "100%",
|
|
3467
3483
|
height: a
|
|
3468
|
-
}), [a]),
|
|
3484
|
+
}), [a]), ue = Oe(() => {
|
|
3469
3485
|
if (!i || !s) return "";
|
|
3470
|
-
const
|
|
3471
|
-
return
|
|
3486
|
+
const C = new URLSearchParams();
|
|
3487
|
+
return C.append("referer", s), C.append("styles", T), C.append("formId", n), C.append("secureToken", i), C.toString();
|
|
3472
3488
|
}, [T, n, s, i]);
|
|
3473
|
-
return
|
|
3474
|
-
!
|
|
3475
|
-
}, [c]), i ? /* @__PURE__ */
|
|
3489
|
+
return qe(() => p(!0), []), qe(() => {
|
|
3490
|
+
!k.current || !c || o(k.current);
|
|
3491
|
+
}, [c]), i ? /* @__PURE__ */ ae(
|
|
3476
3492
|
"iframe",
|
|
3477
3493
|
{
|
|
3478
3494
|
name: `${e}-element`,
|
|
3479
|
-
src: `${u}/app/v1/${e}-element/?${
|
|
3480
|
-
style:
|
|
3481
|
-
ref:
|
|
3495
|
+
src: `${u}/app/v1/${e}-element/?${ue}`,
|
|
3496
|
+
style: $,
|
|
3497
|
+
ref: k
|
|
3482
3498
|
}
|
|
3483
|
-
) : /* @__PURE__ */
|
|
3484
|
-
},
|
|
3499
|
+
) : /* @__PURE__ */ ae("div", {});
|
|
3500
|
+
}, Ts = ({ styles: r }) => /* @__PURE__ */ ae(rt, { styles: r, subPath: "card-cvc" }), Ss = ({ styles: r }) => /* @__PURE__ */ ae(rt, { styles: r, subPath: "card" }), Cs = ({ styles: r }) => /* @__PURE__ */ ae(rt, { styles: r, subPath: "card-expiry" }), Os = ({ styles: r }) => /* @__PURE__ */ ae(rt, { styles: r, subPath: "card-number" });
|
|
3485
3501
|
export {
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3502
|
+
Ts as CardCvcElement,
|
|
3503
|
+
Ss as CardElement,
|
|
3504
|
+
Cs as CardExpiryElement,
|
|
3505
|
+
Os as CardNumberElement,
|
|
3506
|
+
Es as ElementsForm,
|
|
3507
|
+
et as FieldName,
|
|
3508
|
+
br as useOpenPayElements
|
|
3493
3509
|
};
|