@invoice-sdk/widget 1.7.2 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/bidv.png +0 -0
- package/dist/assets/fpt.svg +9 -0
- package/dist/assets/m-invoice.svg +9 -0
- package/dist/assets/mb.png +0 -0
- package/dist/assets/misa.svg +9 -0
- package/dist/assets/momo.png +0 -0
- package/dist/assets/qr.png +0 -0
- package/dist/assets/qrcode.png +0 -0
- package/dist/assets/success.gif +0 -0
- package/dist/assets/vcb.png +0 -0
- package/dist/assets/vietqr.png +0 -0
- package/dist/index.esm.js +1510 -0
- package/dist/index.umd.js +52 -0
- package/dist/widget.css +1 -1
- package/package.json +33 -39
- package/README.md +0 -54
- package/dist/App.d.ts +0 -4
- package/dist/App.d.ts.map +0 -1
- package/dist/components/button.d.ts +0 -10
- package/dist/components/button.d.ts.map +0 -1
- package/dist/components/form/custom-checkbox.d.ts +0 -7
- package/dist/components/form/custom-checkbox.d.ts.map +0 -1
- package/dist/components/form/file-upload.d.ts +0 -10
- package/dist/components/form/file-upload.d.ts.map +0 -1
- package/dist/components/form/input-field.d.ts +0 -7
- package/dist/components/form/input-field.d.ts.map +0 -1
- package/dist/components/form/select-option.d.ts +0 -13
- package/dist/components/form/select-option.d.ts.map +0 -1
- package/dist/components/layout.d.ts +0 -4
- package/dist/components/layout.d.ts.map +0 -1
- package/dist/components/process.d.ts +0 -3
- package/dist/components/process.d.ts.map +0 -1
- package/dist/index.cjs.js +0 -24
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.es.js +0 -4998
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
- package/dist/pages/register.d.ts +0 -33
- package/dist/pages/register.d.ts.map +0 -1
- package/dist/pages/select-plan.d.ts +0 -3
- package/dist/pages/select-plan.d.ts.map +0 -1
- package/dist/pages/select-provider.d.ts +0 -3
- package/dist/pages/select-provider.d.ts.map +0 -1
- package/dist/pages/status.d.ts +0 -3
- package/dist/pages/status.d.ts.map +0 -1
- package/dist/store/process.d.ts +0 -10
- package/dist/store/process.d.ts.map +0 -1
- package/dist/store/register.d.ts +0 -23
- package/dist/store/register.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vite.svg +0 -1
package/dist/index.es.js
DELETED
|
@@ -1,4998 +0,0 @@
|
|
|
1
|
-
import * as yr from "react";
|
|
2
|
-
import P, { useRef as ms, useState as Xt, useCallback as ps, useEffect as ys, forwardRef as gs } from "react";
|
|
3
|
-
var Rt = { exports: {} }, ct = {};
|
|
4
|
-
/**
|
|
5
|
-
* @license React
|
|
6
|
-
* react-jsx-runtime.production.js
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
|
-
var gr;
|
|
14
|
-
function vs() {
|
|
15
|
-
if (gr) return ct;
|
|
16
|
-
gr = 1;
|
|
17
|
-
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
18
|
-
function r(s, n, a) {
|
|
19
|
-
var i = null;
|
|
20
|
-
if (a !== void 0 && (i = "" + a), n.key !== void 0 && (i = "" + n.key), "key" in n) {
|
|
21
|
-
a = {};
|
|
22
|
-
for (var o in n)
|
|
23
|
-
o !== "key" && (a[o] = n[o]);
|
|
24
|
-
} else a = n;
|
|
25
|
-
return n = a.ref, {
|
|
26
|
-
$$typeof: t,
|
|
27
|
-
type: s,
|
|
28
|
-
key: i,
|
|
29
|
-
ref: n !== void 0 ? n : null,
|
|
30
|
-
props: a
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return ct.Fragment = e, ct.jsx = r, ct.jsxs = r, ct;
|
|
34
|
-
}
|
|
35
|
-
var lt = {};
|
|
36
|
-
/**
|
|
37
|
-
* @license React
|
|
38
|
-
* react-jsx-runtime.development.js
|
|
39
|
-
*
|
|
40
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
-
*
|
|
42
|
-
* This source code is licensed under the MIT license found in the
|
|
43
|
-
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/
|
|
45
|
-
var vr;
|
|
46
|
-
function _s() {
|
|
47
|
-
return vr || (vr = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
|
-
function t(m) {
|
|
49
|
-
if (m == null) return null;
|
|
50
|
-
if (typeof m == "function")
|
|
51
|
-
return m.$$typeof === je ? null : m.displayName || m.name || null;
|
|
52
|
-
if (typeof m == "string") return m;
|
|
53
|
-
switch (m) {
|
|
54
|
-
case Z:
|
|
55
|
-
return "Fragment";
|
|
56
|
-
case pe:
|
|
57
|
-
return "Profiler";
|
|
58
|
-
case z:
|
|
59
|
-
return "StrictMode";
|
|
60
|
-
case q:
|
|
61
|
-
return "Suspense";
|
|
62
|
-
case Xe:
|
|
63
|
-
return "SuspenseList";
|
|
64
|
-
case le:
|
|
65
|
-
return "Activity";
|
|
66
|
-
}
|
|
67
|
-
if (typeof m == "object")
|
|
68
|
-
switch (typeof m.tag == "number" && console.error(
|
|
69
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
-
), m.$$typeof) {
|
|
71
|
-
case te:
|
|
72
|
-
return "Portal";
|
|
73
|
-
case ce:
|
|
74
|
-
return (m.displayName || "Context") + ".Provider";
|
|
75
|
-
case R:
|
|
76
|
-
return (m._context.displayName || "Context") + ".Consumer";
|
|
77
|
-
case re:
|
|
78
|
-
var C = m.render;
|
|
79
|
-
return m = m.displayName, m || (m = C.displayName || C.name || "", m = m !== "" ? "ForwardRef(" + m + ")" : "ForwardRef"), m;
|
|
80
|
-
case xe:
|
|
81
|
-
return C = m.displayName || null, C !== null ? C : t(m.type) || "Memo";
|
|
82
|
-
case Qe:
|
|
83
|
-
C = m._payload, m = m._init;
|
|
84
|
-
try {
|
|
85
|
-
return t(m(C));
|
|
86
|
-
} catch {
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
function e(m) {
|
|
92
|
-
return "" + m;
|
|
93
|
-
}
|
|
94
|
-
function r(m) {
|
|
95
|
-
try {
|
|
96
|
-
e(m);
|
|
97
|
-
var C = !1;
|
|
98
|
-
} catch {
|
|
99
|
-
C = !0;
|
|
100
|
-
}
|
|
101
|
-
if (C) {
|
|
102
|
-
C = console;
|
|
103
|
-
var U = C.error, H = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
|
|
104
|
-
return U.call(
|
|
105
|
-
C,
|
|
106
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
-
H
|
|
108
|
-
), e(m);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function s(m) {
|
|
112
|
-
if (m === Z) return "<>";
|
|
113
|
-
if (typeof m == "object" && m !== null && m.$$typeof === Qe)
|
|
114
|
-
return "<...>";
|
|
115
|
-
try {
|
|
116
|
-
var C = t(m);
|
|
117
|
-
return C ? "<" + C + ">" : "<...>";
|
|
118
|
-
} catch {
|
|
119
|
-
return "<...>";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function n() {
|
|
123
|
-
var m = ie.A;
|
|
124
|
-
return m === null ? null : m.getOwner();
|
|
125
|
-
}
|
|
126
|
-
function a() {
|
|
127
|
-
return Error("react-stack-top-frame");
|
|
128
|
-
}
|
|
129
|
-
function i(m) {
|
|
130
|
-
if (V.call(m, "key")) {
|
|
131
|
-
var C = Object.getOwnPropertyDescriptor(m, "key").get;
|
|
132
|
-
if (C && C.isReactWarning) return !1;
|
|
133
|
-
}
|
|
134
|
-
return m.key !== void 0;
|
|
135
|
-
}
|
|
136
|
-
function o(m, C) {
|
|
137
|
-
function U() {
|
|
138
|
-
Q || (Q = !0, console.error(
|
|
139
|
-
"%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://react.dev/link/special-props)",
|
|
140
|
-
C
|
|
141
|
-
));
|
|
142
|
-
}
|
|
143
|
-
U.isReactWarning = !0, Object.defineProperty(m, "key", {
|
|
144
|
-
get: U,
|
|
145
|
-
configurable: !0
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function d() {
|
|
149
|
-
var m = t(this.type);
|
|
150
|
-
return K[m] || (K[m] = !0, console.error(
|
|
151
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
-
)), m = this.props.ref, m !== void 0 ? m : null;
|
|
153
|
-
}
|
|
154
|
-
function h(m, C, U, H, ke, de, ot, Be) {
|
|
155
|
-
return U = de.ref, m = {
|
|
156
|
-
$$typeof: W,
|
|
157
|
-
type: m,
|
|
158
|
-
key: C,
|
|
159
|
-
props: de,
|
|
160
|
-
_owner: ke
|
|
161
|
-
}, (U !== void 0 ? U : null) !== null ? Object.defineProperty(m, "ref", {
|
|
162
|
-
enumerable: !1,
|
|
163
|
-
get: d
|
|
164
|
-
}) : Object.defineProperty(m, "ref", { enumerable: !1, value: null }), m._store = {}, Object.defineProperty(m._store, "validated", {
|
|
165
|
-
configurable: !1,
|
|
166
|
-
enumerable: !1,
|
|
167
|
-
writable: !0,
|
|
168
|
-
value: 0
|
|
169
|
-
}), Object.defineProperty(m, "_debugInfo", {
|
|
170
|
-
configurable: !1,
|
|
171
|
-
enumerable: !1,
|
|
172
|
-
writable: !0,
|
|
173
|
-
value: null
|
|
174
|
-
}), Object.defineProperty(m, "_debugStack", {
|
|
175
|
-
configurable: !1,
|
|
176
|
-
enumerable: !1,
|
|
177
|
-
writable: !0,
|
|
178
|
-
value: ot
|
|
179
|
-
}), Object.defineProperty(m, "_debugTask", {
|
|
180
|
-
configurable: !1,
|
|
181
|
-
enumerable: !1,
|
|
182
|
-
writable: !0,
|
|
183
|
-
value: Be
|
|
184
|
-
}), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
|
|
185
|
-
}
|
|
186
|
-
function f(m, C, U, H, ke, de, ot, Be) {
|
|
187
|
-
var G = C.children;
|
|
188
|
-
if (G !== void 0)
|
|
189
|
-
if (H)
|
|
190
|
-
if (I(G)) {
|
|
191
|
-
for (H = 0; H < G.length; H++)
|
|
192
|
-
x(G[H]);
|
|
193
|
-
Object.freeze && Object.freeze(G);
|
|
194
|
-
} else
|
|
195
|
-
console.error(
|
|
196
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
-
);
|
|
198
|
-
else x(G);
|
|
199
|
-
if (V.call(C, "key")) {
|
|
200
|
-
G = t(m);
|
|
201
|
-
var we = Object.keys(C).filter(function(qt) {
|
|
202
|
-
return qt !== "key";
|
|
203
|
-
});
|
|
204
|
-
H = 0 < we.length ? "{key: someKey, " + we.join(": ..., ") + ": ...}" : "{key: someKey}", Ne[G + H] || (we = 0 < we.length ? "{" + we.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
-
let props = %s;
|
|
207
|
-
<%s {...props} />
|
|
208
|
-
React keys must be passed directly to JSX without using spread:
|
|
209
|
-
let props = %s;
|
|
210
|
-
<%s key={someKey} {...props} />`,
|
|
211
|
-
H,
|
|
212
|
-
G,
|
|
213
|
-
we,
|
|
214
|
-
G
|
|
215
|
-
), Ne[G + H] = !0);
|
|
216
|
-
}
|
|
217
|
-
if (G = null, U !== void 0 && (r(U), G = "" + U), i(C) && (r(C.key), G = "" + C.key), "key" in C) {
|
|
218
|
-
U = {};
|
|
219
|
-
for (var We in C)
|
|
220
|
-
We !== "key" && (U[We] = C[We]);
|
|
221
|
-
} else U = C;
|
|
222
|
-
return G && o(
|
|
223
|
-
U,
|
|
224
|
-
typeof m == "function" ? m.displayName || m.name || "Unknown" : m
|
|
225
|
-
), h(
|
|
226
|
-
m,
|
|
227
|
-
G,
|
|
228
|
-
de,
|
|
229
|
-
ke,
|
|
230
|
-
n(),
|
|
231
|
-
U,
|
|
232
|
-
ot,
|
|
233
|
-
Be
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
function x(m) {
|
|
237
|
-
typeof m == "object" && m !== null && m.$$typeof === W && m._store && (m._store.validated = 1);
|
|
238
|
-
}
|
|
239
|
-
var S = P, W = Symbol.for("react.transitional.element"), te = Symbol.for("react.portal"), Z = Symbol.for("react.fragment"), z = Symbol.for("react.strict_mode"), pe = Symbol.for("react.profiler"), R = Symbol.for("react.consumer"), ce = Symbol.for("react.context"), re = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), Xe = Symbol.for("react.suspense_list"), xe = Symbol.for("react.memo"), Qe = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), je = Symbol.for("react.client.reference"), ie = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, V = Object.prototype.hasOwnProperty, I = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
240
|
-
return null;
|
|
241
|
-
};
|
|
242
|
-
S = {
|
|
243
|
-
"react-stack-bottom-frame": function(m) {
|
|
244
|
-
return m();
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
var Q, K = {}, ue = S["react-stack-bottom-frame"].bind(
|
|
248
|
-
S,
|
|
249
|
-
a
|
|
250
|
-
)(), Pe = $(s(a)), Ne = {};
|
|
251
|
-
lt.Fragment = Z, lt.jsx = function(m, C, U, H, ke) {
|
|
252
|
-
var de = 1e4 > ie.recentlyCreatedOwnerStacks++;
|
|
253
|
-
return f(
|
|
254
|
-
m,
|
|
255
|
-
C,
|
|
256
|
-
U,
|
|
257
|
-
!1,
|
|
258
|
-
H,
|
|
259
|
-
ke,
|
|
260
|
-
de ? Error("react-stack-top-frame") : ue,
|
|
261
|
-
de ? $(s(m)) : Pe
|
|
262
|
-
);
|
|
263
|
-
}, lt.jsxs = function(m, C, U, H, ke) {
|
|
264
|
-
var de = 1e4 > ie.recentlyCreatedOwnerStacks++;
|
|
265
|
-
return f(
|
|
266
|
-
m,
|
|
267
|
-
C,
|
|
268
|
-
U,
|
|
269
|
-
!0,
|
|
270
|
-
H,
|
|
271
|
-
ke,
|
|
272
|
-
de ? Error("react-stack-top-frame") : ue,
|
|
273
|
-
de ? $(s(m)) : Pe
|
|
274
|
-
);
|
|
275
|
-
};
|
|
276
|
-
}()), lt;
|
|
277
|
-
}
|
|
278
|
-
var _r;
|
|
279
|
-
function bs() {
|
|
280
|
-
return _r || (_r = 1, process.env.NODE_ENV === "production" ? Rt.exports = vs() : Rt.exports = _s()), Rt.exports;
|
|
281
|
-
}
|
|
282
|
-
var y = bs();
|
|
283
|
-
const br = (t) => {
|
|
284
|
-
let e;
|
|
285
|
-
const r = /* @__PURE__ */ new Set(), s = (h, f) => {
|
|
286
|
-
const x = typeof h == "function" ? h(e) : h;
|
|
287
|
-
if (!Object.is(x, e)) {
|
|
288
|
-
const S = e;
|
|
289
|
-
e = f ?? (typeof x != "object" || x === null) ? x : Object.assign({}, e, x), r.forEach((W) => W(e, S));
|
|
290
|
-
}
|
|
291
|
-
}, n = () => e, o = { setState: s, getState: n, getInitialState: () => d, subscribe: (h) => (r.add(h), () => r.delete(h)) }, d = e = t(s, n, o);
|
|
292
|
-
return o;
|
|
293
|
-
}, xs = (t) => t ? br(t) : br, ks = (t) => t;
|
|
294
|
-
function ws(t, e = ks) {
|
|
295
|
-
const r = P.useSyncExternalStore(
|
|
296
|
-
t.subscribe,
|
|
297
|
-
() => e(t.getState()),
|
|
298
|
-
() => e(t.getInitialState())
|
|
299
|
-
);
|
|
300
|
-
return P.useDebugValue(r), r;
|
|
301
|
-
}
|
|
302
|
-
const xr = (t) => {
|
|
303
|
-
const e = xs(t), r = (s) => ws(e, s);
|
|
304
|
-
return Object.assign(r, e), r;
|
|
305
|
-
}, Mr = (t) => t ? xr(t) : xr, st = Mr((t) => ({
|
|
306
|
-
step: 1,
|
|
307
|
-
nextStep: () => t((e) => ({ step: e.step + 1 })),
|
|
308
|
-
prevStep: () => t((e) => ({ step: Math.max(e.step - 1, 1) })),
|
|
309
|
-
reset: () => t({ step: 1 })
|
|
310
|
-
})), Ts = 4, Ss = () => {
|
|
311
|
-
const { step: t } = st();
|
|
312
|
-
return /* @__PURE__ */ y.jsx("div", { className: "w-full relative h-3 bg-gray-200 rounded-full", children: /* @__PURE__ */ y.jsx(
|
|
313
|
-
"div",
|
|
314
|
-
{
|
|
315
|
-
className: "absolute rounded-full bg-green-500",
|
|
316
|
-
style: {
|
|
317
|
-
width: `${t / Ts * 100}%`,
|
|
318
|
-
height: "100%",
|
|
319
|
-
transition: "width 0.3s ease-in-out"
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
) });
|
|
323
|
-
}, As = ({ children: t }) => /* @__PURE__ */ y.jsxs("div", { className: "max-w-[800px] mx-auto py-10 flex flex-col gap-8", children: [
|
|
324
|
-
/* @__PURE__ */ y.jsx(Ss, {}),
|
|
325
|
-
t
|
|
326
|
-
] });
|
|
327
|
-
var jt = (t) => t.type === "checkbox", qe = (t) => t instanceof Date, ne = (t) => t == null;
|
|
328
|
-
const Zr = (t) => typeof t == "object";
|
|
329
|
-
var J = (t) => !ne(t) && !Array.isArray(t) && Zr(t) && !qe(t), Lr = (t) => J(t) && t.target ? jt(t.target) ? t.target.checked : t.target.value : t, Es = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, $r = (t, e) => t.has(Es(e)), js = (t) => {
|
|
330
|
-
const e = t.constructor && t.constructor.prototype;
|
|
331
|
-
return J(e) && e.hasOwnProperty("isPrototypeOf");
|
|
332
|
-
}, sr = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
333
|
-
function ee(t) {
|
|
334
|
-
let e;
|
|
335
|
-
const r = Array.isArray(t), s = typeof FileList < "u" ? t instanceof FileList : !1;
|
|
336
|
-
if (t instanceof Date)
|
|
337
|
-
e = new Date(t);
|
|
338
|
-
else if (t instanceof Set)
|
|
339
|
-
e = new Set(t);
|
|
340
|
-
else if (!(sr && (t instanceof Blob || s)) && (r || J(t)))
|
|
341
|
-
if (e = r ? [] : {}, !r && !js(t))
|
|
342
|
-
e = t;
|
|
343
|
-
else
|
|
344
|
-
for (const n in t)
|
|
345
|
-
t.hasOwnProperty(n) && (e[n] = ee(t[n]));
|
|
346
|
-
else
|
|
347
|
-
return t;
|
|
348
|
-
return e;
|
|
349
|
-
}
|
|
350
|
-
var Bt = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Y = (t) => t === void 0, _ = (t, e, r) => {
|
|
351
|
-
if (!e || !J(t))
|
|
352
|
-
return r;
|
|
353
|
-
const s = Bt(e.split(/[,[\].]+?/)).reduce((n, a) => ne(n) ? n : n[a], t);
|
|
354
|
-
return Y(s) || s === t ? Y(t[e]) ? r : t[e] : s;
|
|
355
|
-
}, fe = (t) => typeof t == "boolean", nr = (t) => /^\w*$/.test(t), Ur = (t) => Bt(t.replace(/["|']|\]/g, "").split(/\.|\[/)), D = (t, e, r) => {
|
|
356
|
-
let s = -1;
|
|
357
|
-
const n = nr(e) ? [e] : Ur(e), a = n.length, i = a - 1;
|
|
358
|
-
for (; ++s < a; ) {
|
|
359
|
-
const o = n[s];
|
|
360
|
-
let d = r;
|
|
361
|
-
if (s !== i) {
|
|
362
|
-
const h = t[o];
|
|
363
|
-
d = J(h) || Array.isArray(h) ? h : isNaN(+n[s + 1]) ? {} : [];
|
|
364
|
-
}
|
|
365
|
-
if (o === "__proto__" || o === "constructor" || o === "prototype")
|
|
366
|
-
return;
|
|
367
|
-
t[o] = d, t = t[o];
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
const Vt = {
|
|
371
|
-
BLUR: "blur",
|
|
372
|
-
FOCUS_OUT: "focusout",
|
|
373
|
-
CHANGE: "change"
|
|
374
|
-
}, ye = {
|
|
375
|
-
onBlur: "onBlur",
|
|
376
|
-
onChange: "onChange",
|
|
377
|
-
onSubmit: "onSubmit",
|
|
378
|
-
onTouched: "onTouched",
|
|
379
|
-
all: "all"
|
|
380
|
-
}, Ce = {
|
|
381
|
-
max: "max",
|
|
382
|
-
min: "min",
|
|
383
|
-
maxLength: "maxLength",
|
|
384
|
-
minLength: "minLength",
|
|
385
|
-
pattern: "pattern",
|
|
386
|
-
required: "required",
|
|
387
|
-
validate: "validate"
|
|
388
|
-
}, Ns = P.createContext(null), ar = () => P.useContext(Ns);
|
|
389
|
-
var zr = (t, e, r, s = !0) => {
|
|
390
|
-
const n = {
|
|
391
|
-
defaultValues: e._defaultValues
|
|
392
|
-
};
|
|
393
|
-
for (const a in t)
|
|
394
|
-
Object.defineProperty(n, a, {
|
|
395
|
-
get: () => {
|
|
396
|
-
const i = a;
|
|
397
|
-
return e._proxyFormState[i] !== ye.all && (e._proxyFormState[i] = !s || ye.all), r && (r[i] = !0), t[i];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
return n;
|
|
401
|
-
};
|
|
402
|
-
const ir = typeof window < "u" ? yr.useLayoutEffect : yr.useEffect;
|
|
403
|
-
function Cs(t) {
|
|
404
|
-
const e = ar(), { control: r = e.control, disabled: s, name: n, exact: a } = t || {}, [i, o] = P.useState(r._formState), d = P.useRef({
|
|
405
|
-
isDirty: !1,
|
|
406
|
-
isLoading: !1,
|
|
407
|
-
dirtyFields: !1,
|
|
408
|
-
touchedFields: !1,
|
|
409
|
-
validatingFields: !1,
|
|
410
|
-
isValidating: !1,
|
|
411
|
-
isValid: !1,
|
|
412
|
-
errors: !1
|
|
413
|
-
});
|
|
414
|
-
return ir(() => r._subscribe({
|
|
415
|
-
name: n,
|
|
416
|
-
formState: d.current,
|
|
417
|
-
exact: a,
|
|
418
|
-
callback: (h) => {
|
|
419
|
-
!s && o({
|
|
420
|
-
...r._formState,
|
|
421
|
-
...h
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
}), [n, s, a]), P.useEffect(() => {
|
|
425
|
-
d.current.isValid && r._setValid(!0);
|
|
426
|
-
}, [r]), P.useMemo(() => zr(i, r, d.current, !1), [i, r]);
|
|
427
|
-
}
|
|
428
|
-
var Te = (t) => typeof t == "string", Br = (t, e, r, s, n) => Te(t) ? (s && e.watch.add(t), _(r, t, n)) : Array.isArray(t) ? t.map((a) => (s && e.watch.add(a), _(r, a))) : (s && (e.watchAll = !0), r);
|
|
429
|
-
function Rs(t) {
|
|
430
|
-
const e = ar(), { control: r = e.control, name: s, defaultValue: n, disabled: a, exact: i } = t || {}, o = P.useRef(n), [d, h] = P.useState(r._getWatch(s, o.current));
|
|
431
|
-
return ir(() => r._subscribe({
|
|
432
|
-
name: s,
|
|
433
|
-
formState: {
|
|
434
|
-
values: !0
|
|
435
|
-
},
|
|
436
|
-
exact: i,
|
|
437
|
-
callback: (f) => !a && h(Br(s, r._names, f.values || r._formValues, !1, o.current))
|
|
438
|
-
}), [s, r, a, i]), P.useEffect(() => r._removeUnmounted()), d;
|
|
439
|
-
}
|
|
440
|
-
function Os(t) {
|
|
441
|
-
const e = ar(), { name: r, disabled: s, control: n = e.control, shouldUnregister: a } = t, i = $r(n._names.array, r), o = Rs({
|
|
442
|
-
control: n,
|
|
443
|
-
name: r,
|
|
444
|
-
defaultValue: _(n._formValues, r, _(n._defaultValues, r, t.defaultValue)),
|
|
445
|
-
exact: !0
|
|
446
|
-
}), d = Cs({
|
|
447
|
-
control: n,
|
|
448
|
-
name: r,
|
|
449
|
-
exact: !0
|
|
450
|
-
}), h = P.useRef(t), f = P.useRef(n.register(r, {
|
|
451
|
-
...t.rules,
|
|
452
|
-
value: o,
|
|
453
|
-
...fe(t.disabled) ? { disabled: t.disabled } : {}
|
|
454
|
-
})), x = P.useMemo(() => Object.defineProperties({}, {
|
|
455
|
-
invalid: {
|
|
456
|
-
enumerable: !0,
|
|
457
|
-
get: () => !!_(d.errors, r)
|
|
458
|
-
},
|
|
459
|
-
isDirty: {
|
|
460
|
-
enumerable: !0,
|
|
461
|
-
get: () => !!_(d.dirtyFields, r)
|
|
462
|
-
},
|
|
463
|
-
isTouched: {
|
|
464
|
-
enumerable: !0,
|
|
465
|
-
get: () => !!_(d.touchedFields, r)
|
|
466
|
-
},
|
|
467
|
-
isValidating: {
|
|
468
|
-
enumerable: !0,
|
|
469
|
-
get: () => !!_(d.validatingFields, r)
|
|
470
|
-
},
|
|
471
|
-
error: {
|
|
472
|
-
enumerable: !0,
|
|
473
|
-
get: () => _(d.errors, r)
|
|
474
|
-
}
|
|
475
|
-
}), [d, r]), S = P.useCallback((z) => f.current.onChange({
|
|
476
|
-
target: {
|
|
477
|
-
value: Lr(z),
|
|
478
|
-
name: r
|
|
479
|
-
},
|
|
480
|
-
type: Vt.CHANGE
|
|
481
|
-
}), [r]), W = P.useCallback(() => f.current.onBlur({
|
|
482
|
-
target: {
|
|
483
|
-
value: _(n._formValues, r),
|
|
484
|
-
name: r
|
|
485
|
-
},
|
|
486
|
-
type: Vt.BLUR
|
|
487
|
-
}), [r, n._formValues]), te = P.useCallback((z) => {
|
|
488
|
-
const pe = _(n._fields, r);
|
|
489
|
-
pe && z && (pe._f.ref = {
|
|
490
|
-
focus: () => z.focus && z.focus(),
|
|
491
|
-
select: () => z.select && z.select(),
|
|
492
|
-
setCustomValidity: (R) => z.setCustomValidity(R),
|
|
493
|
-
reportValidity: () => z.reportValidity()
|
|
494
|
-
});
|
|
495
|
-
}, [n._fields, r]), Z = P.useMemo(() => ({
|
|
496
|
-
name: r,
|
|
497
|
-
value: o,
|
|
498
|
-
...fe(s) || d.disabled ? { disabled: d.disabled || s } : {},
|
|
499
|
-
onChange: S,
|
|
500
|
-
onBlur: W,
|
|
501
|
-
ref: te
|
|
502
|
-
}), [r, s, d.disabled, S, W, te, o]);
|
|
503
|
-
return P.useEffect(() => {
|
|
504
|
-
const z = n._options.shouldUnregister || a;
|
|
505
|
-
n.register(r, {
|
|
506
|
-
...h.current.rules,
|
|
507
|
-
...fe(h.current.disabled) ? { disabled: h.current.disabled } : {}
|
|
508
|
-
});
|
|
509
|
-
const pe = (R, ce) => {
|
|
510
|
-
const re = _(n._fields, R);
|
|
511
|
-
re && re._f && (re._f.mount = ce);
|
|
512
|
-
};
|
|
513
|
-
if (pe(r, !0), z) {
|
|
514
|
-
const R = ee(_(n._options.defaultValues, r));
|
|
515
|
-
D(n._defaultValues, r, R), Y(_(n._formValues, r)) && D(n._formValues, r, R);
|
|
516
|
-
}
|
|
517
|
-
return !i && n.register(r), () => {
|
|
518
|
-
(i ? z && !n._state.action : z) ? n.unregister(r) : pe(r, !1);
|
|
519
|
-
};
|
|
520
|
-
}, [r, n, i, a]), P.useEffect(() => {
|
|
521
|
-
n._setDisabledField({
|
|
522
|
-
disabled: s,
|
|
523
|
-
name: r
|
|
524
|
-
});
|
|
525
|
-
}, [s, r, n]), P.useMemo(() => ({
|
|
526
|
-
field: Z,
|
|
527
|
-
formState: d,
|
|
528
|
-
fieldState: x
|
|
529
|
-
}), [Z, d, x]);
|
|
530
|
-
}
|
|
531
|
-
const De = (t) => t.render(Os(t));
|
|
532
|
-
var Wr = (t, e, r, s, n) => e ? {
|
|
533
|
-
...r[t],
|
|
534
|
-
types: {
|
|
535
|
-
...r[t] && r[t].types ? r[t].types : {},
|
|
536
|
-
[s]: n || !0
|
|
537
|
-
}
|
|
538
|
-
} : {}, ft = (t) => Array.isArray(t) ? t : [t], kr = () => {
|
|
539
|
-
let t = [];
|
|
540
|
-
return {
|
|
541
|
-
get observers() {
|
|
542
|
-
return t;
|
|
543
|
-
},
|
|
544
|
-
next: (n) => {
|
|
545
|
-
for (const a of t)
|
|
546
|
-
a.next && a.next(n);
|
|
547
|
-
},
|
|
548
|
-
subscribe: (n) => (t.push(n), {
|
|
549
|
-
unsubscribe: () => {
|
|
550
|
-
t = t.filter((a) => a !== n);
|
|
551
|
-
}
|
|
552
|
-
}),
|
|
553
|
-
unsubscribe: () => {
|
|
554
|
-
t = [];
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
}, Qt = (t) => ne(t) || !Zr(t);
|
|
558
|
-
function Ze(t, e) {
|
|
559
|
-
if (Qt(t) || Qt(e))
|
|
560
|
-
return t === e;
|
|
561
|
-
if (qe(t) && qe(e))
|
|
562
|
-
return t.getTime() === e.getTime();
|
|
563
|
-
const r = Object.keys(t), s = Object.keys(e);
|
|
564
|
-
if (r.length !== s.length)
|
|
565
|
-
return !1;
|
|
566
|
-
for (const n of r) {
|
|
567
|
-
const a = t[n];
|
|
568
|
-
if (!s.includes(n))
|
|
569
|
-
return !1;
|
|
570
|
-
if (n !== "ref") {
|
|
571
|
-
const i = e[n];
|
|
572
|
-
if (qe(a) && qe(i) || J(a) && J(i) || Array.isArray(a) && Array.isArray(i) ? !Ze(a, i) : a !== i)
|
|
573
|
-
return !1;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
return !0;
|
|
577
|
-
}
|
|
578
|
-
var oe = (t) => J(t) && !Object.keys(t).length, or = (t) => t.type === "file", ge = (t) => typeof t == "function", Ft = (t) => {
|
|
579
|
-
if (!sr)
|
|
580
|
-
return !1;
|
|
581
|
-
const e = t ? t.ownerDocument : 0;
|
|
582
|
-
return t instanceof (e && e.defaultView ? e.defaultView.HTMLElement : HTMLElement);
|
|
583
|
-
}, qr = (t) => t.type === "select-multiple", cr = (t) => t.type === "radio", Vs = (t) => cr(t) || jt(t), Ht = (t) => Ft(t) && t.isConnected;
|
|
584
|
-
function Fs(t, e) {
|
|
585
|
-
const r = e.slice(0, -1).length;
|
|
586
|
-
let s = 0;
|
|
587
|
-
for (; s < r; )
|
|
588
|
-
t = Y(t) ? s++ : t[e[s++]];
|
|
589
|
-
return t;
|
|
590
|
-
}
|
|
591
|
-
function Ps(t) {
|
|
592
|
-
for (const e in t)
|
|
593
|
-
if (t.hasOwnProperty(e) && !Y(t[e]))
|
|
594
|
-
return !1;
|
|
595
|
-
return !0;
|
|
596
|
-
}
|
|
597
|
-
function X(t, e) {
|
|
598
|
-
const r = Array.isArray(e) ? e : nr(e) ? [e] : Ur(e), s = r.length === 1 ? t : Fs(t, r), n = r.length - 1, a = r[n];
|
|
599
|
-
return s && delete s[a], n !== 0 && (J(s) && oe(s) || Array.isArray(s) && Ps(s)) && X(t, r.slice(0, -1)), t;
|
|
600
|
-
}
|
|
601
|
-
var Yr = (t) => {
|
|
602
|
-
for (const e in t)
|
|
603
|
-
if (ge(t[e]))
|
|
604
|
-
return !0;
|
|
605
|
-
return !1;
|
|
606
|
-
};
|
|
607
|
-
function Pt(t, e = {}) {
|
|
608
|
-
const r = Array.isArray(t);
|
|
609
|
-
if (J(t) || r)
|
|
610
|
-
for (const s in t)
|
|
611
|
-
Array.isArray(t[s]) || J(t[s]) && !Yr(t[s]) ? (e[s] = Array.isArray(t[s]) ? [] : {}, Pt(t[s], e[s])) : ne(t[s]) || (e[s] = !0);
|
|
612
|
-
return e;
|
|
613
|
-
}
|
|
614
|
-
function Jr(t, e, r) {
|
|
615
|
-
const s = Array.isArray(t);
|
|
616
|
-
if (J(t) || s)
|
|
617
|
-
for (const n in t)
|
|
618
|
-
Array.isArray(t[n]) || J(t[n]) && !Yr(t[n]) ? Y(e) || Qt(r[n]) ? r[n] = Array.isArray(t[n]) ? Pt(t[n], []) : { ...Pt(t[n]) } : Jr(t[n], ne(e) ? {} : e[n], r[n]) : r[n] = !Ze(t[n], e[n]);
|
|
619
|
-
return r;
|
|
620
|
-
}
|
|
621
|
-
var ut = (t, e) => Jr(t, e, Pt(e));
|
|
622
|
-
const wr = {
|
|
623
|
-
value: !1,
|
|
624
|
-
isValid: !1
|
|
625
|
-
}, Tr = { value: !0, isValid: !0 };
|
|
626
|
-
var Hr = (t) => {
|
|
627
|
-
if (Array.isArray(t)) {
|
|
628
|
-
if (t.length > 1) {
|
|
629
|
-
const e = t.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
630
|
-
return { value: e, isValid: !!e.length };
|
|
631
|
-
}
|
|
632
|
-
return t[0].checked && !t[0].disabled ? (
|
|
633
|
-
// @ts-expect-error expected to work in the browser
|
|
634
|
-
t[0].attributes && !Y(t[0].attributes.value) ? Y(t[0].value) || t[0].value === "" ? Tr : { value: t[0].value, isValid: !0 } : Tr
|
|
635
|
-
) : wr;
|
|
636
|
-
}
|
|
637
|
-
return wr;
|
|
638
|
-
}, Gr = (t, { valueAsNumber: e, valueAsDate: r, setValueAs: s }) => Y(t) ? t : e ? t === "" ? NaN : t && +t : r && Te(t) ? new Date(t) : s ? s(t) : t;
|
|
639
|
-
const Sr = {
|
|
640
|
-
isValid: !1,
|
|
641
|
-
value: null
|
|
642
|
-
};
|
|
643
|
-
var Xr = (t) => Array.isArray(t) ? t.reduce((e, r) => r && r.checked && !r.disabled ? {
|
|
644
|
-
isValid: !0,
|
|
645
|
-
value: r.value
|
|
646
|
-
} : e, Sr) : Sr;
|
|
647
|
-
function Ar(t) {
|
|
648
|
-
const e = t.ref;
|
|
649
|
-
return or(e) ? e.files : cr(e) ? Xr(t.refs).value : qr(e) ? [...e.selectedOptions].map(({ value: r }) => r) : jt(e) ? Hr(t.refs).value : Gr(Y(e.value) ? t.ref.value : e.value, t);
|
|
650
|
-
}
|
|
651
|
-
var Is = (t, e, r, s) => {
|
|
652
|
-
const n = {};
|
|
653
|
-
for (const a of t) {
|
|
654
|
-
const i = _(e, a);
|
|
655
|
-
i && D(n, a, i._f);
|
|
656
|
-
}
|
|
657
|
-
return {
|
|
658
|
-
criteriaMode: r,
|
|
659
|
-
names: [...t],
|
|
660
|
-
fields: n,
|
|
661
|
-
shouldUseNativeValidation: s
|
|
662
|
-
};
|
|
663
|
-
}, It = (t) => t instanceof RegExp, dt = (t) => Y(t) ? t : It(t) ? t.source : J(t) ? It(t.value) ? t.value.source : t.value : t, Er = (t) => ({
|
|
664
|
-
isOnSubmit: !t || t === ye.onSubmit,
|
|
665
|
-
isOnBlur: t === ye.onBlur,
|
|
666
|
-
isOnChange: t === ye.onChange,
|
|
667
|
-
isOnAll: t === ye.all,
|
|
668
|
-
isOnTouch: t === ye.onTouched
|
|
669
|
-
});
|
|
670
|
-
const jr = "AsyncFunction";
|
|
671
|
-
var Ds = (t) => !!t && !!t.validate && !!(ge(t.validate) && t.validate.constructor.name === jr || J(t.validate) && Object.values(t.validate).find((e) => e.constructor.name === jr)), Ms = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate), Nr = (t, e, r) => !r && (e.watchAll || e.watch.has(t) || [...e.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
|
|
672
|
-
const ht = (t, e, r, s) => {
|
|
673
|
-
for (const n of r || Object.keys(t)) {
|
|
674
|
-
const a = _(t, n);
|
|
675
|
-
if (a) {
|
|
676
|
-
const { _f: i, ...o } = a;
|
|
677
|
-
if (i) {
|
|
678
|
-
if (i.refs && i.refs[0] && e(i.refs[0], n) && !s)
|
|
679
|
-
return !0;
|
|
680
|
-
if (i.ref && e(i.ref, i.name) && !s)
|
|
681
|
-
return !0;
|
|
682
|
-
if (ht(o, e))
|
|
683
|
-
break;
|
|
684
|
-
} else if (J(o) && ht(o, e))
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
function Cr(t, e, r) {
|
|
690
|
-
const s = _(t, r);
|
|
691
|
-
if (s || nr(r))
|
|
692
|
-
return {
|
|
693
|
-
error: s,
|
|
694
|
-
name: r
|
|
695
|
-
};
|
|
696
|
-
const n = r.split(".");
|
|
697
|
-
for (; n.length; ) {
|
|
698
|
-
const a = n.join("."), i = _(e, a), o = _(t, a);
|
|
699
|
-
if (i && !Array.isArray(i) && r !== a)
|
|
700
|
-
return { name: r };
|
|
701
|
-
if (o && o.type)
|
|
702
|
-
return {
|
|
703
|
-
name: a,
|
|
704
|
-
error: o
|
|
705
|
-
};
|
|
706
|
-
if (o && o.root && o.root.type)
|
|
707
|
-
return {
|
|
708
|
-
name: `${a}.root`,
|
|
709
|
-
error: o.root
|
|
710
|
-
};
|
|
711
|
-
n.pop();
|
|
712
|
-
}
|
|
713
|
-
return {
|
|
714
|
-
name: r
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
var Zs = (t, e, r, s) => {
|
|
718
|
-
r(t);
|
|
719
|
-
const { name: n, ...a } = t;
|
|
720
|
-
return oe(a) || Object.keys(a).length >= Object.keys(e).length || Object.keys(a).find((i) => e[i] === (!s || ye.all));
|
|
721
|
-
}, Ls = (t, e, r) => !t || !e || t === e || ft(t).some((s) => s && (r ? s === e : s.startsWith(e) || e.startsWith(s))), $s = (t, e, r, s, n) => n.isOnAll ? !1 : !r && n.isOnTouch ? !(e || t) : (r ? s.isOnBlur : n.isOnBlur) ? !t : (r ? s.isOnChange : n.isOnChange) ? t : !0, Us = (t, e) => !Bt(_(t, e)).length && X(t, e), zs = (t, e, r) => {
|
|
722
|
-
const s = ft(_(t, r));
|
|
723
|
-
return D(s, "root", e[r]), D(t, r, s), t;
|
|
724
|
-
}, Ot = (t) => Te(t);
|
|
725
|
-
function Rr(t, e, r = "validate") {
|
|
726
|
-
if (Ot(t) || Array.isArray(t) && t.every(Ot) || fe(t) && !t)
|
|
727
|
-
return {
|
|
728
|
-
type: r,
|
|
729
|
-
message: Ot(t) ? t : "",
|
|
730
|
-
ref: e
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
var Ke = (t) => J(t) && !It(t) ? t : {
|
|
734
|
-
value: t,
|
|
735
|
-
message: ""
|
|
736
|
-
}, Or = async (t, e, r, s, n, a) => {
|
|
737
|
-
const { ref: i, refs: o, required: d, maxLength: h, minLength: f, min: x, max: S, pattern: W, validate: te, name: Z, valueAsNumber: z, mount: pe } = t._f, R = _(r, Z);
|
|
738
|
-
if (!pe || e.has(Z))
|
|
739
|
-
return {};
|
|
740
|
-
const ce = o ? o[0] : i, re = (V) => {
|
|
741
|
-
n && ce.reportValidity && (ce.setCustomValidity(fe(V) ? "" : V || ""), ce.reportValidity());
|
|
742
|
-
}, q = {}, Xe = cr(i), xe = jt(i), Qe = Xe || xe, le = (z || or(i)) && Y(i.value) && Y(R) || Ft(i) && i.value === "" || R === "" || Array.isArray(R) && !R.length, je = Wr.bind(null, Z, s, q), ie = (V, I, $, Q = Ce.maxLength, K = Ce.minLength) => {
|
|
743
|
-
const ue = V ? I : $;
|
|
744
|
-
q[Z] = {
|
|
745
|
-
type: V ? Q : K,
|
|
746
|
-
message: ue,
|
|
747
|
-
ref: i,
|
|
748
|
-
...je(V ? Q : K, ue)
|
|
749
|
-
};
|
|
750
|
-
};
|
|
751
|
-
if (a ? !Array.isArray(R) || !R.length : d && (!Qe && (le || ne(R)) || fe(R) && !R || xe && !Hr(o).isValid || Xe && !Xr(o).isValid)) {
|
|
752
|
-
const { value: V, message: I } = Ot(d) ? { value: !!d, message: d } : Ke(d);
|
|
753
|
-
if (V && (q[Z] = {
|
|
754
|
-
type: Ce.required,
|
|
755
|
-
message: I,
|
|
756
|
-
ref: ce,
|
|
757
|
-
...je(Ce.required, I)
|
|
758
|
-
}, !s))
|
|
759
|
-
return re(I), q;
|
|
760
|
-
}
|
|
761
|
-
if (!le && (!ne(x) || !ne(S))) {
|
|
762
|
-
let V, I;
|
|
763
|
-
const $ = Ke(S), Q = Ke(x);
|
|
764
|
-
if (!ne(R) && !isNaN(R)) {
|
|
765
|
-
const K = i.valueAsNumber || R && +R;
|
|
766
|
-
ne($.value) || (V = K > $.value), ne(Q.value) || (I = K < Q.value);
|
|
767
|
-
} else {
|
|
768
|
-
const K = i.valueAsDate || new Date(R), ue = (m) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + m), Pe = i.type == "time", Ne = i.type == "week";
|
|
769
|
-
Te($.value) && R && (V = Pe ? ue(R) > ue($.value) : Ne ? R > $.value : K > new Date($.value)), Te(Q.value) && R && (I = Pe ? ue(R) < ue(Q.value) : Ne ? R < Q.value : K < new Date(Q.value));
|
|
770
|
-
}
|
|
771
|
-
if ((V || I) && (ie(!!V, $.message, Q.message, Ce.max, Ce.min), !s))
|
|
772
|
-
return re(q[Z].message), q;
|
|
773
|
-
}
|
|
774
|
-
if ((h || f) && !le && (Te(R) || a && Array.isArray(R))) {
|
|
775
|
-
const V = Ke(h), I = Ke(f), $ = !ne(V.value) && R.length > +V.value, Q = !ne(I.value) && R.length < +I.value;
|
|
776
|
-
if (($ || Q) && (ie($, V.message, I.message), !s))
|
|
777
|
-
return re(q[Z].message), q;
|
|
778
|
-
}
|
|
779
|
-
if (W && !le && Te(R)) {
|
|
780
|
-
const { value: V, message: I } = Ke(W);
|
|
781
|
-
if (It(V) && !R.match(V) && (q[Z] = {
|
|
782
|
-
type: Ce.pattern,
|
|
783
|
-
message: I,
|
|
784
|
-
ref: i,
|
|
785
|
-
...je(Ce.pattern, I)
|
|
786
|
-
}, !s))
|
|
787
|
-
return re(I), q;
|
|
788
|
-
}
|
|
789
|
-
if (te) {
|
|
790
|
-
if (ge(te)) {
|
|
791
|
-
const V = await te(R, r), I = Rr(V, ce);
|
|
792
|
-
if (I && (q[Z] = {
|
|
793
|
-
...I,
|
|
794
|
-
...je(Ce.validate, I.message)
|
|
795
|
-
}, !s))
|
|
796
|
-
return re(I.message), q;
|
|
797
|
-
} else if (J(te)) {
|
|
798
|
-
let V = {};
|
|
799
|
-
for (const I in te) {
|
|
800
|
-
if (!oe(V) && !s)
|
|
801
|
-
break;
|
|
802
|
-
const $ = Rr(await te[I](R, r), ce, I);
|
|
803
|
-
$ && (V = {
|
|
804
|
-
...$,
|
|
805
|
-
...je(I, $.message)
|
|
806
|
-
}, re($.message), s && (q[Z] = V));
|
|
807
|
-
}
|
|
808
|
-
if (!oe(V) && (q[Z] = {
|
|
809
|
-
ref: ce,
|
|
810
|
-
...V
|
|
811
|
-
}, !s))
|
|
812
|
-
return q;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return re(!0), q;
|
|
816
|
-
};
|
|
817
|
-
const Bs = {
|
|
818
|
-
mode: ye.onSubmit,
|
|
819
|
-
reValidateMode: ye.onChange,
|
|
820
|
-
shouldFocusError: !0
|
|
821
|
-
};
|
|
822
|
-
function Ws(t = {}) {
|
|
823
|
-
let e = {
|
|
824
|
-
...Bs,
|
|
825
|
-
...t
|
|
826
|
-
}, r = {
|
|
827
|
-
submitCount: 0,
|
|
828
|
-
isDirty: !1,
|
|
829
|
-
isReady: !1,
|
|
830
|
-
isLoading: ge(e.defaultValues),
|
|
831
|
-
isValidating: !1,
|
|
832
|
-
isSubmitted: !1,
|
|
833
|
-
isSubmitting: !1,
|
|
834
|
-
isSubmitSuccessful: !1,
|
|
835
|
-
isValid: !1,
|
|
836
|
-
touchedFields: {},
|
|
837
|
-
dirtyFields: {},
|
|
838
|
-
validatingFields: {},
|
|
839
|
-
errors: e.errors || {},
|
|
840
|
-
disabled: e.disabled || !1
|
|
841
|
-
};
|
|
842
|
-
const s = {};
|
|
843
|
-
let n = J(e.defaultValues) || J(e.values) ? ee(e.defaultValues || e.values) || {} : {}, a = e.shouldUnregister ? {} : ee(n), i = {
|
|
844
|
-
action: !1,
|
|
845
|
-
mount: !1,
|
|
846
|
-
watch: !1
|
|
847
|
-
}, o = {
|
|
848
|
-
mount: /* @__PURE__ */ new Set(),
|
|
849
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
850
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
851
|
-
array: /* @__PURE__ */ new Set(),
|
|
852
|
-
watch: /* @__PURE__ */ new Set()
|
|
853
|
-
}, d, h = 0;
|
|
854
|
-
const f = {
|
|
855
|
-
isDirty: !1,
|
|
856
|
-
dirtyFields: !1,
|
|
857
|
-
validatingFields: !1,
|
|
858
|
-
touchedFields: !1,
|
|
859
|
-
isValidating: !1,
|
|
860
|
-
isValid: !1,
|
|
861
|
-
errors: !1
|
|
862
|
-
};
|
|
863
|
-
let x = {
|
|
864
|
-
...f
|
|
865
|
-
};
|
|
866
|
-
const S = {
|
|
867
|
-
array: kr(),
|
|
868
|
-
state: kr()
|
|
869
|
-
}, W = e.criteriaMode === ye.all, te = (c) => (l) => {
|
|
870
|
-
clearTimeout(h), h = setTimeout(c, l);
|
|
871
|
-
}, Z = async (c) => {
|
|
872
|
-
if (!e.disabled && (f.isValid || x.isValid || c)) {
|
|
873
|
-
const l = e.resolver ? oe((await xe()).errors) : await le(s, !0);
|
|
874
|
-
l !== r.isValid && S.state.next({
|
|
875
|
-
isValid: l
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
}, z = (c, l) => {
|
|
879
|
-
!e.disabled && (f.isValidating || f.validatingFields || x.isValidating || x.validatingFields) && ((c || Array.from(o.mount)).forEach((u) => {
|
|
880
|
-
u && (l ? D(r.validatingFields, u, l) : X(r.validatingFields, u));
|
|
881
|
-
}), S.state.next({
|
|
882
|
-
validatingFields: r.validatingFields,
|
|
883
|
-
isValidating: !oe(r.validatingFields)
|
|
884
|
-
}));
|
|
885
|
-
}, pe = (c, l = [], u, k, v = !0, g = !0) => {
|
|
886
|
-
if (k && u && !e.disabled) {
|
|
887
|
-
if (i.action = !0, g && Array.isArray(_(s, c))) {
|
|
888
|
-
const A = u(_(s, c), k.argA, k.argB);
|
|
889
|
-
v && D(s, c, A);
|
|
890
|
-
}
|
|
891
|
-
if (g && Array.isArray(_(r.errors, c))) {
|
|
892
|
-
const A = u(_(r.errors, c), k.argA, k.argB);
|
|
893
|
-
v && D(r.errors, c, A), Us(r.errors, c);
|
|
894
|
-
}
|
|
895
|
-
if ((f.touchedFields || x.touchedFields) && g && Array.isArray(_(r.touchedFields, c))) {
|
|
896
|
-
const A = u(_(r.touchedFields, c), k.argA, k.argB);
|
|
897
|
-
v && D(r.touchedFields, c, A);
|
|
898
|
-
}
|
|
899
|
-
(f.dirtyFields || x.dirtyFields) && (r.dirtyFields = ut(n, a)), S.state.next({
|
|
900
|
-
name: c,
|
|
901
|
-
isDirty: ie(c, l),
|
|
902
|
-
dirtyFields: r.dirtyFields,
|
|
903
|
-
errors: r.errors,
|
|
904
|
-
isValid: r.isValid
|
|
905
|
-
});
|
|
906
|
-
} else
|
|
907
|
-
D(a, c, l);
|
|
908
|
-
}, R = (c, l) => {
|
|
909
|
-
D(r.errors, c, l), S.state.next({
|
|
910
|
-
errors: r.errors
|
|
911
|
-
});
|
|
912
|
-
}, ce = (c) => {
|
|
913
|
-
r.errors = c, S.state.next({
|
|
914
|
-
errors: r.errors,
|
|
915
|
-
isValid: !1
|
|
916
|
-
});
|
|
917
|
-
}, re = (c, l, u, k) => {
|
|
918
|
-
const v = _(s, c);
|
|
919
|
-
if (v) {
|
|
920
|
-
const g = _(a, c, Y(u) ? _(n, c) : u);
|
|
921
|
-
Y(g) || k && k.defaultChecked || l ? D(a, c, l ? g : Ar(v._f)) : $(c, g), i.mount && Z();
|
|
922
|
-
}
|
|
923
|
-
}, q = (c, l, u, k, v) => {
|
|
924
|
-
let g = !1, A = !1;
|
|
925
|
-
const M = {
|
|
926
|
-
name: c
|
|
927
|
-
};
|
|
928
|
-
if (!e.disabled) {
|
|
929
|
-
if (!u || k) {
|
|
930
|
-
(f.isDirty || x.isDirty) && (A = r.isDirty, r.isDirty = M.isDirty = ie(), g = A !== M.isDirty);
|
|
931
|
-
const L = Ze(_(n, c), l);
|
|
932
|
-
A = !!_(r.dirtyFields, c), L ? X(r.dirtyFields, c) : D(r.dirtyFields, c, !0), M.dirtyFields = r.dirtyFields, g = g || (f.dirtyFields || x.dirtyFields) && A !== !L;
|
|
933
|
-
}
|
|
934
|
-
if (u) {
|
|
935
|
-
const L = _(r.touchedFields, c);
|
|
936
|
-
L || (D(r.touchedFields, c, u), M.touchedFields = r.touchedFields, g = g || (f.touchedFields || x.touchedFields) && L !== u);
|
|
937
|
-
}
|
|
938
|
-
g && v && S.state.next(M);
|
|
939
|
-
}
|
|
940
|
-
return g ? M : {};
|
|
941
|
-
}, Xe = (c, l, u, k) => {
|
|
942
|
-
const v = _(r.errors, c), g = (f.isValid || x.isValid) && fe(l) && r.isValid !== l;
|
|
943
|
-
if (e.delayError && u ? (d = te(() => R(c, u)), d(e.delayError)) : (clearTimeout(h), d = null, u ? D(r.errors, c, u) : X(r.errors, c)), (u ? !Ze(v, u) : v) || !oe(k) || g) {
|
|
944
|
-
const A = {
|
|
945
|
-
...k,
|
|
946
|
-
...g && fe(l) ? { isValid: l } : {},
|
|
947
|
-
errors: r.errors,
|
|
948
|
-
name: c
|
|
949
|
-
};
|
|
950
|
-
r = {
|
|
951
|
-
...r,
|
|
952
|
-
...A
|
|
953
|
-
}, S.state.next(A);
|
|
954
|
-
}
|
|
955
|
-
}, xe = async (c) => {
|
|
956
|
-
z(c, !0);
|
|
957
|
-
const l = await e.resolver(a, e.context, Is(c || o.mount, s, e.criteriaMode, e.shouldUseNativeValidation));
|
|
958
|
-
return z(c), l;
|
|
959
|
-
}, Qe = async (c) => {
|
|
960
|
-
const { errors: l } = await xe(c);
|
|
961
|
-
if (c)
|
|
962
|
-
for (const u of c) {
|
|
963
|
-
const k = _(l, u);
|
|
964
|
-
k ? D(r.errors, u, k) : X(r.errors, u);
|
|
965
|
-
}
|
|
966
|
-
else
|
|
967
|
-
r.errors = l;
|
|
968
|
-
return l;
|
|
969
|
-
}, le = async (c, l, u = {
|
|
970
|
-
valid: !0
|
|
971
|
-
}) => {
|
|
972
|
-
for (const k in c) {
|
|
973
|
-
const v = c[k];
|
|
974
|
-
if (v) {
|
|
975
|
-
const { _f: g, ...A } = v;
|
|
976
|
-
if (g) {
|
|
977
|
-
const M = o.array.has(g.name), L = v._f && Ds(v._f);
|
|
978
|
-
L && f.validatingFields && z([k], !0);
|
|
979
|
-
const me = await Or(v, o.disabled, a, W, e.shouldUseNativeValidation && !l, M);
|
|
980
|
-
if (L && f.validatingFields && z([k]), me[g.name] && (u.valid = !1, l))
|
|
981
|
-
break;
|
|
982
|
-
!l && (_(me, g.name) ? M ? zs(r.errors, me, g.name) : D(r.errors, g.name, me[g.name]) : X(r.errors, g.name));
|
|
983
|
-
}
|
|
984
|
-
!oe(A) && await le(A, l, u);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
return u.valid;
|
|
988
|
-
}, je = () => {
|
|
989
|
-
for (const c of o.unMount) {
|
|
990
|
-
const l = _(s, c);
|
|
991
|
-
l && (l._f.refs ? l._f.refs.every((u) => !Ht(u)) : !Ht(l._f.ref)) && Be(c);
|
|
992
|
-
}
|
|
993
|
-
o.unMount = /* @__PURE__ */ new Set();
|
|
994
|
-
}, ie = (c, l) => !e.disabled && (c && l && D(a, c, l), !Ze(m(), n)), V = (c, l, u) => Br(c, o, {
|
|
995
|
-
...i.mount ? a : Y(l) ? n : Te(c) ? { [c]: l } : l
|
|
996
|
-
}, u, l), I = (c) => Bt(_(i.mount ? a : n, c, e.shouldUnregister ? _(n, c, []) : [])), $ = (c, l, u = {}) => {
|
|
997
|
-
const k = _(s, c);
|
|
998
|
-
let v = l;
|
|
999
|
-
if (k) {
|
|
1000
|
-
const g = k._f;
|
|
1001
|
-
g && (!g.disabled && D(a, c, Gr(l, g)), v = Ft(g.ref) && ne(l) ? "" : l, qr(g.ref) ? [...g.ref.options].forEach((A) => A.selected = v.includes(A.value)) : g.refs ? jt(g.ref) ? g.refs.forEach((A) => {
|
|
1002
|
-
(!A.defaultChecked || !A.disabled) && (Array.isArray(v) ? A.checked = !!v.find((M) => M === A.value) : A.checked = v === A.value || !!v);
|
|
1003
|
-
}) : g.refs.forEach((A) => A.checked = A.value === v) : or(g.ref) ? g.ref.value = "" : (g.ref.value = v, g.ref.type || S.state.next({
|
|
1004
|
-
name: c,
|
|
1005
|
-
values: ee(a)
|
|
1006
|
-
})));
|
|
1007
|
-
}
|
|
1008
|
-
(u.shouldDirty || u.shouldTouch) && q(c, v, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && Ne(c);
|
|
1009
|
-
}, Q = (c, l, u) => {
|
|
1010
|
-
for (const k in l) {
|
|
1011
|
-
if (!l.hasOwnProperty(k))
|
|
1012
|
-
return;
|
|
1013
|
-
const v = l[k], g = c + "." + k, A = _(s, g);
|
|
1014
|
-
(o.array.has(c) || J(v) || A && !A._f) && !qe(v) ? Q(g, v, u) : $(g, v, u);
|
|
1015
|
-
}
|
|
1016
|
-
}, K = (c, l, u = {}) => {
|
|
1017
|
-
const k = _(s, c), v = o.array.has(c), g = ee(l);
|
|
1018
|
-
D(a, c, g), v ? (S.array.next({
|
|
1019
|
-
name: c,
|
|
1020
|
-
values: ee(a)
|
|
1021
|
-
}), (f.isDirty || f.dirtyFields || x.isDirty || x.dirtyFields) && u.shouldDirty && S.state.next({
|
|
1022
|
-
name: c,
|
|
1023
|
-
dirtyFields: ut(n, a),
|
|
1024
|
-
isDirty: ie(c, g)
|
|
1025
|
-
})) : k && !k._f && !ne(g) ? Q(c, g, u) : $(c, g, u), Nr(c, o) && S.state.next({ ...r }), S.state.next({
|
|
1026
|
-
name: i.mount ? c : void 0,
|
|
1027
|
-
values: ee(a)
|
|
1028
|
-
});
|
|
1029
|
-
}, ue = async (c) => {
|
|
1030
|
-
i.mount = !0;
|
|
1031
|
-
const l = c.target;
|
|
1032
|
-
let u = l.name, k = !0;
|
|
1033
|
-
const v = _(s, u), g = (L) => {
|
|
1034
|
-
k = Number.isNaN(L) || qe(L) && isNaN(L.getTime()) || Ze(L, _(a, u, L));
|
|
1035
|
-
}, A = Er(e.mode), M = Er(e.reValidateMode);
|
|
1036
|
-
if (v) {
|
|
1037
|
-
let L, me;
|
|
1038
|
-
const Ct = l.type ? Ar(v._f) : Lr(c), Ie = c.type === Vt.BLUR || c.type === Vt.FOCUS_OUT, ds = !Ms(v._f) && !e.resolver && !_(r.errors, u) && !v._f.deps || $s(Ie, _(r.touchedFields, u), r.isSubmitted, M, A), Yt = Nr(u, o, Ie);
|
|
1039
|
-
D(a, u, Ct), Ie ? (v._f.onBlur && v._f.onBlur(c), d && d(0)) : v._f.onChange && v._f.onChange(c);
|
|
1040
|
-
const Jt = q(u, Ct, Ie), fs = !oe(Jt) || Yt;
|
|
1041
|
-
if (!Ie && S.state.next({
|
|
1042
|
-
name: u,
|
|
1043
|
-
type: c.type,
|
|
1044
|
-
values: ee(a)
|
|
1045
|
-
}), ds)
|
|
1046
|
-
return (f.isValid || x.isValid) && (e.mode === "onBlur" ? Ie && Z() : Ie || Z()), fs && S.state.next({ name: u, ...Yt ? {} : Jt });
|
|
1047
|
-
if (!Ie && Yt && S.state.next({ ...r }), e.resolver) {
|
|
1048
|
-
const { errors: mr } = await xe([u]);
|
|
1049
|
-
if (g(Ct), k) {
|
|
1050
|
-
const hs = Cr(r.errors, s, u), pr = Cr(mr, s, hs.name || u);
|
|
1051
|
-
L = pr.error, u = pr.name, me = oe(mr);
|
|
1052
|
-
}
|
|
1053
|
-
} else
|
|
1054
|
-
z([u], !0), L = (await Or(v, o.disabled, a, W, e.shouldUseNativeValidation))[u], z([u]), g(Ct), k && (L ? me = !1 : (f.isValid || x.isValid) && (me = await le(s, !0)));
|
|
1055
|
-
k && (v._f.deps && Ne(v._f.deps), Xe(u, me, L, Jt));
|
|
1056
|
-
}
|
|
1057
|
-
}, Pe = (c, l) => {
|
|
1058
|
-
if (_(r.errors, l) && c.focus)
|
|
1059
|
-
return c.focus(), 1;
|
|
1060
|
-
}, Ne = async (c, l = {}) => {
|
|
1061
|
-
let u, k;
|
|
1062
|
-
const v = ft(c);
|
|
1063
|
-
if (e.resolver) {
|
|
1064
|
-
const g = await Qe(Y(c) ? c : v);
|
|
1065
|
-
u = oe(g), k = c ? !v.some((A) => _(g, A)) : u;
|
|
1066
|
-
} else c ? (k = (await Promise.all(v.map(async (g) => {
|
|
1067
|
-
const A = _(s, g);
|
|
1068
|
-
return await le(A && A._f ? { [g]: A } : A);
|
|
1069
|
-
}))).every(Boolean), !(!k && !r.isValid) && Z()) : k = u = await le(s);
|
|
1070
|
-
return S.state.next({
|
|
1071
|
-
...!Te(c) || (f.isValid || x.isValid) && u !== r.isValid ? {} : { name: c },
|
|
1072
|
-
...e.resolver || !c ? { isValid: u } : {},
|
|
1073
|
-
errors: r.errors
|
|
1074
|
-
}), l.shouldFocus && !k && ht(s, Pe, c ? v : o.mount), k;
|
|
1075
|
-
}, m = (c) => {
|
|
1076
|
-
const l = {
|
|
1077
|
-
...i.mount ? a : n
|
|
1078
|
-
};
|
|
1079
|
-
return Y(c) ? l : Te(c) ? _(l, c) : c.map((u) => _(l, u));
|
|
1080
|
-
}, C = (c, l) => ({
|
|
1081
|
-
invalid: !!_((l || r).errors, c),
|
|
1082
|
-
isDirty: !!_((l || r).dirtyFields, c),
|
|
1083
|
-
error: _((l || r).errors, c),
|
|
1084
|
-
isValidating: !!_(r.validatingFields, c),
|
|
1085
|
-
isTouched: !!_((l || r).touchedFields, c)
|
|
1086
|
-
}), U = (c) => {
|
|
1087
|
-
c && ft(c).forEach((l) => X(r.errors, l)), S.state.next({
|
|
1088
|
-
errors: c ? r.errors : {}
|
|
1089
|
-
});
|
|
1090
|
-
}, H = (c, l, u) => {
|
|
1091
|
-
const k = (_(s, c, { _f: {} })._f || {}).ref, v = _(r.errors, c) || {}, { ref: g, message: A, type: M, ...L } = v;
|
|
1092
|
-
D(r.errors, c, {
|
|
1093
|
-
...L,
|
|
1094
|
-
...l,
|
|
1095
|
-
ref: k
|
|
1096
|
-
}), S.state.next({
|
|
1097
|
-
name: c,
|
|
1098
|
-
errors: r.errors,
|
|
1099
|
-
isValid: !1
|
|
1100
|
-
}), u && u.shouldFocus && k && k.focus && k.focus();
|
|
1101
|
-
}, ke = (c, l) => ge(c) ? S.state.subscribe({
|
|
1102
|
-
next: (u) => c(V(void 0, l), u)
|
|
1103
|
-
}) : V(c, l, !0), de = (c) => S.state.subscribe({
|
|
1104
|
-
next: (l) => {
|
|
1105
|
-
Ls(c.name, l.name, c.exact) && Zs(l, c.formState || f, us, c.reRenderRoot) && c.callback({
|
|
1106
|
-
values: { ...a },
|
|
1107
|
-
...r,
|
|
1108
|
-
...l
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
}).unsubscribe, ot = (c) => (i.mount = !0, x = {
|
|
1112
|
-
...x,
|
|
1113
|
-
...c.formState
|
|
1114
|
-
}, de({
|
|
1115
|
-
...c,
|
|
1116
|
-
formState: x
|
|
1117
|
-
})), Be = (c, l = {}) => {
|
|
1118
|
-
for (const u of c ? ft(c) : o.mount)
|
|
1119
|
-
o.mount.delete(u), o.array.delete(u), l.keepValue || (X(s, u), X(a, u)), !l.keepError && X(r.errors, u), !l.keepDirty && X(r.dirtyFields, u), !l.keepTouched && X(r.touchedFields, u), !l.keepIsValidating && X(r.validatingFields, u), !e.shouldUnregister && !l.keepDefaultValue && X(n, u);
|
|
1120
|
-
S.state.next({
|
|
1121
|
-
values: ee(a)
|
|
1122
|
-
}), S.state.next({
|
|
1123
|
-
...r,
|
|
1124
|
-
...l.keepDirty ? { isDirty: ie() } : {}
|
|
1125
|
-
}), !l.keepIsValid && Z();
|
|
1126
|
-
}, G = ({ disabled: c, name: l }) => {
|
|
1127
|
-
(fe(c) && i.mount || c || o.disabled.has(l)) && (c ? o.disabled.add(l) : o.disabled.delete(l));
|
|
1128
|
-
}, we = (c, l = {}) => {
|
|
1129
|
-
let u = _(s, c);
|
|
1130
|
-
const k = fe(l.disabled) || fe(e.disabled);
|
|
1131
|
-
return D(s, c, {
|
|
1132
|
-
...u || {},
|
|
1133
|
-
_f: {
|
|
1134
|
-
...u && u._f ? u._f : { ref: { name: c } },
|
|
1135
|
-
name: c,
|
|
1136
|
-
mount: !0,
|
|
1137
|
-
...l
|
|
1138
|
-
}
|
|
1139
|
-
}), o.mount.add(c), u ? G({
|
|
1140
|
-
disabled: fe(l.disabled) ? l.disabled : e.disabled,
|
|
1141
|
-
name: c
|
|
1142
|
-
}) : re(c, !0, l.value), {
|
|
1143
|
-
...k ? { disabled: l.disabled || e.disabled } : {},
|
|
1144
|
-
...e.progressive ? {
|
|
1145
|
-
required: !!l.required,
|
|
1146
|
-
min: dt(l.min),
|
|
1147
|
-
max: dt(l.max),
|
|
1148
|
-
minLength: dt(l.minLength),
|
|
1149
|
-
maxLength: dt(l.maxLength),
|
|
1150
|
-
pattern: dt(l.pattern)
|
|
1151
|
-
} : {},
|
|
1152
|
-
name: c,
|
|
1153
|
-
onChange: ue,
|
|
1154
|
-
onBlur: ue,
|
|
1155
|
-
ref: (v) => {
|
|
1156
|
-
if (v) {
|
|
1157
|
-
we(c, l), u = _(s, c);
|
|
1158
|
-
const g = Y(v.value) && v.querySelectorAll && v.querySelectorAll("input,select,textarea")[0] || v, A = Vs(g), M = u._f.refs || [];
|
|
1159
|
-
if (A ? M.find((L) => L === g) : g === u._f.ref)
|
|
1160
|
-
return;
|
|
1161
|
-
D(s, c, {
|
|
1162
|
-
_f: {
|
|
1163
|
-
...u._f,
|
|
1164
|
-
...A ? {
|
|
1165
|
-
refs: [
|
|
1166
|
-
...M.filter(Ht),
|
|
1167
|
-
g,
|
|
1168
|
-
...Array.isArray(_(n, c)) ? [{}] : []
|
|
1169
|
-
],
|
|
1170
|
-
ref: { type: g.type, name: c }
|
|
1171
|
-
} : { ref: g }
|
|
1172
|
-
}
|
|
1173
|
-
}), re(c, !1, void 0, g);
|
|
1174
|
-
} else
|
|
1175
|
-
u = _(s, c, {}), u._f && (u._f.mount = !1), (e.shouldUnregister || l.shouldUnregister) && !($r(o.array, c) && i.action) && o.unMount.add(c);
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
}, We = () => e.shouldFocusError && ht(s, Pe, o.mount), qt = (c) => {
|
|
1179
|
-
fe(c) && (S.state.next({ disabled: c }), ht(s, (l, u) => {
|
|
1180
|
-
const k = _(s, u);
|
|
1181
|
-
k && (l.disabled = k._f.disabled || c, Array.isArray(k._f.refs) && k._f.refs.forEach((v) => {
|
|
1182
|
-
v.disabled = k._f.disabled || c;
|
|
1183
|
-
}));
|
|
1184
|
-
}, 0, !1));
|
|
1185
|
-
}, ur = (c, l) => async (u) => {
|
|
1186
|
-
let k;
|
|
1187
|
-
u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
|
|
1188
|
-
let v = ee(a);
|
|
1189
|
-
if (S.state.next({
|
|
1190
|
-
isSubmitting: !0
|
|
1191
|
-
}), e.resolver) {
|
|
1192
|
-
const { errors: g, values: A } = await xe();
|
|
1193
|
-
r.errors = g, v = A;
|
|
1194
|
-
} else
|
|
1195
|
-
await le(s);
|
|
1196
|
-
if (o.disabled.size)
|
|
1197
|
-
for (const g of o.disabled)
|
|
1198
|
-
D(v, g, void 0);
|
|
1199
|
-
if (X(r.errors, "root"), oe(r.errors)) {
|
|
1200
|
-
S.state.next({
|
|
1201
|
-
errors: {}
|
|
1202
|
-
});
|
|
1203
|
-
try {
|
|
1204
|
-
await c(v, u);
|
|
1205
|
-
} catch (g) {
|
|
1206
|
-
k = g;
|
|
1207
|
-
}
|
|
1208
|
-
} else
|
|
1209
|
-
l && await l({ ...r.errors }, u), We(), setTimeout(We);
|
|
1210
|
-
if (S.state.next({
|
|
1211
|
-
isSubmitted: !0,
|
|
1212
|
-
isSubmitting: !1,
|
|
1213
|
-
isSubmitSuccessful: oe(r.errors) && !k,
|
|
1214
|
-
submitCount: r.submitCount + 1,
|
|
1215
|
-
errors: r.errors
|
|
1216
|
-
}), k)
|
|
1217
|
-
throw k;
|
|
1218
|
-
}, cs = (c, l = {}) => {
|
|
1219
|
-
_(s, c) && (Y(l.defaultValue) ? K(c, ee(_(n, c))) : (K(c, l.defaultValue), D(n, c, ee(l.defaultValue))), l.keepTouched || X(r.touchedFields, c), l.keepDirty || (X(r.dirtyFields, c), r.isDirty = l.defaultValue ? ie(c, ee(_(n, c))) : ie()), l.keepError || (X(r.errors, c), f.isValid && Z()), S.state.next({ ...r }));
|
|
1220
|
-
}, dr = (c, l = {}) => {
|
|
1221
|
-
const u = c ? ee(c) : n, k = ee(u), v = oe(c), g = v ? n : k;
|
|
1222
|
-
if (l.keepDefaultValues || (n = u), !l.keepValues) {
|
|
1223
|
-
if (l.keepDirtyValues) {
|
|
1224
|
-
const A = /* @__PURE__ */ new Set([
|
|
1225
|
-
...o.mount,
|
|
1226
|
-
...Object.keys(ut(n, a))
|
|
1227
|
-
]);
|
|
1228
|
-
for (const M of Array.from(A))
|
|
1229
|
-
_(r.dirtyFields, M) ? D(g, M, _(a, M)) : K(M, _(g, M));
|
|
1230
|
-
} else {
|
|
1231
|
-
if (sr && Y(c))
|
|
1232
|
-
for (const A of o.mount) {
|
|
1233
|
-
const M = _(s, A);
|
|
1234
|
-
if (M && M._f) {
|
|
1235
|
-
const L = Array.isArray(M._f.refs) ? M._f.refs[0] : M._f.ref;
|
|
1236
|
-
if (Ft(L)) {
|
|
1237
|
-
const me = L.closest("form");
|
|
1238
|
-
if (me) {
|
|
1239
|
-
me.reset();
|
|
1240
|
-
break;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
for (const A of o.mount)
|
|
1246
|
-
K(A, _(g, A));
|
|
1247
|
-
}
|
|
1248
|
-
a = ee(g), S.array.next({
|
|
1249
|
-
values: { ...g }
|
|
1250
|
-
}), S.state.next({
|
|
1251
|
-
values: { ...g }
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
o = {
|
|
1255
|
-
mount: l.keepDirtyValues ? o.mount : /* @__PURE__ */ new Set(),
|
|
1256
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
1257
|
-
array: /* @__PURE__ */ new Set(),
|
|
1258
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
1259
|
-
watch: /* @__PURE__ */ new Set(),
|
|
1260
|
-
watchAll: !1,
|
|
1261
|
-
focus: ""
|
|
1262
|
-
}, i.mount = !f.isValid || !!l.keepIsValid || !!l.keepDirtyValues, i.watch = !!e.shouldUnregister, S.state.next({
|
|
1263
|
-
submitCount: l.keepSubmitCount ? r.submitCount : 0,
|
|
1264
|
-
isDirty: v ? !1 : l.keepDirty ? r.isDirty : !!(l.keepDefaultValues && !Ze(c, n)),
|
|
1265
|
-
isSubmitted: l.keepIsSubmitted ? r.isSubmitted : !1,
|
|
1266
|
-
dirtyFields: v ? {} : l.keepDirtyValues ? l.keepDefaultValues && a ? ut(n, a) : r.dirtyFields : l.keepDefaultValues && c ? ut(n, c) : l.keepDirty ? r.dirtyFields : {},
|
|
1267
|
-
touchedFields: l.keepTouched ? r.touchedFields : {},
|
|
1268
|
-
errors: l.keepErrors ? r.errors : {},
|
|
1269
|
-
isSubmitSuccessful: l.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
1270
|
-
isSubmitting: !1
|
|
1271
|
-
});
|
|
1272
|
-
}, fr = (c, l) => dr(ge(c) ? c(a) : c, l), ls = (c, l = {}) => {
|
|
1273
|
-
const u = _(s, c), k = u && u._f;
|
|
1274
|
-
if (k) {
|
|
1275
|
-
const v = k.refs ? k.refs[0] : k.ref;
|
|
1276
|
-
v.focus && (v.focus(), l.shouldSelect && ge(v.select) && v.select());
|
|
1277
|
-
}
|
|
1278
|
-
}, us = (c) => {
|
|
1279
|
-
r = {
|
|
1280
|
-
...r,
|
|
1281
|
-
...c
|
|
1282
|
-
};
|
|
1283
|
-
}, hr = {
|
|
1284
|
-
control: {
|
|
1285
|
-
register: we,
|
|
1286
|
-
unregister: Be,
|
|
1287
|
-
getFieldState: C,
|
|
1288
|
-
handleSubmit: ur,
|
|
1289
|
-
setError: H,
|
|
1290
|
-
_subscribe: de,
|
|
1291
|
-
_runSchema: xe,
|
|
1292
|
-
_focusError: We,
|
|
1293
|
-
_getWatch: V,
|
|
1294
|
-
_getDirty: ie,
|
|
1295
|
-
_setValid: Z,
|
|
1296
|
-
_setFieldArray: pe,
|
|
1297
|
-
_setDisabledField: G,
|
|
1298
|
-
_setErrors: ce,
|
|
1299
|
-
_getFieldArray: I,
|
|
1300
|
-
_reset: dr,
|
|
1301
|
-
_resetDefaultValues: () => ge(e.defaultValues) && e.defaultValues().then((c) => {
|
|
1302
|
-
fr(c, e.resetOptions), S.state.next({
|
|
1303
|
-
isLoading: !1
|
|
1304
|
-
});
|
|
1305
|
-
}),
|
|
1306
|
-
_removeUnmounted: je,
|
|
1307
|
-
_disableForm: qt,
|
|
1308
|
-
_subjects: S,
|
|
1309
|
-
_proxyFormState: f,
|
|
1310
|
-
get _fields() {
|
|
1311
|
-
return s;
|
|
1312
|
-
},
|
|
1313
|
-
get _formValues() {
|
|
1314
|
-
return a;
|
|
1315
|
-
},
|
|
1316
|
-
get _state() {
|
|
1317
|
-
return i;
|
|
1318
|
-
},
|
|
1319
|
-
set _state(c) {
|
|
1320
|
-
i = c;
|
|
1321
|
-
},
|
|
1322
|
-
get _defaultValues() {
|
|
1323
|
-
return n;
|
|
1324
|
-
},
|
|
1325
|
-
get _names() {
|
|
1326
|
-
return o;
|
|
1327
|
-
},
|
|
1328
|
-
set _names(c) {
|
|
1329
|
-
o = c;
|
|
1330
|
-
},
|
|
1331
|
-
get _formState() {
|
|
1332
|
-
return r;
|
|
1333
|
-
},
|
|
1334
|
-
get _options() {
|
|
1335
|
-
return e;
|
|
1336
|
-
},
|
|
1337
|
-
set _options(c) {
|
|
1338
|
-
e = {
|
|
1339
|
-
...e,
|
|
1340
|
-
...c
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
},
|
|
1344
|
-
subscribe: ot,
|
|
1345
|
-
trigger: Ne,
|
|
1346
|
-
register: we,
|
|
1347
|
-
handleSubmit: ur,
|
|
1348
|
-
watch: ke,
|
|
1349
|
-
setValue: K,
|
|
1350
|
-
getValues: m,
|
|
1351
|
-
reset: fr,
|
|
1352
|
-
resetField: cs,
|
|
1353
|
-
clearErrors: U,
|
|
1354
|
-
unregister: Be,
|
|
1355
|
-
setError: H,
|
|
1356
|
-
setFocus: ls,
|
|
1357
|
-
getFieldState: C
|
|
1358
|
-
};
|
|
1359
|
-
return {
|
|
1360
|
-
...hr,
|
|
1361
|
-
formControl: hr
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
function qs(t = {}) {
|
|
1365
|
-
const e = P.useRef(void 0), r = P.useRef(void 0), [s, n] = P.useState({
|
|
1366
|
-
isDirty: !1,
|
|
1367
|
-
isValidating: !1,
|
|
1368
|
-
isLoading: ge(t.defaultValues),
|
|
1369
|
-
isSubmitted: !1,
|
|
1370
|
-
isSubmitting: !1,
|
|
1371
|
-
isSubmitSuccessful: !1,
|
|
1372
|
-
isValid: !1,
|
|
1373
|
-
submitCount: 0,
|
|
1374
|
-
dirtyFields: {},
|
|
1375
|
-
touchedFields: {},
|
|
1376
|
-
validatingFields: {},
|
|
1377
|
-
errors: t.errors || {},
|
|
1378
|
-
disabled: t.disabled || !1,
|
|
1379
|
-
isReady: !1,
|
|
1380
|
-
defaultValues: ge(t.defaultValues) ? void 0 : t.defaultValues
|
|
1381
|
-
});
|
|
1382
|
-
e.current || (e.current = {
|
|
1383
|
-
...t.formControl ? t.formControl : Ws(t),
|
|
1384
|
-
formState: s
|
|
1385
|
-
}, t.formControl && t.defaultValues && !ge(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions));
|
|
1386
|
-
const a = e.current.control;
|
|
1387
|
-
return a._options = t, ir(() => {
|
|
1388
|
-
const i = a._subscribe({
|
|
1389
|
-
formState: a._proxyFormState,
|
|
1390
|
-
callback: () => n({ ...a._formState }),
|
|
1391
|
-
reRenderRoot: !0
|
|
1392
|
-
});
|
|
1393
|
-
return n((o) => ({
|
|
1394
|
-
...o,
|
|
1395
|
-
isReady: !0
|
|
1396
|
-
})), a._formState.isReady = !0, i;
|
|
1397
|
-
}, [a]), P.useEffect(() => a._disableForm(t.disabled), [a, t.disabled]), P.useEffect(() => {
|
|
1398
|
-
t.mode && (a._options.mode = t.mode), t.reValidateMode && (a._options.reValidateMode = t.reValidateMode);
|
|
1399
|
-
}, [a, t.mode, t.reValidateMode]), P.useEffect(() => {
|
|
1400
|
-
t.errors && (a._setErrors(t.errors), a._focusError());
|
|
1401
|
-
}, [a, t.errors]), P.useEffect(() => {
|
|
1402
|
-
t.shouldUnregister && a._subjects.state.next({
|
|
1403
|
-
values: a._getWatch()
|
|
1404
|
-
});
|
|
1405
|
-
}, [a, t.shouldUnregister]), P.useEffect(() => {
|
|
1406
|
-
if (a._proxyFormState.isDirty) {
|
|
1407
|
-
const i = a._getDirty();
|
|
1408
|
-
i !== s.isDirty && a._subjects.state.next({
|
|
1409
|
-
isDirty: i
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
}, [a, s.isDirty]), P.useEffect(() => {
|
|
1413
|
-
t.values && !Ze(t.values, r.current) ? (a._reset(t.values, a._options.resetOptions), r.current = t.values, n((i) => ({ ...i }))) : a._resetDefaultValues();
|
|
1414
|
-
}, [a, t.values]), P.useEffect(() => {
|
|
1415
|
-
a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
|
|
1416
|
-
}), e.current.formState = zr(s, a), e.current;
|
|
1417
|
-
}
|
|
1418
|
-
const Vr = (t, e, r) => {
|
|
1419
|
-
if (t && "reportValidity" in t) {
|
|
1420
|
-
const s = _(r, e);
|
|
1421
|
-
t.setCustomValidity(s && s.message || ""), t.reportValidity();
|
|
1422
|
-
}
|
|
1423
|
-
}, Qr = (t, e) => {
|
|
1424
|
-
for (const r in e.fields) {
|
|
1425
|
-
const s = e.fields[r];
|
|
1426
|
-
s && s.ref && "reportValidity" in s.ref ? Vr(s.ref, r, t) : s && s.refs && s.refs.forEach((n) => Vr(n, r, t));
|
|
1427
|
-
}
|
|
1428
|
-
}, Ys = (t, e) => {
|
|
1429
|
-
e.shouldUseNativeValidation && Qr(t, e);
|
|
1430
|
-
const r = {};
|
|
1431
|
-
for (const s in t) {
|
|
1432
|
-
const n = _(e.fields, s), a = Object.assign(t[s] || {}, { ref: n && n.ref });
|
|
1433
|
-
if (Js(e.names || Object.keys(t), s)) {
|
|
1434
|
-
const i = Object.assign({}, _(r, s));
|
|
1435
|
-
D(i, "root", a), D(r, s, i);
|
|
1436
|
-
} else D(r, s, a);
|
|
1437
|
-
}
|
|
1438
|
-
return r;
|
|
1439
|
-
}, Js = (t, e) => {
|
|
1440
|
-
const r = Fr(e);
|
|
1441
|
-
return t.some((s) => Fr(s).match(`^${r}\\.\\d+`));
|
|
1442
|
-
};
|
|
1443
|
-
function Fr(t) {
|
|
1444
|
-
return t.replace(/\]|\[/g, "");
|
|
1445
|
-
}
|
|
1446
|
-
function Hs(t, e) {
|
|
1447
|
-
for (var r = {}; t.length; ) {
|
|
1448
|
-
var s = t[0], n = s.code, a = s.message, i = s.path.join(".");
|
|
1449
|
-
if (!r[i]) if ("unionErrors" in s) {
|
|
1450
|
-
var o = s.unionErrors[0].errors[0];
|
|
1451
|
-
r[i] = { message: o.message, type: o.code };
|
|
1452
|
-
} else r[i] = { message: a, type: n };
|
|
1453
|
-
if ("unionErrors" in s && s.unionErrors.forEach(function(f) {
|
|
1454
|
-
return f.errors.forEach(function(x) {
|
|
1455
|
-
return t.push(x);
|
|
1456
|
-
});
|
|
1457
|
-
}), e) {
|
|
1458
|
-
var d = r[i].types, h = d && d[s.code];
|
|
1459
|
-
r[i] = Wr(i, e, r, n, h ? [].concat(h, s.message) : s.message);
|
|
1460
|
-
}
|
|
1461
|
-
t.shift();
|
|
1462
|
-
}
|
|
1463
|
-
return r;
|
|
1464
|
-
}
|
|
1465
|
-
function Gs(t, e, r) {
|
|
1466
|
-
return r === void 0 && (r = {}), function(s, n, a) {
|
|
1467
|
-
try {
|
|
1468
|
-
return Promise.resolve(function(i, o) {
|
|
1469
|
-
try {
|
|
1470
|
-
var d = Promise.resolve(t[r.mode === "sync" ? "parse" : "parseAsync"](s, e)).then(function(h) {
|
|
1471
|
-
return a.shouldUseNativeValidation && Qr({}, a), { errors: {}, values: r.raw ? Object.assign({}, s) : h };
|
|
1472
|
-
});
|
|
1473
|
-
} catch (h) {
|
|
1474
|
-
return o(h);
|
|
1475
|
-
}
|
|
1476
|
-
return d && d.then ? d.then(void 0, o) : d;
|
|
1477
|
-
}(0, function(i) {
|
|
1478
|
-
if (function(o) {
|
|
1479
|
-
return Array.isArray(o == null ? void 0 : o.errors);
|
|
1480
|
-
}(i)) return { values: {}, errors: Ys(Hs(i.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a) };
|
|
1481
|
-
throw i;
|
|
1482
|
-
}));
|
|
1483
|
-
} catch (i) {
|
|
1484
|
-
return Promise.reject(i);
|
|
1485
|
-
}
|
|
1486
|
-
};
|
|
1487
|
-
}
|
|
1488
|
-
var F;
|
|
1489
|
-
(function(t) {
|
|
1490
|
-
t.assertEqual = (n) => {
|
|
1491
|
-
};
|
|
1492
|
-
function e(n) {
|
|
1493
|
-
}
|
|
1494
|
-
t.assertIs = e;
|
|
1495
|
-
function r(n) {
|
|
1496
|
-
throw new Error();
|
|
1497
|
-
}
|
|
1498
|
-
t.assertNever = r, t.arrayToEnum = (n) => {
|
|
1499
|
-
const a = {};
|
|
1500
|
-
for (const i of n)
|
|
1501
|
-
a[i] = i;
|
|
1502
|
-
return a;
|
|
1503
|
-
}, t.getValidEnumValues = (n) => {
|
|
1504
|
-
const a = t.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
1505
|
-
for (const o of a)
|
|
1506
|
-
i[o] = n[o];
|
|
1507
|
-
return t.objectValues(i);
|
|
1508
|
-
}, t.objectValues = (n) => t.objectKeys(n).map(function(a) {
|
|
1509
|
-
return n[a];
|
|
1510
|
-
}), t.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
1511
|
-
const a = [];
|
|
1512
|
-
for (const i in n)
|
|
1513
|
-
Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
|
|
1514
|
-
return a;
|
|
1515
|
-
}, t.find = (n, a) => {
|
|
1516
|
-
for (const i of n)
|
|
1517
|
-
if (a(i))
|
|
1518
|
-
return i;
|
|
1519
|
-
}, t.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
1520
|
-
function s(n, a = " | ") {
|
|
1521
|
-
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
1522
|
-
}
|
|
1523
|
-
t.joinValues = s, t.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
1524
|
-
})(F || (F = {}));
|
|
1525
|
-
var Kt;
|
|
1526
|
-
(function(t) {
|
|
1527
|
-
t.mergeShapes = (e, r) => ({
|
|
1528
|
-
...e,
|
|
1529
|
-
...r
|
|
1530
|
-
// second overwrites first
|
|
1531
|
-
});
|
|
1532
|
-
})(Kt || (Kt = {}));
|
|
1533
|
-
const w = F.arrayToEnum([
|
|
1534
|
-
"string",
|
|
1535
|
-
"nan",
|
|
1536
|
-
"number",
|
|
1537
|
-
"integer",
|
|
1538
|
-
"float",
|
|
1539
|
-
"boolean",
|
|
1540
|
-
"date",
|
|
1541
|
-
"bigint",
|
|
1542
|
-
"symbol",
|
|
1543
|
-
"function",
|
|
1544
|
-
"undefined",
|
|
1545
|
-
"null",
|
|
1546
|
-
"array",
|
|
1547
|
-
"object",
|
|
1548
|
-
"unknown",
|
|
1549
|
-
"promise",
|
|
1550
|
-
"void",
|
|
1551
|
-
"never",
|
|
1552
|
-
"map",
|
|
1553
|
-
"set"
|
|
1554
|
-
]), Ve = (t) => {
|
|
1555
|
-
switch (typeof t) {
|
|
1556
|
-
case "undefined":
|
|
1557
|
-
return w.undefined;
|
|
1558
|
-
case "string":
|
|
1559
|
-
return w.string;
|
|
1560
|
-
case "number":
|
|
1561
|
-
return Number.isNaN(t) ? w.nan : w.number;
|
|
1562
|
-
case "boolean":
|
|
1563
|
-
return w.boolean;
|
|
1564
|
-
case "function":
|
|
1565
|
-
return w.function;
|
|
1566
|
-
case "bigint":
|
|
1567
|
-
return w.bigint;
|
|
1568
|
-
case "symbol":
|
|
1569
|
-
return w.symbol;
|
|
1570
|
-
case "object":
|
|
1571
|
-
return Array.isArray(t) ? w.array : t === null ? w.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? w.promise : typeof Map < "u" && t instanceof Map ? w.map : typeof Set < "u" && t instanceof Set ? w.set : typeof Date < "u" && t instanceof Date ? w.date : w.object;
|
|
1572
|
-
default:
|
|
1573
|
-
return w.unknown;
|
|
1574
|
-
}
|
|
1575
|
-
}, p = F.arrayToEnum([
|
|
1576
|
-
"invalid_type",
|
|
1577
|
-
"invalid_literal",
|
|
1578
|
-
"custom",
|
|
1579
|
-
"invalid_union",
|
|
1580
|
-
"invalid_union_discriminator",
|
|
1581
|
-
"invalid_enum_value",
|
|
1582
|
-
"unrecognized_keys",
|
|
1583
|
-
"invalid_arguments",
|
|
1584
|
-
"invalid_return_type",
|
|
1585
|
-
"invalid_date",
|
|
1586
|
-
"invalid_string",
|
|
1587
|
-
"too_small",
|
|
1588
|
-
"too_big",
|
|
1589
|
-
"invalid_intersection_types",
|
|
1590
|
-
"not_multiple_of",
|
|
1591
|
-
"not_finite"
|
|
1592
|
-
]), Xs = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
1593
|
-
class he extends Error {
|
|
1594
|
-
get errors() {
|
|
1595
|
-
return this.issues;
|
|
1596
|
-
}
|
|
1597
|
-
constructor(e) {
|
|
1598
|
-
super(), this.issues = [], this.addIssue = (s) => {
|
|
1599
|
-
this.issues = [...this.issues, s];
|
|
1600
|
-
}, this.addIssues = (s = []) => {
|
|
1601
|
-
this.issues = [...this.issues, ...s];
|
|
1602
|
-
};
|
|
1603
|
-
const r = new.target.prototype;
|
|
1604
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
|
|
1605
|
-
}
|
|
1606
|
-
format(e) {
|
|
1607
|
-
const r = e || function(a) {
|
|
1608
|
-
return a.message;
|
|
1609
|
-
}, s = { _errors: [] }, n = (a) => {
|
|
1610
|
-
for (const i of a.issues)
|
|
1611
|
-
if (i.code === "invalid_union")
|
|
1612
|
-
i.unionErrors.map(n);
|
|
1613
|
-
else if (i.code === "invalid_return_type")
|
|
1614
|
-
n(i.returnTypeError);
|
|
1615
|
-
else if (i.code === "invalid_arguments")
|
|
1616
|
-
n(i.argumentsError);
|
|
1617
|
-
else if (i.path.length === 0)
|
|
1618
|
-
s._errors.push(r(i));
|
|
1619
|
-
else {
|
|
1620
|
-
let o = s, d = 0;
|
|
1621
|
-
for (; d < i.path.length; ) {
|
|
1622
|
-
const h = i.path[d];
|
|
1623
|
-
d === i.path.length - 1 ? (o[h] = o[h] || { _errors: [] }, o[h]._errors.push(r(i))) : o[h] = o[h] || { _errors: [] }, o = o[h], d++;
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
};
|
|
1627
|
-
return n(this), s;
|
|
1628
|
-
}
|
|
1629
|
-
static assert(e) {
|
|
1630
|
-
if (!(e instanceof he))
|
|
1631
|
-
throw new Error(`Not a ZodError: ${e}`);
|
|
1632
|
-
}
|
|
1633
|
-
toString() {
|
|
1634
|
-
return this.message;
|
|
1635
|
-
}
|
|
1636
|
-
get message() {
|
|
1637
|
-
return JSON.stringify(this.issues, F.jsonStringifyReplacer, 2);
|
|
1638
|
-
}
|
|
1639
|
-
get isEmpty() {
|
|
1640
|
-
return this.issues.length === 0;
|
|
1641
|
-
}
|
|
1642
|
-
flatten(e = (r) => r.message) {
|
|
1643
|
-
const r = {}, s = [];
|
|
1644
|
-
for (const n of this.issues)
|
|
1645
|
-
n.path.length > 0 ? (r[n.path[0]] = r[n.path[0]] || [], r[n.path[0]].push(e(n))) : s.push(e(n));
|
|
1646
|
-
return { formErrors: s, fieldErrors: r };
|
|
1647
|
-
}
|
|
1648
|
-
get formErrors() {
|
|
1649
|
-
return this.flatten();
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
he.create = (t) => new he(t);
|
|
1653
|
-
const nt = (t, e) => {
|
|
1654
|
-
let r;
|
|
1655
|
-
switch (t.code) {
|
|
1656
|
-
case p.invalid_type:
|
|
1657
|
-
t.received === w.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
|
|
1658
|
-
break;
|
|
1659
|
-
case p.invalid_literal:
|
|
1660
|
-
r = `Invalid literal value, expected ${JSON.stringify(t.expected, F.jsonStringifyReplacer)}`;
|
|
1661
|
-
break;
|
|
1662
|
-
case p.unrecognized_keys:
|
|
1663
|
-
r = `Unrecognized key(s) in object: ${F.joinValues(t.keys, ", ")}`;
|
|
1664
|
-
break;
|
|
1665
|
-
case p.invalid_union:
|
|
1666
|
-
r = "Invalid input";
|
|
1667
|
-
break;
|
|
1668
|
-
case p.invalid_union_discriminator:
|
|
1669
|
-
r = `Invalid discriminator value. Expected ${F.joinValues(t.options)}`;
|
|
1670
|
-
break;
|
|
1671
|
-
case p.invalid_enum_value:
|
|
1672
|
-
r = `Invalid enum value. Expected ${F.joinValues(t.options)}, received '${t.received}'`;
|
|
1673
|
-
break;
|
|
1674
|
-
case p.invalid_arguments:
|
|
1675
|
-
r = "Invalid function arguments";
|
|
1676
|
-
break;
|
|
1677
|
-
case p.invalid_return_type:
|
|
1678
|
-
r = "Invalid function return type";
|
|
1679
|
-
break;
|
|
1680
|
-
case p.invalid_date:
|
|
1681
|
-
r = "Invalid date";
|
|
1682
|
-
break;
|
|
1683
|
-
case p.invalid_string:
|
|
1684
|
-
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : F.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
|
|
1685
|
-
break;
|
|
1686
|
-
case p.too_small:
|
|
1687
|
-
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
|
|
1688
|
-
break;
|
|
1689
|
-
case p.too_big:
|
|
1690
|
-
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
|
|
1691
|
-
break;
|
|
1692
|
-
case p.custom:
|
|
1693
|
-
r = "Invalid input";
|
|
1694
|
-
break;
|
|
1695
|
-
case p.invalid_intersection_types:
|
|
1696
|
-
r = "Intersection results could not be merged";
|
|
1697
|
-
break;
|
|
1698
|
-
case p.not_multiple_of:
|
|
1699
|
-
r = `Number must be a multiple of ${t.multipleOf}`;
|
|
1700
|
-
break;
|
|
1701
|
-
case p.not_finite:
|
|
1702
|
-
r = "Number must be finite";
|
|
1703
|
-
break;
|
|
1704
|
-
default:
|
|
1705
|
-
r = e.defaultError, F.assertNever(t);
|
|
1706
|
-
}
|
|
1707
|
-
return { message: r };
|
|
1708
|
-
};
|
|
1709
|
-
let Kr = nt;
|
|
1710
|
-
function Qs(t) {
|
|
1711
|
-
Kr = t;
|
|
1712
|
-
}
|
|
1713
|
-
function Dt() {
|
|
1714
|
-
return Kr;
|
|
1715
|
-
}
|
|
1716
|
-
const Mt = (t) => {
|
|
1717
|
-
const { data: e, path: r, errorMaps: s, issueData: n } = t, a = [...r, ...n.path || []], i = {
|
|
1718
|
-
...n,
|
|
1719
|
-
path: a
|
|
1720
|
-
};
|
|
1721
|
-
if (n.message !== void 0)
|
|
1722
|
-
return {
|
|
1723
|
-
...n,
|
|
1724
|
-
path: a,
|
|
1725
|
-
message: n.message
|
|
1726
|
-
};
|
|
1727
|
-
let o = "";
|
|
1728
|
-
const d = s.filter((h) => !!h).slice().reverse();
|
|
1729
|
-
for (const h of d)
|
|
1730
|
-
o = h(i, { data: e, defaultError: o }).message;
|
|
1731
|
-
return {
|
|
1732
|
-
...n,
|
|
1733
|
-
path: a,
|
|
1734
|
-
message: o
|
|
1735
|
-
};
|
|
1736
|
-
}, Ks = [];
|
|
1737
|
-
function b(t, e) {
|
|
1738
|
-
const r = Dt(), s = Mt({
|
|
1739
|
-
issueData: e,
|
|
1740
|
-
data: t.data,
|
|
1741
|
-
path: t.path,
|
|
1742
|
-
errorMaps: [
|
|
1743
|
-
t.common.contextualErrorMap,
|
|
1744
|
-
// contextual error map is first priority
|
|
1745
|
-
t.schemaErrorMap,
|
|
1746
|
-
// then schema-bound map if available
|
|
1747
|
-
r,
|
|
1748
|
-
// then global override map
|
|
1749
|
-
r === nt ? void 0 : nt
|
|
1750
|
-
// then global default map
|
|
1751
|
-
].filter((n) => !!n)
|
|
1752
|
-
});
|
|
1753
|
-
t.common.issues.push(s);
|
|
1754
|
-
}
|
|
1755
|
-
class se {
|
|
1756
|
-
constructor() {
|
|
1757
|
-
this.value = "valid";
|
|
1758
|
-
}
|
|
1759
|
-
dirty() {
|
|
1760
|
-
this.value === "valid" && (this.value = "dirty");
|
|
1761
|
-
}
|
|
1762
|
-
abort() {
|
|
1763
|
-
this.value !== "aborted" && (this.value = "aborted");
|
|
1764
|
-
}
|
|
1765
|
-
static mergeArray(e, r) {
|
|
1766
|
-
const s = [];
|
|
1767
|
-
for (const n of r) {
|
|
1768
|
-
if (n.status === "aborted")
|
|
1769
|
-
return E;
|
|
1770
|
-
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
1771
|
-
}
|
|
1772
|
-
return { status: e.value, value: s };
|
|
1773
|
-
}
|
|
1774
|
-
static async mergeObjectAsync(e, r) {
|
|
1775
|
-
const s = [];
|
|
1776
|
-
for (const n of r) {
|
|
1777
|
-
const a = await n.key, i = await n.value;
|
|
1778
|
-
s.push({
|
|
1779
|
-
key: a,
|
|
1780
|
-
value: i
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
return se.mergeObjectSync(e, s);
|
|
1784
|
-
}
|
|
1785
|
-
static mergeObjectSync(e, r) {
|
|
1786
|
-
const s = {};
|
|
1787
|
-
for (const n of r) {
|
|
1788
|
-
const { key: a, value: i } = n;
|
|
1789
|
-
if (a.status === "aborted" || i.status === "aborted")
|
|
1790
|
-
return E;
|
|
1791
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[a.value] = i.value);
|
|
1792
|
-
}
|
|
1793
|
-
return { status: e.value, value: s };
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
const E = Object.freeze({
|
|
1797
|
-
status: "aborted"
|
|
1798
|
-
}), tt = (t) => ({ status: "dirty", value: t }), ae = (t) => ({ status: "valid", value: t }), er = (t) => t.status === "aborted", tr = (t) => t.status === "dirty", Je = (t) => t.status === "valid", mt = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
1799
|
-
var T;
|
|
1800
|
-
(function(t) {
|
|
1801
|
-
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
1802
|
-
})(T || (T = {}));
|
|
1803
|
-
class Ae {
|
|
1804
|
-
constructor(e, r, s, n) {
|
|
1805
|
-
this._cachedPath = [], this.parent = e, this.data = r, this._path = s, this._key = n;
|
|
1806
|
-
}
|
|
1807
|
-
get path() {
|
|
1808
|
-
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
const Pr = (t, e) => {
|
|
1812
|
-
if (Je(e))
|
|
1813
|
-
return { success: !0, data: e.value };
|
|
1814
|
-
if (!t.common.issues.length)
|
|
1815
|
-
throw new Error("Validation failed but no issues detected.");
|
|
1816
|
-
return {
|
|
1817
|
-
success: !1,
|
|
1818
|
-
get error() {
|
|
1819
|
-
if (this._error)
|
|
1820
|
-
return this._error;
|
|
1821
|
-
const r = new he(t.common.issues);
|
|
1822
|
-
return this._error = r, this._error;
|
|
1823
|
-
}
|
|
1824
|
-
};
|
|
1825
|
-
};
|
|
1826
|
-
function N(t) {
|
|
1827
|
-
if (!t)
|
|
1828
|
-
return {};
|
|
1829
|
-
const { errorMap: e, invalid_type_error: r, required_error: s, description: n } = t;
|
|
1830
|
-
if (e && (r || s))
|
|
1831
|
-
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1832
|
-
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
1833
|
-
const { message: d } = t;
|
|
1834
|
-
return i.code === "invalid_enum_value" ? { message: d ?? o.defaultError } : typeof o.data > "u" ? { message: d ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: d ?? r ?? o.defaultError };
|
|
1835
|
-
}, description: n };
|
|
1836
|
-
}
|
|
1837
|
-
class O {
|
|
1838
|
-
get description() {
|
|
1839
|
-
return this._def.description;
|
|
1840
|
-
}
|
|
1841
|
-
_getType(e) {
|
|
1842
|
-
return Ve(e.data);
|
|
1843
|
-
}
|
|
1844
|
-
_getOrReturnCtx(e, r) {
|
|
1845
|
-
return r || {
|
|
1846
|
-
common: e.parent.common,
|
|
1847
|
-
data: e.data,
|
|
1848
|
-
parsedType: Ve(e.data),
|
|
1849
|
-
schemaErrorMap: this._def.errorMap,
|
|
1850
|
-
path: e.path,
|
|
1851
|
-
parent: e.parent
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
_processInputParams(e) {
|
|
1855
|
-
return {
|
|
1856
|
-
status: new se(),
|
|
1857
|
-
ctx: {
|
|
1858
|
-
common: e.parent.common,
|
|
1859
|
-
data: e.data,
|
|
1860
|
-
parsedType: Ve(e.data),
|
|
1861
|
-
schemaErrorMap: this._def.errorMap,
|
|
1862
|
-
path: e.path,
|
|
1863
|
-
parent: e.parent
|
|
1864
|
-
}
|
|
1865
|
-
};
|
|
1866
|
-
}
|
|
1867
|
-
_parseSync(e) {
|
|
1868
|
-
const r = this._parse(e);
|
|
1869
|
-
if (mt(r))
|
|
1870
|
-
throw new Error("Synchronous parse encountered promise.");
|
|
1871
|
-
return r;
|
|
1872
|
-
}
|
|
1873
|
-
_parseAsync(e) {
|
|
1874
|
-
const r = this._parse(e);
|
|
1875
|
-
return Promise.resolve(r);
|
|
1876
|
-
}
|
|
1877
|
-
parse(e, r) {
|
|
1878
|
-
const s = this.safeParse(e, r);
|
|
1879
|
-
if (s.success)
|
|
1880
|
-
return s.data;
|
|
1881
|
-
throw s.error;
|
|
1882
|
-
}
|
|
1883
|
-
safeParse(e, r) {
|
|
1884
|
-
const s = {
|
|
1885
|
-
common: {
|
|
1886
|
-
issues: [],
|
|
1887
|
-
async: (r == null ? void 0 : r.async) ?? !1,
|
|
1888
|
-
contextualErrorMap: r == null ? void 0 : r.errorMap
|
|
1889
|
-
},
|
|
1890
|
-
path: (r == null ? void 0 : r.path) || [],
|
|
1891
|
-
schemaErrorMap: this._def.errorMap,
|
|
1892
|
-
parent: null,
|
|
1893
|
-
data: e,
|
|
1894
|
-
parsedType: Ve(e)
|
|
1895
|
-
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
1896
|
-
return Pr(s, n);
|
|
1897
|
-
}
|
|
1898
|
-
"~validate"(e) {
|
|
1899
|
-
var s, n;
|
|
1900
|
-
const r = {
|
|
1901
|
-
common: {
|
|
1902
|
-
issues: [],
|
|
1903
|
-
async: !!this["~standard"].async
|
|
1904
|
-
},
|
|
1905
|
-
path: [],
|
|
1906
|
-
schemaErrorMap: this._def.errorMap,
|
|
1907
|
-
parent: null,
|
|
1908
|
-
data: e,
|
|
1909
|
-
parsedType: Ve(e)
|
|
1910
|
-
};
|
|
1911
|
-
if (!this["~standard"].async)
|
|
1912
|
-
try {
|
|
1913
|
-
const a = this._parseSync({ data: e, path: [], parent: r });
|
|
1914
|
-
return Je(a) ? {
|
|
1915
|
-
value: a.value
|
|
1916
|
-
} : {
|
|
1917
|
-
issues: r.common.issues
|
|
1918
|
-
};
|
|
1919
|
-
} catch (a) {
|
|
1920
|
-
(n = (s = a == null ? void 0 : a.message) == null ? void 0 : s.toLowerCase()) != null && n.includes("encountered") && (this["~standard"].async = !0), r.common = {
|
|
1921
|
-
issues: [],
|
|
1922
|
-
async: !0
|
|
1923
|
-
};
|
|
1924
|
-
}
|
|
1925
|
-
return this._parseAsync({ data: e, path: [], parent: r }).then((a) => Je(a) ? {
|
|
1926
|
-
value: a.value
|
|
1927
|
-
} : {
|
|
1928
|
-
issues: r.common.issues
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
async parseAsync(e, r) {
|
|
1932
|
-
const s = await this.safeParseAsync(e, r);
|
|
1933
|
-
if (s.success)
|
|
1934
|
-
return s.data;
|
|
1935
|
-
throw s.error;
|
|
1936
|
-
}
|
|
1937
|
-
async safeParseAsync(e, r) {
|
|
1938
|
-
const s = {
|
|
1939
|
-
common: {
|
|
1940
|
-
issues: [],
|
|
1941
|
-
contextualErrorMap: r == null ? void 0 : r.errorMap,
|
|
1942
|
-
async: !0
|
|
1943
|
-
},
|
|
1944
|
-
path: (r == null ? void 0 : r.path) || [],
|
|
1945
|
-
schemaErrorMap: this._def.errorMap,
|
|
1946
|
-
parent: null,
|
|
1947
|
-
data: e,
|
|
1948
|
-
parsedType: Ve(e)
|
|
1949
|
-
}, n = this._parse({ data: e, path: s.path, parent: s }), a = await (mt(n) ? n : Promise.resolve(n));
|
|
1950
|
-
return Pr(s, a);
|
|
1951
|
-
}
|
|
1952
|
-
refine(e, r) {
|
|
1953
|
-
const s = (n) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(n) : r;
|
|
1954
|
-
return this._refinement((n, a) => {
|
|
1955
|
-
const i = e(n), o = () => a.addIssue({
|
|
1956
|
-
code: p.custom,
|
|
1957
|
-
...s(n)
|
|
1958
|
-
});
|
|
1959
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((d) => d ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
1960
|
-
});
|
|
1961
|
-
}
|
|
1962
|
-
refinement(e, r) {
|
|
1963
|
-
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof r == "function" ? r(s, n) : r), !1));
|
|
1964
|
-
}
|
|
1965
|
-
_refinement(e) {
|
|
1966
|
-
return new be({
|
|
1967
|
-
schema: this,
|
|
1968
|
-
typeName: j.ZodEffects,
|
|
1969
|
-
effect: { type: "refinement", refinement: e }
|
|
1970
|
-
});
|
|
1971
|
-
}
|
|
1972
|
-
superRefine(e) {
|
|
1973
|
-
return this._refinement(e);
|
|
1974
|
-
}
|
|
1975
|
-
constructor(e) {
|
|
1976
|
-
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), this["~standard"] = {
|
|
1977
|
-
version: 1,
|
|
1978
|
-
vendor: "zod",
|
|
1979
|
-
validate: (r) => this["~validate"](r)
|
|
1980
|
-
};
|
|
1981
|
-
}
|
|
1982
|
-
optional() {
|
|
1983
|
-
return Se.create(this, this._def);
|
|
1984
|
-
}
|
|
1985
|
-
nullable() {
|
|
1986
|
-
return ze.create(this, this._def);
|
|
1987
|
-
}
|
|
1988
|
-
nullish() {
|
|
1989
|
-
return this.nullable().optional();
|
|
1990
|
-
}
|
|
1991
|
-
array() {
|
|
1992
|
-
return _e.create(this);
|
|
1993
|
-
}
|
|
1994
|
-
promise() {
|
|
1995
|
-
return it.create(this, this._def);
|
|
1996
|
-
}
|
|
1997
|
-
or(e) {
|
|
1998
|
-
return vt.create([this, e], this._def);
|
|
1999
|
-
}
|
|
2000
|
-
and(e) {
|
|
2001
|
-
return _t.create(this, e, this._def);
|
|
2002
|
-
}
|
|
2003
|
-
transform(e) {
|
|
2004
|
-
return new be({
|
|
2005
|
-
...N(this._def),
|
|
2006
|
-
schema: this,
|
|
2007
|
-
typeName: j.ZodEffects,
|
|
2008
|
-
effect: { type: "transform", transform: e }
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
default(e) {
|
|
2012
|
-
const r = typeof e == "function" ? e : () => e;
|
|
2013
|
-
return new Tt({
|
|
2014
|
-
...N(this._def),
|
|
2015
|
-
innerType: this,
|
|
2016
|
-
defaultValue: r,
|
|
2017
|
-
typeName: j.ZodDefault
|
|
2018
|
-
});
|
|
2019
|
-
}
|
|
2020
|
-
brand() {
|
|
2021
|
-
return new lr({
|
|
2022
|
-
typeName: j.ZodBranded,
|
|
2023
|
-
type: this,
|
|
2024
|
-
...N(this._def)
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
catch(e) {
|
|
2028
|
-
const r = typeof e == "function" ? e : () => e;
|
|
2029
|
-
return new St({
|
|
2030
|
-
...N(this._def),
|
|
2031
|
-
innerType: this,
|
|
2032
|
-
catchValue: r,
|
|
2033
|
-
typeName: j.ZodCatch
|
|
2034
|
-
});
|
|
2035
|
-
}
|
|
2036
|
-
describe(e) {
|
|
2037
|
-
const r = this.constructor;
|
|
2038
|
-
return new r({
|
|
2039
|
-
...this._def,
|
|
2040
|
-
description: e
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
|
-
pipe(e) {
|
|
2044
|
-
return Nt.create(this, e);
|
|
2045
|
-
}
|
|
2046
|
-
readonly() {
|
|
2047
|
-
return At.create(this);
|
|
2048
|
-
}
|
|
2049
|
-
isOptional() {
|
|
2050
|
-
return this.safeParse(void 0).success;
|
|
2051
|
-
}
|
|
2052
|
-
isNullable() {
|
|
2053
|
-
return this.safeParse(null).success;
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
const en = /^c[^\s-]{8,}$/i, tn = /^[0-9a-z]+$/, rn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, sn = /^[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, nn = /^[a-z0-9_-]{21}$/i, an = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, 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, ln = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
2057
|
-
let Gt;
|
|
2058
|
-
const un = /^(?:(?: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])$/, 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])\/(3[0-2]|[12]?[0-9])$/, fn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, hn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, mn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, pn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, es = "((\\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])))", yn = new RegExp(`^${es}$`);
|
|
2059
|
-
function ts(t) {
|
|
2060
|
-
let e = "[0-5]\\d";
|
|
2061
|
-
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
2062
|
-
const r = t.precision ? "+" : "?";
|
|
2063
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
|
|
2064
|
-
}
|
|
2065
|
-
function gn(t) {
|
|
2066
|
-
return new RegExp(`^${ts(t)}$`);
|
|
2067
|
-
}
|
|
2068
|
-
function rs(t) {
|
|
2069
|
-
let e = `${es}T${ts(t)}`;
|
|
2070
|
-
const r = [];
|
|
2071
|
-
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
|
|
2072
|
-
}
|
|
2073
|
-
function vn(t, e) {
|
|
2074
|
-
return !!((e === "v4" || !e) && un.test(t) || (e === "v6" || !e) && fn.test(t));
|
|
2075
|
-
}
|
|
2076
|
-
function _n(t, e) {
|
|
2077
|
-
if (!an.test(t))
|
|
2078
|
-
return !1;
|
|
2079
|
-
try {
|
|
2080
|
-
const [r] = t.split("."), s = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
2081
|
-
return !(typeof n != "object" || n === null || "typ" in n && (n == null ? void 0 : n.typ) !== "JWT" || !n.alg || e && n.alg !== e);
|
|
2082
|
-
} catch {
|
|
2083
|
-
return !1;
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
function bn(t, e) {
|
|
2087
|
-
return !!((e === "v4" || !e) && dn.test(t) || (e === "v6" || !e) && hn.test(t));
|
|
2088
|
-
}
|
|
2089
|
-
class ve extends O {
|
|
2090
|
-
_parse(e) {
|
|
2091
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== w.string) {
|
|
2092
|
-
const a = this._getOrReturnCtx(e);
|
|
2093
|
-
return b(a, {
|
|
2094
|
-
code: p.invalid_type,
|
|
2095
|
-
expected: w.string,
|
|
2096
|
-
received: a.parsedType
|
|
2097
|
-
}), E;
|
|
2098
|
-
}
|
|
2099
|
-
const s = new se();
|
|
2100
|
-
let n;
|
|
2101
|
-
for (const a of this._def.checks)
|
|
2102
|
-
if (a.kind === "min")
|
|
2103
|
-
e.data.length < a.value && (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2104
|
-
code: p.too_small,
|
|
2105
|
-
minimum: a.value,
|
|
2106
|
-
type: "string",
|
|
2107
|
-
inclusive: !0,
|
|
2108
|
-
exact: !1,
|
|
2109
|
-
message: a.message
|
|
2110
|
-
}), s.dirty());
|
|
2111
|
-
else if (a.kind === "max")
|
|
2112
|
-
e.data.length > a.value && (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2113
|
-
code: p.too_big,
|
|
2114
|
-
maximum: a.value,
|
|
2115
|
-
type: "string",
|
|
2116
|
-
inclusive: !0,
|
|
2117
|
-
exact: !1,
|
|
2118
|
-
message: a.message
|
|
2119
|
-
}), s.dirty());
|
|
2120
|
-
else if (a.kind === "length") {
|
|
2121
|
-
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
2122
|
-
(i || o) && (n = this._getOrReturnCtx(e, n), i ? b(n, {
|
|
2123
|
-
code: p.too_big,
|
|
2124
|
-
maximum: a.value,
|
|
2125
|
-
type: "string",
|
|
2126
|
-
inclusive: !0,
|
|
2127
|
-
exact: !0,
|
|
2128
|
-
message: a.message
|
|
2129
|
-
}) : o && b(n, {
|
|
2130
|
-
code: p.too_small,
|
|
2131
|
-
minimum: a.value,
|
|
2132
|
-
type: "string",
|
|
2133
|
-
inclusive: !0,
|
|
2134
|
-
exact: !0,
|
|
2135
|
-
message: a.message
|
|
2136
|
-
}), s.dirty());
|
|
2137
|
-
} else if (a.kind === "email")
|
|
2138
|
-
cn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2139
|
-
validation: "email",
|
|
2140
|
-
code: p.invalid_string,
|
|
2141
|
-
message: a.message
|
|
2142
|
-
}), s.dirty());
|
|
2143
|
-
else if (a.kind === "emoji")
|
|
2144
|
-
Gt || (Gt = new RegExp(ln, "u")), Gt.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2145
|
-
validation: "emoji",
|
|
2146
|
-
code: p.invalid_string,
|
|
2147
|
-
message: a.message
|
|
2148
|
-
}), s.dirty());
|
|
2149
|
-
else if (a.kind === "uuid")
|
|
2150
|
-
sn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2151
|
-
validation: "uuid",
|
|
2152
|
-
code: p.invalid_string,
|
|
2153
|
-
message: a.message
|
|
2154
|
-
}), s.dirty());
|
|
2155
|
-
else if (a.kind === "nanoid")
|
|
2156
|
-
nn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2157
|
-
validation: "nanoid",
|
|
2158
|
-
code: p.invalid_string,
|
|
2159
|
-
message: a.message
|
|
2160
|
-
}), s.dirty());
|
|
2161
|
-
else if (a.kind === "cuid")
|
|
2162
|
-
en.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2163
|
-
validation: "cuid",
|
|
2164
|
-
code: p.invalid_string,
|
|
2165
|
-
message: a.message
|
|
2166
|
-
}), s.dirty());
|
|
2167
|
-
else if (a.kind === "cuid2")
|
|
2168
|
-
tn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2169
|
-
validation: "cuid2",
|
|
2170
|
-
code: p.invalid_string,
|
|
2171
|
-
message: a.message
|
|
2172
|
-
}), s.dirty());
|
|
2173
|
-
else if (a.kind === "ulid")
|
|
2174
|
-
rn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2175
|
-
validation: "ulid",
|
|
2176
|
-
code: p.invalid_string,
|
|
2177
|
-
message: a.message
|
|
2178
|
-
}), s.dirty());
|
|
2179
|
-
else if (a.kind === "url")
|
|
2180
|
-
try {
|
|
2181
|
-
new URL(e.data);
|
|
2182
|
-
} catch {
|
|
2183
|
-
n = this._getOrReturnCtx(e, n), b(n, {
|
|
2184
|
-
validation: "url",
|
|
2185
|
-
code: p.invalid_string,
|
|
2186
|
-
message: a.message
|
|
2187
|
-
}), s.dirty();
|
|
2188
|
-
}
|
|
2189
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2190
|
-
validation: "regex",
|
|
2191
|
-
code: p.invalid_string,
|
|
2192
|
-
message: a.message
|
|
2193
|
-
}), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2194
|
-
code: p.invalid_string,
|
|
2195
|
-
validation: { includes: a.value, position: a.position },
|
|
2196
|
-
message: a.message
|
|
2197
|
-
}), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2198
|
-
code: p.invalid_string,
|
|
2199
|
-
validation: { startsWith: a.value },
|
|
2200
|
-
message: a.message
|
|
2201
|
-
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2202
|
-
code: p.invalid_string,
|
|
2203
|
-
validation: { endsWith: a.value },
|
|
2204
|
-
message: a.message
|
|
2205
|
-
}), s.dirty()) : a.kind === "datetime" ? rs(a).test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2206
|
-
code: p.invalid_string,
|
|
2207
|
-
validation: "datetime",
|
|
2208
|
-
message: a.message
|
|
2209
|
-
}), s.dirty()) : a.kind === "date" ? yn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2210
|
-
code: p.invalid_string,
|
|
2211
|
-
validation: "date",
|
|
2212
|
-
message: a.message
|
|
2213
|
-
}), s.dirty()) : a.kind === "time" ? gn(a).test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2214
|
-
code: p.invalid_string,
|
|
2215
|
-
validation: "time",
|
|
2216
|
-
message: a.message
|
|
2217
|
-
}), s.dirty()) : a.kind === "duration" ? on.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2218
|
-
validation: "duration",
|
|
2219
|
-
code: p.invalid_string,
|
|
2220
|
-
message: a.message
|
|
2221
|
-
}), s.dirty()) : a.kind === "ip" ? vn(e.data, a.version) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2222
|
-
validation: "ip",
|
|
2223
|
-
code: p.invalid_string,
|
|
2224
|
-
message: a.message
|
|
2225
|
-
}), s.dirty()) : a.kind === "jwt" ? _n(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2226
|
-
validation: "jwt",
|
|
2227
|
-
code: p.invalid_string,
|
|
2228
|
-
message: a.message
|
|
2229
|
-
}), s.dirty()) : a.kind === "cidr" ? bn(e.data, a.version) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2230
|
-
validation: "cidr",
|
|
2231
|
-
code: p.invalid_string,
|
|
2232
|
-
message: a.message
|
|
2233
|
-
}), s.dirty()) : a.kind === "base64" ? mn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2234
|
-
validation: "base64",
|
|
2235
|
-
code: p.invalid_string,
|
|
2236
|
-
message: a.message
|
|
2237
|
-
}), s.dirty()) : a.kind === "base64url" ? pn.test(e.data) || (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2238
|
-
validation: "base64url",
|
|
2239
|
-
code: p.invalid_string,
|
|
2240
|
-
message: a.message
|
|
2241
|
-
}), s.dirty()) : F.assertNever(a);
|
|
2242
|
-
return { status: s.value, value: e.data };
|
|
2243
|
-
}
|
|
2244
|
-
_regex(e, r, s) {
|
|
2245
|
-
return this.refinement((n) => e.test(n), {
|
|
2246
|
-
validation: r,
|
|
2247
|
-
code: p.invalid_string,
|
|
2248
|
-
...T.errToObj(s)
|
|
2249
|
-
});
|
|
2250
|
-
}
|
|
2251
|
-
_addCheck(e) {
|
|
2252
|
-
return new ve({
|
|
2253
|
-
...this._def,
|
|
2254
|
-
checks: [...this._def.checks, e]
|
|
2255
|
-
});
|
|
2256
|
-
}
|
|
2257
|
-
email(e) {
|
|
2258
|
-
return this._addCheck({ kind: "email", ...T.errToObj(e) });
|
|
2259
|
-
}
|
|
2260
|
-
url(e) {
|
|
2261
|
-
return this._addCheck({ kind: "url", ...T.errToObj(e) });
|
|
2262
|
-
}
|
|
2263
|
-
emoji(e) {
|
|
2264
|
-
return this._addCheck({ kind: "emoji", ...T.errToObj(e) });
|
|
2265
|
-
}
|
|
2266
|
-
uuid(e) {
|
|
2267
|
-
return this._addCheck({ kind: "uuid", ...T.errToObj(e) });
|
|
2268
|
-
}
|
|
2269
|
-
nanoid(e) {
|
|
2270
|
-
return this._addCheck({ kind: "nanoid", ...T.errToObj(e) });
|
|
2271
|
-
}
|
|
2272
|
-
cuid(e) {
|
|
2273
|
-
return this._addCheck({ kind: "cuid", ...T.errToObj(e) });
|
|
2274
|
-
}
|
|
2275
|
-
cuid2(e) {
|
|
2276
|
-
return this._addCheck({ kind: "cuid2", ...T.errToObj(e) });
|
|
2277
|
-
}
|
|
2278
|
-
ulid(e) {
|
|
2279
|
-
return this._addCheck({ kind: "ulid", ...T.errToObj(e) });
|
|
2280
|
-
}
|
|
2281
|
-
base64(e) {
|
|
2282
|
-
return this._addCheck({ kind: "base64", ...T.errToObj(e) });
|
|
2283
|
-
}
|
|
2284
|
-
base64url(e) {
|
|
2285
|
-
return this._addCheck({
|
|
2286
|
-
kind: "base64url",
|
|
2287
|
-
...T.errToObj(e)
|
|
2288
|
-
});
|
|
2289
|
-
}
|
|
2290
|
-
jwt(e) {
|
|
2291
|
-
return this._addCheck({ kind: "jwt", ...T.errToObj(e) });
|
|
2292
|
-
}
|
|
2293
|
-
ip(e) {
|
|
2294
|
-
return this._addCheck({ kind: "ip", ...T.errToObj(e) });
|
|
2295
|
-
}
|
|
2296
|
-
cidr(e) {
|
|
2297
|
-
return this._addCheck({ kind: "cidr", ...T.errToObj(e) });
|
|
2298
|
-
}
|
|
2299
|
-
datetime(e) {
|
|
2300
|
-
return typeof e == "string" ? this._addCheck({
|
|
2301
|
-
kind: "datetime",
|
|
2302
|
-
precision: null,
|
|
2303
|
-
offset: !1,
|
|
2304
|
-
local: !1,
|
|
2305
|
-
message: e
|
|
2306
|
-
}) : this._addCheck({
|
|
2307
|
-
kind: "datetime",
|
|
2308
|
-
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
2309
|
-
offset: (e == null ? void 0 : e.offset) ?? !1,
|
|
2310
|
-
local: (e == null ? void 0 : e.local) ?? !1,
|
|
2311
|
-
...T.errToObj(e == null ? void 0 : e.message)
|
|
2312
|
-
});
|
|
2313
|
-
}
|
|
2314
|
-
date(e) {
|
|
2315
|
-
return this._addCheck({ kind: "date", message: e });
|
|
2316
|
-
}
|
|
2317
|
-
time(e) {
|
|
2318
|
-
return typeof e == "string" ? this._addCheck({
|
|
2319
|
-
kind: "time",
|
|
2320
|
-
precision: null,
|
|
2321
|
-
message: e
|
|
2322
|
-
}) : this._addCheck({
|
|
2323
|
-
kind: "time",
|
|
2324
|
-
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
2325
|
-
...T.errToObj(e == null ? void 0 : e.message)
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
duration(e) {
|
|
2329
|
-
return this._addCheck({ kind: "duration", ...T.errToObj(e) });
|
|
2330
|
-
}
|
|
2331
|
-
regex(e, r) {
|
|
2332
|
-
return this._addCheck({
|
|
2333
|
-
kind: "regex",
|
|
2334
|
-
regex: e,
|
|
2335
|
-
...T.errToObj(r)
|
|
2336
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
includes(e, r) {
|
|
2339
|
-
return this._addCheck({
|
|
2340
|
-
kind: "includes",
|
|
2341
|
-
value: e,
|
|
2342
|
-
position: r == null ? void 0 : r.position,
|
|
2343
|
-
...T.errToObj(r == null ? void 0 : r.message)
|
|
2344
|
-
});
|
|
2345
|
-
}
|
|
2346
|
-
startsWith(e, r) {
|
|
2347
|
-
return this._addCheck({
|
|
2348
|
-
kind: "startsWith",
|
|
2349
|
-
value: e,
|
|
2350
|
-
...T.errToObj(r)
|
|
2351
|
-
});
|
|
2352
|
-
}
|
|
2353
|
-
endsWith(e, r) {
|
|
2354
|
-
return this._addCheck({
|
|
2355
|
-
kind: "endsWith",
|
|
2356
|
-
value: e,
|
|
2357
|
-
...T.errToObj(r)
|
|
2358
|
-
});
|
|
2359
|
-
}
|
|
2360
|
-
min(e, r) {
|
|
2361
|
-
return this._addCheck({
|
|
2362
|
-
kind: "min",
|
|
2363
|
-
value: e,
|
|
2364
|
-
...T.errToObj(r)
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2367
|
-
max(e, r) {
|
|
2368
|
-
return this._addCheck({
|
|
2369
|
-
kind: "max",
|
|
2370
|
-
value: e,
|
|
2371
|
-
...T.errToObj(r)
|
|
2372
|
-
});
|
|
2373
|
-
}
|
|
2374
|
-
length(e, r) {
|
|
2375
|
-
return this._addCheck({
|
|
2376
|
-
kind: "length",
|
|
2377
|
-
value: e,
|
|
2378
|
-
...T.errToObj(r)
|
|
2379
|
-
});
|
|
2380
|
-
}
|
|
2381
|
-
/**
|
|
2382
|
-
* Equivalent to `.min(1)`
|
|
2383
|
-
*/
|
|
2384
|
-
nonempty(e) {
|
|
2385
|
-
return this.min(1, T.errToObj(e));
|
|
2386
|
-
}
|
|
2387
|
-
trim() {
|
|
2388
|
-
return new ve({
|
|
2389
|
-
...this._def,
|
|
2390
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
2391
|
-
});
|
|
2392
|
-
}
|
|
2393
|
-
toLowerCase() {
|
|
2394
|
-
return new ve({
|
|
2395
|
-
...this._def,
|
|
2396
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
2397
|
-
});
|
|
2398
|
-
}
|
|
2399
|
-
toUpperCase() {
|
|
2400
|
-
return new ve({
|
|
2401
|
-
...this._def,
|
|
2402
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
2403
|
-
});
|
|
2404
|
-
}
|
|
2405
|
-
get isDatetime() {
|
|
2406
|
-
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
2407
|
-
}
|
|
2408
|
-
get isDate() {
|
|
2409
|
-
return !!this._def.checks.find((e) => e.kind === "date");
|
|
2410
|
-
}
|
|
2411
|
-
get isTime() {
|
|
2412
|
-
return !!this._def.checks.find((e) => e.kind === "time");
|
|
2413
|
-
}
|
|
2414
|
-
get isDuration() {
|
|
2415
|
-
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
2416
|
-
}
|
|
2417
|
-
get isEmail() {
|
|
2418
|
-
return !!this._def.checks.find((e) => e.kind === "email");
|
|
2419
|
-
}
|
|
2420
|
-
get isURL() {
|
|
2421
|
-
return !!this._def.checks.find((e) => e.kind === "url");
|
|
2422
|
-
}
|
|
2423
|
-
get isEmoji() {
|
|
2424
|
-
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
2425
|
-
}
|
|
2426
|
-
get isUUID() {
|
|
2427
|
-
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
2428
|
-
}
|
|
2429
|
-
get isNANOID() {
|
|
2430
|
-
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
2431
|
-
}
|
|
2432
|
-
get isCUID() {
|
|
2433
|
-
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
2434
|
-
}
|
|
2435
|
-
get isCUID2() {
|
|
2436
|
-
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
2437
|
-
}
|
|
2438
|
-
get isULID() {
|
|
2439
|
-
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
2440
|
-
}
|
|
2441
|
-
get isIP() {
|
|
2442
|
-
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
2443
|
-
}
|
|
2444
|
-
get isCIDR() {
|
|
2445
|
-
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
2446
|
-
}
|
|
2447
|
-
get isBase64() {
|
|
2448
|
-
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
2449
|
-
}
|
|
2450
|
-
get isBase64url() {
|
|
2451
|
-
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
2452
|
-
}
|
|
2453
|
-
get minLength() {
|
|
2454
|
-
let e = null;
|
|
2455
|
-
for (const r of this._def.checks)
|
|
2456
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2457
|
-
return e;
|
|
2458
|
-
}
|
|
2459
|
-
get maxLength() {
|
|
2460
|
-
let e = null;
|
|
2461
|
-
for (const r of this._def.checks)
|
|
2462
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2463
|
-
return e;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
ve.create = (t) => new ve({
|
|
2467
|
-
checks: [],
|
|
2468
|
-
typeName: j.ZodString,
|
|
2469
|
-
coerce: (t == null ? void 0 : t.coerce) ?? !1,
|
|
2470
|
-
...N(t)
|
|
2471
|
-
});
|
|
2472
|
-
function xn(t, e) {
|
|
2473
|
-
const r = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = r > s ? r : s, a = Number.parseInt(t.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
2474
|
-
return a % i / 10 ** n;
|
|
2475
|
-
}
|
|
2476
|
-
class Le extends O {
|
|
2477
|
-
constructor() {
|
|
2478
|
-
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
2479
|
-
}
|
|
2480
|
-
_parse(e) {
|
|
2481
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== w.number) {
|
|
2482
|
-
const a = this._getOrReturnCtx(e);
|
|
2483
|
-
return b(a, {
|
|
2484
|
-
code: p.invalid_type,
|
|
2485
|
-
expected: w.number,
|
|
2486
|
-
received: a.parsedType
|
|
2487
|
-
}), E;
|
|
2488
|
-
}
|
|
2489
|
-
let s;
|
|
2490
|
-
const n = new se();
|
|
2491
|
-
for (const a of this._def.checks)
|
|
2492
|
-
a.kind === "int" ? F.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2493
|
-
code: p.invalid_type,
|
|
2494
|
-
expected: "integer",
|
|
2495
|
-
received: "float",
|
|
2496
|
-
message: a.message
|
|
2497
|
-
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2498
|
-
code: p.too_small,
|
|
2499
|
-
minimum: a.value,
|
|
2500
|
-
type: "number",
|
|
2501
|
-
inclusive: a.inclusive,
|
|
2502
|
-
exact: !1,
|
|
2503
|
-
message: a.message
|
|
2504
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2505
|
-
code: p.too_big,
|
|
2506
|
-
maximum: a.value,
|
|
2507
|
-
type: "number",
|
|
2508
|
-
inclusive: a.inclusive,
|
|
2509
|
-
exact: !1,
|
|
2510
|
-
message: a.message
|
|
2511
|
-
}), n.dirty()) : a.kind === "multipleOf" ? xn(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2512
|
-
code: p.not_multiple_of,
|
|
2513
|
-
multipleOf: a.value,
|
|
2514
|
-
message: a.message
|
|
2515
|
-
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2516
|
-
code: p.not_finite,
|
|
2517
|
-
message: a.message
|
|
2518
|
-
}), n.dirty()) : F.assertNever(a);
|
|
2519
|
-
return { status: n.value, value: e.data };
|
|
2520
|
-
}
|
|
2521
|
-
gte(e, r) {
|
|
2522
|
-
return this.setLimit("min", e, !0, T.toString(r));
|
|
2523
|
-
}
|
|
2524
|
-
gt(e, r) {
|
|
2525
|
-
return this.setLimit("min", e, !1, T.toString(r));
|
|
2526
|
-
}
|
|
2527
|
-
lte(e, r) {
|
|
2528
|
-
return this.setLimit("max", e, !0, T.toString(r));
|
|
2529
|
-
}
|
|
2530
|
-
lt(e, r) {
|
|
2531
|
-
return this.setLimit("max", e, !1, T.toString(r));
|
|
2532
|
-
}
|
|
2533
|
-
setLimit(e, r, s, n) {
|
|
2534
|
-
return new Le({
|
|
2535
|
-
...this._def,
|
|
2536
|
-
checks: [
|
|
2537
|
-
...this._def.checks,
|
|
2538
|
-
{
|
|
2539
|
-
kind: e,
|
|
2540
|
-
value: r,
|
|
2541
|
-
inclusive: s,
|
|
2542
|
-
message: T.toString(n)
|
|
2543
|
-
}
|
|
2544
|
-
]
|
|
2545
|
-
});
|
|
2546
|
-
}
|
|
2547
|
-
_addCheck(e) {
|
|
2548
|
-
return new Le({
|
|
2549
|
-
...this._def,
|
|
2550
|
-
checks: [...this._def.checks, e]
|
|
2551
|
-
});
|
|
2552
|
-
}
|
|
2553
|
-
int(e) {
|
|
2554
|
-
return this._addCheck({
|
|
2555
|
-
kind: "int",
|
|
2556
|
-
message: T.toString(e)
|
|
2557
|
-
});
|
|
2558
|
-
}
|
|
2559
|
-
positive(e) {
|
|
2560
|
-
return this._addCheck({
|
|
2561
|
-
kind: "min",
|
|
2562
|
-
value: 0,
|
|
2563
|
-
inclusive: !1,
|
|
2564
|
-
message: T.toString(e)
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
negative(e) {
|
|
2568
|
-
return this._addCheck({
|
|
2569
|
-
kind: "max",
|
|
2570
|
-
value: 0,
|
|
2571
|
-
inclusive: !1,
|
|
2572
|
-
message: T.toString(e)
|
|
2573
|
-
});
|
|
2574
|
-
}
|
|
2575
|
-
nonpositive(e) {
|
|
2576
|
-
return this._addCheck({
|
|
2577
|
-
kind: "max",
|
|
2578
|
-
value: 0,
|
|
2579
|
-
inclusive: !0,
|
|
2580
|
-
message: T.toString(e)
|
|
2581
|
-
});
|
|
2582
|
-
}
|
|
2583
|
-
nonnegative(e) {
|
|
2584
|
-
return this._addCheck({
|
|
2585
|
-
kind: "min",
|
|
2586
|
-
value: 0,
|
|
2587
|
-
inclusive: !0,
|
|
2588
|
-
message: T.toString(e)
|
|
2589
|
-
});
|
|
2590
|
-
}
|
|
2591
|
-
multipleOf(e, r) {
|
|
2592
|
-
return this._addCheck({
|
|
2593
|
-
kind: "multipleOf",
|
|
2594
|
-
value: e,
|
|
2595
|
-
message: T.toString(r)
|
|
2596
|
-
});
|
|
2597
|
-
}
|
|
2598
|
-
finite(e) {
|
|
2599
|
-
return this._addCheck({
|
|
2600
|
-
kind: "finite",
|
|
2601
|
-
message: T.toString(e)
|
|
2602
|
-
});
|
|
2603
|
-
}
|
|
2604
|
-
safe(e) {
|
|
2605
|
-
return this._addCheck({
|
|
2606
|
-
kind: "min",
|
|
2607
|
-
inclusive: !0,
|
|
2608
|
-
value: Number.MIN_SAFE_INTEGER,
|
|
2609
|
-
message: T.toString(e)
|
|
2610
|
-
})._addCheck({
|
|
2611
|
-
kind: "max",
|
|
2612
|
-
inclusive: !0,
|
|
2613
|
-
value: Number.MAX_SAFE_INTEGER,
|
|
2614
|
-
message: T.toString(e)
|
|
2615
|
-
});
|
|
2616
|
-
}
|
|
2617
|
-
get minValue() {
|
|
2618
|
-
let e = null;
|
|
2619
|
-
for (const r of this._def.checks)
|
|
2620
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2621
|
-
return e;
|
|
2622
|
-
}
|
|
2623
|
-
get maxValue() {
|
|
2624
|
-
let e = null;
|
|
2625
|
-
for (const r of this._def.checks)
|
|
2626
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2627
|
-
return e;
|
|
2628
|
-
}
|
|
2629
|
-
get isInt() {
|
|
2630
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && F.isInteger(e.value));
|
|
2631
|
-
}
|
|
2632
|
-
get isFinite() {
|
|
2633
|
-
let e = null, r = null;
|
|
2634
|
-
for (const s of this._def.checks) {
|
|
2635
|
-
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
2636
|
-
return !0;
|
|
2637
|
-
s.kind === "min" ? (r === null || s.value > r) && (r = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
2638
|
-
}
|
|
2639
|
-
return Number.isFinite(r) && Number.isFinite(e);
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
Le.create = (t) => new Le({
|
|
2643
|
-
checks: [],
|
|
2644
|
-
typeName: j.ZodNumber,
|
|
2645
|
-
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
2646
|
-
...N(t)
|
|
2647
|
-
});
|
|
2648
|
-
class $e extends O {
|
|
2649
|
-
constructor() {
|
|
2650
|
-
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
2651
|
-
}
|
|
2652
|
-
_parse(e) {
|
|
2653
|
-
if (this._def.coerce)
|
|
2654
|
-
try {
|
|
2655
|
-
e.data = BigInt(e.data);
|
|
2656
|
-
} catch {
|
|
2657
|
-
return this._getInvalidInput(e);
|
|
2658
|
-
}
|
|
2659
|
-
if (this._getType(e) !== w.bigint)
|
|
2660
|
-
return this._getInvalidInput(e);
|
|
2661
|
-
let s;
|
|
2662
|
-
const n = new se();
|
|
2663
|
-
for (const a of this._def.checks)
|
|
2664
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2665
|
-
code: p.too_small,
|
|
2666
|
-
type: "bigint",
|
|
2667
|
-
minimum: a.value,
|
|
2668
|
-
inclusive: a.inclusive,
|
|
2669
|
-
message: a.message
|
|
2670
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2671
|
-
code: p.too_big,
|
|
2672
|
-
type: "bigint",
|
|
2673
|
-
maximum: a.value,
|
|
2674
|
-
inclusive: a.inclusive,
|
|
2675
|
-
message: a.message
|
|
2676
|
-
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), b(s, {
|
|
2677
|
-
code: p.not_multiple_of,
|
|
2678
|
-
multipleOf: a.value,
|
|
2679
|
-
message: a.message
|
|
2680
|
-
}), n.dirty()) : F.assertNever(a);
|
|
2681
|
-
return { status: n.value, value: e.data };
|
|
2682
|
-
}
|
|
2683
|
-
_getInvalidInput(e) {
|
|
2684
|
-
const r = this._getOrReturnCtx(e);
|
|
2685
|
-
return b(r, {
|
|
2686
|
-
code: p.invalid_type,
|
|
2687
|
-
expected: w.bigint,
|
|
2688
|
-
received: r.parsedType
|
|
2689
|
-
}), E;
|
|
2690
|
-
}
|
|
2691
|
-
gte(e, r) {
|
|
2692
|
-
return this.setLimit("min", e, !0, T.toString(r));
|
|
2693
|
-
}
|
|
2694
|
-
gt(e, r) {
|
|
2695
|
-
return this.setLimit("min", e, !1, T.toString(r));
|
|
2696
|
-
}
|
|
2697
|
-
lte(e, r) {
|
|
2698
|
-
return this.setLimit("max", e, !0, T.toString(r));
|
|
2699
|
-
}
|
|
2700
|
-
lt(e, r) {
|
|
2701
|
-
return this.setLimit("max", e, !1, T.toString(r));
|
|
2702
|
-
}
|
|
2703
|
-
setLimit(e, r, s, n) {
|
|
2704
|
-
return new $e({
|
|
2705
|
-
...this._def,
|
|
2706
|
-
checks: [
|
|
2707
|
-
...this._def.checks,
|
|
2708
|
-
{
|
|
2709
|
-
kind: e,
|
|
2710
|
-
value: r,
|
|
2711
|
-
inclusive: s,
|
|
2712
|
-
message: T.toString(n)
|
|
2713
|
-
}
|
|
2714
|
-
]
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
_addCheck(e) {
|
|
2718
|
-
return new $e({
|
|
2719
|
-
...this._def,
|
|
2720
|
-
checks: [...this._def.checks, e]
|
|
2721
|
-
});
|
|
2722
|
-
}
|
|
2723
|
-
positive(e) {
|
|
2724
|
-
return this._addCheck({
|
|
2725
|
-
kind: "min",
|
|
2726
|
-
value: BigInt(0),
|
|
2727
|
-
inclusive: !1,
|
|
2728
|
-
message: T.toString(e)
|
|
2729
|
-
});
|
|
2730
|
-
}
|
|
2731
|
-
negative(e) {
|
|
2732
|
-
return this._addCheck({
|
|
2733
|
-
kind: "max",
|
|
2734
|
-
value: BigInt(0),
|
|
2735
|
-
inclusive: !1,
|
|
2736
|
-
message: T.toString(e)
|
|
2737
|
-
});
|
|
2738
|
-
}
|
|
2739
|
-
nonpositive(e) {
|
|
2740
|
-
return this._addCheck({
|
|
2741
|
-
kind: "max",
|
|
2742
|
-
value: BigInt(0),
|
|
2743
|
-
inclusive: !0,
|
|
2744
|
-
message: T.toString(e)
|
|
2745
|
-
});
|
|
2746
|
-
}
|
|
2747
|
-
nonnegative(e) {
|
|
2748
|
-
return this._addCheck({
|
|
2749
|
-
kind: "min",
|
|
2750
|
-
value: BigInt(0),
|
|
2751
|
-
inclusive: !0,
|
|
2752
|
-
message: T.toString(e)
|
|
2753
|
-
});
|
|
2754
|
-
}
|
|
2755
|
-
multipleOf(e, r) {
|
|
2756
|
-
return this._addCheck({
|
|
2757
|
-
kind: "multipleOf",
|
|
2758
|
-
value: e,
|
|
2759
|
-
message: T.toString(r)
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
|
-
get minValue() {
|
|
2763
|
-
let e = null;
|
|
2764
|
-
for (const r of this._def.checks)
|
|
2765
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2766
|
-
return e;
|
|
2767
|
-
}
|
|
2768
|
-
get maxValue() {
|
|
2769
|
-
let e = null;
|
|
2770
|
-
for (const r of this._def.checks)
|
|
2771
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2772
|
-
return e;
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
$e.create = (t) => new $e({
|
|
2776
|
-
checks: [],
|
|
2777
|
-
typeName: j.ZodBigInt,
|
|
2778
|
-
coerce: (t == null ? void 0 : t.coerce) ?? !1,
|
|
2779
|
-
...N(t)
|
|
2780
|
-
});
|
|
2781
|
-
class pt extends O {
|
|
2782
|
-
_parse(e) {
|
|
2783
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== w.boolean) {
|
|
2784
|
-
const s = this._getOrReturnCtx(e);
|
|
2785
|
-
return b(s, {
|
|
2786
|
-
code: p.invalid_type,
|
|
2787
|
-
expected: w.boolean,
|
|
2788
|
-
received: s.parsedType
|
|
2789
|
-
}), E;
|
|
2790
|
-
}
|
|
2791
|
-
return ae(e.data);
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
pt.create = (t) => new pt({
|
|
2795
|
-
typeName: j.ZodBoolean,
|
|
2796
|
-
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
2797
|
-
...N(t)
|
|
2798
|
-
});
|
|
2799
|
-
class He extends O {
|
|
2800
|
-
_parse(e) {
|
|
2801
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== w.date) {
|
|
2802
|
-
const a = this._getOrReturnCtx(e);
|
|
2803
|
-
return b(a, {
|
|
2804
|
-
code: p.invalid_type,
|
|
2805
|
-
expected: w.date,
|
|
2806
|
-
received: a.parsedType
|
|
2807
|
-
}), E;
|
|
2808
|
-
}
|
|
2809
|
-
if (Number.isNaN(e.data.getTime())) {
|
|
2810
|
-
const a = this._getOrReturnCtx(e);
|
|
2811
|
-
return b(a, {
|
|
2812
|
-
code: p.invalid_date
|
|
2813
|
-
}), E;
|
|
2814
|
-
}
|
|
2815
|
-
const s = new se();
|
|
2816
|
-
let n;
|
|
2817
|
-
for (const a of this._def.checks)
|
|
2818
|
-
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2819
|
-
code: p.too_small,
|
|
2820
|
-
message: a.message,
|
|
2821
|
-
inclusive: !0,
|
|
2822
|
-
exact: !1,
|
|
2823
|
-
minimum: a.value,
|
|
2824
|
-
type: "date"
|
|
2825
|
-
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), b(n, {
|
|
2826
|
-
code: p.too_big,
|
|
2827
|
-
message: a.message,
|
|
2828
|
-
inclusive: !0,
|
|
2829
|
-
exact: !1,
|
|
2830
|
-
maximum: a.value,
|
|
2831
|
-
type: "date"
|
|
2832
|
-
}), s.dirty()) : F.assertNever(a);
|
|
2833
|
-
return {
|
|
2834
|
-
status: s.value,
|
|
2835
|
-
value: new Date(e.data.getTime())
|
|
2836
|
-
};
|
|
2837
|
-
}
|
|
2838
|
-
_addCheck(e) {
|
|
2839
|
-
return new He({
|
|
2840
|
-
...this._def,
|
|
2841
|
-
checks: [...this._def.checks, e]
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
min(e, r) {
|
|
2845
|
-
return this._addCheck({
|
|
2846
|
-
kind: "min",
|
|
2847
|
-
value: e.getTime(),
|
|
2848
|
-
message: T.toString(r)
|
|
2849
|
-
});
|
|
2850
|
-
}
|
|
2851
|
-
max(e, r) {
|
|
2852
|
-
return this._addCheck({
|
|
2853
|
-
kind: "max",
|
|
2854
|
-
value: e.getTime(),
|
|
2855
|
-
message: T.toString(r)
|
|
2856
|
-
});
|
|
2857
|
-
}
|
|
2858
|
-
get minDate() {
|
|
2859
|
-
let e = null;
|
|
2860
|
-
for (const r of this._def.checks)
|
|
2861
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2862
|
-
return e != null ? new Date(e) : null;
|
|
2863
|
-
}
|
|
2864
|
-
get maxDate() {
|
|
2865
|
-
let e = null;
|
|
2866
|
-
for (const r of this._def.checks)
|
|
2867
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2868
|
-
return e != null ? new Date(e) : null;
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
He.create = (t) => new He({
|
|
2872
|
-
checks: [],
|
|
2873
|
-
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
2874
|
-
typeName: j.ZodDate,
|
|
2875
|
-
...N(t)
|
|
2876
|
-
});
|
|
2877
|
-
class Zt extends O {
|
|
2878
|
-
_parse(e) {
|
|
2879
|
-
if (this._getType(e) !== w.symbol) {
|
|
2880
|
-
const s = this._getOrReturnCtx(e);
|
|
2881
|
-
return b(s, {
|
|
2882
|
-
code: p.invalid_type,
|
|
2883
|
-
expected: w.symbol,
|
|
2884
|
-
received: s.parsedType
|
|
2885
|
-
}), E;
|
|
2886
|
-
}
|
|
2887
|
-
return ae(e.data);
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
Zt.create = (t) => new Zt({
|
|
2891
|
-
typeName: j.ZodSymbol,
|
|
2892
|
-
...N(t)
|
|
2893
|
-
});
|
|
2894
|
-
class yt extends O {
|
|
2895
|
-
_parse(e) {
|
|
2896
|
-
if (this._getType(e) !== w.undefined) {
|
|
2897
|
-
const s = this._getOrReturnCtx(e);
|
|
2898
|
-
return b(s, {
|
|
2899
|
-
code: p.invalid_type,
|
|
2900
|
-
expected: w.undefined,
|
|
2901
|
-
received: s.parsedType
|
|
2902
|
-
}), E;
|
|
2903
|
-
}
|
|
2904
|
-
return ae(e.data);
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
yt.create = (t) => new yt({
|
|
2908
|
-
typeName: j.ZodUndefined,
|
|
2909
|
-
...N(t)
|
|
2910
|
-
});
|
|
2911
|
-
class gt extends O {
|
|
2912
|
-
_parse(e) {
|
|
2913
|
-
if (this._getType(e) !== w.null) {
|
|
2914
|
-
const s = this._getOrReturnCtx(e);
|
|
2915
|
-
return b(s, {
|
|
2916
|
-
code: p.invalid_type,
|
|
2917
|
-
expected: w.null,
|
|
2918
|
-
received: s.parsedType
|
|
2919
|
-
}), E;
|
|
2920
|
-
}
|
|
2921
|
-
return ae(e.data);
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
gt.create = (t) => new gt({
|
|
2925
|
-
typeName: j.ZodNull,
|
|
2926
|
-
...N(t)
|
|
2927
|
-
});
|
|
2928
|
-
class at extends O {
|
|
2929
|
-
constructor() {
|
|
2930
|
-
super(...arguments), this._any = !0;
|
|
2931
|
-
}
|
|
2932
|
-
_parse(e) {
|
|
2933
|
-
return ae(e.data);
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
at.create = (t) => new at({
|
|
2937
|
-
typeName: j.ZodAny,
|
|
2938
|
-
...N(t)
|
|
2939
|
-
});
|
|
2940
|
-
class Ye extends O {
|
|
2941
|
-
constructor() {
|
|
2942
|
-
super(...arguments), this._unknown = !0;
|
|
2943
|
-
}
|
|
2944
|
-
_parse(e) {
|
|
2945
|
-
return ae(e.data);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
Ye.create = (t) => new Ye({
|
|
2949
|
-
typeName: j.ZodUnknown,
|
|
2950
|
-
...N(t)
|
|
2951
|
-
});
|
|
2952
|
-
class Fe extends O {
|
|
2953
|
-
_parse(e) {
|
|
2954
|
-
const r = this._getOrReturnCtx(e);
|
|
2955
|
-
return b(r, {
|
|
2956
|
-
code: p.invalid_type,
|
|
2957
|
-
expected: w.never,
|
|
2958
|
-
received: r.parsedType
|
|
2959
|
-
}), E;
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
Fe.create = (t) => new Fe({
|
|
2963
|
-
typeName: j.ZodNever,
|
|
2964
|
-
...N(t)
|
|
2965
|
-
});
|
|
2966
|
-
class Lt extends O {
|
|
2967
|
-
_parse(e) {
|
|
2968
|
-
if (this._getType(e) !== w.undefined) {
|
|
2969
|
-
const s = this._getOrReturnCtx(e);
|
|
2970
|
-
return b(s, {
|
|
2971
|
-
code: p.invalid_type,
|
|
2972
|
-
expected: w.void,
|
|
2973
|
-
received: s.parsedType
|
|
2974
|
-
}), E;
|
|
2975
|
-
}
|
|
2976
|
-
return ae(e.data);
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
Lt.create = (t) => new Lt({
|
|
2980
|
-
typeName: j.ZodVoid,
|
|
2981
|
-
...N(t)
|
|
2982
|
-
});
|
|
2983
|
-
class _e extends O {
|
|
2984
|
-
_parse(e) {
|
|
2985
|
-
const { ctx: r, status: s } = this._processInputParams(e), n = this._def;
|
|
2986
|
-
if (r.parsedType !== w.array)
|
|
2987
|
-
return b(r, {
|
|
2988
|
-
code: p.invalid_type,
|
|
2989
|
-
expected: w.array,
|
|
2990
|
-
received: r.parsedType
|
|
2991
|
-
}), E;
|
|
2992
|
-
if (n.exactLength !== null) {
|
|
2993
|
-
const i = r.data.length > n.exactLength.value, o = r.data.length < n.exactLength.value;
|
|
2994
|
-
(i || o) && (b(r, {
|
|
2995
|
-
code: i ? p.too_big : p.too_small,
|
|
2996
|
-
minimum: o ? n.exactLength.value : void 0,
|
|
2997
|
-
maximum: i ? n.exactLength.value : void 0,
|
|
2998
|
-
type: "array",
|
|
2999
|
-
inclusive: !0,
|
|
3000
|
-
exact: !0,
|
|
3001
|
-
message: n.exactLength.message
|
|
3002
|
-
}), s.dirty());
|
|
3003
|
-
}
|
|
3004
|
-
if (n.minLength !== null && r.data.length < n.minLength.value && (b(r, {
|
|
3005
|
-
code: p.too_small,
|
|
3006
|
-
minimum: n.minLength.value,
|
|
3007
|
-
type: "array",
|
|
3008
|
-
inclusive: !0,
|
|
3009
|
-
exact: !1,
|
|
3010
|
-
message: n.minLength.message
|
|
3011
|
-
}), s.dirty()), n.maxLength !== null && r.data.length > n.maxLength.value && (b(r, {
|
|
3012
|
-
code: p.too_big,
|
|
3013
|
-
maximum: n.maxLength.value,
|
|
3014
|
-
type: "array",
|
|
3015
|
-
inclusive: !0,
|
|
3016
|
-
exact: !1,
|
|
3017
|
-
message: n.maxLength.message
|
|
3018
|
-
}), s.dirty()), r.common.async)
|
|
3019
|
-
return Promise.all([...r.data].map((i, o) => n.type._parseAsync(new Ae(r, i, r.path, o)))).then((i) => se.mergeArray(s, i));
|
|
3020
|
-
const a = [...r.data].map((i, o) => n.type._parseSync(new Ae(r, i, r.path, o)));
|
|
3021
|
-
return se.mergeArray(s, a);
|
|
3022
|
-
}
|
|
3023
|
-
get element() {
|
|
3024
|
-
return this._def.type;
|
|
3025
|
-
}
|
|
3026
|
-
min(e, r) {
|
|
3027
|
-
return new _e({
|
|
3028
|
-
...this._def,
|
|
3029
|
-
minLength: { value: e, message: T.toString(r) }
|
|
3030
|
-
});
|
|
3031
|
-
}
|
|
3032
|
-
max(e, r) {
|
|
3033
|
-
return new _e({
|
|
3034
|
-
...this._def,
|
|
3035
|
-
maxLength: { value: e, message: T.toString(r) }
|
|
3036
|
-
});
|
|
3037
|
-
}
|
|
3038
|
-
length(e, r) {
|
|
3039
|
-
return new _e({
|
|
3040
|
-
...this._def,
|
|
3041
|
-
exactLength: { value: e, message: T.toString(r) }
|
|
3042
|
-
});
|
|
3043
|
-
}
|
|
3044
|
-
nonempty(e) {
|
|
3045
|
-
return this.min(1, e);
|
|
3046
|
-
}
|
|
3047
|
-
}
|
|
3048
|
-
_e.create = (t, e) => new _e({
|
|
3049
|
-
type: t,
|
|
3050
|
-
minLength: null,
|
|
3051
|
-
maxLength: null,
|
|
3052
|
-
exactLength: null,
|
|
3053
|
-
typeName: j.ZodArray,
|
|
3054
|
-
...N(e)
|
|
3055
|
-
});
|
|
3056
|
-
function et(t) {
|
|
3057
|
-
if (t instanceof B) {
|
|
3058
|
-
const e = {};
|
|
3059
|
-
for (const r in t.shape) {
|
|
3060
|
-
const s = t.shape[r];
|
|
3061
|
-
e[r] = Se.create(et(s));
|
|
3062
|
-
}
|
|
3063
|
-
return new B({
|
|
3064
|
-
...t._def,
|
|
3065
|
-
shape: () => e
|
|
3066
|
-
});
|
|
3067
|
-
} else return t instanceof _e ? new _e({
|
|
3068
|
-
...t._def,
|
|
3069
|
-
type: et(t.element)
|
|
3070
|
-
}) : t instanceof Se ? Se.create(et(t.unwrap())) : t instanceof ze ? ze.create(et(t.unwrap())) : t instanceof Ee ? Ee.create(t.items.map((e) => et(e))) : t;
|
|
3071
|
-
}
|
|
3072
|
-
class B extends O {
|
|
3073
|
-
constructor() {
|
|
3074
|
-
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
3075
|
-
}
|
|
3076
|
-
_getCached() {
|
|
3077
|
-
if (this._cached !== null)
|
|
3078
|
-
return this._cached;
|
|
3079
|
-
const e = this._def.shape(), r = F.objectKeys(e);
|
|
3080
|
-
return this._cached = { shape: e, keys: r }, this._cached;
|
|
3081
|
-
}
|
|
3082
|
-
_parse(e) {
|
|
3083
|
-
if (this._getType(e) !== w.object) {
|
|
3084
|
-
const h = this._getOrReturnCtx(e);
|
|
3085
|
-
return b(h, {
|
|
3086
|
-
code: p.invalid_type,
|
|
3087
|
-
expected: w.object,
|
|
3088
|
-
received: h.parsedType
|
|
3089
|
-
}), E;
|
|
3090
|
-
}
|
|
3091
|
-
const { status: s, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
3092
|
-
if (!(this._def.catchall instanceof Fe && this._def.unknownKeys === "strip"))
|
|
3093
|
-
for (const h in n.data)
|
|
3094
|
-
i.includes(h) || o.push(h);
|
|
3095
|
-
const d = [];
|
|
3096
|
-
for (const h of i) {
|
|
3097
|
-
const f = a[h], x = n.data[h];
|
|
3098
|
-
d.push({
|
|
3099
|
-
key: { status: "valid", value: h },
|
|
3100
|
-
value: f._parse(new Ae(n, x, n.path, h)),
|
|
3101
|
-
alwaysSet: h in n.data
|
|
3102
|
-
});
|
|
3103
|
-
}
|
|
3104
|
-
if (this._def.catchall instanceof Fe) {
|
|
3105
|
-
const h = this._def.unknownKeys;
|
|
3106
|
-
if (h === "passthrough")
|
|
3107
|
-
for (const f of o)
|
|
3108
|
-
d.push({
|
|
3109
|
-
key: { status: "valid", value: f },
|
|
3110
|
-
value: { status: "valid", value: n.data[f] }
|
|
3111
|
-
});
|
|
3112
|
-
else if (h === "strict")
|
|
3113
|
-
o.length > 0 && (b(n, {
|
|
3114
|
-
code: p.unrecognized_keys,
|
|
3115
|
-
keys: o
|
|
3116
|
-
}), s.dirty());
|
|
3117
|
-
else if (h !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
3118
|
-
} else {
|
|
3119
|
-
const h = this._def.catchall;
|
|
3120
|
-
for (const f of o) {
|
|
3121
|
-
const x = n.data[f];
|
|
3122
|
-
d.push({
|
|
3123
|
-
key: { status: "valid", value: f },
|
|
3124
|
-
value: h._parse(
|
|
3125
|
-
new Ae(n, x, n.path, f)
|
|
3126
|
-
//, ctx.child(key), value, getParsedType(value)
|
|
3127
|
-
),
|
|
3128
|
-
alwaysSet: f in n.data
|
|
3129
|
-
});
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
return n.common.async ? Promise.resolve().then(async () => {
|
|
3133
|
-
const h = [];
|
|
3134
|
-
for (const f of d) {
|
|
3135
|
-
const x = await f.key, S = await f.value;
|
|
3136
|
-
h.push({
|
|
3137
|
-
key: x,
|
|
3138
|
-
value: S,
|
|
3139
|
-
alwaysSet: f.alwaysSet
|
|
3140
|
-
});
|
|
3141
|
-
}
|
|
3142
|
-
return h;
|
|
3143
|
-
}).then((h) => se.mergeObjectSync(s, h)) : se.mergeObjectSync(s, d);
|
|
3144
|
-
}
|
|
3145
|
-
get shape() {
|
|
3146
|
-
return this._def.shape();
|
|
3147
|
-
}
|
|
3148
|
-
strict(e) {
|
|
3149
|
-
return T.errToObj, new B({
|
|
3150
|
-
...this._def,
|
|
3151
|
-
unknownKeys: "strict",
|
|
3152
|
-
...e !== void 0 ? {
|
|
3153
|
-
errorMap: (r, s) => {
|
|
3154
|
-
var a, i;
|
|
3155
|
-
const n = ((i = (a = this._def).errorMap) == null ? void 0 : i.call(a, r, s).message) ?? s.defaultError;
|
|
3156
|
-
return r.code === "unrecognized_keys" ? {
|
|
3157
|
-
message: T.errToObj(e).message ?? n
|
|
3158
|
-
} : {
|
|
3159
|
-
message: n
|
|
3160
|
-
};
|
|
3161
|
-
}
|
|
3162
|
-
} : {}
|
|
3163
|
-
});
|
|
3164
|
-
}
|
|
3165
|
-
strip() {
|
|
3166
|
-
return new B({
|
|
3167
|
-
...this._def,
|
|
3168
|
-
unknownKeys: "strip"
|
|
3169
|
-
});
|
|
3170
|
-
}
|
|
3171
|
-
passthrough() {
|
|
3172
|
-
return new B({
|
|
3173
|
-
...this._def,
|
|
3174
|
-
unknownKeys: "passthrough"
|
|
3175
|
-
});
|
|
3176
|
-
}
|
|
3177
|
-
// const AugmentFactory =
|
|
3178
|
-
// <Def extends ZodObjectDef>(def: Def) =>
|
|
3179
|
-
// <Augmentation extends ZodRawShape>(
|
|
3180
|
-
// augmentation: Augmentation
|
|
3181
|
-
// ): ZodObject<
|
|
3182
|
-
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
3183
|
-
// Def["unknownKeys"],
|
|
3184
|
-
// Def["catchall"]
|
|
3185
|
-
// > => {
|
|
3186
|
-
// return new ZodObject({
|
|
3187
|
-
// ...def,
|
|
3188
|
-
// shape: () => ({
|
|
3189
|
-
// ...def.shape(),
|
|
3190
|
-
// ...augmentation,
|
|
3191
|
-
// }),
|
|
3192
|
-
// }) as any;
|
|
3193
|
-
// };
|
|
3194
|
-
extend(e) {
|
|
3195
|
-
return new B({
|
|
3196
|
-
...this._def,
|
|
3197
|
-
shape: () => ({
|
|
3198
|
-
...this._def.shape(),
|
|
3199
|
-
...e
|
|
3200
|
-
})
|
|
3201
|
-
});
|
|
3202
|
-
}
|
|
3203
|
-
/**
|
|
3204
|
-
* Prior to zod@1.0.12 there was a bug in the
|
|
3205
|
-
* inferred type of merged objects. Please
|
|
3206
|
-
* upgrade if you are experiencing issues.
|
|
3207
|
-
*/
|
|
3208
|
-
merge(e) {
|
|
3209
|
-
return new B({
|
|
3210
|
-
unknownKeys: e._def.unknownKeys,
|
|
3211
|
-
catchall: e._def.catchall,
|
|
3212
|
-
shape: () => ({
|
|
3213
|
-
...this._def.shape(),
|
|
3214
|
-
...e._def.shape()
|
|
3215
|
-
}),
|
|
3216
|
-
typeName: j.ZodObject
|
|
3217
|
-
});
|
|
3218
|
-
}
|
|
3219
|
-
// merge<
|
|
3220
|
-
// Incoming extends AnyZodObject,
|
|
3221
|
-
// Augmentation extends Incoming["shape"],
|
|
3222
|
-
// NewOutput extends {
|
|
3223
|
-
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
3224
|
-
// ? Augmentation[k]["_output"]
|
|
3225
|
-
// : k extends keyof Output
|
|
3226
|
-
// ? Output[k]
|
|
3227
|
-
// : never;
|
|
3228
|
-
// },
|
|
3229
|
-
// NewInput extends {
|
|
3230
|
-
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
3231
|
-
// ? Augmentation[k]["_input"]
|
|
3232
|
-
// : k extends keyof Input
|
|
3233
|
-
// ? Input[k]
|
|
3234
|
-
// : never;
|
|
3235
|
-
// }
|
|
3236
|
-
// >(
|
|
3237
|
-
// merging: Incoming
|
|
3238
|
-
// ): ZodObject<
|
|
3239
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3240
|
-
// Incoming["_def"]["unknownKeys"],
|
|
3241
|
-
// Incoming["_def"]["catchall"],
|
|
3242
|
-
// NewOutput,
|
|
3243
|
-
// NewInput
|
|
3244
|
-
// > {
|
|
3245
|
-
// const merged: any = new ZodObject({
|
|
3246
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
3247
|
-
// catchall: merging._def.catchall,
|
|
3248
|
-
// shape: () =>
|
|
3249
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3250
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3251
|
-
// }) as any;
|
|
3252
|
-
// return merged;
|
|
3253
|
-
// }
|
|
3254
|
-
setKey(e, r) {
|
|
3255
|
-
return this.augment({ [e]: r });
|
|
3256
|
-
}
|
|
3257
|
-
// merge<Incoming extends AnyZodObject>(
|
|
3258
|
-
// merging: Incoming
|
|
3259
|
-
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
3260
|
-
// ZodObject<
|
|
3261
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3262
|
-
// Incoming["_def"]["unknownKeys"],
|
|
3263
|
-
// Incoming["_def"]["catchall"]
|
|
3264
|
-
// > {
|
|
3265
|
-
// // const mergedShape = objectUtil.mergeShapes(
|
|
3266
|
-
// // this._def.shape(),
|
|
3267
|
-
// // merging._def.shape()
|
|
3268
|
-
// // );
|
|
3269
|
-
// const merged: any = new ZodObject({
|
|
3270
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
3271
|
-
// catchall: merging._def.catchall,
|
|
3272
|
-
// shape: () =>
|
|
3273
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3274
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3275
|
-
// }) as any;
|
|
3276
|
-
// return merged;
|
|
3277
|
-
// }
|
|
3278
|
-
catchall(e) {
|
|
3279
|
-
return new B({
|
|
3280
|
-
...this._def,
|
|
3281
|
-
catchall: e
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
pick(e) {
|
|
3285
|
-
const r = {};
|
|
3286
|
-
for (const s of F.objectKeys(e))
|
|
3287
|
-
e[s] && this.shape[s] && (r[s] = this.shape[s]);
|
|
3288
|
-
return new B({
|
|
3289
|
-
...this._def,
|
|
3290
|
-
shape: () => r
|
|
3291
|
-
});
|
|
3292
|
-
}
|
|
3293
|
-
omit(e) {
|
|
3294
|
-
const r = {};
|
|
3295
|
-
for (const s of F.objectKeys(this.shape))
|
|
3296
|
-
e[s] || (r[s] = this.shape[s]);
|
|
3297
|
-
return new B({
|
|
3298
|
-
...this._def,
|
|
3299
|
-
shape: () => r
|
|
3300
|
-
});
|
|
3301
|
-
}
|
|
3302
|
-
/**
|
|
3303
|
-
* @deprecated
|
|
3304
|
-
*/
|
|
3305
|
-
deepPartial() {
|
|
3306
|
-
return et(this);
|
|
3307
|
-
}
|
|
3308
|
-
partial(e) {
|
|
3309
|
-
const r = {};
|
|
3310
|
-
for (const s of F.objectKeys(this.shape)) {
|
|
3311
|
-
const n = this.shape[s];
|
|
3312
|
-
e && !e[s] ? r[s] = n : r[s] = n.optional();
|
|
3313
|
-
}
|
|
3314
|
-
return new B({
|
|
3315
|
-
...this._def,
|
|
3316
|
-
shape: () => r
|
|
3317
|
-
});
|
|
3318
|
-
}
|
|
3319
|
-
required(e) {
|
|
3320
|
-
const r = {};
|
|
3321
|
-
for (const s of F.objectKeys(this.shape))
|
|
3322
|
-
if (e && !e[s])
|
|
3323
|
-
r[s] = this.shape[s];
|
|
3324
|
-
else {
|
|
3325
|
-
let a = this.shape[s];
|
|
3326
|
-
for (; a instanceof Se; )
|
|
3327
|
-
a = a._def.innerType;
|
|
3328
|
-
r[s] = a;
|
|
3329
|
-
}
|
|
3330
|
-
return new B({
|
|
3331
|
-
...this._def,
|
|
3332
|
-
shape: () => r
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3335
|
-
keyof() {
|
|
3336
|
-
return ss(F.objectKeys(this.shape));
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
B.create = (t, e) => new B({
|
|
3340
|
-
shape: () => t,
|
|
3341
|
-
unknownKeys: "strip",
|
|
3342
|
-
catchall: Fe.create(),
|
|
3343
|
-
typeName: j.ZodObject,
|
|
3344
|
-
...N(e)
|
|
3345
|
-
});
|
|
3346
|
-
B.strictCreate = (t, e) => new B({
|
|
3347
|
-
shape: () => t,
|
|
3348
|
-
unknownKeys: "strict",
|
|
3349
|
-
catchall: Fe.create(),
|
|
3350
|
-
typeName: j.ZodObject,
|
|
3351
|
-
...N(e)
|
|
3352
|
-
});
|
|
3353
|
-
B.lazycreate = (t, e) => new B({
|
|
3354
|
-
shape: t,
|
|
3355
|
-
unknownKeys: "strip",
|
|
3356
|
-
catchall: Fe.create(),
|
|
3357
|
-
typeName: j.ZodObject,
|
|
3358
|
-
...N(e)
|
|
3359
|
-
});
|
|
3360
|
-
class vt extends O {
|
|
3361
|
-
_parse(e) {
|
|
3362
|
-
const { ctx: r } = this._processInputParams(e), s = this._def.options;
|
|
3363
|
-
function n(a) {
|
|
3364
|
-
for (const o of a)
|
|
3365
|
-
if (o.result.status === "valid")
|
|
3366
|
-
return o.result;
|
|
3367
|
-
for (const o of a)
|
|
3368
|
-
if (o.result.status === "dirty")
|
|
3369
|
-
return r.common.issues.push(...o.ctx.common.issues), o.result;
|
|
3370
|
-
const i = a.map((o) => new he(o.ctx.common.issues));
|
|
3371
|
-
return b(r, {
|
|
3372
|
-
code: p.invalid_union,
|
|
3373
|
-
unionErrors: i
|
|
3374
|
-
}), E;
|
|
3375
|
-
}
|
|
3376
|
-
if (r.common.async)
|
|
3377
|
-
return Promise.all(s.map(async (a) => {
|
|
3378
|
-
const i = {
|
|
3379
|
-
...r,
|
|
3380
|
-
common: {
|
|
3381
|
-
...r.common,
|
|
3382
|
-
issues: []
|
|
3383
|
-
},
|
|
3384
|
-
parent: null
|
|
3385
|
-
};
|
|
3386
|
-
return {
|
|
3387
|
-
result: await a._parseAsync({
|
|
3388
|
-
data: r.data,
|
|
3389
|
-
path: r.path,
|
|
3390
|
-
parent: i
|
|
3391
|
-
}),
|
|
3392
|
-
ctx: i
|
|
3393
|
-
};
|
|
3394
|
-
})).then(n);
|
|
3395
|
-
{
|
|
3396
|
-
let a;
|
|
3397
|
-
const i = [];
|
|
3398
|
-
for (const d of s) {
|
|
3399
|
-
const h = {
|
|
3400
|
-
...r,
|
|
3401
|
-
common: {
|
|
3402
|
-
...r.common,
|
|
3403
|
-
issues: []
|
|
3404
|
-
},
|
|
3405
|
-
parent: null
|
|
3406
|
-
}, f = d._parseSync({
|
|
3407
|
-
data: r.data,
|
|
3408
|
-
path: r.path,
|
|
3409
|
-
parent: h
|
|
3410
|
-
});
|
|
3411
|
-
if (f.status === "valid")
|
|
3412
|
-
return f;
|
|
3413
|
-
f.status === "dirty" && !a && (a = { result: f, ctx: h }), h.common.issues.length && i.push(h.common.issues);
|
|
3414
|
-
}
|
|
3415
|
-
if (a)
|
|
3416
|
-
return r.common.issues.push(...a.ctx.common.issues), a.result;
|
|
3417
|
-
const o = i.map((d) => new he(d));
|
|
3418
|
-
return b(r, {
|
|
3419
|
-
code: p.invalid_union,
|
|
3420
|
-
unionErrors: o
|
|
3421
|
-
}), E;
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
get options() {
|
|
3425
|
-
return this._def.options;
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
vt.create = (t, e) => new vt({
|
|
3429
|
-
options: t,
|
|
3430
|
-
typeName: j.ZodUnion,
|
|
3431
|
-
...N(e)
|
|
3432
|
-
});
|
|
3433
|
-
const Oe = (t) => t instanceof xt ? Oe(t.schema) : t instanceof be ? Oe(t.innerType()) : t instanceof kt ? [t.value] : t instanceof Ue ? t.options : t instanceof wt ? F.objectValues(t.enum) : t instanceof Tt ? Oe(t._def.innerType) : t instanceof yt ? [void 0] : t instanceof gt ? [null] : t instanceof Se ? [void 0, ...Oe(t.unwrap())] : t instanceof ze ? [null, ...Oe(t.unwrap())] : t instanceof lr || t instanceof At ? Oe(t.unwrap()) : t instanceof St ? Oe(t._def.innerType) : [];
|
|
3434
|
-
class Wt extends O {
|
|
3435
|
-
_parse(e) {
|
|
3436
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3437
|
-
if (r.parsedType !== w.object)
|
|
3438
|
-
return b(r, {
|
|
3439
|
-
code: p.invalid_type,
|
|
3440
|
-
expected: w.object,
|
|
3441
|
-
received: r.parsedType
|
|
3442
|
-
}), E;
|
|
3443
|
-
const s = this.discriminator, n = r.data[s], a = this.optionsMap.get(n);
|
|
3444
|
-
return a ? r.common.async ? a._parseAsync({
|
|
3445
|
-
data: r.data,
|
|
3446
|
-
path: r.path,
|
|
3447
|
-
parent: r
|
|
3448
|
-
}) : a._parseSync({
|
|
3449
|
-
data: r.data,
|
|
3450
|
-
path: r.path,
|
|
3451
|
-
parent: r
|
|
3452
|
-
}) : (b(r, {
|
|
3453
|
-
code: p.invalid_union_discriminator,
|
|
3454
|
-
options: Array.from(this.optionsMap.keys()),
|
|
3455
|
-
path: [s]
|
|
3456
|
-
}), E);
|
|
3457
|
-
}
|
|
3458
|
-
get discriminator() {
|
|
3459
|
-
return this._def.discriminator;
|
|
3460
|
-
}
|
|
3461
|
-
get options() {
|
|
3462
|
-
return this._def.options;
|
|
3463
|
-
}
|
|
3464
|
-
get optionsMap() {
|
|
3465
|
-
return this._def.optionsMap;
|
|
3466
|
-
}
|
|
3467
|
-
/**
|
|
3468
|
-
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
3469
|
-
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
3470
|
-
* have a different value for each object in the union.
|
|
3471
|
-
* @param discriminator the name of the discriminator property
|
|
3472
|
-
* @param types an array of object schemas
|
|
3473
|
-
* @param params
|
|
3474
|
-
*/
|
|
3475
|
-
static create(e, r, s) {
|
|
3476
|
-
const n = /* @__PURE__ */ new Map();
|
|
3477
|
-
for (const a of r) {
|
|
3478
|
-
const i = Oe(a.shape[e]);
|
|
3479
|
-
if (!i.length)
|
|
3480
|
-
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
3481
|
-
for (const o of i) {
|
|
3482
|
-
if (n.has(o))
|
|
3483
|
-
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
3484
|
-
n.set(o, a);
|
|
3485
|
-
}
|
|
3486
|
-
}
|
|
3487
|
-
return new Wt({
|
|
3488
|
-
typeName: j.ZodDiscriminatedUnion,
|
|
3489
|
-
discriminator: e,
|
|
3490
|
-
options: r,
|
|
3491
|
-
optionsMap: n,
|
|
3492
|
-
...N(s)
|
|
3493
|
-
});
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
|
-
function rr(t, e) {
|
|
3497
|
-
const r = Ve(t), s = Ve(e);
|
|
3498
|
-
if (t === e)
|
|
3499
|
-
return { valid: !0, data: t };
|
|
3500
|
-
if (r === w.object && s === w.object) {
|
|
3501
|
-
const n = F.objectKeys(e), a = F.objectKeys(t).filter((o) => n.indexOf(o) !== -1), i = { ...t, ...e };
|
|
3502
|
-
for (const o of a) {
|
|
3503
|
-
const d = rr(t[o], e[o]);
|
|
3504
|
-
if (!d.valid)
|
|
3505
|
-
return { valid: !1 };
|
|
3506
|
-
i[o] = d.data;
|
|
3507
|
-
}
|
|
3508
|
-
return { valid: !0, data: i };
|
|
3509
|
-
} else if (r === w.array && s === w.array) {
|
|
3510
|
-
if (t.length !== e.length)
|
|
3511
|
-
return { valid: !1 };
|
|
3512
|
-
const n = [];
|
|
3513
|
-
for (let a = 0; a < t.length; a++) {
|
|
3514
|
-
const i = t[a], o = e[a], d = rr(i, o);
|
|
3515
|
-
if (!d.valid)
|
|
3516
|
-
return { valid: !1 };
|
|
3517
|
-
n.push(d.data);
|
|
3518
|
-
}
|
|
3519
|
-
return { valid: !0, data: n };
|
|
3520
|
-
} else return r === w.date && s === w.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
3521
|
-
}
|
|
3522
|
-
class _t extends O {
|
|
3523
|
-
_parse(e) {
|
|
3524
|
-
const { status: r, ctx: s } = this._processInputParams(e), n = (a, i) => {
|
|
3525
|
-
if (er(a) || er(i))
|
|
3526
|
-
return E;
|
|
3527
|
-
const o = rr(a.value, i.value);
|
|
3528
|
-
return o.valid ? ((tr(a) || tr(i)) && r.dirty(), { status: r.value, value: o.data }) : (b(s, {
|
|
3529
|
-
code: p.invalid_intersection_types
|
|
3530
|
-
}), E);
|
|
3531
|
-
};
|
|
3532
|
-
return s.common.async ? Promise.all([
|
|
3533
|
-
this._def.left._parseAsync({
|
|
3534
|
-
data: s.data,
|
|
3535
|
-
path: s.path,
|
|
3536
|
-
parent: s
|
|
3537
|
-
}),
|
|
3538
|
-
this._def.right._parseAsync({
|
|
3539
|
-
data: s.data,
|
|
3540
|
-
path: s.path,
|
|
3541
|
-
parent: s
|
|
3542
|
-
})
|
|
3543
|
-
]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
|
|
3544
|
-
data: s.data,
|
|
3545
|
-
path: s.path,
|
|
3546
|
-
parent: s
|
|
3547
|
-
}), this._def.right._parseSync({
|
|
3548
|
-
data: s.data,
|
|
3549
|
-
path: s.path,
|
|
3550
|
-
parent: s
|
|
3551
|
-
}));
|
|
3552
|
-
}
|
|
3553
|
-
}
|
|
3554
|
-
_t.create = (t, e, r) => new _t({
|
|
3555
|
-
left: t,
|
|
3556
|
-
right: e,
|
|
3557
|
-
typeName: j.ZodIntersection,
|
|
3558
|
-
...N(r)
|
|
3559
|
-
});
|
|
3560
|
-
class Ee extends O {
|
|
3561
|
-
_parse(e) {
|
|
3562
|
-
const { status: r, ctx: s } = this._processInputParams(e);
|
|
3563
|
-
if (s.parsedType !== w.array)
|
|
3564
|
-
return b(s, {
|
|
3565
|
-
code: p.invalid_type,
|
|
3566
|
-
expected: w.array,
|
|
3567
|
-
received: s.parsedType
|
|
3568
|
-
}), E;
|
|
3569
|
-
if (s.data.length < this._def.items.length)
|
|
3570
|
-
return b(s, {
|
|
3571
|
-
code: p.too_small,
|
|
3572
|
-
minimum: this._def.items.length,
|
|
3573
|
-
inclusive: !0,
|
|
3574
|
-
exact: !1,
|
|
3575
|
-
type: "array"
|
|
3576
|
-
}), E;
|
|
3577
|
-
!this._def.rest && s.data.length > this._def.items.length && (b(s, {
|
|
3578
|
-
code: p.too_big,
|
|
3579
|
-
maximum: this._def.items.length,
|
|
3580
|
-
inclusive: !0,
|
|
3581
|
-
exact: !1,
|
|
3582
|
-
type: "array"
|
|
3583
|
-
}), r.dirty());
|
|
3584
|
-
const a = [...s.data].map((i, o) => {
|
|
3585
|
-
const d = this._def.items[o] || this._def.rest;
|
|
3586
|
-
return d ? d._parse(new Ae(s, i, s.path, o)) : null;
|
|
3587
|
-
}).filter((i) => !!i);
|
|
3588
|
-
return s.common.async ? Promise.all(a).then((i) => se.mergeArray(r, i)) : se.mergeArray(r, a);
|
|
3589
|
-
}
|
|
3590
|
-
get items() {
|
|
3591
|
-
return this._def.items;
|
|
3592
|
-
}
|
|
3593
|
-
rest(e) {
|
|
3594
|
-
return new Ee({
|
|
3595
|
-
...this._def,
|
|
3596
|
-
rest: e
|
|
3597
|
-
});
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
|
-
Ee.create = (t, e) => {
|
|
3601
|
-
if (!Array.isArray(t))
|
|
3602
|
-
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
3603
|
-
return new Ee({
|
|
3604
|
-
items: t,
|
|
3605
|
-
typeName: j.ZodTuple,
|
|
3606
|
-
rest: null,
|
|
3607
|
-
...N(e)
|
|
3608
|
-
});
|
|
3609
|
-
};
|
|
3610
|
-
class bt extends O {
|
|
3611
|
-
get keySchema() {
|
|
3612
|
-
return this._def.keyType;
|
|
3613
|
-
}
|
|
3614
|
-
get valueSchema() {
|
|
3615
|
-
return this._def.valueType;
|
|
3616
|
-
}
|
|
3617
|
-
_parse(e) {
|
|
3618
|
-
const { status: r, ctx: s } = this._processInputParams(e);
|
|
3619
|
-
if (s.parsedType !== w.object)
|
|
3620
|
-
return b(s, {
|
|
3621
|
-
code: p.invalid_type,
|
|
3622
|
-
expected: w.object,
|
|
3623
|
-
received: s.parsedType
|
|
3624
|
-
}), E;
|
|
3625
|
-
const n = [], a = this._def.keyType, i = this._def.valueType;
|
|
3626
|
-
for (const o in s.data)
|
|
3627
|
-
n.push({
|
|
3628
|
-
key: a._parse(new Ae(s, o, s.path, o)),
|
|
3629
|
-
value: i._parse(new Ae(s, s.data[o], s.path, o)),
|
|
3630
|
-
alwaysSet: o in s.data
|
|
3631
|
-
});
|
|
3632
|
-
return s.common.async ? se.mergeObjectAsync(r, n) : se.mergeObjectSync(r, n);
|
|
3633
|
-
}
|
|
3634
|
-
get element() {
|
|
3635
|
-
return this._def.valueType;
|
|
3636
|
-
}
|
|
3637
|
-
static create(e, r, s) {
|
|
3638
|
-
return r instanceof O ? new bt({
|
|
3639
|
-
keyType: e,
|
|
3640
|
-
valueType: r,
|
|
3641
|
-
typeName: j.ZodRecord,
|
|
3642
|
-
...N(s)
|
|
3643
|
-
}) : new bt({
|
|
3644
|
-
keyType: ve.create(),
|
|
3645
|
-
valueType: e,
|
|
3646
|
-
typeName: j.ZodRecord,
|
|
3647
|
-
...N(r)
|
|
3648
|
-
});
|
|
3649
|
-
}
|
|
3650
|
-
}
|
|
3651
|
-
class $t extends O {
|
|
3652
|
-
get keySchema() {
|
|
3653
|
-
return this._def.keyType;
|
|
3654
|
-
}
|
|
3655
|
-
get valueSchema() {
|
|
3656
|
-
return this._def.valueType;
|
|
3657
|
-
}
|
|
3658
|
-
_parse(e) {
|
|
3659
|
-
const { status: r, ctx: s } = this._processInputParams(e);
|
|
3660
|
-
if (s.parsedType !== w.map)
|
|
3661
|
-
return b(s, {
|
|
3662
|
-
code: p.invalid_type,
|
|
3663
|
-
expected: w.map,
|
|
3664
|
-
received: s.parsedType
|
|
3665
|
-
}), E;
|
|
3666
|
-
const n = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, d], h) => ({
|
|
3667
|
-
key: n._parse(new Ae(s, o, s.path, [h, "key"])),
|
|
3668
|
-
value: a._parse(new Ae(s, d, s.path, [h, "value"]))
|
|
3669
|
-
}));
|
|
3670
|
-
if (s.common.async) {
|
|
3671
|
-
const o = /* @__PURE__ */ new Map();
|
|
3672
|
-
return Promise.resolve().then(async () => {
|
|
3673
|
-
for (const d of i) {
|
|
3674
|
-
const h = await d.key, f = await d.value;
|
|
3675
|
-
if (h.status === "aborted" || f.status === "aborted")
|
|
3676
|
-
return E;
|
|
3677
|
-
(h.status === "dirty" || f.status === "dirty") && r.dirty(), o.set(h.value, f.value);
|
|
3678
|
-
}
|
|
3679
|
-
return { status: r.value, value: o };
|
|
3680
|
-
});
|
|
3681
|
-
} else {
|
|
3682
|
-
const o = /* @__PURE__ */ new Map();
|
|
3683
|
-
for (const d of i) {
|
|
3684
|
-
const h = d.key, f = d.value;
|
|
3685
|
-
if (h.status === "aborted" || f.status === "aborted")
|
|
3686
|
-
return E;
|
|
3687
|
-
(h.status === "dirty" || f.status === "dirty") && r.dirty(), o.set(h.value, f.value);
|
|
3688
|
-
}
|
|
3689
|
-
return { status: r.value, value: o };
|
|
3690
|
-
}
|
|
3691
|
-
}
|
|
3692
|
-
}
|
|
3693
|
-
$t.create = (t, e, r) => new $t({
|
|
3694
|
-
valueType: e,
|
|
3695
|
-
keyType: t,
|
|
3696
|
-
typeName: j.ZodMap,
|
|
3697
|
-
...N(r)
|
|
3698
|
-
});
|
|
3699
|
-
class Ge extends O {
|
|
3700
|
-
_parse(e) {
|
|
3701
|
-
const { status: r, ctx: s } = this._processInputParams(e);
|
|
3702
|
-
if (s.parsedType !== w.set)
|
|
3703
|
-
return b(s, {
|
|
3704
|
-
code: p.invalid_type,
|
|
3705
|
-
expected: w.set,
|
|
3706
|
-
received: s.parsedType
|
|
3707
|
-
}), E;
|
|
3708
|
-
const n = this._def;
|
|
3709
|
-
n.minSize !== null && s.data.size < n.minSize.value && (b(s, {
|
|
3710
|
-
code: p.too_small,
|
|
3711
|
-
minimum: n.minSize.value,
|
|
3712
|
-
type: "set",
|
|
3713
|
-
inclusive: !0,
|
|
3714
|
-
exact: !1,
|
|
3715
|
-
message: n.minSize.message
|
|
3716
|
-
}), r.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (b(s, {
|
|
3717
|
-
code: p.too_big,
|
|
3718
|
-
maximum: n.maxSize.value,
|
|
3719
|
-
type: "set",
|
|
3720
|
-
inclusive: !0,
|
|
3721
|
-
exact: !1,
|
|
3722
|
-
message: n.maxSize.message
|
|
3723
|
-
}), r.dirty());
|
|
3724
|
-
const a = this._def.valueType;
|
|
3725
|
-
function i(d) {
|
|
3726
|
-
const h = /* @__PURE__ */ new Set();
|
|
3727
|
-
for (const f of d) {
|
|
3728
|
-
if (f.status === "aborted")
|
|
3729
|
-
return E;
|
|
3730
|
-
f.status === "dirty" && r.dirty(), h.add(f.value);
|
|
3731
|
-
}
|
|
3732
|
-
return { status: r.value, value: h };
|
|
3733
|
-
}
|
|
3734
|
-
const o = [...s.data.values()].map((d, h) => a._parse(new Ae(s, d, s.path, h)));
|
|
3735
|
-
return s.common.async ? Promise.all(o).then((d) => i(d)) : i(o);
|
|
3736
|
-
}
|
|
3737
|
-
min(e, r) {
|
|
3738
|
-
return new Ge({
|
|
3739
|
-
...this._def,
|
|
3740
|
-
minSize: { value: e, message: T.toString(r) }
|
|
3741
|
-
});
|
|
3742
|
-
}
|
|
3743
|
-
max(e, r) {
|
|
3744
|
-
return new Ge({
|
|
3745
|
-
...this._def,
|
|
3746
|
-
maxSize: { value: e, message: T.toString(r) }
|
|
3747
|
-
});
|
|
3748
|
-
}
|
|
3749
|
-
size(e, r) {
|
|
3750
|
-
return this.min(e, r).max(e, r);
|
|
3751
|
-
}
|
|
3752
|
-
nonempty(e) {
|
|
3753
|
-
return this.min(1, e);
|
|
3754
|
-
}
|
|
3755
|
-
}
|
|
3756
|
-
Ge.create = (t, e) => new Ge({
|
|
3757
|
-
valueType: t,
|
|
3758
|
-
minSize: null,
|
|
3759
|
-
maxSize: null,
|
|
3760
|
-
typeName: j.ZodSet,
|
|
3761
|
-
...N(e)
|
|
3762
|
-
});
|
|
3763
|
-
class rt extends O {
|
|
3764
|
-
constructor() {
|
|
3765
|
-
super(...arguments), this.validate = this.implement;
|
|
3766
|
-
}
|
|
3767
|
-
_parse(e) {
|
|
3768
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3769
|
-
if (r.parsedType !== w.function)
|
|
3770
|
-
return b(r, {
|
|
3771
|
-
code: p.invalid_type,
|
|
3772
|
-
expected: w.function,
|
|
3773
|
-
received: r.parsedType
|
|
3774
|
-
}), E;
|
|
3775
|
-
function s(o, d) {
|
|
3776
|
-
return Mt({
|
|
3777
|
-
data: o,
|
|
3778
|
-
path: r.path,
|
|
3779
|
-
errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Dt(), nt].filter((h) => !!h),
|
|
3780
|
-
issueData: {
|
|
3781
|
-
code: p.invalid_arguments,
|
|
3782
|
-
argumentsError: d
|
|
3783
|
-
}
|
|
3784
|
-
});
|
|
3785
|
-
}
|
|
3786
|
-
function n(o, d) {
|
|
3787
|
-
return Mt({
|
|
3788
|
-
data: o,
|
|
3789
|
-
path: r.path,
|
|
3790
|
-
errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Dt(), nt].filter((h) => !!h),
|
|
3791
|
-
issueData: {
|
|
3792
|
-
code: p.invalid_return_type,
|
|
3793
|
-
returnTypeError: d
|
|
3794
|
-
}
|
|
3795
|
-
});
|
|
3796
|
-
}
|
|
3797
|
-
const a = { errorMap: r.common.contextualErrorMap }, i = r.data;
|
|
3798
|
-
if (this._def.returns instanceof it) {
|
|
3799
|
-
const o = this;
|
|
3800
|
-
return ae(async function(...d) {
|
|
3801
|
-
const h = new he([]), f = await o._def.args.parseAsync(d, a).catch((W) => {
|
|
3802
|
-
throw h.addIssue(s(d, W)), h;
|
|
3803
|
-
}), x = await Reflect.apply(i, this, f);
|
|
3804
|
-
return await o._def.returns._def.type.parseAsync(x, a).catch((W) => {
|
|
3805
|
-
throw h.addIssue(n(x, W)), h;
|
|
3806
|
-
});
|
|
3807
|
-
});
|
|
3808
|
-
} else {
|
|
3809
|
-
const o = this;
|
|
3810
|
-
return ae(function(...d) {
|
|
3811
|
-
const h = o._def.args.safeParse(d, a);
|
|
3812
|
-
if (!h.success)
|
|
3813
|
-
throw new he([s(d, h.error)]);
|
|
3814
|
-
const f = Reflect.apply(i, this, h.data), x = o._def.returns.safeParse(f, a);
|
|
3815
|
-
if (!x.success)
|
|
3816
|
-
throw new he([n(f, x.error)]);
|
|
3817
|
-
return x.data;
|
|
3818
|
-
});
|
|
3819
|
-
}
|
|
3820
|
-
}
|
|
3821
|
-
parameters() {
|
|
3822
|
-
return this._def.args;
|
|
3823
|
-
}
|
|
3824
|
-
returnType() {
|
|
3825
|
-
return this._def.returns;
|
|
3826
|
-
}
|
|
3827
|
-
args(...e) {
|
|
3828
|
-
return new rt({
|
|
3829
|
-
...this._def,
|
|
3830
|
-
args: Ee.create(e).rest(Ye.create())
|
|
3831
|
-
});
|
|
3832
|
-
}
|
|
3833
|
-
returns(e) {
|
|
3834
|
-
return new rt({
|
|
3835
|
-
...this._def,
|
|
3836
|
-
returns: e
|
|
3837
|
-
});
|
|
3838
|
-
}
|
|
3839
|
-
implement(e) {
|
|
3840
|
-
return this.parse(e);
|
|
3841
|
-
}
|
|
3842
|
-
strictImplement(e) {
|
|
3843
|
-
return this.parse(e);
|
|
3844
|
-
}
|
|
3845
|
-
static create(e, r, s) {
|
|
3846
|
-
return new rt({
|
|
3847
|
-
args: e || Ee.create([]).rest(Ye.create()),
|
|
3848
|
-
returns: r || Ye.create(),
|
|
3849
|
-
typeName: j.ZodFunction,
|
|
3850
|
-
...N(s)
|
|
3851
|
-
});
|
|
3852
|
-
}
|
|
3853
|
-
}
|
|
3854
|
-
class xt extends O {
|
|
3855
|
-
get schema() {
|
|
3856
|
-
return this._def.getter();
|
|
3857
|
-
}
|
|
3858
|
-
_parse(e) {
|
|
3859
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3860
|
-
return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
xt.create = (t, e) => new xt({
|
|
3864
|
-
getter: t,
|
|
3865
|
-
typeName: j.ZodLazy,
|
|
3866
|
-
...N(e)
|
|
3867
|
-
});
|
|
3868
|
-
class kt extends O {
|
|
3869
|
-
_parse(e) {
|
|
3870
|
-
if (e.data !== this._def.value) {
|
|
3871
|
-
const r = this._getOrReturnCtx(e);
|
|
3872
|
-
return b(r, {
|
|
3873
|
-
received: r.data,
|
|
3874
|
-
code: p.invalid_literal,
|
|
3875
|
-
expected: this._def.value
|
|
3876
|
-
}), E;
|
|
3877
|
-
}
|
|
3878
|
-
return { status: "valid", value: e.data };
|
|
3879
|
-
}
|
|
3880
|
-
get value() {
|
|
3881
|
-
return this._def.value;
|
|
3882
|
-
}
|
|
3883
|
-
}
|
|
3884
|
-
kt.create = (t, e) => new kt({
|
|
3885
|
-
value: t,
|
|
3886
|
-
typeName: j.ZodLiteral,
|
|
3887
|
-
...N(e)
|
|
3888
|
-
});
|
|
3889
|
-
function ss(t, e) {
|
|
3890
|
-
return new Ue({
|
|
3891
|
-
values: t,
|
|
3892
|
-
typeName: j.ZodEnum,
|
|
3893
|
-
...N(e)
|
|
3894
|
-
});
|
|
3895
|
-
}
|
|
3896
|
-
class Ue extends O {
|
|
3897
|
-
_parse(e) {
|
|
3898
|
-
if (typeof e.data != "string") {
|
|
3899
|
-
const r = this._getOrReturnCtx(e), s = this._def.values;
|
|
3900
|
-
return b(r, {
|
|
3901
|
-
expected: F.joinValues(s),
|
|
3902
|
-
received: r.parsedType,
|
|
3903
|
-
code: p.invalid_type
|
|
3904
|
-
}), E;
|
|
3905
|
-
}
|
|
3906
|
-
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
3907
|
-
const r = this._getOrReturnCtx(e), s = this._def.values;
|
|
3908
|
-
return b(r, {
|
|
3909
|
-
received: r.data,
|
|
3910
|
-
code: p.invalid_enum_value,
|
|
3911
|
-
options: s
|
|
3912
|
-
}), E;
|
|
3913
|
-
}
|
|
3914
|
-
return ae(e.data);
|
|
3915
|
-
}
|
|
3916
|
-
get options() {
|
|
3917
|
-
return this._def.values;
|
|
3918
|
-
}
|
|
3919
|
-
get enum() {
|
|
3920
|
-
const e = {};
|
|
3921
|
-
for (const r of this._def.values)
|
|
3922
|
-
e[r] = r;
|
|
3923
|
-
return e;
|
|
3924
|
-
}
|
|
3925
|
-
get Values() {
|
|
3926
|
-
const e = {};
|
|
3927
|
-
for (const r of this._def.values)
|
|
3928
|
-
e[r] = r;
|
|
3929
|
-
return e;
|
|
3930
|
-
}
|
|
3931
|
-
get Enum() {
|
|
3932
|
-
const e = {};
|
|
3933
|
-
for (const r of this._def.values)
|
|
3934
|
-
e[r] = r;
|
|
3935
|
-
return e;
|
|
3936
|
-
}
|
|
3937
|
-
extract(e, r = this._def) {
|
|
3938
|
-
return Ue.create(e, {
|
|
3939
|
-
...this._def,
|
|
3940
|
-
...r
|
|
3941
|
-
});
|
|
3942
|
-
}
|
|
3943
|
-
exclude(e, r = this._def) {
|
|
3944
|
-
return Ue.create(this.options.filter((s) => !e.includes(s)), {
|
|
3945
|
-
...this._def,
|
|
3946
|
-
...r
|
|
3947
|
-
});
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
Ue.create = ss;
|
|
3951
|
-
class wt extends O {
|
|
3952
|
-
_parse(e) {
|
|
3953
|
-
const r = F.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
3954
|
-
if (s.parsedType !== w.string && s.parsedType !== w.number) {
|
|
3955
|
-
const n = F.objectValues(r);
|
|
3956
|
-
return b(s, {
|
|
3957
|
-
expected: F.joinValues(n),
|
|
3958
|
-
received: s.parsedType,
|
|
3959
|
-
code: p.invalid_type
|
|
3960
|
-
}), E;
|
|
3961
|
-
}
|
|
3962
|
-
if (this._cache || (this._cache = new Set(F.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
3963
|
-
const n = F.objectValues(r);
|
|
3964
|
-
return b(s, {
|
|
3965
|
-
received: s.data,
|
|
3966
|
-
code: p.invalid_enum_value,
|
|
3967
|
-
options: n
|
|
3968
|
-
}), E;
|
|
3969
|
-
}
|
|
3970
|
-
return ae(e.data);
|
|
3971
|
-
}
|
|
3972
|
-
get enum() {
|
|
3973
|
-
return this._def.values;
|
|
3974
|
-
}
|
|
3975
|
-
}
|
|
3976
|
-
wt.create = (t, e) => new wt({
|
|
3977
|
-
values: t,
|
|
3978
|
-
typeName: j.ZodNativeEnum,
|
|
3979
|
-
...N(e)
|
|
3980
|
-
});
|
|
3981
|
-
class it extends O {
|
|
3982
|
-
unwrap() {
|
|
3983
|
-
return this._def.type;
|
|
3984
|
-
}
|
|
3985
|
-
_parse(e) {
|
|
3986
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3987
|
-
if (r.parsedType !== w.promise && r.common.async === !1)
|
|
3988
|
-
return b(r, {
|
|
3989
|
-
code: p.invalid_type,
|
|
3990
|
-
expected: w.promise,
|
|
3991
|
-
received: r.parsedType
|
|
3992
|
-
}), E;
|
|
3993
|
-
const s = r.parsedType === w.promise ? r.data : Promise.resolve(r.data);
|
|
3994
|
-
return ae(s.then((n) => this._def.type.parseAsync(n, {
|
|
3995
|
-
path: r.path,
|
|
3996
|
-
errorMap: r.common.contextualErrorMap
|
|
3997
|
-
})));
|
|
3998
|
-
}
|
|
3999
|
-
}
|
|
4000
|
-
it.create = (t, e) => new it({
|
|
4001
|
-
type: t,
|
|
4002
|
-
typeName: j.ZodPromise,
|
|
4003
|
-
...N(e)
|
|
4004
|
-
});
|
|
4005
|
-
class be extends O {
|
|
4006
|
-
innerType() {
|
|
4007
|
-
return this._def.schema;
|
|
4008
|
-
}
|
|
4009
|
-
sourceType() {
|
|
4010
|
-
return this._def.schema._def.typeName === j.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
4011
|
-
}
|
|
4012
|
-
_parse(e) {
|
|
4013
|
-
const { status: r, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
|
|
4014
|
-
addIssue: (i) => {
|
|
4015
|
-
b(s, i), i.fatal ? r.abort() : r.dirty();
|
|
4016
|
-
},
|
|
4017
|
-
get path() {
|
|
4018
|
-
return s.path;
|
|
4019
|
-
}
|
|
4020
|
-
};
|
|
4021
|
-
if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
|
|
4022
|
-
const i = n.transform(s.data, a);
|
|
4023
|
-
if (s.common.async)
|
|
4024
|
-
return Promise.resolve(i).then(async (o) => {
|
|
4025
|
-
if (r.value === "aborted")
|
|
4026
|
-
return E;
|
|
4027
|
-
const d = await this._def.schema._parseAsync({
|
|
4028
|
-
data: o,
|
|
4029
|
-
path: s.path,
|
|
4030
|
-
parent: s
|
|
4031
|
-
});
|
|
4032
|
-
return d.status === "aborted" ? E : d.status === "dirty" || r.value === "dirty" ? tt(d.value) : d;
|
|
4033
|
-
});
|
|
4034
|
-
{
|
|
4035
|
-
if (r.value === "aborted")
|
|
4036
|
-
return E;
|
|
4037
|
-
const o = this._def.schema._parseSync({
|
|
4038
|
-
data: i,
|
|
4039
|
-
path: s.path,
|
|
4040
|
-
parent: s
|
|
4041
|
-
});
|
|
4042
|
-
return o.status === "aborted" ? E : o.status === "dirty" || r.value === "dirty" ? tt(o.value) : o;
|
|
4043
|
-
}
|
|
4044
|
-
}
|
|
4045
|
-
if (n.type === "refinement") {
|
|
4046
|
-
const i = (o) => {
|
|
4047
|
-
const d = n.refinement(o, a);
|
|
4048
|
-
if (s.common.async)
|
|
4049
|
-
return Promise.resolve(d);
|
|
4050
|
-
if (d instanceof Promise)
|
|
4051
|
-
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4052
|
-
return o;
|
|
4053
|
-
};
|
|
4054
|
-
if (s.common.async === !1) {
|
|
4055
|
-
const o = this._def.schema._parseSync({
|
|
4056
|
-
data: s.data,
|
|
4057
|
-
path: s.path,
|
|
4058
|
-
parent: s
|
|
4059
|
-
});
|
|
4060
|
-
return o.status === "aborted" ? E : (o.status === "dirty" && r.dirty(), i(o.value), { status: r.value, value: o.value });
|
|
4061
|
-
} else
|
|
4062
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? E : (o.status === "dirty" && r.dirty(), i(o.value).then(() => ({ status: r.value, value: o.value }))));
|
|
4063
|
-
}
|
|
4064
|
-
if (n.type === "transform")
|
|
4065
|
-
if (s.common.async === !1) {
|
|
4066
|
-
const i = this._def.schema._parseSync({
|
|
4067
|
-
data: s.data,
|
|
4068
|
-
path: s.path,
|
|
4069
|
-
parent: s
|
|
4070
|
-
});
|
|
4071
|
-
if (!Je(i))
|
|
4072
|
-
return E;
|
|
4073
|
-
const o = n.transform(i.value, a);
|
|
4074
|
-
if (o instanceof Promise)
|
|
4075
|
-
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4076
|
-
return { status: r.value, value: o };
|
|
4077
|
-
} else
|
|
4078
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => Je(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({
|
|
4079
|
-
status: r.value,
|
|
4080
|
-
value: o
|
|
4081
|
-
})) : E);
|
|
4082
|
-
F.assertNever(n);
|
|
4083
|
-
}
|
|
4084
|
-
}
|
|
4085
|
-
be.create = (t, e, r) => new be({
|
|
4086
|
-
schema: t,
|
|
4087
|
-
typeName: j.ZodEffects,
|
|
4088
|
-
effect: e,
|
|
4089
|
-
...N(r)
|
|
4090
|
-
});
|
|
4091
|
-
be.createWithPreprocess = (t, e, r) => new be({
|
|
4092
|
-
schema: e,
|
|
4093
|
-
effect: { type: "preprocess", transform: t },
|
|
4094
|
-
typeName: j.ZodEffects,
|
|
4095
|
-
...N(r)
|
|
4096
|
-
});
|
|
4097
|
-
class Se extends O {
|
|
4098
|
-
_parse(e) {
|
|
4099
|
-
return this._getType(e) === w.undefined ? ae(void 0) : this._def.innerType._parse(e);
|
|
4100
|
-
}
|
|
4101
|
-
unwrap() {
|
|
4102
|
-
return this._def.innerType;
|
|
4103
|
-
}
|
|
4104
|
-
}
|
|
4105
|
-
Se.create = (t, e) => new Se({
|
|
4106
|
-
innerType: t,
|
|
4107
|
-
typeName: j.ZodOptional,
|
|
4108
|
-
...N(e)
|
|
4109
|
-
});
|
|
4110
|
-
class ze extends O {
|
|
4111
|
-
_parse(e) {
|
|
4112
|
-
return this._getType(e) === w.null ? ae(null) : this._def.innerType._parse(e);
|
|
4113
|
-
}
|
|
4114
|
-
unwrap() {
|
|
4115
|
-
return this._def.innerType;
|
|
4116
|
-
}
|
|
4117
|
-
}
|
|
4118
|
-
ze.create = (t, e) => new ze({
|
|
4119
|
-
innerType: t,
|
|
4120
|
-
typeName: j.ZodNullable,
|
|
4121
|
-
...N(e)
|
|
4122
|
-
});
|
|
4123
|
-
class Tt extends O {
|
|
4124
|
-
_parse(e) {
|
|
4125
|
-
const { ctx: r } = this._processInputParams(e);
|
|
4126
|
-
let s = r.data;
|
|
4127
|
-
return r.parsedType === w.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
4128
|
-
data: s,
|
|
4129
|
-
path: r.path,
|
|
4130
|
-
parent: r
|
|
4131
|
-
});
|
|
4132
|
-
}
|
|
4133
|
-
removeDefault() {
|
|
4134
|
-
return this._def.innerType;
|
|
4135
|
-
}
|
|
4136
|
-
}
|
|
4137
|
-
Tt.create = (t, e) => new Tt({
|
|
4138
|
-
innerType: t,
|
|
4139
|
-
typeName: j.ZodDefault,
|
|
4140
|
-
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
4141
|
-
...N(e)
|
|
4142
|
-
});
|
|
4143
|
-
class St extends O {
|
|
4144
|
-
_parse(e) {
|
|
4145
|
-
const { ctx: r } = this._processInputParams(e), s = {
|
|
4146
|
-
...r,
|
|
4147
|
-
common: {
|
|
4148
|
-
...r.common,
|
|
4149
|
-
issues: []
|
|
4150
|
-
}
|
|
4151
|
-
}, n = this._def.innerType._parse({
|
|
4152
|
-
data: s.data,
|
|
4153
|
-
path: s.path,
|
|
4154
|
-
parent: {
|
|
4155
|
-
...s
|
|
4156
|
-
}
|
|
4157
|
-
});
|
|
4158
|
-
return mt(n) ? n.then((a) => ({
|
|
4159
|
-
status: "valid",
|
|
4160
|
-
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
4161
|
-
get error() {
|
|
4162
|
-
return new he(s.common.issues);
|
|
4163
|
-
},
|
|
4164
|
-
input: s.data
|
|
4165
|
-
})
|
|
4166
|
-
})) : {
|
|
4167
|
-
status: "valid",
|
|
4168
|
-
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
4169
|
-
get error() {
|
|
4170
|
-
return new he(s.common.issues);
|
|
4171
|
-
},
|
|
4172
|
-
input: s.data
|
|
4173
|
-
})
|
|
4174
|
-
};
|
|
4175
|
-
}
|
|
4176
|
-
removeCatch() {
|
|
4177
|
-
return this._def.innerType;
|
|
4178
|
-
}
|
|
4179
|
-
}
|
|
4180
|
-
St.create = (t, e) => new St({
|
|
4181
|
-
innerType: t,
|
|
4182
|
-
typeName: j.ZodCatch,
|
|
4183
|
-
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
4184
|
-
...N(e)
|
|
4185
|
-
});
|
|
4186
|
-
class Ut extends O {
|
|
4187
|
-
_parse(e) {
|
|
4188
|
-
if (this._getType(e) !== w.nan) {
|
|
4189
|
-
const s = this._getOrReturnCtx(e);
|
|
4190
|
-
return b(s, {
|
|
4191
|
-
code: p.invalid_type,
|
|
4192
|
-
expected: w.nan,
|
|
4193
|
-
received: s.parsedType
|
|
4194
|
-
}), E;
|
|
4195
|
-
}
|
|
4196
|
-
return { status: "valid", value: e.data };
|
|
4197
|
-
}
|
|
4198
|
-
}
|
|
4199
|
-
Ut.create = (t) => new Ut({
|
|
4200
|
-
typeName: j.ZodNaN,
|
|
4201
|
-
...N(t)
|
|
4202
|
-
});
|
|
4203
|
-
const kn = Symbol("zod_brand");
|
|
4204
|
-
class lr extends O {
|
|
4205
|
-
_parse(e) {
|
|
4206
|
-
const { ctx: r } = this._processInputParams(e), s = r.data;
|
|
4207
|
-
return this._def.type._parse({
|
|
4208
|
-
data: s,
|
|
4209
|
-
path: r.path,
|
|
4210
|
-
parent: r
|
|
4211
|
-
});
|
|
4212
|
-
}
|
|
4213
|
-
unwrap() {
|
|
4214
|
-
return this._def.type;
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
class Nt extends O {
|
|
4218
|
-
_parse(e) {
|
|
4219
|
-
const { status: r, ctx: s } = this._processInputParams(e);
|
|
4220
|
-
if (s.common.async)
|
|
4221
|
-
return (async () => {
|
|
4222
|
-
const a = await this._def.in._parseAsync({
|
|
4223
|
-
data: s.data,
|
|
4224
|
-
path: s.path,
|
|
4225
|
-
parent: s
|
|
4226
|
-
});
|
|
4227
|
-
return a.status === "aborted" ? E : a.status === "dirty" ? (r.dirty(), tt(a.value)) : this._def.out._parseAsync({
|
|
4228
|
-
data: a.value,
|
|
4229
|
-
path: s.path,
|
|
4230
|
-
parent: s
|
|
4231
|
-
});
|
|
4232
|
-
})();
|
|
4233
|
-
{
|
|
4234
|
-
const n = this._def.in._parseSync({
|
|
4235
|
-
data: s.data,
|
|
4236
|
-
path: s.path,
|
|
4237
|
-
parent: s
|
|
4238
|
-
});
|
|
4239
|
-
return n.status === "aborted" ? E : n.status === "dirty" ? (r.dirty(), {
|
|
4240
|
-
status: "dirty",
|
|
4241
|
-
value: n.value
|
|
4242
|
-
}) : this._def.out._parseSync({
|
|
4243
|
-
data: n.value,
|
|
4244
|
-
path: s.path,
|
|
4245
|
-
parent: s
|
|
4246
|
-
});
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4249
|
-
static create(e, r) {
|
|
4250
|
-
return new Nt({
|
|
4251
|
-
in: e,
|
|
4252
|
-
out: r,
|
|
4253
|
-
typeName: j.ZodPipeline
|
|
4254
|
-
});
|
|
4255
|
-
}
|
|
4256
|
-
}
|
|
4257
|
-
class At extends O {
|
|
4258
|
-
_parse(e) {
|
|
4259
|
-
const r = this._def.innerType._parse(e), s = (n) => (Je(n) && (n.value = Object.freeze(n.value)), n);
|
|
4260
|
-
return mt(r) ? r.then((n) => s(n)) : s(r);
|
|
4261
|
-
}
|
|
4262
|
-
unwrap() {
|
|
4263
|
-
return this._def.innerType;
|
|
4264
|
-
}
|
|
4265
|
-
}
|
|
4266
|
-
At.create = (t, e) => new At({
|
|
4267
|
-
innerType: t,
|
|
4268
|
-
typeName: j.ZodReadonly,
|
|
4269
|
-
...N(e)
|
|
4270
|
-
});
|
|
4271
|
-
function Ir(t, e) {
|
|
4272
|
-
const r = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
|
|
4273
|
-
return typeof r == "string" ? { message: r } : r;
|
|
4274
|
-
}
|
|
4275
|
-
function ns(t, e = {}, r) {
|
|
4276
|
-
return t ? at.create().superRefine((s, n) => {
|
|
4277
|
-
const a = t(s);
|
|
4278
|
-
if (a instanceof Promise)
|
|
4279
|
-
return a.then((i) => {
|
|
4280
|
-
if (!i) {
|
|
4281
|
-
const o = Ir(e, s), d = o.fatal ?? r ?? !0;
|
|
4282
|
-
n.addIssue({ code: "custom", ...o, fatal: d });
|
|
4283
|
-
}
|
|
4284
|
-
});
|
|
4285
|
-
if (!a) {
|
|
4286
|
-
const i = Ir(e, s), o = i.fatal ?? r ?? !0;
|
|
4287
|
-
n.addIssue({ code: "custom", ...i, fatal: o });
|
|
4288
|
-
}
|
|
4289
|
-
}) : at.create();
|
|
4290
|
-
}
|
|
4291
|
-
const wn = {
|
|
4292
|
-
object: B.lazycreate
|
|
4293
|
-
};
|
|
4294
|
-
var j;
|
|
4295
|
-
(function(t) {
|
|
4296
|
-
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
4297
|
-
})(j || (j = {}));
|
|
4298
|
-
const Tn = (t, e = {
|
|
4299
|
-
message: `Input not instance of ${t.name}`
|
|
4300
|
-
}) => ns((r) => r instanceof t, e), as = ve.create, is = Le.create, Sn = Ut.create, An = $e.create, os = pt.create, En = He.create, jn = Zt.create, Nn = yt.create, Cn = gt.create, Rn = at.create, On = Ye.create, Vn = Fe.create, Fn = Lt.create, Pn = _e.create, In = B.create, Dn = B.strictCreate, Mn = vt.create, Zn = Wt.create, Ln = _t.create, $n = Ee.create, Un = bt.create, zn = $t.create, Bn = Ge.create, Wn = rt.create, qn = xt.create, Yn = kt.create, Jn = Ue.create, Hn = wt.create, Gn = it.create, Dr = be.create, Xn = Se.create, Qn = ze.create, Kn = be.createWithPreprocess, ea = Nt.create, ta = () => as().optional(), ra = () => is().optional(), sa = () => os().optional(), na = {
|
|
4301
|
-
string: (t) => ve.create({ ...t, coerce: !0 }),
|
|
4302
|
-
number: (t) => Le.create({ ...t, coerce: !0 }),
|
|
4303
|
-
boolean: (t) => pt.create({
|
|
4304
|
-
...t,
|
|
4305
|
-
coerce: !0
|
|
4306
|
-
}),
|
|
4307
|
-
bigint: (t) => $e.create({ ...t, coerce: !0 }),
|
|
4308
|
-
date: (t) => He.create({ ...t, coerce: !0 })
|
|
4309
|
-
}, aa = E, Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4310
|
-
__proto__: null,
|
|
4311
|
-
BRAND: kn,
|
|
4312
|
-
DIRTY: tt,
|
|
4313
|
-
EMPTY_PATH: Ks,
|
|
4314
|
-
INVALID: E,
|
|
4315
|
-
NEVER: aa,
|
|
4316
|
-
OK: ae,
|
|
4317
|
-
ParseStatus: se,
|
|
4318
|
-
Schema: O,
|
|
4319
|
-
ZodAny: at,
|
|
4320
|
-
ZodArray: _e,
|
|
4321
|
-
ZodBigInt: $e,
|
|
4322
|
-
ZodBoolean: pt,
|
|
4323
|
-
ZodBranded: lr,
|
|
4324
|
-
ZodCatch: St,
|
|
4325
|
-
ZodDate: He,
|
|
4326
|
-
ZodDefault: Tt,
|
|
4327
|
-
ZodDiscriminatedUnion: Wt,
|
|
4328
|
-
ZodEffects: be,
|
|
4329
|
-
ZodEnum: Ue,
|
|
4330
|
-
ZodError: he,
|
|
4331
|
-
get ZodFirstPartyTypeKind() {
|
|
4332
|
-
return j;
|
|
4333
|
-
},
|
|
4334
|
-
ZodFunction: rt,
|
|
4335
|
-
ZodIntersection: _t,
|
|
4336
|
-
ZodIssueCode: p,
|
|
4337
|
-
ZodLazy: xt,
|
|
4338
|
-
ZodLiteral: kt,
|
|
4339
|
-
ZodMap: $t,
|
|
4340
|
-
ZodNaN: Ut,
|
|
4341
|
-
ZodNativeEnum: wt,
|
|
4342
|
-
ZodNever: Fe,
|
|
4343
|
-
ZodNull: gt,
|
|
4344
|
-
ZodNullable: ze,
|
|
4345
|
-
ZodNumber: Le,
|
|
4346
|
-
ZodObject: B,
|
|
4347
|
-
ZodOptional: Se,
|
|
4348
|
-
ZodParsedType: w,
|
|
4349
|
-
ZodPipeline: Nt,
|
|
4350
|
-
ZodPromise: it,
|
|
4351
|
-
ZodReadonly: At,
|
|
4352
|
-
ZodRecord: bt,
|
|
4353
|
-
ZodSchema: O,
|
|
4354
|
-
ZodSet: Ge,
|
|
4355
|
-
ZodString: ve,
|
|
4356
|
-
ZodSymbol: Zt,
|
|
4357
|
-
ZodTransformer: be,
|
|
4358
|
-
ZodTuple: Ee,
|
|
4359
|
-
ZodType: O,
|
|
4360
|
-
ZodUndefined: yt,
|
|
4361
|
-
ZodUnion: vt,
|
|
4362
|
-
ZodUnknown: Ye,
|
|
4363
|
-
ZodVoid: Lt,
|
|
4364
|
-
addIssueToContext: b,
|
|
4365
|
-
any: Rn,
|
|
4366
|
-
array: Pn,
|
|
4367
|
-
bigint: An,
|
|
4368
|
-
boolean: os,
|
|
4369
|
-
coerce: na,
|
|
4370
|
-
custom: ns,
|
|
4371
|
-
date: En,
|
|
4372
|
-
datetimeRegex: rs,
|
|
4373
|
-
defaultErrorMap: nt,
|
|
4374
|
-
discriminatedUnion: Zn,
|
|
4375
|
-
effect: Dr,
|
|
4376
|
-
enum: Jn,
|
|
4377
|
-
function: Wn,
|
|
4378
|
-
getErrorMap: Dt,
|
|
4379
|
-
getParsedType: Ve,
|
|
4380
|
-
instanceof: Tn,
|
|
4381
|
-
intersection: Ln,
|
|
4382
|
-
isAborted: er,
|
|
4383
|
-
isAsync: mt,
|
|
4384
|
-
isDirty: tr,
|
|
4385
|
-
isValid: Je,
|
|
4386
|
-
late: wn,
|
|
4387
|
-
lazy: qn,
|
|
4388
|
-
literal: Yn,
|
|
4389
|
-
makeIssue: Mt,
|
|
4390
|
-
map: zn,
|
|
4391
|
-
nan: Sn,
|
|
4392
|
-
nativeEnum: Hn,
|
|
4393
|
-
never: Vn,
|
|
4394
|
-
null: Cn,
|
|
4395
|
-
nullable: Qn,
|
|
4396
|
-
number: is,
|
|
4397
|
-
object: In,
|
|
4398
|
-
get objectUtil() {
|
|
4399
|
-
return Kt;
|
|
4400
|
-
},
|
|
4401
|
-
oboolean: sa,
|
|
4402
|
-
onumber: ra,
|
|
4403
|
-
optional: Xn,
|
|
4404
|
-
ostring: ta,
|
|
4405
|
-
pipeline: ea,
|
|
4406
|
-
preprocess: Kn,
|
|
4407
|
-
promise: Gn,
|
|
4408
|
-
quotelessJson: Xs,
|
|
4409
|
-
record: Un,
|
|
4410
|
-
set: Bn,
|
|
4411
|
-
setErrorMap: Qs,
|
|
4412
|
-
strictObject: Dn,
|
|
4413
|
-
string: as,
|
|
4414
|
-
symbol: jn,
|
|
4415
|
-
transformer: Dr,
|
|
4416
|
-
tuple: $n,
|
|
4417
|
-
undefined: Nn,
|
|
4418
|
-
union: Mn,
|
|
4419
|
-
unknown: On,
|
|
4420
|
-
get util() {
|
|
4421
|
-
return F;
|
|
4422
|
-
},
|
|
4423
|
-
void: Fn
|
|
4424
|
-
}, Symbol.toStringTag, { value: "Module" })), zt = (t) => /* @__PURE__ */ y.jsx(
|
|
4425
|
-
"button",
|
|
4426
|
-
{
|
|
4427
|
-
type: t.type || "button",
|
|
4428
|
-
disabled: t.isDisabled,
|
|
4429
|
-
className: `bg-green-500 hover:bg-green-600 text-white px-6 py-2 rounded disabled:opacity-50 *:disabled:cursor-not-allowed ${t.className}`,
|
|
4430
|
-
onClick: t.handleClick,
|
|
4431
|
-
children: t.title
|
|
4432
|
-
}
|
|
4433
|
-
), ia = ({
|
|
4434
|
-
label: t,
|
|
4435
|
-
required: e = !1,
|
|
4436
|
-
file: r,
|
|
4437
|
-
onFileChange: s,
|
|
4438
|
-
error: n
|
|
4439
|
-
}) => {
|
|
4440
|
-
const a = ms(null), [i, o] = Xt(null), [d, h] = Xt(!1), f = (S) => {
|
|
4441
|
-
var te;
|
|
4442
|
-
const W = (te = S.target.files) == null ? void 0 : te[0];
|
|
4443
|
-
W && (s(W), o(URL.createObjectURL(W)));
|
|
4444
|
-
}, x = ps(() => {
|
|
4445
|
-
var S;
|
|
4446
|
-
(S = a.current) == null || S.click();
|
|
4447
|
-
}, []);
|
|
4448
|
-
return ys(() => {
|
|
4449
|
-
r && o(URL.createObjectURL(r));
|
|
4450
|
-
}, [r]), /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
|
|
4451
|
-
/* @__PURE__ */ y.jsxs("div", { className: "flex flex-col", children: [
|
|
4452
|
-
/* @__PURE__ */ y.jsxs("label", { className: "font-medium mb-1 text-gray-700", children: [
|
|
4453
|
-
t,
|
|
4454
|
-
e && /* @__PURE__ */ y.jsx("span", { className: "text-red-500 ml-1", children: "*" })
|
|
4455
|
-
] }),
|
|
4456
|
-
/* @__PURE__ */ y.jsxs("div", { className: "flex items-center", children: [
|
|
4457
|
-
/* @__PURE__ */ y.jsx(
|
|
4458
|
-
"button",
|
|
4459
|
-
{
|
|
4460
|
-
type: "button",
|
|
4461
|
-
onClick: x,
|
|
4462
|
-
className: "bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded",
|
|
4463
|
-
children: "Upload file"
|
|
4464
|
-
}
|
|
4465
|
-
),
|
|
4466
|
-
/* @__PURE__ */ y.jsx(
|
|
4467
|
-
"input",
|
|
4468
|
-
{
|
|
4469
|
-
ref: a,
|
|
4470
|
-
type: "file",
|
|
4471
|
-
accept: "image/*,.pdf",
|
|
4472
|
-
className: "hidden",
|
|
4473
|
-
onChange: f
|
|
4474
|
-
}
|
|
4475
|
-
)
|
|
4476
|
-
] }),
|
|
4477
|
-
/* @__PURE__ */ y.jsx(
|
|
4478
|
-
"div",
|
|
4479
|
-
{
|
|
4480
|
-
className: "mt-2 h-40 w-full bg-gray-200 rounded overflow-hidden flex items-center justify-center cursor-pointer",
|
|
4481
|
-
onClick: () => i && h(!0),
|
|
4482
|
-
children: i ? (r == null ? void 0 : r.type) === "application/pdf" ? /* @__PURE__ */ y.jsx(
|
|
4483
|
-
"object",
|
|
4484
|
-
{
|
|
4485
|
-
data: i,
|
|
4486
|
-
type: "application/pdf",
|
|
4487
|
-
width: "100%",
|
|
4488
|
-
height: "100%",
|
|
4489
|
-
children: /* @__PURE__ */ y.jsxs("p", { className: "text-gray-600 text-sm", children: [
|
|
4490
|
-
"Cannot preview PDF.",
|
|
4491
|
-
" ",
|
|
4492
|
-
/* @__PURE__ */ y.jsx(
|
|
4493
|
-
"a",
|
|
4494
|
-
{
|
|
4495
|
-
href: i,
|
|
4496
|
-
target: "_blank",
|
|
4497
|
-
rel: "noreferrer",
|
|
4498
|
-
className: "text-blue-600 underline",
|
|
4499
|
-
children: "Download PDF"
|
|
4500
|
-
}
|
|
4501
|
-
)
|
|
4502
|
-
] })
|
|
4503
|
-
}
|
|
4504
|
-
) : /* @__PURE__ */ y.jsx(
|
|
4505
|
-
"img",
|
|
4506
|
-
{
|
|
4507
|
-
src: i,
|
|
4508
|
-
alt: "Preview",
|
|
4509
|
-
className: "h-full object-contain"
|
|
4510
|
-
}
|
|
4511
|
-
) : /* @__PURE__ */ y.jsx("span", { className: "text-gray-500", children: "No file selected" })
|
|
4512
|
-
}
|
|
4513
|
-
),
|
|
4514
|
-
n && /* @__PURE__ */ y.jsx("span", { className: "text-red-500 text-sm mt-1", children: n })
|
|
4515
|
-
] }),
|
|
4516
|
-
d && i && /* @__PURE__ */ y.jsx(
|
|
4517
|
-
"div",
|
|
4518
|
-
{
|
|
4519
|
-
className: "fixed inset-0 bg-black bg-opacity-75 z-50 flex items-center justify-center",
|
|
4520
|
-
onClick: () => h(!1),
|
|
4521
|
-
children: /* @__PURE__ */ y.jsxs(
|
|
4522
|
-
"div",
|
|
4523
|
-
{
|
|
4524
|
-
className: "relative w-full h-full",
|
|
4525
|
-
onClick: (S) => S.stopPropagation(),
|
|
4526
|
-
children: [
|
|
4527
|
-
/* @__PURE__ */ y.jsx(
|
|
4528
|
-
"button",
|
|
4529
|
-
{
|
|
4530
|
-
onClick: () => h(!1),
|
|
4531
|
-
className: "absolute top-2 right-2 text-white text-2xl",
|
|
4532
|
-
"aria-label": "Close preview",
|
|
4533
|
-
children: "×"
|
|
4534
|
-
}
|
|
4535
|
-
),
|
|
4536
|
-
(r == null ? void 0 : r.type) === "application/pdf" ? /* @__PURE__ */ y.jsx(
|
|
4537
|
-
"object",
|
|
4538
|
-
{
|
|
4539
|
-
data: i,
|
|
4540
|
-
type: "application/pdf",
|
|
4541
|
-
className: "w-full h-full object-contain"
|
|
4542
|
-
}
|
|
4543
|
-
) : /* @__PURE__ */ y.jsx(
|
|
4544
|
-
"img",
|
|
4545
|
-
{
|
|
4546
|
-
src: i,
|
|
4547
|
-
alt: "Full Preview",
|
|
4548
|
-
className: "w-full h-full object-contain"
|
|
4549
|
-
}
|
|
4550
|
-
)
|
|
4551
|
-
]
|
|
4552
|
-
}
|
|
4553
|
-
)
|
|
4554
|
-
}
|
|
4555
|
-
)
|
|
4556
|
-
] });
|
|
4557
|
-
}, Me = gs(
|
|
4558
|
-
({ label: t, required: e = !1, error: r, ...s }, n) => /* @__PURE__ */ y.jsxs("div", { className: "flex flex-col", children: [
|
|
4559
|
-
/* @__PURE__ */ y.jsxs(
|
|
4560
|
-
"label",
|
|
4561
|
-
{
|
|
4562
|
-
htmlFor: s.name,
|
|
4563
|
-
className: "font-medium mb-1 text-gray-700",
|
|
4564
|
-
children: [
|
|
4565
|
-
t,
|
|
4566
|
-
e && /* @__PURE__ */ y.jsx("span", { className: "text-red-500 ml-1", children: "*" })
|
|
4567
|
-
]
|
|
4568
|
-
}
|
|
4569
|
-
),
|
|
4570
|
-
/* @__PURE__ */ y.jsx(
|
|
4571
|
-
"input",
|
|
4572
|
-
{
|
|
4573
|
-
id: s.name,
|
|
4574
|
-
ref: n,
|
|
4575
|
-
...s,
|
|
4576
|
-
className: `border rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 ${r ? "border-red-500" : "border-gray-300"}`
|
|
4577
|
-
}
|
|
4578
|
-
),
|
|
4579
|
-
r && /* @__PURE__ */ y.jsx("span", { className: "text-red-500 text-sm mt-1", children: r })
|
|
4580
|
-
] })
|
|
4581
|
-
);
|
|
4582
|
-
Me.displayName = "InputField";
|
|
4583
|
-
const Et = Mr((t) => ({
|
|
4584
|
-
selectedProvider: null,
|
|
4585
|
-
form: {
|
|
4586
|
-
taxCode: "",
|
|
4587
|
-
companyName: "",
|
|
4588
|
-
representative: "",
|
|
4589
|
-
position: "",
|
|
4590
|
-
email: "",
|
|
4591
|
-
phoneNumber: null,
|
|
4592
|
-
address: "",
|
|
4593
|
-
license: null
|
|
4594
|
-
},
|
|
4595
|
-
selectedPlan: null,
|
|
4596
|
-
setSelectedProvider: (e) => t({ selectedProvider: e }),
|
|
4597
|
-
setForm: (e) => t((r) => ({
|
|
4598
|
-
form: { ...r.form, ...e }
|
|
4599
|
-
})),
|
|
4600
|
-
setSelectedPlan: (e) => t({ selectedPlan: e }),
|
|
4601
|
-
reset: () => t({
|
|
4602
|
-
selectedProvider: null,
|
|
4603
|
-
form: {
|
|
4604
|
-
taxCode: "",
|
|
4605
|
-
companyName: "",
|
|
4606
|
-
representative: "",
|
|
4607
|
-
position: "",
|
|
4608
|
-
email: "",
|
|
4609
|
-
phoneNumber: null,
|
|
4610
|
-
address: "",
|
|
4611
|
-
license: null
|
|
4612
|
-
},
|
|
4613
|
-
selectedPlan: null
|
|
4614
|
-
})
|
|
4615
|
-
})), oa = Re.object({
|
|
4616
|
-
taxCode: Re.string().nonempty("Mã số thuế là bắt buộc"),
|
|
4617
|
-
representative: Re.string().nonempty("Người đại diện là bắt buộc"),
|
|
4618
|
-
email: Re.string().nonempty("Email là bắt buộc").email("Email không hợp lệ"),
|
|
4619
|
-
address: Re.string().nonempty("Địa chỉ là bắt buộc"),
|
|
4620
|
-
companyName: Re.string().nonempty("Tên công ty là bắt buộc"),
|
|
4621
|
-
position: Re.string().optional(),
|
|
4622
|
-
phone: Re.string().regex(/^[0-9()+\-\s]+$/, "SĐT không hợp lệ").optional(),
|
|
4623
|
-
// ← here we make it `.optional()`
|
|
4624
|
-
license: Re.instanceof(File, {
|
|
4625
|
-
message: "Giấy phép đăng ký kinh doanh là bắt buộc"
|
|
4626
|
-
}).optional()
|
|
4627
|
-
}), ca = () => {
|
|
4628
|
-
const t = Et((f) => f.form), {
|
|
4629
|
-
control: e,
|
|
4630
|
-
handleSubmit: r,
|
|
4631
|
-
formState: { errors: s, isSubmitting: n, isValid: a }
|
|
4632
|
-
} = qs({
|
|
4633
|
-
resolver: Gs(oa),
|
|
4634
|
-
defaultValues: {
|
|
4635
|
-
taxCode: t.taxCode || "",
|
|
4636
|
-
representative: t.representative || "",
|
|
4637
|
-
email: t.email || "",
|
|
4638
|
-
address: t.address || "",
|
|
4639
|
-
companyName: t.companyName || "",
|
|
4640
|
-
position: t.position || "",
|
|
4641
|
-
phone: t.phoneNumber || "",
|
|
4642
|
-
license: t.license || void 0
|
|
4643
|
-
// handle optional license
|
|
4644
|
-
}
|
|
4645
|
-
}), i = Et((f) => f.setForm), o = st((f) => f.nextStep), d = st((f) => f.prevStep), h = (f) => {
|
|
4646
|
-
console.log(f), i({
|
|
4647
|
-
taxCode: f.taxCode,
|
|
4648
|
-
representative: f.representative,
|
|
4649
|
-
email: f.email,
|
|
4650
|
-
address: f.address,
|
|
4651
|
-
companyName: f.companyName,
|
|
4652
|
-
position: f.position,
|
|
4653
|
-
phoneNumber: f.phone || null,
|
|
4654
|
-
// handle optional phone
|
|
4655
|
-
license: f.license || null
|
|
4656
|
-
// handle optional license
|
|
4657
|
-
});
|
|
4658
|
-
};
|
|
4659
|
-
return /* @__PURE__ */ y.jsxs(
|
|
4660
|
-
"form",
|
|
4661
|
-
{
|
|
4662
|
-
onSubmit: r(h),
|
|
4663
|
-
className: "w-full mx-auto p-6 bg-white shadow rounded",
|
|
4664
|
-
children: [
|
|
4665
|
-
/* @__PURE__ */ y.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-8", children: [
|
|
4666
|
-
/* @__PURE__ */ y.jsxs("div", { className: "space-y-4", children: [
|
|
4667
|
-
/* @__PURE__ */ y.jsx(
|
|
4668
|
-
De,
|
|
4669
|
-
{
|
|
4670
|
-
name: "taxCode",
|
|
4671
|
-
control: e,
|
|
4672
|
-
render: ({ field: f }) => {
|
|
4673
|
-
var x;
|
|
4674
|
-
return /* @__PURE__ */ y.jsx(
|
|
4675
|
-
Me,
|
|
4676
|
-
{
|
|
4677
|
-
...f,
|
|
4678
|
-
label: "Mã số thuế",
|
|
4679
|
-
required: !0,
|
|
4680
|
-
error: (x = s.taxCode) == null ? void 0 : x.message
|
|
4681
|
-
}
|
|
4682
|
-
);
|
|
4683
|
-
}
|
|
4684
|
-
}
|
|
4685
|
-
),
|
|
4686
|
-
/* @__PURE__ */ y.jsx(
|
|
4687
|
-
De,
|
|
4688
|
-
{
|
|
4689
|
-
name: "representative",
|
|
4690
|
-
control: e,
|
|
4691
|
-
render: ({ field: f }) => {
|
|
4692
|
-
var x;
|
|
4693
|
-
return /* @__PURE__ */ y.jsx(
|
|
4694
|
-
Me,
|
|
4695
|
-
{
|
|
4696
|
-
...f,
|
|
4697
|
-
label: "Người đại diện",
|
|
4698
|
-
required: !0,
|
|
4699
|
-
error: (x = s.representative) == null ? void 0 : x.message
|
|
4700
|
-
}
|
|
4701
|
-
);
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
|
-
),
|
|
4705
|
-
/* @__PURE__ */ y.jsx(
|
|
4706
|
-
De,
|
|
4707
|
-
{
|
|
4708
|
-
name: "email",
|
|
4709
|
-
control: e,
|
|
4710
|
-
render: ({ field: f }) => {
|
|
4711
|
-
var x;
|
|
4712
|
-
return /* @__PURE__ */ y.jsx(
|
|
4713
|
-
Me,
|
|
4714
|
-
{
|
|
4715
|
-
...f,
|
|
4716
|
-
label: "Email",
|
|
4717
|
-
type: "email",
|
|
4718
|
-
required: !0,
|
|
4719
|
-
error: (x = s.email) == null ? void 0 : x.message
|
|
4720
|
-
}
|
|
4721
|
-
);
|
|
4722
|
-
}
|
|
4723
|
-
}
|
|
4724
|
-
),
|
|
4725
|
-
/* @__PURE__ */ y.jsx(
|
|
4726
|
-
De,
|
|
4727
|
-
{
|
|
4728
|
-
name: "address",
|
|
4729
|
-
control: e,
|
|
4730
|
-
render: ({ field: f }) => {
|
|
4731
|
-
var x;
|
|
4732
|
-
return /* @__PURE__ */ y.jsx(
|
|
4733
|
-
Me,
|
|
4734
|
-
{
|
|
4735
|
-
...f,
|
|
4736
|
-
label: "Địa chỉ",
|
|
4737
|
-
required: !0,
|
|
4738
|
-
error: (x = s.address) == null ? void 0 : x.message
|
|
4739
|
-
}
|
|
4740
|
-
);
|
|
4741
|
-
}
|
|
4742
|
-
}
|
|
4743
|
-
),
|
|
4744
|
-
/* @__PURE__ */ y.jsx(
|
|
4745
|
-
De,
|
|
4746
|
-
{
|
|
4747
|
-
name: "license",
|
|
4748
|
-
control: e,
|
|
4749
|
-
render: ({ field: f }) => {
|
|
4750
|
-
var x;
|
|
4751
|
-
return /* @__PURE__ */ y.jsx(
|
|
4752
|
-
ia,
|
|
4753
|
-
{
|
|
4754
|
-
label: "Giấy phép đăng ký kinh doanh",
|
|
4755
|
-
required: !0,
|
|
4756
|
-
file: f.value ?? null,
|
|
4757
|
-
onFileChange: f.onChange,
|
|
4758
|
-
error: (x = s.license) == null ? void 0 : x.message
|
|
4759
|
-
}
|
|
4760
|
-
);
|
|
4761
|
-
}
|
|
4762
|
-
}
|
|
4763
|
-
)
|
|
4764
|
-
] }),
|
|
4765
|
-
/* @__PURE__ */ y.jsxs("div", { className: "space-y-4", children: [
|
|
4766
|
-
/* @__PURE__ */ y.jsx(
|
|
4767
|
-
De,
|
|
4768
|
-
{
|
|
4769
|
-
name: "companyName",
|
|
4770
|
-
control: e,
|
|
4771
|
-
render: ({ field: f }) => {
|
|
4772
|
-
var x;
|
|
4773
|
-
return /* @__PURE__ */ y.jsx(
|
|
4774
|
-
Me,
|
|
4775
|
-
{
|
|
4776
|
-
...f,
|
|
4777
|
-
label: "Tên công ty",
|
|
4778
|
-
required: !0,
|
|
4779
|
-
error: (x = s.companyName) == null ? void 0 : x.message
|
|
4780
|
-
}
|
|
4781
|
-
);
|
|
4782
|
-
}
|
|
4783
|
-
}
|
|
4784
|
-
),
|
|
4785
|
-
/* @__PURE__ */ y.jsx(
|
|
4786
|
-
De,
|
|
4787
|
-
{
|
|
4788
|
-
name: "position",
|
|
4789
|
-
control: e,
|
|
4790
|
-
render: ({ field: f }) => {
|
|
4791
|
-
var x;
|
|
4792
|
-
return /* @__PURE__ */ y.jsx(
|
|
4793
|
-
Me,
|
|
4794
|
-
{
|
|
4795
|
-
...f,
|
|
4796
|
-
label: "Chức vụ",
|
|
4797
|
-
error: (x = s.position) == null ? void 0 : x.message
|
|
4798
|
-
}
|
|
4799
|
-
);
|
|
4800
|
-
}
|
|
4801
|
-
}
|
|
4802
|
-
),
|
|
4803
|
-
/* @__PURE__ */ y.jsx(
|
|
4804
|
-
De,
|
|
4805
|
-
{
|
|
4806
|
-
name: "phone",
|
|
4807
|
-
control: e,
|
|
4808
|
-
render: ({ field: f }) => {
|
|
4809
|
-
var x;
|
|
4810
|
-
return /* @__PURE__ */ y.jsx(
|
|
4811
|
-
Me,
|
|
4812
|
-
{
|
|
4813
|
-
...f,
|
|
4814
|
-
label: "SĐT",
|
|
4815
|
-
type: "tel",
|
|
4816
|
-
error: (x = s.phone) == null ? void 0 : x.message
|
|
4817
|
-
}
|
|
4818
|
-
);
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
)
|
|
4822
|
-
] })
|
|
4823
|
-
] }),
|
|
4824
|
-
/* @__PURE__ */ y.jsxs("div", { className: "flex items-center justify-end gap-2", children: [
|
|
4825
|
-
/* @__PURE__ */ y.jsx(
|
|
4826
|
-
zt,
|
|
4827
|
-
{
|
|
4828
|
-
title: "Back",
|
|
4829
|
-
handleClick: () => {
|
|
4830
|
-
d();
|
|
4831
|
-
},
|
|
4832
|
-
className: " !bg-gray-200 !text-gray-700 hover:!bg-gray-300 disabled:!bg-gray-200 disabled:!text-gray-500"
|
|
4833
|
-
}
|
|
4834
|
-
),
|
|
4835
|
-
/* @__PURE__ */ y.jsx(
|
|
4836
|
-
zt,
|
|
4837
|
-
{
|
|
4838
|
-
type: "submit",
|
|
4839
|
-
title: n ? "Submitting..." : "Submit",
|
|
4840
|
-
isDisabled: n || Object.keys(s).length > 0 || !a,
|
|
4841
|
-
handleClick: () => {
|
|
4842
|
-
o();
|
|
4843
|
-
}
|
|
4844
|
-
}
|
|
4845
|
-
)
|
|
4846
|
-
] })
|
|
4847
|
-
]
|
|
4848
|
-
}
|
|
4849
|
-
);
|
|
4850
|
-
}, la = ({
|
|
4851
|
-
options: t,
|
|
4852
|
-
value: e,
|
|
4853
|
-
onChange: r
|
|
4854
|
-
}) => /* @__PURE__ */ y.jsx(
|
|
4855
|
-
"fieldset",
|
|
4856
|
-
{
|
|
4857
|
-
role: "radiogroup",
|
|
4858
|
-
"aria-label": "Chọn gói đăng ký",
|
|
4859
|
-
className: "flex flex-col md:flex-row gap-4 md:gap-20",
|
|
4860
|
-
children: t.map((s) => {
|
|
4861
|
-
const n = s.value === e;
|
|
4862
|
-
return /* @__PURE__ */ y.jsxs(
|
|
4863
|
-
"label",
|
|
4864
|
-
{
|
|
4865
|
-
className: [
|
|
4866
|
-
"flex items-center cursor-pointer rounded-lg border p-4 transition",
|
|
4867
|
-
n ? "border-green-500 bg-green-50" : "border-gray-300 bg-white hover:bg-gray-50"
|
|
4868
|
-
].join(" "),
|
|
4869
|
-
children: [
|
|
4870
|
-
/* @__PURE__ */ y.jsx(
|
|
4871
|
-
"input",
|
|
4872
|
-
{
|
|
4873
|
-
type: "radio",
|
|
4874
|
-
name: "subscription",
|
|
4875
|
-
value: s.value,
|
|
4876
|
-
checked: n,
|
|
4877
|
-
onChange: () => r(s.value),
|
|
4878
|
-
className: "sr-only"
|
|
4879
|
-
}
|
|
4880
|
-
),
|
|
4881
|
-
/* @__PURE__ */ y.jsx(
|
|
4882
|
-
"span",
|
|
4883
|
-
{
|
|
4884
|
-
className: [
|
|
4885
|
-
"flex-shrink-0 flex items-center justify-center rounded-full mr-3",
|
|
4886
|
-
n ? "w-5 h-5 border-2 border-green-500 bg-green-500" : "w-4 h-4 border border-gray-400"
|
|
4887
|
-
].join(" "),
|
|
4888
|
-
children: n && /* @__PURE__ */ y.jsx("span", { className: "block w-2 h-2 bg-white rounded-full" })
|
|
4889
|
-
}
|
|
4890
|
-
),
|
|
4891
|
-
/* @__PURE__ */ y.jsx(
|
|
4892
|
-
"span",
|
|
4893
|
-
{
|
|
4894
|
-
className: n ? "text-green-700 font-medium" : "text-gray-700",
|
|
4895
|
-
children: s.label
|
|
4896
|
-
}
|
|
4897
|
-
)
|
|
4898
|
-
]
|
|
4899
|
-
},
|
|
4900
|
-
s.value
|
|
4901
|
-
);
|
|
4902
|
-
})
|
|
4903
|
-
}
|
|
4904
|
-
), ua = () => {
|
|
4905
|
-
const t = st((n) => n.nextStep), [e, r] = Xt("300"), s = [
|
|
4906
|
-
{ value: "100", label: "100 đơn/tháng" },
|
|
4907
|
-
{ value: "300", label: "300 đơn/tháng" },
|
|
4908
|
-
{ value: "500", label: "500 đơn/tháng" }
|
|
4909
|
-
];
|
|
4910
|
-
return /* @__PURE__ */ y.jsxs("div", { className: "w-full flex flex-col gap-6", children: [
|
|
4911
|
-
/* @__PURE__ */ y.jsx("h2", { className: "heading", children: "Select subscription package" }),
|
|
4912
|
-
/* @__PURE__ */ y.jsx(
|
|
4913
|
-
la,
|
|
4914
|
-
{
|
|
4915
|
-
options: s,
|
|
4916
|
-
value: e,
|
|
4917
|
-
onChange: r
|
|
4918
|
-
}
|
|
4919
|
-
),
|
|
4920
|
-
/* @__PURE__ */ y.jsx("div", { className: "text-right", children: /* @__PURE__ */ y.jsx(
|
|
4921
|
-
zt,
|
|
4922
|
-
{
|
|
4923
|
-
title: "Next",
|
|
4924
|
-
isDisabled: !e,
|
|
4925
|
-
handleClick: () => {
|
|
4926
|
-
t();
|
|
4927
|
-
}
|
|
4928
|
-
}
|
|
4929
|
-
) })
|
|
4930
|
-
] });
|
|
4931
|
-
}, da = ({ checked: t, setChecked: e }) => /* @__PURE__ */ y.jsxs("label", { className: "relative inline-flex cursor-pointer items-center", children: [
|
|
4932
|
-
/* @__PURE__ */ y.jsx(
|
|
4933
|
-
"input",
|
|
4934
|
-
{
|
|
4935
|
-
type: "checkbox",
|
|
4936
|
-
className: "peer sr-only",
|
|
4937
|
-
checked: t,
|
|
4938
|
-
onChange: (r) => e(r.target.checked)
|
|
4939
|
-
}
|
|
4940
|
-
),
|
|
4941
|
-
/* @__PURE__ */ y.jsx("div", { className: "border-[#ACADAE] relative h-5 w-5 rounded-full border-2 before:absolute before:left-1/2 before:top-1/2 before:hidden before:h-2.5 before:w-2.5 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:bg-green-500 peer-checked:border-green-500 peer-checked:before:block" })
|
|
4942
|
-
] }), fa = [
|
|
4943
|
-
{ name: "M-Invoice", route: "m-invoice" },
|
|
4944
|
-
{ name: "FPT", route: "fpt" },
|
|
4945
|
-
{ name: "Misa", route: "misa" }
|
|
4946
|
-
], ha = ({ provider: t, handleProviderChange: e }) => {
|
|
4947
|
-
const r = Et((s) => s.selectedProvider);
|
|
4948
|
-
return /* @__PURE__ */ y.jsxs(
|
|
4949
|
-
"div",
|
|
4950
|
-
{
|
|
4951
|
-
"data-checked": r === t.route,
|
|
4952
|
-
className: `flex items-center justify-center gap-2 px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-100 cursor-pointer\r
|
|
4953
|
-
transition-colors duration-200 data-[checked=true]:border-green-500 data-[checked=true]:text-green-700\r
|
|
4954
|
-
`,
|
|
4955
|
-
onClick: () => e(t.route),
|
|
4956
|
-
children: [
|
|
4957
|
-
/* @__PURE__ */ y.jsx(
|
|
4958
|
-
da,
|
|
4959
|
-
{
|
|
4960
|
-
checked: r === t.route,
|
|
4961
|
-
setChecked: () => e(t.route)
|
|
4962
|
-
}
|
|
4963
|
-
),
|
|
4964
|
-
/* @__PURE__ */ y.jsx("label", { className: "", children: t.name })
|
|
4965
|
-
]
|
|
4966
|
-
}
|
|
4967
|
-
);
|
|
4968
|
-
}, ma = () => {
|
|
4969
|
-
const t = Et((n) => n.selectedProvider), e = Et((n) => n.setSelectedProvider), r = st((n) => n.nextStep), s = (n) => {
|
|
4970
|
-
e(n);
|
|
4971
|
-
};
|
|
4972
|
-
return /* @__PURE__ */ y.jsxs("div", { className: "w-full flex flex-col gap-6", children: [
|
|
4973
|
-
/* @__PURE__ */ y.jsx("h2", { className: "heading", children: "Select Provider" }),
|
|
4974
|
-
/* @__PURE__ */ y.jsx("div", { className: "flex gap-20", children: fa.map((n) => /* @__PURE__ */ y.jsx(ha, { provider: n, handleProviderChange: s }, n.route)) }),
|
|
4975
|
-
/* @__PURE__ */ y.jsx("div", { className: "text-right", children: /* @__PURE__ */ y.jsx(
|
|
4976
|
-
zt,
|
|
4977
|
-
{
|
|
4978
|
-
title: "Next",
|
|
4979
|
-
isDisabled: !t,
|
|
4980
|
-
handleClick: () => {
|
|
4981
|
-
r();
|
|
4982
|
-
}
|
|
4983
|
-
}
|
|
4984
|
-
) })
|
|
4985
|
-
] });
|
|
4986
|
-
}, pa = () => /* @__PURE__ */ y.jsx("div", { children: "Status" });
|
|
4987
|
-
function va() {
|
|
4988
|
-
const t = st((e) => e.step);
|
|
4989
|
-
return /* @__PURE__ */ y.jsx(y.Fragment, { children: /* @__PURE__ */ y.jsx(As, { children: {
|
|
4990
|
-
1: /* @__PURE__ */ y.jsx(ma, {}),
|
|
4991
|
-
2: /* @__PURE__ */ y.jsx(ca, {}),
|
|
4992
|
-
3: /* @__PURE__ */ y.jsx(ua, {}),
|
|
4993
|
-
4: /* @__PURE__ */ y.jsx(pa, {})
|
|
4994
|
-
}[t] }) });
|
|
4995
|
-
}
|
|
4996
|
-
export {
|
|
4997
|
-
va as default
|
|
4998
|
-
};
|