@ericbutera/kaleido 0.1.0

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