@getopenpay/openpay-js-react 0.0.14 → 0.0.15-alpha.2040cc2
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 +23 -16
- package/dist/index.js +1468 -1419
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsx as
|
|
3
|
-
const
|
|
1
|
+
import Fn, { createContext as zn, useContext as Bn, useState as A, useMemo as Fe, useCallback as Le, useRef as Gt, useEffect as ut } from "react";
|
|
2
|
+
import { jsx as ye } from "react/jsx-runtime";
|
|
3
|
+
const Xt = zn({
|
|
4
4
|
formId: "",
|
|
5
5
|
formHeight: "",
|
|
6
6
|
referer: void 0,
|
|
@@ -8,34 +8,34 @@ const Jt = Lr({
|
|
|
8
8
|
registerIframe: () => {
|
|
9
9
|
},
|
|
10
10
|
baseUrl: ""
|
|
11
|
-
}),
|
|
12
|
-
const t =
|
|
11
|
+
}), Hn = () => {
|
|
12
|
+
const t = Bn(Xt);
|
|
13
13
|
if (!t)
|
|
14
14
|
throw new Error("useOpenPayElements must be used within an OpenPayElementsProvider");
|
|
15
15
|
return t;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
for (var
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
return (
|
|
17
|
+
var M = [];
|
|
18
|
+
for (var Et = 0; Et < 256; ++Et)
|
|
19
|
+
M.push((Et + 256).toString(16).slice(1));
|
|
20
|
+
function qn(t, e = 0) {
|
|
21
|
+
return (M[t[e + 0]] + M[t[e + 1]] + M[t[e + 2]] + M[t[e + 3]] + "-" + M[t[e + 4]] + M[t[e + 5]] + "-" + M[t[e + 6]] + M[t[e + 7]] + "-" + M[t[e + 8]] + M[t[e + 9]] + "-" + M[t[e + 10]] + M[t[e + 11]] + M[t[e + 12]] + M[t[e + 13]] + M[t[e + 14]] + M[t[e + 15]]).toLowerCase();
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
23
|
+
var ct, Wn = new Uint8Array(16);
|
|
24
|
+
function Kn() {
|
|
25
|
+
if (!ct && (ct = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ct))
|
|
26
26
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
27
|
-
return
|
|
27
|
+
return ct(Wn);
|
|
28
28
|
}
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
randomUUID:
|
|
29
|
+
var Yn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
30
|
+
const zt = {
|
|
31
|
+
randomUUID: Yn
|
|
32
32
|
};
|
|
33
|
-
function
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
33
|
+
function Qt(t, e, n) {
|
|
34
|
+
if (zt.randomUUID && !e && !t)
|
|
35
|
+
return zt.randomUUID();
|
|
36
36
|
t = t || {};
|
|
37
|
-
var
|
|
38
|
-
return
|
|
37
|
+
var r = t.random || (t.rng || Kn)();
|
|
38
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, qn(r);
|
|
39
39
|
}
|
|
40
40
|
var x;
|
|
41
41
|
(function(t) {
|
|
@@ -43,10 +43,10 @@ var x;
|
|
|
43
43
|
function e(s) {
|
|
44
44
|
}
|
|
45
45
|
t.assertIs = e;
|
|
46
|
-
function
|
|
46
|
+
function n(s) {
|
|
47
47
|
throw new Error();
|
|
48
48
|
}
|
|
49
|
-
t.assertNever =
|
|
49
|
+
t.assertNever = n, t.arrayToEnum = (s) => {
|
|
50
50
|
const a = {};
|
|
51
51
|
for (const o of s)
|
|
52
52
|
a[o] = o;
|
|
@@ -68,19 +68,19 @@ var x;
|
|
|
68
68
|
if (a(o))
|
|
69
69
|
return o;
|
|
70
70
|
}, t.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
|
|
71
|
-
function
|
|
71
|
+
function r(s, a = " | ") {
|
|
72
72
|
return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
|
|
73
73
|
}
|
|
74
|
-
t.joinValues =
|
|
74
|
+
t.joinValues = r, t.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
75
75
|
})(x || (x = {}));
|
|
76
|
-
var
|
|
76
|
+
var Tt;
|
|
77
77
|
(function(t) {
|
|
78
|
-
t.mergeShapes = (e,
|
|
78
|
+
t.mergeShapes = (e, n) => ({
|
|
79
79
|
...e,
|
|
80
|
-
...
|
|
80
|
+
...n
|
|
81
81
|
// second overwrites first
|
|
82
82
|
});
|
|
83
|
-
})(
|
|
83
|
+
})(Tt || (Tt = {}));
|
|
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
|
+
]), pe = (t) => {
|
|
106
106
|
switch (typeof t) {
|
|
107
107
|
case "undefined":
|
|
108
108
|
return h.undefined;
|
|
@@ -140,24 +140,24 @@ const h = x.arrayToEnum([
|
|
|
140
140
|
"invalid_intersection_types",
|
|
141
141
|
"not_multiple_of",
|
|
142
142
|
"not_finite"
|
|
143
|
-
]),
|
|
144
|
-
class
|
|
143
|
+
]), Jn = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
144
|
+
class z extends Error {
|
|
145
145
|
constructor(e) {
|
|
146
|
-
super(), this.issues = [], this.addIssue = (
|
|
147
|
-
this.issues = [...this.issues,
|
|
148
|
-
}, this.addIssues = (
|
|
149
|
-
this.issues = [...this.issues, ...
|
|
146
|
+
super(), this.issues = [], this.addIssue = (r) => {
|
|
147
|
+
this.issues = [...this.issues, r];
|
|
148
|
+
}, this.addIssues = (r = []) => {
|
|
149
|
+
this.issues = [...this.issues, ...r];
|
|
150
150
|
};
|
|
151
|
-
const
|
|
152
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this,
|
|
151
|
+
const n = new.target.prototype;
|
|
152
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
153
153
|
}
|
|
154
154
|
get errors() {
|
|
155
155
|
return this.issues;
|
|
156
156
|
}
|
|
157
157
|
format(e) {
|
|
158
|
-
const
|
|
158
|
+
const n = e || function(a) {
|
|
159
159
|
return a.message;
|
|
160
|
-
},
|
|
160
|
+
}, r = { _errors: [] }, s = (a) => {
|
|
161
161
|
for (const o of a.issues)
|
|
162
162
|
if (o.code === "invalid_union")
|
|
163
163
|
o.unionErrors.map(s);
|
|
@@ -166,19 +166,19 @@ class F extends Error {
|
|
|
166
166
|
else if (o.code === "invalid_arguments")
|
|
167
167
|
s(o.argumentsError);
|
|
168
168
|
else if (o.path.length === 0)
|
|
169
|
-
|
|
169
|
+
r._errors.push(n(o));
|
|
170
170
|
else {
|
|
171
|
-
let c =
|
|
171
|
+
let c = r, u = 0;
|
|
172
172
|
for (; u < o.path.length; ) {
|
|
173
173
|
const d = o.path[u];
|
|
174
|
-
u === o.path.length - 1 ? (c[d] = c[d] || { _errors: [] }, c[d]._errors.push(
|
|
174
|
+
u === o.path.length - 1 ? (c[d] = c[d] || { _errors: [] }, c[d]._errors.push(n(o))) : c[d] = c[d] || { _errors: [] }, c = c[d], u++;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
|
-
return s(this),
|
|
178
|
+
return s(this), r;
|
|
179
179
|
}
|
|
180
180
|
static assert(e) {
|
|
181
|
-
if (!(e instanceof
|
|
181
|
+
if (!(e instanceof z))
|
|
182
182
|
throw new Error(`Not a ZodError: ${e}`);
|
|
183
183
|
}
|
|
184
184
|
toString() {
|
|
@@ -190,82 +190,82 @@ class F extends Error {
|
|
|
190
190
|
get isEmpty() {
|
|
191
191
|
return this.issues.length === 0;
|
|
192
192
|
}
|
|
193
|
-
flatten(e = (
|
|
194
|
-
const
|
|
193
|
+
flatten(e = (n) => n.message) {
|
|
194
|
+
const n = {}, r = [];
|
|
195
195
|
for (const s of this.issues)
|
|
196
|
-
s.path.length > 0 ? (
|
|
197
|
-
return { formErrors:
|
|
196
|
+
s.path.length > 0 ? (n[s.path[0]] = n[s.path[0]] || [], n[s.path[0]].push(e(s))) : r.push(e(s));
|
|
197
|
+
return { formErrors: r, fieldErrors: n };
|
|
198
198
|
}
|
|
199
199
|
get formErrors() {
|
|
200
200
|
return this.flatten();
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
let
|
|
203
|
+
z.create = (t) => new z(t);
|
|
204
|
+
const Ae = (t, e) => {
|
|
205
|
+
let n;
|
|
206
206
|
switch (t.code) {
|
|
207
207
|
case l.invalid_type:
|
|
208
|
-
t.received === h.undefined ?
|
|
208
|
+
t.received === h.undefined ? n = "Required" : n = `Expected ${t.expected}, received ${t.received}`;
|
|
209
209
|
break;
|
|
210
210
|
case l.invalid_literal:
|
|
211
|
-
|
|
211
|
+
n = `Invalid literal value, expected ${JSON.stringify(t.expected, x.jsonStringifyReplacer)}`;
|
|
212
212
|
break;
|
|
213
213
|
case l.unrecognized_keys:
|
|
214
|
-
|
|
214
|
+
n = `Unrecognized key(s) in object: ${x.joinValues(t.keys, ", ")}`;
|
|
215
215
|
break;
|
|
216
216
|
case l.invalid_union:
|
|
217
|
-
|
|
217
|
+
n = "Invalid input";
|
|
218
218
|
break;
|
|
219
219
|
case l.invalid_union_discriminator:
|
|
220
|
-
|
|
220
|
+
n = `Invalid discriminator value. Expected ${x.joinValues(t.options)}`;
|
|
221
221
|
break;
|
|
222
222
|
case l.invalid_enum_value:
|
|
223
|
-
|
|
223
|
+
n = `Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;
|
|
224
224
|
break;
|
|
225
225
|
case l.invalid_arguments:
|
|
226
|
-
|
|
226
|
+
n = "Invalid function arguments";
|
|
227
227
|
break;
|
|
228
228
|
case l.invalid_return_type:
|
|
229
|
-
|
|
229
|
+
n = "Invalid function return type";
|
|
230
230
|
break;
|
|
231
231
|
case l.invalid_date:
|
|
232
|
-
|
|
232
|
+
n = "Invalid date";
|
|
233
233
|
break;
|
|
234
234
|
case l.invalid_string:
|
|
235
|
-
typeof t.validation == "object" ? "includes" in t.validation ? (
|
|
235
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (n = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? n = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? n = `Invalid input: must end with "${t.validation.endsWith}"` : x.assertNever(t.validation) : t.validation !== "regex" ? n = `Invalid ${t.validation}` : n = "Invalid";
|
|
236
236
|
break;
|
|
237
237
|
case l.too_small:
|
|
238
|
-
t.type === "array" ?
|
|
238
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : n = "Invalid input";
|
|
239
239
|
break;
|
|
240
240
|
case l.too_big:
|
|
241
|
-
t.type === "array" ?
|
|
241
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? n = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : n = "Invalid input";
|
|
242
242
|
break;
|
|
243
243
|
case l.custom:
|
|
244
|
-
|
|
244
|
+
n = "Invalid input";
|
|
245
245
|
break;
|
|
246
246
|
case l.invalid_intersection_types:
|
|
247
|
-
|
|
247
|
+
n = "Intersection results could not be merged";
|
|
248
248
|
break;
|
|
249
249
|
case l.not_multiple_of:
|
|
250
|
-
|
|
250
|
+
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
251
251
|
break;
|
|
252
252
|
case l.not_finite:
|
|
253
|
-
|
|
253
|
+
n = "Number must be finite";
|
|
254
254
|
break;
|
|
255
255
|
default:
|
|
256
|
-
|
|
256
|
+
n = e.defaultError, x.assertNever(t);
|
|
257
257
|
}
|
|
258
|
-
return { message:
|
|
258
|
+
return { message: n };
|
|
259
259
|
};
|
|
260
|
-
let
|
|
261
|
-
function
|
|
262
|
-
|
|
260
|
+
let en = Ae;
|
|
261
|
+
function Gn(t) {
|
|
262
|
+
en = t;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
264
|
+
function lt() {
|
|
265
|
+
return en;
|
|
266
266
|
}
|
|
267
|
-
const
|
|
268
|
-
const { data: e, path:
|
|
267
|
+
const ft = (t) => {
|
|
268
|
+
const { data: e, path: n, errorMaps: r, issueData: s } = t, a = [...n, ...s.path || []], o = {
|
|
269
269
|
...s,
|
|
270
270
|
path: a
|
|
271
271
|
};
|
|
@@ -276,7 +276,7 @@ const dt = (t) => {
|
|
|
276
276
|
message: s.message
|
|
277
277
|
};
|
|
278
278
|
let c = "";
|
|
279
|
-
const u =
|
|
279
|
+
const u = r.filter((d) => !!d).slice().reverse();
|
|
280
280
|
for (const d of u)
|
|
281
281
|
c = d(o, { data: e, defaultError: c }).message;
|
|
282
282
|
return {
|
|
@@ -284,23 +284,23 @@ const dt = (t) => {
|
|
|
284
284
|
path: a,
|
|
285
285
|
message: c
|
|
286
286
|
};
|
|
287
|
-
},
|
|
287
|
+
}, Xn = [];
|
|
288
288
|
function m(t, e) {
|
|
289
|
-
const
|
|
289
|
+
const n = lt(), r = ft({
|
|
290
290
|
issueData: e,
|
|
291
291
|
data: t.data,
|
|
292
292
|
path: t.path,
|
|
293
293
|
errorMaps: [
|
|
294
294
|
t.common.contextualErrorMap,
|
|
295
295
|
t.schemaErrorMap,
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
n,
|
|
297
|
+
n === Ae ? void 0 : Ae
|
|
298
298
|
// then global default map
|
|
299
299
|
].filter((s) => !!s)
|
|
300
300
|
});
|
|
301
|
-
t.common.issues.push(
|
|
301
|
+
t.common.issues.push(r);
|
|
302
302
|
}
|
|
303
|
-
class
|
|
303
|
+
class Z {
|
|
304
304
|
constructor() {
|
|
305
305
|
this.value = "valid";
|
|
306
306
|
}
|
|
@@ -310,63 +310,63 @@ class M {
|
|
|
310
310
|
abort() {
|
|
311
311
|
this.value !== "aborted" && (this.value = "aborted");
|
|
312
312
|
}
|
|
313
|
-
static mergeArray(e,
|
|
314
|
-
const
|
|
315
|
-
for (const s of
|
|
313
|
+
static mergeArray(e, n) {
|
|
314
|
+
const r = [];
|
|
315
|
+
for (const s of n) {
|
|
316
316
|
if (s.status === "aborted")
|
|
317
317
|
return g;
|
|
318
|
-
s.status === "dirty" && e.dirty(),
|
|
318
|
+
s.status === "dirty" && e.dirty(), r.push(s.value);
|
|
319
319
|
}
|
|
320
|
-
return { status: e.value, value:
|
|
320
|
+
return { status: e.value, value: r };
|
|
321
321
|
}
|
|
322
|
-
static async mergeObjectAsync(e,
|
|
323
|
-
const
|
|
324
|
-
for (const s of
|
|
322
|
+
static async mergeObjectAsync(e, n) {
|
|
323
|
+
const r = [];
|
|
324
|
+
for (const s of n) {
|
|
325
325
|
const a = await s.key, o = await s.value;
|
|
326
|
-
|
|
326
|
+
r.push({
|
|
327
327
|
key: a,
|
|
328
328
|
value: o
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
|
-
return
|
|
331
|
+
return Z.mergeObjectSync(e, r);
|
|
332
332
|
}
|
|
333
|
-
static mergeObjectSync(e,
|
|
334
|
-
const
|
|
335
|
-
for (const s of
|
|
333
|
+
static mergeObjectSync(e, n) {
|
|
334
|
+
const r = {};
|
|
335
|
+
for (const s of n) {
|
|
336
336
|
const { key: a, value: o } = s;
|
|
337
337
|
if (a.status === "aborted" || o.status === "aborted")
|
|
338
338
|
return g;
|
|
339
|
-
a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (
|
|
339
|
+
a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (r[a.value] = o.value);
|
|
340
340
|
}
|
|
341
|
-
return { status: e.value, value:
|
|
341
|
+
return { status: e.value, value: r };
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
const g = Object.freeze({
|
|
345
345
|
status: "aborted"
|
|
346
|
-
}),
|
|
347
|
-
function
|
|
348
|
-
if (typeof e == "function" ? t !== e || !
|
|
346
|
+
}), Ie = (t) => ({ status: "dirty", value: t }), $ = (t) => ({ status: "valid", value: t }), Ct = (t) => t.status === "aborted", St = (t) => t.status === "dirty", ze = (t) => t.status === "valid", Be = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
347
|
+
function mt(t, e, n, r) {
|
|
348
|
+
if (typeof e == "function" ? t !== e || !r : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
349
349
|
return e.get(t);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function tn(t, e, n, r, s) {
|
|
352
352
|
if (typeof e == "function" ? t !== e || !s : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
353
|
-
return e.set(t,
|
|
353
|
+
return e.set(t, n), n;
|
|
354
354
|
}
|
|
355
355
|
var p;
|
|
356
356
|
(function(t) {
|
|
357
357
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
358
358
|
})(p || (p = {}));
|
|
359
|
-
var
|
|
360
|
-
class
|
|
361
|
-
constructor(e,
|
|
362
|
-
this._cachedPath = [], this.parent = e, this.data =
|
|
359
|
+
var Ue, Ve;
|
|
360
|
+
class se {
|
|
361
|
+
constructor(e, n, r, s) {
|
|
362
|
+
this._cachedPath = [], this.parent = e, this.data = n, this._path = r, this._key = s;
|
|
363
363
|
}
|
|
364
364
|
get path() {
|
|
365
365
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
368
|
+
const Bt = (t, e) => {
|
|
369
|
+
if (ze(e))
|
|
370
370
|
return { success: !0, data: e.value };
|
|
371
371
|
if (!t.common.issues.length)
|
|
372
372
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -375,21 +375,21 @@ const Vt = (t, e) => {
|
|
|
375
375
|
get error() {
|
|
376
376
|
if (this._error)
|
|
377
377
|
return this._error;
|
|
378
|
-
const
|
|
379
|
-
return this._error =
|
|
378
|
+
const n = new z(t.common.issues);
|
|
379
|
+
return this._error = n, this._error;
|
|
380
380
|
}
|
|
381
381
|
};
|
|
382
382
|
};
|
|
383
383
|
function _(t) {
|
|
384
384
|
if (!t)
|
|
385
385
|
return {};
|
|
386
|
-
const { errorMap: e, invalid_type_error:
|
|
387
|
-
if (e && (
|
|
386
|
+
const { errorMap: e, invalid_type_error: n, required_error: r, description: s } = t;
|
|
387
|
+
if (e && (n || r))
|
|
388
388
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
389
389
|
return e ? { errorMap: e, description: s } : { errorMap: (o, c) => {
|
|
390
390
|
var u, d;
|
|
391
391
|
const { message: f } = t;
|
|
392
|
-
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (u = f ??
|
|
392
|
+
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (u = f ?? r) !== null && u !== void 0 ? u : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (d = f ?? n) !== null && d !== void 0 ? d : c.defaultError };
|
|
393
393
|
}, description: s };
|
|
394
394
|
}
|
|
395
395
|
class v {
|
|
@@ -400,13 +400,13 @@ class v {
|
|
|
400
400
|
return this._def.description;
|
|
401
401
|
}
|
|
402
402
|
_getType(e) {
|
|
403
|
-
return
|
|
403
|
+
return pe(e.data);
|
|
404
404
|
}
|
|
405
|
-
_getOrReturnCtx(e,
|
|
406
|
-
return
|
|
405
|
+
_getOrReturnCtx(e, n) {
|
|
406
|
+
return n || {
|
|
407
407
|
common: e.parent.common,
|
|
408
408
|
data: e.data,
|
|
409
|
-
parsedType:
|
|
409
|
+
parsedType: pe(e.data),
|
|
410
410
|
schemaErrorMap: this._def.errorMap,
|
|
411
411
|
path: e.path,
|
|
412
412
|
parent: e.parent
|
|
@@ -414,11 +414,11 @@ class v {
|
|
|
414
414
|
}
|
|
415
415
|
_processInputParams(e) {
|
|
416
416
|
return {
|
|
417
|
-
status: new
|
|
417
|
+
status: new Z(),
|
|
418
418
|
ctx: {
|
|
419
419
|
common: e.parent.common,
|
|
420
420
|
data: e.data,
|
|
421
|
-
parsedType:
|
|
421
|
+
parsedType: pe(e.data),
|
|
422
422
|
schemaErrorMap: this._def.errorMap,
|
|
423
423
|
path: e.path,
|
|
424
424
|
parent: e.parent
|
|
@@ -426,73 +426,73 @@ class v {
|
|
|
426
426
|
};
|
|
427
427
|
}
|
|
428
428
|
_parseSync(e) {
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
429
|
+
const n = this._parse(e);
|
|
430
|
+
if (Be(n))
|
|
431
431
|
throw new Error("Synchronous parse encountered promise.");
|
|
432
|
-
return
|
|
432
|
+
return n;
|
|
433
433
|
}
|
|
434
434
|
_parseAsync(e) {
|
|
435
|
-
const
|
|
436
|
-
return Promise.resolve(
|
|
435
|
+
const n = this._parse(e);
|
|
436
|
+
return Promise.resolve(n);
|
|
437
437
|
}
|
|
438
|
-
parse(e,
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
return
|
|
442
|
-
throw
|
|
438
|
+
parse(e, n) {
|
|
439
|
+
const r = this.safeParse(e, n);
|
|
440
|
+
if (r.success)
|
|
441
|
+
return r.data;
|
|
442
|
+
throw r.error;
|
|
443
443
|
}
|
|
444
|
-
safeParse(e,
|
|
445
|
-
var
|
|
444
|
+
safeParse(e, n) {
|
|
445
|
+
var r;
|
|
446
446
|
const s = {
|
|
447
447
|
common: {
|
|
448
448
|
issues: [],
|
|
449
|
-
async: (
|
|
450
|
-
contextualErrorMap:
|
|
449
|
+
async: (r = n == null ? void 0 : n.async) !== null && r !== void 0 ? r : !1,
|
|
450
|
+
contextualErrorMap: n == null ? void 0 : n.errorMap
|
|
451
451
|
},
|
|
452
|
-
path: (
|
|
452
|
+
path: (n == null ? void 0 : n.path) || [],
|
|
453
453
|
schemaErrorMap: this._def.errorMap,
|
|
454
454
|
parent: null,
|
|
455
455
|
data: e,
|
|
456
|
-
parsedType:
|
|
456
|
+
parsedType: pe(e)
|
|
457
457
|
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
458
|
-
return
|
|
458
|
+
return Bt(s, a);
|
|
459
459
|
}
|
|
460
|
-
async parseAsync(e,
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
return
|
|
464
|
-
throw
|
|
460
|
+
async parseAsync(e, n) {
|
|
461
|
+
const r = await this.safeParseAsync(e, n);
|
|
462
|
+
if (r.success)
|
|
463
|
+
return r.data;
|
|
464
|
+
throw r.error;
|
|
465
465
|
}
|
|
466
|
-
async safeParseAsync(e,
|
|
467
|
-
const
|
|
466
|
+
async safeParseAsync(e, n) {
|
|
467
|
+
const r = {
|
|
468
468
|
common: {
|
|
469
469
|
issues: [],
|
|
470
|
-
contextualErrorMap:
|
|
470
|
+
contextualErrorMap: n == null ? void 0 : n.errorMap,
|
|
471
471
|
async: !0
|
|
472
472
|
},
|
|
473
|
-
path: (
|
|
473
|
+
path: (n == null ? void 0 : n.path) || [],
|
|
474
474
|
schemaErrorMap: this._def.errorMap,
|
|
475
475
|
parent: null,
|
|
476
476
|
data: e,
|
|
477
|
-
parsedType:
|
|
478
|
-
}, s = this._parse({ data: e, path:
|
|
479
|
-
return
|
|
477
|
+
parsedType: pe(e)
|
|
478
|
+
}, s = this._parse({ data: e, path: r.path, parent: r }), a = await (Be(s) ? s : Promise.resolve(s));
|
|
479
|
+
return Bt(r, a);
|
|
480
480
|
}
|
|
481
|
-
refine(e,
|
|
482
|
-
const
|
|
481
|
+
refine(e, n) {
|
|
482
|
+
const r = (s) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(s) : n;
|
|
483
483
|
return this._refinement((s, a) => {
|
|
484
484
|
const o = e(s), c = () => a.addIssue({
|
|
485
485
|
code: l.custom,
|
|
486
|
-
...
|
|
486
|
+
...r(s)
|
|
487
487
|
});
|
|
488
488
|
return typeof Promise < "u" && o instanceof Promise ? o.then((u) => u ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
489
489
|
});
|
|
490
490
|
}
|
|
491
|
-
refinement(e,
|
|
492
|
-
return this._refinement((
|
|
491
|
+
refinement(e, n) {
|
|
492
|
+
return this._refinement((r, s) => e(r) ? !0 : (s.addIssue(typeof n == "function" ? n(r, s) : n), !1));
|
|
493
493
|
}
|
|
494
494
|
_refinement(e) {
|
|
495
|
-
return new
|
|
495
|
+
return new J({
|
|
496
496
|
schema: this,
|
|
497
497
|
typeName: y.ZodEffects,
|
|
498
498
|
effect: { type: "refinement", refinement: e }
|
|
@@ -502,28 +502,28 @@ class v {
|
|
|
502
502
|
return this._refinement(e);
|
|
503
503
|
}
|
|
504
504
|
optional() {
|
|
505
|
-
return
|
|
505
|
+
return ne.create(this, this._def);
|
|
506
506
|
}
|
|
507
507
|
nullable() {
|
|
508
|
-
return
|
|
508
|
+
return be.create(this, this._def);
|
|
509
509
|
}
|
|
510
510
|
nullish() {
|
|
511
511
|
return this.nullable().optional();
|
|
512
512
|
}
|
|
513
513
|
array() {
|
|
514
|
-
return
|
|
514
|
+
return Y.create(this, this._def);
|
|
515
515
|
}
|
|
516
516
|
promise() {
|
|
517
|
-
return
|
|
517
|
+
return Me.create(this, this._def);
|
|
518
518
|
}
|
|
519
519
|
or(e) {
|
|
520
|
-
return
|
|
520
|
+
return Ke.create([this, e], this._def);
|
|
521
521
|
}
|
|
522
522
|
and(e) {
|
|
523
|
-
return
|
|
523
|
+
return Ye.create(this, e, this._def);
|
|
524
524
|
}
|
|
525
525
|
transform(e) {
|
|
526
|
-
return new
|
|
526
|
+
return new J({
|
|
527
527
|
..._(this._def),
|
|
528
528
|
schema: this,
|
|
529
529
|
typeName: y.ZodEffects,
|
|
@@ -531,42 +531,42 @@ class v {
|
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
533
|
default(e) {
|
|
534
|
-
const
|
|
535
|
-
return new
|
|
534
|
+
const n = typeof e == "function" ? e : () => e;
|
|
535
|
+
return new et({
|
|
536
536
|
..._(this._def),
|
|
537
537
|
innerType: this,
|
|
538
|
-
defaultValue:
|
|
538
|
+
defaultValue: n,
|
|
539
539
|
typeName: y.ZodDefault
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
brand() {
|
|
543
|
-
return new
|
|
543
|
+
return new At({
|
|
544
544
|
typeName: y.ZodBranded,
|
|
545
545
|
type: this,
|
|
546
546
|
..._(this._def)
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
catch(e) {
|
|
550
|
-
const
|
|
551
|
-
return new
|
|
550
|
+
const n = typeof e == "function" ? e : () => e;
|
|
551
|
+
return new tt({
|
|
552
552
|
..._(this._def),
|
|
553
553
|
innerType: this,
|
|
554
|
-
catchValue:
|
|
554
|
+
catchValue: n,
|
|
555
555
|
typeName: y.ZodCatch
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
558
|
describe(e) {
|
|
559
|
-
const
|
|
560
|
-
return new
|
|
559
|
+
const n = this.constructor;
|
|
560
|
+
return new n({
|
|
561
561
|
...this._def,
|
|
562
562
|
description: e
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
565
|
pipe(e) {
|
|
566
|
-
return
|
|
566
|
+
return at.create(this, e);
|
|
567
567
|
}
|
|
568
568
|
readonly() {
|
|
569
|
-
return
|
|
569
|
+
return nt.create(this);
|
|
570
570
|
}
|
|
571
571
|
isOptional() {
|
|
572
572
|
return this.safeParse(void 0).success;
|
|
@@ -575,25 +575,25 @@ class v {
|
|
|
575
575
|
return this.safeParse(null).success;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
let
|
|
580
|
-
const
|
|
581
|
-
function
|
|
578
|
+
const Qn = /^c[^\s-]{8,}$/i, er = /^[0-9a-z]+$/, tr = /^[0-9A-HJKMNP-TV-Z]{26}$/, nr = /^[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, rr = /^[a-z0-9_-]{21}$/i, sr = /^[-+]?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)?)??$/, ar = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, ir = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
579
|
+
let kt;
|
|
580
|
+
const or = /^(?:(?: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])$/, cr = /^(([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})))$/, dr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, nn = "((\\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])))", ur = new RegExp(`^${nn}$`);
|
|
581
|
+
function rn(t) {
|
|
582
582
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
583
583
|
return t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
584
584
|
}
|
|
585
|
-
function
|
|
586
|
-
return new RegExp(`^${
|
|
585
|
+
function lr(t) {
|
|
586
|
+
return new RegExp(`^${rn(t)}$`);
|
|
587
587
|
}
|
|
588
|
-
function
|
|
589
|
-
let e = `${
|
|
590
|
-
const
|
|
591
|
-
return
|
|
588
|
+
function sn(t) {
|
|
589
|
+
let e = `${nn}T${rn(t)}`;
|
|
590
|
+
const n = [];
|
|
591
|
+
return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
return !!((e === "v4" || !e) &&
|
|
593
|
+
function fr(t, e) {
|
|
594
|
+
return !!((e === "v4" || !e) && or.test(t) || (e === "v6" || !e) && cr.test(t));
|
|
595
595
|
}
|
|
596
|
-
class
|
|
596
|
+
class K extends v {
|
|
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);
|
|
@@ -603,7 +603,7 @@ class W extends v {
|
|
|
603
603
|
received: a.parsedType
|
|
604
604
|
}), g;
|
|
605
605
|
}
|
|
606
|
-
const
|
|
606
|
+
const r = new Z();
|
|
607
607
|
let s;
|
|
608
608
|
for (const a of this._def.checks)
|
|
609
609
|
if (a.kind === "min")
|
|
@@ -614,7 +614,7 @@ class W extends v {
|
|
|
614
614
|
inclusive: !0,
|
|
615
615
|
exact: !1,
|
|
616
616
|
message: a.message
|
|
617
|
-
}),
|
|
617
|
+
}), r.dirty());
|
|
618
618
|
else if (a.kind === "max")
|
|
619
619
|
e.data.length > a.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
620
620
|
code: l.too_big,
|
|
@@ -623,7 +623,7 @@ class W extends v {
|
|
|
623
623
|
inclusive: !0,
|
|
624
624
|
exact: !1,
|
|
625
625
|
message: a.message
|
|
626
|
-
}),
|
|
626
|
+
}), r.dirty());
|
|
627
627
|
else if (a.kind === "length") {
|
|
628
628
|
const o = e.data.length > a.value, c = e.data.length < a.value;
|
|
629
629
|
(o || c) && (s = this._getOrReturnCtx(e, s), o ? m(s, {
|
|
@@ -640,49 +640,49 @@ class W extends v {
|
|
|
640
640
|
inclusive: !0,
|
|
641
641
|
exact: !0,
|
|
642
642
|
message: a.message
|
|
643
|
-
}),
|
|
643
|
+
}), r.dirty());
|
|
644
644
|
} else if (a.kind === "email")
|
|
645
|
-
|
|
645
|
+
ar.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
646
646
|
validation: "email",
|
|
647
647
|
code: l.invalid_string,
|
|
648
648
|
message: a.message
|
|
649
|
-
}),
|
|
649
|
+
}), r.dirty());
|
|
650
650
|
else if (a.kind === "emoji")
|
|
651
|
-
|
|
651
|
+
kt || (kt = new RegExp(ir, "u")), kt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
652
652
|
validation: "emoji",
|
|
653
653
|
code: l.invalid_string,
|
|
654
654
|
message: a.message
|
|
655
|
-
}),
|
|
655
|
+
}), r.dirty());
|
|
656
656
|
else if (a.kind === "uuid")
|
|
657
|
-
|
|
657
|
+
nr.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
658
658
|
validation: "uuid",
|
|
659
659
|
code: l.invalid_string,
|
|
660
660
|
message: a.message
|
|
661
|
-
}),
|
|
661
|
+
}), r.dirty());
|
|
662
662
|
else if (a.kind === "nanoid")
|
|
663
|
-
|
|
663
|
+
rr.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
664
664
|
validation: "nanoid",
|
|
665
665
|
code: l.invalid_string,
|
|
666
666
|
message: a.message
|
|
667
|
-
}),
|
|
667
|
+
}), r.dirty());
|
|
668
668
|
else if (a.kind === "cuid")
|
|
669
|
-
|
|
669
|
+
Qn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
670
670
|
validation: "cuid",
|
|
671
671
|
code: l.invalid_string,
|
|
672
672
|
message: a.message
|
|
673
|
-
}),
|
|
673
|
+
}), r.dirty());
|
|
674
674
|
else if (a.kind === "cuid2")
|
|
675
|
-
|
|
675
|
+
er.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
676
676
|
validation: "cuid2",
|
|
677
677
|
code: l.invalid_string,
|
|
678
678
|
message: a.message
|
|
679
|
-
}),
|
|
679
|
+
}), r.dirty());
|
|
680
680
|
else if (a.kind === "ulid")
|
|
681
|
-
|
|
681
|
+
tr.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
682
682
|
validation: "ulid",
|
|
683
683
|
code: l.invalid_string,
|
|
684
684
|
message: a.message
|
|
685
|
-
}),
|
|
685
|
+
}), r.dirty());
|
|
686
686
|
else if (a.kind === "url")
|
|
687
687
|
try {
|
|
688
688
|
new URL(e.data);
|
|
@@ -691,60 +691,60 @@ class W extends v {
|
|
|
691
691
|
validation: "url",
|
|
692
692
|
code: l.invalid_string,
|
|
693
693
|
message: a.message
|
|
694
|
-
}),
|
|
694
|
+
}), r.dirty();
|
|
695
695
|
}
|
|
696
696
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
697
697
|
validation: "regex",
|
|
698
698
|
code: l.invalid_string,
|
|
699
699
|
message: a.message
|
|
700
|
-
}),
|
|
700
|
+
}), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
701
701
|
code: l.invalid_string,
|
|
702
702
|
validation: { includes: a.value, position: a.position },
|
|
703
703
|
message: a.message
|
|
704
|
-
}),
|
|
704
|
+
}), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
705
705
|
code: l.invalid_string,
|
|
706
706
|
validation: { startsWith: a.value },
|
|
707
707
|
message: a.message
|
|
708
|
-
}),
|
|
708
|
+
}), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
709
709
|
code: l.invalid_string,
|
|
710
710
|
validation: { endsWith: a.value },
|
|
711
711
|
message: a.message
|
|
712
|
-
}),
|
|
712
|
+
}), r.dirty()) : a.kind === "datetime" ? sn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
713
713
|
code: l.invalid_string,
|
|
714
714
|
validation: "datetime",
|
|
715
715
|
message: a.message
|
|
716
|
-
}),
|
|
716
|
+
}), r.dirty()) : a.kind === "date" ? ur.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
717
717
|
code: l.invalid_string,
|
|
718
718
|
validation: "date",
|
|
719
719
|
message: a.message
|
|
720
|
-
}),
|
|
720
|
+
}), r.dirty()) : a.kind === "time" ? lr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
721
721
|
code: l.invalid_string,
|
|
722
722
|
validation: "time",
|
|
723
723
|
message: a.message
|
|
724
|
-
}),
|
|
724
|
+
}), r.dirty()) : a.kind === "duration" ? sr.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
725
725
|
validation: "duration",
|
|
726
726
|
code: l.invalid_string,
|
|
727
727
|
message: a.message
|
|
728
|
-
}),
|
|
728
|
+
}), r.dirty()) : a.kind === "ip" ? fr(e.data, a.version) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
729
729
|
validation: "ip",
|
|
730
730
|
code: l.invalid_string,
|
|
731
731
|
message: a.message
|
|
732
|
-
}),
|
|
732
|
+
}), r.dirty()) : a.kind === "base64" ? dr.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
733
733
|
validation: "base64",
|
|
734
734
|
code: l.invalid_string,
|
|
735
735
|
message: a.message
|
|
736
|
-
}),
|
|
737
|
-
return { status:
|
|
736
|
+
}), r.dirty()) : x.assertNever(a);
|
|
737
|
+
return { status: r.value, value: e.data };
|
|
738
738
|
}
|
|
739
|
-
_regex(e,
|
|
739
|
+
_regex(e, n, r) {
|
|
740
740
|
return this.refinement((s) => e.test(s), {
|
|
741
|
-
validation:
|
|
741
|
+
validation: n,
|
|
742
742
|
code: l.invalid_string,
|
|
743
|
-
...p.errToObj(
|
|
743
|
+
...p.errToObj(r)
|
|
744
744
|
});
|
|
745
745
|
}
|
|
746
746
|
_addCheck(e) {
|
|
747
|
-
return new
|
|
747
|
+
return new K({
|
|
748
748
|
...this._def,
|
|
749
749
|
checks: [...this._def.checks, e]
|
|
750
750
|
});
|
|
@@ -780,7 +780,7 @@ class W extends v {
|
|
|
780
780
|
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
781
781
|
}
|
|
782
782
|
datetime(e) {
|
|
783
|
-
var
|
|
783
|
+
var n, r;
|
|
784
784
|
return typeof e == "string" ? this._addCheck({
|
|
785
785
|
kind: "datetime",
|
|
786
786
|
precision: null,
|
|
@@ -790,8 +790,8 @@ class W extends v {
|
|
|
790
790
|
}) : this._addCheck({
|
|
791
791
|
kind: "datetime",
|
|
792
792
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
793
|
-
offset: (
|
|
794
|
-
local: (
|
|
793
|
+
offset: (n = e == null ? void 0 : e.offset) !== null && n !== void 0 ? n : !1,
|
|
794
|
+
local: (r = e == null ? void 0 : e.local) !== null && r !== void 0 ? r : !1,
|
|
795
795
|
...p.errToObj(e == null ? void 0 : e.message)
|
|
796
796
|
});
|
|
797
797
|
}
|
|
@@ -812,54 +812,54 @@ class W extends v {
|
|
|
812
812
|
duration(e) {
|
|
813
813
|
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
814
814
|
}
|
|
815
|
-
regex(e,
|
|
815
|
+
regex(e, n) {
|
|
816
816
|
return this._addCheck({
|
|
817
817
|
kind: "regex",
|
|
818
818
|
regex: e,
|
|
819
|
-
...p.errToObj(
|
|
819
|
+
...p.errToObj(n)
|
|
820
820
|
});
|
|
821
821
|
}
|
|
822
|
-
includes(e,
|
|
822
|
+
includes(e, n) {
|
|
823
823
|
return this._addCheck({
|
|
824
824
|
kind: "includes",
|
|
825
825
|
value: e,
|
|
826
|
-
position:
|
|
827
|
-
...p.errToObj(
|
|
826
|
+
position: n == null ? void 0 : n.position,
|
|
827
|
+
...p.errToObj(n == null ? void 0 : n.message)
|
|
828
828
|
});
|
|
829
829
|
}
|
|
830
|
-
startsWith(e,
|
|
830
|
+
startsWith(e, n) {
|
|
831
831
|
return this._addCheck({
|
|
832
832
|
kind: "startsWith",
|
|
833
833
|
value: e,
|
|
834
|
-
...p.errToObj(
|
|
834
|
+
...p.errToObj(n)
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
endsWith(e,
|
|
837
|
+
endsWith(e, n) {
|
|
838
838
|
return this._addCheck({
|
|
839
839
|
kind: "endsWith",
|
|
840
840
|
value: e,
|
|
841
|
-
...p.errToObj(
|
|
841
|
+
...p.errToObj(n)
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
|
-
min(e,
|
|
844
|
+
min(e, n) {
|
|
845
845
|
return this._addCheck({
|
|
846
846
|
kind: "min",
|
|
847
847
|
value: e,
|
|
848
|
-
...p.errToObj(
|
|
848
|
+
...p.errToObj(n)
|
|
849
849
|
});
|
|
850
850
|
}
|
|
851
|
-
max(e,
|
|
851
|
+
max(e, n) {
|
|
852
852
|
return this._addCheck({
|
|
853
853
|
kind: "max",
|
|
854
854
|
value: e,
|
|
855
|
-
...p.errToObj(
|
|
855
|
+
...p.errToObj(n)
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
|
-
length(e,
|
|
858
|
+
length(e, n) {
|
|
859
859
|
return this._addCheck({
|
|
860
860
|
kind: "length",
|
|
861
861
|
value: e,
|
|
862
|
-
...p.errToObj(
|
|
862
|
+
...p.errToObj(n)
|
|
863
863
|
});
|
|
864
864
|
}
|
|
865
865
|
/**
|
|
@@ -870,19 +870,19 @@ class W extends v {
|
|
|
870
870
|
return this.min(1, p.errToObj(e));
|
|
871
871
|
}
|
|
872
872
|
trim() {
|
|
873
|
-
return new
|
|
873
|
+
return new K({
|
|
874
874
|
...this._def,
|
|
875
875
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
878
|
toLowerCase() {
|
|
879
|
-
return new
|
|
879
|
+
return new K({
|
|
880
880
|
...this._def,
|
|
881
881
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
882
882
|
});
|
|
883
883
|
}
|
|
884
884
|
toUpperCase() {
|
|
885
|
-
return new
|
|
885
|
+
return new K({
|
|
886
886
|
...this._def,
|
|
887
887
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
888
888
|
});
|
|
@@ -931,31 +931,31 @@ class W extends v {
|
|
|
931
931
|
}
|
|
932
932
|
get minLength() {
|
|
933
933
|
let e = null;
|
|
934
|
-
for (const
|
|
935
|
-
|
|
934
|
+
for (const n of this._def.checks)
|
|
935
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
936
936
|
return e;
|
|
937
937
|
}
|
|
938
938
|
get maxLength() {
|
|
939
939
|
let e = null;
|
|
940
|
-
for (const
|
|
941
|
-
|
|
940
|
+
for (const n of this._def.checks)
|
|
941
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
942
942
|
return e;
|
|
943
943
|
}
|
|
944
944
|
}
|
|
945
|
-
|
|
945
|
+
K.create = (t) => {
|
|
946
946
|
var e;
|
|
947
|
-
return new
|
|
947
|
+
return new K({
|
|
948
948
|
checks: [],
|
|
949
949
|
typeName: y.ZodString,
|
|
950
950
|
coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
|
|
951
951
|
..._(t)
|
|
952
952
|
});
|
|
953
953
|
};
|
|
954
|
-
function
|
|
955
|
-
const
|
|
954
|
+
function mr(t, e) {
|
|
955
|
+
const n = (t.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = n > r ? n : r, a = parseInt(t.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
|
|
956
956
|
return a % o / Math.pow(10, s);
|
|
957
957
|
}
|
|
958
|
-
class
|
|
958
|
+
class ge extends v {
|
|
959
959
|
constructor() {
|
|
960
960
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
961
961
|
}
|
|
@@ -968,66 +968,66 @@ class pe extends v {
|
|
|
968
968
|
received: a.parsedType
|
|
969
969
|
}), g;
|
|
970
970
|
}
|
|
971
|
-
let
|
|
972
|
-
const s = new
|
|
971
|
+
let r;
|
|
972
|
+
const s = new Z();
|
|
973
973
|
for (const a of this._def.checks)
|
|
974
|
-
a.kind === "int" ? x.isInteger(e.data) || (
|
|
974
|
+
a.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
975
975
|
code: l.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) && (
|
|
979
|
+
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
980
980
|
code: l.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) && (
|
|
986
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
987
987
|
code: l.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" ? mr(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
994
994
|
code: l.not_multiple_of,
|
|
995
995
|
multipleOf: a.value,
|
|
996
996
|
message: a.message
|
|
997
|
-
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (
|
|
997
|
+
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
998
998
|
code: l.not_finite,
|
|
999
999
|
message: a.message
|
|
1000
1000
|
}), s.dirty()) : x.assertNever(a);
|
|
1001
1001
|
return { status: s.value, value: e.data };
|
|
1002
1002
|
}
|
|
1003
|
-
gte(e,
|
|
1004
|
-
return this.setLimit("min", e, !0, p.toString(
|
|
1003
|
+
gte(e, n) {
|
|
1004
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
1005
1005
|
}
|
|
1006
|
-
gt(e,
|
|
1007
|
-
return this.setLimit("min", e, !1, p.toString(
|
|
1006
|
+
gt(e, n) {
|
|
1007
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
1008
1008
|
}
|
|
1009
|
-
lte(e,
|
|
1010
|
-
return this.setLimit("max", e, !0, p.toString(
|
|
1009
|
+
lte(e, n) {
|
|
1010
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
1011
1011
|
}
|
|
1012
|
-
lt(e,
|
|
1013
|
-
return this.setLimit("max", e, !1, p.toString(
|
|
1012
|
+
lt(e, n) {
|
|
1013
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
1014
1014
|
}
|
|
1015
|
-
setLimit(e,
|
|
1016
|
-
return new
|
|
1015
|
+
setLimit(e, n, r, s) {
|
|
1016
|
+
return new ge({
|
|
1017
1017
|
...this._def,
|
|
1018
1018
|
checks: [
|
|
1019
1019
|
...this._def.checks,
|
|
1020
1020
|
{
|
|
1021
1021
|
kind: e,
|
|
1022
|
-
value:
|
|
1023
|
-
inclusive:
|
|
1022
|
+
value: n,
|
|
1023
|
+
inclusive: r,
|
|
1024
1024
|
message: p.toString(s)
|
|
1025
1025
|
}
|
|
1026
1026
|
]
|
|
1027
1027
|
});
|
|
1028
1028
|
}
|
|
1029
1029
|
_addCheck(e) {
|
|
1030
|
-
return new
|
|
1030
|
+
return new ge({
|
|
1031
1031
|
...this._def,
|
|
1032
1032
|
checks: [...this._def.checks, e]
|
|
1033
1033
|
});
|
|
@@ -1070,11 +1070,11 @@ class pe extends v {
|
|
|
1070
1070
|
message: p.toString(e)
|
|
1071
1071
|
});
|
|
1072
1072
|
}
|
|
1073
|
-
multipleOf(e,
|
|
1073
|
+
multipleOf(e, n) {
|
|
1074
1074
|
return this._addCheck({
|
|
1075
1075
|
kind: "multipleOf",
|
|
1076
1076
|
value: e,
|
|
1077
|
-
message: p.toString(
|
|
1077
|
+
message: p.toString(n)
|
|
1078
1078
|
});
|
|
1079
1079
|
}
|
|
1080
1080
|
finite(e) {
|
|
@@ -1098,36 +1098,36 @@ class pe extends v {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
get minValue() {
|
|
1100
1100
|
let e = null;
|
|
1101
|
-
for (const
|
|
1102
|
-
|
|
1101
|
+
for (const n of this._def.checks)
|
|
1102
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1103
1103
|
return e;
|
|
1104
1104
|
}
|
|
1105
1105
|
get maxValue() {
|
|
1106
1106
|
let e = null;
|
|
1107
|
-
for (const
|
|
1108
|
-
|
|
1107
|
+
for (const n of this._def.checks)
|
|
1108
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1109
1109
|
return e;
|
|
1110
1110
|
}
|
|
1111
1111
|
get isInt() {
|
|
1112
1112
|
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
|
|
1113
1113
|
}
|
|
1114
1114
|
get isFinite() {
|
|
1115
|
-
let e = null,
|
|
1116
|
-
for (const
|
|
1117
|
-
if (
|
|
1115
|
+
let e = null, n = null;
|
|
1116
|
+
for (const r of this._def.checks) {
|
|
1117
|
+
if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
|
|
1118
1118
|
return !0;
|
|
1119
|
-
|
|
1119
|
+
r.kind === "min" ? (n === null || r.value > n) && (n = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1120
1120
|
}
|
|
1121
|
-
return Number.isFinite(
|
|
1121
|
+
return Number.isFinite(n) && Number.isFinite(e);
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
|
-
|
|
1124
|
+
ge.create = (t) => new ge({
|
|
1125
1125
|
checks: [],
|
|
1126
1126
|
typeName: y.ZodNumber,
|
|
1127
1127
|
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1128
1128
|
..._(t)
|
|
1129
1129
|
});
|
|
1130
|
-
class
|
|
1130
|
+
class _e extends v {
|
|
1131
1131
|
constructor() {
|
|
1132
1132
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1133
1133
|
}
|
|
@@ -1140,56 +1140,56 @@ class ye extends v {
|
|
|
1140
1140
|
received: a.parsedType
|
|
1141
1141
|
}), g;
|
|
1142
1142
|
}
|
|
1143
|
-
let
|
|
1144
|
-
const s = new
|
|
1143
|
+
let r;
|
|
1144
|
+
const s = new Z();
|
|
1145
1145
|
for (const a of this._def.checks)
|
|
1146
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1146
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1147
1147
|
code: l.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) && (
|
|
1152
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1153
1153
|
code: l.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) && (
|
|
1158
|
+
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1159
1159
|
code: l.not_multiple_of,
|
|
1160
1160
|
multipleOf: a.value,
|
|
1161
1161
|
message: a.message
|
|
1162
1162
|
}), s.dirty()) : x.assertNever(a);
|
|
1163
1163
|
return { status: s.value, value: e.data };
|
|
1164
1164
|
}
|
|
1165
|
-
gte(e,
|
|
1166
|
-
return this.setLimit("min", e, !0, p.toString(
|
|
1165
|
+
gte(e, n) {
|
|
1166
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
1167
1167
|
}
|
|
1168
|
-
gt(e,
|
|
1169
|
-
return this.setLimit("min", e, !1, p.toString(
|
|
1168
|
+
gt(e, n) {
|
|
1169
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
1170
1170
|
}
|
|
1171
|
-
lte(e,
|
|
1172
|
-
return this.setLimit("max", e, !0, p.toString(
|
|
1171
|
+
lte(e, n) {
|
|
1172
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
1173
1173
|
}
|
|
1174
|
-
lt(e,
|
|
1175
|
-
return this.setLimit("max", e, !1, p.toString(
|
|
1174
|
+
lt(e, n) {
|
|
1175
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
1176
1176
|
}
|
|
1177
|
-
setLimit(e,
|
|
1178
|
-
return new
|
|
1177
|
+
setLimit(e, n, r, s) {
|
|
1178
|
+
return new _e({
|
|
1179
1179
|
...this._def,
|
|
1180
1180
|
checks: [
|
|
1181
1181
|
...this._def.checks,
|
|
1182
1182
|
{
|
|
1183
1183
|
kind: e,
|
|
1184
|
-
value:
|
|
1185
|
-
inclusive:
|
|
1184
|
+
value: n,
|
|
1185
|
+
inclusive: r,
|
|
1186
1186
|
message: p.toString(s)
|
|
1187
1187
|
}
|
|
1188
1188
|
]
|
|
1189
1189
|
});
|
|
1190
1190
|
}
|
|
1191
1191
|
_addCheck(e) {
|
|
1192
|
-
return new
|
|
1192
|
+
return new _e({
|
|
1193
1193
|
...this._def,
|
|
1194
1194
|
checks: [...this._def.checks, e]
|
|
1195
1195
|
});
|
|
@@ -1226,54 +1226,54 @@ class ye extends v {
|
|
|
1226
1226
|
message: p.toString(e)
|
|
1227
1227
|
});
|
|
1228
1228
|
}
|
|
1229
|
-
multipleOf(e,
|
|
1229
|
+
multipleOf(e, n) {
|
|
1230
1230
|
return this._addCheck({
|
|
1231
1231
|
kind: "multipleOf",
|
|
1232
1232
|
value: e,
|
|
1233
|
-
message: p.toString(
|
|
1233
|
+
message: p.toString(n)
|
|
1234
1234
|
});
|
|
1235
1235
|
}
|
|
1236
1236
|
get minValue() {
|
|
1237
1237
|
let e = null;
|
|
1238
|
-
for (const
|
|
1239
|
-
|
|
1238
|
+
for (const n of this._def.checks)
|
|
1239
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1240
1240
|
return e;
|
|
1241
1241
|
}
|
|
1242
1242
|
get maxValue() {
|
|
1243
1243
|
let e = null;
|
|
1244
|
-
for (const
|
|
1245
|
-
|
|
1244
|
+
for (const n of this._def.checks)
|
|
1245
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1246
1246
|
return e;
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
|
|
1249
|
+
_e.create = (t) => {
|
|
1250
1250
|
var e;
|
|
1251
|
-
return new
|
|
1251
|
+
return new _e({
|
|
1252
1252
|
checks: [],
|
|
1253
1253
|
typeName: y.ZodBigInt,
|
|
1254
1254
|
coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
|
|
1255
1255
|
..._(t)
|
|
1256
1256
|
});
|
|
1257
1257
|
};
|
|
1258
|
-
class
|
|
1258
|
+
class He extends v {
|
|
1259
1259
|
_parse(e) {
|
|
1260
1260
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1261
|
-
const
|
|
1262
|
-
return m(
|
|
1261
|
+
const r = this._getOrReturnCtx(e);
|
|
1262
|
+
return m(r, {
|
|
1263
1263
|
code: l.invalid_type,
|
|
1264
1264
|
expected: h.boolean,
|
|
1265
|
-
received:
|
|
1265
|
+
received: r.parsedType
|
|
1266
1266
|
}), g;
|
|
1267
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return $(e.data);
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
|
-
|
|
1271
|
+
He.create = (t) => new He({
|
|
1272
1272
|
typeName: y.ZodBoolean,
|
|
1273
1273
|
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1274
1274
|
..._(t)
|
|
1275
1275
|
});
|
|
1276
|
-
class
|
|
1276
|
+
class Se extends v {
|
|
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);
|
|
@@ -1289,7 +1289,7 @@ class Te extends v {
|
|
|
1289
1289
|
code: l.invalid_date
|
|
1290
1290
|
}), g;
|
|
1291
1291
|
}
|
|
1292
|
-
const
|
|
1292
|
+
const r = new Z();
|
|
1293
1293
|
let s;
|
|
1294
1294
|
for (const a of this._def.checks)
|
|
1295
1295
|
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
@@ -1299,176 +1299,176 @@ class Te extends v {
|
|
|
1299
1299
|
exact: !1,
|
|
1300
1300
|
minimum: a.value,
|
|
1301
1301
|
type: "date"
|
|
1302
|
-
}),
|
|
1302
|
+
}), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
1303
1303
|
code: l.too_big,
|
|
1304
1304
|
message: a.message,
|
|
1305
1305
|
inclusive: !0,
|
|
1306
1306
|
exact: !1,
|
|
1307
1307
|
maximum: a.value,
|
|
1308
1308
|
type: "date"
|
|
1309
|
-
}),
|
|
1309
|
+
}), r.dirty()) : x.assertNever(a);
|
|
1310
1310
|
return {
|
|
1311
|
-
status:
|
|
1311
|
+
status: r.value,
|
|
1312
1312
|
value: new Date(e.data.getTime())
|
|
1313
1313
|
};
|
|
1314
1314
|
}
|
|
1315
1315
|
_addCheck(e) {
|
|
1316
|
-
return new
|
|
1316
|
+
return new Se({
|
|
1317
1317
|
...this._def,
|
|
1318
1318
|
checks: [...this._def.checks, e]
|
|
1319
1319
|
});
|
|
1320
1320
|
}
|
|
1321
|
-
min(e,
|
|
1321
|
+
min(e, n) {
|
|
1322
1322
|
return this._addCheck({
|
|
1323
1323
|
kind: "min",
|
|
1324
1324
|
value: e.getTime(),
|
|
1325
|
-
message: p.toString(
|
|
1325
|
+
message: p.toString(n)
|
|
1326
1326
|
});
|
|
1327
1327
|
}
|
|
1328
|
-
max(e,
|
|
1328
|
+
max(e, n) {
|
|
1329
1329
|
return this._addCheck({
|
|
1330
1330
|
kind: "max",
|
|
1331
1331
|
value: e.getTime(),
|
|
1332
|
-
message: p.toString(
|
|
1332
|
+
message: p.toString(n)
|
|
1333
1333
|
});
|
|
1334
1334
|
}
|
|
1335
1335
|
get minDate() {
|
|
1336
1336
|
let e = null;
|
|
1337
|
-
for (const
|
|
1338
|
-
|
|
1337
|
+
for (const n of this._def.checks)
|
|
1338
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1339
1339
|
return e != null ? new Date(e) : null;
|
|
1340
1340
|
}
|
|
1341
1341
|
get maxDate() {
|
|
1342
1342
|
let e = null;
|
|
1343
|
-
for (const
|
|
1344
|
-
|
|
1343
|
+
for (const n of this._def.checks)
|
|
1344
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1345
1345
|
return e != null ? new Date(e) : null;
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
|
|
1348
|
+
Se.create = (t) => new Se({
|
|
1349
1349
|
checks: [],
|
|
1350
1350
|
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1351
1351
|
typeName: y.ZodDate,
|
|
1352
1352
|
..._(t)
|
|
1353
1353
|
});
|
|
1354
|
-
class
|
|
1354
|
+
class ht extends v {
|
|
1355
1355
|
_parse(e) {
|
|
1356
1356
|
if (this._getType(e) !== h.symbol) {
|
|
1357
|
-
const
|
|
1358
|
-
return m(
|
|
1357
|
+
const r = this._getOrReturnCtx(e);
|
|
1358
|
+
return m(r, {
|
|
1359
1359
|
code: l.invalid_type,
|
|
1360
1360
|
expected: h.symbol,
|
|
1361
|
-
received:
|
|
1361
|
+
received: r.parsedType
|
|
1362
1362
|
}), g;
|
|
1363
1363
|
}
|
|
1364
|
-
return
|
|
1364
|
+
return $(e.data);
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
|
-
|
|
1367
|
+
ht.create = (t) => new ht({
|
|
1368
1368
|
typeName: y.ZodSymbol,
|
|
1369
1369
|
..._(t)
|
|
1370
1370
|
});
|
|
1371
|
-
class
|
|
1371
|
+
class qe extends v {
|
|
1372
1372
|
_parse(e) {
|
|
1373
1373
|
if (this._getType(e) !== h.undefined) {
|
|
1374
|
-
const
|
|
1375
|
-
return m(
|
|
1374
|
+
const r = this._getOrReturnCtx(e);
|
|
1375
|
+
return m(r, {
|
|
1376
1376
|
code: l.invalid_type,
|
|
1377
1377
|
expected: h.undefined,
|
|
1378
|
-
received:
|
|
1378
|
+
received: r.parsedType
|
|
1379
1379
|
}), g;
|
|
1380
1380
|
}
|
|
1381
|
-
return
|
|
1381
|
+
return $(e.data);
|
|
1382
1382
|
}
|
|
1383
1383
|
}
|
|
1384
|
-
|
|
1384
|
+
qe.create = (t) => new qe({
|
|
1385
1385
|
typeName: y.ZodUndefined,
|
|
1386
1386
|
..._(t)
|
|
1387
1387
|
});
|
|
1388
|
-
class
|
|
1388
|
+
class We extends v {
|
|
1389
1389
|
_parse(e) {
|
|
1390
1390
|
if (this._getType(e) !== h.null) {
|
|
1391
|
-
const
|
|
1392
|
-
return m(
|
|
1391
|
+
const r = this._getOrReturnCtx(e);
|
|
1392
|
+
return m(r, {
|
|
1393
1393
|
code: l.invalid_type,
|
|
1394
1394
|
expected: h.null,
|
|
1395
|
-
received:
|
|
1395
|
+
received: r.parsedType
|
|
1396
1396
|
}), g;
|
|
1397
1397
|
}
|
|
1398
|
-
return
|
|
1398
|
+
return $(e.data);
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
|
-
|
|
1401
|
+
We.create = (t) => new We({
|
|
1402
1402
|
typeName: y.ZodNull,
|
|
1403
1403
|
..._(t)
|
|
1404
1404
|
});
|
|
1405
|
-
class
|
|
1405
|
+
class Ne extends v {
|
|
1406
1406
|
constructor() {
|
|
1407
1407
|
super(...arguments), this._any = !0;
|
|
1408
1408
|
}
|
|
1409
1409
|
_parse(e) {
|
|
1410
|
-
return
|
|
1410
|
+
return $(e.data);
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
|
-
|
|
1413
|
+
Ne.create = (t) => new Ne({
|
|
1414
1414
|
typeName: y.ZodAny,
|
|
1415
1415
|
..._(t)
|
|
1416
1416
|
});
|
|
1417
|
-
class
|
|
1417
|
+
class Ce extends v {
|
|
1418
1418
|
constructor() {
|
|
1419
1419
|
super(...arguments), this._unknown = !0;
|
|
1420
1420
|
}
|
|
1421
1421
|
_parse(e) {
|
|
1422
|
-
return
|
|
1422
|
+
return $(e.data);
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
|
|
1425
|
+
Ce.create = (t) => new Ce({
|
|
1426
1426
|
typeName: y.ZodUnknown,
|
|
1427
1427
|
..._(t)
|
|
1428
1428
|
});
|
|
1429
|
-
class
|
|
1429
|
+
class ue extends v {
|
|
1430
1430
|
_parse(e) {
|
|
1431
|
-
const
|
|
1432
|
-
return m(
|
|
1431
|
+
const n = this._getOrReturnCtx(e);
|
|
1432
|
+
return m(n, {
|
|
1433
1433
|
code: l.invalid_type,
|
|
1434
1434
|
expected: h.never,
|
|
1435
|
-
received:
|
|
1435
|
+
received: n.parsedType
|
|
1436
1436
|
}), g;
|
|
1437
1437
|
}
|
|
1438
1438
|
}
|
|
1439
|
-
|
|
1439
|
+
ue.create = (t) => new ue({
|
|
1440
1440
|
typeName: y.ZodNever,
|
|
1441
1441
|
..._(t)
|
|
1442
1442
|
});
|
|
1443
|
-
class
|
|
1443
|
+
class pt extends v {
|
|
1444
1444
|
_parse(e) {
|
|
1445
1445
|
if (this._getType(e) !== h.undefined) {
|
|
1446
|
-
const
|
|
1447
|
-
return m(
|
|
1446
|
+
const r = this._getOrReturnCtx(e);
|
|
1447
|
+
return m(r, {
|
|
1448
1448
|
code: l.invalid_type,
|
|
1449
1449
|
expected: h.void,
|
|
1450
|
-
received:
|
|
1450
|
+
received: r.parsedType
|
|
1451
1451
|
}), g;
|
|
1452
1452
|
}
|
|
1453
|
-
return
|
|
1453
|
+
return $(e.data);
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
|
-
|
|
1456
|
+
pt.create = (t) => new pt({
|
|
1457
1457
|
typeName: y.ZodVoid,
|
|
1458
1458
|
..._(t)
|
|
1459
1459
|
});
|
|
1460
|
-
class
|
|
1460
|
+
class Y extends v {
|
|
1461
1461
|
_parse(e) {
|
|
1462
|
-
const { ctx:
|
|
1463
|
-
if (
|
|
1464
|
-
return m(
|
|
1462
|
+
const { ctx: n, status: r } = this._processInputParams(e), s = this._def;
|
|
1463
|
+
if (n.parsedType !== h.array)
|
|
1464
|
+
return m(n, {
|
|
1465
1465
|
code: l.invalid_type,
|
|
1466
1466
|
expected: h.array,
|
|
1467
|
-
received:
|
|
1467
|
+
received: n.parsedType
|
|
1468
1468
|
}), g;
|
|
1469
1469
|
if (s.exactLength !== null) {
|
|
1470
|
-
const o =
|
|
1471
|
-
(o || c) && (m(
|
|
1470
|
+
const o = n.data.length > s.exactLength.value, c = n.data.length < s.exactLength.value;
|
|
1471
|
+
(o || c) && (m(n, {
|
|
1472
1472
|
code: o ? l.too_big : l.too_small,
|
|
1473
1473
|
minimum: c ? s.exactLength.value : void 0,
|
|
1474
1474
|
maximum: o ? s.exactLength.value : void 0,
|
|
@@ -1476,53 +1476,53 @@ class K extends v {
|
|
|
1476
1476
|
inclusive: !0,
|
|
1477
1477
|
exact: !0,
|
|
1478
1478
|
message: s.exactLength.message
|
|
1479
|
-
}),
|
|
1479
|
+
}), r.dirty());
|
|
1480
1480
|
}
|
|
1481
|
-
if (s.minLength !== null &&
|
|
1481
|
+
if (s.minLength !== null && n.data.length < s.minLength.value && (m(n, {
|
|
1482
1482
|
code: l.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
|
-
}),
|
|
1488
|
+
}), r.dirty()), s.maxLength !== null && n.data.length > s.maxLength.value && (m(n, {
|
|
1489
1489
|
code: l.too_big,
|
|
1490
1490
|
maximum: s.maxLength.value,
|
|
1491
1491
|
type: "array",
|
|
1492
1492
|
inclusive: !0,
|
|
1493
1493
|
exact: !1,
|
|
1494
1494
|
message: s.maxLength.message
|
|
1495
|
-
}),
|
|
1496
|
-
return Promise.all([...
|
|
1497
|
-
const a = [...
|
|
1498
|
-
return
|
|
1495
|
+
}), r.dirty()), n.common.async)
|
|
1496
|
+
return Promise.all([...n.data].map((o, c) => s.type._parseAsync(new se(n, o, n.path, c)))).then((o) => Z.mergeArray(r, o));
|
|
1497
|
+
const a = [...n.data].map((o, c) => s.type._parseSync(new se(n, o, n.path, c)));
|
|
1498
|
+
return Z.mergeArray(r, a);
|
|
1499
1499
|
}
|
|
1500
1500
|
get element() {
|
|
1501
1501
|
return this._def.type;
|
|
1502
1502
|
}
|
|
1503
|
-
min(e,
|
|
1504
|
-
return new
|
|
1503
|
+
min(e, n) {
|
|
1504
|
+
return new Y({
|
|
1505
1505
|
...this._def,
|
|
1506
|
-
minLength: { value: e, message: p.toString(
|
|
1506
|
+
minLength: { value: e, message: p.toString(n) }
|
|
1507
1507
|
});
|
|
1508
1508
|
}
|
|
1509
|
-
max(e,
|
|
1510
|
-
return new
|
|
1509
|
+
max(e, n) {
|
|
1510
|
+
return new Y({
|
|
1511
1511
|
...this._def,
|
|
1512
|
-
maxLength: { value: e, message: p.toString(
|
|
1512
|
+
maxLength: { value: e, message: p.toString(n) }
|
|
1513
1513
|
});
|
|
1514
1514
|
}
|
|
1515
|
-
length(e,
|
|
1516
|
-
return new
|
|
1515
|
+
length(e, n) {
|
|
1516
|
+
return new Y({
|
|
1517
1517
|
...this._def,
|
|
1518
|
-
exactLength: { value: e, message: p.toString(
|
|
1518
|
+
exactLength: { value: e, message: p.toString(n) }
|
|
1519
1519
|
});
|
|
1520
1520
|
}
|
|
1521
1521
|
nonempty(e) {
|
|
1522
1522
|
return this.min(1, e);
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
|
-
|
|
1525
|
+
Y.create = (t, e) => new Y({
|
|
1526
1526
|
type: t,
|
|
1527
1527
|
minLength: null,
|
|
1528
1528
|
maxLength: null,
|
|
@@ -1533,18 +1533,18 @@ K.create = (t, e) => new K({
|
|
|
1533
1533
|
function Oe(t) {
|
|
1534
1534
|
if (t instanceof C) {
|
|
1535
1535
|
const e = {};
|
|
1536
|
-
for (const
|
|
1537
|
-
const
|
|
1538
|
-
e[
|
|
1536
|
+
for (const n in t.shape) {
|
|
1537
|
+
const r = t.shape[n];
|
|
1538
|
+
e[n] = ne.create(Oe(r));
|
|
1539
1539
|
}
|
|
1540
1540
|
return new C({
|
|
1541
1541
|
...t._def,
|
|
1542
1542
|
shape: () => e
|
|
1543
1543
|
});
|
|
1544
|
-
} else return t instanceof
|
|
1544
|
+
} else return t instanceof Y ? new Y({
|
|
1545
1545
|
...t._def,
|
|
1546
1546
|
type: Oe(t.element)
|
|
1547
|
-
}) : t instanceof
|
|
1547
|
+
}) : t instanceof ne ? ne.create(Oe(t.unwrap())) : t instanceof be ? be.create(Oe(t.unwrap())) : t instanceof ae ? ae.create(t.items.map((e) => Oe(e))) : t;
|
|
1548
1548
|
}
|
|
1549
1549
|
class C extends v {
|
|
1550
1550
|
constructor() {
|
|
@@ -1553,8 +1553,8 @@ class C extends v {
|
|
|
1553
1553
|
_getCached() {
|
|
1554
1554
|
if (this._cached !== null)
|
|
1555
1555
|
return this._cached;
|
|
1556
|
-
const e = this._def.shape(),
|
|
1557
|
-
return this._cached = { shape: e, keys:
|
|
1556
|
+
const e = this._def.shape(), n = x.objectKeys(e);
|
|
1557
|
+
return this._cached = { shape: e, keys: n };
|
|
1558
1558
|
}
|
|
1559
1559
|
_parse(e) {
|
|
1560
1560
|
if (this._getType(e) !== h.object) {
|
|
@@ -1565,8 +1565,8 @@ class C extends v {
|
|
|
1565
1565
|
received: d.parsedType
|
|
1566
1566
|
}), g;
|
|
1567
1567
|
}
|
|
1568
|
-
const { status:
|
|
1569
|
-
if (!(this._def.catchall instanceof
|
|
1568
|
+
const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), c = [];
|
|
1569
|
+
if (!(this._def.catchall instanceof ue && this._def.unknownKeys === "strip"))
|
|
1570
1570
|
for (const d in s.data)
|
|
1571
1571
|
o.includes(d) || c.push(d);
|
|
1572
1572
|
const u = [];
|
|
@@ -1574,11 +1574,11 @@ class C extends v {
|
|
|
1574
1574
|
const f = a[d], b = s.data[d];
|
|
1575
1575
|
u.push({
|
|
1576
1576
|
key: { status: "valid", value: d },
|
|
1577
|
-
value: f._parse(new
|
|
1577
|
+
value: f._parse(new se(s, b, s.path, d)),
|
|
1578
1578
|
alwaysSet: d in s.data
|
|
1579
1579
|
});
|
|
1580
1580
|
}
|
|
1581
|
-
if (this._def.catchall instanceof
|
|
1581
|
+
if (this._def.catchall instanceof ue) {
|
|
1582
1582
|
const d = this._def.unknownKeys;
|
|
1583
1583
|
if (d === "passthrough")
|
|
1584
1584
|
for (const f of c)
|
|
@@ -1590,7 +1590,7 @@ class C extends v {
|
|
|
1590
1590
|
c.length > 0 && (m(s, {
|
|
1591
1591
|
code: l.unrecognized_keys,
|
|
1592
1592
|
keys: c
|
|
1593
|
-
}),
|
|
1593
|
+
}), r.dirty());
|
|
1594
1594
|
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1595
1595
|
} else {
|
|
1596
1596
|
const d = this._def.catchall;
|
|
@@ -1599,7 +1599,7 @@ class C extends v {
|
|
|
1599
1599
|
u.push({
|
|
1600
1600
|
key: { status: "valid", value: f },
|
|
1601
1601
|
value: d._parse(
|
|
1602
|
-
new
|
|
1602
|
+
new se(s, b, s.path, f)
|
|
1603
1603
|
//, ctx.child(key), value, getParsedType(value)
|
|
1604
1604
|
),
|
|
1605
1605
|
alwaysSet: f in s.data
|
|
@@ -1617,7 +1617,7 @@ class C extends v {
|
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
1619
1619
|
return d;
|
|
1620
|
-
}).then((d) =>
|
|
1620
|
+
}).then((d) => Z.mergeObjectSync(r, d)) : Z.mergeObjectSync(r, u);
|
|
1621
1621
|
}
|
|
1622
1622
|
get shape() {
|
|
1623
1623
|
return this._def.shape();
|
|
@@ -1627,10 +1627,10 @@ class C extends v {
|
|
|
1627
1627
|
...this._def,
|
|
1628
1628
|
unknownKeys: "strict",
|
|
1629
1629
|
...e !== void 0 ? {
|
|
1630
|
-
errorMap: (
|
|
1630
|
+
errorMap: (n, r) => {
|
|
1631
1631
|
var s, a, o, c;
|
|
1632
|
-
const u = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s,
|
|
1633
|
-
return
|
|
1632
|
+
const u = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, n, r).message) !== null && o !== void 0 ? o : r.defaultError;
|
|
1633
|
+
return n.code === "unrecognized_keys" ? {
|
|
1634
1634
|
message: (c = p.errToObj(e).message) !== null && c !== void 0 ? c : u
|
|
1635
1635
|
} : {
|
|
1636
1636
|
message: u
|
|
@@ -1728,8 +1728,8 @@ class C extends v {
|
|
|
1728
1728
|
// }) as any;
|
|
1729
1729
|
// return merged;
|
|
1730
1730
|
// }
|
|
1731
|
-
setKey(e,
|
|
1732
|
-
return this.augment({ [e]:
|
|
1731
|
+
setKey(e, n) {
|
|
1732
|
+
return this.augment({ [e]: n });
|
|
1733
1733
|
}
|
|
1734
1734
|
// merge<Incoming extends AnyZodObject>(
|
|
1735
1735
|
// merging: Incoming
|
|
@@ -1759,21 +1759,21 @@ class C extends v {
|
|
|
1759
1759
|
});
|
|
1760
1760
|
}
|
|
1761
1761
|
pick(e) {
|
|
1762
|
-
const
|
|
1763
|
-
return x.objectKeys(e).forEach((
|
|
1764
|
-
e[
|
|
1762
|
+
const n = {};
|
|
1763
|
+
return x.objectKeys(e).forEach((r) => {
|
|
1764
|
+
e[r] && this.shape[r] && (n[r] = this.shape[r]);
|
|
1765
1765
|
}), new C({
|
|
1766
1766
|
...this._def,
|
|
1767
|
-
shape: () =>
|
|
1767
|
+
shape: () => n
|
|
1768
1768
|
});
|
|
1769
1769
|
}
|
|
1770
1770
|
omit(e) {
|
|
1771
|
-
const
|
|
1772
|
-
return x.objectKeys(this.shape).forEach((
|
|
1773
|
-
e[
|
|
1771
|
+
const n = {};
|
|
1772
|
+
return x.objectKeys(this.shape).forEach((r) => {
|
|
1773
|
+
e[r] || (n[r] = this.shape[r]);
|
|
1774
1774
|
}), new C({
|
|
1775
1775
|
...this._def,
|
|
1776
|
-
shape: () =>
|
|
1776
|
+
shape: () => n
|
|
1777
1777
|
});
|
|
1778
1778
|
}
|
|
1779
1779
|
/**
|
|
@@ -1783,86 +1783,86 @@ class C extends v {
|
|
|
1783
1783
|
return Oe(this);
|
|
1784
1784
|
}
|
|
1785
1785
|
partial(e) {
|
|
1786
|
-
const
|
|
1787
|
-
return x.objectKeys(this.shape).forEach((
|
|
1788
|
-
const s = this.shape[
|
|
1789
|
-
e && !e[
|
|
1786
|
+
const n = {};
|
|
1787
|
+
return x.objectKeys(this.shape).forEach((r) => {
|
|
1788
|
+
const s = this.shape[r];
|
|
1789
|
+
e && !e[r] ? n[r] = s : n[r] = s.optional();
|
|
1790
1790
|
}), new C({
|
|
1791
1791
|
...this._def,
|
|
1792
|
-
shape: () =>
|
|
1792
|
+
shape: () => n
|
|
1793
1793
|
});
|
|
1794
1794
|
}
|
|
1795
1795
|
required(e) {
|
|
1796
|
-
const
|
|
1797
|
-
return x.objectKeys(this.shape).forEach((
|
|
1798
|
-
if (e && !e[
|
|
1799
|
-
r
|
|
1796
|
+
const n = {};
|
|
1797
|
+
return x.objectKeys(this.shape).forEach((r) => {
|
|
1798
|
+
if (e && !e[r])
|
|
1799
|
+
n[r] = this.shape[r];
|
|
1800
1800
|
else {
|
|
1801
|
-
let a = this.shape[
|
|
1802
|
-
for (; a instanceof
|
|
1801
|
+
let a = this.shape[r];
|
|
1802
|
+
for (; a instanceof ne; )
|
|
1803
1803
|
a = a._def.innerType;
|
|
1804
|
-
r
|
|
1804
|
+
n[r] = a;
|
|
1805
1805
|
}
|
|
1806
1806
|
}), new C({
|
|
1807
1807
|
...this._def,
|
|
1808
|
-
shape: () =>
|
|
1808
|
+
shape: () => n
|
|
1809
1809
|
});
|
|
1810
1810
|
}
|
|
1811
1811
|
keyof() {
|
|
1812
|
-
return
|
|
1812
|
+
return an(x.objectKeys(this.shape));
|
|
1813
1813
|
}
|
|
1814
1814
|
}
|
|
1815
1815
|
C.create = (t, e) => new C({
|
|
1816
1816
|
shape: () => t,
|
|
1817
1817
|
unknownKeys: "strip",
|
|
1818
|
-
catchall:
|
|
1818
|
+
catchall: ue.create(),
|
|
1819
1819
|
typeName: y.ZodObject,
|
|
1820
1820
|
..._(e)
|
|
1821
1821
|
});
|
|
1822
1822
|
C.strictCreate = (t, e) => new C({
|
|
1823
1823
|
shape: () => t,
|
|
1824
1824
|
unknownKeys: "strict",
|
|
1825
|
-
catchall:
|
|
1825
|
+
catchall: ue.create(),
|
|
1826
1826
|
typeName: y.ZodObject,
|
|
1827
1827
|
..._(e)
|
|
1828
1828
|
});
|
|
1829
1829
|
C.lazycreate = (t, e) => new C({
|
|
1830
1830
|
shape: t,
|
|
1831
1831
|
unknownKeys: "strip",
|
|
1832
|
-
catchall:
|
|
1832
|
+
catchall: ue.create(),
|
|
1833
1833
|
typeName: y.ZodObject,
|
|
1834
1834
|
..._(e)
|
|
1835
1835
|
});
|
|
1836
|
-
class
|
|
1836
|
+
class Ke extends v {
|
|
1837
1837
|
_parse(e) {
|
|
1838
|
-
const { ctx:
|
|
1838
|
+
const { ctx: n } = this._processInputParams(e), r = this._def.options;
|
|
1839
1839
|
function s(a) {
|
|
1840
1840
|
for (const c of a)
|
|
1841
1841
|
if (c.result.status === "valid")
|
|
1842
1842
|
return c.result;
|
|
1843
1843
|
for (const c of a)
|
|
1844
1844
|
if (c.result.status === "dirty")
|
|
1845
|
-
return
|
|
1846
|
-
const o = a.map((c) => new
|
|
1847
|
-
return m(
|
|
1845
|
+
return n.common.issues.push(...c.ctx.common.issues), c.result;
|
|
1846
|
+
const o = a.map((c) => new z(c.ctx.common.issues));
|
|
1847
|
+
return m(n, {
|
|
1848
1848
|
code: l.invalid_union,
|
|
1849
1849
|
unionErrors: o
|
|
1850
1850
|
}), g;
|
|
1851
1851
|
}
|
|
1852
|
-
if (
|
|
1853
|
-
return Promise.all(
|
|
1852
|
+
if (n.common.async)
|
|
1853
|
+
return Promise.all(r.map(async (a) => {
|
|
1854
1854
|
const o = {
|
|
1855
|
-
...
|
|
1855
|
+
...n,
|
|
1856
1856
|
common: {
|
|
1857
|
-
...
|
|
1857
|
+
...n.common,
|
|
1858
1858
|
issues: []
|
|
1859
1859
|
},
|
|
1860
1860
|
parent: null
|
|
1861
1861
|
};
|
|
1862
1862
|
return {
|
|
1863
1863
|
result: await a._parseAsync({
|
|
1864
|
-
data:
|
|
1865
|
-
path:
|
|
1864
|
+
data: n.data,
|
|
1865
|
+
path: n.path,
|
|
1866
1866
|
parent: o
|
|
1867
1867
|
}),
|
|
1868
1868
|
ctx: o
|
|
@@ -1871,17 +1871,17 @@ class qe extends v {
|
|
|
1871
1871
|
{
|
|
1872
1872
|
let a;
|
|
1873
1873
|
const o = [];
|
|
1874
|
-
for (const u of
|
|
1874
|
+
for (const u of r) {
|
|
1875
1875
|
const d = {
|
|
1876
|
-
...
|
|
1876
|
+
...n,
|
|
1877
1877
|
common: {
|
|
1878
|
-
...
|
|
1878
|
+
...n.common,
|
|
1879
1879
|
issues: []
|
|
1880
1880
|
},
|
|
1881
1881
|
parent: null
|
|
1882
1882
|
}, f = u._parseSync({
|
|
1883
|
-
data:
|
|
1884
|
-
path:
|
|
1883
|
+
data: n.data,
|
|
1884
|
+
path: n.path,
|
|
1885
1885
|
parent: d
|
|
1886
1886
|
});
|
|
1887
1887
|
if (f.status === "valid")
|
|
@@ -1889,9 +1889,9 @@ class qe extends v {
|
|
|
1889
1889
|
f.status === "dirty" && !a && (a = { result: f, ctx: d }), d.common.issues.length && o.push(d.common.issues);
|
|
1890
1890
|
}
|
|
1891
1891
|
if (a)
|
|
1892
|
-
return
|
|
1893
|
-
const c = o.map((u) => new
|
|
1894
|
-
return m(
|
|
1892
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1893
|
+
const c = o.map((u) => new z(u));
|
|
1894
|
+
return m(n, {
|
|
1895
1895
|
code: l.invalid_union,
|
|
1896
1896
|
unionErrors: c
|
|
1897
1897
|
}), g;
|
|
@@ -1901,34 +1901,34 @@ class qe extends v {
|
|
|
1901
1901
|
return this._def.options;
|
|
1902
1902
|
}
|
|
1903
1903
|
}
|
|
1904
|
-
|
|
1904
|
+
Ke.create = (t, e) => new Ke({
|
|
1905
1905
|
options: t,
|
|
1906
1906
|
typeName: y.ZodUnion,
|
|
1907
1907
|
..._(e)
|
|
1908
1908
|
});
|
|
1909
|
-
const
|
|
1910
|
-
class
|
|
1909
|
+
const de = (t) => t instanceof Ge ? de(t.schema) : t instanceof J ? de(t.innerType()) : t instanceof Xe ? [t.value] : t instanceof ve ? t.options : t instanceof Qe ? x.objectValues(t.enum) : t instanceof et ? de(t._def.innerType) : t instanceof qe ? [void 0] : t instanceof We ? [null] : t instanceof ne ? [void 0, ...de(t.unwrap())] : t instanceof be ? [null, ...de(t.unwrap())] : t instanceof At || t instanceof nt ? de(t.unwrap()) : t instanceof tt ? de(t._def.innerType) : [];
|
|
1910
|
+
class _t extends v {
|
|
1911
1911
|
_parse(e) {
|
|
1912
|
-
const { ctx:
|
|
1913
|
-
if (
|
|
1914
|
-
return m(
|
|
1912
|
+
const { ctx: n } = this._processInputParams(e);
|
|
1913
|
+
if (n.parsedType !== h.object)
|
|
1914
|
+
return m(n, {
|
|
1915
1915
|
code: l.invalid_type,
|
|
1916
1916
|
expected: h.object,
|
|
1917
|
-
received:
|
|
1917
|
+
received: n.parsedType
|
|
1918
1918
|
}), g;
|
|
1919
|
-
const
|
|
1920
|
-
return a ?
|
|
1921
|
-
data:
|
|
1922
|
-
path:
|
|
1923
|
-
parent:
|
|
1919
|
+
const r = this.discriminator, s = n.data[r], a = this.optionsMap.get(s);
|
|
1920
|
+
return a ? n.common.async ? a._parseAsync({
|
|
1921
|
+
data: n.data,
|
|
1922
|
+
path: n.path,
|
|
1923
|
+
parent: n
|
|
1924
1924
|
}) : a._parseSync({
|
|
1925
|
-
data:
|
|
1926
|
-
path:
|
|
1927
|
-
parent:
|
|
1928
|
-
}) : (m(
|
|
1925
|
+
data: n.data,
|
|
1926
|
+
path: n.path,
|
|
1927
|
+
parent: n
|
|
1928
|
+
}) : (m(n, {
|
|
1929
1929
|
code: l.invalid_union_discriminator,
|
|
1930
1930
|
options: Array.from(this.optionsMap.keys()),
|
|
1931
|
-
path: [
|
|
1931
|
+
path: [r]
|
|
1932
1932
|
}), g);
|
|
1933
1933
|
}
|
|
1934
1934
|
get discriminator() {
|
|
@@ -1948,10 +1948,10 @@ class pt extends v {
|
|
|
1948
1948
|
* @param types an array of object schemas
|
|
1949
1949
|
* @param params
|
|
1950
1950
|
*/
|
|
1951
|
-
static create(e,
|
|
1951
|
+
static create(e, n, r) {
|
|
1952
1952
|
const s = /* @__PURE__ */ new Map();
|
|
1953
|
-
for (const a of
|
|
1954
|
-
const o =
|
|
1953
|
+
for (const a of n) {
|
|
1954
|
+
const o = de(a.shape[e]);
|
|
1955
1955
|
if (!o.length)
|
|
1956
1956
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1957
1957
|
for (const c of o) {
|
|
@@ -1960,130 +1960,130 @@ class pt extends v {
|
|
|
1960
1960
|
s.set(c, a);
|
|
1961
1961
|
}
|
|
1962
1962
|
}
|
|
1963
|
-
return new
|
|
1963
|
+
return new _t({
|
|
1964
1964
|
typeName: y.ZodDiscriminatedUnion,
|
|
1965
1965
|
discriminator: e,
|
|
1966
|
-
options:
|
|
1966
|
+
options: n,
|
|
1967
1967
|
optionsMap: s,
|
|
1968
|
-
..._(
|
|
1968
|
+
..._(r)
|
|
1969
1969
|
});
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
|
-
function
|
|
1973
|
-
const
|
|
1972
|
+
function Rt(t, e) {
|
|
1973
|
+
const n = pe(t), r = pe(e);
|
|
1974
1974
|
if (t === e)
|
|
1975
1975
|
return { valid: !0, data: t };
|
|
1976
|
-
if (
|
|
1976
|
+
if (n === h.object && r === h.object) {
|
|
1977
1977
|
const s = x.objectKeys(e), a = x.objectKeys(t).filter((c) => s.indexOf(c) !== -1), o = { ...t, ...e };
|
|
1978
1978
|
for (const c of a) {
|
|
1979
|
-
const u =
|
|
1979
|
+
const u = Rt(t[c], e[c]);
|
|
1980
1980
|
if (!u.valid)
|
|
1981
1981
|
return { valid: !1 };
|
|
1982
1982
|
o[c] = u.data;
|
|
1983
1983
|
}
|
|
1984
1984
|
return { valid: !0, data: o };
|
|
1985
|
-
} else if (
|
|
1985
|
+
} else if (n === h.array && r === h.array) {
|
|
1986
1986
|
if (t.length !== e.length)
|
|
1987
1987
|
return { valid: !1 };
|
|
1988
1988
|
const s = [];
|
|
1989
1989
|
for (let a = 0; a < t.length; a++) {
|
|
1990
|
-
const o = t[a], c = e[a], u =
|
|
1990
|
+
const o = t[a], c = e[a], u = Rt(o, c);
|
|
1991
1991
|
if (!u.valid)
|
|
1992
1992
|
return { valid: !1 };
|
|
1993
1993
|
s.push(u.data);
|
|
1994
1994
|
}
|
|
1995
1995
|
return { valid: !0, data: s };
|
|
1996
|
-
} else return
|
|
1996
|
+
} else return n === h.date && r === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
1997
1997
|
}
|
|
1998
|
-
class
|
|
1998
|
+
class Ye extends v {
|
|
1999
1999
|
_parse(e) {
|
|
2000
|
-
const { status:
|
|
2001
|
-
if (
|
|
2000
|
+
const { status: n, ctx: r } = this._processInputParams(e), s = (a, o) => {
|
|
2001
|
+
if (Ct(a) || Ct(o))
|
|
2002
2002
|
return g;
|
|
2003
|
-
const c =
|
|
2004
|
-
return c.valid ? ((
|
|
2003
|
+
const c = Rt(a.value, o.value);
|
|
2004
|
+
return c.valid ? ((St(a) || St(o)) && n.dirty(), { status: n.value, value: c.data }) : (m(r, {
|
|
2005
2005
|
code: l.invalid_intersection_types
|
|
2006
2006
|
}), g);
|
|
2007
2007
|
};
|
|
2008
|
-
return
|
|
2008
|
+
return r.common.async ? Promise.all([
|
|
2009
2009
|
this._def.left._parseAsync({
|
|
2010
|
-
data:
|
|
2011
|
-
path:
|
|
2012
|
-
parent:
|
|
2010
|
+
data: r.data,
|
|
2011
|
+
path: r.path,
|
|
2012
|
+
parent: r
|
|
2013
2013
|
}),
|
|
2014
2014
|
this._def.right._parseAsync({
|
|
2015
|
-
data:
|
|
2016
|
-
path:
|
|
2017
|
-
parent:
|
|
2015
|
+
data: r.data,
|
|
2016
|
+
path: r.path,
|
|
2017
|
+
parent: r
|
|
2018
2018
|
})
|
|
2019
2019
|
]).then(([a, o]) => s(a, o)) : s(this._def.left._parseSync({
|
|
2020
|
-
data:
|
|
2021
|
-
path:
|
|
2022
|
-
parent:
|
|
2020
|
+
data: r.data,
|
|
2021
|
+
path: r.path,
|
|
2022
|
+
parent: r
|
|
2023
2023
|
}), this._def.right._parseSync({
|
|
2024
|
-
data:
|
|
2025
|
-
path:
|
|
2026
|
-
parent:
|
|
2024
|
+
data: r.data,
|
|
2025
|
+
path: r.path,
|
|
2026
|
+
parent: r
|
|
2027
2027
|
}));
|
|
2028
2028
|
}
|
|
2029
2029
|
}
|
|
2030
|
-
|
|
2030
|
+
Ye.create = (t, e, n) => new Ye({
|
|
2031
2031
|
left: t,
|
|
2032
2032
|
right: e,
|
|
2033
2033
|
typeName: y.ZodIntersection,
|
|
2034
|
-
..._(
|
|
2034
|
+
..._(n)
|
|
2035
2035
|
});
|
|
2036
|
-
class
|
|
2036
|
+
class ae extends v {
|
|
2037
2037
|
_parse(e) {
|
|
2038
|
-
const { status:
|
|
2039
|
-
if (
|
|
2040
|
-
return m(
|
|
2038
|
+
const { status: n, ctx: r } = this._processInputParams(e);
|
|
2039
|
+
if (r.parsedType !== h.array)
|
|
2040
|
+
return m(r, {
|
|
2041
2041
|
code: l.invalid_type,
|
|
2042
2042
|
expected: h.array,
|
|
2043
|
-
received:
|
|
2043
|
+
received: r.parsedType
|
|
2044
2044
|
}), g;
|
|
2045
|
-
if (
|
|
2046
|
-
return m(
|
|
2045
|
+
if (r.data.length < this._def.items.length)
|
|
2046
|
+
return m(r, {
|
|
2047
2047
|
code: l.too_small,
|
|
2048
2048
|
minimum: this._def.items.length,
|
|
2049
2049
|
inclusive: !0,
|
|
2050
2050
|
exact: !1,
|
|
2051
2051
|
type: "array"
|
|
2052
2052
|
}), g;
|
|
2053
|
-
!this._def.rest &&
|
|
2053
|
+
!this._def.rest && r.data.length > this._def.items.length && (m(r, {
|
|
2054
2054
|
code: l.too_big,
|
|
2055
2055
|
maximum: this._def.items.length,
|
|
2056
2056
|
inclusive: !0,
|
|
2057
2057
|
exact: !1,
|
|
2058
2058
|
type: "array"
|
|
2059
|
-
}),
|
|
2060
|
-
const a = [...
|
|
2059
|
+
}), n.dirty());
|
|
2060
|
+
const a = [...r.data].map((o, c) => {
|
|
2061
2061
|
const u = this._def.items[c] || this._def.rest;
|
|
2062
|
-
return u ? u._parse(new
|
|
2062
|
+
return u ? u._parse(new se(r, o, r.path, c)) : null;
|
|
2063
2063
|
}).filter((o) => !!o);
|
|
2064
|
-
return
|
|
2064
|
+
return r.common.async ? Promise.all(a).then((o) => Z.mergeArray(n, o)) : Z.mergeArray(n, 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 ae({
|
|
2071
2071
|
...this._def,
|
|
2072
2072
|
rest: e
|
|
2073
2073
|
});
|
|
2074
2074
|
}
|
|
2075
2075
|
}
|
|
2076
|
-
|
|
2076
|
+
ae.create = (t, e) => {
|
|
2077
2077
|
if (!Array.isArray(t))
|
|
2078
2078
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2079
|
-
return new
|
|
2079
|
+
return new ae({
|
|
2080
2080
|
items: t,
|
|
2081
2081
|
typeName: y.ZodTuple,
|
|
2082
2082
|
rest: null,
|
|
2083
2083
|
..._(e)
|
|
2084
2084
|
});
|
|
2085
2085
|
};
|
|
2086
|
-
class
|
|
2086
|
+
class Je extends v {
|
|
2087
2087
|
get keySchema() {
|
|
2088
2088
|
return this._def.keyType;
|
|
2089
2089
|
}
|
|
@@ -2091,40 +2091,40 @@ class Ke extends v {
|
|
|
2091
2091
|
return this._def.valueType;
|
|
2092
2092
|
}
|
|
2093
2093
|
_parse(e) {
|
|
2094
|
-
const { status:
|
|
2095
|
-
if (
|
|
2096
|
-
return m(
|
|
2094
|
+
const { status: n, ctx: r } = this._processInputParams(e);
|
|
2095
|
+
if (r.parsedType !== h.object)
|
|
2096
|
+
return m(r, {
|
|
2097
2097
|
code: l.invalid_type,
|
|
2098
2098
|
expected: h.object,
|
|
2099
|
-
received:
|
|
2099
|
+
received: r.parsedType
|
|
2100
2100
|
}), g;
|
|
2101
2101
|
const s = [], a = this._def.keyType, o = this._def.valueType;
|
|
2102
|
-
for (const c in
|
|
2102
|
+
for (const c in r.data)
|
|
2103
2103
|
s.push({
|
|
2104
|
-
key: a._parse(new
|
|
2105
|
-
value: o._parse(new
|
|
2106
|
-
alwaysSet: c in
|
|
2104
|
+
key: a._parse(new se(r, c, r.path, c)),
|
|
2105
|
+
value: o._parse(new se(r, r.data[c], r.path, c)),
|
|
2106
|
+
alwaysSet: c in r.data
|
|
2107
2107
|
});
|
|
2108
|
-
return
|
|
2108
|
+
return r.common.async ? Z.mergeObjectAsync(n, s) : Z.mergeObjectSync(n, s);
|
|
2109
2109
|
}
|
|
2110
2110
|
get element() {
|
|
2111
2111
|
return this._def.valueType;
|
|
2112
2112
|
}
|
|
2113
|
-
static create(e,
|
|
2114
|
-
return
|
|
2113
|
+
static create(e, n, r) {
|
|
2114
|
+
return n instanceof v ? new Je({
|
|
2115
2115
|
keyType: e,
|
|
2116
|
-
valueType:
|
|
2116
|
+
valueType: n,
|
|
2117
2117
|
typeName: y.ZodRecord,
|
|
2118
|
-
..._(
|
|
2119
|
-
}) : new
|
|
2120
|
-
keyType:
|
|
2118
|
+
..._(r)
|
|
2119
|
+
}) : new Je({
|
|
2120
|
+
keyType: K.create(),
|
|
2121
2121
|
valueType: e,
|
|
2122
2122
|
typeName: y.ZodRecord,
|
|
2123
|
-
..._(
|
|
2123
|
+
..._(n)
|
|
2124
2124
|
});
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
|
-
class
|
|
2127
|
+
class yt extends v {
|
|
2128
2128
|
get keySchema() {
|
|
2129
2129
|
return this._def.keyType;
|
|
2130
2130
|
}
|
|
@@ -2132,27 +2132,27 @@ class mt extends v {
|
|
|
2132
2132
|
return this._def.valueType;
|
|
2133
2133
|
}
|
|
2134
2134
|
_parse(e) {
|
|
2135
|
-
const { status:
|
|
2136
|
-
if (
|
|
2137
|
-
return m(
|
|
2135
|
+
const { status: n, ctx: r } = this._processInputParams(e);
|
|
2136
|
+
if (r.parsedType !== h.map)
|
|
2137
|
+
return m(r, {
|
|
2138
2138
|
code: l.invalid_type,
|
|
2139
2139
|
expected: h.map,
|
|
2140
|
-
received:
|
|
2140
|
+
received: r.parsedType
|
|
2141
2141
|
}), g;
|
|
2142
|
-
const s = this._def.keyType, a = this._def.valueType, o = [...
|
|
2143
|
-
key: s._parse(new
|
|
2144
|
-
value: a._parse(new
|
|
2142
|
+
const s = this._def.keyType, a = this._def.valueType, o = [...r.data.entries()].map(([c, u], d) => ({
|
|
2143
|
+
key: s._parse(new se(r, c, r.path, [d, "key"])),
|
|
2144
|
+
value: a._parse(new se(r, u, r.path, [d, "value"]))
|
|
2145
2145
|
}));
|
|
2146
|
-
if (
|
|
2146
|
+
if (r.common.async) {
|
|
2147
2147
|
const c = /* @__PURE__ */ new Map();
|
|
2148
2148
|
return Promise.resolve().then(async () => {
|
|
2149
2149
|
for (const u of o) {
|
|
2150
2150
|
const d = await u.key, f = await u.value;
|
|
2151
2151
|
if (d.status === "aborted" || f.status === "aborted")
|
|
2152
2152
|
return g;
|
|
2153
|
-
(d.status === "dirty" || f.status === "dirty") &&
|
|
2153
|
+
(d.status === "dirty" || f.status === "dirty") && n.dirty(), c.set(d.value, f.value);
|
|
2154
2154
|
}
|
|
2155
|
-
return { status:
|
|
2155
|
+
return { status: n.value, value: c };
|
|
2156
2156
|
});
|
|
2157
2157
|
} else {
|
|
2158
2158
|
const c = /* @__PURE__ */ new Map();
|
|
@@ -2160,103 +2160,103 @@ class mt extends v {
|
|
|
2160
2160
|
const d = u.key, f = u.value;
|
|
2161
2161
|
if (d.status === "aborted" || f.status === "aborted")
|
|
2162
2162
|
return g;
|
|
2163
|
-
(d.status === "dirty" || f.status === "dirty") &&
|
|
2163
|
+
(d.status === "dirty" || f.status === "dirty") && n.dirty(), c.set(d.value, f.value);
|
|
2164
2164
|
}
|
|
2165
|
-
return { status:
|
|
2165
|
+
return { status: n.value, value: c };
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
|
-
|
|
2169
|
+
yt.create = (t, e, n) => new yt({
|
|
2170
2170
|
valueType: e,
|
|
2171
2171
|
keyType: t,
|
|
2172
2172
|
typeName: y.ZodMap,
|
|
2173
|
-
..._(
|
|
2173
|
+
..._(n)
|
|
2174
2174
|
});
|
|
2175
|
-
class
|
|
2175
|
+
class Re extends v {
|
|
2176
2176
|
_parse(e) {
|
|
2177
|
-
const { status:
|
|
2178
|
-
if (
|
|
2179
|
-
return m(
|
|
2177
|
+
const { status: n, ctx: r } = this._processInputParams(e);
|
|
2178
|
+
if (r.parsedType !== h.set)
|
|
2179
|
+
return m(r, {
|
|
2180
2180
|
code: l.invalid_type,
|
|
2181
2181
|
expected: h.set,
|
|
2182
|
-
received:
|
|
2182
|
+
received: r.parsedType
|
|
2183
2183
|
}), g;
|
|
2184
2184
|
const s = this._def;
|
|
2185
|
-
s.minSize !== null &&
|
|
2185
|
+
s.minSize !== null && r.data.size < s.minSize.value && (m(r, {
|
|
2186
2186
|
code: l.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
|
-
}),
|
|
2192
|
+
}), n.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (m(r, {
|
|
2193
2193
|
code: l.too_big,
|
|
2194
2194
|
maximum: s.maxSize.value,
|
|
2195
2195
|
type: "set",
|
|
2196
2196
|
inclusive: !0,
|
|
2197
2197
|
exact: !1,
|
|
2198
2198
|
message: s.maxSize.message
|
|
2199
|
-
}),
|
|
2199
|
+
}), n.dirty());
|
|
2200
2200
|
const a = this._def.valueType;
|
|
2201
2201
|
function o(u) {
|
|
2202
2202
|
const d = /* @__PURE__ */ new Set();
|
|
2203
2203
|
for (const f of u) {
|
|
2204
2204
|
if (f.status === "aborted")
|
|
2205
2205
|
return g;
|
|
2206
|
-
f.status === "dirty" &&
|
|
2206
|
+
f.status === "dirty" && n.dirty(), d.add(f.value);
|
|
2207
2207
|
}
|
|
2208
|
-
return { status:
|
|
2208
|
+
return { status: n.value, value: d };
|
|
2209
2209
|
}
|
|
2210
|
-
const c = [...
|
|
2211
|
-
return
|
|
2210
|
+
const c = [...r.data.values()].map((u, d) => a._parse(new se(r, u, r.path, d)));
|
|
2211
|
+
return r.common.async ? Promise.all(c).then((u) => o(u)) : o(c);
|
|
2212
2212
|
}
|
|
2213
|
-
min(e,
|
|
2214
|
-
return new
|
|
2213
|
+
min(e, n) {
|
|
2214
|
+
return new Re({
|
|
2215
2215
|
...this._def,
|
|
2216
|
-
minSize: { value: e, message: p.toString(
|
|
2216
|
+
minSize: { value: e, message: p.toString(n) }
|
|
2217
2217
|
});
|
|
2218
2218
|
}
|
|
2219
|
-
max(e,
|
|
2220
|
-
return new
|
|
2219
|
+
max(e, n) {
|
|
2220
|
+
return new Re({
|
|
2221
2221
|
...this._def,
|
|
2222
|
-
maxSize: { value: e, message: p.toString(
|
|
2222
|
+
maxSize: { value: e, message: p.toString(n) }
|
|
2223
2223
|
});
|
|
2224
2224
|
}
|
|
2225
|
-
size(e,
|
|
2226
|
-
return this.min(e,
|
|
2225
|
+
size(e, n) {
|
|
2226
|
+
return this.min(e, n).max(e, n);
|
|
2227
2227
|
}
|
|
2228
2228
|
nonempty(e) {
|
|
2229
2229
|
return this.min(1, e);
|
|
2230
2230
|
}
|
|
2231
2231
|
}
|
|
2232
|
-
|
|
2232
|
+
Re.create = (t, e) => new Re({
|
|
2233
2233
|
valueType: t,
|
|
2234
2234
|
minSize: null,
|
|
2235
2235
|
maxSize: null,
|
|
2236
2236
|
typeName: y.ZodSet,
|
|
2237
2237
|
..._(e)
|
|
2238
2238
|
});
|
|
2239
|
-
class
|
|
2239
|
+
class Pe extends v {
|
|
2240
2240
|
constructor() {
|
|
2241
2241
|
super(...arguments), this.validate = this.implement;
|
|
2242
2242
|
}
|
|
2243
2243
|
_parse(e) {
|
|
2244
|
-
const { ctx:
|
|
2245
|
-
if (
|
|
2246
|
-
return m(
|
|
2244
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2245
|
+
if (n.parsedType !== h.function)
|
|
2246
|
+
return m(n, {
|
|
2247
2247
|
code: l.invalid_type,
|
|
2248
2248
|
expected: h.function,
|
|
2249
|
-
received:
|
|
2249
|
+
received: n.parsedType
|
|
2250
2250
|
}), g;
|
|
2251
|
-
function
|
|
2252
|
-
return
|
|
2251
|
+
function r(c, u) {
|
|
2252
|
+
return ft({
|
|
2253
2253
|
data: c,
|
|
2254
|
-
path:
|
|
2254
|
+
path: n.path,
|
|
2255
2255
|
errorMaps: [
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2256
|
+
n.common.contextualErrorMap,
|
|
2257
|
+
n.schemaErrorMap,
|
|
2258
|
+
lt(),
|
|
2259
|
+
Ae
|
|
2260
2260
|
].filter((d) => !!d),
|
|
2261
2261
|
issueData: {
|
|
2262
2262
|
code: l.invalid_arguments,
|
|
@@ -2265,14 +2265,14 @@ class Ie extends v {
|
|
|
2265
2265
|
});
|
|
2266
2266
|
}
|
|
2267
2267
|
function s(c, u) {
|
|
2268
|
-
return
|
|
2268
|
+
return ft({
|
|
2269
2269
|
data: c,
|
|
2270
|
-
path:
|
|
2270
|
+
path: n.path,
|
|
2271
2271
|
errorMaps: [
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2272
|
+
n.common.contextualErrorMap,
|
|
2273
|
+
n.schemaErrorMap,
|
|
2274
|
+
lt(),
|
|
2275
|
+
Ae
|
|
2276
2276
|
].filter((d) => !!d),
|
|
2277
2277
|
issueData: {
|
|
2278
2278
|
code: l.invalid_return_type,
|
|
@@ -2280,12 +2280,12 @@ class Ie extends v {
|
|
|
2280
2280
|
}
|
|
2281
2281
|
});
|
|
2282
2282
|
}
|
|
2283
|
-
const a = { errorMap:
|
|
2284
|
-
if (this._def.returns instanceof
|
|
2283
|
+
const a = { errorMap: n.common.contextualErrorMap }, o = n.data;
|
|
2284
|
+
if (this._def.returns instanceof Me) {
|
|
2285
2285
|
const c = this;
|
|
2286
|
-
return
|
|
2287
|
-
const d = new
|
|
2288
|
-
throw d.addIssue(
|
|
2286
|
+
return $(async function(...u) {
|
|
2287
|
+
const d = new z([]), f = await c._def.args.parseAsync(u, a).catch((k) => {
|
|
2288
|
+
throw d.addIssue(r(u, k)), d;
|
|
2289
2289
|
}), b = await Reflect.apply(o, this, f);
|
|
2290
2290
|
return await c._def.returns._def.type.parseAsync(b, a).catch((k) => {
|
|
2291
2291
|
throw d.addIssue(s(b, k)), d;
|
|
@@ -2293,13 +2293,13 @@ class Ie extends v {
|
|
|
2293
2293
|
});
|
|
2294
2294
|
} else {
|
|
2295
2295
|
const c = this;
|
|
2296
|
-
return
|
|
2296
|
+
return $(function(...u) {
|
|
2297
2297
|
const d = c._def.args.safeParse(u, a);
|
|
2298
2298
|
if (!d.success)
|
|
2299
|
-
throw new
|
|
2299
|
+
throw new z([r(u, d.error)]);
|
|
2300
2300
|
const f = Reflect.apply(o, this, d.data), b = c._def.returns.safeParse(f, a);
|
|
2301
2301
|
if (!b.success)
|
|
2302
|
-
throw new
|
|
2302
|
+
throw new z([s(f, b.error)]);
|
|
2303
2303
|
return b.data;
|
|
2304
2304
|
});
|
|
2305
2305
|
}
|
|
@@ -2311,13 +2311,13 @@ class Ie extends v {
|
|
|
2311
2311
|
return this._def.returns;
|
|
2312
2312
|
}
|
|
2313
2313
|
args(...e) {
|
|
2314
|
-
return new
|
|
2314
|
+
return new Pe({
|
|
2315
2315
|
...this._def,
|
|
2316
|
-
args:
|
|
2316
|
+
args: ae.create(e).rest(Ce.create())
|
|
2317
2317
|
});
|
|
2318
2318
|
}
|
|
2319
2319
|
returns(e) {
|
|
2320
|
-
return new
|
|
2320
|
+
return new Pe({
|
|
2321
2321
|
...this._def,
|
|
2322
2322
|
returns: e
|
|
2323
2323
|
});
|
|
@@ -2328,35 +2328,35 @@ class Ie extends v {
|
|
|
2328
2328
|
strictImplement(e) {
|
|
2329
2329
|
return this.parse(e);
|
|
2330
2330
|
}
|
|
2331
|
-
static create(e,
|
|
2332
|
-
return new
|
|
2333
|
-
args: e ||
|
|
2334
|
-
returns:
|
|
2331
|
+
static create(e, n, r) {
|
|
2332
|
+
return new Pe({
|
|
2333
|
+
args: e || ae.create([]).rest(Ce.create()),
|
|
2334
|
+
returns: n || Ce.create(),
|
|
2335
2335
|
typeName: y.ZodFunction,
|
|
2336
|
-
..._(
|
|
2336
|
+
..._(r)
|
|
2337
2337
|
});
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
class
|
|
2340
|
+
class Ge extends v {
|
|
2341
2341
|
get schema() {
|
|
2342
2342
|
return this._def.getter();
|
|
2343
2343
|
}
|
|
2344
2344
|
_parse(e) {
|
|
2345
|
-
const { ctx:
|
|
2346
|
-
return this._def.getter()._parse({ data:
|
|
2345
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2346
|
+
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
|
-
|
|
2349
|
+
Ge.create = (t, e) => new Ge({
|
|
2350
2350
|
getter: t,
|
|
2351
2351
|
typeName: y.ZodLazy,
|
|
2352
2352
|
..._(e)
|
|
2353
2353
|
});
|
|
2354
|
-
class
|
|
2354
|
+
class Xe extends v {
|
|
2355
2355
|
_parse(e) {
|
|
2356
2356
|
if (e.data !== this._def.value) {
|
|
2357
|
-
const
|
|
2358
|
-
return m(
|
|
2359
|
-
received:
|
|
2357
|
+
const n = this._getOrReturnCtx(e);
|
|
2358
|
+
return m(n, {
|
|
2359
|
+
received: n.data,
|
|
2360
2360
|
code: l.invalid_literal,
|
|
2361
2361
|
expected: this._def.value
|
|
2362
2362
|
}), g;
|
|
@@ -2367,136 +2367,136 @@ class Je extends v {
|
|
|
2367
2367
|
return this._def.value;
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
|
-
|
|
2370
|
+
Xe.create = (t, e) => new Xe({
|
|
2371
2371
|
value: t,
|
|
2372
2372
|
typeName: y.ZodLiteral,
|
|
2373
2373
|
..._(e)
|
|
2374
2374
|
});
|
|
2375
|
-
function
|
|
2376
|
-
return new
|
|
2375
|
+
function an(t, e) {
|
|
2376
|
+
return new ve({
|
|
2377
2377
|
values: t,
|
|
2378
2378
|
typeName: y.ZodEnum,
|
|
2379
2379
|
..._(e)
|
|
2380
2380
|
});
|
|
2381
2381
|
}
|
|
2382
|
-
class
|
|
2382
|
+
class ve extends v {
|
|
2383
2383
|
constructor() {
|
|
2384
|
-
super(...arguments),
|
|
2384
|
+
super(...arguments), Ue.set(this, void 0);
|
|
2385
2385
|
}
|
|
2386
2386
|
_parse(e) {
|
|
2387
2387
|
if (typeof e.data != "string") {
|
|
2388
|
-
const
|
|
2389
|
-
return m(
|
|
2390
|
-
expected: x.joinValues(
|
|
2391
|
-
received:
|
|
2388
|
+
const n = this._getOrReturnCtx(e), r = this._def.values;
|
|
2389
|
+
return m(n, {
|
|
2390
|
+
expected: x.joinValues(r),
|
|
2391
|
+
received: n.parsedType,
|
|
2392
2392
|
code: l.invalid_type
|
|
2393
2393
|
}), g;
|
|
2394
2394
|
}
|
|
2395
|
-
if (
|
|
2396
|
-
const
|
|
2397
|
-
return m(
|
|
2398
|
-
received:
|
|
2395
|
+
if (mt(this, Ue) || tn(this, Ue, new Set(this._def.values)), !mt(this, Ue).has(e.data)) {
|
|
2396
|
+
const n = this._getOrReturnCtx(e), r = this._def.values;
|
|
2397
|
+
return m(n, {
|
|
2398
|
+
received: n.data,
|
|
2399
2399
|
code: l.invalid_enum_value,
|
|
2400
|
-
options:
|
|
2400
|
+
options: r
|
|
2401
2401
|
}), g;
|
|
2402
2402
|
}
|
|
2403
|
-
return
|
|
2403
|
+
return $(e.data);
|
|
2404
2404
|
}
|
|
2405
2405
|
get options() {
|
|
2406
2406
|
return this._def.values;
|
|
2407
2407
|
}
|
|
2408
2408
|
get enum() {
|
|
2409
2409
|
const e = {};
|
|
2410
|
-
for (const
|
|
2411
|
-
e[
|
|
2410
|
+
for (const n of this._def.values)
|
|
2411
|
+
e[n] = n;
|
|
2412
2412
|
return e;
|
|
2413
2413
|
}
|
|
2414
2414
|
get Values() {
|
|
2415
2415
|
const e = {};
|
|
2416
|
-
for (const
|
|
2417
|
-
e[
|
|
2416
|
+
for (const n of this._def.values)
|
|
2417
|
+
e[n] = n;
|
|
2418
2418
|
return e;
|
|
2419
2419
|
}
|
|
2420
2420
|
get Enum() {
|
|
2421
2421
|
const e = {};
|
|
2422
|
-
for (const
|
|
2423
|
-
e[
|
|
2422
|
+
for (const n of this._def.values)
|
|
2423
|
+
e[n] = n;
|
|
2424
2424
|
return e;
|
|
2425
2425
|
}
|
|
2426
|
-
extract(e,
|
|
2427
|
-
return
|
|
2426
|
+
extract(e, n = this._def) {
|
|
2427
|
+
return ve.create(e, {
|
|
2428
2428
|
...this._def,
|
|
2429
|
-
...
|
|
2429
|
+
...n
|
|
2430
2430
|
});
|
|
2431
2431
|
}
|
|
2432
|
-
exclude(e,
|
|
2433
|
-
return
|
|
2432
|
+
exclude(e, n = this._def) {
|
|
2433
|
+
return ve.create(this.options.filter((r) => !e.includes(r)), {
|
|
2434
2434
|
...this._def,
|
|
2435
|
-
...
|
|
2435
|
+
...n
|
|
2436
2436
|
});
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
class
|
|
2439
|
+
Ue = /* @__PURE__ */ new WeakMap();
|
|
2440
|
+
ve.create = an;
|
|
2441
|
+
class Qe extends v {
|
|
2442
2442
|
constructor() {
|
|
2443
|
-
super(...arguments),
|
|
2443
|
+
super(...arguments), Ve.set(this, void 0);
|
|
2444
2444
|
}
|
|
2445
2445
|
_parse(e) {
|
|
2446
|
-
const
|
|
2447
|
-
if (
|
|
2448
|
-
const s = x.objectValues(
|
|
2449
|
-
return m(
|
|
2446
|
+
const n = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2447
|
+
if (r.parsedType !== h.string && r.parsedType !== h.number) {
|
|
2448
|
+
const s = x.objectValues(n);
|
|
2449
|
+
return m(r, {
|
|
2450
2450
|
expected: x.joinValues(s),
|
|
2451
|
-
received:
|
|
2451
|
+
received: r.parsedType,
|
|
2452
2452
|
code: l.invalid_type
|
|
2453
2453
|
}), g;
|
|
2454
2454
|
}
|
|
2455
|
-
if (
|
|
2456
|
-
const s = x.objectValues(
|
|
2457
|
-
return m(
|
|
2458
|
-
received:
|
|
2455
|
+
if (mt(this, Ve) || tn(this, Ve, new Set(x.getValidEnumValues(this._def.values))), !mt(this, Ve).has(e.data)) {
|
|
2456
|
+
const s = x.objectValues(n);
|
|
2457
|
+
return m(r, {
|
|
2458
|
+
received: r.data,
|
|
2459
2459
|
code: l.invalid_enum_value,
|
|
2460
2460
|
options: s
|
|
2461
2461
|
}), g;
|
|
2462
2462
|
}
|
|
2463
|
-
return
|
|
2463
|
+
return $(e.data);
|
|
2464
2464
|
}
|
|
2465
2465
|
get enum() {
|
|
2466
2466
|
return this._def.values;
|
|
2467
2467
|
}
|
|
2468
2468
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2469
|
+
Ve = /* @__PURE__ */ new WeakMap();
|
|
2470
|
+
Qe.create = (t, e) => new Qe({
|
|
2471
2471
|
values: t,
|
|
2472
2472
|
typeName: y.ZodNativeEnum,
|
|
2473
2473
|
..._(e)
|
|
2474
2474
|
});
|
|
2475
|
-
class
|
|
2475
|
+
class Me extends v {
|
|
2476
2476
|
unwrap() {
|
|
2477
2477
|
return this._def.type;
|
|
2478
2478
|
}
|
|
2479
2479
|
_parse(e) {
|
|
2480
|
-
const { ctx:
|
|
2481
|
-
if (
|
|
2482
|
-
return m(
|
|
2480
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2481
|
+
if (n.parsedType !== h.promise && n.common.async === !1)
|
|
2482
|
+
return m(n, {
|
|
2483
2483
|
code: l.invalid_type,
|
|
2484
2484
|
expected: h.promise,
|
|
2485
|
-
received:
|
|
2485
|
+
received: n.parsedType
|
|
2486
2486
|
}), g;
|
|
2487
|
-
const
|
|
2488
|
-
return
|
|
2489
|
-
path:
|
|
2490
|
-
errorMap:
|
|
2487
|
+
const r = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2488
|
+
return $(r.then((s) => this._def.type.parseAsync(s, {
|
|
2489
|
+
path: n.path,
|
|
2490
|
+
errorMap: n.common.contextualErrorMap
|
|
2491
2491
|
})));
|
|
2492
2492
|
}
|
|
2493
2493
|
}
|
|
2494
|
-
|
|
2494
|
+
Me.create = (t, e) => new Me({
|
|
2495
2495
|
type: t,
|
|
2496
2496
|
typeName: y.ZodPromise,
|
|
2497
2497
|
..._(e)
|
|
2498
2498
|
});
|
|
2499
|
-
class
|
|
2499
|
+
class J extends v {
|
|
2500
2500
|
innerType() {
|
|
2501
2501
|
return this._def.schema;
|
|
2502
2502
|
}
|
|
@@ -2504,163 +2504,163 @@ class Y extends v {
|
|
|
2504
2504
|
return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2505
2505
|
}
|
|
2506
2506
|
_parse(e) {
|
|
2507
|
-
const { status:
|
|
2507
|
+
const { status: n, ctx: r } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
2508
2508
|
addIssue: (o) => {
|
|
2509
|
-
m(
|
|
2509
|
+
m(r, o), o.fatal ? n.abort() : n.dirty();
|
|
2510
2510
|
},
|
|
2511
2511
|
get path() {
|
|
2512
|
-
return
|
|
2512
|
+
return r.path;
|
|
2513
2513
|
}
|
|
2514
2514
|
};
|
|
2515
2515
|
if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
|
|
2516
|
-
const o = s.transform(
|
|
2517
|
-
if (
|
|
2516
|
+
const o = s.transform(r.data, a);
|
|
2517
|
+
if (r.common.async)
|
|
2518
2518
|
return Promise.resolve(o).then(async (c) => {
|
|
2519
|
-
if (
|
|
2519
|
+
if (n.value === "aborted")
|
|
2520
2520
|
return g;
|
|
2521
2521
|
const u = await this._def.schema._parseAsync({
|
|
2522
2522
|
data: c,
|
|
2523
|
-
path:
|
|
2524
|
-
parent:
|
|
2523
|
+
path: r.path,
|
|
2524
|
+
parent: r
|
|
2525
2525
|
});
|
|
2526
|
-
return u.status === "aborted" ? g : u.status === "dirty" ||
|
|
2526
|
+
return u.status === "aborted" ? g : u.status === "dirty" || n.value === "dirty" ? Ie(u.value) : u;
|
|
2527
2527
|
});
|
|
2528
2528
|
{
|
|
2529
|
-
if (
|
|
2529
|
+
if (n.value === "aborted")
|
|
2530
2530
|
return g;
|
|
2531
2531
|
const c = this._def.schema._parseSync({
|
|
2532
2532
|
data: o,
|
|
2533
|
-
path:
|
|
2534
|
-
parent:
|
|
2533
|
+
path: r.path,
|
|
2534
|
+
parent: r
|
|
2535
2535
|
});
|
|
2536
|
-
return c.status === "aborted" ? g : c.status === "dirty" ||
|
|
2536
|
+
return c.status === "aborted" ? g : c.status === "dirty" || n.value === "dirty" ? Ie(c.value) : c;
|
|
2537
2537
|
}
|
|
2538
2538
|
}
|
|
2539
2539
|
if (s.type === "refinement") {
|
|
2540
2540
|
const o = (c) => {
|
|
2541
2541
|
const u = s.refinement(c, a);
|
|
2542
|
-
if (
|
|
2542
|
+
if (r.common.async)
|
|
2543
2543
|
return Promise.resolve(u);
|
|
2544
2544
|
if (u instanceof Promise)
|
|
2545
2545
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2546
2546
|
return c;
|
|
2547
2547
|
};
|
|
2548
|
-
if (
|
|
2548
|
+
if (r.common.async === !1) {
|
|
2549
2549
|
const c = this._def.schema._parseSync({
|
|
2550
|
-
data:
|
|
2551
|
-
path:
|
|
2552
|
-
parent:
|
|
2550
|
+
data: r.data,
|
|
2551
|
+
path: r.path,
|
|
2552
|
+
parent: r
|
|
2553
2553
|
});
|
|
2554
|
-
return c.status === "aborted" ? g : (c.status === "dirty" &&
|
|
2554
|
+
return c.status === "aborted" ? g : (c.status === "dirty" && n.dirty(), o(c.value), { status: n.value, value: c.value });
|
|
2555
2555
|
} else
|
|
2556
|
-
return this._def.schema._parseAsync({ data:
|
|
2556
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((c) => c.status === "aborted" ? g : (c.status === "dirty" && n.dirty(), o(c.value).then(() => ({ status: n.value, value: c.value }))));
|
|
2557
2557
|
}
|
|
2558
2558
|
if (s.type === "transform")
|
|
2559
|
-
if (
|
|
2559
|
+
if (r.common.async === !1) {
|
|
2560
2560
|
const o = this._def.schema._parseSync({
|
|
2561
|
-
data:
|
|
2562
|
-
path:
|
|
2563
|
-
parent:
|
|
2561
|
+
data: r.data,
|
|
2562
|
+
path: r.path,
|
|
2563
|
+
parent: r
|
|
2564
2564
|
});
|
|
2565
|
-
if (!
|
|
2565
|
+
if (!ze(o))
|
|
2566
2566
|
return o;
|
|
2567
2567
|
const c = s.transform(o.value, a);
|
|
2568
2568
|
if (c instanceof Promise)
|
|
2569
2569
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2570
|
-
return { status:
|
|
2570
|
+
return { status: n.value, value: c };
|
|
2571
2571
|
} else
|
|
2572
|
-
return this._def.schema._parseAsync({ data:
|
|
2572
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => ze(o) ? Promise.resolve(s.transform(o.value, a)).then((c) => ({ status: n.value, value: c })) : o);
|
|
2573
2573
|
x.assertNever(s);
|
|
2574
2574
|
}
|
|
2575
2575
|
}
|
|
2576
|
-
|
|
2576
|
+
J.create = (t, e, n) => new J({
|
|
2577
2577
|
schema: t,
|
|
2578
2578
|
typeName: y.ZodEffects,
|
|
2579
2579
|
effect: e,
|
|
2580
|
-
..._(
|
|
2580
|
+
..._(n)
|
|
2581
2581
|
});
|
|
2582
|
-
|
|
2582
|
+
J.createWithPreprocess = (t, e, n) => new J({
|
|
2583
2583
|
schema: e,
|
|
2584
2584
|
effect: { type: "preprocess", transform: t },
|
|
2585
2585
|
typeName: y.ZodEffects,
|
|
2586
|
-
..._(
|
|
2586
|
+
..._(n)
|
|
2587
2587
|
});
|
|
2588
|
-
class
|
|
2588
|
+
class ne extends v {
|
|
2589
2589
|
_parse(e) {
|
|
2590
|
-
return this._getType(e) === h.undefined ?
|
|
2590
|
+
return this._getType(e) === h.undefined ? $(void 0) : this._def.innerType._parse(e);
|
|
2591
2591
|
}
|
|
2592
2592
|
unwrap() {
|
|
2593
2593
|
return this._def.innerType;
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
2596
|
-
|
|
2596
|
+
ne.create = (t, e) => new ne({
|
|
2597
2597
|
innerType: t,
|
|
2598
2598
|
typeName: y.ZodOptional,
|
|
2599
2599
|
..._(e)
|
|
2600
2600
|
});
|
|
2601
|
-
class
|
|
2601
|
+
class be extends v {
|
|
2602
2602
|
_parse(e) {
|
|
2603
|
-
return this._getType(e) === h.null ?
|
|
2603
|
+
return this._getType(e) === h.null ? $(null) : this._def.innerType._parse(e);
|
|
2604
2604
|
}
|
|
2605
2605
|
unwrap() {
|
|
2606
2606
|
return this._def.innerType;
|
|
2607
2607
|
}
|
|
2608
2608
|
}
|
|
2609
|
-
|
|
2609
|
+
be.create = (t, e) => new be({
|
|
2610
2610
|
innerType: t,
|
|
2611
2611
|
typeName: y.ZodNullable,
|
|
2612
2612
|
..._(e)
|
|
2613
2613
|
});
|
|
2614
|
-
class
|
|
2614
|
+
class et extends v {
|
|
2615
2615
|
_parse(e) {
|
|
2616
|
-
const { ctx:
|
|
2617
|
-
let
|
|
2618
|
-
return
|
|
2619
|
-
data:
|
|
2620
|
-
path:
|
|
2621
|
-
parent:
|
|
2616
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2617
|
+
let r = n.data;
|
|
2618
|
+
return n.parsedType === h.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2619
|
+
data: r,
|
|
2620
|
+
path: n.path,
|
|
2621
|
+
parent: n
|
|
2622
2622
|
});
|
|
2623
2623
|
}
|
|
2624
2624
|
removeDefault() {
|
|
2625
2625
|
return this._def.innerType;
|
|
2626
2626
|
}
|
|
2627
2627
|
}
|
|
2628
|
-
|
|
2628
|
+
et.create = (t, e) => new et({
|
|
2629
2629
|
innerType: t,
|
|
2630
2630
|
typeName: y.ZodDefault,
|
|
2631
2631
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2632
2632
|
..._(e)
|
|
2633
2633
|
});
|
|
2634
|
-
class
|
|
2634
|
+
class tt extends v {
|
|
2635
2635
|
_parse(e) {
|
|
2636
|
-
const { ctx:
|
|
2637
|
-
...
|
|
2636
|
+
const { ctx: n } = this._processInputParams(e), r = {
|
|
2637
|
+
...n,
|
|
2638
2638
|
common: {
|
|
2639
|
-
...
|
|
2639
|
+
...n.common,
|
|
2640
2640
|
issues: []
|
|
2641
2641
|
}
|
|
2642
2642
|
}, s = this._def.innerType._parse({
|
|
2643
|
-
data:
|
|
2644
|
-
path:
|
|
2643
|
+
data: r.data,
|
|
2644
|
+
path: r.path,
|
|
2645
2645
|
parent: {
|
|
2646
|
-
...
|
|
2646
|
+
...r
|
|
2647
2647
|
}
|
|
2648
2648
|
});
|
|
2649
|
-
return
|
|
2649
|
+
return Be(s) ? s.then((a) => ({
|
|
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 z(r.common.issues);
|
|
2654
2654
|
},
|
|
2655
|
-
input:
|
|
2655
|
+
input: r.data
|
|
2656
2656
|
})
|
|
2657
2657
|
})) : {
|
|
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 z(r.common.issues);
|
|
2662
2662
|
},
|
|
2663
|
-
input:
|
|
2663
|
+
input: r.data
|
|
2664
2664
|
})
|
|
2665
2665
|
};
|
|
2666
2666
|
}
|
|
@@ -2668,249 +2668,251 @@ class Qe extends v {
|
|
|
2668
2668
|
return this._def.innerType;
|
|
2669
2669
|
}
|
|
2670
2670
|
}
|
|
2671
|
-
|
|
2671
|
+
tt.create = (t, e) => new tt({
|
|
2672
2672
|
innerType: t,
|
|
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 gt extends v {
|
|
2678
2678
|
_parse(e) {
|
|
2679
2679
|
if (this._getType(e) !== h.nan) {
|
|
2680
|
-
const
|
|
2681
|
-
return m(
|
|
2680
|
+
const r = this._getOrReturnCtx(e);
|
|
2681
|
+
return m(r, {
|
|
2682
2682
|
code: l.invalid_type,
|
|
2683
2683
|
expected: h.nan,
|
|
2684
|
-
received:
|
|
2684
|
+
received: r.parsedType
|
|
2685
2685
|
}), g;
|
|
2686
2686
|
}
|
|
2687
2687
|
return { status: "valid", value: e.data };
|
|
2688
2688
|
}
|
|
2689
2689
|
}
|
|
2690
|
-
|
|
2690
|
+
gt.create = (t) => new gt({
|
|
2691
2691
|
typeName: y.ZodNaN,
|
|
2692
2692
|
..._(t)
|
|
2693
2693
|
});
|
|
2694
|
-
const
|
|
2695
|
-
class
|
|
2694
|
+
const hr = Symbol("zod_brand");
|
|
2695
|
+
class At extends v {
|
|
2696
2696
|
_parse(e) {
|
|
2697
|
-
const { ctx:
|
|
2697
|
+
const { ctx: n } = this._processInputParams(e), r = n.data;
|
|
2698
2698
|
return this._def.type._parse({
|
|
2699
|
-
data:
|
|
2700
|
-
path:
|
|
2701
|
-
parent:
|
|
2699
|
+
data: r,
|
|
2700
|
+
path: n.path,
|
|
2701
|
+
parent: n
|
|
2702
2702
|
});
|
|
2703
2703
|
}
|
|
2704
2704
|
unwrap() {
|
|
2705
2705
|
return this._def.type;
|
|
2706
2706
|
}
|
|
2707
2707
|
}
|
|
2708
|
-
class
|
|
2708
|
+
class at extends v {
|
|
2709
2709
|
_parse(e) {
|
|
2710
|
-
const { status:
|
|
2711
|
-
if (
|
|
2710
|
+
const { status: n, ctx: r } = this._processInputParams(e);
|
|
2711
|
+
if (r.common.async)
|
|
2712
2712
|
return (async () => {
|
|
2713
2713
|
const a = await this._def.in._parseAsync({
|
|
2714
|
-
data:
|
|
2715
|
-
path:
|
|
2716
|
-
parent:
|
|
2714
|
+
data: r.data,
|
|
2715
|
+
path: r.path,
|
|
2716
|
+
parent: r
|
|
2717
2717
|
});
|
|
2718
|
-
return a.status === "aborted" ? g : a.status === "dirty" ? (
|
|
2718
|
+
return a.status === "aborted" ? g : a.status === "dirty" ? (n.dirty(), Ie(a.value)) : this._def.out._parseAsync({
|
|
2719
2719
|
data: a.value,
|
|
2720
|
-
path:
|
|
2721
|
-
parent:
|
|
2720
|
+
path: r.path,
|
|
2721
|
+
parent: r
|
|
2722
2722
|
});
|
|
2723
2723
|
})();
|
|
2724
2724
|
{
|
|
2725
2725
|
const s = this._def.in._parseSync({
|
|
2726
|
-
data:
|
|
2727
|
-
path:
|
|
2728
|
-
parent:
|
|
2726
|
+
data: r.data,
|
|
2727
|
+
path: r.path,
|
|
2728
|
+
parent: r
|
|
2729
2729
|
});
|
|
2730
|
-
return s.status === "aborted" ? g : s.status === "dirty" ? (
|
|
2730
|
+
return s.status === "aborted" ? g : s.status === "dirty" ? (n.dirty(), {
|
|
2731
2731
|
status: "dirty",
|
|
2732
2732
|
value: s.value
|
|
2733
2733
|
}) : this._def.out._parseSync({
|
|
2734
2734
|
data: s.value,
|
|
2735
|
-
path:
|
|
2736
|
-
parent:
|
|
2735
|
+
path: r.path,
|
|
2736
|
+
parent: r
|
|
2737
2737
|
});
|
|
2738
2738
|
}
|
|
2739
2739
|
}
|
|
2740
|
-
static create(e,
|
|
2741
|
-
return new
|
|
2740
|
+
static create(e, n) {
|
|
2741
|
+
return new at({
|
|
2742
2742
|
in: e,
|
|
2743
|
-
out:
|
|
2743
|
+
out: n,
|
|
2744
2744
|
typeName: y.ZodPipeline
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
2747
|
}
|
|
2748
|
-
class
|
|
2748
|
+
class nt extends v {
|
|
2749
2749
|
_parse(e) {
|
|
2750
|
-
const
|
|
2751
|
-
return
|
|
2750
|
+
const n = this._def.innerType._parse(e), r = (s) => (ze(s) && (s.value = Object.freeze(s.value)), s);
|
|
2751
|
+
return Be(n) ? n.then((s) => r(s)) : r(n);
|
|
2752
2752
|
}
|
|
2753
2753
|
unwrap() {
|
|
2754
2754
|
return this._def.innerType;
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
2757
|
-
|
|
2757
|
+
nt.create = (t, e) => new nt({
|
|
2758
2758
|
innerType: t,
|
|
2759
2759
|
typeName: y.ZodReadonly,
|
|
2760
2760
|
..._(e)
|
|
2761
2761
|
});
|
|
2762
|
-
function
|
|
2763
|
-
return t ?
|
|
2762
|
+
function on(t, e = {}, n) {
|
|
2763
|
+
return t ? Ne.create().superRefine((r, s) => {
|
|
2764
2764
|
var a, o;
|
|
2765
|
-
if (!t(
|
|
2766
|
-
const c = typeof e == "function" ? e(
|
|
2765
|
+
if (!t(r)) {
|
|
2766
|
+
const c = typeof e == "function" ? e(r) : typeof e == "string" ? { message: e } : e, u = (o = (a = c.fatal) !== null && a !== void 0 ? a : n) !== null && o !== void 0 ? o : !0, d = typeof c == "string" ? { message: c } : c;
|
|
2767
2767
|
s.addIssue({ code: "custom", ...d, fatal: u });
|
|
2768
2768
|
}
|
|
2769
|
-
}) :
|
|
2769
|
+
}) : Ne.create();
|
|
2770
2770
|
}
|
|
2771
|
-
const
|
|
2771
|
+
const pr = {
|
|
2772
2772
|
object: C.lazycreate
|
|
2773
2773
|
};
|
|
2774
2774
|
var y;
|
|
2775
2775
|
(function(t) {
|
|
2776
2776
|
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2777
2777
|
})(y || (y = {}));
|
|
2778
|
-
const
|
|
2778
|
+
const yr = (t, e = {
|
|
2779
2779
|
message: `Input not instance of ${t.name}`
|
|
2780
|
-
}) =>
|
|
2781
|
-
string: (t) =>
|
|
2782
|
-
number: (t) =>
|
|
2783
|
-
boolean: (t) =>
|
|
2780
|
+
}) => on((n) => n instanceof t, e), cn = K.create, dn = ge.create, gr = gt.create, _r = _e.create, un = He.create, vr = Se.create, br = ht.create, wr = qe.create, xr = We.create, Er = Ne.create, kr = Ce.create, Tr = ue.create, Cr = pt.create, Sr = Y.create, Rr = C.create, Or = C.strictCreate, Ir = Ke.create, Pr = _t.create, Ar = Ye.create, Nr = ae.create, Mr = Je.create, jr = yt.create, Zr = Re.create, Dr = Pe.create, $r = Ge.create, Lr = Xe.create, Ur = ve.create, Vr = Qe.create, Fr = Me.create, Ht = J.create, zr = ne.create, Br = be.create, Hr = J.createWithPreprocess, qr = at.create, Wr = () => cn().optional(), Kr = () => dn().optional(), Yr = () => un().optional(), Jr = {
|
|
2781
|
+
string: (t) => K.create({ ...t, coerce: !0 }),
|
|
2782
|
+
number: (t) => ge.create({ ...t, coerce: !0 }),
|
|
2783
|
+
boolean: (t) => He.create({
|
|
2784
2784
|
...t,
|
|
2785
2785
|
coerce: !0
|
|
2786
2786
|
}),
|
|
2787
|
-
bigint: (t) =>
|
|
2788
|
-
date: (t) =>
|
|
2789
|
-
},
|
|
2787
|
+
bigint: (t) => _e.create({ ...t, coerce: !0 }),
|
|
2788
|
+
date: (t) => Se.create({ ...t, coerce: !0 })
|
|
2789
|
+
}, Gr = g;
|
|
2790
2790
|
var i = /* @__PURE__ */ Object.freeze({
|
|
2791
2791
|
__proto__: null,
|
|
2792
|
-
defaultErrorMap:
|
|
2793
|
-
setErrorMap:
|
|
2794
|
-
getErrorMap:
|
|
2795
|
-
makeIssue:
|
|
2796
|
-
EMPTY_PATH:
|
|
2792
|
+
defaultErrorMap: Ae,
|
|
2793
|
+
setErrorMap: Gn,
|
|
2794
|
+
getErrorMap: lt,
|
|
2795
|
+
makeIssue: ft,
|
|
2796
|
+
EMPTY_PATH: Xn,
|
|
2797
2797
|
addIssueToContext: m,
|
|
2798
|
-
ParseStatus:
|
|
2798
|
+
ParseStatus: Z,
|
|
2799
2799
|
INVALID: g,
|
|
2800
|
-
DIRTY:
|
|
2801
|
-
OK:
|
|
2802
|
-
isAborted:
|
|
2803
|
-
isDirty:
|
|
2804
|
-
isValid:
|
|
2805
|
-
isAsync:
|
|
2800
|
+
DIRTY: Ie,
|
|
2801
|
+
OK: $,
|
|
2802
|
+
isAborted: Ct,
|
|
2803
|
+
isDirty: St,
|
|
2804
|
+
isValid: ze,
|
|
2805
|
+
isAsync: Be,
|
|
2806
2806
|
get util() {
|
|
2807
2807
|
return x;
|
|
2808
2808
|
},
|
|
2809
2809
|
get objectUtil() {
|
|
2810
|
-
return
|
|
2810
|
+
return Tt;
|
|
2811
2811
|
},
|
|
2812
2812
|
ZodParsedType: h,
|
|
2813
|
-
getParsedType:
|
|
2813
|
+
getParsedType: pe,
|
|
2814
2814
|
ZodType: v,
|
|
2815
|
-
datetimeRegex:
|
|
2816
|
-
ZodString:
|
|
2817
|
-
ZodNumber:
|
|
2818
|
-
ZodBigInt:
|
|
2819
|
-
ZodBoolean:
|
|
2820
|
-
ZodDate:
|
|
2821
|
-
ZodSymbol:
|
|
2822
|
-
ZodUndefined:
|
|
2823
|
-
ZodNull:
|
|
2824
|
-
ZodAny:
|
|
2825
|
-
ZodUnknown:
|
|
2826
|
-
ZodNever:
|
|
2827
|
-
ZodVoid:
|
|
2828
|
-
ZodArray:
|
|
2815
|
+
datetimeRegex: sn,
|
|
2816
|
+
ZodString: K,
|
|
2817
|
+
ZodNumber: ge,
|
|
2818
|
+
ZodBigInt: _e,
|
|
2819
|
+
ZodBoolean: He,
|
|
2820
|
+
ZodDate: Se,
|
|
2821
|
+
ZodSymbol: ht,
|
|
2822
|
+
ZodUndefined: qe,
|
|
2823
|
+
ZodNull: We,
|
|
2824
|
+
ZodAny: Ne,
|
|
2825
|
+
ZodUnknown: Ce,
|
|
2826
|
+
ZodNever: ue,
|
|
2827
|
+
ZodVoid: pt,
|
|
2828
|
+
ZodArray: Y,
|
|
2829
2829
|
ZodObject: C,
|
|
2830
|
-
ZodUnion:
|
|
2831
|
-
ZodDiscriminatedUnion:
|
|
2832
|
-
ZodIntersection:
|
|
2833
|
-
ZodTuple:
|
|
2834
|
-
ZodRecord:
|
|
2835
|
-
ZodMap:
|
|
2836
|
-
ZodSet:
|
|
2837
|
-
ZodFunction:
|
|
2838
|
-
ZodLazy:
|
|
2839
|
-
ZodLiteral:
|
|
2840
|
-
ZodEnum:
|
|
2841
|
-
ZodNativeEnum:
|
|
2842
|
-
ZodPromise:
|
|
2843
|
-
ZodEffects:
|
|
2844
|
-
ZodTransformer:
|
|
2845
|
-
ZodOptional:
|
|
2846
|
-
ZodNullable:
|
|
2847
|
-
ZodDefault:
|
|
2848
|
-
ZodCatch:
|
|
2849
|
-
ZodNaN:
|
|
2850
|
-
BRAND:
|
|
2851
|
-
ZodBranded:
|
|
2852
|
-
ZodPipeline:
|
|
2853
|
-
ZodReadonly:
|
|
2854
|
-
custom:
|
|
2830
|
+
ZodUnion: Ke,
|
|
2831
|
+
ZodDiscriminatedUnion: _t,
|
|
2832
|
+
ZodIntersection: Ye,
|
|
2833
|
+
ZodTuple: ae,
|
|
2834
|
+
ZodRecord: Je,
|
|
2835
|
+
ZodMap: yt,
|
|
2836
|
+
ZodSet: Re,
|
|
2837
|
+
ZodFunction: Pe,
|
|
2838
|
+
ZodLazy: Ge,
|
|
2839
|
+
ZodLiteral: Xe,
|
|
2840
|
+
ZodEnum: ve,
|
|
2841
|
+
ZodNativeEnum: Qe,
|
|
2842
|
+
ZodPromise: Me,
|
|
2843
|
+
ZodEffects: J,
|
|
2844
|
+
ZodTransformer: J,
|
|
2845
|
+
ZodOptional: ne,
|
|
2846
|
+
ZodNullable: be,
|
|
2847
|
+
ZodDefault: et,
|
|
2848
|
+
ZodCatch: tt,
|
|
2849
|
+
ZodNaN: gt,
|
|
2850
|
+
BRAND: hr,
|
|
2851
|
+
ZodBranded: At,
|
|
2852
|
+
ZodPipeline: at,
|
|
2853
|
+
ZodReadonly: nt,
|
|
2854
|
+
custom: on,
|
|
2855
2855
|
Schema: v,
|
|
2856
2856
|
ZodSchema: v,
|
|
2857
|
-
late:
|
|
2857
|
+
late: pr,
|
|
2858
2858
|
get ZodFirstPartyTypeKind() {
|
|
2859
2859
|
return y;
|
|
2860
2860
|
},
|
|
2861
|
-
coerce:
|
|
2862
|
-
any:
|
|
2863
|
-
array:
|
|
2864
|
-
bigint:
|
|
2865
|
-
boolean:
|
|
2866
|
-
date:
|
|
2867
|
-
discriminatedUnion:
|
|
2868
|
-
effect:
|
|
2869
|
-
enum:
|
|
2870
|
-
function:
|
|
2871
|
-
instanceof:
|
|
2872
|
-
intersection:
|
|
2873
|
-
lazy:
|
|
2874
|
-
literal:
|
|
2875
|
-
map:
|
|
2876
|
-
nan:
|
|
2877
|
-
nativeEnum:
|
|
2878
|
-
never:
|
|
2879
|
-
null:
|
|
2880
|
-
nullable:
|
|
2881
|
-
number:
|
|
2882
|
-
object:
|
|
2883
|
-
oboolean:
|
|
2884
|
-
onumber:
|
|
2885
|
-
optional:
|
|
2886
|
-
ostring:
|
|
2887
|
-
pipeline:
|
|
2888
|
-
preprocess:
|
|
2889
|
-
promise:
|
|
2890
|
-
record:
|
|
2891
|
-
set:
|
|
2892
|
-
strictObject:
|
|
2893
|
-
string:
|
|
2894
|
-
symbol:
|
|
2895
|
-
transformer:
|
|
2896
|
-
tuple:
|
|
2897
|
-
undefined:
|
|
2898
|
-
union:
|
|
2899
|
-
unknown:
|
|
2900
|
-
void:
|
|
2901
|
-
NEVER:
|
|
2861
|
+
coerce: Jr,
|
|
2862
|
+
any: Er,
|
|
2863
|
+
array: Sr,
|
|
2864
|
+
bigint: _r,
|
|
2865
|
+
boolean: un,
|
|
2866
|
+
date: vr,
|
|
2867
|
+
discriminatedUnion: Pr,
|
|
2868
|
+
effect: Ht,
|
|
2869
|
+
enum: Ur,
|
|
2870
|
+
function: Dr,
|
|
2871
|
+
instanceof: yr,
|
|
2872
|
+
intersection: Ar,
|
|
2873
|
+
lazy: $r,
|
|
2874
|
+
literal: Lr,
|
|
2875
|
+
map: jr,
|
|
2876
|
+
nan: gr,
|
|
2877
|
+
nativeEnum: Vr,
|
|
2878
|
+
never: Tr,
|
|
2879
|
+
null: xr,
|
|
2880
|
+
nullable: Br,
|
|
2881
|
+
number: dn,
|
|
2882
|
+
object: Rr,
|
|
2883
|
+
oboolean: Yr,
|
|
2884
|
+
onumber: Kr,
|
|
2885
|
+
optional: zr,
|
|
2886
|
+
ostring: Wr,
|
|
2887
|
+
pipeline: qr,
|
|
2888
|
+
preprocess: Hr,
|
|
2889
|
+
promise: Fr,
|
|
2890
|
+
record: Mr,
|
|
2891
|
+
set: Zr,
|
|
2892
|
+
strictObject: Or,
|
|
2893
|
+
string: cn,
|
|
2894
|
+
symbol: br,
|
|
2895
|
+
transformer: Ht,
|
|
2896
|
+
tuple: Nr,
|
|
2897
|
+
undefined: wr,
|
|
2898
|
+
union: Ir,
|
|
2899
|
+
unknown: kr,
|
|
2900
|
+
void: Cr,
|
|
2901
|
+
NEVER: Gr,
|
|
2902
2902
|
ZodIssueCode: l,
|
|
2903
|
-
quotelessJson:
|
|
2904
|
-
ZodError:
|
|
2903
|
+
quotelessJson: Jn,
|
|
2904
|
+
ZodError: z
|
|
2905
2905
|
});
|
|
2906
|
-
const
|
|
2907
|
-
var
|
|
2908
|
-
const
|
|
2909
|
-
var
|
|
2910
|
-
const
|
|
2906
|
+
const F = i.string().trim().min(1, { message: "Cannot be blank" }), V = i.string().trim().optional(), Ot = (t) => i.nullable(t.optional());
|
|
2907
|
+
var rt = /* @__PURE__ */ ((t) => (t.FIRST_NAME = "firstName", t.LAST_NAME = "lastName", t.EMAIL = "email", t.ZIP_CODE = "zipCode", t.CITY = "city", t.STATE = "state", t.COUNTRY = "country", t.ADDRESS = "address", t.PHONE = "phone", t.PROMOTION_CODE = "promotionCode", t))(rt || {});
|
|
2908
|
+
const ln = i.nativeEnum(rt);
|
|
2909
|
+
var fn = /* @__PURE__ */ ((t) => (t.CARD_NUMBER = "cardNumber", t.CARD_EXPIRY = "cardExpiry", t.CARD_CVC = "cardCvc", t))(fn || {});
|
|
2910
|
+
const mn = i.nativeEnum(fn), Xr = i.union([ln, mn]), hn = i.object({
|
|
2911
2911
|
provider: i.string(),
|
|
2912
|
-
processor_name:
|
|
2913
|
-
metadata:
|
|
2912
|
+
processor_name: Ot(i.string()),
|
|
2913
|
+
metadata: Ot(i.record(i.string(), i.any()))
|
|
2914
|
+
}), Qr = i.object({
|
|
2915
|
+
id: i.string()
|
|
2914
2916
|
});
|
|
2915
2917
|
i.object({
|
|
2916
2918
|
cardNumber: V,
|
|
@@ -2926,7 +2928,7 @@ i.object({
|
|
|
2926
2928
|
margin: V,
|
|
2927
2929
|
padding: V
|
|
2928
2930
|
});
|
|
2929
|
-
const
|
|
2931
|
+
const T = i.enum([
|
|
2930
2932
|
// Element -> Form
|
|
2931
2933
|
"LAYOUT",
|
|
2932
2934
|
"LOADED",
|
|
@@ -2947,267 +2949,273 @@ const E = i.enum([
|
|
|
2947
2949
|
"TOKENIZE",
|
|
2948
2950
|
"CHECKOUT",
|
|
2949
2951
|
"START_PAYMENT_FLOW"
|
|
2950
|
-
]),
|
|
2951
|
-
type:
|
|
2952
|
-
elementType:
|
|
2953
|
-
}),
|
|
2954
|
-
type:
|
|
2955
|
-
message:
|
|
2956
|
-
}),
|
|
2957
|
-
type:
|
|
2958
|
-
elementType:
|
|
2952
|
+
]), es = T.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), ts = i.object({ type: es }), ns = T.extract(["BLUR", "FOCUS", "CHANGE"]), rs = i.object({
|
|
2953
|
+
type: ns,
|
|
2954
|
+
elementType: mn
|
|
2955
|
+
}), ss = T.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), as = i.object({
|
|
2956
|
+
type: ss,
|
|
2957
|
+
message: F
|
|
2958
|
+
}), is = T.extract(["VALIDATION_ERROR"]), os = i.object({
|
|
2959
|
+
type: is,
|
|
2960
|
+
elementType: Xr,
|
|
2959
2961
|
errors: i.array(i.string())
|
|
2960
|
-
}),
|
|
2961
|
-
type: i.literal(
|
|
2962
|
-
height:
|
|
2963
|
-
}),
|
|
2964
|
-
type: i.literal(
|
|
2965
|
-
sessionId:
|
|
2962
|
+
}), cs = i.object({
|
|
2963
|
+
type: i.literal(T.enum.LAYOUT),
|
|
2964
|
+
height: F
|
|
2965
|
+
}), ds = i.object({
|
|
2966
|
+
type: i.literal(T.enum.LOADED),
|
|
2967
|
+
sessionId: F,
|
|
2966
2968
|
totalAmountAtoms: i.number(),
|
|
2967
2969
|
currency: V,
|
|
2968
|
-
checkoutPaymentMethods: i.array(
|
|
2969
|
-
}),
|
|
2970
|
-
type: i.literal(
|
|
2970
|
+
checkoutPaymentMethods: i.array(hn)
|
|
2971
|
+
}), us = i.object({
|
|
2972
|
+
type: i.literal(T.enum.PAYMENT_FLOW_STARTED),
|
|
2971
2973
|
nextActionMetadata: i.record(i.string(), i.any()),
|
|
2972
2974
|
paymentFlowMetadata: i.any().optional(),
|
|
2973
2975
|
startPFMetadata: i.optional(i.record(i.string(), i.any()))
|
|
2974
|
-
}),
|
|
2975
|
-
type: i.literal(
|
|
2976
|
+
}), ls = i.object({
|
|
2977
|
+
type: i.literal(T.enum.SETUP_PAYMENT_METHOD_SUCCESS),
|
|
2976
2978
|
paymentMethodId: i.string()
|
|
2977
|
-
}),
|
|
2978
|
-
firstName:
|
|
2979
|
-
lastName:
|
|
2980
|
-
email:
|
|
2981
|
-
zipCode:
|
|
2982
|
-
country:
|
|
2979
|
+
}), fs = i.object({
|
|
2980
|
+
firstName: F,
|
|
2981
|
+
lastName: F,
|
|
2982
|
+
email: F,
|
|
2983
|
+
zipCode: F,
|
|
2984
|
+
country: F,
|
|
2983
2985
|
promotionCode: V
|
|
2984
|
-
}),
|
|
2985
|
-
type:
|
|
2986
|
-
sessionId:
|
|
2987
|
-
checkoutPaymentMethod:
|
|
2986
|
+
}), ms = T.extract(["TOKENIZE", "CHECKOUT", "START_PAYMENT_FLOW"]), pn = i.object({
|
|
2987
|
+
type: ms,
|
|
2988
|
+
sessionId: F,
|
|
2989
|
+
checkoutPaymentMethod: hn,
|
|
2988
2990
|
paymentFlowMetadata: i.any().optional(),
|
|
2989
2991
|
doNotUseLegacyCCFlow: i.boolean().optional(),
|
|
2990
2992
|
existingCCPMId: V
|
|
2991
|
-
}).extend(
|
|
2992
|
-
type: i.literal(
|
|
2993
|
+
}).extend(fs.shape), hs = i.object({
|
|
2994
|
+
type: i.literal(T.enum.TOKENIZE_SUCCESS),
|
|
2993
2995
|
isReadyForCheckout: i.boolean()
|
|
2994
|
-
}),
|
|
2995
|
-
type: i.literal(
|
|
2996
|
+
}), ps = i.object({
|
|
2997
|
+
type: i.literal(T.enum.CHECKOUT_SUCCESS),
|
|
2996
2998
|
invoiceUrls: i.array(i.string()),
|
|
2997
2999
|
subscriptionIds: i.array(i.string()),
|
|
2998
3000
|
customerId: i.string()
|
|
2999
|
-
}),
|
|
3000
|
-
Gn,
|
|
3001
|
-
Qn,
|
|
3001
|
+
}), ys = i.discriminatedUnion("type", [
|
|
3002
3002
|
ts,
|
|
3003
|
-
|
|
3004
|
-
ss,
|
|
3003
|
+
rs,
|
|
3005
3004
|
as,
|
|
3006
|
-
|
|
3005
|
+
os,
|
|
3006
|
+
cs,
|
|
3007
|
+
ds,
|
|
3008
|
+
pn,
|
|
3009
|
+
hs,
|
|
3010
|
+
ps,
|
|
3007
3011
|
us,
|
|
3008
|
-
ls
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
formId: H,
|
|
3015
|
-
elementId: H
|
|
3012
|
+
ls
|
|
3013
|
+
]), gs = i.object({
|
|
3014
|
+
payload: ys,
|
|
3015
|
+
nonce: F,
|
|
3016
|
+
formId: F,
|
|
3017
|
+
elementId: F
|
|
3016
3018
|
});
|
|
3017
3019
|
i.object({
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
startFlow: i.function(i.tuple([]), i.void())
|
|
3020
|
+
amountAtom: i.number(),
|
|
3021
|
+
currency: F
|
|
3021
3022
|
});
|
|
3022
3023
|
i.object({
|
|
3023
3024
|
secure_token: i.string(),
|
|
3024
3025
|
promotion_code: i.string().optional()
|
|
3025
3026
|
});
|
|
3026
|
-
|
|
3027
|
+
i.object({
|
|
3028
|
+
secure_token: i.string(),
|
|
3029
|
+
existing_cc_pm_id: Ot(i.string())
|
|
3030
|
+
});
|
|
3031
|
+
const _s = i.object({
|
|
3032
|
+
payment_methods: i.array(Qr)
|
|
3033
|
+
}), vs = (t) => {
|
|
3027
3034
|
const e = {};
|
|
3028
|
-
return Object.entries(t).forEach(([
|
|
3035
|
+
return Object.entries(t).forEach(([n, r]) => {
|
|
3029
3036
|
try {
|
|
3030
|
-
const s =
|
|
3031
|
-
Array.isArray(
|
|
3037
|
+
const s = ln.parse(n);
|
|
3038
|
+
Array.isArray(r) ? e[s] = r : Array.isArray(r._errors) && (e[s] = r._errors);
|
|
3032
3039
|
} catch {
|
|
3033
3040
|
return;
|
|
3034
3041
|
}
|
|
3035
3042
|
}), e;
|
|
3036
|
-
},
|
|
3043
|
+
}, yn = (t, e) => Array.from(t.querySelectorAll("input[data-opid]") ?? []).reduce((s, a) => {
|
|
3037
3044
|
const o = a.getAttribute("data-opid");
|
|
3038
3045
|
return o ? { ...s, [o]: a.value } : s;
|
|
3039
|
-
}, e),
|
|
3040
|
-
const c =
|
|
3046
|
+
}, e), dt = (t, e, n, r, s, a, o) => {
|
|
3047
|
+
const c = yn(n, {
|
|
3041
3048
|
type: t,
|
|
3042
3049
|
sessionId: e,
|
|
3043
3050
|
checkoutPaymentMethod: s,
|
|
3044
3051
|
paymentFlowMetadata: o,
|
|
3045
3052
|
doNotUseLegacyCCFlow: a
|
|
3046
3053
|
});
|
|
3047
|
-
(s.provider === "apple_pay" || s.provider === "google_pay") && (c[
|
|
3048
|
-
const u =
|
|
3054
|
+
(s.provider === "apple_pay" || s.provider === "google_pay") && (c[rt.ZIP_CODE] || (c[rt.ZIP_CODE] = "00000"));
|
|
3055
|
+
const u = pn.safeParse(c);
|
|
3049
3056
|
if (u.success)
|
|
3050
3057
|
return u.data;
|
|
3051
3058
|
{
|
|
3052
|
-
const d = u.error.format(), f =
|
|
3059
|
+
const d = u.error.format(), f = vs(d);
|
|
3053
3060
|
for (const [b, w] of Object.entries(f))
|
|
3054
|
-
|
|
3061
|
+
r(b, w, b);
|
|
3055
3062
|
return null;
|
|
3056
3063
|
}
|
|
3057
|
-
},
|
|
3064
|
+
}, bs = (t) => {
|
|
3058
3065
|
try {
|
|
3059
|
-
return
|
|
3066
|
+
return gs.parse(t);
|
|
3060
3067
|
} catch (e) {
|
|
3061
3068
|
throw e;
|
|
3062
3069
|
}
|
|
3063
|
-
},
|
|
3070
|
+
}, $e = (t, e, n, r, s) => {
|
|
3064
3071
|
const a = {
|
|
3065
|
-
payload:
|
|
3066
|
-
nonce:
|
|
3072
|
+
payload: r,
|
|
3073
|
+
nonce: Qt(),
|
|
3067
3074
|
formId: e,
|
|
3068
|
-
elementId:
|
|
3075
|
+
elementId: n
|
|
3069
3076
|
};
|
|
3070
3077
|
t.postMessage(JSON.stringify(a), s);
|
|
3071
|
-
},
|
|
3078
|
+
}, ws = "https://cde.openpaystaging.com", xs = {
|
|
3072
3079
|
usd: "usd",
|
|
3073
3080
|
brl: "brl"
|
|
3074
|
-
},
|
|
3075
|
-
for (let
|
|
3076
|
-
|
|
3077
|
-
if (!
|
|
3081
|
+
}, Nt = async (t) => {
|
|
3082
|
+
for (let n = 0; n < 10; n++)
|
|
3083
|
+
qt() || await Es(500);
|
|
3084
|
+
if (!qt())
|
|
3078
3085
|
throw new Error("Stripe JS not found.");
|
|
3079
3086
|
return new Stripe(t);
|
|
3080
|
-
},
|
|
3081
|
-
const
|
|
3082
|
-
return
|
|
3087
|
+
}, gn = async (t, e, n, r) => {
|
|
3088
|
+
const s = await Nt(t), a = xs[n.toLowerCase().trim()];
|
|
3089
|
+
return s.paymentRequest({
|
|
3083
3090
|
// TODO: replace this with stripe account country as soon as we support it
|
|
3084
3091
|
country: "US",
|
|
3085
|
-
currency:
|
|
3092
|
+
currency: a,
|
|
3086
3093
|
total: {
|
|
3087
3094
|
label: "Total",
|
|
3088
|
-
amount: e
|
|
3095
|
+
amount: e,
|
|
3096
|
+
pending: r
|
|
3089
3097
|
},
|
|
3090
3098
|
requestPayerName: !0,
|
|
3091
3099
|
requestPayerEmail: !0
|
|
3092
3100
|
});
|
|
3093
|
-
},
|
|
3101
|
+
}, Es = (t) => new Promise((e) => {
|
|
3094
3102
|
setTimeout(e, t);
|
|
3095
|
-
}),
|
|
3103
|
+
}), qt = () => "Stripe" in window, ks = async (t) => new Promise((e, n) => {
|
|
3096
3104
|
try {
|
|
3097
|
-
t.on("paymentmethod", async (
|
|
3098
|
-
e(
|
|
3105
|
+
t.on("paymentmethod", async (r) => {
|
|
3106
|
+
e(r);
|
|
3099
3107
|
}), t.on("cancel", () => {
|
|
3100
|
-
|
|
3108
|
+
n(new Error("Payment cancelled, please click Submit again to pay"));
|
|
3101
3109
|
});
|
|
3102
|
-
} catch (
|
|
3103
|
-
r
|
|
3110
|
+
} catch (r) {
|
|
3111
|
+
n(r);
|
|
3104
3112
|
}
|
|
3105
|
-
}),
|
|
3113
|
+
}), Ts = (t) => {
|
|
3106
3114
|
const e = t == null ? void 0 : t.stripe_pk;
|
|
3107
3115
|
if (typeof e != "string")
|
|
3108
3116
|
throw new Error("Invalid: stripe_pk not passed in checkout payment method");
|
|
3109
3117
|
return e;
|
|
3110
|
-
},
|
|
3111
|
-
const
|
|
3118
|
+
}, Cs = async (t, e) => {
|
|
3119
|
+
const n = t.nextActionMetadata;
|
|
3112
3120
|
if (!t.paymentFlowMetadata || !t.paymentFlowMetadata.stripePmId)
|
|
3113
3121
|
throw new Error(`Invalid payment flow metadata format: ${JSON.stringify(t.paymentFlowMetadata)}`);
|
|
3114
|
-
if (!
|
|
3115
|
-
throw new Error(`Invalid next action metadata format: ${JSON.stringify(
|
|
3122
|
+
if (!n.stripe_pk || !n.client_secret)
|
|
3123
|
+
throw new Error(`Invalid next action metadata format: ${JSON.stringify(n)}`);
|
|
3116
3124
|
if (e.paymentMethod.id !== t.paymentFlowMetadata.stripePmId)
|
|
3117
3125
|
throw new Error(`PM ID mismatch: ${e.paymentMethod.id} != ${t.paymentFlowMetadata.stripePmId}`);
|
|
3118
|
-
const s = await (await
|
|
3126
|
+
const s = await (await Nt(n.stripe_pk)).confirmCardSetup(n.client_secret, {
|
|
3119
3127
|
payment_method: t.paymentFlowMetadata.stripePmId
|
|
3120
3128
|
});
|
|
3121
3129
|
if (s.error)
|
|
3122
3130
|
throw e.complete("fail"), new Error(`Payment failed: ${s.error.message ?? "unknown"}`);
|
|
3123
3131
|
e.complete("success");
|
|
3124
|
-
},
|
|
3132
|
+
}, Ss = async (t) => {
|
|
3125
3133
|
var a, o, c, u;
|
|
3126
|
-
const e = t.nextActionMetadata,
|
|
3134
|
+
const e = t.nextActionMetadata, r = await (await Nt(e.stripe_pk)).confirmCardSetup(e.client_secret, {
|
|
3127
3135
|
payment_method: e.stripe_pm_id
|
|
3128
|
-
}), s = (a =
|
|
3136
|
+
}), s = (a = r.setupIntent) == null ? void 0 : a.status;
|
|
3129
3137
|
if (s !== "succeeded") throw s === "canceled" ? new Error("Payment cancelled, please click Submit again to pay") : new Error(
|
|
3130
|
-
`${((o =
|
|
3138
|
+
`${((o = r.error) == null ? void 0 : o.message) ?? ((u = (c = r.setupIntent) == null ? void 0 : c.last_setup_error) == null ? void 0 : u.message) ?? "Payment failed, please click submit again to pay."}`
|
|
3131
3139
|
);
|
|
3132
|
-
},
|
|
3133
|
-
const [e,
|
|
3140
|
+
}, Rs = (t = {}) => {
|
|
3141
|
+
const [e, n] = A(t), r = Fe(
|
|
3134
3142
|
() => ({
|
|
3135
3143
|
set: (a, o) => {
|
|
3136
|
-
|
|
3144
|
+
n((c) => ({
|
|
3137
3145
|
...c,
|
|
3138
3146
|
[a]: o
|
|
3139
3147
|
}));
|
|
3140
3148
|
},
|
|
3141
3149
|
setAll: (a) => {
|
|
3142
|
-
|
|
3150
|
+
n(a);
|
|
3143
3151
|
},
|
|
3144
3152
|
remove: (a) => {
|
|
3145
|
-
|
|
3153
|
+
n((o) => {
|
|
3146
3154
|
const { [a]: c, ...u } = o;
|
|
3147
3155
|
return u;
|
|
3148
3156
|
});
|
|
3149
3157
|
},
|
|
3150
|
-
reset: () =>
|
|
3158
|
+
reset: () => n(t)
|
|
3151
3159
|
}),
|
|
3152
3160
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3153
|
-
[
|
|
3161
|
+
[n]
|
|
3154
3162
|
), s = {
|
|
3155
|
-
get:
|
|
3156
|
-
...
|
|
3163
|
+
get: Le((a) => e[a], [e]),
|
|
3164
|
+
...r
|
|
3157
3165
|
};
|
|
3158
3166
|
return [e, s];
|
|
3159
3167
|
};
|
|
3160
|
-
function
|
|
3168
|
+
function Os(t) {
|
|
3161
3169
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
3162
3170
|
}
|
|
3163
|
-
var
|
|
3164
|
-
function
|
|
3165
|
-
var
|
|
3166
|
-
|
|
3171
|
+
var Mt = { exports: {} }, Is = Fn;
|
|
3172
|
+
function _n(t, e, n) {
|
|
3173
|
+
var r = typeof e == "function";
|
|
3174
|
+
Is.useEffect(function() {
|
|
3167
3175
|
var s, a = !0, o = t(function() {
|
|
3168
3176
|
return a;
|
|
3169
3177
|
});
|
|
3170
3178
|
return Promise.resolve(o).then(function(c) {
|
|
3171
3179
|
s = c;
|
|
3172
3180
|
}), function() {
|
|
3173
|
-
a = !1,
|
|
3181
|
+
a = !1, r && e(s);
|
|
3174
3182
|
};
|
|
3175
|
-
},
|
|
3183
|
+
}, r ? n : e);
|
|
3176
3184
|
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
var
|
|
3180
|
-
const
|
|
3185
|
+
Mt.exports = _n;
|
|
3186
|
+
Mt.exports.useAsyncEffect = _n;
|
|
3187
|
+
var Ps = Mt.exports;
|
|
3188
|
+
const vn = /* @__PURE__ */ Os(Ps), As = i.object({
|
|
3181
3189
|
type: i.string(),
|
|
3182
3190
|
loc: i.array(i.string()),
|
|
3183
3191
|
msg: i.string(),
|
|
3184
3192
|
url: i.string()
|
|
3185
|
-
}),
|
|
3193
|
+
}), Ns = i.array(As), Ms = i.object({
|
|
3186
3194
|
code: i.string(),
|
|
3187
3195
|
message: i.string(),
|
|
3188
3196
|
path: i.array(i.string())
|
|
3189
|
-
}),
|
|
3197
|
+
}), js = i.array(Ms), Zs = {
|
|
3190
3198
|
"failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
|
|
3191
|
-
},
|
|
3199
|
+
}, It = (t) => {
|
|
3192
3200
|
const e = t.toLowerCase().trim();
|
|
3193
|
-
return
|
|
3194
|
-
},
|
|
3201
|
+
return Zs[e] ?? t;
|
|
3202
|
+
}, Ds = (t) => {
|
|
3195
3203
|
try {
|
|
3196
3204
|
return typeof JSON.parse(t) == "object";
|
|
3197
3205
|
} catch {
|
|
3198
3206
|
return !1;
|
|
3199
3207
|
}
|
|
3200
|
-
},
|
|
3201
|
-
${t.map((
|
|
3202
|
-
`)}`,
|
|
3203
|
-
${t.map((
|
|
3204
|
-
`)}`,
|
|
3208
|
+
}, $s = (t) => t.length === 1 ? It(t[0].msg) : `Please fix the following errors:
|
|
3209
|
+
${t.map((n) => `• ${It(n.msg)}`).join(`
|
|
3210
|
+
`)}`, Ls = (t) => `Encountered the following errors:
|
|
3211
|
+
${t.map((n) => `- ${n.path.join("/")}: ${n.message}`).join(`
|
|
3212
|
+
`)}`, bn = (t) => {
|
|
3205
3213
|
if (window.cur_error = t, t instanceof Error)
|
|
3206
|
-
if (
|
|
3214
|
+
if (Ds(t.message)) {
|
|
3207
3215
|
const e = JSON.parse(t.message);
|
|
3208
|
-
return
|
|
3216
|
+
return Ns.safeParse(e).success ? $s(e) : js.safeParse(e).success ? Ls(e) : t.message;
|
|
3209
3217
|
} else
|
|
3210
|
-
return
|
|
3218
|
+
return It(t.message);
|
|
3211
3219
|
if (typeof t == "object")
|
|
3212
3220
|
try {
|
|
3213
3221
|
return JSON.stringify(t);
|
|
@@ -3216,92 +3224,95 @@ ${t.map((r) => `- ${r.path.join("/")}: ${r.message}`).join(`
|
|
|
3216
3224
|
}
|
|
3217
3225
|
else
|
|
3218
3226
|
return t + "";
|
|
3219
|
-
},
|
|
3227
|
+
}, O = (t) => i.nullable(t.optional());
|
|
3220
3228
|
i.string().trim().min(1, { message: "Cannot be blank" });
|
|
3221
|
-
const
|
|
3229
|
+
const Us = i.object({
|
|
3230
|
+
cde_response_type: i.literal("error"),
|
|
3231
|
+
message: i.string()
|
|
3232
|
+
}), Vs = i.enum(["usd", "brl"]), wn = i.object({
|
|
3222
3233
|
name: i.string(),
|
|
3223
|
-
amount_atom_off:
|
|
3224
|
-
percent_off:
|
|
3225
|
-
currency:
|
|
3234
|
+
amount_atom_off: O(i.number()),
|
|
3235
|
+
percent_off: O(i.number()),
|
|
3236
|
+
currency: O(i.string()),
|
|
3226
3237
|
duration: i.string(),
|
|
3227
|
-
duration_in_months:
|
|
3228
|
-
}),
|
|
3238
|
+
duration_in_months: O(i.number())
|
|
3239
|
+
}), Fs = i.object({
|
|
3229
3240
|
amount_subtotal_atom: i.number().int(),
|
|
3230
3241
|
amount_total_atom: i.number().int(),
|
|
3231
3242
|
currency: i.string(),
|
|
3232
|
-
description:
|
|
3243
|
+
description: O(i.string()),
|
|
3233
3244
|
price_id: i.string(),
|
|
3234
|
-
billing_interval:
|
|
3235
|
-
billing_interval_count:
|
|
3245
|
+
billing_interval: O(i.string()),
|
|
3246
|
+
billing_interval_count: O(i.number().int()),
|
|
3236
3247
|
quantity: i.number().int()
|
|
3237
|
-
}),
|
|
3248
|
+
}), zs = i.record(i.string(), i.any()), Bs = i.object({
|
|
3238
3249
|
name: i.string(),
|
|
3239
|
-
settings:
|
|
3240
|
-
}),
|
|
3250
|
+
settings: O(zs)
|
|
3251
|
+
}), Hs = i.object({
|
|
3241
3252
|
provider: i.string(),
|
|
3242
|
-
processor_name:
|
|
3243
|
-
metadata:
|
|
3244
|
-
}),
|
|
3253
|
+
processor_name: O(i.string()),
|
|
3254
|
+
metadata: O(i.record(i.string(), i.any()))
|
|
3255
|
+
}), qs = i.object({
|
|
3245
3256
|
quantity: i.number()
|
|
3246
|
-
}),
|
|
3247
|
-
id:
|
|
3248
|
-
billing_interval:
|
|
3249
|
-
billing_interval_count:
|
|
3250
|
-
subscription_items: i.array(
|
|
3251
|
-
trial_start:
|
|
3252
|
-
trial_end:
|
|
3253
|
-
}),
|
|
3257
|
+
}), Ws = i.object({
|
|
3258
|
+
id: O(i.string()),
|
|
3259
|
+
billing_interval: O(i.string()),
|
|
3260
|
+
billing_interval_count: O(i.number().int()),
|
|
3261
|
+
subscription_items: i.array(qs),
|
|
3262
|
+
trial_start: O(i.string()),
|
|
3263
|
+
trial_end: O(i.string())
|
|
3264
|
+
}), xn = i.object({
|
|
3254
3265
|
amount_atom: i.number()
|
|
3255
|
-
}),
|
|
3266
|
+
}), Ks = i.object({
|
|
3256
3267
|
amount_atom: i.number(),
|
|
3257
3268
|
amount_atom_considering_discount_applied: i.number(),
|
|
3258
3269
|
currency: i.string(),
|
|
3259
|
-
discount_amount_atoms: i.array(
|
|
3270
|
+
discount_amount_atoms: i.array(xn),
|
|
3260
3271
|
subscription_item_id: i.string()
|
|
3261
|
-
}),
|
|
3262
|
-
coupon:
|
|
3263
|
-
}),
|
|
3272
|
+
}), Ys = i.object({
|
|
3273
|
+
coupon: wn
|
|
3274
|
+
}), Js = i.object({
|
|
3264
3275
|
currency: i.string(),
|
|
3265
|
-
discounts: i.array(
|
|
3266
|
-
hosted_invoice_url:
|
|
3267
|
-
lines: i.array(
|
|
3276
|
+
discounts: i.array(Ys),
|
|
3277
|
+
hosted_invoice_url: O(i.string()),
|
|
3278
|
+
lines: i.array(Ks),
|
|
3268
3279
|
remaining_amount_atom: i.number(),
|
|
3269
3280
|
tax_amount_atom: i.number(),
|
|
3270
3281
|
total_amount_atom: i.number(),
|
|
3271
|
-
total_discount_amount_atoms: i.array(
|
|
3272
|
-
}),
|
|
3273
|
-
created: i.array(
|
|
3274
|
-
invoices: i.array(
|
|
3275
|
-
}),
|
|
3276
|
-
preview:
|
|
3277
|
-
preview_post_trial:
|
|
3278
|
-
coupons: i.array(
|
|
3279
|
-
}),
|
|
3282
|
+
total_discount_amount_atoms: i.array(xn)
|
|
3283
|
+
}), Wt = i.object({
|
|
3284
|
+
created: i.array(Ws),
|
|
3285
|
+
invoices: i.array(Js)
|
|
3286
|
+
}), En = i.object({
|
|
3287
|
+
preview: Wt,
|
|
3288
|
+
preview_post_trial: O(Wt),
|
|
3289
|
+
coupons: i.array(wn)
|
|
3290
|
+
}), Kt = i.object({
|
|
3280
3291
|
status: i.literal("open"),
|
|
3281
3292
|
token: i.string(),
|
|
3282
|
-
email:
|
|
3283
|
-
line_items: i.array(
|
|
3293
|
+
email: O(i.string()),
|
|
3294
|
+
line_items: i.array(Fs),
|
|
3284
3295
|
amount_subtotal_atom: i.number().int(),
|
|
3285
3296
|
amount_total_atom: i.number().int(),
|
|
3286
|
-
brand:
|
|
3287
|
-
subs_preview:
|
|
3297
|
+
brand: Bs,
|
|
3298
|
+
subs_preview: O(En),
|
|
3288
3299
|
// Null in setup mode
|
|
3289
|
-
methods_available: i.array(
|
|
3290
|
-
}),
|
|
3300
|
+
methods_available: i.array(Hs)
|
|
3301
|
+
}), kn = i.discriminatedUnion("mode", [
|
|
3291
3302
|
i.object({
|
|
3292
3303
|
mode: i.literal("setup"),
|
|
3293
3304
|
currency: i.nullable(i.undefined())
|
|
3294
|
-
}).extend(
|
|
3305
|
+
}).extend(Kt.shape),
|
|
3295
3306
|
i.object({
|
|
3296
3307
|
mode: i.enum(["payment", "subscription"]),
|
|
3297
|
-
currency:
|
|
3298
|
-
}).extend(
|
|
3299
|
-
]),
|
|
3308
|
+
currency: Vs
|
|
3309
|
+
}).extend(Kt.shape)
|
|
3310
|
+
]), Gs = i.object({
|
|
3300
3311
|
status: i.literal("complete")
|
|
3301
|
-
}),
|
|
3312
|
+
}), Xs = i.object({
|
|
3302
3313
|
status: i.literal("expired")
|
|
3303
3314
|
});
|
|
3304
|
-
i.union([
|
|
3315
|
+
i.union([kn, Gs, Xs]);
|
|
3305
3316
|
i.object({
|
|
3306
3317
|
logo: i.string(),
|
|
3307
3318
|
icon: i.string(),
|
|
@@ -3320,13 +3331,13 @@ i.object({
|
|
|
3320
3331
|
id: i.string(),
|
|
3321
3332
|
return_url: i.string()
|
|
3322
3333
|
});
|
|
3323
|
-
const
|
|
3334
|
+
const Qs = i.object({
|
|
3324
3335
|
type: i.string(),
|
|
3325
3336
|
loc: i.array(i.string()),
|
|
3326
3337
|
msg: i.string(),
|
|
3327
3338
|
url: i.string()
|
|
3328
3339
|
});
|
|
3329
|
-
i.array(
|
|
3340
|
+
i.array(Qs);
|
|
3330
3341
|
i.object({
|
|
3331
3342
|
required_user_actions: i.array(i.record(i.string(), i.any()))
|
|
3332
3343
|
});
|
|
@@ -3334,260 +3345,278 @@ i.object({
|
|
|
3334
3345
|
required_user_actions: i.array(i.record(i.string(), i.any())),
|
|
3335
3346
|
cc_pm_id: i.string()
|
|
3336
3347
|
});
|
|
3337
|
-
const
|
|
3338
|
-
const
|
|
3339
|
-
if (
|
|
3340
|
-
|
|
3348
|
+
const jt = async (t, e, n) => {
|
|
3349
|
+
const r = await t.send(e);
|
|
3350
|
+
if (ta(r))
|
|
3351
|
+
throw new Error(`[cde-client] Error querying CDE: ${r.message}`);
|
|
3352
|
+
if (!ea(r, n)) {
|
|
3353
|
+
const s = n.safeParse(r);
|
|
3341
3354
|
throw s.success ? new Error("Invalid state") : s.error;
|
|
3342
3355
|
}
|
|
3343
|
-
return
|
|
3344
|
-
},
|
|
3356
|
+
return r;
|
|
3357
|
+
}, ea = (t, e) => e.safeParse(t).success, ta = (t) => Us.safeParse(t).success, na = async (t, e) => await jt(t, { type: "get_checkout_preview", payload: e }, En), Tn = async (t) => await jt(t, { type: "get_prefill", payload: {} }, kn), ra = async (t, e) => await jt(t, { type: "confirm_payment_flow", payload: e }, _s), sa = (t) => t.reduce((e, n) => e + n, 0), aa = i.enum(["apple_pay", "google_pay"]), ia = {
|
|
3345
3358
|
apple_pay: "applePay",
|
|
3346
3359
|
google_pay: "googlePay"
|
|
3347
|
-
},
|
|
3360
|
+
}, Yt = {
|
|
3348
3361
|
isLoading: !0,
|
|
3349
3362
|
isAvailable: !1,
|
|
3350
|
-
startFlow: () => {
|
|
3363
|
+
startFlow: async () => {
|
|
3351
3364
|
}
|
|
3352
|
-
},
|
|
3365
|
+
}, oa = {
|
|
3353
3366
|
isLoading: !1,
|
|
3354
3367
|
isAvailable: !1,
|
|
3355
|
-
startFlow: () => {
|
|
3356
|
-
}
|
|
3357
|
-
},
|
|
3358
|
-
const [c, u] =
|
|
3359
|
-
apple_pay:
|
|
3360
|
-
google_pay:
|
|
3361
|
-
}), d = e === void 0 ||
|
|
3362
|
-
return
|
|
3368
|
+
startFlow: async () => {
|
|
3369
|
+
}
|
|
3370
|
+
}, ca = (t, e, n, r, s, a, o) => {
|
|
3371
|
+
const [c, u] = Rs({
|
|
3372
|
+
apple_pay: Yt,
|
|
3373
|
+
google_pay: Yt
|
|
3374
|
+
}), d = e === void 0 || n === void 0 || !r || !t;
|
|
3375
|
+
return vn(async () => {
|
|
3363
3376
|
if (!d)
|
|
3364
|
-
for (const f of
|
|
3377
|
+
for (const f of aa.options) {
|
|
3365
3378
|
const b = f.replace("_", "");
|
|
3366
3379
|
try {
|
|
3367
|
-
const w =
|
|
3380
|
+
const w = n.find((E) => E.provider === f && E.processor_name === "stripe");
|
|
3368
3381
|
if (!w)
|
|
3369
3382
|
throw new Error(`${b} is not available as a checkout method`);
|
|
3370
|
-
const k =
|
|
3383
|
+
const k = Ts(w.metadata), j = await ua(k, f);
|
|
3371
3384
|
u.set(f, {
|
|
3372
3385
|
isLoading: !1,
|
|
3373
3386
|
isAvailable: j,
|
|
3374
|
-
startFlow: () =>
|
|
3387
|
+
startFlow: (E) => fa(
|
|
3375
3388
|
t,
|
|
3376
3389
|
e,
|
|
3377
|
-
|
|
3390
|
+
r,
|
|
3378
3391
|
w,
|
|
3379
3392
|
k,
|
|
3380
3393
|
s,
|
|
3381
3394
|
a,
|
|
3382
|
-
o
|
|
3395
|
+
o,
|
|
3396
|
+
E
|
|
3383
3397
|
)
|
|
3384
3398
|
});
|
|
3385
3399
|
} catch {
|
|
3386
|
-
u.set(f,
|
|
3400
|
+
u.set(f, oa);
|
|
3387
3401
|
}
|
|
3388
3402
|
}
|
|
3389
|
-
}, [d,
|
|
3390
|
-
},
|
|
3391
|
-
const
|
|
3403
|
+
}, [d, n]), c;
|
|
3404
|
+
}, da = async (t, e, n) => {
|
|
3405
|
+
const r = await na(t, {
|
|
3392
3406
|
secure_token: e,
|
|
3393
|
-
promotion_code:
|
|
3394
|
-
}), s = new Set(
|
|
3407
|
+
promotion_code: n
|
|
3408
|
+
}), s = new Set(r.preview.invoices.map((c) => c.currency));
|
|
3395
3409
|
if (s.size !== 1)
|
|
3396
3410
|
throw new Error(`Expected exactly one currency, got ${s.size}`);
|
|
3397
|
-
const a = s.values().next().value, o =
|
|
3411
|
+
const a = s.values().next().value, o = sa(r.preview.invoices.map((c) => c.remaining_amount_atom));
|
|
3398
3412
|
return {
|
|
3399
3413
|
currency: a,
|
|
3400
3414
|
amountAtom: o
|
|
3401
3415
|
};
|
|
3402
|
-
},
|
|
3403
|
-
const
|
|
3404
|
-
if (
|
|
3416
|
+
}, ua = async (t, e) => {
|
|
3417
|
+
const r = await gn(t, 1e3, "usd"), s = await r.canMakePayment();
|
|
3418
|
+
if (r.abort(), !s)
|
|
3405
3419
|
throw new Error(`Cannot make payment with ${e} for this session`);
|
|
3406
|
-
return s[
|
|
3407
|
-
},
|
|
3420
|
+
return s[ia[e]];
|
|
3421
|
+
}, la = (t, e, n) => !!dt(
|
|
3422
|
+
T.enum.START_PAYMENT_FLOW,
|
|
3423
|
+
// This is ok since we're just calling this function to use the validation function inside it
|
|
3424
|
+
"dummy",
|
|
3425
|
+
t,
|
|
3426
|
+
e ?? (() => {
|
|
3427
|
+
}),
|
|
3428
|
+
n,
|
|
3429
|
+
!1
|
|
3430
|
+
), fa = async (t, e, n, r, s, a, o, c, u) => {
|
|
3408
3431
|
try {
|
|
3409
|
-
const
|
|
3410
|
-
if (o
|
|
3411
|
-
E.enum.START_PAYMENT_FLOW,
|
|
3412
|
-
// This is ok since we're just calling this function to use the validation function inside it
|
|
3413
|
-
"dummy",
|
|
3414
|
-
r,
|
|
3415
|
-
o,
|
|
3416
|
-
n,
|
|
3417
|
-
!1
|
|
3418
|
-
))
|
|
3432
|
+
const d = yn(n, {});
|
|
3433
|
+
if (!la(n, o, r))
|
|
3419
3434
|
return;
|
|
3420
|
-
const
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3435
|
+
const b = (await Tn(t)).mode === "setup";
|
|
3436
|
+
let w;
|
|
3437
|
+
if (b)
|
|
3438
|
+
w = (u == null ? void 0 : u.amountToDisplayForSetupMode) ?? { amountAtom: 0, currency: "usd" };
|
|
3439
|
+
else {
|
|
3440
|
+
u != null && u.amountToDisplayForSetupMode;
|
|
3441
|
+
const E = V.safeParse(d[rt.PROMOTION_CODE]);
|
|
3442
|
+
if (!E.success)
|
|
3443
|
+
throw new Error(`Unknown promo code type: ${E.error.message}`);
|
|
3444
|
+
const N = await da(t, e, E.data);
|
|
3445
|
+
w = { amountAtom: N.amountAtom, currency: N.currency };
|
|
3446
|
+
}
|
|
3447
|
+
const k = await gn(
|
|
3448
|
+
s,
|
|
3449
|
+
w.amountAtom,
|
|
3450
|
+
w.currency,
|
|
3451
|
+
b
|
|
3452
|
+
);
|
|
3453
|
+
await k.canMakePayment(), k.show();
|
|
3454
|
+
const j = await ks(k);
|
|
3455
|
+
a(j, r);
|
|
3456
|
+
} catch (d) {
|
|
3457
|
+
c(bn(d));
|
|
3429
3458
|
}
|
|
3430
3459
|
};
|
|
3431
|
-
var
|
|
3460
|
+
var re;
|
|
3432
3461
|
(function(t) {
|
|
3433
3462
|
t.Call = "call", t.Reply = "reply", t.Syn = "syn", t.SynAck = "synAck", t.Ack = "ack";
|
|
3434
|
-
})(
|
|
3435
|
-
var
|
|
3463
|
+
})(re || (re = {}));
|
|
3464
|
+
var Te;
|
|
3436
3465
|
(function(t) {
|
|
3437
3466
|
t.Fulfilled = "fulfilled", t.Rejected = "rejected";
|
|
3438
|
-
})(
|
|
3439
|
-
var
|
|
3467
|
+
})(Te || (Te = {}));
|
|
3468
|
+
var st;
|
|
3440
3469
|
(function(t) {
|
|
3441
3470
|
t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
|
|
3442
|
-
})(
|
|
3443
|
-
var
|
|
3471
|
+
})(st || (st = {}));
|
|
3472
|
+
var Pt;
|
|
3444
3473
|
(function(t) {
|
|
3445
3474
|
t.DataCloneError = "DataCloneError";
|
|
3446
|
-
})(
|
|
3447
|
-
var
|
|
3475
|
+
})(Pt || (Pt = {}));
|
|
3476
|
+
var we;
|
|
3448
3477
|
(function(t) {
|
|
3449
3478
|
t.Message = "message";
|
|
3450
|
-
})(
|
|
3451
|
-
const
|
|
3452
|
-
const
|
|
3453
|
-
let
|
|
3479
|
+
})(we || (we = {}));
|
|
3480
|
+
const ma = (t, e) => {
|
|
3481
|
+
const n = [];
|
|
3482
|
+
let r = !1;
|
|
3454
3483
|
return {
|
|
3455
3484
|
destroy(s) {
|
|
3456
|
-
|
|
3485
|
+
r || (r = !0, e(`${t}: Destroying connection`), n.forEach((a) => {
|
|
3457
3486
|
a(s);
|
|
3458
3487
|
}));
|
|
3459
3488
|
},
|
|
3460
3489
|
onDestroy(s) {
|
|
3461
|
-
|
|
3490
|
+
r ? s() : n.push(s);
|
|
3462
3491
|
}
|
|
3463
3492
|
};
|
|
3464
|
-
},
|
|
3465
|
-
},
|
|
3493
|
+
}, ha = (t) => (...e) => {
|
|
3494
|
+
}, pa = {
|
|
3466
3495
|
"http:": "80",
|
|
3467
3496
|
"https:": "443"
|
|
3468
|
-
},
|
|
3469
|
-
if (t &&
|
|
3497
|
+
}, ya = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, ga = ["file:", "data:"], _a = (t) => {
|
|
3498
|
+
if (t && ga.find((c) => t.startsWith(c)))
|
|
3470
3499
|
return "null";
|
|
3471
|
-
const e = document.location,
|
|
3472
|
-
let
|
|
3473
|
-
|
|
3474
|
-
const o = a && a !==
|
|
3475
|
-
return `${
|
|
3476
|
-
},
|
|
3500
|
+
const e = document.location, n = ya.exec(t);
|
|
3501
|
+
let r, s, a;
|
|
3502
|
+
n ? (r = n[1] ? n[1] : e.protocol, s = n[2], a = n[4]) : (r = e.protocol, s = e.hostname, a = e.port);
|
|
3503
|
+
const o = a && a !== pa[r] ? `:${a}` : "";
|
|
3504
|
+
return `${r}//${s}${o}`;
|
|
3505
|
+
}, Jt = ({ name: t, message: e, stack: n }) => ({
|
|
3477
3506
|
name: t,
|
|
3478
3507
|
message: e,
|
|
3479
|
-
stack:
|
|
3480
|
-
}),
|
|
3508
|
+
stack: n
|
|
3509
|
+
}), va = (t) => {
|
|
3481
3510
|
const e = new Error();
|
|
3482
|
-
return Object.keys(t).forEach((
|
|
3483
|
-
},
|
|
3484
|
-
const { localName:
|
|
3511
|
+
return Object.keys(t).forEach((n) => e[n] = t[n]), e;
|
|
3512
|
+
}, ba = (t, e, n) => {
|
|
3513
|
+
const { localName: r, local: s, remote: a, originForSending: o, originForReceiving: c } = t;
|
|
3485
3514
|
let u = !1;
|
|
3486
3515
|
const d = (f) => {
|
|
3487
|
-
if (f.source !== a || f.data.penpal !==
|
|
3516
|
+
if (f.source !== a || f.data.penpal !== re.Call)
|
|
3488
3517
|
return;
|
|
3489
3518
|
if (c !== "*" && f.origin !== c) {
|
|
3490
|
-
|
|
3519
|
+
n(`${r} received message from origin ${f.origin} which did not match expected origin ${c}`);
|
|
3491
3520
|
return;
|
|
3492
3521
|
}
|
|
3493
3522
|
const b = f.data, { methodName: w, args: k, id: j } = b;
|
|
3494
|
-
|
|
3495
|
-
const
|
|
3496
|
-
if (
|
|
3497
|
-
|
|
3523
|
+
n(`${r}: Received ${w}() call`);
|
|
3524
|
+
const E = (N) => (ie) => {
|
|
3525
|
+
if (n(`${r}: Sending ${w}() reply`), u) {
|
|
3526
|
+
n(`${r}: Unable to send ${w}() reply due to destroyed connection`);
|
|
3498
3527
|
return;
|
|
3499
3528
|
}
|
|
3500
|
-
const
|
|
3501
|
-
penpal:
|
|
3529
|
+
const B = {
|
|
3530
|
+
penpal: re.Reply,
|
|
3502
3531
|
id: j,
|
|
3503
|
-
resolution:
|
|
3504
|
-
returnValue:
|
|
3532
|
+
resolution: N,
|
|
3533
|
+
returnValue: ie
|
|
3505
3534
|
};
|
|
3506
|
-
|
|
3535
|
+
N === Te.Rejected && ie instanceof Error && (B.returnValue = Jt(ie), B.returnValueIsError = !0);
|
|
3507
3536
|
try {
|
|
3508
|
-
a.postMessage(
|
|
3509
|
-
} catch (
|
|
3510
|
-
if (
|
|
3511
|
-
const
|
|
3512
|
-
penpal:
|
|
3537
|
+
a.postMessage(B, o);
|
|
3538
|
+
} catch (I) {
|
|
3539
|
+
if (I.name === Pt.DataCloneError) {
|
|
3540
|
+
const le = {
|
|
3541
|
+
penpal: re.Reply,
|
|
3513
3542
|
id: j,
|
|
3514
|
-
resolution:
|
|
3515
|
-
returnValue:
|
|
3543
|
+
resolution: Te.Rejected,
|
|
3544
|
+
returnValue: Jt(I),
|
|
3516
3545
|
returnValueIsError: !0
|
|
3517
3546
|
};
|
|
3518
|
-
a.postMessage(
|
|
3547
|
+
a.postMessage(le, o);
|
|
3519
3548
|
}
|
|
3520
|
-
throw
|
|
3549
|
+
throw I;
|
|
3521
3550
|
}
|
|
3522
3551
|
};
|
|
3523
|
-
new Promise((
|
|
3552
|
+
new Promise((N) => N(e[w].apply(e, k))).then(E(Te.Fulfilled), E(Te.Rejected));
|
|
3524
3553
|
};
|
|
3525
|
-
return s.addEventListener(
|
|
3526
|
-
u = !0, s.removeEventListener(
|
|
3554
|
+
return s.addEventListener(we.Message, d), () => {
|
|
3555
|
+
u = !0, s.removeEventListener(we.Message, d);
|
|
3527
3556
|
};
|
|
3528
3557
|
};
|
|
3529
|
-
let
|
|
3530
|
-
const
|
|
3531
|
-
const
|
|
3532
|
-
return
|
|
3533
|
-
},
|
|
3534
|
-
const
|
|
3535
|
-
return
|
|
3536
|
-
},
|
|
3537
|
-
const
|
|
3538
|
-
return Object.keys(t).forEach((
|
|
3539
|
-
const s = t[
|
|
3540
|
-
typeof s == "object" && Object.assign(
|
|
3541
|
-
}),
|
|
3542
|
-
},
|
|
3558
|
+
let wa = 0;
|
|
3559
|
+
const xa = () => ++wa, Cn = ".", Sn = (t) => t ? t.split(Cn) : [], Ea = (t) => t.join(Cn), ka = (t, e) => {
|
|
3560
|
+
const n = Sn(e || "");
|
|
3561
|
+
return n.push(t), Ea(n);
|
|
3562
|
+
}, Ta = (t, e, n) => {
|
|
3563
|
+
const r = Sn(e);
|
|
3564
|
+
return r.reduce((s, a, o) => (typeof s[a] > "u" && (s[a] = {}), o === r.length - 1 && (s[a] = n), s[a]), t), t;
|
|
3565
|
+
}, Rn = (t, e) => {
|
|
3566
|
+
const n = {};
|
|
3567
|
+
return Object.keys(t).forEach((r) => {
|
|
3568
|
+
const s = t[r], a = ka(r, e);
|
|
3569
|
+
typeof s == "object" && Object.assign(n, Rn(s, a)), typeof s == "function" && (n[a] = s);
|
|
3570
|
+
}), n;
|
|
3571
|
+
}, Ca = (t) => {
|
|
3543
3572
|
const e = {};
|
|
3544
|
-
for (const
|
|
3545
|
-
|
|
3573
|
+
for (const n in t)
|
|
3574
|
+
Ta(e, n, t[n]);
|
|
3546
3575
|
return e;
|
|
3547
|
-
},
|
|
3576
|
+
}, Sa = (t, e, n, r, s) => {
|
|
3548
3577
|
const { localName: a, local: o, remote: c, originForSending: u, originForReceiving: d } = e;
|
|
3549
3578
|
let f = !1;
|
|
3550
3579
|
s(`${a}: Connecting call sender`);
|
|
3551
3580
|
const b = (k) => (...j) => {
|
|
3552
3581
|
s(`${a}: Sending ${k}() call`);
|
|
3553
|
-
let
|
|
3582
|
+
let E;
|
|
3554
3583
|
try {
|
|
3555
|
-
c.closed && (
|
|
3584
|
+
c.closed && (E = !0);
|
|
3556
3585
|
} catch {
|
|
3557
|
-
|
|
3586
|
+
E = !0;
|
|
3558
3587
|
}
|
|
3559
|
-
if (
|
|
3560
|
-
const
|
|
3561
|
-
throw
|
|
3588
|
+
if (E && r(), f) {
|
|
3589
|
+
const N = new Error(`Unable to send ${k}() call due to destroyed connection`);
|
|
3590
|
+
throw N.code = st.ConnectionDestroyed, N;
|
|
3562
3591
|
}
|
|
3563
|
-
return new Promise((
|
|
3564
|
-
const
|
|
3565
|
-
if (
|
|
3592
|
+
return new Promise((N, ie) => {
|
|
3593
|
+
const B = xa(), I = (fe) => {
|
|
3594
|
+
if (fe.source !== c || fe.data.penpal !== re.Reply || fe.data.id !== B)
|
|
3566
3595
|
return;
|
|
3567
|
-
if (d !== "*" &&
|
|
3568
|
-
s(`${a} received message from origin ${
|
|
3596
|
+
if (d !== "*" && fe.origin !== d) {
|
|
3597
|
+
s(`${a} received message from origin ${fe.origin} which did not match expected origin ${d}`);
|
|
3569
3598
|
return;
|
|
3570
3599
|
}
|
|
3571
|
-
const
|
|
3572
|
-
s(`${a}: Received ${k}() reply`), o.removeEventListener(
|
|
3573
|
-
let
|
|
3574
|
-
|
|
3600
|
+
const xe = fe.data;
|
|
3601
|
+
s(`${a}: Received ${k}() reply`), o.removeEventListener(we.Message, I);
|
|
3602
|
+
let je = xe.returnValue;
|
|
3603
|
+
xe.returnValueIsError && (je = va(je)), (xe.resolution === Te.Fulfilled ? N : ie)(je);
|
|
3575
3604
|
};
|
|
3576
|
-
o.addEventListener(
|
|
3577
|
-
const
|
|
3578
|
-
penpal:
|
|
3579
|
-
id:
|
|
3605
|
+
o.addEventListener(we.Message, I);
|
|
3606
|
+
const le = {
|
|
3607
|
+
penpal: re.Call,
|
|
3608
|
+
id: B,
|
|
3580
3609
|
methodName: k,
|
|
3581
3610
|
args: j
|
|
3582
3611
|
};
|
|
3583
|
-
c.postMessage(
|
|
3612
|
+
c.postMessage(le, u);
|
|
3584
3613
|
});
|
|
3585
|
-
}, w =
|
|
3586
|
-
return Object.assign(t,
|
|
3614
|
+
}, w = n.reduce((k, j) => (k[j] = b(j), k), {});
|
|
3615
|
+
return Object.assign(t, Ca(w)), () => {
|
|
3587
3616
|
f = !0;
|
|
3588
3617
|
};
|
|
3589
|
-
},
|
|
3590
|
-
const { destroy: a, onDestroy: o } =
|
|
3618
|
+
}, Ra = (t, e, n, r, s) => {
|
|
3619
|
+
const { destroy: a, onDestroy: o } = r;
|
|
3591
3620
|
let c, u;
|
|
3592
3621
|
const d = {};
|
|
3593
3622
|
return (f) => {
|
|
@@ -3600,119 +3629,119 @@ const pa = () => ++ha, wr = ".", xr = (t) => t ? t.split(wr) : [], ya = (t) => t
|
|
|
3600
3629
|
localName: "Parent",
|
|
3601
3630
|
local: window,
|
|
3602
3631
|
remote: f.source,
|
|
3603
|
-
originForSending:
|
|
3632
|
+
originForSending: n,
|
|
3604
3633
|
originForReceiving: e
|
|
3605
3634
|
};
|
|
3606
|
-
c && c(), c =
|
|
3635
|
+
c && c(), c = ba(b, t, s), o(c), u && u.forEach((k) => {
|
|
3607
3636
|
delete d[k];
|
|
3608
3637
|
}), u = f.data.methodNames;
|
|
3609
|
-
const w =
|
|
3638
|
+
const w = Sa(d, b, u, a, s);
|
|
3610
3639
|
return o(w), d;
|
|
3611
3640
|
};
|
|
3612
|
-
},
|
|
3641
|
+
}, Oa = (t, e, n, r) => (s) => {
|
|
3613
3642
|
if (!s.source)
|
|
3614
3643
|
return;
|
|
3615
|
-
if (
|
|
3616
|
-
t(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${
|
|
3644
|
+
if (n !== "*" && s.origin !== n) {
|
|
3645
|
+
t(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${n}`);
|
|
3617
3646
|
return;
|
|
3618
3647
|
}
|
|
3619
3648
|
t("Parent: Handshake - Received SYN, responding with SYN-ACK");
|
|
3620
3649
|
const a = {
|
|
3621
|
-
penpal:
|
|
3650
|
+
penpal: re.SynAck,
|
|
3622
3651
|
methodNames: Object.keys(e)
|
|
3623
3652
|
};
|
|
3624
|
-
s.source.postMessage(a,
|
|
3625
|
-
},
|
|
3626
|
-
const { destroy:
|
|
3627
|
-
t.isConnected || (clearInterval(s),
|
|
3628
|
-
},
|
|
3629
|
-
|
|
3653
|
+
s.source.postMessage(a, r);
|
|
3654
|
+
}, Ia = 6e4, Pa = (t, e) => {
|
|
3655
|
+
const { destroy: n, onDestroy: r } = e, s = setInterval(() => {
|
|
3656
|
+
t.isConnected || (clearInterval(s), n());
|
|
3657
|
+
}, Ia);
|
|
3658
|
+
r(() => {
|
|
3630
3659
|
clearInterval(s);
|
|
3631
3660
|
});
|
|
3632
|
-
},
|
|
3633
|
-
let
|
|
3634
|
-
return t !== void 0 && (
|
|
3635
|
-
const
|
|
3636
|
-
|
|
3661
|
+
}, Aa = (t, e) => {
|
|
3662
|
+
let n;
|
|
3663
|
+
return t !== void 0 && (n = window.setTimeout(() => {
|
|
3664
|
+
const r = new Error(`Connection timed out after ${t}ms`);
|
|
3665
|
+
r.code = st.ConnectionTimeout, e(r);
|
|
3637
3666
|
}, t)), () => {
|
|
3638
|
-
clearTimeout(
|
|
3667
|
+
clearTimeout(n);
|
|
3639
3668
|
};
|
|
3640
|
-
},
|
|
3669
|
+
}, Na = (t) => {
|
|
3641
3670
|
if (!t.src && !t.srcdoc) {
|
|
3642
3671
|
const e = new Error("Iframe must have src or srcdoc property defined.");
|
|
3643
|
-
throw e.code =
|
|
3672
|
+
throw e.code = st.NoIframeSrc, e;
|
|
3644
3673
|
}
|
|
3645
|
-
},
|
|
3646
|
-
let { iframe: e, methods:
|
|
3647
|
-
const o =
|
|
3648
|
-
|
|
3649
|
-
const f =
|
|
3674
|
+
}, Ma = (t) => {
|
|
3675
|
+
let { iframe: e, methods: n = {}, childOrigin: r, timeout: s, debug: a = !1 } = t;
|
|
3676
|
+
const o = ha(a), c = ma("Parent", o), { onDestroy: u, destroy: d } = c;
|
|
3677
|
+
r || (Na(e), r = _a(e.src));
|
|
3678
|
+
const f = r === "null" ? "*" : r, b = Rn(n), w = Oa(o, b, r, f), k = Ra(b, r, f, c, o);
|
|
3650
3679
|
return {
|
|
3651
|
-
promise: new Promise((
|
|
3652
|
-
const
|
|
3653
|
-
if (!(
|
|
3654
|
-
if (
|
|
3655
|
-
w(
|
|
3680
|
+
promise: new Promise((E, N) => {
|
|
3681
|
+
const ie = Aa(s, d), B = (I) => {
|
|
3682
|
+
if (!(I.source !== e.contentWindow || !I.data)) {
|
|
3683
|
+
if (I.data.penpal === re.Syn) {
|
|
3684
|
+
w(I);
|
|
3656
3685
|
return;
|
|
3657
3686
|
}
|
|
3658
|
-
if (
|
|
3659
|
-
const
|
|
3660
|
-
|
|
3687
|
+
if (I.data.penpal === re.Ack) {
|
|
3688
|
+
const le = k(I);
|
|
3689
|
+
le && (ie(), E(le));
|
|
3661
3690
|
return;
|
|
3662
3691
|
}
|
|
3663
3692
|
}
|
|
3664
3693
|
};
|
|
3665
|
-
window.addEventListener(
|
|
3666
|
-
window.removeEventListener(
|
|
3694
|
+
window.addEventListener(we.Message, B), o("Parent: Awaiting handshake"), Pa(e, c), u((I) => {
|
|
3695
|
+
window.removeEventListener(we.Message, B), I && N(I);
|
|
3667
3696
|
});
|
|
3668
3697
|
}),
|
|
3669
3698
|
destroy() {
|
|
3670
3699
|
d();
|
|
3671
3700
|
}
|
|
3672
3701
|
};
|
|
3673
|
-
},
|
|
3674
|
-
const [t, e] = A({ status: "none" }),
|
|
3702
|
+
}, ja = () => {
|
|
3703
|
+
const [t, e] = A({ status: "none" }), n = async (r) => {
|
|
3675
3704
|
if (t.status !== "none")
|
|
3676
3705
|
return;
|
|
3677
3706
|
e({ status: "connecting" });
|
|
3678
|
-
const s =
|
|
3679
|
-
iframe:
|
|
3707
|
+
const s = Ma({
|
|
3708
|
+
iframe: r,
|
|
3680
3709
|
debug: !0
|
|
3681
3710
|
});
|
|
3682
3711
|
e({ status: "waiting", conn: s });
|
|
3683
3712
|
};
|
|
3684
|
-
return
|
|
3713
|
+
return vn(async () => {
|
|
3685
3714
|
if (t.status !== "waiting") return;
|
|
3686
|
-
const
|
|
3687
|
-
if (!
|
|
3715
|
+
const r = await t.conn.promise, s = await Za(r);
|
|
3716
|
+
if (!Da(r, s))
|
|
3688
3717
|
throw new Error("Got invalid CDE connection object");
|
|
3689
|
-
e({ status: "connected", conn:
|
|
3718
|
+
e({ status: "connected", conn: r });
|
|
3690
3719
|
}, [t.status]), {
|
|
3691
3720
|
cdeConn: t.status === "connected" ? t.conn : null,
|
|
3692
|
-
connectToCdeIframe:
|
|
3721
|
+
connectToCdeIframe: n
|
|
3693
3722
|
};
|
|
3694
|
-
},
|
|
3723
|
+
}, Za = async (t) => {
|
|
3695
3724
|
if (typeof t != "object" || !t) return !1;
|
|
3696
3725
|
try {
|
|
3697
|
-
const e = { type: "ping" },
|
|
3698
|
-
if (
|
|
3699
|
-
throw new Error(`Expected 'true' after ping, got ${JSON.stringify(
|
|
3726
|
+
const e = { type: "ping" }, n = await t.send(e);
|
|
3727
|
+
if (n !== !0)
|
|
3728
|
+
throw new Error(`Expected 'true' after ping, got ${JSON.stringify(n)}`);
|
|
3700
3729
|
return !0;
|
|
3701
3730
|
} catch {
|
|
3702
3731
|
return !1;
|
|
3703
3732
|
}
|
|
3704
|
-
},
|
|
3733
|
+
}, Da = (t, e) => !!t && e, $a = (t) => {
|
|
3705
3734
|
if (typeof t != "string") return !1;
|
|
3706
3735
|
try {
|
|
3707
3736
|
return JSON.parse(t), !0;
|
|
3708
3737
|
} catch {
|
|
3709
3738
|
return !1;
|
|
3710
3739
|
}
|
|
3711
|
-
},
|
|
3740
|
+
}, Fa = (t) => {
|
|
3712
3741
|
const {
|
|
3713
3742
|
children: e,
|
|
3714
|
-
checkoutSecureToken:
|
|
3715
|
-
className:
|
|
3743
|
+
checkoutSecureToken: n,
|
|
3744
|
+
className: r,
|
|
3716
3745
|
onFocus: s,
|
|
3717
3746
|
onBlur: a,
|
|
3718
3747
|
onChange: o,
|
|
@@ -3724,107 +3753,126 @@ const pa = () => ++ha, wr = ".", xr = (t) => t ? t.split(wr) : [], ya = (t) => t
|
|
|
3724
3753
|
onCheckoutError: w,
|
|
3725
3754
|
onSetupPaymentMethodSuccess: k,
|
|
3726
3755
|
baseUrl: j
|
|
3727
|
-
} = t,
|
|
3728
|
-
(
|
|
3729
|
-
if (
|
|
3730
|
-
const
|
|
3731
|
-
if (
|
|
3756
|
+
} = t, E = j ?? ws, [N, ie] = A(void 0), [B, I] = A([]), [le, fe] = A("1px"), [xe, je] = A(!1), [G, Ze] = A(void 0), [Zt, Ee] = A(!1), [me, On] = A([]), [he, In] = A({}), [Dt, it] = A(0), [$t, X] = A(!1), [Q, Pn] = A(void 0), [Lt, An] = A(void 0), [Ut, Nn] = A(void 0), [oe, Mn] = A(void 0), [bt, jn] = A(void 0), ce = Fe(() => `opjs-form-${Qt()}`, []), ee = Gt(null), { cdeConn: De, connectToCdeIframe: Vt } = ja(), wt = Le(
|
|
3757
|
+
(R) => {
|
|
3758
|
+
if (R.origin !== E || !R.source) return;
|
|
3759
|
+
const H = R.source;
|
|
3760
|
+
if (!$a(R.data))
|
|
3732
3761
|
return;
|
|
3733
|
-
const q = JSON.parse(
|
|
3734
|
-
if (L.formId !==
|
|
3762
|
+
const q = JSON.parse(R.data), L = bs(q), ke = L.elementId;
|
|
3763
|
+
if (L.formId !== ce || !ke || L.nonce in B)
|
|
3735
3764
|
return;
|
|
3736
|
-
|
|
3765
|
+
I((D) => [...D, L.nonce]);
|
|
3737
3766
|
const S = L.payload, U = S.type;
|
|
3738
|
-
if (U ===
|
|
3739
|
-
const
|
|
3740
|
-
|
|
3741
|
-
} else if (U ===
|
|
3767
|
+
if (U === T.enum.LAYOUT) {
|
|
3768
|
+
const D = S.height ? `${S.height}px` : "100%";
|
|
3769
|
+
fe(D);
|
|
3770
|
+
} else if (U === T.enum.FOCUS && s)
|
|
3742
3771
|
s(L.elementId);
|
|
3743
|
-
else if (U ===
|
|
3772
|
+
else if (U === T.enum.BLUR && a)
|
|
3744
3773
|
a(L.elementId);
|
|
3745
|
-
else if (U ===
|
|
3774
|
+
else if (U === T.enum.CHANGE && o)
|
|
3746
3775
|
o(L.elementId);
|
|
3747
|
-
else if (U ===
|
|
3748
|
-
const
|
|
3749
|
-
if (
|
|
3776
|
+
else if (U === T.enum.LOADED) {
|
|
3777
|
+
const D = me.find((P) => P.contentWindow === H);
|
|
3778
|
+
if (Ee(!1), !D)
|
|
3750
3779
|
return;
|
|
3751
|
-
|
|
3752
|
-
} else if (U ===
|
|
3753
|
-
|
|
3754
|
-
else if (U ===
|
|
3755
|
-
if (!
|
|
3780
|
+
In((P) => ({ ...P, [ke]: H })), Nn(S.totalAmountAtoms), An(S.currency), Mn(S.checkoutPaymentMethods), Q || Pn(S.sessionId);
|
|
3781
|
+
} else if (U === T.enum.TOKENIZE_STARTED)
|
|
3782
|
+
Ee(!0), f && f();
|
|
3783
|
+
else if (U === T.enum.PAYMENT_FLOW_STARTED) {
|
|
3784
|
+
if (!G)
|
|
3756
3785
|
throw new Error("extraData not populated");
|
|
3786
|
+
if (!De)
|
|
3787
|
+
throw new Error("Not connected to CDE");
|
|
3757
3788
|
(async () => {
|
|
3758
|
-
const
|
|
3759
|
-
if (
|
|
3760
|
-
await
|
|
3761
|
-
else if (
|
|
3762
|
-
if (!
|
|
3789
|
+
const P = S.nextActionMetadata.type;
|
|
3790
|
+
if (P !== void 0) if (P === "stripe_3ds")
|
|
3791
|
+
await Ss(S);
|
|
3792
|
+
else if (P === "stripe_payment_request") {
|
|
3793
|
+
if (!bt)
|
|
3763
3794
|
throw new Error("Stripe PM not set");
|
|
3764
|
-
await
|
|
3795
|
+
await Cs(S, bt);
|
|
3765
3796
|
} else
|
|
3766
|
-
throw new Error(`Unknown next action type: ${
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3797
|
+
throw new Error(`Unknown next action type: ${P}`);
|
|
3798
|
+
const W = await Tn(De);
|
|
3799
|
+
if (W.mode === "setup") {
|
|
3800
|
+
const { payment_methods: te } = await ra(De, {
|
|
3801
|
+
secure_token: W.token,
|
|
3802
|
+
existing_cc_pm_id: G.existingCCPMId
|
|
3803
|
+
});
|
|
3804
|
+
if (te.length !== 1)
|
|
3805
|
+
throw new Error(`Expected exactly one payment method, got ${te.length}`);
|
|
3806
|
+
return Ee(!1), it(0), X(!1), k && k(te[0].id), {
|
|
3807
|
+
proceedToCheckout: !1
|
|
3808
|
+
};
|
|
3809
|
+
} else
|
|
3810
|
+
return {
|
|
3811
|
+
proceedToCheckout: !0
|
|
3812
|
+
};
|
|
3813
|
+
})().then(({ proceedToCheckout: P }) => {
|
|
3814
|
+
var te;
|
|
3815
|
+
if (!P)
|
|
3816
|
+
return;
|
|
3817
|
+
let W;
|
|
3818
|
+
if (G.checkoutPaymentMethod.provider === "credit_card" && (W = (te = S.startPFMetadata) == null ? void 0 : te.cc_pm_id, !W))
|
|
3771
3819
|
throw new Error("CC PM ID not found");
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
{ ...
|
|
3777
|
-
|
|
3778
|
-
),
|
|
3779
|
-
}).catch((
|
|
3780
|
-
const
|
|
3781
|
-
|
|
3820
|
+
$e(
|
|
3821
|
+
H,
|
|
3822
|
+
ce,
|
|
3823
|
+
ke,
|
|
3824
|
+
{ ...G, type: "CHECKOUT", doNotUseLegacyCCFlow: !0, existingCCPMId: W },
|
|
3825
|
+
E
|
|
3826
|
+
), X(!0), Ze(void 0), f && f();
|
|
3827
|
+
}).catch((P) => {
|
|
3828
|
+
const W = bn(P);
|
|
3829
|
+
Ee(!1), X(!1), w && w(W);
|
|
3782
3830
|
});
|
|
3783
|
-
} else if (U ===
|
|
3784
|
-
const
|
|
3785
|
-
|
|
3786
|
-
} else if (U ===
|
|
3787
|
-
|
|
3788
|
-
else if (U ===
|
|
3789
|
-
|
|
3790
|
-
else if (U ===
|
|
3831
|
+
} else if (U === T.enum.TOKENIZE_SUCCESS && G) {
|
|
3832
|
+
const D = Dt + 1, P = D === Object.keys(he).length;
|
|
3833
|
+
!$t && (P || S.isReadyForCheckout) ? ($e(H, ce, ke, G, E), X(!0), Ze(void 0)) : it(D);
|
|
3834
|
+
} else if (U === T.enum.CHECKOUT_SUCCESS)
|
|
3835
|
+
Ee(!1), it(0), X(!1), b && b(S.invoiceUrls, S.subscriptionIds, S.customerId);
|
|
3836
|
+
else if (U === T.enum.SETUP_PAYMENT_METHOD_SUCCESS)
|
|
3837
|
+
Ee(!1), it(0), X(!1), k && k(S.paymentMethodId);
|
|
3838
|
+
else if (U === T.enum.LOAD_ERROR)
|
|
3791
3839
|
u && u(S.message);
|
|
3792
|
-
else if (U ===
|
|
3793
|
-
const
|
|
3794
|
-
(
|
|
3795
|
-
} else if (U ===
|
|
3840
|
+
else if (U === T.enum.VALIDATION_ERROR) {
|
|
3841
|
+
const D = G == null ? void 0 : G.checkoutPaymentMethod.provider;
|
|
3842
|
+
(D === "credit_card" || D === void 0) && d && d(S.elementType, S.errors, ke);
|
|
3843
|
+
} else if (U === T.enum.TOKENIZE_ERROR || U === T.enum.CHECKOUT_ERROR)
|
|
3796
3844
|
if (S.message === "3DS_REQUIRED") {
|
|
3797
|
-
const
|
|
3798
|
-
if (!
|
|
3799
|
-
for (const [
|
|
3800
|
-
if (!
|
|
3801
|
-
const
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3845
|
+
const D = oe == null ? void 0 : oe.find((P) => P.provider === "credit_card");
|
|
3846
|
+
if (!Q || !ee.current || !d || !D) return;
|
|
3847
|
+
for (const [P, W] of Object.entries(he)) {
|
|
3848
|
+
if (!W) continue;
|
|
3849
|
+
const te = dt(
|
|
3850
|
+
T.enum.START_PAYMENT_FLOW,
|
|
3851
|
+
Q,
|
|
3852
|
+
ee.current,
|
|
3805
3853
|
d,
|
|
3806
3854
|
// Only stripe supports frontend 3DS right now,
|
|
3807
3855
|
// so we pass processor_name: 'stripe' to tell delegator to only use stripe
|
|
3808
|
-
{ ...
|
|
3856
|
+
{ ...D, processor_name: "stripe" },
|
|
3809
3857
|
!1
|
|
3810
3858
|
);
|
|
3811
|
-
if (
|
|
3812
|
-
|
|
3859
|
+
if (te) {
|
|
3860
|
+
X(!0), Ze(te), $e(W, ce, P, te, E);
|
|
3813
3861
|
break;
|
|
3814
3862
|
}
|
|
3815
3863
|
}
|
|
3816
3864
|
} else
|
|
3817
|
-
|
|
3865
|
+
Ee(!1), X(!1), w && w(S.message);
|
|
3818
3866
|
},
|
|
3819
3867
|
[
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3868
|
+
ce,
|
|
3869
|
+
Q,
|
|
3870
|
+
B,
|
|
3871
|
+
G,
|
|
3872
|
+
me,
|
|
3873
|
+
he,
|
|
3874
|
+
Dt,
|
|
3875
|
+
$t,
|
|
3828
3876
|
a,
|
|
3829
3877
|
o,
|
|
3830
3878
|
s,
|
|
@@ -3834,102 +3882,103 @@ const pa = () => ++ha, wr = ".", xr = (t) => t ? t.split(wr) : [], ya = (t) => t
|
|
|
3834
3882
|
k,
|
|
3835
3883
|
w,
|
|
3836
3884
|
d,
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3885
|
+
E,
|
|
3886
|
+
bt,
|
|
3887
|
+
oe,
|
|
3888
|
+
De
|
|
3840
3889
|
]
|
|
3841
|
-
),
|
|
3842
|
-
if (!
|
|
3843
|
-
const
|
|
3844
|
-
if (!
|
|
3890
|
+
), Zn = Le(() => {
|
|
3891
|
+
if (!ee.current || !d || !Q || !oe) return;
|
|
3892
|
+
const R = oe.find((q) => q.provider === "credit_card");
|
|
3893
|
+
if (!R)
|
|
3845
3894
|
throw new Error("Card not available as a payment method in checkout");
|
|
3846
|
-
const
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3895
|
+
const H = dt(
|
|
3896
|
+
T.enum.TOKENIZE,
|
|
3897
|
+
Q,
|
|
3898
|
+
ee.current,
|
|
3850
3899
|
d,
|
|
3851
|
-
|
|
3900
|
+
R,
|
|
3852
3901
|
!1
|
|
3853
3902
|
);
|
|
3854
|
-
if (
|
|
3855
|
-
for (const [q, L] of Object.entries(
|
|
3856
|
-
L &&
|
|
3857
|
-
|
|
3903
|
+
if (H) {
|
|
3904
|
+
for (const [q, L] of Object.entries(he))
|
|
3905
|
+
L && $e(L, ce, q, H, E);
|
|
3906
|
+
H.type = T.enum.CHECKOUT, Ze(H);
|
|
3858
3907
|
}
|
|
3859
|
-
}, [
|
|
3860
|
-
(
|
|
3861
|
-
|
|
3908
|
+
}, [ee, he, ce, d, Q, E, oe]), xt = Le(
|
|
3909
|
+
(R) => {
|
|
3910
|
+
Zt && R.preventDefault();
|
|
3862
3911
|
},
|
|
3863
|
-
[
|
|
3912
|
+
[Zt]
|
|
3864
3913
|
);
|
|
3865
|
-
|
|
3866
|
-
if (
|
|
3867
|
-
|
|
3868
|
-
}, [
|
|
3869
|
-
window.removeEventListener("beforeunload",
|
|
3870
|
-
}), [
|
|
3871
|
-
const
|
|
3872
|
-
(
|
|
3873
|
-
|
|
3914
|
+
ut(() => {
|
|
3915
|
+
if (xe || !ee.current) return;
|
|
3916
|
+
me.length > 0 && me.length === Object.keys(he).length && (je(!0), c && c(Ut, Lt));
|
|
3917
|
+
}, [me, he, xe, c, Ut, Lt]), ut(() => (ie(window.location.origin), window.addEventListener("message", wt), window.addEventListener("beforeunload", xt), () => {
|
|
3918
|
+
window.removeEventListener("beforeunload", xt), window.removeEventListener("message", wt);
|
|
3919
|
+
}), [Q, wt, xt]);
|
|
3920
|
+
const Dn = Le(
|
|
3921
|
+
(R) => {
|
|
3922
|
+
me.find((q) => q.contentWindow === R.contentWindow) || (me.length === 0 && Vt(R), On((q) => [...q, R]));
|
|
3874
3923
|
},
|
|
3875
|
-
[
|
|
3876
|
-
),
|
|
3877
|
-
if (!(!
|
|
3878
|
-
for (const [q, L] of Object.entries(
|
|
3924
|
+
[me, Vt]
|
|
3925
|
+
), $n = async (R, H) => {
|
|
3926
|
+
if (!(!ee.current || !d || !Q || !oe))
|
|
3927
|
+
for (const [q, L] of Object.entries(he)) {
|
|
3879
3928
|
if (!L) continue;
|
|
3880
|
-
const
|
|
3881
|
-
stripePmId:
|
|
3882
|
-
},
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3929
|
+
const ke = {
|
|
3930
|
+
stripePmId: R.paymentMethod.id
|
|
3931
|
+
}, ot = dt(
|
|
3932
|
+
T.enum.START_PAYMENT_FLOW,
|
|
3933
|
+
Q,
|
|
3934
|
+
ee.current,
|
|
3886
3935
|
d,
|
|
3887
|
-
|
|
3936
|
+
H,
|
|
3888
3937
|
!1,
|
|
3889
|
-
|
|
3938
|
+
ke
|
|
3890
3939
|
);
|
|
3891
|
-
if (
|
|
3892
|
-
|
|
3940
|
+
if (ot) {
|
|
3941
|
+
jn(R), X(!0), Ze(ot), $e(L, ce, q, ot, E);
|
|
3893
3942
|
break;
|
|
3894
3943
|
}
|
|
3895
3944
|
}
|
|
3896
|
-
},
|
|
3897
|
-
|
|
3898
|
-
},
|
|
3899
|
-
formId:
|
|
3900
|
-
formHeight:
|
|
3901
|
-
referer:
|
|
3902
|
-
checkoutSecureToken:
|
|
3903
|
-
registerIframe:
|
|
3904
|
-
baseUrl:
|
|
3905
|
-
},
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3945
|
+
}, Ln = (R) => {
|
|
3946
|
+
X(!1), w && w(R);
|
|
3947
|
+
}, Un = {
|
|
3948
|
+
formId: ce,
|
|
3949
|
+
formHeight: le,
|
|
3950
|
+
referer: N,
|
|
3951
|
+
checkoutSecureToken: n,
|
|
3952
|
+
registerIframe: Dn,
|
|
3953
|
+
baseUrl: E
|
|
3954
|
+
}, Ft = ca(
|
|
3955
|
+
De,
|
|
3956
|
+
n,
|
|
3957
|
+
oe,
|
|
3958
|
+
ee.current,
|
|
3959
|
+
$n,
|
|
3911
3960
|
d,
|
|
3912
|
-
|
|
3913
|
-
),
|
|
3914
|
-
submit:
|
|
3915
|
-
applePay:
|
|
3916
|
-
googlePay:
|
|
3917
|
-
loaded:
|
|
3961
|
+
Ln
|
|
3962
|
+
), Vn = {
|
|
3963
|
+
submit: Zn,
|
|
3964
|
+
applePay: Ft.apple_pay,
|
|
3965
|
+
googlePay: Ft.google_pay,
|
|
3966
|
+
loaded: xe
|
|
3918
3967
|
};
|
|
3919
|
-
return /* @__PURE__ */
|
|
3920
|
-
},
|
|
3921
|
-
const { subPath: e, styles:
|
|
3968
|
+
return /* @__PURE__ */ ye(Xt.Provider, { value: Un, children: /* @__PURE__ */ ye("div", { className: r, ref: ee, children: e(Vn) }) });
|
|
3969
|
+
}, La = (t) => JSON.stringify(t), vt = (t) => {
|
|
3970
|
+
const { subPath: e, styles: n } = t, { formId: r, referer: s, formHeight: a, checkoutSecureToken: o, registerIframe: c, baseUrl: u } = Hn(), [d, f] = A(!1), b = Gt(null), w = Fe(() => n ? La(n) : "", [n]), k = Fe(() => ({
|
|
3922
3971
|
border: "none",
|
|
3923
3972
|
width: "100%",
|
|
3924
3973
|
height: a
|
|
3925
|
-
}), [a]), j =
|
|
3974
|
+
}), [a]), j = Fe(() => {
|
|
3926
3975
|
if (!o || !s) return "";
|
|
3927
|
-
const
|
|
3928
|
-
return
|
|
3929
|
-
}, [w,
|
|
3930
|
-
return
|
|
3976
|
+
const E = new URLSearchParams();
|
|
3977
|
+
return E.append("referer", s), E.append("styles", w), E.append("formId", r), E.append("secureToken", o), E.toString();
|
|
3978
|
+
}, [w, r, s, o]);
|
|
3979
|
+
return ut(() => f(!0), []), ut(() => {
|
|
3931
3980
|
!b.current || !d || c(b.current);
|
|
3932
|
-
}, [d]), o ? /* @__PURE__ */
|
|
3981
|
+
}, [d]), o ? /* @__PURE__ */ ye(
|
|
3933
3982
|
"iframe",
|
|
3934
3983
|
{
|
|
3935
3984
|
id: `ojs-${e}-element`,
|
|
@@ -3939,14 +3988,14 @@ const pa = () => ++ha, wr = ".", xr = (t) => t ? t.split(wr) : [], ya = (t) => t
|
|
|
3939
3988
|
style: k,
|
|
3940
3989
|
ref: b
|
|
3941
3990
|
}
|
|
3942
|
-
) : /* @__PURE__ */
|
|
3943
|
-
},
|
|
3991
|
+
) : /* @__PURE__ */ ye("div", {});
|
|
3992
|
+
}, za = ({ styles: t }) => /* @__PURE__ */ ye(vt, { styles: t, subPath: "card-cvc" }), Ba = ({ styles: t }) => /* @__PURE__ */ ye(vt, { styles: t, subPath: "card" }), Ha = ({ styles: t }) => /* @__PURE__ */ ye(vt, { styles: t, subPath: "card-expiry" }), qa = ({ styles: t }) => /* @__PURE__ */ ye(vt, { styles: t, subPath: "card-number" });
|
|
3944
3993
|
export {
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3994
|
+
za as CardCvcElement,
|
|
3995
|
+
Ba as CardElement,
|
|
3996
|
+
Ha as CardExpiryElement,
|
|
3997
|
+
qa as CardNumberElement,
|
|
3998
|
+
Fa as ElementsForm,
|
|
3999
|
+
rt as FieldName,
|
|
4000
|
+
Hn as useOpenPayElements
|
|
3952
4001
|
};
|