@twintag/twintag-form 1.7.4 → 1.7.7

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.
Files changed (52) hide show
  1. package/AGENTS.md +19 -0
  2. package/CHANGELOG.md +20 -0
  3. package/lib/common/calendar.tsx +1 -1
  4. package/lib/vite-env.d.ts +1 -0
  5. package/package.json +6 -3
  6. package/tsconfig.json +0 -1
  7. package/vite.config.ts +1 -1
  8. package/.turbo/turbo-build.log +0 -15
  9. package/dist/common/accordion.d.ts +0 -7
  10. package/dist/common/button.d.ts +0 -70
  11. package/dist/common/calendar.d.ts +0 -139
  12. package/dist/common/checkbox.d.ts +0 -4
  13. package/dist/common/form.d.ts +0 -86
  14. package/dist/common/icon.d.ts +0 -7
  15. package/dist/common/input.d.ts +0 -132
  16. package/dist/common/label.d.ts +0 -20
  17. package/dist/common/popover.d.ts +0 -6
  18. package/dist/common/radiogroup.d.ts +0 -5
  19. package/dist/common/slider.d.ts +0 -4
  20. package/dist/common/switch.d.ts +0 -4
  21. package/dist/common/textarea.d.ts +0 -67
  22. package/dist/components/config.d.ts +0 -5
  23. package/dist/components/containers/accordion.d.ts +0 -6
  24. package/dist/components/containers/category.d.ts +0 -7
  25. package/dist/components/fields/checkbox.d.ts +0 -4
  26. package/dist/components/fields/date-picker.d.ts +0 -4
  27. package/dist/components/fields/file.d.ts +0 -4
  28. package/dist/components/fields/input.d.ts +0 -4
  29. package/dist/components/fields/radiogroup.d.ts +0 -6
  30. package/dist/components/fields/submit.d.ts +0 -3
  31. package/dist/components/fields/textarea.d.ts +0 -4
  32. package/dist/components/fields/toggle.d.ts +0 -4
  33. package/dist/components/fields/tri-toggle.d.ts +0 -4
  34. package/dist/components/form.d.ts +0 -8
  35. package/dist/components/input.d.ts +0 -3
  36. package/dist/components/label.d.ts +0 -3
  37. package/dist/components/provider.d.ts +0 -13
  38. package/dist/components/renderer.d.ts +0 -1
  39. package/dist/dev/main.d.ts +0 -0
  40. package/dist/index.cjs +0 -1
  41. package/dist/index.d.ts +0 -16
  42. package/dist/index.js +0 -4301
  43. package/dist/tailwind.config.d.ts +0 -54
  44. package/dist/twind.config.d.ts +0 -6
  45. package/dist/types/index.d.ts +0 -67
  46. package/dist/utils/data.d.ts +0 -6
  47. package/dist/utils/string.d.ts +0 -3
  48. package/dist/utils/style.d.ts +0 -2
  49. package/dist/vite.config.d.ts +0 -4
  50. package/dist/webcomponent.cjs +0 -1
  51. package/dist/webcomponent.d.ts +0 -1
  52. package/dist/webcomponent.js +0 -1179
package/dist/index.js DELETED
@@ -1,4301 +0,0 @@
1
- import { jsx as c, jsxs as b, Fragment as br } from "react/jsx-runtime";
2
- import * as A from "react";
3
- import { useMemo as De, createContext as xr, useContext as kr, forwardRef as Ot, useRef as wr, useImperativeHandle as Nr, useEffect as mt } from "react";
4
- import { twMerge as Cr, extendTailwindMerge as Tr } from "tailwind-merge";
5
- import * as oe from "@radix-ui/react-accordion";
6
- import { ChevronDown as Ar, AsteriskIcon as le, ChevronRight as Sr, ChevronLeft as Vr, Calendar as Rr, Circle as Or } from "lucide-react";
7
- import * as Ir from "@heroicons/react/24/outline";
8
- import { v4 as Er } from "uuid";
9
- import { useFormContext as K, Controller as jr, FormProvider as Zr, useForm as $r } from "react-hook-form";
10
- import * as Ue from "@radix-ui/react-checkbox";
11
- import { CheckIcon as Mr } from "@radix-ui/react-icons";
12
- import { Slot as It } from "@radix-ui/react-slot";
13
- import * as Et from "@radix-ui/react-label";
14
- import { format as Lr } from "date-fns";
15
- import { DayPicker as zr } from "react-day-picker";
16
- import * as $e from "@radix-ui/react-popover";
17
- import * as we from "@radix-ui/react-radio-group";
18
- import * as Be from "@radix-ui/react-switch";
19
- import * as xe from "@radix-ui/react-slider";
20
- var Fr = /\s+/g, Pr = (r) => typeof r != "string" || !r ? r : r.replace(Fr, " ").trim(), Re = (...r) => {
21
- const e = [], t = (a) => {
22
- if (!a && a !== 0 && a !== 0n) return;
23
- if (Array.isArray(a)) {
24
- for (let n = 0, i = a.length; n < i; n++) t(a[n]);
25
- return;
26
- }
27
- const s = typeof a;
28
- if (s === "string" || s === "number" || s === "bigint") {
29
- if (s === "number" && a !== a) return;
30
- e.push(String(a));
31
- } else if (s === "object") {
32
- const n = Object.keys(a);
33
- for (let i = 0, o = n.length; i < o; i++) {
34
- const d = n[i];
35
- a[d] && e.push(d);
36
- }
37
- }
38
- };
39
- for (let a = 0, s = r.length; a < s; a++) {
40
- const n = r[a];
41
- n != null && t(n);
42
- }
43
- return e.length > 0 ? Pr(e.join(" ")) : void 0;
44
- }, pt = (r) => r === !1 ? "false" : r === !0 ? "true" : r === 0 ? "0" : r, j = (r) => {
45
- if (!r || typeof r != "object") return !0;
46
- for (const e in r) return !1;
47
- return !0;
48
- }, Dr = (r, e) => {
49
- if (r === e) return !0;
50
- if (!r || !e) return !1;
51
- const t = Object.keys(r), a = Object.keys(e);
52
- if (t.length !== a.length) return !1;
53
- for (let s = 0; s < t.length; s++) {
54
- const n = t[s];
55
- if (!a.includes(n) || r[n] !== e[n]) return !1;
56
- }
57
- return !0;
58
- }, Ur = (r, e) => {
59
- for (const t in e)
60
- if (Object.prototype.hasOwnProperty.call(e, t)) {
61
- const a = e[t];
62
- t in r ? r[t] = Re(r[t], a) : r[t] = a;
63
- }
64
- return r;
65
- }, jt = (r, e) => {
66
- for (let t = 0; t < r.length; t++) {
67
- const a = r[t];
68
- Array.isArray(a) ? jt(a, e) : a && e.push(a);
69
- }
70
- }, Zt = (...r) => {
71
- const e = [];
72
- jt(r, e);
73
- const t = [];
74
- for (let a = 0; a < e.length; a++)
75
- e[a] && t.push(e[a]);
76
- return t;
77
- }, qe = (r, e) => {
78
- const t = {};
79
- for (const a in r) {
80
- const s = r[a];
81
- if (a in e) {
82
- const n = e[a];
83
- Array.isArray(s) || Array.isArray(n) ? t[a] = Zt(n, s) : typeof s == "object" && typeof n == "object" && s && n ? t[a] = qe(s, n) : t[a] = n + " " + s;
84
- } else
85
- t[a] = s;
86
- }
87
- for (const a in e)
88
- a in r || (t[a] = e[a]);
89
- return t;
90
- }, Br = {
91
- twMerge: !0,
92
- twMergeConfig: {}
93
- };
94
- function qr() {
95
- let r = null, e = {}, t = !1;
96
- return {
97
- get cachedTwMerge() {
98
- return r;
99
- },
100
- set cachedTwMerge(a) {
101
- r = a;
102
- },
103
- get cachedTwMergeConfig() {
104
- return e;
105
- },
106
- set cachedTwMergeConfig(a) {
107
- e = a;
108
- },
109
- get didTwMergeConfigChange() {
110
- return t;
111
- },
112
- set didTwMergeConfigChange(a) {
113
- t = a;
114
- },
115
- reset() {
116
- r = null, e = {}, t = !1;
117
- }
118
- };
119
- }
120
- var Y = qr(), Wr = (r) => {
121
- const e = (a, s) => {
122
- const {
123
- extend: n = null,
124
- slots: i = {},
125
- variants: o = {},
126
- compoundVariants: d = [],
127
- compoundSlots: u = [],
128
- defaultVariants: p = {}
129
- } = a, k = { ...Br, ...s }, F = n?.base ? Re(n.base, a?.base) : a?.base, $ = n?.variants && !j(n.variants) ? qe(o, n.variants) : o, ze = n?.defaultVariants && !j(n.defaultVariants) ? { ...n.defaultVariants, ...p } : p;
130
- !j(k.twMergeConfig) && !Dr(k.twMergeConfig, Y.cachedTwMergeConfig) && (Y.didTwMergeConfigChange = !0, Y.cachedTwMergeConfig = k.twMergeConfig);
131
- const Se = j(n?.slots), Fe = j(i) ? {} : {
132
- // add "base" to the slots object
133
- base: Re(a?.base, Se && n?.base),
134
- ...i
135
- }, be = Se ? Fe : Ur(
136
- { ...n?.slots },
137
- j(Fe) ? { base: a?.base } : Fe
138
- ), de = j(n?.compoundVariants) ? d : Zt(n?.compoundVariants, d), W = (G) => {
139
- if (j($) && j(i) && Se)
140
- return r(F, G?.class, G?.className)(k);
141
- if (de && !Array.isArray(de))
142
- throw new TypeError(
143
- `The "compoundVariants" prop must be an array. Received: ${typeof de}`
144
- );
145
- if (u && !Array.isArray(u))
146
- throw new TypeError(
147
- `The "compoundSlots" prop must be an array. Received: ${typeof u}`
148
- );
149
- const dt = (w, C = $, N = null, R = null) => {
150
- const V = C[w];
151
- if (!V || j(V))
152
- return null;
153
- const I = R?.[w] ?? G?.[w];
154
- if (I === null) return null;
155
- const M = pt(I);
156
- if (typeof M == "object")
157
- return null;
158
- const re = ze?.[w], L = M ?? pt(re);
159
- return V[L || "false"];
160
- }, gr = () => {
161
- if (!$) return null;
162
- const w = Object.keys($), C = [];
163
- for (let N = 0; N < w.length; N++) {
164
- const R = dt(w[N], $);
165
- R && C.push(R);
166
- }
167
- return C;
168
- }, yr = (w, C) => {
169
- if (!$ || typeof $ != "object") return null;
170
- const N = [];
171
- for (const R in $) {
172
- const V = dt(R, $, w, C), I = w === "base" && typeof V == "string" ? V : V && V[w];
173
- I && N.push(I);
174
- }
175
- return N;
176
- }, ut = {};
177
- for (const w in G) {
178
- const C = G[w];
179
- C !== void 0 && (ut[w] = C);
180
- }
181
- const ft = (w, C) => {
182
- const N = typeof G?.[w] == "object" ? {
183
- [w]: G[w]?.initial
184
- } : {};
185
- return {
186
- ...ze,
187
- ...ut,
188
- ...N,
189
- ...C
190
- };
191
- }, ht = (w = [], C) => {
192
- const N = [], R = w.length;
193
- for (let V = 0; V < R; V++) {
194
- const { class: I, className: M, ...re } = w[V];
195
- let L = !0;
196
- const J = ft(null, C);
197
- for (const ue in re) {
198
- const H = re[ue], Ve = J[ue];
199
- if (Array.isArray(H)) {
200
- if (!H.includes(Ve)) {
201
- L = !1;
202
- break;
203
- }
204
- } else {
205
- if ((H == null || H === !1) && (Ve == null || Ve === !1))
206
- continue;
207
- if (Ve !== H) {
208
- L = !1;
209
- break;
210
- }
211
- }
212
- }
213
- L && (I && N.push(I), M && N.push(M));
214
- }
215
- return N;
216
- }, vr = (w) => {
217
- const C = ht(de, w);
218
- if (!Array.isArray(C)) return C;
219
- const N = {}, R = r;
220
- for (let V = 0; V < C.length; V++) {
221
- const I = C[V];
222
- if (typeof I == "string")
223
- N.base = R(N.base, I)(k);
224
- else if (typeof I == "object")
225
- for (const M in I)
226
- N[M] = R(N[M], I[M])(k);
227
- }
228
- return N;
229
- }, _r = (w) => {
230
- if (u.length < 1) return null;
231
- const C = {}, N = ft(null, w);
232
- for (let R = 0; R < u.length; R++) {
233
- const {
234
- slots: V = [],
235
- class: I,
236
- className: M,
237
- ...re
238
- } = u[R];
239
- if (!j(re)) {
240
- let L = !0;
241
- for (const J in re) {
242
- const ue = N[J], H = re[J];
243
- if (ue === void 0 || (Array.isArray(H) ? !H.includes(ue) : H !== ue)) {
244
- L = !1;
245
- break;
246
- }
247
- }
248
- if (!L) continue;
249
- }
250
- for (let L = 0; L < V.length; L++) {
251
- const J = V[L];
252
- C[J] || (C[J] = []), C[J].push([I, M]);
253
- }
254
- }
255
- return C;
256
- };
257
- if (!j(i) || !Se) {
258
- const w = {};
259
- if (typeof be == "object" && !j(be)) {
260
- const C = r;
261
- for (const N in be)
262
- w[N] = (R) => {
263
- const V = vr(R), I = _r(R);
264
- return C(
265
- be[N],
266
- yr(N, R),
267
- V ? V[N] : void 0,
268
- I ? I[N] : void 0,
269
- R?.class,
270
- R?.className
271
- )(k);
272
- };
273
- }
274
- return w;
275
- }
276
- return r(
277
- F,
278
- gr(),
279
- ht(de),
280
- G?.class,
281
- G?.className
282
- )(k);
283
- }, pr = () => {
284
- if (!(!$ || typeof $ != "object"))
285
- return Object.keys($);
286
- };
287
- return W.variantKeys = pr(), W.extend = n, W.base = F, W.slots = be, W.variants = $, W.defaultVariants = ze, W.compoundSlots = u, W.compoundVariants = de, W;
288
- };
289
- return {
290
- tv: e,
291
- createTV: (a) => (s, n) => e(s, n ? qe(a, n) : a)
292
- };
293
- }, Gr = (r) => j(r) ? Cr : Tr({
294
- ...r,
295
- extend: {
296
- theme: r.theme,
297
- classGroups: r.classGroups,
298
- conflictingClassGroupModifiers: r.conflictingClassGroupModifiers,
299
- conflictingClassGroups: r.conflictingClassGroups,
300
- ...r.extend
301
- }
302
- }), Jr = (r, e) => {
303
- const t = Re(r);
304
- return !t || !(e?.twMerge ?? !0) ? t : ((!Y.cachedTwMerge || Y.didTwMergeConfigChange) && (Y.didTwMergeConfigChange = !1, Y.cachedTwMerge = Gr(Y.cachedTwMergeConfig)), Y.cachedTwMerge(t) || void 0);
305
- }, Hr = (...r) => (e) => Jr(r, e), { tv: S } = Wr(Hr);
306
- const gt = oe.Root, Yr = S({
307
- base: "border-b"
308
- }), $t = A.forwardRef(({ className: r, ...e }, t) => /* @__PURE__ */ c(
309
- oe.Item,
310
- {
311
- ref: t,
312
- className: Yr({ className: r }),
313
- ...e
314
- }
315
- ));
316
- $t.displayName = "AccordionItem";
317
- const Qr = S({
318
- slots: {
319
- header: "flex",
320
- trigger: "flex flex-1 items-center justify-between py-4 font-medium hover:underline [&[data-state=open]>svg]:rotate-180",
321
- icon: "h-4 w-4 shrink-0 text-current transition-transform duration-200"
322
- }
323
- }), Mt = A.forwardRef(({ className: r, children: e, ...t }, a) => {
324
- const { header: s, trigger: n, icon: i } = Qr();
325
- return /* @__PURE__ */ c(oe.Header, { className: s(), asChild: !0, children: /* @__PURE__ */ c("div", { children: /* @__PURE__ */ b(
326
- oe.Trigger,
327
- {
328
- ref: a,
329
- className: n({
330
- className: r
331
- }),
332
- ...t,
333
- children: [
334
- e,
335
- /* @__PURE__ */ c(Ar, { className: i() })
336
- ]
337
- }
338
- ) }) });
339
- });
340
- Mt.displayName = oe.Trigger.displayName;
341
- const Xr = S({
342
- slots: {
343
- content: "overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
344
- wrapper: "pb-4 pt-0"
345
- }
346
- }), Lt = A.forwardRef(({ className: r, children: e, ...t }, a) => {
347
- const { content: s, wrapper: n } = Xr();
348
- return /* @__PURE__ */ c(oe.Content, { ref: a, className: s(), ...t, children: /* @__PURE__ */ c("div", { className: n({ className: r }), children: e }) });
349
- });
350
- Lt.displayName = oe.Content.displayName;
351
- const Kr = (r) => r.replace(
352
- /(?:^\w|[A-Z]|\b\w)/g,
353
- (e, t) => t === 0 ? e.toLowerCase() : e.toUpperCase()
354
- ).replace(/\s+/g, ""), ea = (r) => r.replace(/-./g, (e) => e[1].toUpperCase()), ta = (r) => r && r[0].toUpperCase() + r.slice(1), ra = S({
355
- base: "h-5 w-5 shrink-0"
356
- }), aa = ({ name: r, className: e, ...t }) => {
357
- const a = De(
358
- () => `${ta(ea(r))}Icon`,
359
- [r]
360
- ), s = Ir[a];
361
- return s ? /* @__PURE__ */ c(
362
- s,
363
- {
364
- "aria-hidden": "true",
365
- className: ra({
366
- className: e
367
- }),
368
- ...t
369
- }
370
- ) : null;
371
- };
372
- var x;
373
- (function(r) {
374
- r.assertEqual = (s) => {
375
- };
376
- function e(s) {
377
- }
378
- r.assertIs = e;
379
- function t(s) {
380
- throw new Error();
381
- }
382
- r.assertNever = t, r.arrayToEnum = (s) => {
383
- const n = {};
384
- for (const i of s)
385
- n[i] = i;
386
- return n;
387
- }, r.getValidEnumValues = (s) => {
388
- const n = r.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
389
- for (const o of n)
390
- i[o] = s[o];
391
- return r.objectValues(i);
392
- }, r.objectValues = (s) => r.objectKeys(s).map(function(n) {
393
- return s[n];
394
- }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
395
- const n = [];
396
- for (const i in s)
397
- Object.prototype.hasOwnProperty.call(s, i) && n.push(i);
398
- return n;
399
- }, r.find = (s, n) => {
400
- for (const i of s)
401
- if (n(i))
402
- return i;
403
- }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && Number.isFinite(s) && Math.floor(s) === s;
404
- function a(s, n = " | ") {
405
- return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(n);
406
- }
407
- r.joinValues = a, r.jsonStringifyReplacer = (s, n) => typeof n == "bigint" ? n.toString() : n;
408
- })(x || (x = {}));
409
- var yt;
410
- (function(r) {
411
- r.mergeShapes = (e, t) => ({
412
- ...e,
413
- ...t
414
- // second overwrites first
415
- });
416
- })(yt || (yt = {}));
417
- const h = x.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
- ]), ae = (r) => {
439
- switch (typeof r) {
440
- case "undefined":
441
- return h.undefined;
442
- case "string":
443
- return h.string;
444
- case "number":
445
- return Number.isNaN(r) ? h.nan : h.number;
446
- case "boolean":
447
- return h.boolean;
448
- case "function":
449
- return h.function;
450
- case "bigint":
451
- return h.bigint;
452
- case "symbol":
453
- return h.symbol;
454
- case "object":
455
- return Array.isArray(r) ? h.array : r === null ? h.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? h.promise : typeof Map < "u" && r instanceof Map ? h.map : typeof Set < "u" && r instanceof Set ? h.set : typeof Date < "u" && r instanceof Date ? h.date : h.object;
456
- default:
457
- return h.unknown;
458
- }
459
- }, l = x.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 X extends Error {
478
- get errors() {
479
- return this.issues;
480
- }
481
- constructor(e) {
482
- super(), this.issues = [], this.addIssue = (a) => {
483
- this.issues = [...this.issues, a];
484
- }, this.addIssues = (a = []) => {
485
- this.issues = [...this.issues, ...a];
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(n) {
492
- return n.message;
493
- }, a = { _errors: [] }, s = (n) => {
494
- for (const i of n.issues)
495
- if (i.code === "invalid_union")
496
- i.unionErrors.map(s);
497
- else if (i.code === "invalid_return_type")
498
- s(i.returnTypeError);
499
- else if (i.code === "invalid_arguments")
500
- s(i.argumentsError);
501
- else if (i.path.length === 0)
502
- a._errors.push(t(i));
503
- else {
504
- let o = a, d = 0;
505
- for (; d < i.path.length; ) {
506
- const u = i.path[d];
507
- d === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], d++;
508
- }
509
- }
510
- };
511
- return s(this), a;
512
- }
513
- static assert(e) {
514
- if (!(e instanceof X))
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, x.jsonStringifyReplacer, 2);
522
- }
523
- get isEmpty() {
524
- return this.issues.length === 0;
525
- }
526
- flatten(e = (t) => t.message) {
527
- const t = {}, a = [];
528
- for (const s of this.issues)
529
- if (s.path.length > 0) {
530
- const n = s.path[0];
531
- t[n] = t[n] || [], t[n].push(e(s));
532
- } else
533
- a.push(e(s));
534
- return { formErrors: a, fieldErrors: t };
535
- }
536
- get formErrors() {
537
- return this.flatten();
538
- }
539
- }
540
- X.create = (r) => new X(r);
541
- const We = (r, e) => {
542
- let t;
543
- switch (r.code) {
544
- case l.invalid_type:
545
- r.received === h.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, x.jsonStringifyReplacer)}`;
549
- break;
550
- case l.unrecognized_keys:
551
- t = `Unrecognized key(s) in object: ${x.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 ${x.joinValues(r.options)}`;
558
- break;
559
- case l.invalid_enum_value:
560
- t = `Invalid enum value. Expected ${x.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}"` : x.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, x.assertNever(r);
594
- }
595
- return { message: t };
596
- };
597
- let sa = We;
598
- function na() {
599
- return sa;
600
- }
601
- const ia = (r) => {
602
- const { data: e, path: t, errorMaps: a, issueData: s } = r, n = [...t, ...s.path || []], i = {
603
- ...s,
604
- path: n
605
- };
606
- if (s.message !== void 0)
607
- return {
608
- ...s,
609
- path: n,
610
- message: s.message
611
- };
612
- let o = "";
613
- const d = a.filter((u) => !!u).slice().reverse();
614
- for (const u of d)
615
- o = u(i, { data: e, defaultError: o }).message;
616
- return {
617
- ...s,
618
- path: n,
619
- message: o
620
- };
621
- };
622
- function f(r, e) {
623
- const t = na(), a = ia({
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 === We ? void 0 : We
635
- // then global default map
636
- ].filter((s) => !!s)
637
- });
638
- r.common.issues.push(a);
639
- }
640
- class E {
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 a = [];
652
- for (const s of t) {
653
- if (s.status === "aborted")
654
- return g;
655
- s.status === "dirty" && e.dirty(), a.push(s.value);
656
- }
657
- return { status: e.value, value: a };
658
- }
659
- static async mergeObjectAsync(e, t) {
660
- const a = [];
661
- for (const s of t) {
662
- const n = await s.key, i = await s.value;
663
- a.push({
664
- key: n,
665
- value: i
666
- });
667
- }
668
- return E.mergeObjectSync(e, a);
669
- }
670
- static mergeObjectSync(e, t) {
671
- const a = {};
672
- for (const s of t) {
673
- const { key: n, value: i } = s;
674
- if (n.status === "aborted" || i.status === "aborted")
675
- return g;
676
- n.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), n.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (a[n.value] = i.value);
677
- }
678
- return { status: e.value, value: a };
679
- }
680
- }
681
- const g = Object.freeze({
682
- status: "aborted"
683
- }), ke = (r) => ({ status: "dirty", value: r }), z = (r) => ({ status: "valid", value: r }), vt = (r) => r.status === "aborted", _t = (r) => r.status === "dirty", me = (r) => r.status === "valid", Oe = (r) => typeof Promise < "u" && r instanceof Promise;
684
- var m;
685
- (function(r) {
686
- r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e?.message;
687
- })(m || (m = {}));
688
- class D {
689
- constructor(e, t, a, s) {
690
- this._cachedPath = [], this.parent = e, this.data = t, this._path = a, this._key = s;
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 bt = (r, e) => {
697
- if (me(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 X(r.common.issues);
707
- return this._error = t, this._error;
708
- }
709
- };
710
- };
711
- function v(r) {
712
- if (!r)
713
- return {};
714
- const { errorMap: e, invalid_type_error: t, required_error: a, description: s } = r;
715
- if (e && (t || a))
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: s } : { errorMap: (i, o) => {
718
- const { message: d } = r;
719
- return i.code === "invalid_enum_value" ? { message: d ?? o.defaultError } : typeof o.data > "u" ? { message: d ?? a ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: d ?? t ?? o.defaultError };
720
- }, description: s };
721
- }
722
- class _ {
723
- get description() {
724
- return this._def.description;
725
- }
726
- _getType(e) {
727
- return ae(e.data);
728
- }
729
- _getOrReturnCtx(e, t) {
730
- return t || {
731
- common: e.parent.common,
732
- data: e.data,
733
- parsedType: ae(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 E(),
742
- ctx: {
743
- common: e.parent.common,
744
- data: e.data,
745
- parsedType: ae(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 (Oe(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 a = this.safeParse(e, t);
764
- if (a.success)
765
- return a.data;
766
- throw a.error;
767
- }
768
- safeParse(e, t) {
769
- const a = {
770
- common: {
771
- issues: [],
772
- async: t?.async ?? !1,
773
- contextualErrorMap: t?.errorMap
774
- },
775
- path: t?.path || [],
776
- schemaErrorMap: this._def.errorMap,
777
- parent: null,
778
- data: e,
779
- parsedType: ae(e)
780
- }, s = this._parseSync({ data: e, path: a.path, parent: a });
781
- return bt(a, s);
782
- }
783
- "~validate"(e) {
784
- const t = {
785
- common: {
786
- issues: [],
787
- async: !!this["~standard"].async
788
- },
789
- path: [],
790
- schemaErrorMap: this._def.errorMap,
791
- parent: null,
792
- data: e,
793
- parsedType: ae(e)
794
- };
795
- if (!this["~standard"].async)
796
- try {
797
- const a = this._parseSync({ data: e, path: [], parent: t });
798
- return me(a) ? {
799
- value: a.value
800
- } : {
801
- issues: t.common.issues
802
- };
803
- } catch (a) {
804
- a?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
805
- issues: [],
806
- async: !0
807
- };
808
- }
809
- return this._parseAsync({ data: e, path: [], parent: t }).then((a) => me(a) ? {
810
- value: a.value
811
- } : {
812
- issues: t.common.issues
813
- });
814
- }
815
- async parseAsync(e, t) {
816
- const a = await this.safeParseAsync(e, t);
817
- if (a.success)
818
- return a.data;
819
- throw a.error;
820
- }
821
- async safeParseAsync(e, t) {
822
- const a = {
823
- common: {
824
- issues: [],
825
- contextualErrorMap: t?.errorMap,
826
- async: !0
827
- },
828
- path: t?.path || [],
829
- schemaErrorMap: this._def.errorMap,
830
- parent: null,
831
- data: e,
832
- parsedType: ae(e)
833
- }, s = this._parse({ data: e, path: a.path, parent: a }), n = await (Oe(s) ? s : Promise.resolve(s));
834
- return bt(a, n);
835
- }
836
- refine(e, t) {
837
- const a = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
838
- return this._refinement((s, n) => {
839
- const i = e(s), o = () => n.addIssue({
840
- code: l.custom,
841
- ...a(s)
842
- });
843
- return typeof Promise < "u" && i instanceof Promise ? i.then((d) => d ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
844
- });
845
- }
846
- refinement(e, t) {
847
- return this._refinement((a, s) => e(a) ? !0 : (s.addIssue(typeof t == "function" ? t(a, s) : t), !1));
848
- }
849
- _refinement(e) {
850
- return new ye({
851
- schema: this,
852
- typeName: y.ZodEffects,
853
- effect: { type: "refinement", refinement: e }
854
- });
855
- }
856
- superRefine(e) {
857
- return this._refinement(e);
858
- }
859
- constructor(e) {
860
- 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"] = {
861
- version: 1,
862
- vendor: "zod",
863
- validate: (t) => this["~validate"](t)
864
- };
865
- }
866
- optional() {
867
- return se.create(this, this._def);
868
- }
869
- nullable() {
870
- return ve.create(this, this._def);
871
- }
872
- nullish() {
873
- return this.nullable().optional();
874
- }
875
- array() {
876
- return P.create(this);
877
- }
878
- promise() {
879
- return Ze.create(this, this._def);
880
- }
881
- or(e) {
882
- return Ie.create([this, e], this._def);
883
- }
884
- and(e) {
885
- return Ee.create(this, e, this._def);
886
- }
887
- transform(e) {
888
- return new ye({
889
- ...v(this._def),
890
- schema: this,
891
- typeName: y.ZodEffects,
892
- effect: { type: "transform", transform: e }
893
- });
894
- }
895
- default(e) {
896
- const t = typeof e == "function" ? e : () => e;
897
- return new Ke({
898
- ...v(this._def),
899
- innerType: this,
900
- defaultValue: t,
901
- typeName: y.ZodDefault
902
- });
903
- }
904
- brand() {
905
- return new Va({
906
- typeName: y.ZodBranded,
907
- type: this,
908
- ...v(this._def)
909
- });
910
- }
911
- catch(e) {
912
- const t = typeof e == "function" ? e : () => e;
913
- return new et({
914
- ...v(this._def),
915
- innerType: this,
916
- catchValue: t,
917
- typeName: y.ZodCatch
918
- });
919
- }
920
- describe(e) {
921
- const t = this.constructor;
922
- return new t({
923
- ...this._def,
924
- description: e
925
- });
926
- }
927
- pipe(e) {
928
- return nt.create(this, e);
929
- }
930
- readonly() {
931
- return tt.create(this);
932
- }
933
- isOptional() {
934
- return this.safeParse(void 0).success;
935
- }
936
- isNullable() {
937
- return this.safeParse(null).success;
938
- }
939
- }
940
- const oa = /^c[^\s-]{8,}$/i, ca = /^[0-9a-z]+$/, la = /^[0-9A-HJKMNP-TV-Z]{26}$/i, da = /^[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, ua = /^[a-z0-9_-]{21}$/i, fa = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ha = /^[-+]?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)?)??$/, ma = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, pa = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
941
- let Pe;
942
- const ga = /^(?:(?: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])$/, ya = /^(?:(?: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])$/, va = /^(([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]))$/, _a = /^(([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])$/, ba = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, xa = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, zt = "((\\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])))", ka = new RegExp(`^${zt}$`);
943
- function Ft(r) {
944
- let e = "[0-5]\\d";
945
- r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`);
946
- const t = r.precision ? "+" : "?";
947
- return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
948
- }
949
- function wa(r) {
950
- return new RegExp(`^${Ft(r)}$`);
951
- }
952
- function Na(r) {
953
- let e = `${zt}T${Ft(r)}`;
954
- const t = [];
955
- return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
956
- }
957
- function Ca(r, e) {
958
- return !!((e === "v4" || !e) && ga.test(r) || (e === "v6" || !e) && va.test(r));
959
- }
960
- function Ta(r, e) {
961
- if (!fa.test(r))
962
- return !1;
963
- try {
964
- const [t] = r.split(".");
965
- if (!t)
966
- return !1;
967
- const a = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(a));
968
- return !(typeof s != "object" || s === null || "typ" in s && s?.typ !== "JWT" || !s.alg || e && s.alg !== e);
969
- } catch {
970
- return !1;
971
- }
972
- }
973
- function Aa(r, e) {
974
- return !!((e === "v4" || !e) && ya.test(r) || (e === "v6" || !e) && _a.test(r));
975
- }
976
- class Q extends _ {
977
- _parse(e) {
978
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
979
- const n = this._getOrReturnCtx(e);
980
- return f(n, {
981
- code: l.invalid_type,
982
- expected: h.string,
983
- received: n.parsedType
984
- }), g;
985
- }
986
- const a = new E();
987
- let s;
988
- for (const n of this._def.checks)
989
- if (n.kind === "min")
990
- e.data.length < n.value && (s = this._getOrReturnCtx(e, s), f(s, {
991
- code: l.too_small,
992
- minimum: n.value,
993
- type: "string",
994
- inclusive: !0,
995
- exact: !1,
996
- message: n.message
997
- }), a.dirty());
998
- else if (n.kind === "max")
999
- e.data.length > n.value && (s = this._getOrReturnCtx(e, s), f(s, {
1000
- code: l.too_big,
1001
- maximum: n.value,
1002
- type: "string",
1003
- inclusive: !0,
1004
- exact: !1,
1005
- message: n.message
1006
- }), a.dirty());
1007
- else if (n.kind === "length") {
1008
- const i = e.data.length > n.value, o = e.data.length < n.value;
1009
- (i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
1010
- code: l.too_big,
1011
- maximum: n.value,
1012
- type: "string",
1013
- inclusive: !0,
1014
- exact: !0,
1015
- message: n.message
1016
- }) : o && f(s, {
1017
- code: l.too_small,
1018
- minimum: n.value,
1019
- type: "string",
1020
- inclusive: !0,
1021
- exact: !0,
1022
- message: n.message
1023
- }), a.dirty());
1024
- } else if (n.kind === "email")
1025
- ma.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1026
- validation: "email",
1027
- code: l.invalid_string,
1028
- message: n.message
1029
- }), a.dirty());
1030
- else if (n.kind === "emoji")
1031
- Pe || (Pe = new RegExp(pa, "u")), Pe.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1032
- validation: "emoji",
1033
- code: l.invalid_string,
1034
- message: n.message
1035
- }), a.dirty());
1036
- else if (n.kind === "uuid")
1037
- da.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1038
- validation: "uuid",
1039
- code: l.invalid_string,
1040
- message: n.message
1041
- }), a.dirty());
1042
- else if (n.kind === "nanoid")
1043
- ua.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1044
- validation: "nanoid",
1045
- code: l.invalid_string,
1046
- message: n.message
1047
- }), a.dirty());
1048
- else if (n.kind === "cuid")
1049
- oa.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1050
- validation: "cuid",
1051
- code: l.invalid_string,
1052
- message: n.message
1053
- }), a.dirty());
1054
- else if (n.kind === "cuid2")
1055
- ca.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1056
- validation: "cuid2",
1057
- code: l.invalid_string,
1058
- message: n.message
1059
- }), a.dirty());
1060
- else if (n.kind === "ulid")
1061
- la.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1062
- validation: "ulid",
1063
- code: l.invalid_string,
1064
- message: n.message
1065
- }), a.dirty());
1066
- else if (n.kind === "url")
1067
- try {
1068
- new URL(e.data);
1069
- } catch {
1070
- s = this._getOrReturnCtx(e, s), f(s, {
1071
- validation: "url",
1072
- code: l.invalid_string,
1073
- message: n.message
1074
- }), a.dirty();
1075
- }
1076
- else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1077
- validation: "regex",
1078
- code: l.invalid_string,
1079
- message: n.message
1080
- }), a.dirty())) : n.kind === "trim" ? e.data = e.data.trim() : n.kind === "includes" ? e.data.includes(n.value, n.position) || (s = this._getOrReturnCtx(e, s), f(s, {
1081
- code: l.invalid_string,
1082
- validation: { includes: n.value, position: n.position },
1083
- message: n.message
1084
- }), a.dirty()) : n.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : n.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : n.kind === "startsWith" ? e.data.startsWith(n.value) || (s = this._getOrReturnCtx(e, s), f(s, {
1085
- code: l.invalid_string,
1086
- validation: { startsWith: n.value },
1087
- message: n.message
1088
- }), a.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (s = this._getOrReturnCtx(e, s), f(s, {
1089
- code: l.invalid_string,
1090
- validation: { endsWith: n.value },
1091
- message: n.message
1092
- }), a.dirty()) : n.kind === "datetime" ? Na(n).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1093
- code: l.invalid_string,
1094
- validation: "datetime",
1095
- message: n.message
1096
- }), a.dirty()) : n.kind === "date" ? ka.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1097
- code: l.invalid_string,
1098
- validation: "date",
1099
- message: n.message
1100
- }), a.dirty()) : n.kind === "time" ? wa(n).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1101
- code: l.invalid_string,
1102
- validation: "time",
1103
- message: n.message
1104
- }), a.dirty()) : n.kind === "duration" ? ha.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1105
- validation: "duration",
1106
- code: l.invalid_string,
1107
- message: n.message
1108
- }), a.dirty()) : n.kind === "ip" ? Ca(e.data, n.version) || (s = this._getOrReturnCtx(e, s), f(s, {
1109
- validation: "ip",
1110
- code: l.invalid_string,
1111
- message: n.message
1112
- }), a.dirty()) : n.kind === "jwt" ? Ta(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
1113
- validation: "jwt",
1114
- code: l.invalid_string,
1115
- message: n.message
1116
- }), a.dirty()) : n.kind === "cidr" ? Aa(e.data, n.version) || (s = this._getOrReturnCtx(e, s), f(s, {
1117
- validation: "cidr",
1118
- code: l.invalid_string,
1119
- message: n.message
1120
- }), a.dirty()) : n.kind === "base64" ? ba.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1121
- validation: "base64",
1122
- code: l.invalid_string,
1123
- message: n.message
1124
- }), a.dirty()) : n.kind === "base64url" ? xa.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1125
- validation: "base64url",
1126
- code: l.invalid_string,
1127
- message: n.message
1128
- }), a.dirty()) : x.assertNever(n);
1129
- return { status: a.value, value: e.data };
1130
- }
1131
- _regex(e, t, a) {
1132
- return this.refinement((s) => e.test(s), {
1133
- validation: t,
1134
- code: l.invalid_string,
1135
- ...m.errToObj(a)
1136
- });
1137
- }
1138
- _addCheck(e) {
1139
- return new Q({
1140
- ...this._def,
1141
- checks: [...this._def.checks, e]
1142
- });
1143
- }
1144
- email(e) {
1145
- return this._addCheck({ kind: "email", ...m.errToObj(e) });
1146
- }
1147
- url(e) {
1148
- return this._addCheck({ kind: "url", ...m.errToObj(e) });
1149
- }
1150
- emoji(e) {
1151
- return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
1152
- }
1153
- uuid(e) {
1154
- return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
1155
- }
1156
- nanoid(e) {
1157
- return this._addCheck({ kind: "nanoid", ...m.errToObj(e) });
1158
- }
1159
- cuid(e) {
1160
- return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
1161
- }
1162
- cuid2(e) {
1163
- return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
1164
- }
1165
- ulid(e) {
1166
- return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
1167
- }
1168
- base64(e) {
1169
- return this._addCheck({ kind: "base64", ...m.errToObj(e) });
1170
- }
1171
- base64url(e) {
1172
- return this._addCheck({
1173
- kind: "base64url",
1174
- ...m.errToObj(e)
1175
- });
1176
- }
1177
- jwt(e) {
1178
- return this._addCheck({ kind: "jwt", ...m.errToObj(e) });
1179
- }
1180
- ip(e) {
1181
- return this._addCheck({ kind: "ip", ...m.errToObj(e) });
1182
- }
1183
- cidr(e) {
1184
- return this._addCheck({ kind: "cidr", ...m.errToObj(e) });
1185
- }
1186
- datetime(e) {
1187
- return typeof e == "string" ? this._addCheck({
1188
- kind: "datetime",
1189
- precision: null,
1190
- offset: !1,
1191
- local: !1,
1192
- message: e
1193
- }) : this._addCheck({
1194
- kind: "datetime",
1195
- precision: typeof e?.precision > "u" ? null : e?.precision,
1196
- offset: e?.offset ?? !1,
1197
- local: e?.local ?? !1,
1198
- ...m.errToObj(e?.message)
1199
- });
1200
- }
1201
- date(e) {
1202
- return this._addCheck({ kind: "date", message: e });
1203
- }
1204
- time(e) {
1205
- return typeof e == "string" ? this._addCheck({
1206
- kind: "time",
1207
- precision: null,
1208
- message: e
1209
- }) : this._addCheck({
1210
- kind: "time",
1211
- precision: typeof e?.precision > "u" ? null : e?.precision,
1212
- ...m.errToObj(e?.message)
1213
- });
1214
- }
1215
- duration(e) {
1216
- return this._addCheck({ kind: "duration", ...m.errToObj(e) });
1217
- }
1218
- regex(e, t) {
1219
- return this._addCheck({
1220
- kind: "regex",
1221
- regex: e,
1222
- ...m.errToObj(t)
1223
- });
1224
- }
1225
- includes(e, t) {
1226
- return this._addCheck({
1227
- kind: "includes",
1228
- value: e,
1229
- position: t?.position,
1230
- ...m.errToObj(t?.message)
1231
- });
1232
- }
1233
- startsWith(e, t) {
1234
- return this._addCheck({
1235
- kind: "startsWith",
1236
- value: e,
1237
- ...m.errToObj(t)
1238
- });
1239
- }
1240
- endsWith(e, t) {
1241
- return this._addCheck({
1242
- kind: "endsWith",
1243
- value: e,
1244
- ...m.errToObj(t)
1245
- });
1246
- }
1247
- min(e, t) {
1248
- return this._addCheck({
1249
- kind: "min",
1250
- value: e,
1251
- ...m.errToObj(t)
1252
- });
1253
- }
1254
- max(e, t) {
1255
- return this._addCheck({
1256
- kind: "max",
1257
- value: e,
1258
- ...m.errToObj(t)
1259
- });
1260
- }
1261
- length(e, t) {
1262
- return this._addCheck({
1263
- kind: "length",
1264
- value: e,
1265
- ...m.errToObj(t)
1266
- });
1267
- }
1268
- /**
1269
- * Equivalent to `.min(1)`
1270
- */
1271
- nonempty(e) {
1272
- return this.min(1, m.errToObj(e));
1273
- }
1274
- trim() {
1275
- return new Q({
1276
- ...this._def,
1277
- checks: [...this._def.checks, { kind: "trim" }]
1278
- });
1279
- }
1280
- toLowerCase() {
1281
- return new Q({
1282
- ...this._def,
1283
- checks: [...this._def.checks, { kind: "toLowerCase" }]
1284
- });
1285
- }
1286
- toUpperCase() {
1287
- return new Q({
1288
- ...this._def,
1289
- checks: [...this._def.checks, { kind: "toUpperCase" }]
1290
- });
1291
- }
1292
- get isDatetime() {
1293
- return !!this._def.checks.find((e) => e.kind === "datetime");
1294
- }
1295
- get isDate() {
1296
- return !!this._def.checks.find((e) => e.kind === "date");
1297
- }
1298
- get isTime() {
1299
- return !!this._def.checks.find((e) => e.kind === "time");
1300
- }
1301
- get isDuration() {
1302
- return !!this._def.checks.find((e) => e.kind === "duration");
1303
- }
1304
- get isEmail() {
1305
- return !!this._def.checks.find((e) => e.kind === "email");
1306
- }
1307
- get isURL() {
1308
- return !!this._def.checks.find((e) => e.kind === "url");
1309
- }
1310
- get isEmoji() {
1311
- return !!this._def.checks.find((e) => e.kind === "emoji");
1312
- }
1313
- get isUUID() {
1314
- return !!this._def.checks.find((e) => e.kind === "uuid");
1315
- }
1316
- get isNANOID() {
1317
- return !!this._def.checks.find((e) => e.kind === "nanoid");
1318
- }
1319
- get isCUID() {
1320
- return !!this._def.checks.find((e) => e.kind === "cuid");
1321
- }
1322
- get isCUID2() {
1323
- return !!this._def.checks.find((e) => e.kind === "cuid2");
1324
- }
1325
- get isULID() {
1326
- return !!this._def.checks.find((e) => e.kind === "ulid");
1327
- }
1328
- get isIP() {
1329
- return !!this._def.checks.find((e) => e.kind === "ip");
1330
- }
1331
- get isCIDR() {
1332
- return !!this._def.checks.find((e) => e.kind === "cidr");
1333
- }
1334
- get isBase64() {
1335
- return !!this._def.checks.find((e) => e.kind === "base64");
1336
- }
1337
- get isBase64url() {
1338
- return !!this._def.checks.find((e) => e.kind === "base64url");
1339
- }
1340
- get minLength() {
1341
- let e = null;
1342
- for (const t of this._def.checks)
1343
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1344
- return e;
1345
- }
1346
- get maxLength() {
1347
- let e = null;
1348
- for (const t of this._def.checks)
1349
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1350
- return e;
1351
- }
1352
- }
1353
- Q.create = (r) => new Q({
1354
- checks: [],
1355
- typeName: y.ZodString,
1356
- coerce: r?.coerce ?? !1,
1357
- ...v(r)
1358
- });
1359
- function Sa(r, e) {
1360
- const t = (r.toString().split(".")[1] || "").length, a = (e.toString().split(".")[1] || "").length, s = t > a ? t : a, n = Number.parseInt(r.toFixed(s).replace(".", "")), i = Number.parseInt(e.toFixed(s).replace(".", ""));
1361
- return n % i / 10 ** s;
1362
- }
1363
- class pe extends _ {
1364
- constructor() {
1365
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1366
- }
1367
- _parse(e) {
1368
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
1369
- const n = this._getOrReturnCtx(e);
1370
- return f(n, {
1371
- code: l.invalid_type,
1372
- expected: h.number,
1373
- received: n.parsedType
1374
- }), g;
1375
- }
1376
- let a;
1377
- const s = new E();
1378
- for (const n of this._def.checks)
1379
- n.kind === "int" ? x.isInteger(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
1380
- code: l.invalid_type,
1381
- expected: "integer",
1382
- received: "float",
1383
- message: n.message
1384
- }), s.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1385
- code: l.too_small,
1386
- minimum: n.value,
1387
- type: "number",
1388
- inclusive: n.inclusive,
1389
- exact: !1,
1390
- message: n.message
1391
- }), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1392
- code: l.too_big,
1393
- maximum: n.value,
1394
- type: "number",
1395
- inclusive: n.inclusive,
1396
- exact: !1,
1397
- message: n.message
1398
- }), s.dirty()) : n.kind === "multipleOf" ? Sa(e.data, n.value) !== 0 && (a = this._getOrReturnCtx(e, a), f(a, {
1399
- code: l.not_multiple_of,
1400
- multipleOf: n.value,
1401
- message: n.message
1402
- }), s.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
1403
- code: l.not_finite,
1404
- message: n.message
1405
- }), s.dirty()) : x.assertNever(n);
1406
- return { status: s.value, value: e.data };
1407
- }
1408
- gte(e, t) {
1409
- return this.setLimit("min", e, !0, m.toString(t));
1410
- }
1411
- gt(e, t) {
1412
- return this.setLimit("min", e, !1, m.toString(t));
1413
- }
1414
- lte(e, t) {
1415
- return this.setLimit("max", e, !0, m.toString(t));
1416
- }
1417
- lt(e, t) {
1418
- return this.setLimit("max", e, !1, m.toString(t));
1419
- }
1420
- setLimit(e, t, a, s) {
1421
- return new pe({
1422
- ...this._def,
1423
- checks: [
1424
- ...this._def.checks,
1425
- {
1426
- kind: e,
1427
- value: t,
1428
- inclusive: a,
1429
- message: m.toString(s)
1430
- }
1431
- ]
1432
- });
1433
- }
1434
- _addCheck(e) {
1435
- return new pe({
1436
- ...this._def,
1437
- checks: [...this._def.checks, e]
1438
- });
1439
- }
1440
- int(e) {
1441
- return this._addCheck({
1442
- kind: "int",
1443
- message: m.toString(e)
1444
- });
1445
- }
1446
- positive(e) {
1447
- return this._addCheck({
1448
- kind: "min",
1449
- value: 0,
1450
- inclusive: !1,
1451
- message: m.toString(e)
1452
- });
1453
- }
1454
- negative(e) {
1455
- return this._addCheck({
1456
- kind: "max",
1457
- value: 0,
1458
- inclusive: !1,
1459
- message: m.toString(e)
1460
- });
1461
- }
1462
- nonpositive(e) {
1463
- return this._addCheck({
1464
- kind: "max",
1465
- value: 0,
1466
- inclusive: !0,
1467
- message: m.toString(e)
1468
- });
1469
- }
1470
- nonnegative(e) {
1471
- return this._addCheck({
1472
- kind: "min",
1473
- value: 0,
1474
- inclusive: !0,
1475
- message: m.toString(e)
1476
- });
1477
- }
1478
- multipleOf(e, t) {
1479
- return this._addCheck({
1480
- kind: "multipleOf",
1481
- value: e,
1482
- message: m.toString(t)
1483
- });
1484
- }
1485
- finite(e) {
1486
- return this._addCheck({
1487
- kind: "finite",
1488
- message: m.toString(e)
1489
- });
1490
- }
1491
- safe(e) {
1492
- return this._addCheck({
1493
- kind: "min",
1494
- inclusive: !0,
1495
- value: Number.MIN_SAFE_INTEGER,
1496
- message: m.toString(e)
1497
- })._addCheck({
1498
- kind: "max",
1499
- inclusive: !0,
1500
- value: Number.MAX_SAFE_INTEGER,
1501
- message: m.toString(e)
1502
- });
1503
- }
1504
- get minValue() {
1505
- let e = null;
1506
- for (const t of this._def.checks)
1507
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1508
- return e;
1509
- }
1510
- get maxValue() {
1511
- let e = null;
1512
- for (const t of this._def.checks)
1513
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1514
- return e;
1515
- }
1516
- get isInt() {
1517
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1518
- }
1519
- get isFinite() {
1520
- let e = null, t = null;
1521
- for (const a of this._def.checks) {
1522
- if (a.kind === "finite" || a.kind === "int" || a.kind === "multipleOf")
1523
- return !0;
1524
- a.kind === "min" ? (t === null || a.value > t) && (t = a.value) : a.kind === "max" && (e === null || a.value < e) && (e = a.value);
1525
- }
1526
- return Number.isFinite(t) && Number.isFinite(e);
1527
- }
1528
- }
1529
- pe.create = (r) => new pe({
1530
- checks: [],
1531
- typeName: y.ZodNumber,
1532
- coerce: r?.coerce || !1,
1533
- ...v(r)
1534
- });
1535
- class Ne extends _ {
1536
- constructor() {
1537
- super(...arguments), this.min = this.gte, this.max = this.lte;
1538
- }
1539
- _parse(e) {
1540
- if (this._def.coerce)
1541
- try {
1542
- e.data = BigInt(e.data);
1543
- } catch {
1544
- return this._getInvalidInput(e);
1545
- }
1546
- if (this._getType(e) !== h.bigint)
1547
- return this._getInvalidInput(e);
1548
- let a;
1549
- const s = new E();
1550
- for (const n of this._def.checks)
1551
- n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1552
- code: l.too_small,
1553
- type: "bigint",
1554
- minimum: n.value,
1555
- inclusive: n.inclusive,
1556
- message: n.message
1557
- }), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1558
- code: l.too_big,
1559
- type: "bigint",
1560
- maximum: n.value,
1561
- inclusive: n.inclusive,
1562
- message: n.message
1563
- }), s.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (a = this._getOrReturnCtx(e, a), f(a, {
1564
- code: l.not_multiple_of,
1565
- multipleOf: n.value,
1566
- message: n.message
1567
- }), s.dirty()) : x.assertNever(n);
1568
- return { status: s.value, value: e.data };
1569
- }
1570
- _getInvalidInput(e) {
1571
- const t = this._getOrReturnCtx(e);
1572
- return f(t, {
1573
- code: l.invalid_type,
1574
- expected: h.bigint,
1575
- received: t.parsedType
1576
- }), g;
1577
- }
1578
- gte(e, t) {
1579
- return this.setLimit("min", e, !0, m.toString(t));
1580
- }
1581
- gt(e, t) {
1582
- return this.setLimit("min", e, !1, m.toString(t));
1583
- }
1584
- lte(e, t) {
1585
- return this.setLimit("max", e, !0, m.toString(t));
1586
- }
1587
- lt(e, t) {
1588
- return this.setLimit("max", e, !1, m.toString(t));
1589
- }
1590
- setLimit(e, t, a, s) {
1591
- return new Ne({
1592
- ...this._def,
1593
- checks: [
1594
- ...this._def.checks,
1595
- {
1596
- kind: e,
1597
- value: t,
1598
- inclusive: a,
1599
- message: m.toString(s)
1600
- }
1601
- ]
1602
- });
1603
- }
1604
- _addCheck(e) {
1605
- return new Ne({
1606
- ...this._def,
1607
- checks: [...this._def.checks, e]
1608
- });
1609
- }
1610
- positive(e) {
1611
- return this._addCheck({
1612
- kind: "min",
1613
- value: BigInt(0),
1614
- inclusive: !1,
1615
- message: m.toString(e)
1616
- });
1617
- }
1618
- negative(e) {
1619
- return this._addCheck({
1620
- kind: "max",
1621
- value: BigInt(0),
1622
- inclusive: !1,
1623
- message: m.toString(e)
1624
- });
1625
- }
1626
- nonpositive(e) {
1627
- return this._addCheck({
1628
- kind: "max",
1629
- value: BigInt(0),
1630
- inclusive: !0,
1631
- message: m.toString(e)
1632
- });
1633
- }
1634
- nonnegative(e) {
1635
- return this._addCheck({
1636
- kind: "min",
1637
- value: BigInt(0),
1638
- inclusive: !0,
1639
- message: m.toString(e)
1640
- });
1641
- }
1642
- multipleOf(e, t) {
1643
- return this._addCheck({
1644
- kind: "multipleOf",
1645
- value: e,
1646
- message: m.toString(t)
1647
- });
1648
- }
1649
- get minValue() {
1650
- let e = null;
1651
- for (const t of this._def.checks)
1652
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1653
- return e;
1654
- }
1655
- get maxValue() {
1656
- let e = null;
1657
- for (const t of this._def.checks)
1658
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1659
- return e;
1660
- }
1661
- }
1662
- Ne.create = (r) => new Ne({
1663
- checks: [],
1664
- typeName: y.ZodBigInt,
1665
- coerce: r?.coerce ?? !1,
1666
- ...v(r)
1667
- });
1668
- class Ge extends _ {
1669
- _parse(e) {
1670
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
1671
- const a = this._getOrReturnCtx(e);
1672
- return f(a, {
1673
- code: l.invalid_type,
1674
- expected: h.boolean,
1675
- received: a.parsedType
1676
- }), g;
1677
- }
1678
- return z(e.data);
1679
- }
1680
- }
1681
- Ge.create = (r) => new Ge({
1682
- typeName: y.ZodBoolean,
1683
- coerce: r?.coerce || !1,
1684
- ...v(r)
1685
- });
1686
- class Ce extends _ {
1687
- _parse(e) {
1688
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
1689
- const n = this._getOrReturnCtx(e);
1690
- return f(n, {
1691
- code: l.invalid_type,
1692
- expected: h.date,
1693
- received: n.parsedType
1694
- }), g;
1695
- }
1696
- if (Number.isNaN(e.data.getTime())) {
1697
- const n = this._getOrReturnCtx(e);
1698
- return f(n, {
1699
- code: l.invalid_date
1700
- }), g;
1701
- }
1702
- const a = new E();
1703
- let s;
1704
- for (const n of this._def.checks)
1705
- n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), f(s, {
1706
- code: l.too_small,
1707
- message: n.message,
1708
- inclusive: !0,
1709
- exact: !1,
1710
- minimum: n.value,
1711
- type: "date"
1712
- }), a.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (s = this._getOrReturnCtx(e, s), f(s, {
1713
- code: l.too_big,
1714
- message: n.message,
1715
- inclusive: !0,
1716
- exact: !1,
1717
- maximum: n.value,
1718
- type: "date"
1719
- }), a.dirty()) : x.assertNever(n);
1720
- return {
1721
- status: a.value,
1722
- value: new Date(e.data.getTime())
1723
- };
1724
- }
1725
- _addCheck(e) {
1726
- return new Ce({
1727
- ...this._def,
1728
- checks: [...this._def.checks, e]
1729
- });
1730
- }
1731
- min(e, t) {
1732
- return this._addCheck({
1733
- kind: "min",
1734
- value: e.getTime(),
1735
- message: m.toString(t)
1736
- });
1737
- }
1738
- max(e, t) {
1739
- return this._addCheck({
1740
- kind: "max",
1741
- value: e.getTime(),
1742
- message: m.toString(t)
1743
- });
1744
- }
1745
- get minDate() {
1746
- let e = null;
1747
- for (const t of this._def.checks)
1748
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1749
- return e != null ? new Date(e) : null;
1750
- }
1751
- get maxDate() {
1752
- let e = null;
1753
- for (const t of this._def.checks)
1754
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1755
- return e != null ? new Date(e) : null;
1756
- }
1757
- }
1758
- Ce.create = (r) => new Ce({
1759
- checks: [],
1760
- coerce: r?.coerce || !1,
1761
- typeName: y.ZodDate,
1762
- ...v(r)
1763
- });
1764
- class xt extends _ {
1765
- _parse(e) {
1766
- if (this._getType(e) !== h.symbol) {
1767
- const a = this._getOrReturnCtx(e);
1768
- return f(a, {
1769
- code: l.invalid_type,
1770
- expected: h.symbol,
1771
- received: a.parsedType
1772
- }), g;
1773
- }
1774
- return z(e.data);
1775
- }
1776
- }
1777
- xt.create = (r) => new xt({
1778
- typeName: y.ZodSymbol,
1779
- ...v(r)
1780
- });
1781
- class kt extends _ {
1782
- _parse(e) {
1783
- if (this._getType(e) !== h.undefined) {
1784
- const a = this._getOrReturnCtx(e);
1785
- return f(a, {
1786
- code: l.invalid_type,
1787
- expected: h.undefined,
1788
- received: a.parsedType
1789
- }), g;
1790
- }
1791
- return z(e.data);
1792
- }
1793
- }
1794
- kt.create = (r) => new kt({
1795
- typeName: y.ZodUndefined,
1796
- ...v(r)
1797
- });
1798
- class Je extends _ {
1799
- _parse(e) {
1800
- if (this._getType(e) !== h.null) {
1801
- const a = this._getOrReturnCtx(e);
1802
- return f(a, {
1803
- code: l.invalid_type,
1804
- expected: h.null,
1805
- received: a.parsedType
1806
- }), g;
1807
- }
1808
- return z(e.data);
1809
- }
1810
- }
1811
- Je.create = (r) => new Je({
1812
- typeName: y.ZodNull,
1813
- ...v(r)
1814
- });
1815
- class He extends _ {
1816
- constructor() {
1817
- super(...arguments), this._any = !0;
1818
- }
1819
- _parse(e) {
1820
- return z(e.data);
1821
- }
1822
- }
1823
- He.create = (r) => new He({
1824
- typeName: y.ZodAny,
1825
- ...v(r)
1826
- });
1827
- class wt extends _ {
1828
- constructor() {
1829
- super(...arguments), this._unknown = !0;
1830
- }
1831
- _parse(e) {
1832
- return z(e.data);
1833
- }
1834
- }
1835
- wt.create = (r) => new wt({
1836
- typeName: y.ZodUnknown,
1837
- ...v(r)
1838
- });
1839
- class ne extends _ {
1840
- _parse(e) {
1841
- const t = this._getOrReturnCtx(e);
1842
- return f(t, {
1843
- code: l.invalid_type,
1844
- expected: h.never,
1845
- received: t.parsedType
1846
- }), g;
1847
- }
1848
- }
1849
- ne.create = (r) => new ne({
1850
- typeName: y.ZodNever,
1851
- ...v(r)
1852
- });
1853
- class Nt extends _ {
1854
- _parse(e) {
1855
- if (this._getType(e) !== h.undefined) {
1856
- const a = this._getOrReturnCtx(e);
1857
- return f(a, {
1858
- code: l.invalid_type,
1859
- expected: h.void,
1860
- received: a.parsedType
1861
- }), g;
1862
- }
1863
- return z(e.data);
1864
- }
1865
- }
1866
- Nt.create = (r) => new Nt({
1867
- typeName: y.ZodVoid,
1868
- ...v(r)
1869
- });
1870
- class P extends _ {
1871
- _parse(e) {
1872
- const { ctx: t, status: a } = this._processInputParams(e), s = this._def;
1873
- if (t.parsedType !== h.array)
1874
- return f(t, {
1875
- code: l.invalid_type,
1876
- expected: h.array,
1877
- received: t.parsedType
1878
- }), g;
1879
- if (s.exactLength !== null) {
1880
- const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
1881
- (i || o) && (f(t, {
1882
- code: i ? l.too_big : l.too_small,
1883
- minimum: o ? s.exactLength.value : void 0,
1884
- maximum: i ? s.exactLength.value : void 0,
1885
- type: "array",
1886
- inclusive: !0,
1887
- exact: !0,
1888
- message: s.exactLength.message
1889
- }), a.dirty());
1890
- }
1891
- if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
1892
- code: l.too_small,
1893
- minimum: s.minLength.value,
1894
- type: "array",
1895
- inclusive: !0,
1896
- exact: !1,
1897
- message: s.minLength.message
1898
- }), a.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
1899
- code: l.too_big,
1900
- maximum: s.maxLength.value,
1901
- type: "array",
1902
- inclusive: !0,
1903
- exact: !1,
1904
- message: s.maxLength.message
1905
- }), a.dirty()), t.common.async)
1906
- return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new D(t, i, t.path, o)))).then((i) => E.mergeArray(a, i));
1907
- const n = [...t.data].map((i, o) => s.type._parseSync(new D(t, i, t.path, o)));
1908
- return E.mergeArray(a, n);
1909
- }
1910
- get element() {
1911
- return this._def.type;
1912
- }
1913
- min(e, t) {
1914
- return new P({
1915
- ...this._def,
1916
- minLength: { value: e, message: m.toString(t) }
1917
- });
1918
- }
1919
- max(e, t) {
1920
- return new P({
1921
- ...this._def,
1922
- maxLength: { value: e, message: m.toString(t) }
1923
- });
1924
- }
1925
- length(e, t) {
1926
- return new P({
1927
- ...this._def,
1928
- exactLength: { value: e, message: m.toString(t) }
1929
- });
1930
- }
1931
- nonempty(e) {
1932
- return this.min(1, e);
1933
- }
1934
- }
1935
- P.create = (r, e) => new P({
1936
- type: r,
1937
- minLength: null,
1938
- maxLength: null,
1939
- exactLength: null,
1940
- typeName: y.ZodArray,
1941
- ...v(e)
1942
- });
1943
- function he(r) {
1944
- if (r instanceof O) {
1945
- const e = {};
1946
- for (const t in r.shape) {
1947
- const a = r.shape[t];
1948
- e[t] = se.create(he(a));
1949
- }
1950
- return new O({
1951
- ...r._def,
1952
- shape: () => e
1953
- });
1954
- } else return r instanceof P ? new P({
1955
- ...r._def,
1956
- type: he(r.element)
1957
- }) : r instanceof se ? se.create(he(r.unwrap())) : r instanceof ve ? ve.create(he(r.unwrap())) : r instanceof ce ? ce.create(r.items.map((e) => he(e))) : r;
1958
- }
1959
- class O extends _ {
1960
- constructor() {
1961
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1962
- }
1963
- _getCached() {
1964
- if (this._cached !== null)
1965
- return this._cached;
1966
- const e = this._def.shape(), t = x.objectKeys(e);
1967
- return this._cached = { shape: e, keys: t }, this._cached;
1968
- }
1969
- _parse(e) {
1970
- if (this._getType(e) !== h.object) {
1971
- const u = this._getOrReturnCtx(e);
1972
- return f(u, {
1973
- code: l.invalid_type,
1974
- expected: h.object,
1975
- received: u.parsedType
1976
- }), g;
1977
- }
1978
- const { status: a, ctx: s } = this._processInputParams(e), { shape: n, keys: i } = this._getCached(), o = [];
1979
- if (!(this._def.catchall instanceof ne && this._def.unknownKeys === "strip"))
1980
- for (const u in s.data)
1981
- i.includes(u) || o.push(u);
1982
- const d = [];
1983
- for (const u of i) {
1984
- const p = n[u], k = s.data[u];
1985
- d.push({
1986
- key: { status: "valid", value: u },
1987
- value: p._parse(new D(s, k, s.path, u)),
1988
- alwaysSet: u in s.data
1989
- });
1990
- }
1991
- if (this._def.catchall instanceof ne) {
1992
- const u = this._def.unknownKeys;
1993
- if (u === "passthrough")
1994
- for (const p of o)
1995
- d.push({
1996
- key: { status: "valid", value: p },
1997
- value: { status: "valid", value: s.data[p] }
1998
- });
1999
- else if (u === "strict")
2000
- o.length > 0 && (f(s, {
2001
- code: l.unrecognized_keys,
2002
- keys: o
2003
- }), a.dirty());
2004
- else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2005
- } else {
2006
- const u = this._def.catchall;
2007
- for (const p of o) {
2008
- const k = s.data[p];
2009
- d.push({
2010
- key: { status: "valid", value: p },
2011
- value: u._parse(
2012
- new D(s, k, s.path, p)
2013
- //, ctx.child(key), value, getParsedType(value)
2014
- ),
2015
- alwaysSet: p in s.data
2016
- });
2017
- }
2018
- }
2019
- return s.common.async ? Promise.resolve().then(async () => {
2020
- const u = [];
2021
- for (const p of d) {
2022
- const k = await p.key, F = await p.value;
2023
- u.push({
2024
- key: k,
2025
- value: F,
2026
- alwaysSet: p.alwaysSet
2027
- });
2028
- }
2029
- return u;
2030
- }).then((u) => E.mergeObjectSync(a, u)) : E.mergeObjectSync(a, d);
2031
- }
2032
- get shape() {
2033
- return this._def.shape();
2034
- }
2035
- strict(e) {
2036
- return m.errToObj, new O({
2037
- ...this._def,
2038
- unknownKeys: "strict",
2039
- ...e !== void 0 ? {
2040
- errorMap: (t, a) => {
2041
- const s = this._def.errorMap?.(t, a).message ?? a.defaultError;
2042
- return t.code === "unrecognized_keys" ? {
2043
- message: m.errToObj(e).message ?? s
2044
- } : {
2045
- message: s
2046
- };
2047
- }
2048
- } : {}
2049
- });
2050
- }
2051
- strip() {
2052
- return new O({
2053
- ...this._def,
2054
- unknownKeys: "strip"
2055
- });
2056
- }
2057
- passthrough() {
2058
- return new O({
2059
- ...this._def,
2060
- unknownKeys: "passthrough"
2061
- });
2062
- }
2063
- // const AugmentFactory =
2064
- // <Def extends ZodObjectDef>(def: Def) =>
2065
- // <Augmentation extends ZodRawShape>(
2066
- // augmentation: Augmentation
2067
- // ): ZodObject<
2068
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2069
- // Def["unknownKeys"],
2070
- // Def["catchall"]
2071
- // > => {
2072
- // return new ZodObject({
2073
- // ...def,
2074
- // shape: () => ({
2075
- // ...def.shape(),
2076
- // ...augmentation,
2077
- // }),
2078
- // }) as any;
2079
- // };
2080
- extend(e) {
2081
- return new O({
2082
- ...this._def,
2083
- shape: () => ({
2084
- ...this._def.shape(),
2085
- ...e
2086
- })
2087
- });
2088
- }
2089
- /**
2090
- * Prior to zod@1.0.12 there was a bug in the
2091
- * inferred type of merged objects. Please
2092
- * upgrade if you are experiencing issues.
2093
- */
2094
- merge(e) {
2095
- return new O({
2096
- unknownKeys: e._def.unknownKeys,
2097
- catchall: e._def.catchall,
2098
- shape: () => ({
2099
- ...this._def.shape(),
2100
- ...e._def.shape()
2101
- }),
2102
- typeName: y.ZodObject
2103
- });
2104
- }
2105
- // merge<
2106
- // Incoming extends AnyZodObject,
2107
- // Augmentation extends Incoming["shape"],
2108
- // NewOutput extends {
2109
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2110
- // ? Augmentation[k]["_output"]
2111
- // : k extends keyof Output
2112
- // ? Output[k]
2113
- // : never;
2114
- // },
2115
- // NewInput extends {
2116
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2117
- // ? Augmentation[k]["_input"]
2118
- // : k extends keyof Input
2119
- // ? Input[k]
2120
- // : never;
2121
- // }
2122
- // >(
2123
- // merging: Incoming
2124
- // ): ZodObject<
2125
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2126
- // Incoming["_def"]["unknownKeys"],
2127
- // Incoming["_def"]["catchall"],
2128
- // NewOutput,
2129
- // NewInput
2130
- // > {
2131
- // const merged: any = new ZodObject({
2132
- // unknownKeys: merging._def.unknownKeys,
2133
- // catchall: merging._def.catchall,
2134
- // shape: () =>
2135
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2136
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2137
- // }) as any;
2138
- // return merged;
2139
- // }
2140
- setKey(e, t) {
2141
- return this.augment({ [e]: t });
2142
- }
2143
- // merge<Incoming extends AnyZodObject>(
2144
- // merging: Incoming
2145
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2146
- // ZodObject<
2147
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2148
- // Incoming["_def"]["unknownKeys"],
2149
- // Incoming["_def"]["catchall"]
2150
- // > {
2151
- // // const mergedShape = objectUtil.mergeShapes(
2152
- // // this._def.shape(),
2153
- // // merging._def.shape()
2154
- // // );
2155
- // const merged: any = new ZodObject({
2156
- // unknownKeys: merging._def.unknownKeys,
2157
- // catchall: merging._def.catchall,
2158
- // shape: () =>
2159
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2160
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2161
- // }) as any;
2162
- // return merged;
2163
- // }
2164
- catchall(e) {
2165
- return new O({
2166
- ...this._def,
2167
- catchall: e
2168
- });
2169
- }
2170
- pick(e) {
2171
- const t = {};
2172
- for (const a of x.objectKeys(e))
2173
- e[a] && this.shape[a] && (t[a] = this.shape[a]);
2174
- return new O({
2175
- ...this._def,
2176
- shape: () => t
2177
- });
2178
- }
2179
- omit(e) {
2180
- const t = {};
2181
- for (const a of x.objectKeys(this.shape))
2182
- e[a] || (t[a] = this.shape[a]);
2183
- return new O({
2184
- ...this._def,
2185
- shape: () => t
2186
- });
2187
- }
2188
- /**
2189
- * @deprecated
2190
- */
2191
- deepPartial() {
2192
- return he(this);
2193
- }
2194
- partial(e) {
2195
- const t = {};
2196
- for (const a of x.objectKeys(this.shape)) {
2197
- const s = this.shape[a];
2198
- e && !e[a] ? t[a] = s : t[a] = s.optional();
2199
- }
2200
- return new O({
2201
- ...this._def,
2202
- shape: () => t
2203
- });
2204
- }
2205
- required(e) {
2206
- const t = {};
2207
- for (const a of x.objectKeys(this.shape))
2208
- if (e && !e[a])
2209
- t[a] = this.shape[a];
2210
- else {
2211
- let n = this.shape[a];
2212
- for (; n instanceof se; )
2213
- n = n._def.innerType;
2214
- t[a] = n;
2215
- }
2216
- return new O({
2217
- ...this._def,
2218
- shape: () => t
2219
- });
2220
- }
2221
- keyof() {
2222
- return Pt(x.objectKeys(this.shape));
2223
- }
2224
- }
2225
- O.create = (r, e) => new O({
2226
- shape: () => r,
2227
- unknownKeys: "strip",
2228
- catchall: ne.create(),
2229
- typeName: y.ZodObject,
2230
- ...v(e)
2231
- });
2232
- O.strictCreate = (r, e) => new O({
2233
- shape: () => r,
2234
- unknownKeys: "strict",
2235
- catchall: ne.create(),
2236
- typeName: y.ZodObject,
2237
- ...v(e)
2238
- });
2239
- O.lazycreate = (r, e) => new O({
2240
- shape: r,
2241
- unknownKeys: "strip",
2242
- catchall: ne.create(),
2243
- typeName: y.ZodObject,
2244
- ...v(e)
2245
- });
2246
- class Ie extends _ {
2247
- _parse(e) {
2248
- const { ctx: t } = this._processInputParams(e), a = this._def.options;
2249
- function s(n) {
2250
- for (const o of n)
2251
- if (o.result.status === "valid")
2252
- return o.result;
2253
- for (const o of n)
2254
- if (o.result.status === "dirty")
2255
- return t.common.issues.push(...o.ctx.common.issues), o.result;
2256
- const i = n.map((o) => new X(o.ctx.common.issues));
2257
- return f(t, {
2258
- code: l.invalid_union,
2259
- unionErrors: i
2260
- }), g;
2261
- }
2262
- if (t.common.async)
2263
- return Promise.all(a.map(async (n) => {
2264
- const i = {
2265
- ...t,
2266
- common: {
2267
- ...t.common,
2268
- issues: []
2269
- },
2270
- parent: null
2271
- };
2272
- return {
2273
- result: await n._parseAsync({
2274
- data: t.data,
2275
- path: t.path,
2276
- parent: i
2277
- }),
2278
- ctx: i
2279
- };
2280
- })).then(s);
2281
- {
2282
- let n;
2283
- const i = [];
2284
- for (const d of a) {
2285
- const u = {
2286
- ...t,
2287
- common: {
2288
- ...t.common,
2289
- issues: []
2290
- },
2291
- parent: null
2292
- }, p = d._parseSync({
2293
- data: t.data,
2294
- path: t.path,
2295
- parent: u
2296
- });
2297
- if (p.status === "valid")
2298
- return p;
2299
- p.status === "dirty" && !n && (n = { result: p, ctx: u }), u.common.issues.length && i.push(u.common.issues);
2300
- }
2301
- if (n)
2302
- return t.common.issues.push(...n.ctx.common.issues), n.result;
2303
- const o = i.map((d) => new X(d));
2304
- return f(t, {
2305
- code: l.invalid_union,
2306
- unionErrors: o
2307
- }), g;
2308
- }
2309
- }
2310
- get options() {
2311
- return this._def.options;
2312
- }
2313
- }
2314
- Ie.create = (r, e) => new Ie({
2315
- options: r,
2316
- typeName: y.ZodUnion,
2317
- ...v(e)
2318
- });
2319
- function Ye(r, e) {
2320
- const t = ae(r), a = ae(e);
2321
- if (r === e)
2322
- return { valid: !0, data: r };
2323
- if (t === h.object && a === h.object) {
2324
- const s = x.objectKeys(e), n = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
2325
- for (const o of n) {
2326
- const d = Ye(r[o], e[o]);
2327
- if (!d.valid)
2328
- return { valid: !1 };
2329
- i[o] = d.data;
2330
- }
2331
- return { valid: !0, data: i };
2332
- } else if (t === h.array && a === h.array) {
2333
- if (r.length !== e.length)
2334
- return { valid: !1 };
2335
- const s = [];
2336
- for (let n = 0; n < r.length; n++) {
2337
- const i = r[n], o = e[n], d = Ye(i, o);
2338
- if (!d.valid)
2339
- return { valid: !1 };
2340
- s.push(d.data);
2341
- }
2342
- return { valid: !0, data: s };
2343
- } else return t === h.date && a === h.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
2344
- }
2345
- class Ee extends _ {
2346
- _parse(e) {
2347
- const { status: t, ctx: a } = this._processInputParams(e), s = (n, i) => {
2348
- if (vt(n) || vt(i))
2349
- return g;
2350
- const o = Ye(n.value, i.value);
2351
- return o.valid ? ((_t(n) || _t(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(a, {
2352
- code: l.invalid_intersection_types
2353
- }), g);
2354
- };
2355
- return a.common.async ? Promise.all([
2356
- this._def.left._parseAsync({
2357
- data: a.data,
2358
- path: a.path,
2359
- parent: a
2360
- }),
2361
- this._def.right._parseAsync({
2362
- data: a.data,
2363
- path: a.path,
2364
- parent: a
2365
- })
2366
- ]).then(([n, i]) => s(n, i)) : s(this._def.left._parseSync({
2367
- data: a.data,
2368
- path: a.path,
2369
- parent: a
2370
- }), this._def.right._parseSync({
2371
- data: a.data,
2372
- path: a.path,
2373
- parent: a
2374
- }));
2375
- }
2376
- }
2377
- Ee.create = (r, e, t) => new Ee({
2378
- left: r,
2379
- right: e,
2380
- typeName: y.ZodIntersection,
2381
- ...v(t)
2382
- });
2383
- class ce extends _ {
2384
- _parse(e) {
2385
- const { status: t, ctx: a } = this._processInputParams(e);
2386
- if (a.parsedType !== h.array)
2387
- return f(a, {
2388
- code: l.invalid_type,
2389
- expected: h.array,
2390
- received: a.parsedType
2391
- }), g;
2392
- if (a.data.length < this._def.items.length)
2393
- return f(a, {
2394
- code: l.too_small,
2395
- minimum: this._def.items.length,
2396
- inclusive: !0,
2397
- exact: !1,
2398
- type: "array"
2399
- }), g;
2400
- !this._def.rest && a.data.length > this._def.items.length && (f(a, {
2401
- code: l.too_big,
2402
- maximum: this._def.items.length,
2403
- inclusive: !0,
2404
- exact: !1,
2405
- type: "array"
2406
- }), t.dirty());
2407
- const n = [...a.data].map((i, o) => {
2408
- const d = this._def.items[o] || this._def.rest;
2409
- return d ? d._parse(new D(a, i, a.path, o)) : null;
2410
- }).filter((i) => !!i);
2411
- return a.common.async ? Promise.all(n).then((i) => E.mergeArray(t, i)) : E.mergeArray(t, n);
2412
- }
2413
- get items() {
2414
- return this._def.items;
2415
- }
2416
- rest(e) {
2417
- return new ce({
2418
- ...this._def,
2419
- rest: e
2420
- });
2421
- }
2422
- }
2423
- ce.create = (r, e) => {
2424
- if (!Array.isArray(r))
2425
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2426
- return new ce({
2427
- items: r,
2428
- typeName: y.ZodTuple,
2429
- rest: null,
2430
- ...v(e)
2431
- });
2432
- };
2433
- class je extends _ {
2434
- get keySchema() {
2435
- return this._def.keyType;
2436
- }
2437
- get valueSchema() {
2438
- return this._def.valueType;
2439
- }
2440
- _parse(e) {
2441
- const { status: t, ctx: a } = this._processInputParams(e);
2442
- if (a.parsedType !== h.object)
2443
- return f(a, {
2444
- code: l.invalid_type,
2445
- expected: h.object,
2446
- received: a.parsedType
2447
- }), g;
2448
- const s = [], n = this._def.keyType, i = this._def.valueType;
2449
- for (const o in a.data)
2450
- s.push({
2451
- key: n._parse(new D(a, o, a.path, o)),
2452
- value: i._parse(new D(a, a.data[o], a.path, o)),
2453
- alwaysSet: o in a.data
2454
- });
2455
- return a.common.async ? E.mergeObjectAsync(t, s) : E.mergeObjectSync(t, s);
2456
- }
2457
- get element() {
2458
- return this._def.valueType;
2459
- }
2460
- static create(e, t, a) {
2461
- return t instanceof _ ? new je({
2462
- keyType: e,
2463
- valueType: t,
2464
- typeName: y.ZodRecord,
2465
- ...v(a)
2466
- }) : new je({
2467
- keyType: Q.create(),
2468
- valueType: e,
2469
- typeName: y.ZodRecord,
2470
- ...v(t)
2471
- });
2472
- }
2473
- }
2474
- class Ct extends _ {
2475
- get keySchema() {
2476
- return this._def.keyType;
2477
- }
2478
- get valueSchema() {
2479
- return this._def.valueType;
2480
- }
2481
- _parse(e) {
2482
- const { status: t, ctx: a } = this._processInputParams(e);
2483
- if (a.parsedType !== h.map)
2484
- return f(a, {
2485
- code: l.invalid_type,
2486
- expected: h.map,
2487
- received: a.parsedType
2488
- }), g;
2489
- const s = this._def.keyType, n = this._def.valueType, i = [...a.data.entries()].map(([o, d], u) => ({
2490
- key: s._parse(new D(a, o, a.path, [u, "key"])),
2491
- value: n._parse(new D(a, d, a.path, [u, "value"]))
2492
- }));
2493
- if (a.common.async) {
2494
- const o = /* @__PURE__ */ new Map();
2495
- return Promise.resolve().then(async () => {
2496
- for (const d of i) {
2497
- const u = await d.key, p = await d.value;
2498
- if (u.status === "aborted" || p.status === "aborted")
2499
- return g;
2500
- (u.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(u.value, p.value);
2501
- }
2502
- return { status: t.value, value: o };
2503
- });
2504
- } else {
2505
- const o = /* @__PURE__ */ new Map();
2506
- for (const d of i) {
2507
- const u = d.key, p = d.value;
2508
- if (u.status === "aborted" || p.status === "aborted")
2509
- return g;
2510
- (u.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(u.value, p.value);
2511
- }
2512
- return { status: t.value, value: o };
2513
- }
2514
- }
2515
- }
2516
- Ct.create = (r, e, t) => new Ct({
2517
- valueType: e,
2518
- keyType: r,
2519
- typeName: y.ZodMap,
2520
- ...v(t)
2521
- });
2522
- class Te extends _ {
2523
- _parse(e) {
2524
- const { status: t, ctx: a } = this._processInputParams(e);
2525
- if (a.parsedType !== h.set)
2526
- return f(a, {
2527
- code: l.invalid_type,
2528
- expected: h.set,
2529
- received: a.parsedType
2530
- }), g;
2531
- const s = this._def;
2532
- s.minSize !== null && a.data.size < s.minSize.value && (f(a, {
2533
- code: l.too_small,
2534
- minimum: s.minSize.value,
2535
- type: "set",
2536
- inclusive: !0,
2537
- exact: !1,
2538
- message: s.minSize.message
2539
- }), t.dirty()), s.maxSize !== null && a.data.size > s.maxSize.value && (f(a, {
2540
- code: l.too_big,
2541
- maximum: s.maxSize.value,
2542
- type: "set",
2543
- inclusive: !0,
2544
- exact: !1,
2545
- message: s.maxSize.message
2546
- }), t.dirty());
2547
- const n = this._def.valueType;
2548
- function i(d) {
2549
- const u = /* @__PURE__ */ new Set();
2550
- for (const p of d) {
2551
- if (p.status === "aborted")
2552
- return g;
2553
- p.status === "dirty" && t.dirty(), u.add(p.value);
2554
- }
2555
- return { status: t.value, value: u };
2556
- }
2557
- const o = [...a.data.values()].map((d, u) => n._parse(new D(a, d, a.path, u)));
2558
- return a.common.async ? Promise.all(o).then((d) => i(d)) : i(o);
2559
- }
2560
- min(e, t) {
2561
- return new Te({
2562
- ...this._def,
2563
- minSize: { value: e, message: m.toString(t) }
2564
- });
2565
- }
2566
- max(e, t) {
2567
- return new Te({
2568
- ...this._def,
2569
- maxSize: { value: e, message: m.toString(t) }
2570
- });
2571
- }
2572
- size(e, t) {
2573
- return this.min(e, t).max(e, t);
2574
- }
2575
- nonempty(e) {
2576
- return this.min(1, e);
2577
- }
2578
- }
2579
- Te.create = (r, e) => new Te({
2580
- valueType: r,
2581
- minSize: null,
2582
- maxSize: null,
2583
- typeName: y.ZodSet,
2584
- ...v(e)
2585
- });
2586
- class Qe extends _ {
2587
- get schema() {
2588
- return this._def.getter();
2589
- }
2590
- _parse(e) {
2591
- const { ctx: t } = this._processInputParams(e);
2592
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2593
- }
2594
- }
2595
- Qe.create = (r, e) => new Qe({
2596
- getter: r,
2597
- typeName: y.ZodLazy,
2598
- ...v(e)
2599
- });
2600
- class Xe extends _ {
2601
- _parse(e) {
2602
- if (e.data !== this._def.value) {
2603
- const t = this._getOrReturnCtx(e);
2604
- return f(t, {
2605
- received: t.data,
2606
- code: l.invalid_literal,
2607
- expected: this._def.value
2608
- }), g;
2609
- }
2610
- return { status: "valid", value: e.data };
2611
- }
2612
- get value() {
2613
- return this._def.value;
2614
- }
2615
- }
2616
- Xe.create = (r, e) => new Xe({
2617
- value: r,
2618
- typeName: y.ZodLiteral,
2619
- ...v(e)
2620
- });
2621
- function Pt(r, e) {
2622
- return new ge({
2623
- values: r,
2624
- typeName: y.ZodEnum,
2625
- ...v(e)
2626
- });
2627
- }
2628
- class ge extends _ {
2629
- _parse(e) {
2630
- if (typeof e.data != "string") {
2631
- const t = this._getOrReturnCtx(e), a = this._def.values;
2632
- return f(t, {
2633
- expected: x.joinValues(a),
2634
- received: t.parsedType,
2635
- code: l.invalid_type
2636
- }), g;
2637
- }
2638
- if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2639
- const t = this._getOrReturnCtx(e), a = this._def.values;
2640
- return f(t, {
2641
- received: t.data,
2642
- code: l.invalid_enum_value,
2643
- options: a
2644
- }), g;
2645
- }
2646
- return z(e.data);
2647
- }
2648
- get options() {
2649
- return this._def.values;
2650
- }
2651
- get enum() {
2652
- const e = {};
2653
- for (const t of this._def.values)
2654
- e[t] = t;
2655
- return e;
2656
- }
2657
- get Values() {
2658
- const e = {};
2659
- for (const t of this._def.values)
2660
- e[t] = t;
2661
- return e;
2662
- }
2663
- get Enum() {
2664
- const e = {};
2665
- for (const t of this._def.values)
2666
- e[t] = t;
2667
- return e;
2668
- }
2669
- extract(e, t = this._def) {
2670
- return ge.create(e, {
2671
- ...this._def,
2672
- ...t
2673
- });
2674
- }
2675
- exclude(e, t = this._def) {
2676
- return ge.create(this.options.filter((a) => !e.includes(a)), {
2677
- ...this._def,
2678
- ...t
2679
- });
2680
- }
2681
- }
2682
- ge.create = Pt;
2683
- class Tt extends _ {
2684
- _parse(e) {
2685
- const t = x.getValidEnumValues(this._def.values), a = this._getOrReturnCtx(e);
2686
- if (a.parsedType !== h.string && a.parsedType !== h.number) {
2687
- const s = x.objectValues(t);
2688
- return f(a, {
2689
- expected: x.joinValues(s),
2690
- received: a.parsedType,
2691
- code: l.invalid_type
2692
- }), g;
2693
- }
2694
- if (this._cache || (this._cache = new Set(x.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2695
- const s = x.objectValues(t);
2696
- return f(a, {
2697
- received: a.data,
2698
- code: l.invalid_enum_value,
2699
- options: s
2700
- }), g;
2701
- }
2702
- return z(e.data);
2703
- }
2704
- get enum() {
2705
- return this._def.values;
2706
- }
2707
- }
2708
- Tt.create = (r, e) => new Tt({
2709
- values: r,
2710
- typeName: y.ZodNativeEnum,
2711
- ...v(e)
2712
- });
2713
- class Ze extends _ {
2714
- unwrap() {
2715
- return this._def.type;
2716
- }
2717
- _parse(e) {
2718
- const { ctx: t } = this._processInputParams(e);
2719
- if (t.parsedType !== h.promise && t.common.async === !1)
2720
- return f(t, {
2721
- code: l.invalid_type,
2722
- expected: h.promise,
2723
- received: t.parsedType
2724
- }), g;
2725
- const a = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
2726
- return z(a.then((s) => this._def.type.parseAsync(s, {
2727
- path: t.path,
2728
- errorMap: t.common.contextualErrorMap
2729
- })));
2730
- }
2731
- }
2732
- Ze.create = (r, e) => new Ze({
2733
- type: r,
2734
- typeName: y.ZodPromise,
2735
- ...v(e)
2736
- });
2737
- class ye extends _ {
2738
- innerType() {
2739
- return this._def.schema;
2740
- }
2741
- sourceType() {
2742
- return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2743
- }
2744
- _parse(e) {
2745
- const { status: t, ctx: a } = this._processInputParams(e), s = this._def.effect || null, n = {
2746
- addIssue: (i) => {
2747
- f(a, i), i.fatal ? t.abort() : t.dirty();
2748
- },
2749
- get path() {
2750
- return a.path;
2751
- }
2752
- };
2753
- if (n.addIssue = n.addIssue.bind(n), s.type === "preprocess") {
2754
- const i = s.transform(a.data, n);
2755
- if (a.common.async)
2756
- return Promise.resolve(i).then(async (o) => {
2757
- if (t.value === "aborted")
2758
- return g;
2759
- const d = await this._def.schema._parseAsync({
2760
- data: o,
2761
- path: a.path,
2762
- parent: a
2763
- });
2764
- return d.status === "aborted" ? g : d.status === "dirty" || t.value === "dirty" ? ke(d.value) : d;
2765
- });
2766
- {
2767
- if (t.value === "aborted")
2768
- return g;
2769
- const o = this._def.schema._parseSync({
2770
- data: i,
2771
- path: a.path,
2772
- parent: a
2773
- });
2774
- return o.status === "aborted" ? g : o.status === "dirty" || t.value === "dirty" ? ke(o.value) : o;
2775
- }
2776
- }
2777
- if (s.type === "refinement") {
2778
- const i = (o) => {
2779
- const d = s.refinement(o, n);
2780
- if (a.common.async)
2781
- return Promise.resolve(d);
2782
- if (d instanceof Promise)
2783
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2784
- return o;
2785
- };
2786
- if (a.common.async === !1) {
2787
- const o = this._def.schema._parseSync({
2788
- data: a.data,
2789
- path: a.path,
2790
- parent: a
2791
- });
2792
- return o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2793
- } else
2794
- return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2795
- }
2796
- if (s.type === "transform")
2797
- if (a.common.async === !1) {
2798
- const i = this._def.schema._parseSync({
2799
- data: a.data,
2800
- path: a.path,
2801
- parent: a
2802
- });
2803
- if (!me(i))
2804
- return g;
2805
- const o = s.transform(i.value, n);
2806
- if (o instanceof Promise)
2807
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2808
- return { status: t.value, value: o };
2809
- } else
2810
- return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((i) => me(i) ? Promise.resolve(s.transform(i.value, n)).then((o) => ({
2811
- status: t.value,
2812
- value: o
2813
- })) : g);
2814
- x.assertNever(s);
2815
- }
2816
- }
2817
- ye.create = (r, e, t) => new ye({
2818
- schema: r,
2819
- typeName: y.ZodEffects,
2820
- effect: e,
2821
- ...v(t)
2822
- });
2823
- ye.createWithPreprocess = (r, e, t) => new ye({
2824
- schema: e,
2825
- effect: { type: "preprocess", transform: r },
2826
- typeName: y.ZodEffects,
2827
- ...v(t)
2828
- });
2829
- class se extends _ {
2830
- _parse(e) {
2831
- return this._getType(e) === h.undefined ? z(void 0) : this._def.innerType._parse(e);
2832
- }
2833
- unwrap() {
2834
- return this._def.innerType;
2835
- }
2836
- }
2837
- se.create = (r, e) => new se({
2838
- innerType: r,
2839
- typeName: y.ZodOptional,
2840
- ...v(e)
2841
- });
2842
- class ve extends _ {
2843
- _parse(e) {
2844
- return this._getType(e) === h.null ? z(null) : this._def.innerType._parse(e);
2845
- }
2846
- unwrap() {
2847
- return this._def.innerType;
2848
- }
2849
- }
2850
- ve.create = (r, e) => new ve({
2851
- innerType: r,
2852
- typeName: y.ZodNullable,
2853
- ...v(e)
2854
- });
2855
- class Ke extends _ {
2856
- _parse(e) {
2857
- const { ctx: t } = this._processInputParams(e);
2858
- let a = t.data;
2859
- return t.parsedType === h.undefined && (a = this._def.defaultValue()), this._def.innerType._parse({
2860
- data: a,
2861
- path: t.path,
2862
- parent: t
2863
- });
2864
- }
2865
- removeDefault() {
2866
- return this._def.innerType;
2867
- }
2868
- }
2869
- Ke.create = (r, e) => new Ke({
2870
- innerType: r,
2871
- typeName: y.ZodDefault,
2872
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2873
- ...v(e)
2874
- });
2875
- class et extends _ {
2876
- _parse(e) {
2877
- const { ctx: t } = this._processInputParams(e), a = {
2878
- ...t,
2879
- common: {
2880
- ...t.common,
2881
- issues: []
2882
- }
2883
- }, s = this._def.innerType._parse({
2884
- data: a.data,
2885
- path: a.path,
2886
- parent: {
2887
- ...a
2888
- }
2889
- });
2890
- return Oe(s) ? s.then((n) => ({
2891
- status: "valid",
2892
- value: n.status === "valid" ? n.value : this._def.catchValue({
2893
- get error() {
2894
- return new X(a.common.issues);
2895
- },
2896
- input: a.data
2897
- })
2898
- })) : {
2899
- status: "valid",
2900
- value: s.status === "valid" ? s.value : this._def.catchValue({
2901
- get error() {
2902
- return new X(a.common.issues);
2903
- },
2904
- input: a.data
2905
- })
2906
- };
2907
- }
2908
- removeCatch() {
2909
- return this._def.innerType;
2910
- }
2911
- }
2912
- et.create = (r, e) => new et({
2913
- innerType: r,
2914
- typeName: y.ZodCatch,
2915
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2916
- ...v(e)
2917
- });
2918
- class At extends _ {
2919
- _parse(e) {
2920
- if (this._getType(e) !== h.nan) {
2921
- const a = this._getOrReturnCtx(e);
2922
- return f(a, {
2923
- code: l.invalid_type,
2924
- expected: h.nan,
2925
- received: a.parsedType
2926
- }), g;
2927
- }
2928
- return { status: "valid", value: e.data };
2929
- }
2930
- }
2931
- At.create = (r) => new At({
2932
- typeName: y.ZodNaN,
2933
- ...v(r)
2934
- });
2935
- class Va extends _ {
2936
- _parse(e) {
2937
- const { ctx: t } = this._processInputParams(e), a = t.data;
2938
- return this._def.type._parse({
2939
- data: a,
2940
- path: t.path,
2941
- parent: t
2942
- });
2943
- }
2944
- unwrap() {
2945
- return this._def.type;
2946
- }
2947
- }
2948
- class nt extends _ {
2949
- _parse(e) {
2950
- const { status: t, ctx: a } = this._processInputParams(e);
2951
- if (a.common.async)
2952
- return (async () => {
2953
- const n = await this._def.in._parseAsync({
2954
- data: a.data,
2955
- path: a.path,
2956
- parent: a
2957
- });
2958
- return n.status === "aborted" ? g : n.status === "dirty" ? (t.dirty(), ke(n.value)) : this._def.out._parseAsync({
2959
- data: n.value,
2960
- path: a.path,
2961
- parent: a
2962
- });
2963
- })();
2964
- {
2965
- const s = this._def.in._parseSync({
2966
- data: a.data,
2967
- path: a.path,
2968
- parent: a
2969
- });
2970
- return s.status === "aborted" ? g : s.status === "dirty" ? (t.dirty(), {
2971
- status: "dirty",
2972
- value: s.value
2973
- }) : this._def.out._parseSync({
2974
- data: s.value,
2975
- path: a.path,
2976
- parent: a
2977
- });
2978
- }
2979
- }
2980
- static create(e, t) {
2981
- return new nt({
2982
- in: e,
2983
- out: t,
2984
- typeName: y.ZodPipeline
2985
- });
2986
- }
2987
- }
2988
- class tt extends _ {
2989
- _parse(e) {
2990
- const t = this._def.innerType._parse(e), a = (s) => (me(s) && (s.value = Object.freeze(s.value)), s);
2991
- return Oe(t) ? t.then((s) => a(s)) : a(t);
2992
- }
2993
- unwrap() {
2994
- return this._def.innerType;
2995
- }
2996
- }
2997
- tt.create = (r, e) => new tt({
2998
- innerType: r,
2999
- typeName: y.ZodReadonly,
3000
- ...v(e)
3001
- });
3002
- var y;
3003
- (function(r) {
3004
- 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";
3005
- })(y || (y = {}));
3006
- const T = Q.create, Ae = pe.create, it = Ge.create, Ra = Ce.create, Dt = Je.create, Ut = He.create;
3007
- ne.create;
3008
- const Oa = P.create, Me = O.create, _e = Ie.create;
3009
- Ee.create;
3010
- ce.create;
3011
- const Bt = je.create, Ia = Qe.create, fe = Xe.create;
3012
- ge.create;
3013
- Ze.create;
3014
- se.create;
3015
- ve.create;
3016
- const Ea = g, ja = Me({
3017
- qid: T(),
3018
- size: Ae(),
3019
- fileName: T(),
3020
- extension: T(),
3021
- downloadUrl: _e([T().url(), T().startsWith("/")])
3022
- });
3023
- Me({
3024
- Extention: T(),
3025
- FileMode: T(),
3026
- FileQid: T(),
3027
- IsThumnail: it(),
3028
- MTime: T(),
3029
- Name: T(),
3030
- Parent: T(),
3031
- Size: Ae(),
3032
- URL: T().nullable(),
3033
- fromObjectId: T().nullish(),
3034
- fromObject: T().nullish()
3035
- });
3036
- Me({
3037
- fileQid: T(),
3038
- instanceQid: T(),
3039
- signedUrl: T().url()
3040
- });
3041
- const Za = _e([T(), Ae(), it(), Dt()]), St = Ia(
3042
- () => _e([Za, Oa(St), Bt(St)])
3043
- );
3044
- T().transform((r, e) => {
3045
- try {
3046
- return JSON.parse(r);
3047
- } catch {
3048
- return e.addIssue({ code: "custom", message: "Invalid JSON" }), Ea;
3049
- }
3050
- });
3051
- const $a = _e([
3052
- T().min(1),
3053
- T().datetime(),
3054
- Ae(),
3055
- Ra()
3056
- ]), Ma = $a.transform((r) => typeof r == "object" && typeof r.getMonth == "function" ? r.toLocaleDateString("en-US", {
3057
- year: "numeric",
3058
- month: "long",
3059
- day: "numeric",
3060
- hour: "numeric",
3061
- minute: "numeric"
3062
- }) : r.toString()), La = Ut();
3063
- Me({
3064
- children: La
3065
- });
3066
- const za = T(), Fa = _e([
3067
- T(),
3068
- Ae(),
3069
- it(),
3070
- Dt(),
3071
- ja
3072
- ]);
3073
- Bt(za, Fa);
3074
- Ut();
3075
- _e([
3076
- fe("RICH_TEXT"),
3077
- fe("STRING"),
3078
- fe("FILE"),
3079
- fe("DATETIME"),
3080
- fe("BOOLEAN"),
3081
- fe("NUMBER")
3082
- ]);
3083
- const qt = xr({
3084
- variant: "default",
3085
- size: "base",
3086
- inputs: /* @__PURE__ */ new Map(),
3087
- components: /* @__PURE__ */ new Map(),
3088
- config: [],
3089
- resetValues: {},
3090
- acceptFileType: void 0
3091
- }), Z = () => {
3092
- const r = kr(qt);
3093
- if (!r)
3094
- throw new Error("useTwintagForm must be used within a TwintagFormProvider");
3095
- return r;
3096
- }, rt = (r, e) => {
3097
- const t = { ...r };
3098
- let a;
3099
- if (t.props ? a = { ...t.props } : a = { ...t }, !t.type) return /* @__PURE__ */ Object.create(null);
3100
- const [s, n = void 0] = t.type.split(":");
3101
- a.id = `${s}-${Er()}`;
3102
- const i = e.get(s);
3103
- if (i && (a.comp = i), a.type = s, n && (a.subtype = n), t.props && (t.props.subtype && (a.subtype = t.props.subtype), t.props.label)) {
3104
- const o = Ma.safeParse(t.props.label);
3105
- a.label = o.success ? o.data : void 0;
3106
- }
3107
- return t.children && Array.isArray(t.children) && (a.items = t.children.map(
3108
- (o) => rt(o, e)
3109
- )), a;
3110
- }, Pa = (r, e) => {
3111
- const t = Array.isArray(r) ? [...r] : [r], a = /* @__PURE__ */ new Map();
3112
- for (; t.length > 0; ) {
3113
- const s = t.pop();
3114
- if (s)
3115
- for (const [n, i] of Object.entries(s)) {
3116
- if (Array.isArray(i))
3117
- for (const o of i)
3118
- t.push(o);
3119
- typeof i == "object" && i !== null && t.push(i), n === "subtype" && "bind" in s && typeof s.bind == "string" && a.set(
3120
- s.bind,
3121
- e.get(i)?.defaultValue
3122
- );
3123
- }
3124
- }
3125
- return Object.fromEntries(a);
3126
- }, Da = ({
3127
- variant: r,
3128
- size: e,
3129
- inputs: t,
3130
- components: a,
3131
- config: s,
3132
- acceptFileType: n,
3133
- children: i
3134
- }) => {
3135
- const o = De(() => Array.isArray(s) ? s.map((u) => rt(u, a)) : rt(s, a), [s, a]), d = De(() => Pa(o, t), [o, t]);
3136
- return /* @__PURE__ */ c(
3137
- qt.Provider,
3138
- {
3139
- value: {
3140
- config: o,
3141
- variant: r,
3142
- size: e,
3143
- inputs: t,
3144
- components: a,
3145
- resetValues: d,
3146
- acceptFileType: n
3147
- },
3148
- children: i
3149
- }
3150
- );
3151
- }, Vt = S({
3152
- base: "border",
3153
- variants: {
3154
- variant: {
3155
- default: "rounded-md",
3156
- outline: "rounded-none"
3157
- }
3158
- },
3159
- defaultVariants: {
3160
- variant: "default"
3161
- }
3162
- }), Wt = ({
3163
- type: r,
3164
- defaultValue: e,
3165
- children: t
3166
- }) => {
3167
- const { variant: a } = Z();
3168
- return r === "single" ? /* @__PURE__ */ c(gt, { type: "single", defaultValue: e, collapsible: !0, children: /* @__PURE__ */ c("div", { className: Vt({ variant: a }), children: t }) }) : /* @__PURE__ */ c(gt, { type: "multiple", children: /* @__PURE__ */ c("div", { className: Vt({ variant: a }), children: t }) });
3169
- };
3170
- Wt.displayName = "AccordionRoot";
3171
- const Ua = S({
3172
- slots: {
3173
- item: "px-5 last:border-none",
3174
- trigger: "flex flex-1 items-center gap-2.5 font-tf-font",
3175
- icon: "shrink-0",
3176
- content: "space-y-3"
3177
- },
3178
- variants: {
3179
- variant: {
3180
- default: {
3181
- trigger: "font-medium"
3182
- },
3183
- outline: {
3184
- trigger: ""
3185
- }
3186
- },
3187
- size: {
3188
- sm: {
3189
- item: "text-sm",
3190
- icon: "h-4 w-4"
3191
- },
3192
- base: {
3193
- item: "text-base",
3194
- icon: "h-5 w-5"
3195
- }
3196
- }
3197
- },
3198
- defaultVariants: {
3199
- variant: "default",
3200
- size: "base"
3201
- }
3202
- }), Gt = ({
3203
- label: r = "",
3204
- value: e = "",
3205
- icon: t,
3206
- children: a,
3207
- ...s
3208
- }) => {
3209
- const { variant: n, size: i } = Z(), {
3210
- item: o,
3211
- trigger: d,
3212
- icon: u,
3213
- content: p
3214
- } = Ua({ size: i, variant: n });
3215
- return /* @__PURE__ */ b(
3216
- $t,
3217
- {
3218
- value: e || Kr(r),
3219
- className: o(),
3220
- ...s,
3221
- children: [
3222
- /* @__PURE__ */ c(Mt, { className: "text-category", children: /* @__PURE__ */ b("span", { className: d(), children: [
3223
- t ? /* @__PURE__ */ c(aa, { name: t, className: u() }) : null,
3224
- r
3225
- ] }) }),
3226
- /* @__PURE__ */ c(Lt, { className: p(), children: a })
3227
- ]
3228
- }
3229
- );
3230
- };
3231
- Gt.displayName = "AccordionItem";
3232
- const Ba = ({ subtype: r = "single", ...e }) => r === "item" ? /* @__PURE__ */ c(
3233
- Gt,
3234
- {
3235
- ...e
3236
- }
3237
- ) : /* @__PURE__ */ c(Wt, { type: r, ...e }), qa = S({
3238
- slots: {
3239
- container: "relative w-full space-y-3",
3240
- heading: "font-tf-font text-tf-category",
3241
- content: "grid gap-3"
3242
- },
3243
- variants: {
3244
- variant: {
3245
- default: {
3246
- heading: "font-medium"
3247
- },
3248
- outline: {
3249
- heading: "font-normal"
3250
- }
3251
- },
3252
- size: {
3253
- sm: {
3254
- heading: "text-sm"
3255
- },
3256
- base: {
3257
- heading: "text-base"
3258
- }
3259
- }
3260
- },
3261
- defaultVariants: {
3262
- variant: "default",
3263
- size: "base"
3264
- }
3265
- }), Jt = ({ label: r, children: e }) => {
3266
- const { variant: t, size: a } = Z(), { container: s, heading: n, content: i } = qa({ size: a, variant: t });
3267
- return /* @__PURE__ */ b("section", { className: s(), children: [
3268
- r ? /* @__PURE__ */ c("h3", { className: n(), children: r }) : null,
3269
- /* @__PURE__ */ c("div", { className: i(), children: e })
3270
- ] });
3271
- };
3272
- Jt.displayName = "Category";
3273
- const Wa = S({
3274
- slots: {
3275
- root: [
3276
- "peer h-4 w-4 shrink-0 rounded-tf-sm border border-tf-accent shadow",
3277
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-tf-ring focus-visible:ring-offset-1",
3278
- "disabled:cursor-not-allowed disabled:opacity-50",
3279
- "data-[state=checked]:bg-tf-accent data-[state=checked]:text-tf-accent-foreground"
3280
- ],
3281
- indicator: "flex items-center justify-center text-current",
3282
- icon: "h-4 w-4"
3283
- }
3284
- }), Ht = A.forwardRef(({ className: r, ...e }, t) => {
3285
- const { root: a, indicator: s, icon: n } = Wa();
3286
- return /* @__PURE__ */ c(
3287
- Ue.Root,
3288
- {
3289
- ref: t,
3290
- className: a({
3291
- className: r
3292
- }),
3293
- ...e,
3294
- children: /* @__PURE__ */ c(Ue.Indicator, { className: s(), children: /* @__PURE__ */ c(Mr, { className: n() }) })
3295
- }
3296
- );
3297
- });
3298
- Ht.displayName = Ue.Root.displayName;
3299
- const Ga = S({
3300
- base: [
3301
- "text-tf-label",
3302
- "peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
3303
- ],
3304
- variants: {
3305
- size: {
3306
- sm: "text-sm leading-none",
3307
- base: "text-base leading-none"
3308
- }
3309
- },
3310
- defaultVariants: {
3311
- size: "base"
3312
- }
3313
- }), ot = A.forwardRef(({ size: r, className: e, ...t }, a) => /* @__PURE__ */ c(
3314
- Et.Root,
3315
- {
3316
- ref: a,
3317
- className: Ga({
3318
- size: r,
3319
- className: e
3320
- }),
3321
- ...t
3322
- }
3323
- ));
3324
- ot.displayName = Et.Root.displayName;
3325
- const Ja = Zr, Yt = A.createContext(
3326
- {}
3327
- ), ie = ({
3328
- ...r
3329
- }) => /* @__PURE__ */ c(Yt.Provider, { value: { name: r.name }, children: /* @__PURE__ */ c(jr, { ...r }) }), Le = () => {
3330
- const r = A.useContext(Yt), e = A.useContext(Qt), { getFieldState: t, formState: a } = K(), s = t(r.name, a);
3331
- if (!r)
3332
- throw new Error("useFormField should be used within <FormField>");
3333
- const { id: n } = e;
3334
- return {
3335
- id: n,
3336
- name: r.name,
3337
- formItemId: `${n}-form-item`,
3338
- formDescriptionId: `${n}-form-item-description`,
3339
- formMessageId: `${n}-form-item-message`,
3340
- ...s
3341
- };
3342
- }, Qt = A.createContext(
3343
- {}
3344
- ), Ha = S({
3345
- base: "",
3346
- variants: {
3347
- variant: {
3348
- default: "space-y-2",
3349
- outline: "space-y-1"
3350
- }
3351
- },
3352
- defaultVariants: {
3353
- variant: "default"
3354
- }
3355
- }), U = A.forwardRef(({ variant: r, className: e, ...t }, a) => {
3356
- const s = A.useId();
3357
- return /* @__PURE__ */ c(Qt.Provider, { value: { id: s }, children: /* @__PURE__ */ c(
3358
- "div",
3359
- {
3360
- ref: a,
3361
- className: Ha({ variant: r, className: e }),
3362
- ...t
3363
- }
3364
- ) });
3365
- });
3366
- U.displayName = "FormItem";
3367
- const Ya = S({
3368
- base: "",
3369
- variants: {
3370
- error: {
3371
- true: "text-tf-destructive"
3372
- }
3373
- }
3374
- }), B = A.forwardRef(({ size: r, className: e, ...t }, a) => {
3375
- const { error: s, formItemId: n } = Le();
3376
- return /* @__PURE__ */ c(
3377
- ot,
3378
- {
3379
- ref: a,
3380
- size: r,
3381
- className: Ya({
3382
- error: !!s,
3383
- className: e
3384
- }),
3385
- htmlFor: n,
3386
- ...t
3387
- }
3388
- );
3389
- });
3390
- B.displayName = "FormLabel";
3391
- const q = A.forwardRef(({ ...r }, e) => {
3392
- const { error: t, formItemId: a, formDescriptionId: s, formMessageId: n } = Le();
3393
- return /* @__PURE__ */ c(
3394
- It,
3395
- {
3396
- ref: e,
3397
- id: a,
3398
- "aria-describedby": t ? `${s} ${n}` : `${s}`,
3399
- "aria-invalid": !!t,
3400
- ...r
3401
- }
3402
- );
3403
- });
3404
- q.displayName = "FormControl";
3405
- const Qa = S({
3406
- base: "text-tf-muted-foreground",
3407
- variants: {
3408
- size: {
3409
- sm: "text-[0.8rem] leading-none",
3410
- base: "text-[0.9rem] leading-none"
3411
- }
3412
- },
3413
- defaultVariants: {
3414
- size: "base"
3415
- }
3416
- }), ee = A.forwardRef(({ size: r, className: e, ...t }, a) => {
3417
- const { formDescriptionId: s } = Le();
3418
- return /* @__PURE__ */ c(
3419
- "p",
3420
- {
3421
- ref: a,
3422
- id: s,
3423
- className: Qa({ size: r, className: e }),
3424
- ...t
3425
- }
3426
- );
3427
- });
3428
- ee.displayName = "FormDescription";
3429
- const Xa = S({
3430
- base: "font-medium text-tf-destructive",
3431
- variants: {
3432
- size: {
3433
- sm: "text-[0.8rem]",
3434
- base: "text-[0.9rem]"
3435
- }
3436
- },
3437
- defaultVariants: {
3438
- size: "base"
3439
- }
3440
- }), te = A.forwardRef(({ size: r, className: e, children: t, ...a }, s) => {
3441
- const { error: n, formMessageId: i } = Le(), o = n ? String(n?.message) : t;
3442
- return o ? /* @__PURE__ */ c(
3443
- "p",
3444
- {
3445
- ref: s,
3446
- id: i,
3447
- className: Xa({ size: r, className: e }),
3448
- ...a,
3449
- children: o
3450
- }
3451
- ) : null;
3452
- });
3453
- te.displayName = "FormMessage";
3454
- const Xt = !1, Ka = ({ label: r, bind: e, options: t }) => {
3455
- const { control: a } = K(), { variant: s, size: n } = Z(), i = t?.optionalField;
3456
- return /* @__PURE__ */ c(
3457
- ie,
3458
- {
3459
- defaultValue: Xt,
3460
- control: a,
3461
- name: e,
3462
- rules: {
3463
- required: i ? !1 : t?.error ?? !0
3464
- },
3465
- render: ({ field: o }) => /* @__PURE__ */ c(U, { variant: s, className: "pt-1.5", children: /* @__PURE__ */ b("div", { className: "flex space-x-2", children: [
3466
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
3467
- Ht,
3468
- {
3469
- ...o,
3470
- checked: o.value,
3471
- onCheckedChange: (d) => {
3472
- o.onChange(d);
3473
- }
3474
- }
3475
- ) }),
3476
- /* @__PURE__ */ b("div", { className: "grid gap-1", children: [
3477
- /* @__PURE__ */ b(B, { size: n, children: [
3478
- r,
3479
- i ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
3480
- ] }),
3481
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null,
3482
- /* @__PURE__ */ c(te, { size: n })
3483
- ] })
3484
- ] }) })
3485
- }
3486
- );
3487
- }, at = S({
3488
- base: [
3489
- "inline-flex items-center justify-center whitespace-nowrap rounded-tf-md font-medium transition-colors",
3490
- "ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-tf-ring focus-visible:ring-offset-2",
3491
- "disabled:pointer-events-none disabled:opacity-50"
3492
- ],
3493
- variants: {
3494
- variant: {
3495
- default: "bg-tf-primary-foreground text-tf-primary shadow hover:bg-tf-primary-foreground/90",
3496
- outline: "border border-tf-input bg-tf-background hover:bg-tf-accent hover:text-tf-accent-foreground",
3497
- ghost: "hover:bg-tf-accent hover:text-tf-accent-foreground"
3498
- },
3499
- size: {
3500
- sm: "h-9 rounded-tf-md px-3 text-sm",
3501
- base: "h-10 px-3 py-2 text-base"
3502
- }
3503
- },
3504
- defaultVariants: {
3505
- variant: "default",
3506
- size: "base"
3507
- }
3508
- }), ct = A.forwardRef(
3509
- ({ className: r, variant: e, size: t, asChild: a = !1, ...s }, n) => /* @__PURE__ */ c(
3510
- a ? It : "button",
3511
- {
3512
- className: at({ variant: e, size: t, className: r }),
3513
- ref: n,
3514
- ...s
3515
- }
3516
- )
3517
- );
3518
- ct.displayName = "Button";
3519
- const es = S({
3520
- slots: {
3521
- picker: "p-3",
3522
- months: "flex flex-col space-y-4 sm:flex-row sm:space-x-4 sm:space-y-0",
3523
- month: "space-y-4",
3524
- caption: "relative flex items-center justify-center pt-1",
3525
- caption_dropdowns: "",
3526
- caption_label: "font-semibold",
3527
- nav: "flex items-center space-x-1",
3528
- nav_button: at({
3529
- variant: "outline",
3530
- className: "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
3531
- }),
3532
- nav_button_previous: "absolute left-1",
3533
- nav_button_next: "absolute right-1",
3534
- table: "w-full border-collapse space-y-1",
3535
- head_row: "flex",
3536
- head_cell: "w-9 rounded-tf-md text-[0.8rem] font-normal text-tf-muted-foreground",
3537
- row: "mt-2 flex w-full",
3538
- cell: "relative h-9 w-9 p-0 text-center focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-transparent first:[&:has([aria-selected])]:rounded-l-tf-md last:[&:has([aria-selected])]:rounded-r-tf-md [&:has([aria-selected].day-outside)]:bg-tf-muted/50 [&:has([aria-selected].day-range-end)]:rounded-r-tf-md",
3539
- day: at({
3540
- variant: "ghost",
3541
- className: "h-9 w-9 p-0 font-normal aria-selected:opacity-100"
3542
- }),
3543
- day_range_end: "day-range-end",
3544
- day_selected: "bg-tf-accent text-tf-accent-foreground hover:bg-tf-accent hover:text-tf-accent-foreground focus:bg-tf-accent focus:text-tf-accent-foreground",
3545
- day_today: "bg-tf-muted text-tf-muted-foreground",
3546
- day_outside: "day-outside text-tf-muted-foreground opacity-50 aria-selected:bg-tf-accent/30 aria-selected:text-tf-accent-foreground",
3547
- day_disabled: "text-tf-muted-foreground opacity-50",
3548
- day_range_middle: "aria-selected:bg-tf-accent aria-selected:text-tf-accent-foreground",
3549
- day_hidden: "invisible"
3550
- },
3551
- variants: {
3552
- variant: {
3553
- dropdown: {
3554
- caption_label: "hidden",
3555
- caption_dropdowns: [
3556
- "flex w-4/6 justify-center gap-1",
3557
- "[&>*>span]:hidden [&>*]:flex-1 [&>.rdp-vhidden]:hidden ",
3558
- "[&>*>select]:h-7 [&>*>select]:min-w-[3.6rem] [&>*>select]:rounded-tf-md [&>*>select]:border [&>*>select]:border-tf-input [&>*>select]:bg-tf-background [&>*>select]:px-1",
3559
- "[&>*>select]:ring-offset-tf-background [&>*>select]:focus-visible:outline-none [&>*>select]:focus-visible:ring-1 [&>*>select]:focus-visible:ring-tf-ring"
3560
- ]
3561
- }
3562
- },
3563
- size: {
3564
- sm: {
3565
- caption_label: "text-sm",
3566
- caption_dropdowns: "[&>*>select]:text-sm",
3567
- cell: "text-sm"
3568
- },
3569
- base: {
3570
- caption_label: "text-base",
3571
- caption_dropdowns: "[&>*>select]:text-base",
3572
- cell: "text-base"
3573
- }
3574
- }
3575
- },
3576
- defaultVariants: {
3577
- size: "base"
3578
- }
3579
- });
3580
- function Kt({
3581
- size: r,
3582
- className: e,
3583
- classNames: t,
3584
- showOutsideDays: a = !0,
3585
- ...s
3586
- }) {
3587
- const n = es({
3588
- size: r,
3589
- variant: s.captionLayout === "dropdown-buttons" ? "dropdown" : void 0
3590
- });
3591
- return /* @__PURE__ */ c(
3592
- zr,
3593
- {
3594
- showOutsideDays: a,
3595
- className: n.picker({ className: e }),
3596
- classNames: {
3597
- months: n.months(),
3598
- month: n.month(),
3599
- caption: n.caption(),
3600
- caption_label: n.caption_label(),
3601
- caption_dropdowns: n.caption_dropdowns(),
3602
- nav: n.nav(),
3603
- nav_button: n.nav_button(),
3604
- nav_button_previous: n.nav_button_previous(),
3605
- nav_button_next: n.nav_button_next(),
3606
- table: n.table(),
3607
- head_row: n.head_row(),
3608
- head_cell: n.head_cell(),
3609
- row: n.row(),
3610
- cell: n.cell(),
3611
- day: n.day(),
3612
- day_range_end: n.day_range_end(),
3613
- day_selected: n.day_selected(),
3614
- day_today: n.day_today(),
3615
- day_outside: n.day_outside(),
3616
- day_disabled: n.day_disabled(),
3617
- day_range_middle: n.day_range_middle(),
3618
- day_hidden: n.day_hidden(),
3619
- ...t
3620
- },
3621
- components: {
3622
- IconLeft: () => /* @__PURE__ */ c(Vr, { className: "h-4 w-4" }),
3623
- IconRight: () => /* @__PURE__ */ c(Sr, { className: "h-4 w-4" })
3624
- },
3625
- ...s
3626
- }
3627
- );
3628
- }
3629
- Kt.displayName = "Calendar";
3630
- const ts = $e.Root, rs = $e.Trigger, as = S({
3631
- base: "z-50 w-72 rounded-tf-md border bg-tf-background p-4 text-tf-foreground shadow-md outline-none"
3632
- }), er = A.forwardRef(({ className: r, align: e = "center", sideOffset: t = 2, ...a }, s) => /* @__PURE__ */ c(
3633
- $e.Content,
3634
- {
3635
- ref: s,
3636
- align: e,
3637
- sideOffset: t,
3638
- className: as({
3639
- className: r
3640
- }),
3641
- ...a
3642
- }
3643
- ));
3644
- er.displayName = $e.Content.displayName;
3645
- const ss = S({
3646
- slots: {
3647
- button: "w-full justify-start text-left font-normal",
3648
- icon: "ml-auto text-tf-muted-foreground opacity-70"
3649
- },
3650
- variants: {
3651
- variant: {
3652
- default: {
3653
- button: "px-3"
3654
- },
3655
- outline: {
3656
- button: "rounded-none border-x-transparent border-t-transparent px-1 transition-none hover:bg-white hover:text-tf-muted-foreground"
3657
- }
3658
- },
3659
- withValue: {
3660
- true: {
3661
- button: "text-tf-muted-foreground"
3662
- },
3663
- false: {
3664
- button: ""
3665
- }
3666
- },
3667
- size: {
3668
- sm: {
3669
- button: "text-sm",
3670
- icon: "h-4 w-4"
3671
- },
3672
- base: {
3673
- button: "text-base",
3674
- icon: "h-5 w-5"
3675
- }
3676
- }
3677
- },
3678
- defaultVariants: {
3679
- variant: "default",
3680
- size: "base"
3681
- }
3682
- }), tr = null, ns = ({
3683
- label: r,
3684
- bind: e,
3685
- options: t
3686
- }) => {
3687
- const { variant: a, size: s } = Z(), { control: n } = K(), { button: i, icon: o } = ss({ variant: a, size: s }), d = t?.optionalField;
3688
- return /* @__PURE__ */ c(
3689
- ie,
3690
- {
3691
- defaultValue: tr,
3692
- control: n,
3693
- name: e,
3694
- rules: {
3695
- required: d ? !1 : t?.error ?? !0
3696
- },
3697
- render: ({ field: u }) => /* @__PURE__ */ b(
3698
- U,
3699
- {
3700
- variant: a,
3701
- className: "flex flex-col [&>div[data-radix-popper-content-wrapper]]:!z-50",
3702
- children: [
3703
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
3704
- /* @__PURE__ */ b(B, { size: s, children: [
3705
- r,
3706
- d ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
3707
- ] }),
3708
- t?.description ? /* @__PURE__ */ c(ee, { size: s, children: t.description }) : null
3709
- ] }),
3710
- /* @__PURE__ */ b(ts, { children: [
3711
- /* @__PURE__ */ c(rs, { asChild: !0, children: /* @__PURE__ */ c(q, { children: /* @__PURE__ */ b(
3712
- ct,
3713
- {
3714
- variant: "outline",
3715
- size: s,
3716
- className: i({
3717
- withValue: !u.value,
3718
- className: "h-10 gap-2"
3719
- }),
3720
- children: [
3721
- u.value ? Lr(u.value, "PPP") : /* @__PURE__ */ c("span", { children: t?.placeholder ?? "Select a date" }),
3722
- /* @__PURE__ */ c(Rr, { className: o() })
3723
- ]
3724
- }
3725
- ) }) }),
3726
- /* @__PURE__ */ c(er, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ c(
3727
- Kt,
3728
- {
3729
- fromYear: 1970,
3730
- toYear: 2050,
3731
- captionLayout: "dropdown-buttons",
3732
- mode: "single",
3733
- size: s,
3734
- selected: Number.isNaN(new Date(u.value).getTime()) ? void 0 : new Date(u.value),
3735
- onSelect: u.onChange,
3736
- initialFocus: !0
3737
- }
3738
- ) })
3739
- ] }),
3740
- /* @__PURE__ */ c(te, { size: s, className: "pt-1" })
3741
- ]
3742
- }
3743
- )
3744
- }
3745
- );
3746
- }, is = S({
3747
- slots: {
3748
- root: "relative",
3749
- input: [
3750
- "flex h-10 w-full border-tf-input bg-tf-background py-2 text-tf-primary-foreground placeholder:text-tf-muted-foreground focus-visible:outline-none",
3751
- "file:border-0 file:bg-transparent file:px-0 file:font-medium file:text-tf-primary-foreground",
3752
- "disabled:cursor-not-allowed disabled:opacity-50"
3753
- ]
3754
- },
3755
- variants: {
3756
- variant: {
3757
- default: {
3758
- input: "rounded-tf-md border px-3 ring-offset-tf-background focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2"
3759
- },
3760
- outline: {
3761
- root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-tf-ring',
3762
- input: "border-b px-1"
3763
- }
3764
- },
3765
- size: {
3766
- sm: {
3767
- input: "text-sm file:text-sm"
3768
- },
3769
- base: {
3770
- input: "text-base file:text-base"
3771
- }
3772
- }
3773
- },
3774
- defaultVariants: {
3775
- variant: "default",
3776
- size: "base"
3777
- }
3778
- }), lt = A.forwardRef(
3779
- ({ variant: r, size: e, className: t, type: a, ...s }, n) => {
3780
- const { root: i, input: o } = is({ variant: r, size: e });
3781
- return /* @__PURE__ */ c("div", { className: i(), children: /* @__PURE__ */ c(
3782
- "input",
3783
- {
3784
- type: a,
3785
- className: o({
3786
- className: t
3787
- }),
3788
- ref: n,
3789
- ...s
3790
- }
3791
- ) });
3792
- }
3793
- );
3794
- lt.displayName = "Input";
3795
- const rr = "", os = ({ label: r, bind: e, options: t }) => {
3796
- const { control: a } = K(), { variant: s, size: n, acceptFileType: i } = Z(), o = t?.optionalField;
3797
- return /* @__PURE__ */ c(
3798
- ie,
3799
- {
3800
- defaultValue: rr,
3801
- control: a,
3802
- name: e,
3803
- rules: {
3804
- required: o ? !1 : t?.error ?? !0
3805
- },
3806
- render: ({ field: d, formState: u }) => /* @__PURE__ */ b(U, { variant: s, children: [
3807
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
3808
- /* @__PURE__ */ b(B, { htmlFor: e, size: n, children: [
3809
- r,
3810
- o ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
3811
- ] }),
3812
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null
3813
- ] }),
3814
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
3815
- lt,
3816
- {
3817
- ref: (p) => {
3818
- d.ref(p), p && u.isSubmitSuccessful && (p.value = "");
3819
- },
3820
- id: e,
3821
- type: "file",
3822
- accept: t?.accept ?? i,
3823
- name: d.name,
3824
- size: n,
3825
- variant: s,
3826
- multiple: !0,
3827
- onBlur: d.onBlur,
3828
- onChange: (p) => {
3829
- p.target.files && d.onChange(p.target.files);
3830
- }
3831
- }
3832
- ) }),
3833
- /* @__PURE__ */ c(te, { size: n, className: "pt-1.5" })
3834
- ] })
3835
- }
3836
- );
3837
- }, ar = "", cs = ({ label: r, bind: e, options: t }) => {
3838
- const { control: a } = K(), { variant: s, size: n } = Z(), i = t?.optionalField;
3839
- return /* @__PURE__ */ c(
3840
- ie,
3841
- {
3842
- defaultValue: ar,
3843
- control: a,
3844
- name: e,
3845
- rules: {
3846
- required: i ? !1 : t?.error ?? !0
3847
- },
3848
- render: ({ field: o }) => /* @__PURE__ */ b(U, { variant: s, children: [
3849
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
3850
- /* @__PURE__ */ b(B, { size: n, children: [
3851
- r,
3852
- i ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
3853
- ] }),
3854
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null
3855
- ] }),
3856
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
3857
- lt,
3858
- {
3859
- type: "text",
3860
- size: n,
3861
- variant: s,
3862
- placeholder: t?.placeholder ?? "Write here...",
3863
- ...o
3864
- }
3865
- ) }),
3866
- /* @__PURE__ */ c(te, { size: n, className: "pt-1" })
3867
- ] })
3868
- }
3869
- );
3870
- }, ls = S({
3871
- base: "grid gap-2"
3872
- }), sr = A.forwardRef(({ className: r, ...e }, t) => /* @__PURE__ */ c(
3873
- we.Root,
3874
- {
3875
- className: ls({ className: r }),
3876
- ...e,
3877
- ref: t
3878
- }
3879
- ));
3880
- sr.displayName = we.Root.displayName;
3881
- const ds = S({
3882
- slots: {
3883
- item: [
3884
- "aspect-square h-4 w-4 items-center rounded-full border border-tf-accent text-tf-accent ring-offset-tf-background",
3885
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2",
3886
- "disabled:cursor-not-allowed disabled:opacity-50"
3887
- ],
3888
- indicator: "relative block h-full w-full",
3889
- icon: "absolute left-1/2 top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 transform fill-current text-current"
3890
- }
3891
- }), nr = A.forwardRef(({ className: r, ...e }, t) => {
3892
- const { item: a, indicator: s, icon: n } = ds();
3893
- return /* @__PURE__ */ c(
3894
- we.Item,
3895
- {
3896
- ref: t,
3897
- className: a({
3898
- className: r
3899
- }),
3900
- ...e,
3901
- children: /* @__PURE__ */ c(we.Indicator, { className: s(), children: /* @__PURE__ */ c(Or, { className: n() }) })
3902
- }
3903
- );
3904
- });
3905
- nr.displayName = we.Item.displayName;
3906
- const ir = "", us = ({ label: r, bind: e, items: t, options: a }) => {
3907
- const { control: s } = K(), { size: n } = Z(), i = a?.optionalField;
3908
- return /* @__PURE__ */ c(
3909
- ie,
3910
- {
3911
- defaultValue: ir,
3912
- control: s,
3913
- name: e,
3914
- rules: {
3915
- required: i ? !1 : a?.error ?? !0
3916
- },
3917
- render: ({ field: o }) => /* @__PURE__ */ b(U, { className: "space-y-3", children: [
3918
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
3919
- /* @__PURE__ */ b(B, { size: n, children: [
3920
- r,
3921
- i ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
3922
- ] }),
3923
- a?.description ? /* @__PURE__ */ c(ee, { size: n, children: a.description }) : null
3924
- ] }),
3925
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
3926
- sr,
3927
- {
3928
- ref: o.ref,
3929
- value: o.value,
3930
- onValueChange: o.onChange,
3931
- children: t?.map((d) => d.type === "item" ? /* @__PURE__ */ b(
3932
- U,
3933
- {
3934
- className: "flex items-center space-x-2 space-y-0",
3935
- children: [
3936
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(nr, { value: d.bind }) }),
3937
- /* @__PURE__ */ c(B, { size: n, className: "font-normal", children: d.label })
3938
- ]
3939
- },
3940
- d.id
3941
- ) : null)
3942
- }
3943
- ) }),
3944
- /* @__PURE__ */ c(te, { size: n })
3945
- ] })
3946
- }
3947
- );
3948
- }, fs = ({ label: r }) => {
3949
- const { size: e } = Z();
3950
- return /* @__PURE__ */ c("div", { className: "flex w-full justify-center pt-2", children: /* @__PURE__ */ c(ct, { size: e, children: r }) });
3951
- }, hs = S({
3952
- slots: {
3953
- root: "relative",
3954
- textarea: [
3955
- "flex min-h-[60px] w-full border-tf-input bg-tf-background py-2 text-tf-primary-foreground shadow-sm placeholder:text-tf-muted-foreground focus-visible:outline-none",
3956
- "disabled:cursor-not-allowed disabled:opacity-50"
3957
- ]
3958
- },
3959
- variants: {
3960
- variant: {
3961
- default: {
3962
- textarea: "rounded-tf-md border px-3 ring-offset-tf-background focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2"
3963
- },
3964
- outline: {
3965
- root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-tf-ring',
3966
- textarea: "border-b px-1"
3967
- }
3968
- },
3969
- size: {
3970
- sm: {
3971
- textarea: "text-sm"
3972
- },
3973
- base: {
3974
- textarea: "text-base"
3975
- }
3976
- }
3977
- },
3978
- defaultVariants: {
3979
- variant: "default",
3980
- size: "base"
3981
- }
3982
- }), or = A.forwardRef(
3983
- ({ variant: r, size: e, className: t, ...a }, s) => {
3984
- const { root: n, textarea: i } = hs({ size: e, variant: r });
3985
- return /* @__PURE__ */ c("div", { className: n(), children: /* @__PURE__ */ c(
3986
- "textarea",
3987
- {
3988
- className: i({
3989
- className: t
3990
- }),
3991
- ref: s,
3992
- ...a
3993
- }
3994
- ) });
3995
- }
3996
- );
3997
- or.displayName = "Textarea";
3998
- const cr = "", ms = ({
3999
- label: r,
4000
- bind: e,
4001
- options: t
4002
- }) => {
4003
- const { control: a } = K(), { variant: s, size: n } = Z(), i = t?.optionalField;
4004
- return /* @__PURE__ */ c(
4005
- ie,
4006
- {
4007
- defaultValue: cr,
4008
- control: a,
4009
- name: e,
4010
- rules: {
4011
- required: i ? !1 : t?.error ?? !0
4012
- },
4013
- render: ({ field: o }) => /* @__PURE__ */ b(U, { variant: s, children: [
4014
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
4015
- /* @__PURE__ */ b(B, { size: n, children: [
4016
- r,
4017
- i ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
4018
- ] }),
4019
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null
4020
- ] }),
4021
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
4022
- or,
4023
- {
4024
- ...o,
4025
- size: n,
4026
- variant: s,
4027
- placeholder: t?.placeholder ?? "Write here..."
4028
- }
4029
- ) }),
4030
- /* @__PURE__ */ c(te, { size: n, className: "pt-1" })
4031
- ] })
4032
- }
4033
- );
4034
- }, ps = S({
4035
- slots: {
4036
- root: [
4037
- "peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors",
4038
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2 focus-visible:ring-offset-tf-background",
4039
- "disabled:cursor-not-allowed disabled:opacity-50",
4040
- "data-[state=checked]:bg-tf-accent data-[state=unchecked]:bg-tf-muted"
4041
- ],
4042
- thumb: [
4043
- "pointer-events-none block h-4 w-4 rounded-full bg-tf-background shadow-lg ring-0 transition-transform",
4044
- "data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4045
- ]
4046
- }
4047
- }), lr = A.forwardRef(({ className: r, ...e }, t) => {
4048
- const { root: a, thumb: s } = ps();
4049
- return /* @__PURE__ */ c(
4050
- Be.Root,
4051
- {
4052
- className: a({
4053
- className: r
4054
- }),
4055
- ...e,
4056
- ref: t,
4057
- children: /* @__PURE__ */ c(Be.Thumb, { className: s() })
4058
- }
4059
- );
4060
- });
4061
- lr.displayName = Be.Root.displayName;
4062
- const dr = !1, gs = ({ label: r, bind: e, options: t }) => {
4063
- const { control: a } = K(), { variant: s, size: n } = Z(), i = t?.optionalField;
4064
- return /* @__PURE__ */ c(
4065
- ie,
4066
- {
4067
- defaultValue: dr,
4068
- control: a,
4069
- name: e,
4070
- rules: {
4071
- required: i ? !1 : t?.error ?? !0
4072
- },
4073
- render: ({ field: o }) => /* @__PURE__ */ b(U, { variant: s, children: [
4074
- /* @__PURE__ */ b("div", { className: "flex flex-row items-center justify-between", children: [
4075
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
4076
- /* @__PURE__ */ b(B, { htmlFor: e, size: n, children: [
4077
- r,
4078
- i ? null : /* @__PURE__ */ c("span", { className: "ml-0.5 inline-block", children: /* @__PURE__ */ c(le, { className: "h-3 w-3 text-tf-destructive" }) })
4079
- ] }),
4080
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null
4081
- ] }),
4082
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
4083
- lr,
4084
- {
4085
- id: e,
4086
- ref: o.ref,
4087
- checked: o.value,
4088
- onCheckedChange: o.onChange,
4089
- className: "!my-0"
4090
- }
4091
- ) })
4092
- ] }),
4093
- /* @__PURE__ */ c(te, { size: n })
4094
- ] })
4095
- }
4096
- );
4097
- }, Rt = S({
4098
- slots: {
4099
- root: "relative flex w-11 touch-none select-none items-center",
4100
- track: "relative h-5 w-full grow overflow-hidden rounded-full bg-tf-muted",
4101
- range: "absolute h-full bg-tf-accent",
4102
- thumb: "relative block h-4 w-4 rounded-full border-2 border-transparent bg-tf-background shadow-lg focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50"
4103
- },
4104
- variants: {
4105
- state: {
4106
- // false
4107
- 0: {
4108
- thumb: "left-0.5"
4109
- },
4110
- // null
4111
- 1: {
4112
- thumb: "h-5 w-5 border-tf-accent"
4113
- },
4114
- // true
4115
- 2: {
4116
- thumb: "right-0.5"
4117
- }
4118
- }
4119
- },
4120
- defaultVariants: {
4121
- state: 1
4122
- }
4123
- }), ur = A.forwardRef(({ className: r, ...e }, t) => {
4124
- const a = e.value?.[0], { root: s, track: n, range: i, thumb: o } = Rt({
4125
- state: a
4126
- });
4127
- return /* @__PURE__ */ b(
4128
- xe.Root,
4129
- {
4130
- disabled: !0,
4131
- ref: t,
4132
- className: s({
4133
- className: r
4134
- }),
4135
- onClick: (d) => {
4136
- if (d.preventDefault(), a !== void 0) {
4137
- const u = Object.keys(Rt.variants.state), p = u.indexOf(a.toString()), k = p === u.length - 1 ? 0 : p + 1;
4138
- e.onValueChange?.([k]);
4139
- }
4140
- },
4141
- ...e,
4142
- children: [
4143
- /* @__PURE__ */ c(xe.Track, { className: n(), children: /* @__PURE__ */ c(xe.Range, { className: i() }) }),
4144
- /* @__PURE__ */ c(xe.Thumb, { className: o() })
4145
- ]
4146
- }
4147
- );
4148
- });
4149
- ur.displayName = xe.Root.displayName;
4150
- const fr = null, ys = ({ label: r, bind: e, options: t }) => {
4151
- const { control: a } = K(), { variant: s, size: n } = Z();
4152
- return /* @__PURE__ */ c(
4153
- ie,
4154
- {
4155
- defaultValue: fr,
4156
- control: a,
4157
- name: e,
4158
- rules: {
4159
- required: !1
4160
- },
4161
- render: ({ field: i }) => /* @__PURE__ */ b(U, { variant: s, children: [
4162
- /* @__PURE__ */ b("div", { className: "flex flex-row items-center justify-between", children: [
4163
- /* @__PURE__ */ b("div", { className: "space-y-1", children: [
4164
- /* @__PURE__ */ c(B, { htmlFor: e, size: n, children: r }),
4165
- t?.description ? /* @__PURE__ */ c(ee, { size: n, children: t.description }) : null
4166
- ] }),
4167
- /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(
4168
- ur,
4169
- {
4170
- id: e,
4171
- ref: i.ref,
4172
- min: 0,
4173
- max: 2,
4174
- step: 1,
4175
- value: [
4176
- i.value === !0 ? 2 : i.value === null ? 1 : 0
4177
- ],
4178
- onValueChange: (o) => {
4179
- i.onChange(
4180
- o[0] === 2 ? !0 : o[0] === 1 ? null : !1
4181
- );
4182
- }
4183
- }
4184
- ) })
4185
- ] }),
4186
- /* @__PURE__ */ c(te, { size: n })
4187
- ] })
4188
- }
4189
- );
4190
- }, vs = ({ subtype: r, ...e }) => {
4191
- const t = mr.get(r)?.component;
4192
- return t ? /* @__PURE__ */ c(t, { ...e }) : null;
4193
- }, _s = ({ label: r }) => /* @__PURE__ */ c(ot, { children: r }), hr = (/* @__PURE__ */ new Map()).set("category", Jt).set("accordion", Ba), mr = (/* @__PURE__ */ new Map()).set("simple", {
4194
- defaultValue: ar,
4195
- component: cs
4196
- }).set("textarea", {
4197
- defaultValue: cr,
4198
- component: ms
4199
- }).set("toggle", {
4200
- defaultValue: dr,
4201
- component: gs
4202
- }).set("file", {
4203
- defaultValue: rr,
4204
- component: os
4205
- }).set("submit", {
4206
- component: fs
4207
- }).set("checkbox", {
4208
- defaultValue: Xt,
4209
- component: Ka
4210
- }).set("radiogroup", {
4211
- defaultValue: ir,
4212
- component: us
4213
- }).set("datepicker", {
4214
- defaultValue: tr,
4215
- component: ns
4216
- }).set("tri-toggle", {
4217
- defaultValue: fr,
4218
- component: ys
4219
- }), bs = new Map(hr).set("input", vs).set("label", _s), xs = Ot(
4220
- ({ defaultValues: r, resetOnSubmit: e, children: t }, a) => {
4221
- const { resetValues: s } = Z(), n = wr(null), i = $r({
4222
- defaultValues: r
4223
- });
4224
- Nr(a, () => n.current), mt(() => {
4225
- i.formState.isSubmitSuccessful && e && r && i.reset(s || r);
4226
- }, [i.formState, r]);
4227
- const o = (k) => {
4228
- const F = new CustomEvent("twintag-form-valid", {
4229
- detail: k,
4230
- bubbles: !0,
4231
- cancelable: !1,
4232
- composed: !0
4233
- });
4234
- n.current?.dispatchEvent(F);
4235
- }, d = (k) => {
4236
- const F = new CustomEvent("twintag-form-invalid", {
4237
- detail: k,
4238
- bubbles: !0,
4239
- cancelable: !1,
4240
- composed: !0
4241
- });
4242
- n.current?.dispatchEvent(F);
4243
- }, u = () => {
4244
- i.handleSubmit(o, d)();
4245
- }, p = () => {
4246
- const k = i.getValues(), F = new CustomEvent("twintag-form-values", {
4247
- detail: k,
4248
- bubbles: !0,
4249
- cancelable: !1,
4250
- composed: !0
4251
- });
4252
- n.current?.dispatchEvent(F);
4253
- };
4254
- return mt(() => {
4255
- const k = n.current;
4256
- return k && (k.addEventListener("twintag-form-validate", u), k.addEventListener("twintag-form-get_values", p)), () => {
4257
- k && (k.removeEventListener("twintag-form-validate", u), k.removeEventListener("twintag-form-get_values", p));
4258
- };
4259
- }, []), /* @__PURE__ */ c(Ja, { ...i, children: /* @__PURE__ */ c(
4260
- "form",
4261
- {
4262
- ref: n,
4263
- className: "relative flex w-full flex-col gap-4 font-tf-font",
4264
- onSubmit: i.handleSubmit(o, d),
4265
- children: t
4266
- }
4267
- ) });
4268
- }
4269
- ), st = ({ config: r }) => {
4270
- const { id: e, type: t, items: a, comp: s, ...n } = r;
4271
- if (!t || !s) return null;
4272
- const i = s;
4273
- return a && Array.isArray(a) && a.length > 0 ? hr.has(t) ? /* @__PURE__ */ c(i, { items: a, ...n, children: a.map((o) => /* @__PURE__ */ c(st, { config: { ...o } }, o.id)) }, e) : /* @__PURE__ */ c(i, { items: a, ...n }, e) : /* @__PURE__ */ c(i, { ...n }, e);
4274
- }, ks = () => {
4275
- const { config: r } = Z();
4276
- return Array.isArray(r) ? /* @__PURE__ */ c(br, { children: r.map((e) => /* @__PURE__ */ c(st, { config: { ...e } }, e.id)) }) : /* @__PURE__ */ c(st, { config: r });
4277
- }, Es = Ot(
4278
- ({ config: r, options: e }, t) => /* @__PURE__ */ c(
4279
- Da,
4280
- {
4281
- inputs: mr,
4282
- components: bs,
4283
- variant: e?.variant,
4284
- size: e?.size,
4285
- config: r,
4286
- acceptFileType: e?.acceptFileType,
4287
- children: /* @__PURE__ */ c(
4288
- xs,
4289
- {
4290
- ref: t,
4291
- defaultValues: e?.defaultValues,
4292
- resetOnSubmit: e?.resetOnSubmit,
4293
- children: /* @__PURE__ */ c(ks, {})
4294
- }
4295
- )
4296
- }
4297
- )
4298
- );
4299
- export {
4300
- Es as Form
4301
- };