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