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