@thetechfossil/auth2 1.2.2 → 1.2.4

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.
@@ -1,17 +1,18 @@
1
+ "use client";
1
2
  import axios from 'axios';
2
- import { createContext, useState, useCallback, useEffect, useContext, useRef } from 'react';
3
+ import React3, { createContext, forwardRef, useState, useCallback, useEffect, useContext, useMemo, useRef } from 'react';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { cookies } from 'next/headers';
5
- import { redirect } from 'next/navigation';
6
- import { NextResponse } from 'next/server';
5
+ import PhoneInputWithCountry from 'react-phone-number-input';
6
+ import 'react-phone-number-input/style.css';
7
7
 
8
8
  // src/core/http-client.ts
9
9
  var HttpClient = class {
10
10
  constructor(baseUrl, defaultHeaders = {}) {
11
11
  this.csrfToken = null;
12
12
  this.frontendBaseUrl = null;
13
+ this.baseUrl = baseUrl.replace(/\/$/, "");
13
14
  this.axiosInstance = axios.create({
14
- baseURL: baseUrl.replace(/\/$/, ""),
15
+ baseURL: this.baseUrl,
15
16
  headers: {
16
17
  "Content-Type": "application/json",
17
18
  ...defaultHeaders
@@ -22,8 +23,16 @@ var HttpClient = class {
22
23
  // 30 second timeout
23
24
  });
24
25
  this.axiosInstance.interceptors.request.use(
25
- (config) => {
26
- if (this.csrfToken && ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "")) {
26
+ async (config) => {
27
+ const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
28
+ if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
29
+ try {
30
+ await this.refreshCsrfToken();
31
+ } catch (error) {
32
+ console.warn("Failed to fetch CSRF token:", error);
33
+ }
34
+ }
35
+ if (this.csrfToken && isMutatingRequest) {
27
36
  config.headers["x-csrf-token"] = this.csrfToken;
28
37
  }
29
38
  if (this.frontendBaseUrl) {
@@ -121,9 +130,6 @@ var AuthService = class {
121
130
  this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
122
131
  }
123
132
  }
124
- if (this.config.csrfEnabled && typeof window !== "undefined") {
125
- this.refreshCsrfToken();
126
- }
127
133
  }
128
134
  loadTokenFromStorage() {
129
135
  if (typeof window !== "undefined" && this.config.localStorageKey) {
@@ -225,7 +231,7 @@ var AuthService = class {
225
231
  this.saveTokenToStorage(response.token);
226
232
  return response;
227
233
  }
228
- if (response.success && response.message === "OTP sent to your email.") {
234
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
229
235
  return response;
230
236
  }
231
237
  if (response.success && response.message === "OTP verified successfully." && response.token) {
@@ -296,7 +302,7 @@ var AuthService = class {
296
302
  if (!this.token) {
297
303
  throw new Error("Not authenticated");
298
304
  }
299
- const response = await this.httpClient.post("/api/v1/user/update/user", data);
305
+ const response = await this.httpClient.post("/api/v1/user/update/profile", data);
300
306
  if (response.success && response.token) {
301
307
  this.token = response.token;
302
308
  this.httpClient.setAuthToken(response.token);
@@ -337,7 +343,7 @@ var AuthService = class {
337
343
  if (!this.token) {
338
344
  throw new Error("Not authenticated");
339
345
  }
340
- const response = await this.httpClient.post("/api/v1/user/update/avatar", { avatar });
346
+ const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
341
347
  if (response.success && response.token) {
342
348
  this.token = response.token;
343
349
  this.httpClient.setAuthToken(response.token);
@@ -400,21 +406,21 @@ var AuthService = class {
400
406
  if (!this.token) {
401
407
  throw new Error("Not authenticated");
402
408
  }
403
- const response = await this.httpClient.get("/api/v1/session");
409
+ const response = await this.httpClient.get("/api/v1/sessions");
404
410
  return response;
405
411
  }
406
412
  async revokeSession(sessionId) {
407
413
  if (!this.token) {
408
414
  throw new Error("Not authenticated");
409
415
  }
410
- const response = await this.httpClient.delete(`/api/v1/session/${sessionId}`);
416
+ const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
411
417
  return response;
412
418
  }
413
419
  async revokeAllSessions() {
414
420
  if (!this.token) {
415
421
  throw new Error("Not authenticated");
416
422
  }
417
- const response = await this.httpClient.delete("/api/v1/session/revoke/all");
423
+ const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
418
424
  this.token = null;
419
425
  this.httpClient.removeAuthToken();
420
426
  this.removeTokenFromStorage();
@@ -469,8 +475,8 @@ var useAuth = (config) => {
469
475
  const authenticated = authService.isAuthenticated();
470
476
  setIsAuthenticated(authenticated);
471
477
  if (authenticated) {
472
- const currentUser2 = authService.getCurrentUser();
473
- setUser(currentUser2);
478
+ const currentUser = authService.getCurrentUser();
479
+ setUser(currentUser);
474
480
  } else {
475
481
  setUser(null);
476
482
  }
@@ -590,6 +596,57 @@ var useAuth = (config) => {
590
596
  getUserById
591
597
  };
592
598
  };
599
+ var ThemeContext = createContext({ theme: "light", mounted: false });
600
+ function AuthThemeProvider({ children }) {
601
+ const [theme, setTheme] = useState("light");
602
+ const [mounted, setMounted] = useState(false);
603
+ useEffect(() => {
604
+ const detectTheme = () => {
605
+ const htmlElement = document.documentElement;
606
+ const bodyElement = document.body;
607
+ if (htmlElement.classList.contains("dark") || bodyElement.classList.contains("dark")) {
608
+ return "dark";
609
+ }
610
+ if (htmlElement.classList.contains("light") || bodyElement.classList.contains("light")) {
611
+ return "light";
612
+ }
613
+ const dataTheme = htmlElement.getAttribute("data-theme") || bodyElement.getAttribute("data-theme");
614
+ if (dataTheme === "dark" || dataTheme === "light") {
615
+ return dataTheme;
616
+ }
617
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
618
+ return "dark";
619
+ }
620
+ return "light";
621
+ };
622
+ const updateTheme = () => {
623
+ const detectedTheme = detectTheme();
624
+ setTheme(detectedTheme);
625
+ };
626
+ updateTheme();
627
+ setMounted(true);
628
+ const observer = new MutationObserver(updateTheme);
629
+ observer.observe(document.documentElement, {
630
+ attributes: true,
631
+ attributeFilter: ["class", "data-theme"]
632
+ });
633
+ observer.observe(document.body, {
634
+ attributes: true,
635
+ attributeFilter: ["class", "data-theme"]
636
+ });
637
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
638
+ const handleMediaChange = () => updateTheme();
639
+ mediaQuery.addEventListener("change", handleMediaChange);
640
+ return () => {
641
+ observer.disconnect();
642
+ mediaQuery.removeEventListener("change", handleMediaChange);
643
+ };
644
+ }, []);
645
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
646
+ }
647
+ function useAuthTheme() {
648
+ return useContext(ThemeContext);
649
+ }
593
650
  var AuthContext = createContext(void 0);
594
651
  var AuthProvider = ({ children, config }) => {
595
652
  const authConfig = {
@@ -605,8 +662,8 @@ var AuthProvider = ({ children, config }) => {
605
662
  const authenticated = authService.isAuthenticated();
606
663
  if (authenticated) {
607
664
  try {
608
- const currentUser2 = authService.getCurrentUser();
609
- setUser(currentUser2);
665
+ const currentUser = authService.getCurrentUser();
666
+ setUser(currentUser);
610
667
  } catch (error) {
611
668
  console.error("Failed to get current user:", error);
612
669
  setUser(null);
@@ -853,7 +910,7 @@ var AuthProvider = ({ children, config }) => {
853
910
  revokeAllSessions,
854
911
  authService
855
912
  };
856
- return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
913
+ return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx(AuthThemeProvider, { children }) });
857
914
  };
858
915
  var useAuth2 = () => {
859
916
  const context = useContext(AuthContext);
@@ -862,6 +919,267 @@ var useAuth2 = () => {
862
919
  }
863
920
  return context;
864
921
  };
922
+
923
+ // src/react/hooks/useThemeColors.ts
924
+ var lightTheme = {
925
+ bgPrimary: "var(--auth-bg-primary, #ffffff)",
926
+ bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
927
+ bgHover: "var(--auth-bg-hover, #f1f5f9)",
928
+ textPrimary: "var(--auth-text-primary, #0f172a)",
929
+ textSecondary: "var(--auth-text-secondary, #475569)",
930
+ textTertiary: "var(--auth-text-tertiary, #94a3b8)",
931
+ borderPrimary: "var(--auth-border-primary, #e2e8f0)",
932
+ borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
933
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
934
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
935
+ errorBg: "var(--auth-error-bg, #fef2f2)",
936
+ errorText: "var(--auth-error-text, #dc2626)",
937
+ errorBorder: "var(--auth-error-border, #fecaca)",
938
+ successBg: "var(--auth-success-bg, #f0fdf4)",
939
+ successText: "var(--auth-success-text, #16a34a)",
940
+ successBorder: "var(--auth-success-border, #bbf7d0)"
941
+ };
942
+ var darkTheme = {
943
+ bgPrimary: "var(--auth-bg-primary, #1f2937)",
944
+ bgSecondary: "var(--auth-bg-secondary, #111827)",
945
+ bgHover: "var(--auth-bg-hover, #374151)",
946
+ textPrimary: "var(--auth-text-primary, #f9fafb)",
947
+ textSecondary: "var(--auth-text-secondary, #e5e7eb)",
948
+ textTertiary: "var(--auth-text-tertiary, #d1d5db)",
949
+ borderPrimary: "var(--auth-border-primary, #374151)",
950
+ borderSecondary: "var(--auth-border-secondary, #4b5563)",
951
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
952
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
953
+ errorBg: "var(--auth-error-bg, #7f1d1d)",
954
+ errorText: "var(--auth-error-text, #fecaca)",
955
+ errorBorder: "var(--auth-error-border, #991b1b)",
956
+ successBg: "var(--auth-success-bg, #14532d)",
957
+ successText: "var(--auth-success-text, #bbf7d0)",
958
+ successBorder: "var(--auth-success-border, #166534)"
959
+ };
960
+ function useThemeColors() {
961
+ const { theme } = useAuthTheme();
962
+ return theme === "dark" ? darkTheme : lightTheme;
963
+ }
964
+ var CustomPhoneInput = React3.forwardRef((props, ref) => /* @__PURE__ */ jsx(
965
+ "input",
966
+ {
967
+ ...props,
968
+ ref,
969
+ className: "PhoneInputInput"
970
+ }
971
+ ));
972
+ CustomPhoneInput.displayName = "CustomPhoneInput";
973
+ var PhoneInput = ({
974
+ value,
975
+ onChange,
976
+ disabled = false,
977
+ required = false,
978
+ placeholder = "Enter phone number",
979
+ id = "phone",
980
+ style = {}
981
+ }) => {
982
+ const colors = useThemeColors();
983
+ const [defaultCountry, setDefaultCountry] = useState("US");
984
+ const styleContent = useMemo(() => `
985
+ .PhoneInput {
986
+ display: flex;
987
+ align-items: center;
988
+ gap: 8px;
989
+ }
990
+
991
+ .PhoneInputCountry {
992
+ position: relative;
993
+ align-self: stretch;
994
+ display: flex;
995
+ align-items: center;
996
+ padding: 0 8px;
997
+ border: 1px solid ${colors.borderSecondary};
998
+ border-radius: 8px;
999
+ background-color: ${colors.bgSecondary};
1000
+ transition: all 0.2s ease;
1001
+ }
1002
+
1003
+ .PhoneInputCountry:focus-within {
1004
+ border-color: ${colors.buttonPrimary};
1005
+ outline: 2px solid ${colors.buttonPrimary}40;
1006
+ }
1007
+
1008
+ .PhoneInputCountryIcon {
1009
+ width: 24px;
1010
+ height: 24px;
1011
+ margin-right: 4px;
1012
+ }
1013
+
1014
+ .PhoneInputCountryIcon--border {
1015
+ box-shadow: none;
1016
+ }
1017
+
1018
+ .PhoneInputCountrySelect {
1019
+ position: absolute;
1020
+ top: 0;
1021
+ left: 0;
1022
+ height: 100%;
1023
+ width: 100%;
1024
+ z-index: 1;
1025
+ border: 0;
1026
+ opacity: 0;
1027
+ cursor: pointer;
1028
+ color: ${colors.textPrimary};
1029
+ background-color: ${colors.bgSecondary};
1030
+ }
1031
+
1032
+ .PhoneInputCountrySelect:disabled {
1033
+ cursor: not-allowed;
1034
+ }
1035
+
1036
+ /* Dropdown menu styling */
1037
+ .PhoneInputCountrySelect option {
1038
+ background-color: ${colors.bgPrimary};
1039
+ color: ${colors.textPrimary};
1040
+ padding: 8px 12px;
1041
+ font-size: 14px;
1042
+ }
1043
+
1044
+ .PhoneInputCountrySelect option:hover,
1045
+ .PhoneInputCountrySelect option:focus,
1046
+ .PhoneInputCountrySelect option:checked {
1047
+ background-color: ${colors.buttonPrimary};
1048
+ color: white;
1049
+ }
1050
+
1051
+ .PhoneInputCountrySelectArrow {
1052
+ display: block;
1053
+ content: '';
1054
+ width: 0.3em;
1055
+ height: 0.3em;
1056
+ margin-left: 0.35em;
1057
+ border-style: solid;
1058
+ border-color: ${colors.textPrimary};
1059
+ border-top-width: 0;
1060
+ border-bottom-width: 1px;
1061
+ border-left-width: 0;
1062
+ border-right-width: 1px;
1063
+ transform: rotate(45deg);
1064
+ opacity: 0.7;
1065
+ }
1066
+
1067
+ .PhoneInputInput {
1068
+ flex: 1;
1069
+ min-width: 0;
1070
+ padding: 12px 16px;
1071
+ border: 1px solid ${colors.borderSecondary};
1072
+ border-radius: 8px;
1073
+ font-size: 16px;
1074
+ background-color: ${colors.bgSecondary};
1075
+ color: ${colors.textPrimary};
1076
+ transition: all 0.2s ease;
1077
+ -webkit-text-fill-color: ${colors.textPrimary};
1078
+ -webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
1079
+ }
1080
+
1081
+ .PhoneInputInput:focus {
1082
+ border-color: ${colors.buttonPrimary};
1083
+ outline: 2px solid ${colors.buttonPrimary}40;
1084
+ }
1085
+
1086
+ .PhoneInputInput:disabled {
1087
+ cursor: not-allowed;
1088
+ opacity: 0.6;
1089
+ }
1090
+
1091
+ .PhoneInputInput::placeholder {
1092
+ color: ${colors.textTertiary};
1093
+ opacity: 0.6;
1094
+ }
1095
+ `, [colors]);
1096
+ useEffect(() => {
1097
+ const detectCountry = async () => {
1098
+ try {
1099
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1100
+ const timezoneToCountry = {
1101
+ "America/New_York": "US",
1102
+ "America/Chicago": "US",
1103
+ "America/Denver": "US",
1104
+ "America/Los_Angeles": "US",
1105
+ "America/Phoenix": "US",
1106
+ "America/Anchorage": "US",
1107
+ "Pacific/Honolulu": "US",
1108
+ "Europe/London": "GB",
1109
+ "Europe/Paris": "FR",
1110
+ "Europe/Berlin": "DE",
1111
+ "Europe/Rome": "IT",
1112
+ "Europe/Madrid": "ES",
1113
+ "Asia/Dubai": "AE",
1114
+ "Asia/Kolkata": "IN",
1115
+ "Asia/Shanghai": "CN",
1116
+ "Asia/Tokyo": "JP",
1117
+ "Asia/Seoul": "KR",
1118
+ "Asia/Singapore": "SG",
1119
+ "Asia/Hong_Kong": "HK",
1120
+ "Australia/Sydney": "AU",
1121
+ "Pacific/Auckland": "NZ",
1122
+ "America/Toronto": "CA",
1123
+ "America/Vancouver": "CA",
1124
+ "America/Mexico_City": "MX",
1125
+ "America/Sao_Paulo": "BR",
1126
+ "America/Buenos_Aires": "AR",
1127
+ "Africa/Cairo": "EG",
1128
+ "Africa/Johannesburg": "ZA",
1129
+ "Africa/Lagos": "NG",
1130
+ "Africa/Nairobi": "KE"
1131
+ };
1132
+ const detectedCountry = timezoneToCountry[timezone];
1133
+ if (detectedCountry) {
1134
+ setDefaultCountry(detectedCountry);
1135
+ return;
1136
+ }
1137
+ const response = await fetch("https://ipapi.co/json/", {
1138
+ signal: AbortSignal.timeout(3e3)
1139
+ // 3 second timeout
1140
+ });
1141
+ if (response.ok) {
1142
+ const data = await response.json();
1143
+ if (data.country_code) {
1144
+ setDefaultCountry(data.country_code);
1145
+ }
1146
+ }
1147
+ } catch (error) {
1148
+ console.log("Country detection failed, using default US");
1149
+ }
1150
+ };
1151
+ detectCountry();
1152
+ }, []);
1153
+ const handleChange = useMemo(() => (val) => {
1154
+ onChange(val || "");
1155
+ }, [onChange]);
1156
+ return /* @__PURE__ */ jsxs(
1157
+ "div",
1158
+ {
1159
+ style: {
1160
+ width: "100%",
1161
+ ...style
1162
+ },
1163
+ children: [
1164
+ /* @__PURE__ */ jsx("style", { children: styleContent }),
1165
+ /* @__PURE__ */ jsx(
1166
+ PhoneInputWithCountry,
1167
+ {
1168
+ id,
1169
+ international: true,
1170
+ defaultCountry,
1171
+ value: value || "",
1172
+ onChange: handleChange,
1173
+ disabled,
1174
+ placeholder,
1175
+ inputComponent: CustomPhoneInput
1176
+ },
1177
+ id
1178
+ )
1179
+ ]
1180
+ }
1181
+ );
1182
+ };
865
1183
  var LoginForm = ({
866
1184
  onSuccess,
867
1185
  onLoginSuccess,
@@ -871,7 +1189,10 @@ var LoginForm = ({
871
1189
  oauthProviders = ["google", "github"],
872
1190
  showOAuthButtons = true
873
1191
  }) => {
1192
+ const colors = useThemeColors();
874
1193
  const [email, setEmail] = useState("");
1194
+ const [phoneNumber, setPhoneNumber] = useState("");
1195
+ const [usePhone, setUsePhone] = useState(false);
875
1196
  const [password, setPassword] = useState("");
876
1197
  const [usePassword, setUsePassword] = useState(false);
877
1198
  const [showPassword, setShowPassword] = useState(false);
@@ -879,7 +1200,7 @@ var LoginForm = ({
879
1200
  const [error, setError] = useState(null);
880
1201
  const [rememberMe, setRememberMe] = useState(false);
881
1202
  const { login } = useAuth({
882
- baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
1203
+ baseUrl: config?.baseUrl || "http://localhost:7000"
883
1204
  });
884
1205
  const handleSubmit = async (e) => {
885
1206
  e.preventDefault();
@@ -887,20 +1208,28 @@ var LoginForm = ({
887
1208
  setError(null);
888
1209
  try {
889
1210
  let response;
1211
+ const loginData = {};
1212
+ if (usePhone && phoneNumber) {
1213
+ loginData.phoneNumber = phoneNumber;
1214
+ } else if (email) {
1215
+ loginData.email = email;
1216
+ }
890
1217
  if (usePassword) {
891
- response = await login({ email, password });
1218
+ loginData.password = password;
1219
+ response = await login(loginData);
892
1220
  } else {
893
- response = await login({ email });
1221
+ response = await login(loginData);
894
1222
  }
895
1223
  if (response.success) {
896
1224
  onSuccess?.(response);
897
1225
  if (onLoginSuccess) {
898
- if (response.message === "OTP sent to your email.") {
899
- onLoginSuccess(email, true);
1226
+ const identifier = usePhone ? phoneNumber : email;
1227
+ if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
1228
+ onLoginSuccess(identifier, true);
900
1229
  } else if (response.token) {
901
- onLoginSuccess(email, false);
1230
+ onLoginSuccess(identifier, false);
902
1231
  } else {
903
- onLoginSuccess(email, true);
1232
+ onLoginSuccess(identifier, true);
904
1233
  }
905
1234
  }
906
1235
  } else {
@@ -922,43 +1251,53 @@ var LoginForm = ({
922
1251
  return /* @__PURE__ */ jsx("div", { style: {
923
1252
  maxWidth: "400px",
924
1253
  margin: "0 auto",
925
- padding: "30px",
1254
+ padding: "24px",
926
1255
  borderRadius: "12px",
927
1256
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
928
- backgroundColor: "#ffffff",
929
- border: "1px solid #eaeaea"
1257
+ backgroundColor: colors.bgPrimary,
1258
+ border: `1px solid ${colors.borderPrimary}`
930
1259
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
931
1260
  display: "flex",
932
1261
  flexDirection: "column"
933
1262
  }, children: [
934
1263
  /* @__PURE__ */ jsx("h2", { style: {
935
1264
  textAlign: "center",
936
- marginBottom: "24px",
937
- color: "#1f2937",
1265
+ marginBottom: "20px",
1266
+ color: colors.textPrimary,
938
1267
  fontSize: "24px",
939
1268
  fontWeight: 600
940
1269
  }, children: usePassword ? "Login with Password" : "Login with OTP" }),
941
1270
  error && /* @__PURE__ */ jsx("div", { style: {
942
1271
  padding: "12px 16px",
943
- marginBottom: "20px",
944
- backgroundColor: "#f8d7da",
945
- color: "#721c24",
946
- border: "1px solid #f5c6cb",
1272
+ marginBottom: "16px",
1273
+ backgroundColor: colors.errorBg,
1274
+ color: colors.errorText,
1275
+ border: `1px solid ${colors.errorBorder}`,
947
1276
  borderRadius: "8px",
948
1277
  fontSize: "14px",
949
1278
  fontWeight: 500
950
1279
  }, children: error }),
951
1280
  /* @__PURE__ */ jsxs("div", { style: {
952
- marginBottom: "20px"
1281
+ marginBottom: "16px"
953
1282
  }, children: [
954
- /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
1283
+ /* @__PURE__ */ jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
955
1284
  display: "block",
956
1285
  marginBottom: "8px",
957
1286
  fontWeight: 500,
958
- color: "#374151",
1287
+ color: colors.textSecondary,
959
1288
  fontSize: "14px"
960
- }, children: "Email:" }),
961
- /* @__PURE__ */ jsx(
1289
+ }, children: usePhone ? "Phone Number:" : "Email:" }),
1290
+ usePhone ? /* @__PURE__ */ jsx(
1291
+ PhoneInput,
1292
+ {
1293
+ id: "phone",
1294
+ value: phoneNumber,
1295
+ onChange: setPhoneNumber,
1296
+ required: true,
1297
+ disabled: isLoading,
1298
+ placeholder: "1234567890"
1299
+ }
1300
+ ) : /* @__PURE__ */ jsx(
962
1301
  "input",
963
1302
  {
964
1303
  id: "email",
@@ -970,27 +1309,48 @@ var LoginForm = ({
970
1309
  style: {
971
1310
  width: "100%",
972
1311
  padding: "12px 16px",
973
- border: "1px solid #ddd",
1312
+ border: `1px solid ${colors.borderSecondary}`,
974
1313
  borderRadius: "8px",
975
1314
  fontSize: "16px",
976
1315
  boxSizing: "border-box",
977
- color: "#111827",
1316
+ color: colors.textPrimary,
978
1317
  transition: "all 0.2s ease",
979
- backgroundColor: "#ffffff"
1318
+ backgroundColor: colors.bgSecondary
980
1319
  },
981
1320
  placeholder: "Enter your email"
982
1321
  }
1322
+ ),
1323
+ /* @__PURE__ */ jsx(
1324
+ "button",
1325
+ {
1326
+ type: "button",
1327
+ onClick: () => setUsePhone(!usePhone),
1328
+ disabled: isLoading,
1329
+ style: {
1330
+ marginTop: "8px",
1331
+ background: "none",
1332
+ border: "none",
1333
+ color: colors.buttonPrimary,
1334
+ textDecoration: "none",
1335
+ cursor: "pointer",
1336
+ fontSize: "13px",
1337
+ fontWeight: 500,
1338
+ padding: "0",
1339
+ transition: "color 0.2s ease"
1340
+ },
1341
+ children: usePhone ? "Use email instead" : "Use phone number instead"
1342
+ }
983
1343
  )
984
1344
  ] }),
985
1345
  usePassword && /* @__PURE__ */ jsxs("div", { style: {
986
- marginBottom: "20px",
1346
+ marginBottom: "16px",
987
1347
  position: "relative"
988
1348
  }, children: [
989
1349
  /* @__PURE__ */ jsx("label", { htmlFor: "login-password", style: {
990
1350
  display: "block",
991
1351
  marginBottom: "8px",
992
1352
  fontWeight: 500,
993
- color: "#555",
1353
+ color: colors.textSecondary,
994
1354
  fontSize: "14px"
995
1355
  }, children: "Password:" }),
996
1356
  /* @__PURE__ */ jsx(
@@ -1005,13 +1365,13 @@ var LoginForm = ({
1005
1365
  style: {
1006
1366
  width: "100%",
1007
1367
  padding: "12px 16px",
1008
- border: "1px solid #ddd",
1368
+ border: `1px solid ${colors.borderSecondary}`,
1009
1369
  borderRadius: "8px",
1010
1370
  fontSize: "16px",
1011
1371
  boxSizing: "border-box",
1012
- color: "#333",
1372
+ color: colors.textPrimary,
1013
1373
  transition: "all 0.2s ease",
1014
- backgroundColor: "#fafafa"
1374
+ backgroundColor: colors.bgSecondary
1015
1375
  },
1016
1376
  placeholder: "Enter your password"
1017
1377
  }
@@ -1029,7 +1389,7 @@ var LoginForm = ({
1029
1389
  background: "none",
1030
1390
  border: "none",
1031
1391
  cursor: "pointer",
1032
- color: "#666",
1392
+ color: colors.textTertiary,
1033
1393
  fontSize: "14px"
1034
1394
  },
1035
1395
  children: showPassword ? "Hide" : "Show"
@@ -1039,8 +1399,8 @@ var LoginForm = ({
1039
1399
  usePassword && /* @__PURE__ */ jsxs("div", { style: {
1040
1400
  display: "flex",
1041
1401
  alignItems: "center",
1042
- marginBottom: "16px",
1043
- marginTop: "8px"
1402
+ marginBottom: "12px",
1403
+ marginTop: "4px"
1044
1404
  }, children: [
1045
1405
  /* @__PURE__ */ jsx(
1046
1406
  "input",
@@ -1064,7 +1424,7 @@ var LoginForm = ({
1064
1424
  htmlFor: "remember-me",
1065
1425
  style: {
1066
1426
  fontSize: "14px",
1067
- color: "#666",
1427
+ color: colors.textSecondary,
1068
1428
  cursor: "pointer",
1069
1429
  userSelect: "none"
1070
1430
  },
@@ -1079,7 +1439,7 @@ var LoginForm = ({
1079
1439
  disabled: isLoading,
1080
1440
  style: {
1081
1441
  padding: "14px",
1082
- backgroundColor: "#007bff",
1442
+ backgroundColor: colors.buttonPrimary,
1083
1443
  color: "white",
1084
1444
  border: "none",
1085
1445
  borderRadius: "8px",
@@ -1087,16 +1447,16 @@ var LoginForm = ({
1087
1447
  fontWeight: 600,
1088
1448
  cursor: "pointer",
1089
1449
  transition: "all 0.2s ease",
1090
- marginTop: "8px"
1450
+ marginTop: "4px"
1091
1451
  },
1092
1452
  children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
1093
1453
  }
1094
1454
  ),
1095
1455
  /* @__PURE__ */ jsx("div", { style: {
1096
1456
  textAlign: "center",
1097
- marginTop: "20px",
1098
- paddingTop: "20px",
1099
- borderTop: "1px solid #eee"
1457
+ marginTop: "16px",
1458
+ paddingTop: "16px",
1459
+ borderTop: `1px solid ${colors.borderPrimary}`
1100
1460
  }, children: /* @__PURE__ */ jsx(
1101
1461
  "button",
1102
1462
  {
@@ -1106,7 +1466,7 @@ var LoginForm = ({
1106
1466
  style: {
1107
1467
  background: "none",
1108
1468
  border: "none",
1109
- color: "#007bff",
1469
+ color: colors.buttonPrimary,
1110
1470
  textDecoration: "none",
1111
1471
  cursor: "pointer",
1112
1472
  fontSize: "14px",
@@ -1118,9 +1478,9 @@ var LoginForm = ({
1118
1478
  }
1119
1479
  ) }),
1120
1480
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
1121
- marginTop: "20px",
1122
- paddingTop: "20px",
1123
- borderTop: "1px solid #eee"
1481
+ marginTop: "16px",
1482
+ paddingTop: "16px",
1483
+ borderTop: `1px solid ${colors.borderPrimary}`
1124
1484
  }, children: [
1125
1485
  /* @__PURE__ */ jsxs("div", { style: {
1126
1486
  position: "relative",
@@ -1132,15 +1492,15 @@ var LoginForm = ({
1132
1492
  left: 0,
1133
1493
  right: 0,
1134
1494
  height: "1px",
1135
- backgroundColor: "#eee"
1495
+ backgroundColor: colors.borderPrimary
1136
1496
  } }),
1137
1497
  /* @__PURE__ */ jsx("div", { style: {
1138
1498
  position: "relative",
1139
1499
  textAlign: "center"
1140
1500
  }, children: /* @__PURE__ */ jsx("span", { style: {
1141
- backgroundColor: "#ffffff",
1501
+ backgroundColor: colors.bgPrimary,
1142
1502
  padding: "0 12px",
1143
- color: "#666",
1503
+ color: colors.textSecondary,
1144
1504
  fontSize: "14px"
1145
1505
  }, children: "Or continue with" }) })
1146
1506
  ] }),
@@ -1159,10 +1519,10 @@ var LoginForm = ({
1159
1519
  justifyContent: "center",
1160
1520
  gap: "8px",
1161
1521
  padding: "10px 16px",
1162
- backgroundColor: "#ffffff",
1163
- border: "1px solid #ddd",
1522
+ backgroundColor: colors.bgPrimary,
1523
+ border: `1px solid ${colors.borderSecondary}`,
1164
1524
  borderRadius: "8px",
1165
- color: "#333",
1525
+ color: colors.textPrimary,
1166
1526
  textDecoration: "none",
1167
1527
  fontSize: "14px",
1168
1528
  fontWeight: 500,
@@ -1170,12 +1530,12 @@ var LoginForm = ({
1170
1530
  transition: "all 0.2s ease"
1171
1531
  },
1172
1532
  onMouseEnter: (e) => {
1173
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1174
- e.currentTarget.style.borderColor = "#007bff";
1533
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1534
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1175
1535
  },
1176
1536
  onMouseLeave: (e) => {
1177
- e.currentTarget.style.backgroundColor = "#ffffff";
1178
- e.currentTarget.style.borderColor = "#ddd";
1537
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1538
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1179
1539
  },
1180
1540
  children: [
1181
1541
  /* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1250,11 +1610,11 @@ var LoginForm = ({
1250
1610
  ] }),
1251
1611
  showRegisterLink && /* @__PURE__ */ jsx("div", { style: {
1252
1612
  textAlign: "center",
1253
- marginTop: "20px",
1254
- paddingTop: "20px",
1255
- borderTop: "1px solid #eee"
1613
+ marginTop: "16px",
1614
+ paddingTop: "16px",
1615
+ borderTop: `1px solid ${colors.borderPrimary}`
1256
1616
  }, children: /* @__PURE__ */ jsxs("p", { style: {
1257
- color: "#666",
1617
+ color: colors.textSecondary,
1258
1618
  fontSize: "14px"
1259
1619
  }, children: [
1260
1620
  "Don't have an account?",
@@ -1268,7 +1628,7 @@ var LoginForm = ({
1268
1628
  style: {
1269
1629
  background: "none",
1270
1630
  border: "none",
1271
- color: "#007bff",
1631
+ color: colors.buttonPrimary,
1272
1632
  textDecoration: "none",
1273
1633
  cursor: "pointer",
1274
1634
  fontSize: "14px",
@@ -1288,10 +1648,13 @@ var RegisterForm = ({
1288
1648
  showLoginLink = true,
1289
1649
  authConfig,
1290
1650
  oauthProviders = ["google", "github"],
1291
- showOAuthButtons = true
1651
+ showOAuthButtons = true,
1652
+ invitationToken
1292
1653
  }) => {
1654
+ const colors = useThemeColors();
1293
1655
  const [name, setName] = useState("");
1294
1656
  const [email, setEmail] = useState("");
1657
+ const [phoneNumber, setPhoneNumber] = useState("");
1295
1658
  const [password, setPassword] = useState("");
1296
1659
  const [confirmPassword, setConfirmPassword] = useState("");
1297
1660
  const [isLoading, setIsLoading] = useState(false);
@@ -1320,7 +1683,7 @@ var RegisterForm = ({
1320
1683
  };
1321
1684
  getPasswordStrength(password);
1322
1685
  const config = authConfig || {
1323
- baseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || window.location.origin : "http://localhost:7000"
1686
+ baseUrl: "http://localhost:7000"
1324
1687
  };
1325
1688
  const { register } = useAuth(config);
1326
1689
  const handleSubmit = async (e) => {
@@ -1338,17 +1701,45 @@ var RegisterForm = ({
1338
1701
  return;
1339
1702
  }
1340
1703
  try {
1341
- const registerData = {
1342
- name,
1343
- email,
1344
- password,
1345
- frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1346
- };
1347
- const response = await register(registerData);
1348
- if (response.success) {
1349
- onRegisterSuccess?.();
1704
+ if (invitationToken) {
1705
+ const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
1706
+ method: "POST",
1707
+ headers: {
1708
+ "Content-Type": "application/json"
1709
+ },
1710
+ body: JSON.stringify({
1711
+ name,
1712
+ email,
1713
+ password,
1714
+ phoneNumber: phoneNumber || void 0,
1715
+ invitationToken
1716
+ })
1717
+ });
1718
+ const data = await response.json();
1719
+ if (response.ok && data.success) {
1720
+ if (typeof window !== "undefined" && data.token) {
1721
+ localStorage.setItem("auth_token", data.token);
1722
+ }
1723
+ onRegisterSuccess?.();
1724
+ } else {
1725
+ setError(data.error || data.message || "Registration failed");
1726
+ }
1350
1727
  } else {
1351
- setError(response.message || "Registration failed");
1728
+ const registerData = {
1729
+ name,
1730
+ password,
1731
+ frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1732
+ };
1733
+ if (email)
1734
+ registerData.email = email;
1735
+ if (phoneNumber)
1736
+ registerData.phoneNumber = phoneNumber;
1737
+ const response = await register(registerData);
1738
+ if (response.success) {
1739
+ onRegisterSuccess?.();
1740
+ } else {
1741
+ setError(response.message || "Registration failed");
1742
+ }
1352
1743
  }
1353
1744
  } catch (err) {
1354
1745
  setError(err instanceof Error ? err.message : "An unknown error occurred");
@@ -1359,40 +1750,40 @@ var RegisterForm = ({
1359
1750
  return /* @__PURE__ */ jsx("div", { style: {
1360
1751
  maxWidth: "400px",
1361
1752
  margin: "0 auto",
1362
- padding: "30px",
1753
+ padding: "24px",
1363
1754
  borderRadius: "12px",
1364
1755
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1365
- backgroundColor: "#ffffff",
1366
- border: "1px solid #eaeaea"
1756
+ backgroundColor: colors.bgPrimary,
1757
+ border: `1px solid ${colors.borderPrimary}`
1367
1758
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
1368
1759
  display: "flex",
1369
1760
  flexDirection: "column"
1370
1761
  }, children: [
1371
1762
  /* @__PURE__ */ jsx("h2", { style: {
1372
1763
  textAlign: "center",
1373
- marginBottom: "24px",
1374
- color: "#1f2937",
1764
+ marginBottom: "20px",
1765
+ color: colors.textPrimary,
1375
1766
  fontSize: "24px",
1376
1767
  fontWeight: 600
1377
1768
  }, children: "Register" }),
1378
1769
  error && /* @__PURE__ */ jsx("div", { style: {
1379
1770
  padding: "12px 16px",
1380
- marginBottom: "20px",
1381
- backgroundColor: "#f8d7da",
1382
- color: "#721c24",
1383
- border: "1px solid #f5c6cb",
1771
+ marginBottom: "16px",
1772
+ backgroundColor: colors.errorBg,
1773
+ color: colors.errorText,
1774
+ border: `1px solid ${colors.errorBorder}`,
1384
1775
  borderRadius: "8px",
1385
1776
  fontSize: "14px",
1386
1777
  fontWeight: 500
1387
1778
  }, children: error }),
1388
1779
  /* @__PURE__ */ jsxs("div", { style: {
1389
- marginBottom: "20px"
1780
+ marginBottom: "16px"
1390
1781
  }, children: [
1391
1782
  /* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
1392
1783
  display: "block",
1393
1784
  marginBottom: "8px",
1394
1785
  fontWeight: 500,
1395
- color: "#374151",
1786
+ color: colors.textSecondary,
1396
1787
  fontSize: "14px"
1397
1788
  }, children: "Name:" }),
1398
1789
  /* @__PURE__ */ jsx(
@@ -1407,26 +1798,26 @@ var RegisterForm = ({
1407
1798
  style: {
1408
1799
  width: "100%",
1409
1800
  padding: "12px 16px",
1410
- border: "1px solid #ddd",
1801
+ border: `1px solid ${colors.borderSecondary}`,
1411
1802
  borderRadius: "8px",
1412
1803
  fontSize: "16px",
1413
1804
  boxSizing: "border-box",
1414
- color: "#111827",
1805
+ color: colors.textPrimary,
1415
1806
  transition: "all 0.2s ease",
1416
- backgroundColor: "#ffffff"
1807
+ backgroundColor: colors.bgSecondary
1417
1808
  },
1418
1809
  placeholder: "Enter your name"
1419
1810
  }
1420
1811
  )
1421
1812
  ] }),
1422
1813
  /* @__PURE__ */ jsxs("div", { style: {
1423
- marginBottom: "20px"
1814
+ marginBottom: "16px"
1424
1815
  }, children: [
1425
1816
  /* @__PURE__ */ jsx("label", { htmlFor: "register-email", style: {
1426
1817
  display: "block",
1427
1818
  marginBottom: "8px",
1428
1819
  fontWeight: 500,
1429
- color: "#555",
1820
+ color: colors.textSecondary,
1430
1821
  fontSize: "14px"
1431
1822
  }, children: "Email:" }),
1432
1823
  /* @__PURE__ */ jsx(
@@ -1436,31 +1827,52 @@ var RegisterForm = ({
1436
1827
  type: "email",
1437
1828
  value: email,
1438
1829
  onChange: (e) => setEmail(e.target.value),
1439
- required: true,
1830
+ required: !phoneNumber,
1440
1831
  disabled: isLoading,
1441
1832
  style: {
1442
1833
  width: "100%",
1443
1834
  padding: "12px 16px",
1444
- border: "1px solid #ddd",
1835
+ border: `1px solid ${colors.borderSecondary}`,
1445
1836
  borderRadius: "8px",
1446
1837
  fontSize: "16px",
1447
1838
  boxSizing: "border-box",
1448
- color: "#333",
1839
+ color: colors.textPrimary,
1449
1840
  transition: "all 0.2s ease",
1450
- backgroundColor: "#fafafa"
1841
+ backgroundColor: colors.bgSecondary
1451
1842
  },
1452
1843
  placeholder: "Enter your email"
1453
1844
  }
1454
1845
  )
1455
1846
  ] }),
1456
1847
  /* @__PURE__ */ jsxs("div", { style: {
1457
- marginBottom: "20px"
1848
+ marginBottom: "16px"
1849
+ }, children: [
1850
+ /* @__PURE__ */ jsx("label", { htmlFor: "register-phone", style: {
1851
+ display: "block",
1852
+ marginBottom: "8px",
1853
+ fontWeight: 500,
1854
+ color: colors.textSecondary,
1855
+ fontSize: "14px"
1856
+ }, children: "Phone Number (Optional):" }),
1857
+ /* @__PURE__ */ jsx(
1858
+ PhoneInput,
1859
+ {
1860
+ id: "register-phone",
1861
+ value: phoneNumber,
1862
+ onChange: setPhoneNumber,
1863
+ disabled: isLoading,
1864
+ placeholder: "1234567890"
1865
+ }
1866
+ )
1867
+ ] }),
1868
+ /* @__PURE__ */ jsxs("div", { style: {
1869
+ marginBottom: "16px"
1458
1870
  }, children: [
1459
1871
  /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
1460
1872
  display: "block",
1461
1873
  marginBottom: "8px",
1462
1874
  fontWeight: 500,
1463
- color: "#555",
1875
+ color: colors.textSecondary,
1464
1876
  fontSize: "14px"
1465
1877
  }, children: "Password:" }),
1466
1878
  /* @__PURE__ */ jsx(
@@ -1475,13 +1887,13 @@ var RegisterForm = ({
1475
1887
  style: {
1476
1888
  width: "100%",
1477
1889
  padding: "12px 16px",
1478
- border: "1px solid #ddd",
1890
+ border: `1px solid ${colors.borderSecondary}`,
1479
1891
  borderRadius: "8px",
1480
1892
  fontSize: "16px",
1481
1893
  boxSizing: "border-box",
1482
- color: "#333",
1894
+ color: colors.textPrimary,
1483
1895
  transition: "all 0.2s ease",
1484
- backgroundColor: "#fafafa"
1896
+ backgroundColor: colors.bgSecondary
1485
1897
  },
1486
1898
  placeholder: "Enter your password",
1487
1899
  minLength: 6
@@ -1489,13 +1901,13 @@ var RegisterForm = ({
1489
1901
  )
1490
1902
  ] }),
1491
1903
  /* @__PURE__ */ jsxs("div", { style: {
1492
- marginBottom: "20px"
1904
+ marginBottom: "16px"
1493
1905
  }, children: [
1494
1906
  /* @__PURE__ */ jsx("label", { htmlFor: "confirm-password", style: {
1495
1907
  display: "block",
1496
1908
  marginBottom: "8px",
1497
1909
  fontWeight: 500,
1498
- color: "#555",
1910
+ color: colors.textSecondary,
1499
1911
  fontSize: "14px"
1500
1912
  }, children: "Confirm Password:" }),
1501
1913
  /* @__PURE__ */ jsx(
@@ -1510,13 +1922,13 @@ var RegisterForm = ({
1510
1922
  style: {
1511
1923
  width: "100%",
1512
1924
  padding: "12px 16px",
1513
- border: "1px solid #ddd",
1925
+ border: `1px solid ${colors.borderSecondary}`,
1514
1926
  borderRadius: "8px",
1515
1927
  fontSize: "16px",
1516
1928
  boxSizing: "border-box",
1517
- color: "#333",
1929
+ color: colors.textPrimary,
1518
1930
  transition: "all 0.2s ease",
1519
- backgroundColor: "#fafafa"
1931
+ backgroundColor: colors.bgSecondary
1520
1932
  },
1521
1933
  placeholder: "Confirm your password"
1522
1934
  }
@@ -1529,7 +1941,7 @@ var RegisterForm = ({
1529
1941
  disabled: isLoading,
1530
1942
  style: {
1531
1943
  padding: "14px",
1532
- backgroundColor: "#007bff",
1944
+ backgroundColor: colors.buttonPrimary,
1533
1945
  color: "white",
1534
1946
  border: "none",
1535
1947
  borderRadius: "8px",
@@ -1537,15 +1949,15 @@ var RegisterForm = ({
1537
1949
  fontWeight: 600,
1538
1950
  cursor: "pointer",
1539
1951
  transition: "all 0.2s ease",
1540
- marginTop: "8px"
1952
+ marginTop: "4px"
1541
1953
  },
1542
1954
  children: isLoading ? "Registering..." : "Register"
1543
1955
  }
1544
1956
  ),
1545
1957
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
1546
- marginTop: "20px",
1547
- paddingTop: "20px",
1548
- borderTop: "1px solid #eee"
1958
+ marginTop: "16px",
1959
+ paddingTop: "16px",
1960
+ borderTop: `1px solid ${colors.borderPrimary}`
1549
1961
  }, children: [
1550
1962
  /* @__PURE__ */ jsxs("div", { style: {
1551
1963
  position: "relative",
@@ -1557,15 +1969,15 @@ var RegisterForm = ({
1557
1969
  left: 0,
1558
1970
  right: 0,
1559
1971
  height: "1px",
1560
- backgroundColor: "#eee"
1972
+ backgroundColor: colors.borderPrimary
1561
1973
  } }),
1562
1974
  /* @__PURE__ */ jsx("div", { style: {
1563
1975
  position: "relative",
1564
1976
  textAlign: "center"
1565
1977
  }, children: /* @__PURE__ */ jsx("span", { style: {
1566
- backgroundColor: "#ffffff",
1978
+ backgroundColor: colors.bgPrimary,
1567
1979
  padding: "0 12px",
1568
- color: "#666",
1980
+ color: colors.textSecondary,
1569
1981
  fontSize: "14px"
1570
1982
  }, children: "Or continue with" }) })
1571
1983
  ] }),
@@ -1584,10 +1996,10 @@ var RegisterForm = ({
1584
1996
  justifyContent: "center",
1585
1997
  gap: "8px",
1586
1998
  padding: "10px 16px",
1587
- backgroundColor: "#ffffff",
1588
- border: "1px solid #ddd",
1999
+ backgroundColor: colors.bgPrimary,
2000
+ border: `1px solid ${colors.borderSecondary}`,
1589
2001
  borderRadius: "8px",
1590
- color: "#333",
2002
+ color: colors.textPrimary,
1591
2003
  textDecoration: "none",
1592
2004
  fontSize: "14px",
1593
2005
  fontWeight: 500,
@@ -1595,12 +2007,12 @@ var RegisterForm = ({
1595
2007
  transition: "all 0.2s ease"
1596
2008
  },
1597
2009
  onMouseEnter: (e) => {
1598
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1599
- e.currentTarget.style.borderColor = "#007bff";
2010
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2011
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1600
2012
  },
1601
2013
  onMouseLeave: (e) => {
1602
- e.currentTarget.style.backgroundColor = "#ffffff";
1603
- e.currentTarget.style.borderColor = "#ddd";
2014
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
2015
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1604
2016
  },
1605
2017
  children: [
1606
2018
  /* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1675,11 +2087,11 @@ var RegisterForm = ({
1675
2087
  ] }),
1676
2088
  showLoginLink && /* @__PURE__ */ jsx("div", { style: {
1677
2089
  textAlign: "center",
1678
- marginTop: "20px",
1679
- paddingTop: "20px",
1680
- borderTop: "1px solid #eee"
2090
+ marginTop: "16px",
2091
+ paddingTop: "16px",
2092
+ borderTop: `1px solid ${colors.borderPrimary}`
1681
2093
  }, children: /* @__PURE__ */ jsxs("p", { style: {
1682
- color: "#666",
2094
+ color: colors.textSecondary,
1683
2095
  fontSize: "14px"
1684
2096
  }, children: [
1685
2097
  "Already have an account?",
@@ -1693,7 +2105,7 @@ var RegisterForm = ({
1693
2105
  style: {
1694
2106
  background: "none",
1695
2107
  border: "none",
1696
- color: "#007bff",
2108
+ color: colors.buttonPrimary,
1697
2109
  textDecoration: "none",
1698
2110
  cursor: "pointer",
1699
2111
  fontSize: "14px",
@@ -1710,15 +2122,17 @@ var RegisterForm = ({
1710
2122
  var OtpForm = ({
1711
2123
  email,
1712
2124
  onVerifySuccess,
1713
- onBackToLogin
2125
+ onBackToLogin,
2126
+ baseUrl
1714
2127
  }) => {
2128
+ const colors = useThemeColors();
1715
2129
  const [otp, setOtp] = useState("");
1716
2130
  const [isLoading, setIsLoading] = useState(false);
1717
2131
  const [error, setError] = useState(null);
1718
2132
  const [resendCooldown, setResendCooldown] = useState(0);
1719
2133
  const [resendLoading, setResendLoading] = useState(false);
1720
2134
  const { verify, login } = useAuth({
1721
- baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost:7000"
2135
+ baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
1722
2136
  });
1723
2137
  const handleSubmit = async (e) => {
1724
2138
  e.preventDefault();
@@ -1781,8 +2195,8 @@ var OtpForm = ({
1781
2195
  padding: "30px",
1782
2196
  borderRadius: "12px",
1783
2197
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1784
- backgroundColor: "#ffffff",
1785
- border: "1px solid #eaeaea"
2198
+ backgroundColor: colors.bgPrimary,
2199
+ border: `1px solid ${colors.borderPrimary}`
1786
2200
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
1787
2201
  display: "flex",
1788
2202
  flexDirection: "column"
@@ -1790,25 +2204,25 @@ var OtpForm = ({
1790
2204
  /* @__PURE__ */ jsx("h2", { style: {
1791
2205
  textAlign: "center",
1792
2206
  marginBottom: "24px",
1793
- color: "#1f2937",
2207
+ color: colors.textPrimary,
1794
2208
  fontSize: "24px",
1795
2209
  fontWeight: 600
1796
2210
  }, children: "Verify OTP" }),
1797
2211
  /* @__PURE__ */ jsxs("p", { style: {
1798
2212
  textAlign: "center",
1799
2213
  marginBottom: "24px",
1800
- color: "#4b5563",
2214
+ color: colors.textSecondary,
1801
2215
  fontSize: "14px"
1802
2216
  }, children: [
1803
2217
  "Enter the 6-digit code sent to ",
1804
- /* @__PURE__ */ jsx("strong", { style: { color: "#111827" }, children: email })
2218
+ /* @__PURE__ */ jsx("strong", { style: { color: colors.textPrimary }, children: email })
1805
2219
  ] }),
1806
2220
  error && /* @__PURE__ */ jsx("div", { style: {
1807
2221
  padding: "12px 16px",
1808
2222
  marginBottom: "20px",
1809
- backgroundColor: "#f8d7da",
1810
- color: "#721c24",
1811
- border: "1px solid #f5c6cb",
2223
+ backgroundColor: colors.errorBg,
2224
+ color: colors.errorText,
2225
+ border: `1px solid ${colors.errorBorder}`,
1812
2226
  borderRadius: "8px",
1813
2227
  fontSize: "14px",
1814
2228
  fontWeight: 500
@@ -1820,7 +2234,7 @@ var OtpForm = ({
1820
2234
  display: "block",
1821
2235
  marginBottom: "8px",
1822
2236
  fontWeight: 500,
1823
- color: "#374151",
2237
+ color: colors.textSecondary,
1824
2238
  fontSize: "14px"
1825
2239
  }, children: "OTP Code:" }),
1826
2240
  /* @__PURE__ */ jsx(
@@ -1835,13 +2249,13 @@ var OtpForm = ({
1835
2249
  style: {
1836
2250
  width: "100%",
1837
2251
  padding: "12px 16px",
1838
- border: "1px solid #ddd",
2252
+ border: `1px solid ${colors.borderSecondary}`,
1839
2253
  borderRadius: "8px",
1840
2254
  fontSize: "20px",
1841
2255
  boxSizing: "border-box",
1842
- color: "#111827",
2256
+ color: colors.textPrimary,
1843
2257
  transition: "all 0.2s ease",
1844
- backgroundColor: "#ffffff",
2258
+ backgroundColor: colors.bgSecondary,
1845
2259
  textAlign: "center",
1846
2260
  letterSpacing: "5px"
1847
2261
  },
@@ -1858,7 +2272,7 @@ var OtpForm = ({
1858
2272
  disabled: isLoading || otp.length !== 6,
1859
2273
  style: {
1860
2274
  padding: "14px",
1861
- backgroundColor: "#007bff",
2275
+ backgroundColor: colors.buttonPrimary,
1862
2276
  color: "white",
1863
2277
  border: "none",
1864
2278
  borderRadius: "8px",
@@ -1875,7 +2289,7 @@ var OtpForm = ({
1875
2289
  textAlign: "center",
1876
2290
  marginTop: "20px",
1877
2291
  paddingTop: "20px",
1878
- borderTop: "1px solid #eee"
2292
+ borderTop: `1px solid ${colors.borderPrimary}`
1879
2293
  }, children: [
1880
2294
  /* @__PURE__ */ jsx(
1881
2295
  "button",
@@ -1886,7 +2300,7 @@ var OtpForm = ({
1886
2300
  style: {
1887
2301
  background: "none",
1888
2302
  border: "none",
1889
- color: resendCooldown > 0 ? "#999" : "#007bff",
2303
+ color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
1890
2304
  textDecoration: "none",
1891
2305
  cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
1892
2306
  fontSize: "14px",
@@ -1909,7 +2323,7 @@ var OtpForm = ({
1909
2323
  style: {
1910
2324
  background: "none",
1911
2325
  border: "none",
1912
- color: "#007bff",
2326
+ color: colors.buttonPrimary,
1913
2327
  textDecoration: "none",
1914
2328
  cursor: "pointer",
1915
2329
  fontSize: "14px",
@@ -2176,12 +2590,25 @@ var EmailVerificationPage = ({
2176
2590
  ] })
2177
2591
  ] }) });
2178
2592
  };
2593
+ var ThemeWrapper = forwardRef(
2594
+ ({ children, className = "", style }, ref) => {
2595
+ const { theme, mounted } = useAuthTheme();
2596
+ if (!mounted) {
2597
+ return /* @__PURE__ */ jsx("div", { ref, className, style, children });
2598
+ }
2599
+ return /* @__PURE__ */ jsx("div", { ref, className: `${theme} ${className}`, style, children });
2600
+ }
2601
+ );
2602
+ ThemeWrapper.displayName = "ThemeWrapper";
2179
2603
  var SignIn = ({ redirectUrl, appearance }) => {
2180
2604
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
2605
+ const colors = useThemeColors();
2181
2606
  const [email, setEmail] = useState("");
2607
+ const [phoneNumber, setPhoneNumber] = useState("");
2182
2608
  const [password, setPassword] = useState("");
2183
2609
  const [otp, setOtp] = useState("");
2184
2610
  const [usePassword, setUsePassword] = useState(false);
2611
+ const [usePhone, setUsePhone] = useState(false);
2185
2612
  const [showPassword, setShowPassword] = useState(false);
2186
2613
  const [isLoading, setIsLoading] = useState(false);
2187
2614
  const [error, setError] = useState(null);
@@ -2189,9 +2616,9 @@ var SignIn = ({ redirectUrl, appearance }) => {
2189
2616
  const [success, setSuccess] = useState(null);
2190
2617
  useEffect(() => {
2191
2618
  if (isSignedIn && redirectUrl) {
2192
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2619
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2193
2620
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2194
- window.location.href = `${baseUrl}${redirect2}`;
2621
+ window.location.href = `${baseUrl}${redirect}`;
2195
2622
  }
2196
2623
  }, [isSignedIn, redirectUrl]);
2197
2624
  const handleSubmit = async (e) => {
@@ -2200,25 +2627,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
2200
2627
  setError(null);
2201
2628
  setSuccess(null);
2202
2629
  try {
2630
+ const loginData = usePhone ? { phoneNumber } : { email };
2203
2631
  if (needsOtp) {
2204
- const response = await signIn({ email, otp });
2632
+ const response = await signIn({ ...loginData, otp });
2205
2633
  if (response.success) {
2206
2634
  setSuccess("Login successful!");
2207
2635
  } else {
2208
2636
  setError(response.message || "OTP verification failed");
2209
2637
  }
2210
2638
  } else if (usePassword) {
2211
- const response = await signIn({ email, password });
2639
+ const response = await signIn({ ...loginData, password });
2212
2640
  if (response.success) {
2213
2641
  setSuccess("Login successful!");
2214
2642
  } else {
2215
2643
  setError(response.message || "Login failed");
2216
2644
  }
2217
2645
  } else {
2218
- const response = await signIn({ email });
2219
- if (response.success && response.message === "OTP sent to your email.") {
2646
+ const response = await signIn(loginData);
2647
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
2220
2648
  setNeedsOtp(true);
2221
- setSuccess("OTP sent to your email. Please check your inbox.");
2649
+ setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
2222
2650
  } else {
2223
2651
  setError(response.message || "Failed to send OTP");
2224
2652
  }
@@ -2236,222 +2664,350 @@ var SignIn = ({ redirectUrl, appearance }) => {
2236
2664
  setSuccess(null);
2237
2665
  setOtp("");
2238
2666
  };
2667
+ const toggleLoginMethod = () => {
2668
+ setUsePhone(!usePhone);
2669
+ setNeedsOtp(false);
2670
+ setError(null);
2671
+ setSuccess(null);
2672
+ setOtp("");
2673
+ setEmail("");
2674
+ setPhoneNumber("");
2675
+ };
2239
2676
  if (authLoading) {
2240
2677
  return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
2241
2678
  }
2242
- return /* @__PURE__ */ jsx("div", { style: {
2243
- maxWidth: "400px",
2244
- margin: "0 auto",
2245
- padding: "30px",
2246
- borderRadius: "12px",
2247
- boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2248
- backgroundColor: "#ffffff",
2249
- border: "1px solid #eaeaea",
2250
- ...appearance?.elements?.card
2251
- }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
2252
- /* @__PURE__ */ jsx("h2", { style: {
2253
- textAlign: "center",
2254
- marginBottom: "24px",
2255
- color: "#1f2937",
2256
- fontSize: "24px",
2257
- fontWeight: 600,
2258
- ...appearance?.elements?.headerTitle
2259
- }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2260
- error && /* @__PURE__ */ jsx("div", { style: {
2261
- padding: "12px 16px",
2262
- marginBottom: "20px",
2263
- backgroundColor: "#fee",
2264
- color: "#c33",
2265
- border: "1px solid #fcc",
2266
- borderRadius: "8px",
2267
- fontSize: "14px"
2268
- }, children: error }),
2269
- success && /* @__PURE__ */ jsx("div", { style: {
2270
- padding: "12px 16px",
2271
- marginBottom: "20px",
2272
- backgroundColor: "#efe",
2273
- color: "#3c3",
2274
- border: "1px solid #cfc",
2275
- borderRadius: "8px",
2276
- fontSize: "14px"
2277
- }, children: success }),
2278
- !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2279
- /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
2280
- display: "block",
2281
- marginBottom: "8px",
2282
- fontWeight: 500,
2283
- color: "#374151",
2284
- fontSize: "14px"
2285
- }, children: "Email" }),
2286
- /* @__PURE__ */ jsx(
2287
- "input",
2288
- {
2289
- id: "email",
2290
- type: "email",
2291
- value: email,
2292
- onChange: (e) => setEmail(e.target.value),
2293
- required: true,
2294
- disabled: isLoading,
2295
- style: {
2296
- width: "100%",
2297
- padding: "12px 16px",
2298
- border: "1px solid #ddd",
2299
- borderRadius: "8px",
2300
- fontSize: "16px",
2301
- boxSizing: "border-box",
2302
- ...appearance?.elements?.formFieldInput
2303
- },
2304
- placeholder: "Enter your email"
2305
- }
2306
- )
2307
- ] }),
2308
- usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2309
- /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2310
- display: "block",
2311
- marginBottom: "8px",
2312
- fontWeight: 500,
2313
- color: "#374151",
2314
- fontSize: "14px"
2315
- }, children: "Password" }),
2316
- /* @__PURE__ */ jsx(
2317
- "input",
2318
- {
2319
- id: "password",
2320
- type: showPassword ? "text" : "password",
2321
- value: password,
2322
- onChange: (e) => setPassword(e.target.value),
2323
- required: true,
2324
- disabled: isLoading,
2325
- style: {
2326
- width: "100%",
2327
- padding: "12px 16px",
2328
- border: "1px solid #ddd",
2329
- borderRadius: "8px",
2330
- fontSize: "16px",
2331
- boxSizing: "border-box",
2332
- ...appearance?.elements?.formFieldInput
2333
- },
2334
- placeholder: "Enter your password"
2335
- }
2336
- ),
2337
- /* @__PURE__ */ jsx(
2338
- "button",
2339
- {
2340
- type: "button",
2341
- onClick: () => setShowPassword(!showPassword),
2342
- style: {
2343
- position: "absolute",
2344
- right: "12px",
2345
- top: "38px",
2346
- background: "none",
2347
- border: "none",
2348
- cursor: "pointer",
2349
- color: "#666",
2350
- fontSize: "14px"
2351
- },
2352
- children: showPassword ? "Hide" : "Show"
2353
- }
2354
- )
2355
- ] }),
2356
- needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2357
- /* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
2358
- display: "block",
2359
- marginBottom: "8px",
2360
- fontWeight: 500,
2361
- color: "#374151",
2362
- fontSize: "14px"
2363
- }, children: "One-Time Password" }),
2364
- /* @__PURE__ */ jsx(
2365
- "input",
2366
- {
2367
- id: "otp",
2368
- type: "text",
2369
- value: otp,
2370
- onChange: (e) => setOtp(e.target.value),
2371
- required: true,
2372
- disabled: isLoading,
2373
- maxLength: 6,
2374
- style: {
2375
- width: "100%",
2376
- padding: "12px 16px",
2377
- border: "1px solid #ddd",
2378
- borderRadius: "8px",
2379
- fontSize: "16px",
2380
- boxSizing: "border-box",
2381
- letterSpacing: "0.5em",
2382
- textAlign: "center",
2383
- ...appearance?.elements?.formFieldInput
2384
- },
2385
- placeholder: "000000"
2386
- }
2387
- )
2388
- ] }),
2389
- /* @__PURE__ */ jsx(
2390
- "button",
2391
- {
2392
- type: "submit",
2393
- disabled: isLoading,
2394
- style: {
2395
- width: "100%",
2396
- padding: "14px",
2397
- backgroundColor: "#007bff",
2398
- color: "white",
2399
- border: "none",
2400
- borderRadius: "8px",
2401
- fontSize: "16px",
2679
+ return /* @__PURE__ */ jsx(
2680
+ ThemeWrapper,
2681
+ {
2682
+ style: {
2683
+ maxWidth: "400px",
2684
+ margin: "0 auto",
2685
+ padding: "30px",
2686
+ borderRadius: "12px",
2687
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2688
+ backgroundColor: colors.bgPrimary,
2689
+ border: `1px solid ${colors.borderPrimary}`,
2690
+ ...appearance?.elements?.card
2691
+ },
2692
+ children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
2693
+ /* @__PURE__ */ jsx("h2", { style: {
2694
+ textAlign: "center",
2695
+ marginBottom: "24px",
2696
+ color: colors.textPrimary,
2697
+ fontSize: "24px",
2402
2698
  fontWeight: 600,
2403
- cursor: "pointer",
2404
- transition: "all 0.2s ease",
2405
- ...appearance?.elements?.formButtonPrimary
2406
- },
2407
- children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : "Continue with email"
2408
- }
2409
- ),
2410
- !needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2411
- "button",
2412
- {
2413
- type: "button",
2414
- onClick: toggleAuthMethod,
2415
- disabled: isLoading,
2416
- style: {
2417
- background: "none",
2418
- border: "none",
2419
- color: "#007bff",
2420
- cursor: "pointer",
2421
- fontSize: "14px",
2422
- fontWeight: 600
2423
- },
2424
- children: usePassword ? "Use email code instead" : "Use password instead"
2425
- }
2426
- ) }),
2427
- needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2428
- "button",
2429
- {
2430
- type: "button",
2431
- onClick: () => {
2432
- setNeedsOtp(false);
2433
- setOtp("");
2434
- setError(null);
2435
- setSuccess(null);
2436
- },
2437
- disabled: isLoading,
2438
- style: {
2439
- background: "none",
2440
- border: "none",
2441
- color: "#007bff",
2442
- cursor: "pointer",
2443
- fontSize: "14px",
2444
- fontWeight: 600
2445
- },
2446
- children: "Back to sign in"
2447
- }
2448
- ) })
2449
- ] }) });
2699
+ ...appearance?.elements?.headerTitle
2700
+ }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2701
+ error && /* @__PURE__ */ jsx("div", { style: {
2702
+ padding: "12px 16px",
2703
+ marginBottom: "20px",
2704
+ backgroundColor: colors.errorBg,
2705
+ color: colors.errorText,
2706
+ border: `1px solid ${colors.errorBorder}`,
2707
+ borderRadius: "8px",
2708
+ fontSize: "14px"
2709
+ }, children: error }),
2710
+ success && /* @__PURE__ */ jsx("div", { style: {
2711
+ padding: "12px 16px",
2712
+ marginBottom: "20px",
2713
+ backgroundColor: colors.successBg,
2714
+ color: colors.successText,
2715
+ border: `1px solid ${colors.successBorder}`,
2716
+ borderRadius: "8px",
2717
+ fontSize: "14px"
2718
+ }, children: success }),
2719
+ !needsOtp && !usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2720
+ /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
2721
+ display: "block",
2722
+ marginBottom: "8px",
2723
+ fontWeight: 500,
2724
+ color: colors.textSecondary,
2725
+ fontSize: "14px"
2726
+ }, children: "Email" }),
2727
+ /* @__PURE__ */ jsx(
2728
+ "input",
2729
+ {
2730
+ id: "email",
2731
+ type: "email",
2732
+ value: email,
2733
+ onChange: (e) => setEmail(e.target.value),
2734
+ onFocus: (e) => {
2735
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2736
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2737
+ },
2738
+ onBlur: (e) => {
2739
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2740
+ e.currentTarget.style.outline = "none";
2741
+ },
2742
+ required: true,
2743
+ disabled: isLoading,
2744
+ style: {
2745
+ width: "100%",
2746
+ padding: "12px 16px",
2747
+ border: `1px solid ${colors.borderSecondary}`,
2748
+ borderRadius: "8px",
2749
+ fontSize: "16px",
2750
+ boxSizing: "border-box",
2751
+ backgroundColor: colors.bgSecondary,
2752
+ color: colors.textPrimary,
2753
+ transition: "all 0.2s ease",
2754
+ WebkitTextFillColor: colors.textPrimary,
2755
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2756
+ ...appearance?.elements?.formFieldInput
2757
+ },
2758
+ placeholder: "Enter your email"
2759
+ }
2760
+ )
2761
+ ] }),
2762
+ !needsOtp && usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2763
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
2764
+ display: "block",
2765
+ marginBottom: "8px",
2766
+ fontWeight: 500,
2767
+ color: colors.textSecondary,
2768
+ fontSize: "14px"
2769
+ }, children: "Phone Number" }),
2770
+ /* @__PURE__ */ jsx(
2771
+ "input",
2772
+ {
2773
+ id: "phoneNumber",
2774
+ type: "tel",
2775
+ value: phoneNumber,
2776
+ onChange: (e) => setPhoneNumber(e.target.value),
2777
+ onFocus: (e) => {
2778
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2779
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2780
+ },
2781
+ onBlur: (e) => {
2782
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2783
+ e.currentTarget.style.outline = "none";
2784
+ },
2785
+ required: true,
2786
+ disabled: isLoading,
2787
+ style: {
2788
+ width: "100%",
2789
+ padding: "12px 16px",
2790
+ border: `1px solid ${colors.borderSecondary}`,
2791
+ borderRadius: "8px",
2792
+ fontSize: "16px",
2793
+ boxSizing: "border-box",
2794
+ backgroundColor: colors.bgSecondary,
2795
+ color: colors.textPrimary,
2796
+ transition: "all 0.2s ease",
2797
+ WebkitTextFillColor: colors.textPrimary,
2798
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2799
+ ...appearance?.elements?.formFieldInput
2800
+ },
2801
+ placeholder: "Enter your phone number"
2802
+ }
2803
+ )
2804
+ ] }),
2805
+ usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2806
+ /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2807
+ display: "block",
2808
+ marginBottom: "8px",
2809
+ fontWeight: 500,
2810
+ color: colors.textSecondary,
2811
+ fontSize: "14px"
2812
+ }, children: "Password" }),
2813
+ /* @__PURE__ */ jsx(
2814
+ "input",
2815
+ {
2816
+ id: "password",
2817
+ type: showPassword ? "text" : "password",
2818
+ value: password,
2819
+ onChange: (e) => setPassword(e.target.value),
2820
+ onFocus: (e) => {
2821
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2822
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2823
+ },
2824
+ onBlur: (e) => {
2825
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2826
+ e.currentTarget.style.outline = "none";
2827
+ },
2828
+ required: true,
2829
+ disabled: isLoading,
2830
+ style: {
2831
+ width: "100%",
2832
+ padding: "12px 16px",
2833
+ border: `1px solid ${colors.borderSecondary}`,
2834
+ borderRadius: "8px",
2835
+ fontSize: "16px",
2836
+ boxSizing: "border-box",
2837
+ backgroundColor: colors.bgSecondary,
2838
+ color: colors.textPrimary,
2839
+ transition: "all 0.2s ease",
2840
+ WebkitTextFillColor: colors.textPrimary,
2841
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2842
+ ...appearance?.elements?.formFieldInput
2843
+ },
2844
+ placeholder: "Enter your password"
2845
+ }
2846
+ ),
2847
+ /* @__PURE__ */ jsx(
2848
+ "button",
2849
+ {
2850
+ type: "button",
2851
+ onClick: () => setShowPassword(!showPassword),
2852
+ style: {
2853
+ position: "absolute",
2854
+ right: "12px",
2855
+ top: "38px",
2856
+ background: "none",
2857
+ border: "none",
2858
+ cursor: "pointer",
2859
+ color: colors.textTertiary,
2860
+ fontSize: "14px"
2861
+ },
2862
+ children: showPassword ? "Hide" : "Show"
2863
+ }
2864
+ )
2865
+ ] }),
2866
+ needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2867
+ /* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
2868
+ display: "block",
2869
+ marginBottom: "8px",
2870
+ fontWeight: 500,
2871
+ color: colors.textSecondary,
2872
+ fontSize: "14px"
2873
+ }, children: "One-Time Password" }),
2874
+ /* @__PURE__ */ jsx(
2875
+ "input",
2876
+ {
2877
+ id: "otp",
2878
+ type: "text",
2879
+ value: otp,
2880
+ onChange: (e) => setOtp(e.target.value),
2881
+ onFocus: (e) => {
2882
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2883
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2884
+ },
2885
+ onBlur: (e) => {
2886
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2887
+ e.currentTarget.style.outline = "none";
2888
+ },
2889
+ required: true,
2890
+ disabled: isLoading,
2891
+ maxLength: 6,
2892
+ style: {
2893
+ width: "100%",
2894
+ padding: "12px 16px",
2895
+ border: `1px solid ${colors.borderSecondary}`,
2896
+ borderRadius: "8px",
2897
+ fontSize: "16px",
2898
+ boxSizing: "border-box",
2899
+ letterSpacing: "0.5em",
2900
+ textAlign: "center",
2901
+ backgroundColor: colors.bgSecondary,
2902
+ color: colors.textPrimary,
2903
+ transition: "all 0.2s ease",
2904
+ WebkitTextFillColor: colors.textPrimary,
2905
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2906
+ ...appearance?.elements?.formFieldInput
2907
+ },
2908
+ placeholder: "000000"
2909
+ }
2910
+ )
2911
+ ] }),
2912
+ /* @__PURE__ */ jsx(
2913
+ "button",
2914
+ {
2915
+ type: "submit",
2916
+ disabled: isLoading,
2917
+ onMouseEnter: (e) => {
2918
+ if (!isLoading) {
2919
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
2920
+ }
2921
+ },
2922
+ onMouseLeave: (e) => {
2923
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
2924
+ },
2925
+ style: {
2926
+ width: "100%",
2927
+ padding: "14px",
2928
+ backgroundColor: colors.buttonPrimary,
2929
+ color: "white",
2930
+ border: "none",
2931
+ borderRadius: "8px",
2932
+ fontSize: "16px",
2933
+ fontWeight: 600,
2934
+ cursor: isLoading ? "not-allowed" : "pointer",
2935
+ opacity: isLoading ? 0.6 : 1,
2936
+ transition: "all 0.2s ease",
2937
+ ...appearance?.elements?.formButtonPrimary
2938
+ },
2939
+ children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
2940
+ }
2941
+ ),
2942
+ !needsOtp && /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
2943
+ /* @__PURE__ */ jsx(
2944
+ "button",
2945
+ {
2946
+ type: "button",
2947
+ onClick: toggleAuthMethod,
2948
+ disabled: isLoading,
2949
+ style: {
2950
+ background: "none",
2951
+ border: "none",
2952
+ color: colors.buttonPrimary,
2953
+ cursor: "pointer",
2954
+ fontSize: "14px",
2955
+ fontWeight: 600,
2956
+ marginRight: "16px"
2957
+ },
2958
+ children: usePassword ? "Use OTP code instead" : "Use password instead"
2959
+ }
2960
+ ),
2961
+ /* @__PURE__ */ jsx(
2962
+ "button",
2963
+ {
2964
+ type: "button",
2965
+ onClick: toggleLoginMethod,
2966
+ disabled: isLoading,
2967
+ style: {
2968
+ background: "none",
2969
+ border: "none",
2970
+ color: colors.buttonPrimary,
2971
+ cursor: "pointer",
2972
+ fontSize: "14px",
2973
+ fontWeight: 600
2974
+ },
2975
+ children: usePhone ? "Use email instead" : "Use phone instead"
2976
+ }
2977
+ )
2978
+ ] }),
2979
+ needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2980
+ "button",
2981
+ {
2982
+ type: "button",
2983
+ onClick: () => {
2984
+ setNeedsOtp(false);
2985
+ setOtp("");
2986
+ setError(null);
2987
+ setSuccess(null);
2988
+ },
2989
+ disabled: isLoading,
2990
+ style: {
2991
+ background: "none",
2992
+ border: "none",
2993
+ color: colors.buttonPrimary,
2994
+ cursor: "pointer",
2995
+ fontSize: "14px",
2996
+ fontWeight: 600
2997
+ },
2998
+ children: "Back to sign in"
2999
+ }
3000
+ ) })
3001
+ ] })
3002
+ }
3003
+ );
2450
3004
  };
2451
3005
  var SignUp = ({ redirectUrl, appearance }) => {
2452
3006
  const { signUp, isSignedIn } = useAuth2();
3007
+ const colors = useThemeColors();
2453
3008
  const [name, setName] = useState("");
2454
3009
  const [email, setEmail] = useState("");
3010
+ const [phoneNumber, setPhoneNumber] = useState("");
2455
3011
  const [password, setPassword] = useState("");
2456
3012
  const [confirmPassword, setConfirmPassword] = useState("");
2457
3013
  const [showPassword, setShowPassword] = useState(false);
@@ -2460,14 +3016,14 @@ var SignUp = ({ redirectUrl, appearance }) => {
2460
3016
  const [success, setSuccess] = useState(null);
2461
3017
  useEffect(() => {
2462
3018
  if (isSignedIn && redirectUrl) {
2463
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
3019
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
2464
3020
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2465
- window.location.href = `${baseUrl}${redirect2}`;
3021
+ window.location.href = `${baseUrl}${redirect}`;
2466
3022
  }
2467
3023
  }, [isSignedIn, redirectUrl]);
2468
- const getPasswordStrength = (pwd) => {
3024
+ const getPasswordStrength = (pwd, colors2) => {
2469
3025
  if (!pwd)
2470
- return { strength: "weak", color: "#ddd" };
3026
+ return { strength: "weak", color: colors2.borderSecondary };
2471
3027
  let score = 0;
2472
3028
  if (pwd.length >= 6)
2473
3029
  score++;
@@ -2480,12 +3036,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2480
3036
  if (/[^a-zA-Z\d]/.test(pwd))
2481
3037
  score++;
2482
3038
  if (score <= 2)
2483
- return { strength: "weak", color: "#f44" };
3039
+ return { strength: "weak", color: colors2.errorText };
2484
3040
  if (score <= 3)
2485
- return { strength: "medium", color: "#fa4" };
2486
- return { strength: "strong", color: "#4f4" };
3041
+ return { strength: "medium", color: colors2.warningText || "#fa4" };
3042
+ return { strength: "strong", color: colors2.successText };
2487
3043
  };
2488
- const passwordStrength = getPasswordStrength(password);
3044
+ const passwordStrength = getPasswordStrength(password, colors);
2489
3045
  const handleSubmit = async (e) => {
2490
3046
  e.preventDefault();
2491
3047
  setIsLoading(true);
@@ -2502,7 +3058,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2502
3058
  return;
2503
3059
  }
2504
3060
  try {
2505
- const response = await signUp({ name, email, password });
3061
+ const signUpData = { name, password };
3062
+ if (email)
3063
+ signUpData.email = email;
3064
+ if (phoneNumber)
3065
+ signUpData.phoneNumber = phoneNumber;
3066
+ const response = await signUp(signUpData);
2506
3067
  if (response.success) {
2507
3068
  setSuccess("Registration successful! Please check your email to verify your account.");
2508
3069
  } else {
@@ -2514,20 +3075,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
2514
3075
  setIsLoading(false);
2515
3076
  }
2516
3077
  };
2517
- return /* @__PURE__ */ jsx("div", { style: {
3078
+ return /* @__PURE__ */ jsx(ThemeWrapper, { style: {
2518
3079
  maxWidth: "400px",
2519
3080
  margin: "0 auto",
2520
3081
  padding: "30px",
2521
3082
  borderRadius: "12px",
2522
3083
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2523
- backgroundColor: "#ffffff",
2524
- border: "1px solid #eaeaea",
3084
+ backgroundColor: colors.bgPrimary,
3085
+ border: `1px solid ${colors.borderPrimary}`,
2525
3086
  ...appearance?.elements?.card
2526
3087
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
2527
3088
  /* @__PURE__ */ jsx("h2", { style: {
2528
3089
  textAlign: "center",
2529
3090
  marginBottom: "24px",
2530
- color: "#1f2937",
3091
+ color: colors.textPrimary,
2531
3092
  fontSize: "24px",
2532
3093
  fontWeight: 600,
2533
3094
  ...appearance?.elements?.headerTitle
@@ -2535,18 +3096,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
2535
3096
  error && /* @__PURE__ */ jsx("div", { style: {
2536
3097
  padding: "12px 16px",
2537
3098
  marginBottom: "20px",
2538
- backgroundColor: "#fee",
2539
- color: "#c33",
2540
- border: "1px solid #fcc",
3099
+ backgroundColor: colors.errorBg,
3100
+ color: colors.errorText,
3101
+ border: `1px solid ${colors.errorBorder}`,
2541
3102
  borderRadius: "8px",
2542
3103
  fontSize: "14px"
2543
3104
  }, children: error }),
2544
3105
  success && /* @__PURE__ */ jsx("div", { style: {
2545
3106
  padding: "12px 16px",
2546
3107
  marginBottom: "20px",
2547
- backgroundColor: "#efe",
2548
- color: "#3c3",
2549
- border: "1px solid #cfc",
3108
+ backgroundColor: colors.successBg,
3109
+ color: colors.successText,
3110
+ border: `1px solid ${colors.successBorder}`,
2550
3111
  borderRadius: "8px",
2551
3112
  fontSize: "14px"
2552
3113
  }, children: success }),
@@ -2555,7 +3116,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2555
3116
  display: "block",
2556
3117
  marginBottom: "8px",
2557
3118
  fontWeight: 500,
2558
- color: "#374151",
3119
+ color: colors.textSecondary,
2559
3120
  fontSize: "14px"
2560
3121
  }, children: "Full name" }),
2561
3122
  /* @__PURE__ */ jsx(
@@ -2565,15 +3126,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2565
3126
  type: "text",
2566
3127
  value: name,
2567
3128
  onChange: (e) => setName(e.target.value),
3129
+ onFocus: (e) => {
3130
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3131
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3132
+ },
3133
+ onBlur: (e) => {
3134
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3135
+ e.currentTarget.style.outline = "none";
3136
+ },
2568
3137
  required: true,
2569
3138
  disabled: isLoading,
2570
3139
  style: {
2571
3140
  width: "100%",
2572
3141
  padding: "12px 16px",
2573
- border: "1px solid #ddd",
3142
+ border: `1px solid ${colors.borderSecondary}`,
2574
3143
  borderRadius: "8px",
2575
3144
  fontSize: "16px",
2576
3145
  boxSizing: "border-box",
3146
+ backgroundColor: colors.bgSecondary,
3147
+ color: colors.textPrimary,
3148
+ transition: "all 0.2s ease",
3149
+ WebkitTextFillColor: colors.textPrimary,
3150
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2577
3151
  ...appearance?.elements?.formFieldInput
2578
3152
  },
2579
3153
  placeholder: "Enter your full name"
@@ -2585,7 +3159,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2585
3159
  display: "block",
2586
3160
  marginBottom: "8px",
2587
3161
  fontWeight: 500,
2588
- color: "#374151",
3162
+ color: colors.textSecondary,
2589
3163
  fontSize: "14px"
2590
3164
  }, children: "Email" }),
2591
3165
  /* @__PURE__ */ jsx(
@@ -2595,27 +3169,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
2595
3169
  type: "email",
2596
3170
  value: email,
2597
3171
  onChange: (e) => setEmail(e.target.value),
2598
- required: true,
3172
+ onFocus: (e) => {
3173
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3174
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3175
+ },
3176
+ onBlur: (e) => {
3177
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3178
+ e.currentTarget.style.outline = "none";
3179
+ },
3180
+ required: !phoneNumber,
2599
3181
  disabled: isLoading,
2600
3182
  style: {
2601
3183
  width: "100%",
2602
3184
  padding: "12px 16px",
2603
- border: "1px solid #ddd",
3185
+ border: `1px solid ${colors.borderSecondary}`,
2604
3186
  borderRadius: "8px",
2605
3187
  fontSize: "16px",
2606
3188
  boxSizing: "border-box",
3189
+ backgroundColor: colors.bgSecondary,
3190
+ color: colors.textPrimary,
3191
+ transition: "all 0.2s ease",
3192
+ WebkitTextFillColor: colors.textPrimary,
3193
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2607
3194
  ...appearance?.elements?.formFieldInput
2608
3195
  },
2609
3196
  placeholder: "Enter your email"
2610
3197
  }
2611
3198
  )
2612
3199
  ] }),
3200
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
3201
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
3202
+ display: "block",
3203
+ marginBottom: "8px",
3204
+ fontWeight: 500,
3205
+ color: colors.textSecondary,
3206
+ fontSize: "14px"
3207
+ }, children: "Phone Number (Optional)" }),
3208
+ /* @__PURE__ */ jsx(
3209
+ PhoneInput,
3210
+ {
3211
+ id: "phoneNumber",
3212
+ value: phoneNumber,
3213
+ onChange: setPhoneNumber,
3214
+ disabled: isLoading,
3215
+ placeholder: "1234567890",
3216
+ style: appearance?.elements?.formFieldInput
3217
+ }
3218
+ )
3219
+ ] }),
2613
3220
  /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2614
3221
  /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2615
3222
  display: "block",
2616
3223
  marginBottom: "8px",
2617
3224
  fontWeight: 500,
2618
- color: "#374151",
3225
+ color: colors.textSecondary,
2619
3226
  fontSize: "14px"
2620
3227
  }, children: "Password" }),
2621
3228
  /* @__PURE__ */ jsx(
@@ -2625,16 +3232,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
2625
3232
  type: showPassword ? "text" : "password",
2626
3233
  value: password,
2627
3234
  onChange: (e) => setPassword(e.target.value),
3235
+ onFocus: (e) => {
3236
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3237
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3238
+ },
3239
+ onBlur: (e) => {
3240
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3241
+ e.currentTarget.style.outline = "none";
3242
+ },
2628
3243
  required: true,
2629
3244
  disabled: isLoading,
2630
3245
  minLength: 6,
2631
3246
  style: {
2632
3247
  width: "100%",
2633
3248
  padding: "12px 16px",
2634
- border: "1px solid #ddd",
3249
+ border: `1px solid ${colors.borderSecondary}`,
2635
3250
  borderRadius: "8px",
2636
3251
  fontSize: "16px",
2637
3252
  boxSizing: "border-box",
3253
+ backgroundColor: colors.bgSecondary,
3254
+ color: colors.textPrimary,
3255
+ transition: "all 0.2s ease",
3256
+ WebkitTextFillColor: colors.textPrimary,
3257
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2638
3258
  ...appearance?.elements?.formFieldInput
2639
3259
  },
2640
3260
  placeholder: "Create a password"
@@ -2652,7 +3272,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2652
3272
  background: "none",
2653
3273
  border: "none",
2654
3274
  cursor: "pointer",
2655
- color: "#666",
3275
+ color: colors.textTertiary,
2656
3276
  fontSize: "14px"
2657
3277
  },
2658
3278
  children: showPassword ? "Hide" : "Show"
@@ -2661,7 +3281,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2661
3281
  password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
2662
3282
  /* @__PURE__ */ jsx("div", { style: {
2663
3283
  height: "4px",
2664
- backgroundColor: "#eee",
3284
+ backgroundColor: colors.borderSecondary,
2665
3285
  borderRadius: "2px",
2666
3286
  overflow: "hidden"
2667
3287
  }, children: /* @__PURE__ */ jsx("div", { style: {
@@ -2686,7 +3306,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2686
3306
  display: "block",
2687
3307
  marginBottom: "8px",
2688
3308
  fontWeight: 500,
2689
- color: "#374151",
3309
+ color: colors.textSecondary,
2690
3310
  fontSize: "14px"
2691
3311
  }, children: "Confirm password" }),
2692
3312
  /* @__PURE__ */ jsx(
@@ -2696,15 +3316,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2696
3316
  type: showPassword ? "text" : "password",
2697
3317
  value: confirmPassword,
2698
3318
  onChange: (e) => setConfirmPassword(e.target.value),
3319
+ onFocus: (e) => {
3320
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3321
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3322
+ },
3323
+ onBlur: (e) => {
3324
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3325
+ e.currentTarget.style.outline = "none";
3326
+ },
2699
3327
  required: true,
2700
3328
  disabled: isLoading,
2701
3329
  style: {
2702
3330
  width: "100%",
2703
3331
  padding: "12px 16px",
2704
- border: "1px solid #ddd",
3332
+ border: `1px solid ${colors.borderSecondary}`,
2705
3333
  borderRadius: "8px",
2706
3334
  fontSize: "16px",
2707
3335
  boxSizing: "border-box",
3336
+ backgroundColor: colors.bgSecondary,
3337
+ color: colors.textPrimary,
3338
+ transition: "all 0.2s ease",
3339
+ WebkitTextFillColor: colors.textPrimary,
3340
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2708
3341
  ...appearance?.elements?.formFieldInput
2709
3342
  },
2710
3343
  placeholder: "Confirm your password"
@@ -2716,16 +3349,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
2716
3349
  {
2717
3350
  type: "submit",
2718
3351
  disabled: isLoading,
3352
+ onMouseEnter: (e) => {
3353
+ if (!isLoading) {
3354
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
3355
+ }
3356
+ },
3357
+ onMouseLeave: (e) => {
3358
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3359
+ },
2719
3360
  style: {
2720
3361
  width: "100%",
2721
3362
  padding: "14px",
2722
- backgroundColor: "#007bff",
3363
+ backgroundColor: colors.buttonPrimary,
2723
3364
  color: "white",
2724
3365
  border: "none",
2725
3366
  borderRadius: "8px",
2726
3367
  fontSize: "16px",
2727
3368
  fontWeight: 600,
2728
- cursor: "pointer",
3369
+ cursor: isLoading ? "not-allowed" : "pointer",
3370
+ opacity: isLoading ? 0.6 : 1,
2729
3371
  transition: "all 0.2s ease",
2730
3372
  ...appearance?.elements?.formButtonPrimary
2731
3373
  },
@@ -2739,9 +3381,9 @@ var SignOut = ({ redirectUrl }) => {
2739
3381
  useEffect(() => {
2740
3382
  const performSignOut = async () => {
2741
3383
  await signOut();
2742
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
3384
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
2743
3385
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2744
- window.location.href = `${baseUrl}${redirect2}`;
3386
+ window.location.href = `${baseUrl}${redirect}`;
2745
3387
  };
2746
3388
  performSignOut();
2747
3389
  }, [signOut, redirectUrl]);
@@ -2749,6 +3391,7 @@ var SignOut = ({ redirectUrl }) => {
2749
3391
  };
2750
3392
  var UserButton = ({ showName = false, appearance }) => {
2751
3393
  const { user, signOut } = useAuth2();
3394
+ const colors = useThemeColors();
2752
3395
  const [isOpen, setIsOpen] = useState(false);
2753
3396
  const dropdownRef = useRef(null);
2754
3397
  useEffect(() => {
@@ -2767,11 +3410,11 @@ var UserButton = ({ showName = false, appearance }) => {
2767
3410
  };
2768
3411
  const handleSignOut = async () => {
2769
3412
  await signOut();
2770
- const redirect2 = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
3413
+ const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
2771
3414
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2772
- window.location.href = `${baseUrl}${redirect2}`;
3415
+ window.location.href = `${baseUrl}${redirect}`;
2773
3416
  };
2774
- return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
3417
+ return /* @__PURE__ */ jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
2775
3418
  /* @__PURE__ */ jsxs(
2776
3419
  "button",
2777
3420
  {
@@ -2789,7 +3432,7 @@ var UserButton = ({ showName = false, appearance }) => {
2789
3432
  ...appearance?.elements?.userButtonTrigger
2790
3433
  },
2791
3434
  onMouseEnter: (e) => {
2792
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3435
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2793
3436
  },
2794
3437
  onMouseLeave: (e) => {
2795
3438
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2799,15 +3442,15 @@ var UserButton = ({ showName = false, appearance }) => {
2799
3442
  width: "36px",
2800
3443
  height: "36px",
2801
3444
  borderRadius: "50%",
2802
- backgroundColor: "#007bff",
2803
- color: "white",
3445
+ backgroundColor: colors.buttonPrimary,
3446
+ color: colors.textPrimary,
2804
3447
  display: "flex",
2805
3448
  alignItems: "center",
2806
3449
  justifyContent: "center",
2807
3450
  fontSize: "14px",
2808
3451
  fontWeight: 600
2809
3452
  }, children: getInitials(user.name) }),
2810
- showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: "#333" }, children: user.name })
3453
+ showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
2811
3454
  ]
2812
3455
  }
2813
3456
  ),
@@ -2817,16 +3460,16 @@ var UserButton = ({ showName = false, appearance }) => {
2817
3460
  right: 0,
2818
3461
  marginTop: "8px",
2819
3462
  width: "240px",
2820
- backgroundColor: "white",
3463
+ backgroundColor: colors.bgPrimary,
2821
3464
  borderRadius: "12px",
2822
3465
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
2823
- border: "1px solid #eaeaea",
3466
+ border: `1px solid ${colors.borderPrimary}`,
2824
3467
  zIndex: 1e3,
2825
3468
  ...appearance?.elements?.userButtonPopoverCard
2826
3469
  }, children: [
2827
3470
  /* @__PURE__ */ jsx("div", { style: {
2828
3471
  padding: "16px",
2829
- borderBottom: "1px solid #eee"
3472
+ borderBottom: `1px solid ${colors.borderPrimary}`
2830
3473
  }, children: /* @__PURE__ */ jsxs("div", { style: {
2831
3474
  display: "flex",
2832
3475
  alignItems: "center",
@@ -2836,8 +3479,8 @@ var UserButton = ({ showName = false, appearance }) => {
2836
3479
  width: "48px",
2837
3480
  height: "48px",
2838
3481
  borderRadius: "50%",
2839
- backgroundColor: "#007bff",
2840
- color: "white",
3482
+ backgroundColor: colors.buttonPrimary,
3483
+ color: colors.textPrimary,
2841
3484
  display: "flex",
2842
3485
  alignItems: "center",
2843
3486
  justifyContent: "center",
@@ -2848,14 +3491,14 @@ var UserButton = ({ showName = false, appearance }) => {
2848
3491
  /* @__PURE__ */ jsx("div", { style: {
2849
3492
  fontSize: "14px",
2850
3493
  fontWeight: 600,
2851
- color: "#333",
3494
+ color: colors.textPrimary,
2852
3495
  overflow: "hidden",
2853
3496
  textOverflow: "ellipsis",
2854
3497
  whiteSpace: "nowrap"
2855
3498
  }, children: user.name }),
2856
3499
  /* @__PURE__ */ jsx("div", { style: {
2857
3500
  fontSize: "12px",
2858
- color: "#666",
3501
+ color: colors.textTertiary,
2859
3502
  overflow: "hidden",
2860
3503
  textOverflow: "ellipsis",
2861
3504
  whiteSpace: "nowrap"
@@ -2875,12 +3518,12 @@ var UserButton = ({ showName = false, appearance }) => {
2875
3518
  textAlign: "left",
2876
3519
  cursor: "pointer",
2877
3520
  fontSize: "14px",
2878
- color: "#333",
3521
+ color: colors.textPrimary,
2879
3522
  fontWeight: 500,
2880
3523
  transition: "background-color 0.2s"
2881
3524
  },
2882
3525
  onMouseEnter: (e) => {
2883
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3526
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2884
3527
  },
2885
3528
  onMouseLeave: (e) => {
2886
3529
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2962,9 +3605,9 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
2962
3605
  setMessage("Email verified successfully! Redirecting...");
2963
3606
  onSuccess?.();
2964
3607
  setTimeout(() => {
2965
- const redirect2 = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_VERIFY || process.env.REACT_APP_AUTH_REDIRECT_AFTER_VERIFY || "/dashboard";
3608
+ const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_VERIFY || process.env.REACT_APP_AUTH_REDIRECT_AFTER_VERIFY || "/dashboard";
2966
3609
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2967
- window.location.href = `${baseUrl}${redirect2}`;
3610
+ window.location.href = `${baseUrl}${redirect}`;
2968
3611
  }, 2e3);
2969
3612
  } else {
2970
3613
  setStatus("error");
@@ -3733,43 +4376,41 @@ var UserProfile = ({
3733
4376
  showEmailChange = true,
3734
4377
  showPasswordChange = true
3735
4378
  }) => {
3736
- const { user, updateProfile, updateAvatar, requestEmailChange } = useAuth2();
4379
+ const { user, updateProfile, requestEmailChange } = useAuth2();
4380
+ const colors = useThemeColors();
3737
4381
  const [name, setName] = useState(user?.name || "");
3738
- const [avatar, setAvatar] = useState("");
4382
+ const [avatar, setAvatar] = useState(user?.avatar || "");
4383
+ const [phoneNumber, setPhoneNumber] = useState(user?.phoneNumber || "");
3739
4384
  const [newEmail, setNewEmail] = useState("");
3740
4385
  const [isLoading, setIsLoading] = useState(false);
3741
4386
  const [error, setError] = useState(null);
3742
4387
  const [success, setSuccess] = useState(null);
3743
- const handleUpdateName = async (e) => {
4388
+ const handleUpdateProfile = async (e) => {
3744
4389
  e.preventDefault();
3745
4390
  setIsLoading(true);
3746
4391
  setError(null);
3747
4392
  setSuccess(null);
3748
4393
  try {
3749
- const response = await updateProfile({ name });
3750
- if (response.success) {
3751
- setSuccess("Name updated successfully!");
3752
- } else {
3753
- setError(response.message || "Failed to update name");
4394
+ const updates = {};
4395
+ if (name !== user?.name) {
4396
+ updates.name = name;
3754
4397
  }
3755
- } catch (err) {
3756
- setError(err instanceof Error ? err.message : "An error occurred");
3757
- } finally {
3758
- setIsLoading(false);
3759
- }
3760
- };
3761
- const handleUpdateAvatar = async (e) => {
3762
- e.preventDefault();
3763
- setIsLoading(true);
3764
- setError(null);
3765
- setSuccess(null);
3766
- try {
3767
- const response = await updateAvatar(avatar);
4398
+ if (showAvatar && avatar !== user?.avatar) {
4399
+ updates.avatar = avatar;
4400
+ }
4401
+ if (phoneNumber !== user?.phoneNumber) {
4402
+ updates.phoneNumber = phoneNumber;
4403
+ }
4404
+ if (Object.keys(updates).length === 0) {
4405
+ setError("No changes to save");
4406
+ setIsLoading(false);
4407
+ return;
4408
+ }
4409
+ const response = await updateProfile(updates);
3768
4410
  if (response.success) {
3769
- setSuccess("Avatar updated successfully!");
3770
- setAvatar("");
4411
+ setSuccess("Profile updated successfully!");
3771
4412
  } else {
3772
- setError(response.message || "Failed to update avatar");
4413
+ setError(response.message || "Failed to update profile");
3773
4414
  }
3774
4415
  } catch (err) {
3775
4416
  setError(err instanceof Error ? err.message : "An error occurred");
@@ -3798,173 +4439,220 @@ var UserProfile = ({
3798
4439
  };
3799
4440
  if (!user)
3800
4441
  return null;
3801
- return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "600px", margin: "0 auto", padding: "20px" }, children: [
3802
- /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
4442
+ return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4443
+ /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
3803
4444
  error && /* @__PURE__ */ jsx("div", { style: {
3804
4445
  padding: "12px 16px",
3805
4446
  marginBottom: "20px",
3806
- backgroundColor: "#fee",
3807
- color: "#c33",
3808
- border: "1px solid #fcc",
4447
+ backgroundColor: colors.errorBg,
4448
+ color: colors.errorText,
4449
+ border: `1px solid ${colors.errorBorder}`,
3809
4450
  borderRadius: "8px",
3810
4451
  fontSize: "14px"
3811
4452
  }, children: error }),
3812
4453
  success && /* @__PURE__ */ jsx("div", { style: {
3813
4454
  padding: "12px 16px",
3814
4455
  marginBottom: "20px",
3815
- backgroundColor: "#efe",
3816
- color: "#3c3",
3817
- border: "1px solid #cfc",
4456
+ backgroundColor: colors.successBg,
4457
+ color: colors.successText,
4458
+ border: `1px solid ${colors.successBorder}`,
3818
4459
  borderRadius: "8px",
3819
4460
  fontSize: "14px"
3820
4461
  }, children: success }),
3821
4462
  /* @__PURE__ */ jsxs("div", { style: {
3822
- padding: "20px",
3823
- backgroundColor: "#fff",
3824
- borderRadius: "8px",
4463
+ padding: "24px",
4464
+ backgroundColor: colors.bgPrimary,
4465
+ borderRadius: "12px",
3825
4466
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3826
- marginBottom: "20px"
4467
+ marginBottom: "24px",
4468
+ border: `1px solid ${colors.borderPrimary}`
3827
4469
  }, children: [
3828
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Name" }),
3829
- /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateName, children: [
3830
- /* @__PURE__ */ jsx(
3831
- "input",
3832
- {
3833
- type: "text",
3834
- value: name,
3835
- onChange: (e) => setName(e.target.value),
3836
- required: true,
3837
- disabled: isLoading,
3838
- style: {
3839
- width: "100%",
3840
- padding: "12px 16px",
3841
- border: "1px solid #ddd",
3842
- borderRadius: "8px",
3843
- fontSize: "16px",
3844
- boxSizing: "border-box",
3845
- marginBottom: "12px"
3846
- },
3847
- placeholder: "Your name"
3848
- }
3849
- ),
4470
+ /* @__PURE__ */ jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
4471
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateProfile, children: [
4472
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4473
+ /* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
4474
+ display: "block",
4475
+ marginBottom: "8px",
4476
+ fontWeight: 500,
4477
+ color: colors.textSecondary,
4478
+ fontSize: "14px"
4479
+ }, children: "Full Name" }),
4480
+ /* @__PURE__ */ jsx(
4481
+ "input",
4482
+ {
4483
+ id: "name",
4484
+ type: "text",
4485
+ value: name,
4486
+ onChange: (e) => setName(e.target.value),
4487
+ required: true,
4488
+ disabled: isLoading,
4489
+ style: {
4490
+ width: "100%",
4491
+ padding: "12px 16px",
4492
+ border: `1px solid ${colors.borderSecondary}`,
4493
+ borderRadius: "8px",
4494
+ fontSize: "16px",
4495
+ boxSizing: "border-box",
4496
+ backgroundColor: colors.bgSecondary,
4497
+ color: colors.textPrimary,
4498
+ transition: "all 0.2s ease"
4499
+ },
4500
+ placeholder: "Manish Batra"
4501
+ }
4502
+ )
4503
+ ] }),
4504
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4505
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
4506
+ display: "block",
4507
+ marginBottom: "8px",
4508
+ fontWeight: 500,
4509
+ color: colors.textSecondary,
4510
+ fontSize: "14px"
4511
+ }, children: "Phone Number" }),
4512
+ /* @__PURE__ */ jsx(
4513
+ PhoneInput,
4514
+ {
4515
+ id: "phoneNumber",
4516
+ value: phoneNumber,
4517
+ onChange: setPhoneNumber,
4518
+ disabled: isLoading,
4519
+ placeholder: "1234567890"
4520
+ }
4521
+ )
4522
+ ] }),
4523
+ showAvatar && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4524
+ /* @__PURE__ */ jsx("label", { htmlFor: "avatar", style: {
4525
+ display: "block",
4526
+ marginBottom: "8px",
4527
+ fontWeight: 500,
4528
+ color: colors.textSecondary,
4529
+ fontSize: "14px"
4530
+ }, children: "Avatar URL" }),
4531
+ /* @__PURE__ */ jsx(
4532
+ "input",
4533
+ {
4534
+ id: "avatar",
4535
+ type: "url",
4536
+ value: avatar,
4537
+ onChange: (e) => setAvatar(e.target.value),
4538
+ disabled: isLoading,
4539
+ style: {
4540
+ width: "100%",
4541
+ padding: "12px 16px",
4542
+ border: `1px solid ${colors.borderSecondary}`,
4543
+ borderRadius: "8px",
4544
+ fontSize: "16px",
4545
+ boxSizing: "border-box",
4546
+ backgroundColor: colors.bgSecondary,
4547
+ color: colors.textPrimary,
4548
+ transition: "all 0.2s ease"
4549
+ },
4550
+ placeholder: "https://example.com/avatar.jpg"
4551
+ }
4552
+ )
4553
+ ] }),
3850
4554
  /* @__PURE__ */ jsx(
3851
4555
  "button",
3852
4556
  {
3853
4557
  type: "submit",
3854
4558
  disabled: isLoading,
3855
- style: {
3856
- padding: "10px 20px",
3857
- backgroundColor: "#007bff",
3858
- color: "white",
3859
- border: "none",
3860
- borderRadius: "8px",
3861
- fontSize: "14px",
3862
- fontWeight: 600,
3863
- cursor: "pointer"
4559
+ onMouseEnter: (e) => {
4560
+ if (!isLoading) {
4561
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4562
+ }
3864
4563
  },
3865
- children: "Update Name"
3866
- }
3867
- )
3868
- ] })
3869
- ] }),
3870
- showAvatar && /* @__PURE__ */ jsxs("div", { style: {
3871
- padding: "20px",
3872
- backgroundColor: "#fff",
3873
- borderRadius: "8px",
3874
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3875
- marginBottom: "20px"
3876
- }, children: [
3877
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
3878
- /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateAvatar, children: [
3879
- /* @__PURE__ */ jsx(
3880
- "input",
3881
- {
3882
- type: "url",
3883
- value: avatar,
3884
- onChange: (e) => setAvatar(e.target.value),
3885
- required: true,
3886
- disabled: isLoading,
3887
- style: {
3888
- width: "100%",
3889
- padding: "12px 16px",
3890
- border: "1px solid #ddd",
3891
- borderRadius: "8px",
3892
- fontSize: "16px",
3893
- boxSizing: "border-box",
3894
- marginBottom: "12px"
4564
+ onMouseLeave: (e) => {
4565
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3895
4566
  },
3896
- placeholder: "Avatar URL"
3897
- }
3898
- ),
3899
- /* @__PURE__ */ jsx(
3900
- "button",
3901
- {
3902
- type: "submit",
3903
- disabled: isLoading,
3904
4567
  style: {
3905
- padding: "10px 20px",
3906
- backgroundColor: "#007bff",
4568
+ padding: "12px 24px",
4569
+ backgroundColor: colors.buttonPrimary,
3907
4570
  color: "white",
3908
4571
  border: "none",
3909
4572
  borderRadius: "8px",
3910
4573
  fontSize: "14px",
3911
4574
  fontWeight: 600,
3912
- cursor: "pointer"
4575
+ cursor: isLoading ? "not-allowed" : "pointer",
4576
+ opacity: isLoading ? 0.6 : 1,
4577
+ transition: "all 0.2s ease"
3913
4578
  },
3914
- children: "Update Avatar"
4579
+ children: isLoading ? "Saving..." : "Save Changes"
3915
4580
  }
3916
4581
  )
3917
4582
  ] })
3918
4583
  ] }),
3919
4584
  showEmailChange && /* @__PURE__ */ jsxs("div", { style: {
3920
- padding: "20px",
3921
- backgroundColor: "#fff",
3922
- borderRadius: "8px",
4585
+ padding: "24px",
4586
+ backgroundColor: colors.bgPrimary,
4587
+ borderRadius: "12px",
3923
4588
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3924
- marginBottom: "20px"
4589
+ marginBottom: "20px",
4590
+ border: `1px solid ${colors.borderPrimary}`
3925
4591
  }, children: [
3926
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
3927
- /* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: "#666", marginBottom: "12px" }, children: [
4592
+ /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
4593
+ /* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
3928
4594
  "Current email: ",
3929
4595
  /* @__PURE__ */ jsx("strong", { children: user.email })
3930
4596
  ] }),
3931
4597
  /* @__PURE__ */ jsxs("form", { onSubmit: handleRequestEmailChange, children: [
3932
- /* @__PURE__ */ jsx(
3933
- "input",
3934
- {
3935
- type: "email",
3936
- value: newEmail,
3937
- onChange: (e) => setNewEmail(e.target.value),
3938
- required: true,
3939
- disabled: isLoading,
3940
- style: {
3941
- width: "100%",
3942
- padding: "12px 16px",
3943
- border: "1px solid #ddd",
3944
- borderRadius: "8px",
3945
- fontSize: "16px",
3946
- boxSizing: "border-box",
3947
- marginBottom: "12px"
3948
- },
3949
- placeholder: "New email address"
3950
- }
3951
- ),
4598
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
4599
+ /* @__PURE__ */ jsx("label", { htmlFor: "newEmail", style: {
4600
+ display: "block",
4601
+ marginBottom: "8px",
4602
+ fontWeight: 500,
4603
+ color: colors.textSecondary,
4604
+ fontSize: "14px"
4605
+ }, children: "New Email Address" }),
4606
+ /* @__PURE__ */ jsx(
4607
+ "input",
4608
+ {
4609
+ id: "newEmail",
4610
+ type: "email",
4611
+ value: newEmail,
4612
+ onChange: (e) => setNewEmail(e.target.value),
4613
+ required: true,
4614
+ disabled: isLoading,
4615
+ style: {
4616
+ width: "100%",
4617
+ padding: "12px 16px",
4618
+ border: `1px solid ${colors.borderSecondary}`,
4619
+ borderRadius: "8px",
4620
+ fontSize: "16px",
4621
+ boxSizing: "border-box",
4622
+ backgroundColor: colors.bgSecondary,
4623
+ color: colors.textPrimary,
4624
+ transition: "all 0.2s ease"
4625
+ },
4626
+ placeholder: "newemail@example.com"
4627
+ }
4628
+ )
4629
+ ] }),
3952
4630
  /* @__PURE__ */ jsx(
3953
4631
  "button",
3954
4632
  {
3955
4633
  type: "submit",
3956
4634
  disabled: isLoading,
4635
+ onMouseEnter: (e) => {
4636
+ if (!isLoading) {
4637
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4638
+ }
4639
+ },
4640
+ onMouseLeave: (e) => {
4641
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
4642
+ },
3957
4643
  style: {
3958
- padding: "10px 20px",
3959
- backgroundColor: "#007bff",
4644
+ padding: "12px 24px",
4645
+ backgroundColor: colors.buttonPrimary,
3960
4646
  color: "white",
3961
4647
  border: "none",
3962
4648
  borderRadius: "8px",
3963
4649
  fontSize: "14px",
3964
4650
  fontWeight: 600,
3965
- cursor: "pointer"
4651
+ cursor: isLoading ? "not-allowed" : "pointer",
4652
+ opacity: isLoading ? 0.6 : 1,
4653
+ transition: "all 0.2s ease"
3966
4654
  },
3967
- children: "Request Email Change"
4655
+ children: isLoading ? "Sending..." : "Request Email Change"
3968
4656
  }
3969
4657
  )
3970
4658
  ] })
@@ -4004,8 +4692,8 @@ var useNextAuth = (config) => {
4004
4692
  const authenticated = authService.isAuthenticated();
4005
4693
  setIsAuthenticated(authenticated);
4006
4694
  if (authenticated) {
4007
- const currentUser2 = authService.getCurrentUser();
4008
- setUser(currentUser2);
4695
+ const currentUser = authService.getCurrentUser();
4696
+ setUser(currentUser);
4009
4697
  } else {
4010
4698
  setUser(null);
4011
4699
  }
@@ -4163,276 +4851,6 @@ var useNextAuth = (config) => {
4163
4851
  };
4164
4852
  };
4165
4853
 
4166
- // src/node/auth-client.ts
4167
- var AuthClient = class extends AuthService {
4168
- constructor(config) {
4169
- super(config);
4170
- }
4171
- // Override methods that require browser-specific features
4172
- // For Node.js, token persistence must be handled manually
4173
- async register(data) {
4174
- const frontendBaseUrl = process.env.FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL;
4175
- if (frontendBaseUrl) {
4176
- this["httpClient"].setFrontendBaseUrl(frontendBaseUrl);
4177
- }
4178
- const response = await this["httpClient"].post("/api/v1/auth/register", data);
4179
- if (response.success && response.message === "Registration data saved. Verification email sent. Please check your inbox.") {
4180
- return response;
4181
- }
4182
- throw new Error(response.message || "Registration failed");
4183
- }
4184
- async login(data) {
4185
- const response = await this["httpClient"].post("/api/v1/auth/login", data);
4186
- if (response.success && response.token) {
4187
- this["token"] = response.token;
4188
- this["httpClient"].setAuthToken(response.token);
4189
- return response;
4190
- }
4191
- if (response.success && response.message === "OTP sent to your email.") {
4192
- return response;
4193
- }
4194
- if (response.success && response.message === "OTP verified successfully." && response.token) {
4195
- this["token"] = response.token;
4196
- this["httpClient"].setAuthToken(response.token);
4197
- return response;
4198
- }
4199
- throw new Error(response.message || "Login failed");
4200
- }
4201
- async verify(data) {
4202
- const response = await this["httpClient"].post("/api/v1/auth/verify", data);
4203
- if (response.success && response.token) {
4204
- this["token"] = response.token;
4205
- this["httpClient"].setAuthToken(response.token);
4206
- }
4207
- return response;
4208
- }
4209
- async logout() {
4210
- this["token"] = null;
4211
- this["httpClient"].removeAuthToken();
4212
- }
4213
- async getProfile() {
4214
- if (!this["token"]) {
4215
- throw new Error("Not authenticated");
4216
- }
4217
- const response = await this["httpClient"].get("/api/v1/user/me");
4218
- return response.user;
4219
- }
4220
- async getUserById(id) {
4221
- const response = await this["httpClient"].get(`/api/v1/user/${id}`);
4222
- return response.user;
4223
- }
4224
- async updateProfile(data) {
4225
- if (!this["token"]) {
4226
- throw new Error("Not authenticated");
4227
- }
4228
- const response = await this["httpClient"].post("/api/v1/user/update/name", data);
4229
- if (response.success && response.token) {
4230
- this["token"] = response.token;
4231
- this["httpClient"].setAuthToken(response.token);
4232
- }
4233
- return response;
4234
- }
4235
- async getAllUsers() {
4236
- if (!this["token"]) {
4237
- throw new Error("Not authenticated");
4238
- }
4239
- const response = await this["httpClient"].get("/api/v1/user/all");
4240
- return response.users;
4241
- }
4242
- };
4243
-
4244
- // src/nextjs/server-auth.ts
4245
- var NextServerAuth = class extends AuthClient {
4246
- constructor(config) {
4247
- super(config);
4248
- }
4249
- // Parse token from request headers
4250
- static parseTokenFromHeaders(headers) {
4251
- const authHeader = headers.get("authorization");
4252
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
4253
- return null;
4254
- }
4255
- return authHeader.substring(7);
4256
- }
4257
- // Parse token from cookies
4258
- static parseTokenFromCookies(cookies2) {
4259
- const cookieArray = cookies2.split(";");
4260
- for (const cookie of cookieArray) {
4261
- const [name, value] = cookie.trim().split("=");
4262
- if (name === "auth_token") {
4263
- return decodeURIComponent(value);
4264
- }
4265
- }
4266
- return null;
4267
- }
4268
- // Parse token from Next.js request object
4269
- static parseTokenFromRequest(req) {
4270
- if (req.headers) {
4271
- const authHeader = req.headers.authorization || req.headers.Authorization;
4272
- if (authHeader && authHeader.startsWith("Bearer ")) {
4273
- return authHeader.substring(7);
4274
- }
4275
- }
4276
- if (req.cookies) {
4277
- return req.cookies.auth_token || null;
4278
- }
4279
- if (req.headers && req.headers.cookie) {
4280
- return this.parseTokenFromCookies(req.headers.cookie);
4281
- }
4282
- return null;
4283
- }
4284
- // Verify token and get user
4285
- async verifyToken(token) {
4286
- try {
4287
- this["httpClient"].setAuthToken(token);
4288
- const user = await this.getProfile();
4289
- return user;
4290
- } catch (error) {
4291
- console.error("Token verification failed:", error);
4292
- return null;
4293
- }
4294
- }
4295
- // Create authenticated client with token
4296
- static createAuthenticatedClient(config, token) {
4297
- const client = new NextServerAuth(config);
4298
- client["httpClient"].setAuthToken(token);
4299
- client["token"] = token;
4300
- return client;
4301
- }
4302
- };
4303
- var AuthServer = class {
4304
- constructor(config) {
4305
- this.config = {
4306
- authApiUrl: config?.authApiUrl || process.env.AUTH_API_URL || "http://localhost:7000",
4307
- tokenCookieName: config?.tokenCookieName || "auth_token"
4308
- };
4309
- }
4310
- async getToken() {
4311
- const cookieStore = await cookies();
4312
- const token = cookieStore.get(this.config.tokenCookieName);
4313
- return token?.value || null;
4314
- }
4315
- async getCurrentUser() {
4316
- const token = await this.getToken();
4317
- if (!token)
4318
- return null;
4319
- try {
4320
- const payload = JSON.parse(Buffer.from(token.split(".")[1], "base64").toString());
4321
- return payload.user || null;
4322
- } catch (error) {
4323
- console.error("Failed to parse user from token:", error);
4324
- return null;
4325
- }
4326
- }
4327
- async isAuthenticated() {
4328
- const token = await this.getToken();
4329
- return !!token;
4330
- }
4331
- async requireAuth(redirectTo) {
4332
- const user = await this.getCurrentUser();
4333
- if (!user) {
4334
- const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
4335
- redirect(loginPath);
4336
- }
4337
- return user;
4338
- }
4339
- async redirectIfAuthenticated(redirectTo) {
4340
- const isAuth = await this.isAuthenticated();
4341
- if (isAuth) {
4342
- const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
4343
- redirect(dashboardPath);
4344
- }
4345
- }
4346
- async getProfile() {
4347
- const token = await this.getToken();
4348
- if (!token)
4349
- return null;
4350
- try {
4351
- const response = await fetch(`${this.config.authApiUrl}/api/v1/user/me`, {
4352
- headers: {
4353
- "Authorization": `Bearer ${token}`
4354
- }
4355
- });
4356
- if (!response.ok) {
4357
- return null;
4358
- }
4359
- const data = await response.json();
4360
- return data.user;
4361
- } catch (error) {
4362
- console.error("Failed to fetch profile:", error);
4363
- return null;
4364
- }
4365
- }
4366
- };
4367
- var authServerInstance = null;
4368
- function getAuthServer(config) {
4369
- if (!authServerInstance) {
4370
- authServerInstance = new AuthServer(config);
4371
- }
4372
- return authServerInstance;
4373
- }
4374
- async function currentUser() {
4375
- const auth2 = getAuthServer();
4376
- return auth2.getCurrentUser();
4377
- }
4378
- async function auth() {
4379
- const authServer = getAuthServer();
4380
- const user = await authServer.getCurrentUser();
4381
- const token = await authServer.getToken();
4382
- return {
4383
- user,
4384
- userId: user?._id || null,
4385
- isAuthenticated: !!user,
4386
- token
4387
- };
4388
- }
4389
- async function requireAuth(redirectTo) {
4390
- const authServer = getAuthServer();
4391
- return authServer.requireAuth(redirectTo);
4392
- }
4393
- async function redirectIfAuthenticated(redirectTo) {
4394
- const authServer = getAuthServer();
4395
- return authServer.redirectIfAuthenticated(redirectTo);
4396
- }
4397
- function authMiddleware(config) {
4398
- const {
4399
- publicRoutes = ["/auth/login", "/auth/register", "/auth/verify-email", "/auth/forgot-password", "/auth/reset-password"],
4400
- protectedRoutes = ["/dashboard"],
4401
- loginUrl = "/auth/login",
4402
- afterLoginUrl = "/dashboard",
4403
- tokenCookieName = "auth_token"
4404
- } = config || {};
4405
- return function middleware(request) {
4406
- const { pathname } = request.nextUrl;
4407
- const token = request.cookies.get(tokenCookieName)?.value;
4408
- const isAuthenticated = !!token;
4409
- const isPublicRoute = publicRoutes.some((route) => {
4410
- if (route.endsWith("*")) {
4411
- return pathname.startsWith(route.slice(0, -1));
4412
- }
4413
- return pathname === route || pathname.startsWith(route + "/");
4414
- });
4415
- const isProtectedRoute = protectedRoutes.some((route) => {
4416
- if (route.endsWith("*")) {
4417
- return pathname.startsWith(route.slice(0, -1));
4418
- }
4419
- return pathname === route || pathname.startsWith(route + "/");
4420
- });
4421
- if (isAuthenticated && isPublicRoute) {
4422
- return NextResponse.redirect(new URL(afterLoginUrl, request.url));
4423
- }
4424
- if (!isAuthenticated && isProtectedRoute) {
4425
- const loginUrlWithRedirect = new URL(loginUrl, request.url);
4426
- loginUrlWithRedirect.searchParams.set("redirect", pathname);
4427
- return NextResponse.redirect(loginUrlWithRedirect);
4428
- }
4429
- return NextResponse.next();
4430
- };
4431
- }
4432
- function createAuthMiddleware(config) {
4433
- return authMiddleware(config);
4434
- }
4435
-
4436
- export { AuthFlow, AuthProvider, AuthServer, AuthService, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, NextServerAuth, OtpForm, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, auth, authMiddleware, createAuthMiddleware, currentUser, getAuthServer, redirectIfAuthenticated, requireAuth, useAuth2 as useAuth, useAuth as useAuthLegacy, useNextAuth };
4854
+ export { AuthFlow, AuthProvider, AuthService, AuthThemeProvider, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, useAuth2 as useAuth, useAuth as useAuthLegacy, useAuthTheme, useNextAuth };
4437
4855
  //# sourceMappingURL=out.js.map
4438
4856
  //# sourceMappingURL=index.next.mjs.map