@rpcbase/auth 0.109.0 → 0.111.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 (59) hide show
  1. package/dist/handler-BH38xcvj.js +60 -0
  2. package/dist/handler-BH38xcvj.js.map +1 -0
  3. package/dist/handler-Bjxe8iM2.js +67 -0
  4. package/dist/handler-Bjxe8iM2.js.map +1 -0
  5. package/dist/handler-CVeU9Nyf.js +85 -0
  6. package/dist/handler-CVeU9Nyf.js.map +1 -0
  7. package/dist/handler-CrTy-N1A.js +51 -0
  8. package/dist/handler-CrTy-N1A.js.map +1 -0
  9. package/dist/handler-D2-FmmDc.js +56 -0
  10. package/dist/handler-D2-FmmDc.js.map +1 -0
  11. package/dist/handler-D4-sXlBe.js +74 -0
  12. package/dist/handler-D4-sXlBe.js.map +1 -0
  13. package/dist/handler-D87G4mz9.js +67 -0
  14. package/dist/handler-D87G4mz9.js.map +1 -0
  15. package/dist/handler-DKrwSIQz.js +19 -0
  16. package/dist/handler-DKrwSIQz.js.map +1 -0
  17. package/dist/handler-tJUJWqII.js +59 -0
  18. package/dist/handler-tJUJWqII.js.map +1 -0
  19. package/dist/index.js +657 -684
  20. package/dist/index.js.map +1 -1
  21. package/dist/middleware-BbKZ_rOe.js +18 -0
  22. package/dist/middleware-BbKZ_rOe.js.map +1 -0
  23. package/dist/oauth/index.js +625 -746
  24. package/dist/oauth/index.js.map +1 -1
  25. package/dist/routes.js +18 -9
  26. package/dist/routes.js.map +1 -1
  27. package/dist/schemas-BKnjeqQ9.js +3380 -0
  28. package/dist/schemas-BKnjeqQ9.js.map +1 -0
  29. package/dist/sign-in-C9a-NvBu.js +18 -0
  30. package/dist/sign-in-C9a-NvBu.js.map +1 -0
  31. package/dist/sign-up-DqDJxb2D.js +18 -0
  32. package/dist/sign-up-DqDJxb2D.js.map +1 -0
  33. package/package.json +1 -1
  34. package/dist/handler-BNDemOGd.js +0 -79
  35. package/dist/handler-BNDemOGd.js.map +0 -1
  36. package/dist/handler-Bt53h0sk.js +0 -64
  37. package/dist/handler-Bt53h0sk.js.map +0 -1
  38. package/dist/handler-C4cw739Z.js +0 -59
  39. package/dist/handler-C4cw739Z.js.map +0 -1
  40. package/dist/handler-Ck7oLQ_R.js +0 -87
  41. package/dist/handler-Ck7oLQ_R.js.map +0 -1
  42. package/dist/handler-CyP6R8FM.js +0 -24
  43. package/dist/handler-CyP6R8FM.js.map +0 -1
  44. package/dist/handler-D6zJn86A.js +0 -82
  45. package/dist/handler-D6zJn86A.js.map +0 -1
  46. package/dist/handler-D8HfTbUs.js +0 -58
  47. package/dist/handler-D8HfTbUs.js.map +0 -1
  48. package/dist/handler-DfEsSB4T.js +0 -74
  49. package/dist/handler-DfEsSB4T.js.map +0 -1
  50. package/dist/handler-xEpHnzkZ.js +0 -58
  51. package/dist/handler-xEpHnzkZ.js.map +0 -1
  52. package/dist/index-Bxz6YdiB.js +0 -20
  53. package/dist/index-Bxz6YdiB.js.map +0 -1
  54. package/dist/index-C_uBu_fP.js +0 -20
  55. package/dist/index-C_uBu_fP.js.map +0 -1
  56. package/dist/middleware-5Zwy7HRL.js +0 -25
  57. package/dist/middleware-5Zwy7HRL.js.map +0 -1
  58. package/dist/schemas-Dn3gHDGz.js +0 -3706
  59. package/dist/schemas-Dn3gHDGz.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,706 +1,679 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
1
+ import { n as requestSchema } from "./sign-in-C9a-NvBu.js";
2
+ import { n as requestSchema$1 } from "./sign-up-DqDJxb2D.js";
3
+ import { n as requireSession, r as restrictSessionMiddleware, t as redirectAuthMiddleware } from "./middleware-BbKZ_rOe.js";
2
4
  import { c } from "react/compiler-runtime";
3
- import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
5
+ import { createElement, forwardRef, useEffect, useState } from "react";
6
+ import { Link, useLocation, useNavigate, useSearchParams } from "@rpcbase/router";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
8
  import clsx from "clsx";
5
- import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
6
- import { r as requestSchema } from "./index-Bxz6YdiB.js";
7
- import { useState, forwardRef, createElement, useEffect } from "react";
8
- import { r as requestSchema$1 } from "./index-C_uBu_fP.js";
9
- import { b, a, r } from "./middleware-5Zwy7HRL.js";
10
- const LINKS_REDIRECTION_MAP = {
11
- "/auth/sign-in": {
12
- "title": "Sign Up",
13
- "location": "/auth/sign-up"
14
- },
15
- "/auth/sign-up": {
16
- "title": "Sign In",
17
- "location": "/auth/sign-in"
18
- },
19
- "/auth/logout-success": {
20
- "title": "Sign In",
21
- "location": "/auth/sign-in"
22
- }
9
+ import { FormProvider, useForm, useFormContext, zodResolver } from "@rpcbase/form";
10
+ //#region src/components/AuthLayout/index.tsx
11
+ var LINKS_REDIRECTION_MAP = {
12
+ "/auth/sign-in": {
13
+ "title": "Sign Up",
14
+ "location": "/auth/sign-up"
15
+ },
16
+ "/auth/sign-up": {
17
+ "title": "Sign In",
18
+ "location": "/auth/sign-in"
19
+ },
20
+ "/auth/logout-success": {
21
+ "title": "Sign In",
22
+ "location": "/auth/sign-in"
23
+ }
23
24
  };
24
- const AuthLayout = (t0) => {
25
- const $ = c(11);
26
- const {
27
- sidePanel: t1,
28
- children
29
- } = t0;
30
- const sidePanel = t1 === void 0 ? null : t1;
31
- const location = useLocation();
32
- const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
33
- const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
34
- let t2;
35
- if ($[0] !== linkLocation || $[1] !== linkTitle) {
36
- t2 = linkTitle && linkLocation ? /* @__PURE__ */ jsx(Link, { className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 absolute right-4 top-4 md:right-8 md:top-8", to: linkLocation, children: linkTitle }) : null;
37
- $[0] = linkLocation;
38
- $[1] = linkTitle;
39
- $[2] = t2;
40
- } else {
41
- t2 = $[2];
42
- }
43
- let t3;
44
- if ($[3] !== sidePanel) {
45
- t3 = /* @__PURE__ */ jsx("div", { className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex", children: sidePanel });
46
- $[3] = sidePanel;
47
- $[4] = t3;
48
- } else {
49
- t3 = $[4];
50
- }
51
- let t4;
52
- if ($[5] !== children) {
53
- t4 = /* @__PURE__ */ jsx("div", { className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/", children });
54
- $[5] = children;
55
- $[6] = t4;
56
- } else {
57
- t4 = $[6];
58
- }
59
- let t5;
60
- if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
61
- t5 = /* @__PURE__ */ jsxs("div", { className: "container relative hidden h-dvh flex-col items-center justify-center md:grid md:w-full lg:max-w-none lg:grid-cols-2 lg:px-0", children: [
62
- t2,
63
- t3,
64
- t4
65
- ] });
66
- $[7] = t2;
67
- $[8] = t3;
68
- $[9] = t4;
69
- $[10] = t5;
70
- } else {
71
- t5 = $[10];
72
- }
73
- return t5;
25
+ var AuthLayout = (t0) => {
26
+ const $ = c(11);
27
+ const { sidePanel: t1, children } = t0;
28
+ const sidePanel = t1 === void 0 ? null : t1;
29
+ const location = useLocation();
30
+ const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
31
+ const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
32
+ let t2;
33
+ if ($[0] !== linkLocation || $[1] !== linkTitle) {
34
+ t2 = linkTitle && linkLocation ? /* @__PURE__ */ jsx(Link, {
35
+ className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 absolute right-4 top-4 md:right-8 md:top-8",
36
+ to: linkLocation,
37
+ children: linkTitle
38
+ }) : null;
39
+ $[0] = linkLocation;
40
+ $[1] = linkTitle;
41
+ $[2] = t2;
42
+ } else t2 = $[2];
43
+ let t3;
44
+ if ($[3] !== sidePanel) {
45
+ t3 = /* @__PURE__ */ jsx("div", {
46
+ className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex",
47
+ children: sidePanel
48
+ });
49
+ $[3] = sidePanel;
50
+ $[4] = t3;
51
+ } else t3 = $[4];
52
+ let t4;
53
+ if ($[5] !== children) {
54
+ t4 = /* @__PURE__ */ jsx("div", {
55
+ className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/",
56
+ children
57
+ });
58
+ $[5] = children;
59
+ $[6] = t4;
60
+ } else t4 = $[6];
61
+ let t5;
62
+ if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
63
+ t5 = /* @__PURE__ */ jsxs("div", {
64
+ className: "container relative hidden h-dvh flex-col items-center justify-center md:grid md:w-full lg:max-w-none lg:grid-cols-2 lg:px-0",
65
+ children: [
66
+ t2,
67
+ t3,
68
+ t4
69
+ ]
70
+ });
71
+ $[7] = t2;
72
+ $[8] = t3;
73
+ $[9] = t4;
74
+ $[10] = t5;
75
+ } else t5 = $[10];
76
+ return t5;
74
77
  };
75
- const AppleSignInButton = (t0) => {
76
- const $ = c(7);
77
- const {
78
- onPress,
79
- className
80
- } = t0;
81
- let t1;
82
- if ($[0] !== className) {
83
- t1 = clsx("\n w-full\n bg-black text-white hover:bg-gray-800\n flex items-center justify-center\n px-6 py-2\n rounded-lg\n font-medium\n transition duration-150 ease-in-out\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black\n ", className);
84
- $[0] = className;
85
- $[1] = t1;
86
- } else {
87
- t1 = $[1];
88
- }
89
- let t2;
90
- let t3;
91
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
92
- t2 = /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 mr-3", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.539 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" }) });
93
- t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
94
- $[2] = t2;
95
- $[3] = t3;
96
- } else {
97
- t2 = $[2];
98
- t3 = $[3];
99
- }
100
- let t4;
101
- if ($[4] !== onPress || $[5] !== t1) {
102
- t4 = /* @__PURE__ */ jsxs("button", { onClick: onPress, className: t1, children: [
103
- t2,
104
- t3
105
- ] });
106
- $[4] = onPress;
107
- $[5] = t1;
108
- $[6] = t4;
109
- } else {
110
- t4 = $[6];
111
- }
112
- return t4;
78
+ //#endregion
79
+ //#region src/components/AppleSignInButton/index.tsx
80
+ var AppleSignInButton = (t0) => {
81
+ const $ = c(7);
82
+ const { onPress, className } = t0;
83
+ let t1;
84
+ if ($[0] !== className) {
85
+ t1 = clsx("\n w-full\n bg-black text-white hover:bg-gray-800\n flex items-center justify-center\n px-6 py-2\n rounded-lg\n font-medium\n transition duration-150 ease-in-out\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black\n ", className);
86
+ $[0] = className;
87
+ $[1] = t1;
88
+ } else t1 = $[1];
89
+ let t2;
90
+ let t3;
91
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
92
+ t2 = /* @__PURE__ */ jsx("svg", {
93
+ className: "w-5 h-5 mr-3",
94
+ xmlns: "http://www.w3.org/2000/svg",
95
+ viewBox: "0 0 24 24",
96
+ fill: "white",
97
+ children: /* @__PURE__ */ jsx("path", { d: "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.539 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" })
98
+ });
99
+ t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
100
+ $[2] = t2;
101
+ $[3] = t3;
102
+ } else {
103
+ t2 = $[2];
104
+ t3 = $[3];
105
+ }
106
+ let t4;
107
+ if ($[4] !== onPress || $[5] !== t1) {
108
+ t4 = /* @__PURE__ */ jsxs("button", {
109
+ onClick: onPress,
110
+ className: t1,
111
+ children: [t2, t3]
112
+ });
113
+ $[4] = onPress;
114
+ $[5] = t1;
115
+ $[6] = t4;
116
+ } else t4 = $[6];
117
+ return t4;
113
118
  };
114
- const EmailInput = (t0) => {
115
- const $ = c(12);
116
- const {
117
- id,
118
- className,
119
- placeholder
120
- } = t0;
121
- const {
122
- register,
123
- formState
124
- } = useFormContext();
125
- const error = formState.errors.email;
126
- let errorMessage;
127
- if (typeof error === "string") {
128
- errorMessage = error;
129
- } else {
130
- if (error && typeof error.message === "string") {
131
- errorMessage = error.message;
132
- }
133
- }
134
- let t1;
135
- if ($[0] !== register) {
136
- t1 = register("email");
137
- $[0] = register;
138
- $[1] = t1;
139
- } else {
140
- t1 = $[1];
141
- }
142
- let t2;
143
- if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
144
- t2 = /* @__PURE__ */ jsx("input", { id, type: "email", required: true, autoComplete: "email", className, placeholder, ...t1 });
145
- $[2] = className;
146
- $[3] = id;
147
- $[4] = placeholder;
148
- $[5] = t1;
149
- $[6] = t2;
150
- } else {
151
- t2 = $[6];
152
- }
153
- let t3;
154
- if ($[7] !== errorMessage) {
155
- t3 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
156
- $[7] = errorMessage;
157
- $[8] = t3;
158
- } else {
159
- t3 = $[8];
160
- }
161
- let t4;
162
- if ($[9] !== t2 || $[10] !== t3) {
163
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
164
- t2,
165
- t3
166
- ] });
167
- $[9] = t2;
168
- $[10] = t3;
169
- $[11] = t4;
170
- } else {
171
- t4 = $[11];
172
- }
173
- return t4;
119
+ //#endregion
120
+ //#region src/components/EmailInput/index.tsx
121
+ var EmailInput = (t0) => {
122
+ const $ = c(12);
123
+ const { id, className, placeholder } = t0;
124
+ const { register, formState } = useFormContext();
125
+ const error = formState.errors.email;
126
+ let errorMessage;
127
+ if (typeof error === "string") errorMessage = error;
128
+ else if (error && typeof error.message === "string") errorMessage = error.message;
129
+ let t1;
130
+ if ($[0] !== register) {
131
+ t1 = register("email");
132
+ $[0] = register;
133
+ $[1] = t1;
134
+ } else t1 = $[1];
135
+ let t2;
136
+ if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
137
+ t2 = /* @__PURE__ */ jsx("input", {
138
+ id,
139
+ type: "email",
140
+ required: true,
141
+ autoComplete: "email",
142
+ className,
143
+ placeholder,
144
+ ...t1
145
+ });
146
+ $[2] = className;
147
+ $[3] = id;
148
+ $[4] = placeholder;
149
+ $[5] = t1;
150
+ $[6] = t2;
151
+ } else t2 = $[6];
152
+ let t3;
153
+ if ($[7] !== errorMessage) {
154
+ t3 = errorMessage ? /* @__PURE__ */ jsx("p", {
155
+ className: "mt-1 -mb-2 text-sm/6 text-red-500",
156
+ children: errorMessage
157
+ }) : null;
158
+ $[7] = errorMessage;
159
+ $[8] = t3;
160
+ } else t3 = $[8];
161
+ let t4;
162
+ if ($[9] !== t2 || $[10] !== t3) {
163
+ t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t3] });
164
+ $[9] = t2;
165
+ $[10] = t3;
166
+ $[11] = t4;
167
+ } else t4 = $[11];
168
+ return t4;
174
169
  };
175
- const hasUnsafeNextPathChars = (value) => {
176
- for (let i = 0; i < value.length; i++) {
177
- const code = value.charCodeAt(i);
178
- if (code === 92 || code <= 31 || code === 127) return true;
179
- }
180
- return false;
170
+ //#endregion
171
+ //#region src/utils/sanitizeNextPath.ts
172
+ var hasUnsafeNextPathChars = (value) => {
173
+ for (let i = 0; i < value.length; i++) {
174
+ const code = value.charCodeAt(i);
175
+ if (code === 92 || code <= 31 || code === 127) return true;
176
+ }
177
+ return false;
181
178
  };
182
- const sanitizeNextPath = (raw) => {
183
- if (!raw) return null;
184
- const nextPath = raw.trim();
185
- if (!nextPath) return null;
186
- if (!nextPath.startsWith("/") || nextPath.startsWith("//")) {
187
- return null;
188
- }
189
- if (hasUnsafeNextPathChars(nextPath)) {
190
- return null;
191
- }
192
- try {
193
- const base = new URL("http://localhost");
194
- const url = new URL(nextPath, base);
195
- if (url.origin !== base.origin) {
196
- return null;
197
- }
198
- return `${url.pathname}${url.search}${url.hash}`;
199
- } catch {
200
- return null;
201
- }
179
+ var sanitizeNextPath = (raw) => {
180
+ if (!raw) return null;
181
+ const nextPath = raw.trim();
182
+ if (!nextPath) return null;
183
+ if (!nextPath.startsWith("/") || nextPath.startsWith("//")) return null;
184
+ if (hasUnsafeNextPathChars(nextPath)) return null;
185
+ try {
186
+ const base = new URL("http://localhost");
187
+ const url = new URL(nextPath, base);
188
+ if (url.origin !== base.origin) return null;
189
+ return `${url.pathname}${url.search}${url.hash}`;
190
+ } catch {
191
+ return null;
192
+ }
202
193
  };
203
- const SignInForm = ({
204
- children,
205
- className
206
- }) => {
207
- const navigate = useNavigate();
208
- const [searchParams] = useSearchParams();
209
- const methods = useForm({
210
- defaultValues: {
211
- email: "",
212
- password: "",
213
- rememberMe: true
214
- },
215
- navigationGuard: false,
216
- resolver: zodResolver(requestSchema)
217
- });
218
- const onSubmit = async (data) => {
219
- methods.clearErrors("root");
220
- try {
221
- const res = await fetch("/api/rb/auth/sign-in", {
222
- method: "POST",
223
- headers: {
224
- "Content-Type": "application/json"
225
- },
226
- body: JSON.stringify(data),
227
- credentials: "include"
228
- });
229
- const json = await res.json().catch(() => null);
230
- if (!res.ok || !json?.success) {
231
- const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
232
- methods.setError("root", {
233
- type: "server",
234
- message
235
- });
236
- return;
237
- }
238
- const nextPath = sanitizeNextPath(searchParams.get("next")) ?? "/";
239
- navigate(nextPath, {
240
- replace: true
241
- });
242
- } catch (err) {
243
- methods.setError("root", {
244
- type: "server",
245
- message: "Network error. Please try again."
246
- });
247
- }
248
- };
249
- return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
250
- children,
251
- methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message })
252
- ] }) });
194
+ //#endregion
195
+ //#region src/components/SignInForm/index.tsx
196
+ var SignInForm = ({ children, className }) => {
197
+ const navigate = useNavigate();
198
+ const [searchParams] = useSearchParams();
199
+ const methods = useForm({
200
+ defaultValues: {
201
+ email: "",
202
+ password: "",
203
+ rememberMe: true
204
+ },
205
+ navigationGuard: false,
206
+ resolver: zodResolver(requestSchema)
207
+ });
208
+ const onSubmit = async (data) => {
209
+ methods.clearErrors("root");
210
+ try {
211
+ const res = await fetch("/api/rb/auth/sign-in", {
212
+ method: "POST",
213
+ headers: { "Content-Type": "application/json" },
214
+ body: JSON.stringify(data),
215
+ credentials: "include"
216
+ });
217
+ const json = await res.json().catch(() => null);
218
+ if (!res.ok || !json?.success) {
219
+ const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
220
+ methods.setError("root", {
221
+ type: "server",
222
+ message
223
+ });
224
+ return;
225
+ }
226
+ navigate(sanitizeNextPath(searchParams.get("next")) ?? "/", { replace: true });
227
+ } catch (err) {
228
+ methods.setError("root", {
229
+ type: "server",
230
+ message: "Network error. Please try again."
231
+ });
232
+ }
233
+ };
234
+ return /* @__PURE__ */ jsx(FormProvider, {
235
+ ...methods,
236
+ children: /* @__PURE__ */ jsxs("form", {
237
+ method: "post",
238
+ noValidate: true,
239
+ className,
240
+ onSubmit: methods.handleSubmit(onSubmit),
241
+ children: [children, methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
242
+ className: "mt-2 text-sm text-red-600",
243
+ role: "alert",
244
+ children: methods.formState.errors.root.message
245
+ })]
246
+ })
247
+ });
253
248
  };
254
- const SignUpForm = ({
255
- children,
256
- className,
257
- otpNextPath
258
- }) => {
259
- const navigate = useNavigate();
260
- const [serverMessage, setServerMessage] = useState(null);
261
- const methods = useForm({
262
- defaultValues: {
263
- email: "",
264
- password: "",
265
- rememberMe: true
266
- },
267
- navigationGuard: false,
268
- resolver: zodResolver(requestSchema$1)
269
- });
270
- const onSubmit = async (data) => {
271
- setServerMessage(null);
272
- methods.clearErrors("root");
273
- try {
274
- const res = await fetch("/api/rb/auth/sign-up", {
275
- method: "POST",
276
- headers: {
277
- "Content-Type": "application/json"
278
- },
279
- body: JSON.stringify(data),
280
- credentials: "include"
281
- });
282
- const json = await res.json();
283
- if (!res.ok) {
284
- const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
285
- methods.setError("root", {
286
- type: "server",
287
- message
288
- });
289
- return;
290
- }
291
- if (!json.success) {
292
- methods.setError("root", {
293
- type: "server",
294
- message: "Sign-up failed. Please try again."
295
- });
296
- return;
297
- }
298
- const search = new URLSearchParams({
299
- email: data.email
300
- });
301
- if (otpNextPath) {
302
- search.set("next", otpNextPath);
303
- }
304
- navigate(`/auth/sign-up-otp?${search.toString()}`);
305
- setServerMessage("Account created. Check your inbox to verify your email.");
306
- } catch (err) {
307
- methods.setError("root", {
308
- type: "server",
309
- message: "Network error. Please try again."
310
- });
311
- }
312
- };
313
- return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
314
- children,
315
- methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message }),
316
- serverMessage && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-green-700", role: "status", children: serverMessage })
317
- ] }) });
249
+ //#endregion
250
+ //#region src/components/SignUpForm/index.tsx
251
+ var SignUpForm = ({ children, className, otpNextPath }) => {
252
+ const navigate = useNavigate();
253
+ const [serverMessage, setServerMessage] = useState(null);
254
+ const methods = useForm({
255
+ defaultValues: {
256
+ email: "",
257
+ password: "",
258
+ rememberMe: true
259
+ },
260
+ navigationGuard: false,
261
+ resolver: zodResolver(requestSchema$1)
262
+ });
263
+ const onSubmit = async (data) => {
264
+ setServerMessage(null);
265
+ methods.clearErrors("root");
266
+ try {
267
+ const res = await fetch("/api/rb/auth/sign-up", {
268
+ method: "POST",
269
+ headers: { "Content-Type": "application/json" },
270
+ body: JSON.stringify(data),
271
+ credentials: "include"
272
+ });
273
+ const json = await res.json();
274
+ if (!res.ok) {
275
+ const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
276
+ methods.setError("root", {
277
+ type: "server",
278
+ message
279
+ });
280
+ return;
281
+ }
282
+ if (!json.success) {
283
+ methods.setError("root", {
284
+ type: "server",
285
+ message: "Sign-up failed. Please try again."
286
+ });
287
+ return;
288
+ }
289
+ const search = new URLSearchParams({ email: data.email });
290
+ if (otpNextPath) search.set("next", otpNextPath);
291
+ navigate(`/auth/sign-up-otp?${search.toString()}`);
292
+ setServerMessage("Account created. Check your inbox to verify your email.");
293
+ } catch (err) {
294
+ methods.setError("root", {
295
+ type: "server",
296
+ message: "Network error. Please try again."
297
+ });
298
+ }
299
+ };
300
+ return /* @__PURE__ */ jsx(FormProvider, {
301
+ ...methods,
302
+ children: /* @__PURE__ */ jsxs("form", {
303
+ method: "post",
304
+ noValidate: true,
305
+ className,
306
+ onSubmit: methods.handleSubmit(onSubmit),
307
+ children: [
308
+ children,
309
+ methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
310
+ className: "mt-2 text-sm text-red-600",
311
+ role: "alert",
312
+ children: methods.formState.errors.root.message
313
+ }),
314
+ serverMessage && /* @__PURE__ */ jsx("p", {
315
+ className: "mt-2 text-sm text-green-700",
316
+ role: "status",
317
+ children: serverMessage
318
+ })
319
+ ]
320
+ })
321
+ });
318
322
  };
319
- const RememberMeCheckbox = (t0) => {
320
- const $ = c(10);
321
- const {
322
- label,
323
- as: t1
324
- } = t0;
325
- const Component = t1 === void 0 ? "input" : t1;
326
- const {
327
- register
328
- } = useFormContext();
329
- let t2;
330
- if ($[0] !== register) {
331
- t2 = register("rememberMe");
332
- $[0] = register;
333
- $[1] = t2;
334
- } else {
335
- t2 = $[1];
336
- }
337
- let t3;
338
- if ($[2] !== Component || $[3] !== t2) {
339
- t3 = /* @__PURE__ */ jsx(Component, { id: "rememberMe", ...t2 });
340
- $[2] = Component;
341
- $[3] = t2;
342
- $[4] = t3;
343
- } else {
344
- t3 = $[4];
345
- }
346
- let t4;
347
- if ($[5] !== label) {
348
- t4 = /* @__PURE__ */ jsx("label", { htmlFor: "rememberMe", className: "pl-2 block text-sm/6 text-gray-900", children: label });
349
- $[5] = label;
350
- $[6] = t4;
351
- } else {
352
- t4 = $[6];
353
- }
354
- let t5;
355
- if ($[7] !== t3 || $[8] !== t4) {
356
- t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
357
- t3,
358
- t4
359
- ] });
360
- $[7] = t3;
361
- $[8] = t4;
362
- $[9] = t5;
363
- } else {
364
- t5 = $[9];
365
- }
366
- return t5;
323
+ //#endregion
324
+ //#region src/components/RememberMeCheckbox/index.tsx
325
+ var RememberMeCheckbox = (t0) => {
326
+ const $ = c(10);
327
+ const { label, as: t1 } = t0;
328
+ const Component = t1 === void 0 ? "input" : t1;
329
+ const { register } = useFormContext();
330
+ let t2;
331
+ if ($[0] !== register) {
332
+ t2 = register("rememberMe");
333
+ $[0] = register;
334
+ $[1] = t2;
335
+ } else t2 = $[1];
336
+ let t3;
337
+ if ($[2] !== Component || $[3] !== t2) {
338
+ t3 = /* @__PURE__ */ jsx(Component, {
339
+ id: "rememberMe",
340
+ ...t2
341
+ });
342
+ $[2] = Component;
343
+ $[3] = t2;
344
+ $[4] = t3;
345
+ } else t3 = $[4];
346
+ let t4;
347
+ if ($[5] !== label) {
348
+ t4 = /* @__PURE__ */ jsx("label", {
349
+ htmlFor: "rememberMe",
350
+ className: "pl-2 block text-sm/6 text-gray-900",
351
+ children: label
352
+ });
353
+ $[5] = label;
354
+ $[6] = t4;
355
+ } else t4 = $[6];
356
+ let t5;
357
+ if ($[7] !== t3 || $[8] !== t4) {
358
+ t5 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, t4] });
359
+ $[7] = t3;
360
+ $[8] = t4;
361
+ $[9] = t5;
362
+ } else t5 = $[9];
363
+ return t5;
367
364
  };
368
- const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
369
- const toCamelCase = (string) => string.replace(
370
- /^([A-Z])|[\s-_]+(\w)/g,
371
- (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
372
- );
373
- const toPascalCase = (string) => {
374
- const camelCase = toCamelCase(string);
375
- return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
365
+ //#endregion
366
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
367
+ /**
368
+ * @license lucide-react v0.562.0 - ISC
369
+ *
370
+ * This source code is licensed under the ISC license.
371
+ * See the LICENSE file in the root directory of this source tree.
372
+ */
373
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
374
+ var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
375
+ var toPascalCase = (string) => {
376
+ const camelCase = toCamelCase(string);
377
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
376
378
  };
377
- const mergeClasses = (...classes) => classes.filter((className, index, array) => {
378
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
379
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
380
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
379
381
  }).join(" ").trim();
380
- const hasA11yProp = (props) => {
381
- for (const prop in props) {
382
- if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
383
- return true;
384
- }
385
- }
382
+ var hasA11yProp = (props) => {
383
+ for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
386
384
  };
385
+ //#endregion
386
+ //#region ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
387
+ /**
388
+ * @license lucide-react v0.562.0 - ISC
389
+ *
390
+ * This source code is licensed under the ISC license.
391
+ * See the LICENSE file in the root directory of this source tree.
392
+ */
387
393
  var defaultAttributes = {
388
- xmlns: "http://www.w3.org/2000/svg",
389
- width: 24,
390
- height: 24,
391
- viewBox: "0 0 24 24",
392
- fill: "none",
393
- stroke: "currentColor",
394
- strokeWidth: 2,
395
- strokeLinecap: "round",
396
- strokeLinejoin: "round"
394
+ xmlns: "http://www.w3.org/2000/svg",
395
+ width: 24,
396
+ height: 24,
397
+ viewBox: "0 0 24 24",
398
+ fill: "none",
399
+ stroke: "currentColor",
400
+ strokeWidth: 2,
401
+ strokeLinecap: "round",
402
+ strokeLinejoin: "round"
397
403
  };
398
- const Icon = forwardRef(
399
- ({
400
- color = "currentColor",
401
- size = 24,
402
- strokeWidth = 2,
403
- absoluteStrokeWidth,
404
- className = "",
405
- children,
406
- iconNode,
407
- ...rest
408
- }, ref) => createElement(
409
- "svg",
410
- {
411
- ref,
412
- ...defaultAttributes,
413
- width: size,
414
- height: size,
415
- stroke: color,
416
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
417
- className: mergeClasses("lucide", className),
418
- ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
419
- ...rest
420
- },
421
- [
422
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
423
- ...Array.isArray(children) ? children : [children]
424
- ]
425
- )
426
- );
427
- const createLucideIcon = (iconName, iconNode) => {
428
- const Component = forwardRef(
429
- ({ className, ...props }, ref) => createElement(Icon, {
430
- ref,
431
- iconNode,
432
- className: mergeClasses(
433
- `lucide-${toKebabCase(toPascalCase(iconName))}`,
434
- `lucide-${iconName}`,
435
- className
436
- ),
437
- ...props
438
- })
439
- );
440
- Component.displayName = toPascalCase(iconName);
441
- return Component;
404
+ //#endregion
405
+ //#region ../../node_modules/lucide-react/dist/esm/Icon.js
406
+ /**
407
+ * @license lucide-react v0.562.0 - ISC
408
+ *
409
+ * This source code is licensed under the ISC license.
410
+ * See the LICENSE file in the root directory of this source tree.
411
+ */
412
+ var Icon = forwardRef(({ color = "currentColor", size = 24, strokeWidth = 2, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => createElement("svg", {
413
+ ref,
414
+ ...defaultAttributes,
415
+ width: size,
416
+ height: size,
417
+ stroke: color,
418
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
419
+ className: mergeClasses("lucide", className),
420
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
421
+ ...rest
422
+ }, [...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]));
423
+ //#endregion
424
+ //#region ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
425
+ /**
426
+ * @license lucide-react v0.562.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */
431
+ var createLucideIcon = (iconName, iconNode) => {
432
+ const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
433
+ ref,
434
+ iconNode,
435
+ className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
436
+ ...props
437
+ }));
438
+ Component.displayName = toPascalCase(iconName);
439
+ return Component;
442
440
  };
443
- const __iconNode$1 = [
444
- [
445
- "path",
446
- {
447
- d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
448
- key: "ct8e1f"
449
- }
450
- ],
451
- ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
452
- [
453
- "path",
454
- {
455
- d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
456
- key: "13bj9a"
457
- }
458
- ],
459
- ["path", { d: "m2 2 20 20", key: "1ooewy" }]
460
- ];
461
- const EyeOff = createLucideIcon("eye-off", __iconNode$1);
462
- const __iconNode = [
463
- [
464
- "path",
465
- {
466
- d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
467
- key: "1nclc0"
468
- }
469
- ],
470
- ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
471
- ];
472
- const Eye = createLucideIcon("eye", __iconNode);
473
- const PasswordInput = (t0) => {
474
- const $ = c(24);
475
- const {
476
- id,
477
- name: t1,
478
- className,
479
- placeholder,
480
- autoComplete: t2
481
- } = t0;
482
- const name = t1 === void 0 ? "password" : t1;
483
- const autoComplete = t2 === void 0 ? "current-password" : t2;
484
- const [showPassword, setShowPassword] = useState(false);
485
- const {
486
- register,
487
- formState
488
- } = useFormContext();
489
- const fieldError = formState.errors[name];
490
- const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
491
- const inputClassName = className ? `${className} pr-11` : "pr-11";
492
- const t3 = showPassword ? "text" : "password";
493
- const t4 = name;
494
- let t5;
495
- if ($[0] !== register || $[1] !== t4) {
496
- t5 = register(t4);
497
- $[0] = register;
498
- $[1] = t4;
499
- $[2] = t5;
500
- } else {
501
- t5 = $[2];
502
- }
503
- let t6;
504
- if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
505
- t6 = /* @__PURE__ */ jsx("input", { id, type: t3, autoComplete, className: inputClassName, placeholder, ...t5 });
506
- $[3] = autoComplete;
507
- $[4] = id;
508
- $[5] = inputClassName;
509
- $[6] = placeholder;
510
- $[7] = t3;
511
- $[8] = t5;
512
- $[9] = t6;
513
- } else {
514
- t6 = $[9];
515
- }
516
- let t7;
517
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
518
- t7 = () => setShowPassword(_temp);
519
- $[10] = t7;
520
- } else {
521
- t7 = $[10];
522
- }
523
- const t8 = showPassword ? "Hide characters" : "Show characters";
524
- let t9;
525
- if ($[11] !== showPassword) {
526
- t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "h-5 w-5", "aria-hidden": true }) : /* @__PURE__ */ jsx(Eye, { className: "h-5 w-5", "aria-hidden": true });
527
- $[11] = showPassword;
528
- $[12] = t9;
529
- } else {
530
- t9 = $[12];
531
- }
532
- let t10;
533
- if ($[13] !== t8 || $[14] !== t9) {
534
- t10 = /* @__PURE__ */ jsx("button", { type: "button", className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500", onClick: t7, "aria-label": t8, children: t9 });
535
- $[13] = t8;
536
- $[14] = t9;
537
- $[15] = t10;
538
- } else {
539
- t10 = $[15];
540
- }
541
- let t11;
542
- if ($[16] !== t10 || $[17] !== t6) {
543
- t11 = /* @__PURE__ */ jsxs("div", { className: "relative", children: [
544
- t6,
545
- t10
546
- ] });
547
- $[16] = t10;
548
- $[17] = t6;
549
- $[18] = t11;
550
- } else {
551
- t11 = $[18];
552
- }
553
- let t12;
554
- if ($[19] !== errorMessage) {
555
- t12 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
556
- $[19] = errorMessage;
557
- $[20] = t12;
558
- } else {
559
- t12 = $[20];
560
- }
561
- let t13;
562
- if ($[21] !== t11 || $[22] !== t12) {
563
- t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
564
- t11,
565
- t12
566
- ] });
567
- $[21] = t11;
568
- $[22] = t12;
569
- $[23] = t13;
570
- } else {
571
- t13 = $[23];
572
- }
573
- return t13;
441
+ var EyeOff = createLucideIcon("eye-off", [
442
+ ["path", {
443
+ d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
444
+ key: "ct8e1f"
445
+ }],
446
+ ["path", {
447
+ d: "M14.084 14.158a3 3 0 0 1-4.242-4.242",
448
+ key: "151rxh"
449
+ }],
450
+ ["path", {
451
+ d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
452
+ key: "13bj9a"
453
+ }],
454
+ ["path", {
455
+ d: "m2 2 20 20",
456
+ key: "1ooewy"
457
+ }]
458
+ ]);
459
+ var Eye = createLucideIcon("eye", [["path", {
460
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
461
+ key: "1nclc0"
462
+ }], ["circle", {
463
+ cx: "12",
464
+ cy: "12",
465
+ r: "3",
466
+ key: "1v7zrd"
467
+ }]]);
468
+ //#endregion
469
+ //#region src/components/PasswordInput/index.tsx
470
+ var PasswordInput = (t0) => {
471
+ const $ = c(24);
472
+ const { id, name: t1, className, placeholder, autoComplete: t2 } = t0;
473
+ const name = t1 === void 0 ? "password" : t1;
474
+ const autoComplete = t2 === void 0 ? "current-password" : t2;
475
+ const [showPassword, setShowPassword] = useState(false);
476
+ const { register, formState } = useFormContext();
477
+ const fieldError = formState.errors[name];
478
+ const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
479
+ const inputClassName = className ? `${className} pr-11` : "pr-11";
480
+ const t3 = showPassword ? "text" : "password";
481
+ const t4 = name;
482
+ let t5;
483
+ if ($[0] !== register || $[1] !== t4) {
484
+ t5 = register(t4);
485
+ $[0] = register;
486
+ $[1] = t4;
487
+ $[2] = t5;
488
+ } else t5 = $[2];
489
+ let t6;
490
+ if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
491
+ t6 = /* @__PURE__ */ jsx("input", {
492
+ id,
493
+ type: t3,
494
+ autoComplete,
495
+ className: inputClassName,
496
+ placeholder,
497
+ ...t5
498
+ });
499
+ $[3] = autoComplete;
500
+ $[4] = id;
501
+ $[5] = inputClassName;
502
+ $[6] = placeholder;
503
+ $[7] = t3;
504
+ $[8] = t5;
505
+ $[9] = t6;
506
+ } else t6 = $[9];
507
+ let t7;
508
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
509
+ t7 = () => setShowPassword(_temp);
510
+ $[10] = t7;
511
+ } else t7 = $[10];
512
+ const t8 = showPassword ? "Hide characters" : "Show characters";
513
+ let t9;
514
+ if ($[11] !== showPassword) {
515
+ t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, {
516
+ className: "h-5 w-5",
517
+ "aria-hidden": true
518
+ }) : /* @__PURE__ */ jsx(Eye, {
519
+ className: "h-5 w-5",
520
+ "aria-hidden": true
521
+ });
522
+ $[11] = showPassword;
523
+ $[12] = t9;
524
+ } else t9 = $[12];
525
+ let t10;
526
+ if ($[13] !== t8 || $[14] !== t9) {
527
+ t10 = /* @__PURE__ */ jsx("button", {
528
+ type: "button",
529
+ className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500",
530
+ onClick: t7,
531
+ "aria-label": t8,
532
+ children: t9
533
+ });
534
+ $[13] = t8;
535
+ $[14] = t9;
536
+ $[15] = t10;
537
+ } else t10 = $[15];
538
+ let t11;
539
+ if ($[16] !== t10 || $[17] !== t6) {
540
+ t11 = /* @__PURE__ */ jsxs("div", {
541
+ className: "relative",
542
+ children: [t6, t10]
543
+ });
544
+ $[16] = t10;
545
+ $[17] = t6;
546
+ $[18] = t11;
547
+ } else t11 = $[18];
548
+ let t12;
549
+ if ($[19] !== errorMessage) {
550
+ t12 = errorMessage ? /* @__PURE__ */ jsx("p", {
551
+ className: "mt-1 -mb-2 text-sm/6 text-red-500",
552
+ children: errorMessage
553
+ }) : null;
554
+ $[19] = errorMessage;
555
+ $[20] = t12;
556
+ } else t12 = $[20];
557
+ let t13;
558
+ if ($[21] !== t11 || $[22] !== t12) {
559
+ t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t12] });
560
+ $[21] = t11;
561
+ $[22] = t12;
562
+ $[23] = t13;
563
+ } else t13 = $[23];
564
+ return t13;
574
565
  };
575
566
  function _temp(prev) {
576
- return !prev;
567
+ return !prev;
577
568
  }
578
- const useResendCountdown = (t0) => {
579
- const $ = c(14);
580
- const seconds = t0 === void 0 ? 60 : t0;
581
- const [remaining, setRemaining] = useState(seconds);
582
- const [isCountingDown, setIsCountingDown] = useState(true);
583
- let t1;
584
- let t2;
585
- if ($[0] !== isCountingDown || $[1] !== seconds) {
586
- t1 = () => {
587
- if (!isCountingDown) {
588
- return;
589
- }
590
- const timer = setInterval(() => {
591
- setRemaining((prev) => {
592
- if (prev <= 1) {
593
- setIsCountingDown(false);
594
- return seconds;
595
- }
596
- return prev - 1;
597
- });
598
- }, 1e3);
599
- return () => clearInterval(timer);
600
- };
601
- t2 = [isCountingDown, seconds];
602
- $[0] = isCountingDown;
603
- $[1] = seconds;
604
- $[2] = t1;
605
- $[3] = t2;
606
- } else {
607
- t1 = $[2];
608
- t2 = $[3];
609
- }
610
- useEffect(t1, t2);
611
- let t3;
612
- if ($[4] !== seconds) {
613
- t3 = (nextSeconds) => {
614
- const value = typeof nextSeconds === "number" ? nextSeconds : seconds;
615
- setRemaining(value);
616
- setIsCountingDown(true);
617
- };
618
- $[4] = seconds;
619
- $[5] = t3;
620
- } else {
621
- t3 = $[5];
622
- }
623
- const restart = t3;
624
- const minutes = Math.floor(remaining / 60);
625
- const secs = remaining % 60;
626
- let t4;
627
- if ($[6] !== secs) {
628
- t4 = secs.toString().padStart(2, "0");
629
- $[6] = secs;
630
- $[7] = t4;
631
- } else {
632
- t4 = $[7];
633
- }
634
- const formatted = `${minutes}:${t4}`;
635
- const canResend = !isCountingDown;
636
- let t5;
637
- if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
638
- t5 = {
639
- remaining,
640
- formatted,
641
- isCountingDown,
642
- canResend,
643
- restart
644
- };
645
- $[8] = canResend;
646
- $[9] = formatted;
647
- $[10] = isCountingDown;
648
- $[11] = remaining;
649
- $[12] = restart;
650
- $[13] = t5;
651
- } else {
652
- t5 = $[13];
653
- }
654
- return t5;
569
+ //#endregion
570
+ //#region src/components/ResendCodeButton/index.tsx
571
+ var useResendCountdown = (t0) => {
572
+ const $ = c(14);
573
+ const seconds = t0 === void 0 ? 60 : t0;
574
+ const [remaining, setRemaining] = useState(seconds);
575
+ const [isCountingDown, setIsCountingDown] = useState(true);
576
+ let t1;
577
+ let t2;
578
+ if ($[0] !== isCountingDown || $[1] !== seconds) {
579
+ t1 = () => {
580
+ if (!isCountingDown) return;
581
+ const timer = setInterval(() => {
582
+ setRemaining((prev) => {
583
+ if (prev <= 1) {
584
+ setIsCountingDown(false);
585
+ return seconds;
586
+ }
587
+ return prev - 1;
588
+ });
589
+ }, 1e3);
590
+ return () => clearInterval(timer);
591
+ };
592
+ t2 = [isCountingDown, seconds];
593
+ $[0] = isCountingDown;
594
+ $[1] = seconds;
595
+ $[2] = t1;
596
+ $[3] = t2;
597
+ } else {
598
+ t1 = $[2];
599
+ t2 = $[3];
600
+ }
601
+ useEffect(t1, t2);
602
+ let t3;
603
+ if ($[4] !== seconds) {
604
+ t3 = (nextSeconds) => {
605
+ setRemaining(typeof nextSeconds === "number" ? nextSeconds : seconds);
606
+ setIsCountingDown(true);
607
+ };
608
+ $[4] = seconds;
609
+ $[5] = t3;
610
+ } else t3 = $[5];
611
+ const restart = t3;
612
+ const minutes = Math.floor(remaining / 60);
613
+ const secs = remaining % 60;
614
+ let t4;
615
+ if ($[6] !== secs) {
616
+ t4 = secs.toString().padStart(2, "0");
617
+ $[6] = secs;
618
+ $[7] = t4;
619
+ } else t4 = $[7];
620
+ const formatted = `${minutes}:${t4}`;
621
+ const canResend = !isCountingDown;
622
+ let t5;
623
+ if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
624
+ t5 = {
625
+ remaining,
626
+ formatted,
627
+ isCountingDown,
628
+ canResend,
629
+ restart
630
+ };
631
+ $[8] = canResend;
632
+ $[9] = formatted;
633
+ $[10] = isCountingDown;
634
+ $[11] = remaining;
635
+ $[12] = restart;
636
+ $[13] = t5;
637
+ } else t5 = $[13];
638
+ return t5;
655
639
  };
656
- const ResendCodeButton = ({
657
- seconds = 60,
658
- onResend,
659
- className,
660
- disabled
661
- }) => {
662
- const [isSending, setIsSending] = useState(false);
663
- const {
664
- formatted,
665
- isCountingDown,
666
- restart,
667
- canResend
668
- } = useResendCountdown(seconds);
669
- const handleClick = async () => {
670
- if (!canResend || isSending || disabled) return;
671
- try {
672
- setIsSending(true);
673
- if (onResend) {
674
- await onResend();
675
- }
676
- } finally {
677
- restart();
678
- setIsSending(false);
679
- }
680
- };
681
- const isDisabled = disabled || isCountingDown || isSending;
682
- const showCountdown = isDisabled && (isCountingDown || isSending);
683
- return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
684
- /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, disabled: isDisabled, "aria-label": "Resend code", className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className), children: "Resend code" }),
685
- showCountdown ? /* @__PURE__ */ jsxs("span", { "data-testid": "resend-countdown", className: "text-sm text-gray-500", "aria-live": "polite", children: [
686
- "(",
687
- formatted,
688
- ")"
689
- ] }) : null
690
- ] });
640
+ var ResendCodeButton = ({ seconds = 60, onResend, className, disabled }) => {
641
+ const [isSending, setIsSending] = useState(false);
642
+ const { formatted, isCountingDown, restart, canResend } = useResendCountdown(seconds);
643
+ const handleClick = async () => {
644
+ if (!canResend || isSending || disabled) return;
645
+ try {
646
+ setIsSending(true);
647
+ if (onResend) await onResend();
648
+ } finally {
649
+ restart();
650
+ setIsSending(false);
651
+ }
652
+ };
653
+ const isDisabled = disabled || isCountingDown || isSending;
654
+ const showCountdown = isDisabled && (isCountingDown || isSending);
655
+ return /* @__PURE__ */ jsxs("span", {
656
+ className: "inline-flex items-center gap-2",
657
+ children: [/* @__PURE__ */ jsx("button", {
658
+ type: "button",
659
+ onClick: handleClick,
660
+ disabled: isDisabled,
661
+ "aria-label": "Resend code",
662
+ className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className),
663
+ children: "Resend code"
664
+ }), showCountdown ? /* @__PURE__ */ jsxs("span", {
665
+ "data-testid": "resend-countdown",
666
+ className: "text-sm text-gray-500",
667
+ "aria-live": "polite",
668
+ children: [
669
+ "(",
670
+ formatted,
671
+ ")"
672
+ ]
673
+ }) : null]
674
+ });
691
675
  };
692
- export {
693
- AppleSignInButton,
694
- AuthLayout,
695
- EmailInput,
696
- PasswordInput,
697
- RememberMeCheckbox,
698
- ResendCodeButton,
699
- SignInForm,
700
- SignUpForm,
701
- b as redirectAuthMiddleware,
702
- a as requireSession,
703
- r as restrictSessionMiddleware,
704
- useResendCountdown
705
- };
706
- //# sourceMappingURL=index.js.map
676
+ //#endregion
677
+ export { AppleSignInButton, AuthLayout, EmailInput, PasswordInput, RememberMeCheckbox, ResendCodeButton, SignInForm, SignUpForm, redirectAuthMiddleware, requireSession, restrictSessionMiddleware, useResendCountdown };
678
+
679
+ //# sourceMappingURL=index.js.map