@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,23 +1,26 @@
1
+ "use client";
1
2
  'use strict';
2
3
 
3
4
  var axios = require('axios');
4
- var react = require('react');
5
+ var React3 = require('react');
5
6
  var jsxRuntime = require('react/jsx-runtime');
6
- var headers = require('next/headers');
7
- var navigation = require('next/navigation');
8
- var server = require('next/server');
7
+ var PhoneInputWithCountry = require('react-phone-number-input');
8
+ require('react-phone-number-input/style.css');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
12
  var axios__default = /*#__PURE__*/_interopDefault(axios);
13
+ var React3__default = /*#__PURE__*/_interopDefault(React3);
14
+ var PhoneInputWithCountry__default = /*#__PURE__*/_interopDefault(PhoneInputWithCountry);
13
15
 
14
16
  // src/core/http-client.ts
15
17
  var HttpClient = class {
16
18
  constructor(baseUrl, defaultHeaders = {}) {
17
19
  this.csrfToken = null;
18
20
  this.frontendBaseUrl = null;
21
+ this.baseUrl = baseUrl.replace(/\/$/, "");
19
22
  this.axiosInstance = axios__default.default.create({
20
- baseURL: baseUrl.replace(/\/$/, ""),
23
+ baseURL: this.baseUrl,
21
24
  headers: {
22
25
  "Content-Type": "application/json",
23
26
  ...defaultHeaders
@@ -28,8 +31,16 @@ var HttpClient = class {
28
31
  // 30 second timeout
29
32
  });
30
33
  this.axiosInstance.interceptors.request.use(
31
- (config) => {
32
- if (this.csrfToken && ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "")) {
34
+ async (config) => {
35
+ const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
36
+ if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
37
+ try {
38
+ await this.refreshCsrfToken();
39
+ } catch (error) {
40
+ console.warn("Failed to fetch CSRF token:", error);
41
+ }
42
+ }
43
+ if (this.csrfToken && isMutatingRequest) {
33
44
  config.headers["x-csrf-token"] = this.csrfToken;
34
45
  }
35
46
  if (this.frontendBaseUrl) {
@@ -127,9 +138,6 @@ var AuthService = class {
127
138
  this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
128
139
  }
129
140
  }
130
- if (this.config.csrfEnabled && typeof window !== "undefined") {
131
- this.refreshCsrfToken();
132
- }
133
141
  }
134
142
  loadTokenFromStorage() {
135
143
  if (typeof window !== "undefined" && this.config.localStorageKey) {
@@ -231,7 +239,7 @@ var AuthService = class {
231
239
  this.saveTokenToStorage(response.token);
232
240
  return response;
233
241
  }
234
- if (response.success && response.message === "OTP sent to your email.") {
242
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
235
243
  return response;
236
244
  }
237
245
  if (response.success && response.message === "OTP verified successfully." && response.token) {
@@ -302,7 +310,7 @@ var AuthService = class {
302
310
  if (!this.token) {
303
311
  throw new Error("Not authenticated");
304
312
  }
305
- const response = await this.httpClient.post("/api/v1/user/update/user", data);
313
+ const response = await this.httpClient.post("/api/v1/user/update/profile", data);
306
314
  if (response.success && response.token) {
307
315
  this.token = response.token;
308
316
  this.httpClient.setAuthToken(response.token);
@@ -343,7 +351,7 @@ var AuthService = class {
343
351
  if (!this.token) {
344
352
  throw new Error("Not authenticated");
345
353
  }
346
- const response = await this.httpClient.post("/api/v1/user/update/avatar", { avatar });
354
+ const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
347
355
  if (response.success && response.token) {
348
356
  this.token = response.token;
349
357
  this.httpClient.setAuthToken(response.token);
@@ -406,21 +414,21 @@ var AuthService = class {
406
414
  if (!this.token) {
407
415
  throw new Error("Not authenticated");
408
416
  }
409
- const response = await this.httpClient.get("/api/v1/session");
417
+ const response = await this.httpClient.get("/api/v1/sessions");
410
418
  return response;
411
419
  }
412
420
  async revokeSession(sessionId) {
413
421
  if (!this.token) {
414
422
  throw new Error("Not authenticated");
415
423
  }
416
- const response = await this.httpClient.delete(`/api/v1/session/${sessionId}`);
424
+ const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
417
425
  return response;
418
426
  }
419
427
  async revokeAllSessions() {
420
428
  if (!this.token) {
421
429
  throw new Error("Not authenticated");
422
430
  }
423
- const response = await this.httpClient.delete("/api/v1/session/revoke/all");
431
+ const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
424
432
  this.token = null;
425
433
  this.httpClient.removeAuthToken();
426
434
  this.removeTokenFromStorage();
@@ -467,25 +475,25 @@ var AuthService = class {
467
475
  }
468
476
  };
469
477
  var useAuth = (config) => {
470
- const [authService] = react.useState(() => new AuthService(config));
471
- const [user, setUser] = react.useState(null);
472
- const [isAuthenticated, setIsAuthenticated] = react.useState(false);
473
- const [loading, setLoading] = react.useState(true);
474
- const checkAuthStatus = react.useCallback(() => {
478
+ const [authService] = React3.useState(() => new AuthService(config));
479
+ const [user, setUser] = React3.useState(null);
480
+ const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
481
+ const [loading, setLoading] = React3.useState(true);
482
+ const checkAuthStatus = React3.useCallback(() => {
475
483
  const authenticated = authService.isAuthenticated();
476
484
  setIsAuthenticated(authenticated);
477
485
  if (authenticated) {
478
- const currentUser2 = authService.getCurrentUser();
479
- setUser(currentUser2);
486
+ const currentUser = authService.getCurrentUser();
487
+ setUser(currentUser);
480
488
  } else {
481
489
  setUser(null);
482
490
  }
483
491
  setLoading(false);
484
492
  }, [authService]);
485
- react.useEffect(() => {
493
+ React3.useEffect(() => {
486
494
  checkAuthStatus();
487
495
  }, [checkAuthStatus]);
488
- const register = react.useCallback(async (data) => {
496
+ const register = React3.useCallback(async (data) => {
489
497
  setLoading(true);
490
498
  try {
491
499
  const response = await authService.register(data);
@@ -494,7 +502,7 @@ var useAuth = (config) => {
494
502
  setLoading(false);
495
503
  }
496
504
  }, [authService]);
497
- const login = react.useCallback(async (data) => {
505
+ const login = React3.useCallback(async (data) => {
498
506
  setLoading(true);
499
507
  try {
500
508
  const response = await authService.login(data);
@@ -507,7 +515,7 @@ var useAuth = (config) => {
507
515
  setLoading(false);
508
516
  }
509
517
  }, [authService]);
510
- const verify = react.useCallback(async (data) => {
518
+ const verify = React3.useCallback(async (data) => {
511
519
  setLoading(true);
512
520
  try {
513
521
  const response = await authService.verify(data);
@@ -520,7 +528,7 @@ var useAuth = (config) => {
520
528
  setLoading(false);
521
529
  }
522
530
  }, [authService]);
523
- const verifyEmailToken = react.useCallback(async (token) => {
531
+ const verifyEmailToken = React3.useCallback(async (token) => {
524
532
  setLoading(true);
525
533
  try {
526
534
  const response = await authService.verifyEmailToken(token);
@@ -533,7 +541,7 @@ var useAuth = (config) => {
533
541
  setLoading(false);
534
542
  }
535
543
  }, [authService]);
536
- const logout = react.useCallback(async () => {
544
+ const logout = React3.useCallback(async () => {
537
545
  setLoading(true);
538
546
  try {
539
547
  await authService.logout();
@@ -543,7 +551,7 @@ var useAuth = (config) => {
543
551
  setLoading(false);
544
552
  }
545
553
  }, [authService]);
546
- const updateProfile = react.useCallback(async (data) => {
554
+ const updateProfile = React3.useCallback(async (data) => {
547
555
  setLoading(true);
548
556
  try {
549
557
  const response = await authService.updateProfile(data);
@@ -555,7 +563,7 @@ var useAuth = (config) => {
555
563
  setLoading(false);
556
564
  }
557
565
  }, [authService]);
558
- const getProfile = react.useCallback(async () => {
566
+ const getProfile = React3.useCallback(async () => {
559
567
  setLoading(true);
560
568
  try {
561
569
  const userData = await authService.getProfile();
@@ -565,7 +573,7 @@ var useAuth = (config) => {
565
573
  setLoading(false);
566
574
  }
567
575
  }, [authService]);
568
- const getAllUsers = react.useCallback(async () => {
576
+ const getAllUsers = React3.useCallback(async () => {
569
577
  setLoading(true);
570
578
  try {
571
579
  return await authService.getAllUsers();
@@ -573,7 +581,7 @@ var useAuth = (config) => {
573
581
  setLoading(false);
574
582
  }
575
583
  }, [authService]);
576
- const getUserById = react.useCallback(async (id) => {
584
+ const getUserById = React3.useCallback(async (id) => {
577
585
  setLoading(true);
578
586
  try {
579
587
  return await authService.getUserById(id);
@@ -596,23 +604,74 @@ var useAuth = (config) => {
596
604
  getUserById
597
605
  };
598
606
  };
599
- var AuthContext = react.createContext(void 0);
607
+ var ThemeContext = React3.createContext({ theme: "light", mounted: false });
608
+ function AuthThemeProvider({ children }) {
609
+ const [theme, setTheme] = React3.useState("light");
610
+ const [mounted, setMounted] = React3.useState(false);
611
+ React3.useEffect(() => {
612
+ const detectTheme = () => {
613
+ const htmlElement = document.documentElement;
614
+ const bodyElement = document.body;
615
+ if (htmlElement.classList.contains("dark") || bodyElement.classList.contains("dark")) {
616
+ return "dark";
617
+ }
618
+ if (htmlElement.classList.contains("light") || bodyElement.classList.contains("light")) {
619
+ return "light";
620
+ }
621
+ const dataTheme = htmlElement.getAttribute("data-theme") || bodyElement.getAttribute("data-theme");
622
+ if (dataTheme === "dark" || dataTheme === "light") {
623
+ return dataTheme;
624
+ }
625
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
626
+ return "dark";
627
+ }
628
+ return "light";
629
+ };
630
+ const updateTheme = () => {
631
+ const detectedTheme = detectTheme();
632
+ setTheme(detectedTheme);
633
+ };
634
+ updateTheme();
635
+ setMounted(true);
636
+ const observer = new MutationObserver(updateTheme);
637
+ observer.observe(document.documentElement, {
638
+ attributes: true,
639
+ attributeFilter: ["class", "data-theme"]
640
+ });
641
+ observer.observe(document.body, {
642
+ attributes: true,
643
+ attributeFilter: ["class", "data-theme"]
644
+ });
645
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
646
+ const handleMediaChange = () => updateTheme();
647
+ mediaQuery.addEventListener("change", handleMediaChange);
648
+ return () => {
649
+ observer.disconnect();
650
+ mediaQuery.removeEventListener("change", handleMediaChange);
651
+ };
652
+ }, []);
653
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
654
+ }
655
+ function useAuthTheme() {
656
+ return React3.useContext(ThemeContext);
657
+ }
658
+ var AuthContext = React3.createContext(void 0);
600
659
  var AuthProvider = ({ children, config }) => {
601
660
  const authConfig = {
602
661
  baseUrl: config?.baseUrl || (typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || process.env.REACT_APP_AUTH_API_URL || "http://localhost:7000" : "http://localhost:7000"),
603
662
  localStorageKey: config?.localStorageKey || "auth_token",
604
663
  csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true
605
664
  };
606
- const [authService] = react.useState(() => new AuthService(authConfig));
607
- const [user, setUser] = react.useState(null);
608
- const [isLoaded, setIsLoaded] = react.useState(false);
609
- const [loading, setLoading] = react.useState(false);
610
- const checkAuthStatus = react.useCallback(async () => {
665
+ const [authService] = React3.useState(() => new AuthService(authConfig));
666
+ const [user, setUser] = React3.useState(null);
667
+ const [isLoaded, setIsLoaded] = React3.useState(false);
668
+ const [loading, setLoading] = React3.useState(false);
669
+ const checkAuthStatus = React3.useCallback(async () => {
611
670
  const authenticated = authService.isAuthenticated();
612
671
  if (authenticated) {
613
672
  try {
614
- const currentUser2 = authService.getCurrentUser();
615
- setUser(currentUser2);
673
+ const currentUser = authService.getCurrentUser();
674
+ setUser(currentUser);
616
675
  } catch (error) {
617
676
  console.error("Failed to get current user:", error);
618
677
  setUser(null);
@@ -622,10 +681,10 @@ var AuthProvider = ({ children, config }) => {
622
681
  }
623
682
  setIsLoaded(true);
624
683
  }, [authService]);
625
- react.useEffect(() => {
684
+ React3.useEffect(() => {
626
685
  checkAuthStatus();
627
686
  }, [checkAuthStatus]);
628
- const signIn = react.useCallback(async (data) => {
687
+ const signIn = React3.useCallback(async (data) => {
629
688
  setLoading(true);
630
689
  try {
631
690
  const response = await authService.login(data);
@@ -637,7 +696,7 @@ var AuthProvider = ({ children, config }) => {
637
696
  setLoading(false);
638
697
  }
639
698
  }, [authService]);
640
- const signUp = react.useCallback(async (data) => {
699
+ const signUp = React3.useCallback(async (data) => {
641
700
  setLoading(true);
642
701
  try {
643
702
  const response = await authService.register(data);
@@ -646,7 +705,7 @@ var AuthProvider = ({ children, config }) => {
646
705
  setLoading(false);
647
706
  }
648
707
  }, [authService]);
649
- const signOut = react.useCallback(async () => {
708
+ const signOut = React3.useCallback(async () => {
650
709
  setLoading(true);
651
710
  try {
652
711
  await authService.logout();
@@ -655,7 +714,7 @@ var AuthProvider = ({ children, config }) => {
655
714
  setLoading(false);
656
715
  }
657
716
  }, [authService]);
658
- const verify = react.useCallback(async (data) => {
717
+ const verify = React3.useCallback(async (data) => {
659
718
  setLoading(true);
660
719
  try {
661
720
  const response = await authService.verify(data);
@@ -667,7 +726,7 @@ var AuthProvider = ({ children, config }) => {
667
726
  setLoading(false);
668
727
  }
669
728
  }, [authService]);
670
- const verifyEmailToken = react.useCallback(async (token) => {
729
+ const verifyEmailToken = React3.useCallback(async (token) => {
671
730
  setLoading(true);
672
731
  try {
673
732
  const response = await authService.verifyEmailToken(token);
@@ -679,7 +738,7 @@ var AuthProvider = ({ children, config }) => {
679
738
  setLoading(false);
680
739
  }
681
740
  }, [authService]);
682
- const updateProfile = react.useCallback(async (data) => {
741
+ const updateProfile = React3.useCallback(async (data) => {
683
742
  setLoading(true);
684
743
  try {
685
744
  const response = await authService.updateProfile(data);
@@ -691,7 +750,7 @@ var AuthProvider = ({ children, config }) => {
691
750
  setLoading(false);
692
751
  }
693
752
  }, [authService]);
694
- const getProfile = react.useCallback(async () => {
753
+ const getProfile = React3.useCallback(async () => {
695
754
  setLoading(true);
696
755
  try {
697
756
  const userData = await authService.getProfile();
@@ -701,13 +760,13 @@ var AuthProvider = ({ children, config }) => {
701
760
  setLoading(false);
702
761
  }
703
762
  }, [authService]);
704
- const signInWithOAuth = react.useCallback((provider) => {
763
+ const signInWithOAuth = React3.useCallback((provider) => {
705
764
  authService.loginWithOAuth(provider);
706
765
  }, [authService]);
707
- const linkOAuthProvider = react.useCallback((provider) => {
766
+ const linkOAuthProvider = React3.useCallback((provider) => {
708
767
  authService.linkOAuthProvider(provider);
709
768
  }, [authService]);
710
- const unlinkOAuthProvider = react.useCallback(async (provider) => {
769
+ const unlinkOAuthProvider = React3.useCallback(async (provider) => {
711
770
  setLoading(true);
712
771
  try {
713
772
  return await authService.unlinkOAuthProvider(provider);
@@ -715,7 +774,7 @@ var AuthProvider = ({ children, config }) => {
715
774
  setLoading(false);
716
775
  }
717
776
  }, [authService]);
718
- const forgotPassword = react.useCallback(async (email) => {
777
+ const forgotPassword = React3.useCallback(async (email) => {
719
778
  setLoading(true);
720
779
  try {
721
780
  return await authService.forgotPassword(email);
@@ -723,7 +782,7 @@ var AuthProvider = ({ children, config }) => {
723
782
  setLoading(false);
724
783
  }
725
784
  }, [authService]);
726
- const resetPassword = react.useCallback(async (token, password) => {
785
+ const resetPassword = React3.useCallback(async (token, password) => {
727
786
  setLoading(true);
728
787
  try {
729
788
  return await authService.resetPassword(token, password);
@@ -731,7 +790,7 @@ var AuthProvider = ({ children, config }) => {
731
790
  setLoading(false);
732
791
  }
733
792
  }, [authService]);
734
- const changePassword = react.useCallback(async (oldPassword, newPassword) => {
793
+ const changePassword = React3.useCallback(async (oldPassword, newPassword) => {
735
794
  setLoading(true);
736
795
  try {
737
796
  return await authService.changePassword(oldPassword, newPassword);
@@ -739,7 +798,7 @@ var AuthProvider = ({ children, config }) => {
739
798
  setLoading(false);
740
799
  }
741
800
  }, [authService]);
742
- const updateAvatar = react.useCallback(async (avatar) => {
801
+ const updateAvatar = React3.useCallback(async (avatar) => {
743
802
  setLoading(true);
744
803
  try {
745
804
  const response = await authService.updateAvatar(avatar);
@@ -751,7 +810,7 @@ var AuthProvider = ({ children, config }) => {
751
810
  setLoading(false);
752
811
  }
753
812
  }, [authService]);
754
- const requestEmailChange = react.useCallback(async (newEmail) => {
813
+ const requestEmailChange = React3.useCallback(async (newEmail) => {
755
814
  setLoading(true);
756
815
  try {
757
816
  return await authService.requestEmailChange(newEmail);
@@ -759,7 +818,7 @@ var AuthProvider = ({ children, config }) => {
759
818
  setLoading(false);
760
819
  }
761
820
  }, [authService]);
762
- const verifyEmailChange = react.useCallback(async (token) => {
821
+ const verifyEmailChange = React3.useCallback(async (token) => {
763
822
  setLoading(true);
764
823
  try {
765
824
  const response = await authService.verifyEmailChange(token);
@@ -771,7 +830,7 @@ var AuthProvider = ({ children, config }) => {
771
830
  setLoading(false);
772
831
  }
773
832
  }, [authService]);
774
- const generate2FA = react.useCallback(async () => {
833
+ const generate2FA = React3.useCallback(async () => {
775
834
  setLoading(true);
776
835
  try {
777
836
  return await authService.generate2FA();
@@ -779,7 +838,7 @@ var AuthProvider = ({ children, config }) => {
779
838
  setLoading(false);
780
839
  }
781
840
  }, [authService]);
782
- const enable2FA = react.useCallback(async (token) => {
841
+ const enable2FA = React3.useCallback(async (token) => {
783
842
  setLoading(true);
784
843
  try {
785
844
  return await authService.enable2FA(token);
@@ -787,7 +846,7 @@ var AuthProvider = ({ children, config }) => {
787
846
  setLoading(false);
788
847
  }
789
848
  }, [authService]);
790
- const disable2FA = react.useCallback(async (token) => {
849
+ const disable2FA = React3.useCallback(async (token) => {
791
850
  setLoading(true);
792
851
  try {
793
852
  return await authService.disable2FA(token);
@@ -795,7 +854,7 @@ var AuthProvider = ({ children, config }) => {
795
854
  setLoading(false);
796
855
  }
797
856
  }, [authService]);
798
- const validate2FA = react.useCallback(async (token) => {
857
+ const validate2FA = React3.useCallback(async (token) => {
799
858
  setLoading(true);
800
859
  try {
801
860
  return await authService.validate2FA(token);
@@ -803,7 +862,7 @@ var AuthProvider = ({ children, config }) => {
803
862
  setLoading(false);
804
863
  }
805
864
  }, [authService]);
806
- const getSessions = react.useCallback(async () => {
865
+ const getSessions = React3.useCallback(async () => {
807
866
  setLoading(true);
808
867
  try {
809
868
  return await authService.getSessions();
@@ -811,7 +870,7 @@ var AuthProvider = ({ children, config }) => {
811
870
  setLoading(false);
812
871
  }
813
872
  }, [authService]);
814
- const revokeSession = react.useCallback(async (sessionId) => {
873
+ const revokeSession = React3.useCallback(async (sessionId) => {
815
874
  setLoading(true);
816
875
  try {
817
876
  return await authService.revokeSession(sessionId);
@@ -819,7 +878,7 @@ var AuthProvider = ({ children, config }) => {
819
878
  setLoading(false);
820
879
  }
821
880
  }, [authService]);
822
- const revokeAllSessions = react.useCallback(async () => {
881
+ const revokeAllSessions = React3.useCallback(async () => {
823
882
  setLoading(true);
824
883
  try {
825
884
  const response = await authService.revokeAllSessions();
@@ -859,15 +918,276 @@ var AuthProvider = ({ children, config }) => {
859
918
  revokeAllSessions,
860
919
  authService
861
920
  };
862
- return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
921
+ return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
863
922
  };
864
923
  var useAuth2 = () => {
865
- const context = react.useContext(AuthContext);
924
+ const context = React3.useContext(AuthContext);
866
925
  if (context === void 0) {
867
926
  throw new Error("useAuth must be used within an AuthProvider");
868
927
  }
869
928
  return context;
870
929
  };
930
+
931
+ // src/react/hooks/useThemeColors.ts
932
+ var lightTheme = {
933
+ bgPrimary: "var(--auth-bg-primary, #ffffff)",
934
+ bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
935
+ bgHover: "var(--auth-bg-hover, #f1f5f9)",
936
+ textPrimary: "var(--auth-text-primary, #0f172a)",
937
+ textSecondary: "var(--auth-text-secondary, #475569)",
938
+ textTertiary: "var(--auth-text-tertiary, #94a3b8)",
939
+ borderPrimary: "var(--auth-border-primary, #e2e8f0)",
940
+ borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
941
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
942
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
943
+ errorBg: "var(--auth-error-bg, #fef2f2)",
944
+ errorText: "var(--auth-error-text, #dc2626)",
945
+ errorBorder: "var(--auth-error-border, #fecaca)",
946
+ successBg: "var(--auth-success-bg, #f0fdf4)",
947
+ successText: "var(--auth-success-text, #16a34a)",
948
+ successBorder: "var(--auth-success-border, #bbf7d0)"
949
+ };
950
+ var darkTheme = {
951
+ bgPrimary: "var(--auth-bg-primary, #1f2937)",
952
+ bgSecondary: "var(--auth-bg-secondary, #111827)",
953
+ bgHover: "var(--auth-bg-hover, #374151)",
954
+ textPrimary: "var(--auth-text-primary, #f9fafb)",
955
+ textSecondary: "var(--auth-text-secondary, #e5e7eb)",
956
+ textTertiary: "var(--auth-text-tertiary, #d1d5db)",
957
+ borderPrimary: "var(--auth-border-primary, #374151)",
958
+ borderSecondary: "var(--auth-border-secondary, #4b5563)",
959
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
960
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
961
+ errorBg: "var(--auth-error-bg, #7f1d1d)",
962
+ errorText: "var(--auth-error-text, #fecaca)",
963
+ errorBorder: "var(--auth-error-border, #991b1b)",
964
+ successBg: "var(--auth-success-bg, #14532d)",
965
+ successText: "var(--auth-success-text, #bbf7d0)",
966
+ successBorder: "var(--auth-success-border, #166534)"
967
+ };
968
+ function useThemeColors() {
969
+ const { theme } = useAuthTheme();
970
+ return theme === "dark" ? darkTheme : lightTheme;
971
+ }
972
+ var CustomPhoneInput = React3__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
973
+ "input",
974
+ {
975
+ ...props,
976
+ ref,
977
+ className: "PhoneInputInput"
978
+ }
979
+ ));
980
+ CustomPhoneInput.displayName = "CustomPhoneInput";
981
+ var PhoneInput = ({
982
+ value,
983
+ onChange,
984
+ disabled = false,
985
+ required = false,
986
+ placeholder = "Enter phone number",
987
+ id = "phone",
988
+ style = {}
989
+ }) => {
990
+ const colors = useThemeColors();
991
+ const [defaultCountry, setDefaultCountry] = React3.useState("US");
992
+ const styleContent = React3.useMemo(() => `
993
+ .PhoneInput {
994
+ display: flex;
995
+ align-items: center;
996
+ gap: 8px;
997
+ }
998
+
999
+ .PhoneInputCountry {
1000
+ position: relative;
1001
+ align-self: stretch;
1002
+ display: flex;
1003
+ align-items: center;
1004
+ padding: 0 8px;
1005
+ border: 1px solid ${colors.borderSecondary};
1006
+ border-radius: 8px;
1007
+ background-color: ${colors.bgSecondary};
1008
+ transition: all 0.2s ease;
1009
+ }
1010
+
1011
+ .PhoneInputCountry:focus-within {
1012
+ border-color: ${colors.buttonPrimary};
1013
+ outline: 2px solid ${colors.buttonPrimary}40;
1014
+ }
1015
+
1016
+ .PhoneInputCountryIcon {
1017
+ width: 24px;
1018
+ height: 24px;
1019
+ margin-right: 4px;
1020
+ }
1021
+
1022
+ .PhoneInputCountryIcon--border {
1023
+ box-shadow: none;
1024
+ }
1025
+
1026
+ .PhoneInputCountrySelect {
1027
+ position: absolute;
1028
+ top: 0;
1029
+ left: 0;
1030
+ height: 100%;
1031
+ width: 100%;
1032
+ z-index: 1;
1033
+ border: 0;
1034
+ opacity: 0;
1035
+ cursor: pointer;
1036
+ color: ${colors.textPrimary};
1037
+ background-color: ${colors.bgSecondary};
1038
+ }
1039
+
1040
+ .PhoneInputCountrySelect:disabled {
1041
+ cursor: not-allowed;
1042
+ }
1043
+
1044
+ /* Dropdown menu styling */
1045
+ .PhoneInputCountrySelect option {
1046
+ background-color: ${colors.bgPrimary};
1047
+ color: ${colors.textPrimary};
1048
+ padding: 8px 12px;
1049
+ font-size: 14px;
1050
+ }
1051
+
1052
+ .PhoneInputCountrySelect option:hover,
1053
+ .PhoneInputCountrySelect option:focus,
1054
+ .PhoneInputCountrySelect option:checked {
1055
+ background-color: ${colors.buttonPrimary};
1056
+ color: white;
1057
+ }
1058
+
1059
+ .PhoneInputCountrySelectArrow {
1060
+ display: block;
1061
+ content: '';
1062
+ width: 0.3em;
1063
+ height: 0.3em;
1064
+ margin-left: 0.35em;
1065
+ border-style: solid;
1066
+ border-color: ${colors.textPrimary};
1067
+ border-top-width: 0;
1068
+ border-bottom-width: 1px;
1069
+ border-left-width: 0;
1070
+ border-right-width: 1px;
1071
+ transform: rotate(45deg);
1072
+ opacity: 0.7;
1073
+ }
1074
+
1075
+ .PhoneInputInput {
1076
+ flex: 1;
1077
+ min-width: 0;
1078
+ padding: 12px 16px;
1079
+ border: 1px solid ${colors.borderSecondary};
1080
+ border-radius: 8px;
1081
+ font-size: 16px;
1082
+ background-color: ${colors.bgSecondary};
1083
+ color: ${colors.textPrimary};
1084
+ transition: all 0.2s ease;
1085
+ -webkit-text-fill-color: ${colors.textPrimary};
1086
+ -webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
1087
+ }
1088
+
1089
+ .PhoneInputInput:focus {
1090
+ border-color: ${colors.buttonPrimary};
1091
+ outline: 2px solid ${colors.buttonPrimary}40;
1092
+ }
1093
+
1094
+ .PhoneInputInput:disabled {
1095
+ cursor: not-allowed;
1096
+ opacity: 0.6;
1097
+ }
1098
+
1099
+ .PhoneInputInput::placeholder {
1100
+ color: ${colors.textTertiary};
1101
+ opacity: 0.6;
1102
+ }
1103
+ `, [colors]);
1104
+ React3.useEffect(() => {
1105
+ const detectCountry = async () => {
1106
+ try {
1107
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1108
+ const timezoneToCountry = {
1109
+ "America/New_York": "US",
1110
+ "America/Chicago": "US",
1111
+ "America/Denver": "US",
1112
+ "America/Los_Angeles": "US",
1113
+ "America/Phoenix": "US",
1114
+ "America/Anchorage": "US",
1115
+ "Pacific/Honolulu": "US",
1116
+ "Europe/London": "GB",
1117
+ "Europe/Paris": "FR",
1118
+ "Europe/Berlin": "DE",
1119
+ "Europe/Rome": "IT",
1120
+ "Europe/Madrid": "ES",
1121
+ "Asia/Dubai": "AE",
1122
+ "Asia/Kolkata": "IN",
1123
+ "Asia/Shanghai": "CN",
1124
+ "Asia/Tokyo": "JP",
1125
+ "Asia/Seoul": "KR",
1126
+ "Asia/Singapore": "SG",
1127
+ "Asia/Hong_Kong": "HK",
1128
+ "Australia/Sydney": "AU",
1129
+ "Pacific/Auckland": "NZ",
1130
+ "America/Toronto": "CA",
1131
+ "America/Vancouver": "CA",
1132
+ "America/Mexico_City": "MX",
1133
+ "America/Sao_Paulo": "BR",
1134
+ "America/Buenos_Aires": "AR",
1135
+ "Africa/Cairo": "EG",
1136
+ "Africa/Johannesburg": "ZA",
1137
+ "Africa/Lagos": "NG",
1138
+ "Africa/Nairobi": "KE"
1139
+ };
1140
+ const detectedCountry = timezoneToCountry[timezone];
1141
+ if (detectedCountry) {
1142
+ setDefaultCountry(detectedCountry);
1143
+ return;
1144
+ }
1145
+ const response = await fetch("https://ipapi.co/json/", {
1146
+ signal: AbortSignal.timeout(3e3)
1147
+ // 3 second timeout
1148
+ });
1149
+ if (response.ok) {
1150
+ const data = await response.json();
1151
+ if (data.country_code) {
1152
+ setDefaultCountry(data.country_code);
1153
+ }
1154
+ }
1155
+ } catch (error) {
1156
+ console.log("Country detection failed, using default US");
1157
+ }
1158
+ };
1159
+ detectCountry();
1160
+ }, []);
1161
+ const handleChange = React3.useMemo(() => (val) => {
1162
+ onChange(val || "");
1163
+ }, [onChange]);
1164
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1165
+ "div",
1166
+ {
1167
+ style: {
1168
+ width: "100%",
1169
+ ...style
1170
+ },
1171
+ children: [
1172
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
1173
+ /* @__PURE__ */ jsxRuntime.jsx(
1174
+ PhoneInputWithCountry__default.default,
1175
+ {
1176
+ id,
1177
+ international: true,
1178
+ defaultCountry,
1179
+ value: value || "",
1180
+ onChange: handleChange,
1181
+ disabled,
1182
+ placeholder,
1183
+ inputComponent: CustomPhoneInput
1184
+ },
1185
+ id
1186
+ )
1187
+ ]
1188
+ }
1189
+ );
1190
+ };
871
1191
  var LoginForm = ({
872
1192
  onSuccess,
873
1193
  onLoginSuccess,
@@ -877,15 +1197,18 @@ var LoginForm = ({
877
1197
  oauthProviders = ["google", "github"],
878
1198
  showOAuthButtons = true
879
1199
  }) => {
880
- const [email, setEmail] = react.useState("");
881
- const [password, setPassword] = react.useState("");
882
- const [usePassword, setUsePassword] = react.useState(false);
883
- const [showPassword, setShowPassword] = react.useState(false);
884
- const [isLoading, setIsLoading] = react.useState(false);
885
- const [error, setError] = react.useState(null);
886
- const [rememberMe, setRememberMe] = react.useState(false);
1200
+ const colors = useThemeColors();
1201
+ const [email, setEmail] = React3.useState("");
1202
+ const [phoneNumber, setPhoneNumber] = React3.useState("");
1203
+ const [usePhone, setUsePhone] = React3.useState(false);
1204
+ const [password, setPassword] = React3.useState("");
1205
+ const [usePassword, setUsePassword] = React3.useState(false);
1206
+ const [showPassword, setShowPassword] = React3.useState(false);
1207
+ const [isLoading, setIsLoading] = React3.useState(false);
1208
+ const [error, setError] = React3.useState(null);
1209
+ const [rememberMe, setRememberMe] = React3.useState(false);
887
1210
  const { login } = useAuth({
888
- baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
1211
+ baseUrl: config?.baseUrl || "http://localhost:7000"
889
1212
  });
890
1213
  const handleSubmit = async (e) => {
891
1214
  e.preventDefault();
@@ -893,20 +1216,28 @@ var LoginForm = ({
893
1216
  setError(null);
894
1217
  try {
895
1218
  let response;
1219
+ const loginData = {};
1220
+ if (usePhone && phoneNumber) {
1221
+ loginData.phoneNumber = phoneNumber;
1222
+ } else if (email) {
1223
+ loginData.email = email;
1224
+ }
896
1225
  if (usePassword) {
897
- response = await login({ email, password });
1226
+ loginData.password = password;
1227
+ response = await login(loginData);
898
1228
  } else {
899
- response = await login({ email });
1229
+ response = await login(loginData);
900
1230
  }
901
1231
  if (response.success) {
902
1232
  onSuccess?.(response);
903
1233
  if (onLoginSuccess) {
904
- if (response.message === "OTP sent to your email.") {
905
- onLoginSuccess(email, true);
1234
+ const identifier = usePhone ? phoneNumber : email;
1235
+ if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
1236
+ onLoginSuccess(identifier, true);
906
1237
  } else if (response.token) {
907
- onLoginSuccess(email, false);
1238
+ onLoginSuccess(identifier, false);
908
1239
  } else {
909
- onLoginSuccess(email, true);
1240
+ onLoginSuccess(identifier, true);
910
1241
  }
911
1242
  }
912
1243
  } else {
@@ -928,43 +1259,53 @@ var LoginForm = ({
928
1259
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
929
1260
  maxWidth: "400px",
930
1261
  margin: "0 auto",
931
- padding: "30px",
1262
+ padding: "24px",
932
1263
  borderRadius: "12px",
933
1264
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
934
- backgroundColor: "#ffffff",
935
- border: "1px solid #eaeaea"
1265
+ backgroundColor: colors.bgPrimary,
1266
+ border: `1px solid ${colors.borderPrimary}`
936
1267
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
937
1268
  display: "flex",
938
1269
  flexDirection: "column"
939
1270
  }, children: [
940
1271
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
941
1272
  textAlign: "center",
942
- marginBottom: "24px",
943
- color: "#1f2937",
1273
+ marginBottom: "20px",
1274
+ color: colors.textPrimary,
944
1275
  fontSize: "24px",
945
1276
  fontWeight: 600
946
1277
  }, children: usePassword ? "Login with Password" : "Login with OTP" }),
947
1278
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
948
1279
  padding: "12px 16px",
949
- marginBottom: "20px",
950
- backgroundColor: "#f8d7da",
951
- color: "#721c24",
952
- border: "1px solid #f5c6cb",
1280
+ marginBottom: "16px",
1281
+ backgroundColor: colors.errorBg,
1282
+ color: colors.errorText,
1283
+ border: `1px solid ${colors.errorBorder}`,
953
1284
  borderRadius: "8px",
954
1285
  fontSize: "14px",
955
1286
  fontWeight: 500
956
1287
  }, children: error }),
957
1288
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
958
- marginBottom: "20px"
1289
+ marginBottom: "16px"
959
1290
  }, children: [
960
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
1291
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
961
1292
  display: "block",
962
1293
  marginBottom: "8px",
963
1294
  fontWeight: 500,
964
- color: "#374151",
1295
+ color: colors.textSecondary,
965
1296
  fontSize: "14px"
966
- }, children: "Email:" }),
967
- /* @__PURE__ */ jsxRuntime.jsx(
1297
+ }, children: usePhone ? "Phone Number:" : "Email:" }),
1298
+ usePhone ? /* @__PURE__ */ jsxRuntime.jsx(
1299
+ PhoneInput,
1300
+ {
1301
+ id: "phone",
1302
+ value: phoneNumber,
1303
+ onChange: setPhoneNumber,
1304
+ required: true,
1305
+ disabled: isLoading,
1306
+ placeholder: "1234567890"
1307
+ }
1308
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
968
1309
  "input",
969
1310
  {
970
1311
  id: "email",
@@ -976,27 +1317,48 @@ var LoginForm = ({
976
1317
  style: {
977
1318
  width: "100%",
978
1319
  padding: "12px 16px",
979
- border: "1px solid #ddd",
1320
+ border: `1px solid ${colors.borderSecondary}`,
980
1321
  borderRadius: "8px",
981
1322
  fontSize: "16px",
982
1323
  boxSizing: "border-box",
983
- color: "#111827",
1324
+ color: colors.textPrimary,
984
1325
  transition: "all 0.2s ease",
985
- backgroundColor: "#ffffff"
1326
+ backgroundColor: colors.bgSecondary
986
1327
  },
987
1328
  placeholder: "Enter your email"
988
1329
  }
1330
+ ),
1331
+ /* @__PURE__ */ jsxRuntime.jsx(
1332
+ "button",
1333
+ {
1334
+ type: "button",
1335
+ onClick: () => setUsePhone(!usePhone),
1336
+ disabled: isLoading,
1337
+ style: {
1338
+ marginTop: "8px",
1339
+ background: "none",
1340
+ border: "none",
1341
+ color: colors.buttonPrimary,
1342
+ textDecoration: "none",
1343
+ cursor: "pointer",
1344
+ fontSize: "13px",
1345
+ fontWeight: 500,
1346
+ padding: "0",
1347
+ transition: "color 0.2s ease"
1348
+ },
1349
+ children: usePhone ? "Use email instead" : "Use phone number instead"
1350
+ }
989
1351
  )
990
1352
  ] }),
991
1353
  usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
992
- marginBottom: "20px",
1354
+ marginBottom: "16px",
993
1355
  position: "relative"
994
1356
  }, children: [
995
1357
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-password", style: {
996
1358
  display: "block",
997
1359
  marginBottom: "8px",
998
1360
  fontWeight: 500,
999
- color: "#555",
1361
+ color: colors.textSecondary,
1000
1362
  fontSize: "14px"
1001
1363
  }, children: "Password:" }),
1002
1364
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1011,13 +1373,13 @@ var LoginForm = ({
1011
1373
  style: {
1012
1374
  width: "100%",
1013
1375
  padding: "12px 16px",
1014
- border: "1px solid #ddd",
1376
+ border: `1px solid ${colors.borderSecondary}`,
1015
1377
  borderRadius: "8px",
1016
1378
  fontSize: "16px",
1017
1379
  boxSizing: "border-box",
1018
- color: "#333",
1380
+ color: colors.textPrimary,
1019
1381
  transition: "all 0.2s ease",
1020
- backgroundColor: "#fafafa"
1382
+ backgroundColor: colors.bgSecondary
1021
1383
  },
1022
1384
  placeholder: "Enter your password"
1023
1385
  }
@@ -1035,7 +1397,7 @@ var LoginForm = ({
1035
1397
  background: "none",
1036
1398
  border: "none",
1037
1399
  cursor: "pointer",
1038
- color: "#666",
1400
+ color: colors.textTertiary,
1039
1401
  fontSize: "14px"
1040
1402
  },
1041
1403
  children: showPassword ? "Hide" : "Show"
@@ -1045,8 +1407,8 @@ var LoginForm = ({
1045
1407
  usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1046
1408
  display: "flex",
1047
1409
  alignItems: "center",
1048
- marginBottom: "16px",
1049
- marginTop: "8px"
1410
+ marginBottom: "12px",
1411
+ marginTop: "4px"
1050
1412
  }, children: [
1051
1413
  /* @__PURE__ */ jsxRuntime.jsx(
1052
1414
  "input",
@@ -1070,7 +1432,7 @@ var LoginForm = ({
1070
1432
  htmlFor: "remember-me",
1071
1433
  style: {
1072
1434
  fontSize: "14px",
1073
- color: "#666",
1435
+ color: colors.textSecondary,
1074
1436
  cursor: "pointer",
1075
1437
  userSelect: "none"
1076
1438
  },
@@ -1085,7 +1447,7 @@ var LoginForm = ({
1085
1447
  disabled: isLoading,
1086
1448
  style: {
1087
1449
  padding: "14px",
1088
- backgroundColor: "#007bff",
1450
+ backgroundColor: colors.buttonPrimary,
1089
1451
  color: "white",
1090
1452
  border: "none",
1091
1453
  borderRadius: "8px",
@@ -1093,16 +1455,16 @@ var LoginForm = ({
1093
1455
  fontWeight: 600,
1094
1456
  cursor: "pointer",
1095
1457
  transition: "all 0.2s ease",
1096
- marginTop: "8px"
1458
+ marginTop: "4px"
1097
1459
  },
1098
1460
  children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
1099
1461
  }
1100
1462
  ),
1101
1463
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1102
1464
  textAlign: "center",
1103
- marginTop: "20px",
1104
- paddingTop: "20px",
1105
- borderTop: "1px solid #eee"
1465
+ marginTop: "16px",
1466
+ paddingTop: "16px",
1467
+ borderTop: `1px solid ${colors.borderPrimary}`
1106
1468
  }, children: /* @__PURE__ */ jsxRuntime.jsx(
1107
1469
  "button",
1108
1470
  {
@@ -1112,7 +1474,7 @@ var LoginForm = ({
1112
1474
  style: {
1113
1475
  background: "none",
1114
1476
  border: "none",
1115
- color: "#007bff",
1477
+ color: colors.buttonPrimary,
1116
1478
  textDecoration: "none",
1117
1479
  cursor: "pointer",
1118
1480
  fontSize: "14px",
@@ -1124,9 +1486,9 @@ var LoginForm = ({
1124
1486
  }
1125
1487
  ) }),
1126
1488
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1127
- marginTop: "20px",
1128
- paddingTop: "20px",
1129
- borderTop: "1px solid #eee"
1489
+ marginTop: "16px",
1490
+ paddingTop: "16px",
1491
+ borderTop: `1px solid ${colors.borderPrimary}`
1130
1492
  }, children: [
1131
1493
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1132
1494
  position: "relative",
@@ -1138,15 +1500,15 @@ var LoginForm = ({
1138
1500
  left: 0,
1139
1501
  right: 0,
1140
1502
  height: "1px",
1141
- backgroundColor: "#eee"
1503
+ backgroundColor: colors.borderPrimary
1142
1504
  } }),
1143
1505
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1144
1506
  position: "relative",
1145
1507
  textAlign: "center"
1146
1508
  }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
1147
- backgroundColor: "#ffffff",
1509
+ backgroundColor: colors.bgPrimary,
1148
1510
  padding: "0 12px",
1149
- color: "#666",
1511
+ color: colors.textSecondary,
1150
1512
  fontSize: "14px"
1151
1513
  }, children: "Or continue with" }) })
1152
1514
  ] }),
@@ -1165,10 +1527,10 @@ var LoginForm = ({
1165
1527
  justifyContent: "center",
1166
1528
  gap: "8px",
1167
1529
  padding: "10px 16px",
1168
- backgroundColor: "#ffffff",
1169
- border: "1px solid #ddd",
1530
+ backgroundColor: colors.bgPrimary,
1531
+ border: `1px solid ${colors.borderSecondary}`,
1170
1532
  borderRadius: "8px",
1171
- color: "#333",
1533
+ color: colors.textPrimary,
1172
1534
  textDecoration: "none",
1173
1535
  fontSize: "14px",
1174
1536
  fontWeight: 500,
@@ -1176,12 +1538,12 @@ var LoginForm = ({
1176
1538
  transition: "all 0.2s ease"
1177
1539
  },
1178
1540
  onMouseEnter: (e) => {
1179
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1180
- e.currentTarget.style.borderColor = "#007bff";
1541
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1542
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1181
1543
  },
1182
1544
  onMouseLeave: (e) => {
1183
- e.currentTarget.style.backgroundColor = "#ffffff";
1184
- e.currentTarget.style.borderColor = "#ddd";
1545
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1546
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1185
1547
  },
1186
1548
  children: [
1187
1549
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1256,11 +1618,11 @@ var LoginForm = ({
1256
1618
  ] }),
1257
1619
  showRegisterLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1258
1620
  textAlign: "center",
1259
- marginTop: "20px",
1260
- paddingTop: "20px",
1261
- borderTop: "1px solid #eee"
1621
+ marginTop: "16px",
1622
+ paddingTop: "16px",
1623
+ borderTop: `1px solid ${colors.borderPrimary}`
1262
1624
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
1263
- color: "#666",
1625
+ color: colors.textSecondary,
1264
1626
  fontSize: "14px"
1265
1627
  }, children: [
1266
1628
  "Don't have an account?",
@@ -1274,7 +1636,7 @@ var LoginForm = ({
1274
1636
  style: {
1275
1637
  background: "none",
1276
1638
  border: "none",
1277
- color: "#007bff",
1639
+ color: colors.buttonPrimary,
1278
1640
  textDecoration: "none",
1279
1641
  cursor: "pointer",
1280
1642
  fontSize: "14px",
@@ -1294,16 +1656,19 @@ var RegisterForm = ({
1294
1656
  showLoginLink = true,
1295
1657
  authConfig,
1296
1658
  oauthProviders = ["google", "github"],
1297
- showOAuthButtons = true
1659
+ showOAuthButtons = true,
1660
+ invitationToken
1298
1661
  }) => {
1299
- const [name, setName] = react.useState("");
1300
- const [email, setEmail] = react.useState("");
1301
- const [password, setPassword] = react.useState("");
1302
- const [confirmPassword, setConfirmPassword] = react.useState("");
1303
- const [isLoading, setIsLoading] = react.useState(false);
1304
- const [error, setError] = react.useState(null);
1305
- react.useState(false);
1306
- react.useState(false);
1662
+ const colors = useThemeColors();
1663
+ const [name, setName] = React3.useState("");
1664
+ const [email, setEmail] = React3.useState("");
1665
+ const [phoneNumber, setPhoneNumber] = React3.useState("");
1666
+ const [password, setPassword] = React3.useState("");
1667
+ const [confirmPassword, setConfirmPassword] = React3.useState("");
1668
+ const [isLoading, setIsLoading] = React3.useState(false);
1669
+ const [error, setError] = React3.useState(null);
1670
+ React3.useState(false);
1671
+ React3.useState(false);
1307
1672
  const getPasswordStrength = (pwd) => {
1308
1673
  if (!pwd)
1309
1674
  return { strength: "weak", score: 0, label: "" };
@@ -1326,7 +1691,7 @@ var RegisterForm = ({
1326
1691
  };
1327
1692
  getPasswordStrength(password);
1328
1693
  const config = authConfig || {
1329
- baseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || window.location.origin : "http://localhost:7000"
1694
+ baseUrl: "http://localhost:7000"
1330
1695
  };
1331
1696
  const { register } = useAuth(config);
1332
1697
  const handleSubmit = async (e) => {
@@ -1344,17 +1709,45 @@ var RegisterForm = ({
1344
1709
  return;
1345
1710
  }
1346
1711
  try {
1347
- const registerData = {
1348
- name,
1349
- email,
1350
- password,
1351
- frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1352
- };
1353
- const response = await register(registerData);
1354
- if (response.success) {
1355
- onRegisterSuccess?.();
1712
+ if (invitationToken) {
1713
+ const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
1714
+ method: "POST",
1715
+ headers: {
1716
+ "Content-Type": "application/json"
1717
+ },
1718
+ body: JSON.stringify({
1719
+ name,
1720
+ email,
1721
+ password,
1722
+ phoneNumber: phoneNumber || void 0,
1723
+ invitationToken
1724
+ })
1725
+ });
1726
+ const data = await response.json();
1727
+ if (response.ok && data.success) {
1728
+ if (typeof window !== "undefined" && data.token) {
1729
+ localStorage.setItem("auth_token", data.token);
1730
+ }
1731
+ onRegisterSuccess?.();
1732
+ } else {
1733
+ setError(data.error || data.message || "Registration failed");
1734
+ }
1356
1735
  } else {
1357
- setError(response.message || "Registration failed");
1736
+ const registerData = {
1737
+ name,
1738
+ password,
1739
+ frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1740
+ };
1741
+ if (email)
1742
+ registerData.email = email;
1743
+ if (phoneNumber)
1744
+ registerData.phoneNumber = phoneNumber;
1745
+ const response = await register(registerData);
1746
+ if (response.success) {
1747
+ onRegisterSuccess?.();
1748
+ } else {
1749
+ setError(response.message || "Registration failed");
1750
+ }
1358
1751
  }
1359
1752
  } catch (err) {
1360
1753
  setError(err instanceof Error ? err.message : "An unknown error occurred");
@@ -1365,40 +1758,40 @@ var RegisterForm = ({
1365
1758
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1366
1759
  maxWidth: "400px",
1367
1760
  margin: "0 auto",
1368
- padding: "30px",
1761
+ padding: "24px",
1369
1762
  borderRadius: "12px",
1370
1763
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1371
- backgroundColor: "#ffffff",
1372
- border: "1px solid #eaeaea"
1764
+ backgroundColor: colors.bgPrimary,
1765
+ border: `1px solid ${colors.borderPrimary}`
1373
1766
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
1374
1767
  display: "flex",
1375
1768
  flexDirection: "column"
1376
1769
  }, children: [
1377
1770
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
1378
1771
  textAlign: "center",
1379
- marginBottom: "24px",
1380
- color: "#1f2937",
1772
+ marginBottom: "20px",
1773
+ color: colors.textPrimary,
1381
1774
  fontSize: "24px",
1382
1775
  fontWeight: 600
1383
1776
  }, children: "Register" }),
1384
1777
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1385
1778
  padding: "12px 16px",
1386
- marginBottom: "20px",
1387
- backgroundColor: "#f8d7da",
1388
- color: "#721c24",
1389
- border: "1px solid #f5c6cb",
1779
+ marginBottom: "16px",
1780
+ backgroundColor: colors.errorBg,
1781
+ color: colors.errorText,
1782
+ border: `1px solid ${colors.errorBorder}`,
1390
1783
  borderRadius: "8px",
1391
1784
  fontSize: "14px",
1392
1785
  fontWeight: 500
1393
1786
  }, children: error }),
1394
1787
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1395
- marginBottom: "20px"
1788
+ marginBottom: "16px"
1396
1789
  }, children: [
1397
1790
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
1398
1791
  display: "block",
1399
1792
  marginBottom: "8px",
1400
1793
  fontWeight: 500,
1401
- color: "#374151",
1794
+ color: colors.textSecondary,
1402
1795
  fontSize: "14px"
1403
1796
  }, children: "Name:" }),
1404
1797
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1413,26 +1806,26 @@ var RegisterForm = ({
1413
1806
  style: {
1414
1807
  width: "100%",
1415
1808
  padding: "12px 16px",
1416
- border: "1px solid #ddd",
1809
+ border: `1px solid ${colors.borderSecondary}`,
1417
1810
  borderRadius: "8px",
1418
1811
  fontSize: "16px",
1419
1812
  boxSizing: "border-box",
1420
- color: "#111827",
1813
+ color: colors.textPrimary,
1421
1814
  transition: "all 0.2s ease",
1422
- backgroundColor: "#ffffff"
1815
+ backgroundColor: colors.bgSecondary
1423
1816
  },
1424
1817
  placeholder: "Enter your name"
1425
1818
  }
1426
1819
  )
1427
1820
  ] }),
1428
1821
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1429
- marginBottom: "20px"
1822
+ marginBottom: "16px"
1430
1823
  }, children: [
1431
1824
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-email", style: {
1432
1825
  display: "block",
1433
1826
  marginBottom: "8px",
1434
1827
  fontWeight: 500,
1435
- color: "#555",
1828
+ color: colors.textSecondary,
1436
1829
  fontSize: "14px"
1437
1830
  }, children: "Email:" }),
1438
1831
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1442,31 +1835,52 @@ var RegisterForm = ({
1442
1835
  type: "email",
1443
1836
  value: email,
1444
1837
  onChange: (e) => setEmail(e.target.value),
1445
- required: true,
1838
+ required: !phoneNumber,
1446
1839
  disabled: isLoading,
1447
1840
  style: {
1448
1841
  width: "100%",
1449
1842
  padding: "12px 16px",
1450
- border: "1px solid #ddd",
1843
+ border: `1px solid ${colors.borderSecondary}`,
1451
1844
  borderRadius: "8px",
1452
1845
  fontSize: "16px",
1453
1846
  boxSizing: "border-box",
1454
- color: "#333",
1847
+ color: colors.textPrimary,
1455
1848
  transition: "all 0.2s ease",
1456
- backgroundColor: "#fafafa"
1849
+ backgroundColor: colors.bgSecondary
1457
1850
  },
1458
1851
  placeholder: "Enter your email"
1459
1852
  }
1460
1853
  )
1461
1854
  ] }),
1462
1855
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1463
- marginBottom: "20px"
1856
+ marginBottom: "16px"
1857
+ }, children: [
1858
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-phone", style: {
1859
+ display: "block",
1860
+ marginBottom: "8px",
1861
+ fontWeight: 500,
1862
+ color: colors.textSecondary,
1863
+ fontSize: "14px"
1864
+ }, children: "Phone Number (Optional):" }),
1865
+ /* @__PURE__ */ jsxRuntime.jsx(
1866
+ PhoneInput,
1867
+ {
1868
+ id: "register-phone",
1869
+ value: phoneNumber,
1870
+ onChange: setPhoneNumber,
1871
+ disabled: isLoading,
1872
+ placeholder: "1234567890"
1873
+ }
1874
+ )
1875
+ ] }),
1876
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1877
+ marginBottom: "16px"
1464
1878
  }, children: [
1465
1879
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
1466
1880
  display: "block",
1467
1881
  marginBottom: "8px",
1468
1882
  fontWeight: 500,
1469
- color: "#555",
1883
+ color: colors.textSecondary,
1470
1884
  fontSize: "14px"
1471
1885
  }, children: "Password:" }),
1472
1886
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1481,13 +1895,13 @@ var RegisterForm = ({
1481
1895
  style: {
1482
1896
  width: "100%",
1483
1897
  padding: "12px 16px",
1484
- border: "1px solid #ddd",
1898
+ border: `1px solid ${colors.borderSecondary}`,
1485
1899
  borderRadius: "8px",
1486
1900
  fontSize: "16px",
1487
1901
  boxSizing: "border-box",
1488
- color: "#333",
1902
+ color: colors.textPrimary,
1489
1903
  transition: "all 0.2s ease",
1490
- backgroundColor: "#fafafa"
1904
+ backgroundColor: colors.bgSecondary
1491
1905
  },
1492
1906
  placeholder: "Enter your password",
1493
1907
  minLength: 6
@@ -1495,13 +1909,13 @@ var RegisterForm = ({
1495
1909
  )
1496
1910
  ] }),
1497
1911
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1498
- marginBottom: "20px"
1912
+ marginBottom: "16px"
1499
1913
  }, children: [
1500
1914
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirm-password", style: {
1501
1915
  display: "block",
1502
1916
  marginBottom: "8px",
1503
1917
  fontWeight: 500,
1504
- color: "#555",
1918
+ color: colors.textSecondary,
1505
1919
  fontSize: "14px"
1506
1920
  }, children: "Confirm Password:" }),
1507
1921
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1516,13 +1930,13 @@ var RegisterForm = ({
1516
1930
  style: {
1517
1931
  width: "100%",
1518
1932
  padding: "12px 16px",
1519
- border: "1px solid #ddd",
1933
+ border: `1px solid ${colors.borderSecondary}`,
1520
1934
  borderRadius: "8px",
1521
1935
  fontSize: "16px",
1522
1936
  boxSizing: "border-box",
1523
- color: "#333",
1937
+ color: colors.textPrimary,
1524
1938
  transition: "all 0.2s ease",
1525
- backgroundColor: "#fafafa"
1939
+ backgroundColor: colors.bgSecondary
1526
1940
  },
1527
1941
  placeholder: "Confirm your password"
1528
1942
  }
@@ -1535,7 +1949,7 @@ var RegisterForm = ({
1535
1949
  disabled: isLoading,
1536
1950
  style: {
1537
1951
  padding: "14px",
1538
- backgroundColor: "#007bff",
1952
+ backgroundColor: colors.buttonPrimary,
1539
1953
  color: "white",
1540
1954
  border: "none",
1541
1955
  borderRadius: "8px",
@@ -1543,15 +1957,15 @@ var RegisterForm = ({
1543
1957
  fontWeight: 600,
1544
1958
  cursor: "pointer",
1545
1959
  transition: "all 0.2s ease",
1546
- marginTop: "8px"
1960
+ marginTop: "4px"
1547
1961
  },
1548
1962
  children: isLoading ? "Registering..." : "Register"
1549
1963
  }
1550
1964
  ),
1551
1965
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1552
- marginTop: "20px",
1553
- paddingTop: "20px",
1554
- borderTop: "1px solid #eee"
1966
+ marginTop: "16px",
1967
+ paddingTop: "16px",
1968
+ borderTop: `1px solid ${colors.borderPrimary}`
1555
1969
  }, children: [
1556
1970
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1557
1971
  position: "relative",
@@ -1563,15 +1977,15 @@ var RegisterForm = ({
1563
1977
  left: 0,
1564
1978
  right: 0,
1565
1979
  height: "1px",
1566
- backgroundColor: "#eee"
1980
+ backgroundColor: colors.borderPrimary
1567
1981
  } }),
1568
1982
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1569
1983
  position: "relative",
1570
1984
  textAlign: "center"
1571
1985
  }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
1572
- backgroundColor: "#ffffff",
1986
+ backgroundColor: colors.bgPrimary,
1573
1987
  padding: "0 12px",
1574
- color: "#666",
1988
+ color: colors.textSecondary,
1575
1989
  fontSize: "14px"
1576
1990
  }, children: "Or continue with" }) })
1577
1991
  ] }),
@@ -1590,10 +2004,10 @@ var RegisterForm = ({
1590
2004
  justifyContent: "center",
1591
2005
  gap: "8px",
1592
2006
  padding: "10px 16px",
1593
- backgroundColor: "#ffffff",
1594
- border: "1px solid #ddd",
2007
+ backgroundColor: colors.bgPrimary,
2008
+ border: `1px solid ${colors.borderSecondary}`,
1595
2009
  borderRadius: "8px",
1596
- color: "#333",
2010
+ color: colors.textPrimary,
1597
2011
  textDecoration: "none",
1598
2012
  fontSize: "14px",
1599
2013
  fontWeight: 500,
@@ -1601,12 +2015,12 @@ var RegisterForm = ({
1601
2015
  transition: "all 0.2s ease"
1602
2016
  },
1603
2017
  onMouseEnter: (e) => {
1604
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1605
- e.currentTarget.style.borderColor = "#007bff";
2018
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2019
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1606
2020
  },
1607
2021
  onMouseLeave: (e) => {
1608
- e.currentTarget.style.backgroundColor = "#ffffff";
1609
- e.currentTarget.style.borderColor = "#ddd";
2022
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
2023
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1610
2024
  },
1611
2025
  children: [
1612
2026
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1681,11 +2095,11 @@ var RegisterForm = ({
1681
2095
  ] }),
1682
2096
  showLoginLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1683
2097
  textAlign: "center",
1684
- marginTop: "20px",
1685
- paddingTop: "20px",
1686
- borderTop: "1px solid #eee"
2098
+ marginTop: "16px",
2099
+ paddingTop: "16px",
2100
+ borderTop: `1px solid ${colors.borderPrimary}`
1687
2101
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
1688
- color: "#666",
2102
+ color: colors.textSecondary,
1689
2103
  fontSize: "14px"
1690
2104
  }, children: [
1691
2105
  "Already have an account?",
@@ -1699,7 +2113,7 @@ var RegisterForm = ({
1699
2113
  style: {
1700
2114
  background: "none",
1701
2115
  border: "none",
1702
- color: "#007bff",
2116
+ color: colors.buttonPrimary,
1703
2117
  textDecoration: "none",
1704
2118
  cursor: "pointer",
1705
2119
  fontSize: "14px",
@@ -1716,15 +2130,17 @@ var RegisterForm = ({
1716
2130
  var OtpForm = ({
1717
2131
  email,
1718
2132
  onVerifySuccess,
1719
- onBackToLogin
2133
+ onBackToLogin,
2134
+ baseUrl
1720
2135
  }) => {
1721
- const [otp, setOtp] = react.useState("");
1722
- const [isLoading, setIsLoading] = react.useState(false);
1723
- const [error, setError] = react.useState(null);
1724
- const [resendCooldown, setResendCooldown] = react.useState(0);
1725
- const [resendLoading, setResendLoading] = react.useState(false);
2136
+ const colors = useThemeColors();
2137
+ const [otp, setOtp] = React3.useState("");
2138
+ const [isLoading, setIsLoading] = React3.useState(false);
2139
+ const [error, setError] = React3.useState(null);
2140
+ const [resendCooldown, setResendCooldown] = React3.useState(0);
2141
+ const [resendLoading, setResendLoading] = React3.useState(false);
1726
2142
  const { verify, login } = useAuth({
1727
- baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost:7000"
2143
+ baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
1728
2144
  });
1729
2145
  const handleSubmit = async (e) => {
1730
2146
  e.preventDefault();
@@ -1787,8 +2203,8 @@ var OtpForm = ({
1787
2203
  padding: "30px",
1788
2204
  borderRadius: "12px",
1789
2205
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1790
- backgroundColor: "#ffffff",
1791
- border: "1px solid #eaeaea"
2206
+ backgroundColor: colors.bgPrimary,
2207
+ border: `1px solid ${colors.borderPrimary}`
1792
2208
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
1793
2209
  display: "flex",
1794
2210
  flexDirection: "column"
@@ -1796,25 +2212,25 @@ var OtpForm = ({
1796
2212
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
1797
2213
  textAlign: "center",
1798
2214
  marginBottom: "24px",
1799
- color: "#1f2937",
2215
+ color: colors.textPrimary,
1800
2216
  fontSize: "24px",
1801
2217
  fontWeight: 600
1802
2218
  }, children: "Verify OTP" }),
1803
2219
  /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
1804
2220
  textAlign: "center",
1805
2221
  marginBottom: "24px",
1806
- color: "#4b5563",
2222
+ color: colors.textSecondary,
1807
2223
  fontSize: "14px"
1808
2224
  }, children: [
1809
2225
  "Enter the 6-digit code sent to ",
1810
- /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: "#111827" }, children: email })
2226
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: colors.textPrimary }, children: email })
1811
2227
  ] }),
1812
2228
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1813
2229
  padding: "12px 16px",
1814
2230
  marginBottom: "20px",
1815
- backgroundColor: "#f8d7da",
1816
- color: "#721c24",
1817
- border: "1px solid #f5c6cb",
2231
+ backgroundColor: colors.errorBg,
2232
+ color: colors.errorText,
2233
+ border: `1px solid ${colors.errorBorder}`,
1818
2234
  borderRadius: "8px",
1819
2235
  fontSize: "14px",
1820
2236
  fontWeight: 500
@@ -1826,7 +2242,7 @@ var OtpForm = ({
1826
2242
  display: "block",
1827
2243
  marginBottom: "8px",
1828
2244
  fontWeight: 500,
1829
- color: "#374151",
2245
+ color: colors.textSecondary,
1830
2246
  fontSize: "14px"
1831
2247
  }, children: "OTP Code:" }),
1832
2248
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1841,13 +2257,13 @@ var OtpForm = ({
1841
2257
  style: {
1842
2258
  width: "100%",
1843
2259
  padding: "12px 16px",
1844
- border: "1px solid #ddd",
2260
+ border: `1px solid ${colors.borderSecondary}`,
1845
2261
  borderRadius: "8px",
1846
2262
  fontSize: "20px",
1847
2263
  boxSizing: "border-box",
1848
- color: "#111827",
2264
+ color: colors.textPrimary,
1849
2265
  transition: "all 0.2s ease",
1850
- backgroundColor: "#ffffff",
2266
+ backgroundColor: colors.bgSecondary,
1851
2267
  textAlign: "center",
1852
2268
  letterSpacing: "5px"
1853
2269
  },
@@ -1864,7 +2280,7 @@ var OtpForm = ({
1864
2280
  disabled: isLoading || otp.length !== 6,
1865
2281
  style: {
1866
2282
  padding: "14px",
1867
- backgroundColor: "#007bff",
2283
+ backgroundColor: colors.buttonPrimary,
1868
2284
  color: "white",
1869
2285
  border: "none",
1870
2286
  borderRadius: "8px",
@@ -1881,7 +2297,7 @@ var OtpForm = ({
1881
2297
  textAlign: "center",
1882
2298
  marginTop: "20px",
1883
2299
  paddingTop: "20px",
1884
- borderTop: "1px solid #eee"
2300
+ borderTop: `1px solid ${colors.borderPrimary}`
1885
2301
  }, children: [
1886
2302
  /* @__PURE__ */ jsxRuntime.jsx(
1887
2303
  "button",
@@ -1892,7 +2308,7 @@ var OtpForm = ({
1892
2308
  style: {
1893
2309
  background: "none",
1894
2310
  border: "none",
1895
- color: resendCooldown > 0 ? "#999" : "#007bff",
2311
+ color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
1896
2312
  textDecoration: "none",
1897
2313
  cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
1898
2314
  fontSize: "14px",
@@ -1915,7 +2331,7 @@ var OtpForm = ({
1915
2331
  style: {
1916
2332
  background: "none",
1917
2333
  border: "none",
1918
- color: "#007bff",
2334
+ color: colors.buttonPrimary,
1919
2335
  textDecoration: "none",
1920
2336
  cursor: "pointer",
1921
2337
  fontSize: "14px",
@@ -1934,9 +2350,9 @@ var AuthFlow = ({
1934
2350
  initialStep = "login",
1935
2351
  showTitle = true
1936
2352
  }) => {
1937
- const [step, setStep] = react.useState(initialStep);
1938
- const [email, setEmail] = react.useState("");
1939
- const [message, setMessage] = react.useState(null);
2353
+ const [step, setStep] = React3.useState(initialStep);
2354
+ const [email, setEmail] = React3.useState("");
2355
+ const [message, setMessage] = React3.useState(null);
1940
2356
  const handleLoginSuccess = (email2, needsOtpVerification) => {
1941
2357
  setEmail(email2);
1942
2358
  if (needsOtpVerification) {
@@ -2071,13 +2487,13 @@ var EmailVerificationPage = ({
2071
2487
  onVerificationError,
2072
2488
  baseUrl
2073
2489
  }) => {
2074
- const [isLoading, setIsLoading] = react.useState(true);
2075
- const [message, setMessage] = react.useState("");
2076
- const [isSuccess, setIsSuccess] = react.useState(false);
2490
+ const [isLoading, setIsLoading] = React3.useState(true);
2491
+ const [message, setMessage] = React3.useState("");
2492
+ const [isSuccess, setIsSuccess] = React3.useState(false);
2077
2493
  const { verifyEmailToken } = useAuth({
2078
2494
  baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
2079
2495
  });
2080
- react.useEffect(() => {
2496
+ React3.useEffect(() => {
2081
2497
  const verifyEmail = async () => {
2082
2498
  if (!token) {
2083
2499
  setIsLoading(false);
@@ -2182,22 +2598,35 @@ var EmailVerificationPage = ({
2182
2598
  ] })
2183
2599
  ] }) });
2184
2600
  };
2601
+ var ThemeWrapper = React3.forwardRef(
2602
+ ({ children, className = "", style }, ref) => {
2603
+ const { theme, mounted } = useAuthTheme();
2604
+ if (!mounted) {
2605
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className, style, children });
2606
+ }
2607
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: `${theme} ${className}`, style, children });
2608
+ }
2609
+ );
2610
+ ThemeWrapper.displayName = "ThemeWrapper";
2185
2611
  var SignIn = ({ redirectUrl, appearance }) => {
2186
2612
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
2187
- const [email, setEmail] = react.useState("");
2188
- const [password, setPassword] = react.useState("");
2189
- const [otp, setOtp] = react.useState("");
2190
- const [usePassword, setUsePassword] = react.useState(false);
2191
- const [showPassword, setShowPassword] = react.useState(false);
2192
- const [isLoading, setIsLoading] = react.useState(false);
2193
- const [error, setError] = react.useState(null);
2194
- const [needsOtp, setNeedsOtp] = react.useState(false);
2195
- const [success, setSuccess] = react.useState(null);
2196
- react.useEffect(() => {
2613
+ const colors = useThemeColors();
2614
+ const [email, setEmail] = React3.useState("");
2615
+ const [phoneNumber, setPhoneNumber] = React3.useState("");
2616
+ const [password, setPassword] = React3.useState("");
2617
+ const [otp, setOtp] = React3.useState("");
2618
+ const [usePassword, setUsePassword] = React3.useState(false);
2619
+ const [usePhone, setUsePhone] = React3.useState(false);
2620
+ const [showPassword, setShowPassword] = React3.useState(false);
2621
+ const [isLoading, setIsLoading] = React3.useState(false);
2622
+ const [error, setError] = React3.useState(null);
2623
+ const [needsOtp, setNeedsOtp] = React3.useState(false);
2624
+ const [success, setSuccess] = React3.useState(null);
2625
+ React3.useEffect(() => {
2197
2626
  if (isSignedIn && redirectUrl) {
2198
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2627
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2199
2628
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2200
- window.location.href = `${baseUrl}${redirect2}`;
2629
+ window.location.href = `${baseUrl}${redirect}`;
2201
2630
  }
2202
2631
  }, [isSignedIn, redirectUrl]);
2203
2632
  const handleSubmit = async (e) => {
@@ -2206,25 +2635,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
2206
2635
  setError(null);
2207
2636
  setSuccess(null);
2208
2637
  try {
2638
+ const loginData = usePhone ? { phoneNumber } : { email };
2209
2639
  if (needsOtp) {
2210
- const response = await signIn({ email, otp });
2640
+ const response = await signIn({ ...loginData, otp });
2211
2641
  if (response.success) {
2212
2642
  setSuccess("Login successful!");
2213
2643
  } else {
2214
2644
  setError(response.message || "OTP verification failed");
2215
2645
  }
2216
2646
  } else if (usePassword) {
2217
- const response = await signIn({ email, password });
2647
+ const response = await signIn({ ...loginData, password });
2218
2648
  if (response.success) {
2219
2649
  setSuccess("Login successful!");
2220
2650
  } else {
2221
2651
  setError(response.message || "Login failed");
2222
2652
  }
2223
2653
  } else {
2224
- const response = await signIn({ email });
2225
- if (response.success && response.message === "OTP sent to your email.") {
2654
+ const response = await signIn(loginData);
2655
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
2226
2656
  setNeedsOtp(true);
2227
- setSuccess("OTP sent to your email. Please check your inbox.");
2657
+ setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
2228
2658
  } else {
2229
2659
  setError(response.message || "Failed to send OTP");
2230
2660
  }
@@ -2242,238 +2672,366 @@ var SignIn = ({ redirectUrl, appearance }) => {
2242
2672
  setSuccess(null);
2243
2673
  setOtp("");
2244
2674
  };
2675
+ const toggleLoginMethod = () => {
2676
+ setUsePhone(!usePhone);
2677
+ setNeedsOtp(false);
2678
+ setError(null);
2679
+ setSuccess(null);
2680
+ setOtp("");
2681
+ setEmail("");
2682
+ setPhoneNumber("");
2683
+ };
2245
2684
  if (authLoading) {
2246
2685
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
2247
2686
  }
2248
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2249
- maxWidth: "400px",
2250
- margin: "0 auto",
2251
- padding: "30px",
2252
- borderRadius: "12px",
2253
- boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2254
- backgroundColor: "#ffffff",
2255
- border: "1px solid #eaeaea",
2256
- ...appearance?.elements?.card
2257
- }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
2258
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
2259
- textAlign: "center",
2260
- marginBottom: "24px",
2261
- color: "#1f2937",
2262
- fontSize: "24px",
2263
- fontWeight: 600,
2264
- ...appearance?.elements?.headerTitle
2265
- }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2266
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2267
- padding: "12px 16px",
2268
- marginBottom: "20px",
2269
- backgroundColor: "#fee",
2270
- color: "#c33",
2271
- border: "1px solid #fcc",
2272
- borderRadius: "8px",
2273
- fontSize: "14px"
2274
- }, children: error }),
2275
- success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2276
- padding: "12px 16px",
2277
- marginBottom: "20px",
2278
- backgroundColor: "#efe",
2279
- color: "#3c3",
2280
- border: "1px solid #cfc",
2281
- borderRadius: "8px",
2282
- fontSize: "14px"
2283
- }, children: success }),
2284
- !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2285
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
2286
- display: "block",
2287
- marginBottom: "8px",
2288
- fontWeight: 500,
2289
- color: "#374151",
2290
- fontSize: "14px"
2291
- }, children: "Email" }),
2292
- /* @__PURE__ */ jsxRuntime.jsx(
2293
- "input",
2294
- {
2295
- id: "email",
2296
- type: "email",
2297
- value: email,
2298
- onChange: (e) => setEmail(e.target.value),
2299
- required: true,
2300
- disabled: isLoading,
2301
- style: {
2302
- width: "100%",
2303
- padding: "12px 16px",
2304
- border: "1px solid #ddd",
2305
- borderRadius: "8px",
2306
- fontSize: "16px",
2307
- boxSizing: "border-box",
2308
- ...appearance?.elements?.formFieldInput
2309
- },
2310
- placeholder: "Enter your email"
2311
- }
2312
- )
2313
- ] }),
2314
- usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2315
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2316
- display: "block",
2317
- marginBottom: "8px",
2318
- fontWeight: 500,
2319
- color: "#374151",
2320
- fontSize: "14px"
2321
- }, children: "Password" }),
2322
- /* @__PURE__ */ jsxRuntime.jsx(
2323
- "input",
2324
- {
2325
- id: "password",
2326
- type: showPassword ? "text" : "password",
2327
- value: password,
2328
- onChange: (e) => setPassword(e.target.value),
2329
- required: true,
2330
- disabled: isLoading,
2331
- style: {
2332
- width: "100%",
2333
- padding: "12px 16px",
2334
- border: "1px solid #ddd",
2335
- borderRadius: "8px",
2336
- fontSize: "16px",
2337
- boxSizing: "border-box",
2338
- ...appearance?.elements?.formFieldInput
2339
- },
2340
- placeholder: "Enter your password"
2341
- }
2342
- ),
2343
- /* @__PURE__ */ jsxRuntime.jsx(
2344
- "button",
2345
- {
2346
- type: "button",
2347
- onClick: () => setShowPassword(!showPassword),
2348
- style: {
2349
- position: "absolute",
2350
- right: "12px",
2351
- top: "38px",
2352
- background: "none",
2353
- border: "none",
2354
- cursor: "pointer",
2355
- color: "#666",
2356
- fontSize: "14px"
2357
- },
2358
- children: showPassword ? "Hide" : "Show"
2359
- }
2360
- )
2361
- ] }),
2362
- needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2363
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
2364
- display: "block",
2365
- marginBottom: "8px",
2366
- fontWeight: 500,
2367
- color: "#374151",
2368
- fontSize: "14px"
2369
- }, children: "One-Time Password" }),
2370
- /* @__PURE__ */ jsxRuntime.jsx(
2371
- "input",
2372
- {
2373
- id: "otp",
2374
- type: "text",
2375
- value: otp,
2376
- onChange: (e) => setOtp(e.target.value),
2377
- required: true,
2378
- disabled: isLoading,
2379
- maxLength: 6,
2380
- style: {
2381
- width: "100%",
2382
- padding: "12px 16px",
2383
- border: "1px solid #ddd",
2384
- borderRadius: "8px",
2385
- fontSize: "16px",
2386
- boxSizing: "border-box",
2387
- letterSpacing: "0.5em",
2388
- textAlign: "center",
2389
- ...appearance?.elements?.formFieldInput
2390
- },
2391
- placeholder: "000000"
2392
- }
2393
- )
2394
- ] }),
2395
- /* @__PURE__ */ jsxRuntime.jsx(
2396
- "button",
2397
- {
2398
- type: "submit",
2399
- disabled: isLoading,
2400
- style: {
2401
- width: "100%",
2402
- padding: "14px",
2403
- backgroundColor: "#007bff",
2404
- color: "white",
2405
- border: "none",
2406
- borderRadius: "8px",
2407
- fontSize: "16px",
2687
+ return /* @__PURE__ */ jsxRuntime.jsx(
2688
+ ThemeWrapper,
2689
+ {
2690
+ style: {
2691
+ maxWidth: "400px",
2692
+ margin: "0 auto",
2693
+ padding: "30px",
2694
+ borderRadius: "12px",
2695
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2696
+ backgroundColor: colors.bgPrimary,
2697
+ border: `1px solid ${colors.borderPrimary}`,
2698
+ ...appearance?.elements?.card
2699
+ },
2700
+ children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
2701
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
2702
+ textAlign: "center",
2703
+ marginBottom: "24px",
2704
+ color: colors.textPrimary,
2705
+ fontSize: "24px",
2408
2706
  fontWeight: 600,
2409
- cursor: "pointer",
2410
- transition: "all 0.2s ease",
2411
- ...appearance?.elements?.formButtonPrimary
2412
- },
2413
- children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : "Continue with email"
2414
- }
2415
- ),
2416
- !needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2417
- "button",
2418
- {
2419
- type: "button",
2420
- onClick: toggleAuthMethod,
2421
- disabled: isLoading,
2422
- style: {
2423
- background: "none",
2424
- border: "none",
2425
- color: "#007bff",
2426
- cursor: "pointer",
2427
- fontSize: "14px",
2428
- fontWeight: 600
2429
- },
2430
- children: usePassword ? "Use email code instead" : "Use password instead"
2431
- }
2432
- ) }),
2433
- needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2434
- "button",
2435
- {
2436
- type: "button",
2437
- onClick: () => {
2438
- setNeedsOtp(false);
2439
- setOtp("");
2440
- setError(null);
2441
- setSuccess(null);
2442
- },
2443
- disabled: isLoading,
2444
- style: {
2445
- background: "none",
2446
- border: "none",
2447
- color: "#007bff",
2448
- cursor: "pointer",
2449
- fontSize: "14px",
2450
- fontWeight: 600
2451
- },
2452
- children: "Back to sign in"
2453
- }
2454
- ) })
2455
- ] }) });
2707
+ ...appearance?.elements?.headerTitle
2708
+ }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2709
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2710
+ padding: "12px 16px",
2711
+ marginBottom: "20px",
2712
+ backgroundColor: colors.errorBg,
2713
+ color: colors.errorText,
2714
+ border: `1px solid ${colors.errorBorder}`,
2715
+ borderRadius: "8px",
2716
+ fontSize: "14px"
2717
+ }, children: error }),
2718
+ success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2719
+ padding: "12px 16px",
2720
+ marginBottom: "20px",
2721
+ backgroundColor: colors.successBg,
2722
+ color: colors.successText,
2723
+ border: `1px solid ${colors.successBorder}`,
2724
+ borderRadius: "8px",
2725
+ fontSize: "14px"
2726
+ }, children: success }),
2727
+ !needsOtp && !usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2728
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
2729
+ display: "block",
2730
+ marginBottom: "8px",
2731
+ fontWeight: 500,
2732
+ color: colors.textSecondary,
2733
+ fontSize: "14px"
2734
+ }, children: "Email" }),
2735
+ /* @__PURE__ */ jsxRuntime.jsx(
2736
+ "input",
2737
+ {
2738
+ id: "email",
2739
+ type: "email",
2740
+ value: email,
2741
+ onChange: (e) => setEmail(e.target.value),
2742
+ onFocus: (e) => {
2743
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2744
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2745
+ },
2746
+ onBlur: (e) => {
2747
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2748
+ e.currentTarget.style.outline = "none";
2749
+ },
2750
+ required: true,
2751
+ disabled: isLoading,
2752
+ style: {
2753
+ width: "100%",
2754
+ padding: "12px 16px",
2755
+ border: `1px solid ${colors.borderSecondary}`,
2756
+ borderRadius: "8px",
2757
+ fontSize: "16px",
2758
+ boxSizing: "border-box",
2759
+ backgroundColor: colors.bgSecondary,
2760
+ color: colors.textPrimary,
2761
+ transition: "all 0.2s ease",
2762
+ WebkitTextFillColor: colors.textPrimary,
2763
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2764
+ ...appearance?.elements?.formFieldInput
2765
+ },
2766
+ placeholder: "Enter your email"
2767
+ }
2768
+ )
2769
+ ] }),
2770
+ !needsOtp && usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2771
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
2772
+ display: "block",
2773
+ marginBottom: "8px",
2774
+ fontWeight: 500,
2775
+ color: colors.textSecondary,
2776
+ fontSize: "14px"
2777
+ }, children: "Phone Number" }),
2778
+ /* @__PURE__ */ jsxRuntime.jsx(
2779
+ "input",
2780
+ {
2781
+ id: "phoneNumber",
2782
+ type: "tel",
2783
+ value: phoneNumber,
2784
+ onChange: (e) => setPhoneNumber(e.target.value),
2785
+ onFocus: (e) => {
2786
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2787
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2788
+ },
2789
+ onBlur: (e) => {
2790
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2791
+ e.currentTarget.style.outline = "none";
2792
+ },
2793
+ required: true,
2794
+ disabled: isLoading,
2795
+ style: {
2796
+ width: "100%",
2797
+ padding: "12px 16px",
2798
+ border: `1px solid ${colors.borderSecondary}`,
2799
+ borderRadius: "8px",
2800
+ fontSize: "16px",
2801
+ boxSizing: "border-box",
2802
+ backgroundColor: colors.bgSecondary,
2803
+ color: colors.textPrimary,
2804
+ transition: "all 0.2s ease",
2805
+ WebkitTextFillColor: colors.textPrimary,
2806
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2807
+ ...appearance?.elements?.formFieldInput
2808
+ },
2809
+ placeholder: "Enter your phone number"
2810
+ }
2811
+ )
2812
+ ] }),
2813
+ usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2814
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2815
+ display: "block",
2816
+ marginBottom: "8px",
2817
+ fontWeight: 500,
2818
+ color: colors.textSecondary,
2819
+ fontSize: "14px"
2820
+ }, children: "Password" }),
2821
+ /* @__PURE__ */ jsxRuntime.jsx(
2822
+ "input",
2823
+ {
2824
+ id: "password",
2825
+ type: showPassword ? "text" : "password",
2826
+ value: password,
2827
+ onChange: (e) => setPassword(e.target.value),
2828
+ onFocus: (e) => {
2829
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2830
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2831
+ },
2832
+ onBlur: (e) => {
2833
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2834
+ e.currentTarget.style.outline = "none";
2835
+ },
2836
+ required: true,
2837
+ disabled: isLoading,
2838
+ style: {
2839
+ width: "100%",
2840
+ padding: "12px 16px",
2841
+ border: `1px solid ${colors.borderSecondary}`,
2842
+ borderRadius: "8px",
2843
+ fontSize: "16px",
2844
+ boxSizing: "border-box",
2845
+ backgroundColor: colors.bgSecondary,
2846
+ color: colors.textPrimary,
2847
+ transition: "all 0.2s ease",
2848
+ WebkitTextFillColor: colors.textPrimary,
2849
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2850
+ ...appearance?.elements?.formFieldInput
2851
+ },
2852
+ placeholder: "Enter your password"
2853
+ }
2854
+ ),
2855
+ /* @__PURE__ */ jsxRuntime.jsx(
2856
+ "button",
2857
+ {
2858
+ type: "button",
2859
+ onClick: () => setShowPassword(!showPassword),
2860
+ style: {
2861
+ position: "absolute",
2862
+ right: "12px",
2863
+ top: "38px",
2864
+ background: "none",
2865
+ border: "none",
2866
+ cursor: "pointer",
2867
+ color: colors.textTertiary,
2868
+ fontSize: "14px"
2869
+ },
2870
+ children: showPassword ? "Hide" : "Show"
2871
+ }
2872
+ )
2873
+ ] }),
2874
+ needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2875
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
2876
+ display: "block",
2877
+ marginBottom: "8px",
2878
+ fontWeight: 500,
2879
+ color: colors.textSecondary,
2880
+ fontSize: "14px"
2881
+ }, children: "One-Time Password" }),
2882
+ /* @__PURE__ */ jsxRuntime.jsx(
2883
+ "input",
2884
+ {
2885
+ id: "otp",
2886
+ type: "text",
2887
+ value: otp,
2888
+ onChange: (e) => setOtp(e.target.value),
2889
+ onFocus: (e) => {
2890
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2891
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2892
+ },
2893
+ onBlur: (e) => {
2894
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2895
+ e.currentTarget.style.outline = "none";
2896
+ },
2897
+ required: true,
2898
+ disabled: isLoading,
2899
+ maxLength: 6,
2900
+ style: {
2901
+ width: "100%",
2902
+ padding: "12px 16px",
2903
+ border: `1px solid ${colors.borderSecondary}`,
2904
+ borderRadius: "8px",
2905
+ fontSize: "16px",
2906
+ boxSizing: "border-box",
2907
+ letterSpacing: "0.5em",
2908
+ textAlign: "center",
2909
+ backgroundColor: colors.bgSecondary,
2910
+ color: colors.textPrimary,
2911
+ transition: "all 0.2s ease",
2912
+ WebkitTextFillColor: colors.textPrimary,
2913
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2914
+ ...appearance?.elements?.formFieldInput
2915
+ },
2916
+ placeholder: "000000"
2917
+ }
2918
+ )
2919
+ ] }),
2920
+ /* @__PURE__ */ jsxRuntime.jsx(
2921
+ "button",
2922
+ {
2923
+ type: "submit",
2924
+ disabled: isLoading,
2925
+ onMouseEnter: (e) => {
2926
+ if (!isLoading) {
2927
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
2928
+ }
2929
+ },
2930
+ onMouseLeave: (e) => {
2931
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
2932
+ },
2933
+ style: {
2934
+ width: "100%",
2935
+ padding: "14px",
2936
+ backgroundColor: colors.buttonPrimary,
2937
+ color: "white",
2938
+ border: "none",
2939
+ borderRadius: "8px",
2940
+ fontSize: "16px",
2941
+ fontWeight: 600,
2942
+ cursor: isLoading ? "not-allowed" : "pointer",
2943
+ opacity: isLoading ? 0.6 : 1,
2944
+ transition: "all 0.2s ease",
2945
+ ...appearance?.elements?.formButtonPrimary
2946
+ },
2947
+ children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
2948
+ }
2949
+ ),
2950
+ !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
2951
+ /* @__PURE__ */ jsxRuntime.jsx(
2952
+ "button",
2953
+ {
2954
+ type: "button",
2955
+ onClick: toggleAuthMethod,
2956
+ disabled: isLoading,
2957
+ style: {
2958
+ background: "none",
2959
+ border: "none",
2960
+ color: colors.buttonPrimary,
2961
+ cursor: "pointer",
2962
+ fontSize: "14px",
2963
+ fontWeight: 600,
2964
+ marginRight: "16px"
2965
+ },
2966
+ children: usePassword ? "Use OTP code instead" : "Use password instead"
2967
+ }
2968
+ ),
2969
+ /* @__PURE__ */ jsxRuntime.jsx(
2970
+ "button",
2971
+ {
2972
+ type: "button",
2973
+ onClick: toggleLoginMethod,
2974
+ disabled: isLoading,
2975
+ style: {
2976
+ background: "none",
2977
+ border: "none",
2978
+ color: colors.buttonPrimary,
2979
+ cursor: "pointer",
2980
+ fontSize: "14px",
2981
+ fontWeight: 600
2982
+ },
2983
+ children: usePhone ? "Use email instead" : "Use phone instead"
2984
+ }
2985
+ )
2986
+ ] }),
2987
+ needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2988
+ "button",
2989
+ {
2990
+ type: "button",
2991
+ onClick: () => {
2992
+ setNeedsOtp(false);
2993
+ setOtp("");
2994
+ setError(null);
2995
+ setSuccess(null);
2996
+ },
2997
+ disabled: isLoading,
2998
+ style: {
2999
+ background: "none",
3000
+ border: "none",
3001
+ color: colors.buttonPrimary,
3002
+ cursor: "pointer",
3003
+ fontSize: "14px",
3004
+ fontWeight: 600
3005
+ },
3006
+ children: "Back to sign in"
3007
+ }
3008
+ ) })
3009
+ ] })
3010
+ }
3011
+ );
2456
3012
  };
2457
3013
  var SignUp = ({ redirectUrl, appearance }) => {
2458
3014
  const { signUp, isSignedIn } = useAuth2();
2459
- const [name, setName] = react.useState("");
2460
- const [email, setEmail] = react.useState("");
2461
- const [password, setPassword] = react.useState("");
2462
- const [confirmPassword, setConfirmPassword] = react.useState("");
2463
- const [showPassword, setShowPassword] = react.useState(false);
2464
- const [isLoading, setIsLoading] = react.useState(false);
2465
- const [error, setError] = react.useState(null);
2466
- const [success, setSuccess] = react.useState(null);
2467
- react.useEffect(() => {
3015
+ const colors = useThemeColors();
3016
+ const [name, setName] = React3.useState("");
3017
+ const [email, setEmail] = React3.useState("");
3018
+ const [phoneNumber, setPhoneNumber] = React3.useState("");
3019
+ const [password, setPassword] = React3.useState("");
3020
+ const [confirmPassword, setConfirmPassword] = React3.useState("");
3021
+ const [showPassword, setShowPassword] = React3.useState(false);
3022
+ const [isLoading, setIsLoading] = React3.useState(false);
3023
+ const [error, setError] = React3.useState(null);
3024
+ const [success, setSuccess] = React3.useState(null);
3025
+ React3.useEffect(() => {
2468
3026
  if (isSignedIn && redirectUrl) {
2469
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
3027
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
2470
3028
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2471
- window.location.href = `${baseUrl}${redirect2}`;
3029
+ window.location.href = `${baseUrl}${redirect}`;
2472
3030
  }
2473
3031
  }, [isSignedIn, redirectUrl]);
2474
- const getPasswordStrength = (pwd) => {
3032
+ const getPasswordStrength = (pwd, colors2) => {
2475
3033
  if (!pwd)
2476
- return { strength: "weak", color: "#ddd" };
3034
+ return { strength: "weak", color: colors2.borderSecondary };
2477
3035
  let score = 0;
2478
3036
  if (pwd.length >= 6)
2479
3037
  score++;
@@ -2486,12 +3044,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2486
3044
  if (/[^a-zA-Z\d]/.test(pwd))
2487
3045
  score++;
2488
3046
  if (score <= 2)
2489
- return { strength: "weak", color: "#f44" };
3047
+ return { strength: "weak", color: colors2.errorText };
2490
3048
  if (score <= 3)
2491
- return { strength: "medium", color: "#fa4" };
2492
- return { strength: "strong", color: "#4f4" };
3049
+ return { strength: "medium", color: colors2.warningText || "#fa4" };
3050
+ return { strength: "strong", color: colors2.successText };
2493
3051
  };
2494
- const passwordStrength = getPasswordStrength(password);
3052
+ const passwordStrength = getPasswordStrength(password, colors);
2495
3053
  const handleSubmit = async (e) => {
2496
3054
  e.preventDefault();
2497
3055
  setIsLoading(true);
@@ -2508,7 +3066,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2508
3066
  return;
2509
3067
  }
2510
3068
  try {
2511
- const response = await signUp({ name, email, password });
3069
+ const signUpData = { name, password };
3070
+ if (email)
3071
+ signUpData.email = email;
3072
+ if (phoneNumber)
3073
+ signUpData.phoneNumber = phoneNumber;
3074
+ const response = await signUp(signUpData);
2512
3075
  if (response.success) {
2513
3076
  setSuccess("Registration successful! Please check your email to verify your account.");
2514
3077
  } else {
@@ -2520,20 +3083,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
2520
3083
  setIsLoading(false);
2521
3084
  }
2522
3085
  };
2523
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3086
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeWrapper, { style: {
2524
3087
  maxWidth: "400px",
2525
3088
  margin: "0 auto",
2526
3089
  padding: "30px",
2527
3090
  borderRadius: "12px",
2528
3091
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2529
- backgroundColor: "#ffffff",
2530
- border: "1px solid #eaeaea",
3092
+ backgroundColor: colors.bgPrimary,
3093
+ border: `1px solid ${colors.borderPrimary}`,
2531
3094
  ...appearance?.elements?.card
2532
3095
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
2533
3096
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
2534
3097
  textAlign: "center",
2535
3098
  marginBottom: "24px",
2536
- color: "#1f2937",
3099
+ color: colors.textPrimary,
2537
3100
  fontSize: "24px",
2538
3101
  fontWeight: 600,
2539
3102
  ...appearance?.elements?.headerTitle
@@ -2541,18 +3104,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
2541
3104
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2542
3105
  padding: "12px 16px",
2543
3106
  marginBottom: "20px",
2544
- backgroundColor: "#fee",
2545
- color: "#c33",
2546
- border: "1px solid #fcc",
3107
+ backgroundColor: colors.errorBg,
3108
+ color: colors.errorText,
3109
+ border: `1px solid ${colors.errorBorder}`,
2547
3110
  borderRadius: "8px",
2548
3111
  fontSize: "14px"
2549
3112
  }, children: error }),
2550
3113
  success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2551
3114
  padding: "12px 16px",
2552
3115
  marginBottom: "20px",
2553
- backgroundColor: "#efe",
2554
- color: "#3c3",
2555
- border: "1px solid #cfc",
3116
+ backgroundColor: colors.successBg,
3117
+ color: colors.successText,
3118
+ border: `1px solid ${colors.successBorder}`,
2556
3119
  borderRadius: "8px",
2557
3120
  fontSize: "14px"
2558
3121
  }, children: success }),
@@ -2561,7 +3124,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2561
3124
  display: "block",
2562
3125
  marginBottom: "8px",
2563
3126
  fontWeight: 500,
2564
- color: "#374151",
3127
+ color: colors.textSecondary,
2565
3128
  fontSize: "14px"
2566
3129
  }, children: "Full name" }),
2567
3130
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2571,15 +3134,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2571
3134
  type: "text",
2572
3135
  value: name,
2573
3136
  onChange: (e) => setName(e.target.value),
3137
+ onFocus: (e) => {
3138
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3139
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3140
+ },
3141
+ onBlur: (e) => {
3142
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3143
+ e.currentTarget.style.outline = "none";
3144
+ },
2574
3145
  required: true,
2575
3146
  disabled: isLoading,
2576
3147
  style: {
2577
3148
  width: "100%",
2578
3149
  padding: "12px 16px",
2579
- border: "1px solid #ddd",
3150
+ border: `1px solid ${colors.borderSecondary}`,
2580
3151
  borderRadius: "8px",
2581
3152
  fontSize: "16px",
2582
3153
  boxSizing: "border-box",
3154
+ backgroundColor: colors.bgSecondary,
3155
+ color: colors.textPrimary,
3156
+ transition: "all 0.2s ease",
3157
+ WebkitTextFillColor: colors.textPrimary,
3158
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2583
3159
  ...appearance?.elements?.formFieldInput
2584
3160
  },
2585
3161
  placeholder: "Enter your full name"
@@ -2591,7 +3167,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2591
3167
  display: "block",
2592
3168
  marginBottom: "8px",
2593
3169
  fontWeight: 500,
2594
- color: "#374151",
3170
+ color: colors.textSecondary,
2595
3171
  fontSize: "14px"
2596
3172
  }, children: "Email" }),
2597
3173
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2601,27 +3177,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
2601
3177
  type: "email",
2602
3178
  value: email,
2603
3179
  onChange: (e) => setEmail(e.target.value),
2604
- required: true,
3180
+ onFocus: (e) => {
3181
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3182
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3183
+ },
3184
+ onBlur: (e) => {
3185
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3186
+ e.currentTarget.style.outline = "none";
3187
+ },
3188
+ required: !phoneNumber,
2605
3189
  disabled: isLoading,
2606
3190
  style: {
2607
3191
  width: "100%",
2608
3192
  padding: "12px 16px",
2609
- border: "1px solid #ddd",
3193
+ border: `1px solid ${colors.borderSecondary}`,
2610
3194
  borderRadius: "8px",
2611
3195
  fontSize: "16px",
2612
3196
  boxSizing: "border-box",
3197
+ backgroundColor: colors.bgSecondary,
3198
+ color: colors.textPrimary,
3199
+ transition: "all 0.2s ease",
3200
+ WebkitTextFillColor: colors.textPrimary,
3201
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2613
3202
  ...appearance?.elements?.formFieldInput
2614
3203
  },
2615
3204
  placeholder: "Enter your email"
2616
3205
  }
2617
3206
  )
2618
3207
  ] }),
3208
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
3209
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
3210
+ display: "block",
3211
+ marginBottom: "8px",
3212
+ fontWeight: 500,
3213
+ color: colors.textSecondary,
3214
+ fontSize: "14px"
3215
+ }, children: "Phone Number (Optional)" }),
3216
+ /* @__PURE__ */ jsxRuntime.jsx(
3217
+ PhoneInput,
3218
+ {
3219
+ id: "phoneNumber",
3220
+ value: phoneNumber,
3221
+ onChange: setPhoneNumber,
3222
+ disabled: isLoading,
3223
+ placeholder: "1234567890",
3224
+ style: appearance?.elements?.formFieldInput
3225
+ }
3226
+ )
3227
+ ] }),
2619
3228
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2620
3229
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2621
3230
  display: "block",
2622
3231
  marginBottom: "8px",
2623
3232
  fontWeight: 500,
2624
- color: "#374151",
3233
+ color: colors.textSecondary,
2625
3234
  fontSize: "14px"
2626
3235
  }, children: "Password" }),
2627
3236
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2631,16 +3240,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
2631
3240
  type: showPassword ? "text" : "password",
2632
3241
  value: password,
2633
3242
  onChange: (e) => setPassword(e.target.value),
3243
+ onFocus: (e) => {
3244
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3245
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3246
+ },
3247
+ onBlur: (e) => {
3248
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3249
+ e.currentTarget.style.outline = "none";
3250
+ },
2634
3251
  required: true,
2635
3252
  disabled: isLoading,
2636
3253
  minLength: 6,
2637
3254
  style: {
2638
3255
  width: "100%",
2639
3256
  padding: "12px 16px",
2640
- border: "1px solid #ddd",
3257
+ border: `1px solid ${colors.borderSecondary}`,
2641
3258
  borderRadius: "8px",
2642
3259
  fontSize: "16px",
2643
3260
  boxSizing: "border-box",
3261
+ backgroundColor: colors.bgSecondary,
3262
+ color: colors.textPrimary,
3263
+ transition: "all 0.2s ease",
3264
+ WebkitTextFillColor: colors.textPrimary,
3265
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2644
3266
  ...appearance?.elements?.formFieldInput
2645
3267
  },
2646
3268
  placeholder: "Create a password"
@@ -2658,7 +3280,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2658
3280
  background: "none",
2659
3281
  border: "none",
2660
3282
  cursor: "pointer",
2661
- color: "#666",
3283
+ color: colors.textTertiary,
2662
3284
  fontSize: "14px"
2663
3285
  },
2664
3286
  children: showPassword ? "Hide" : "Show"
@@ -2667,7 +3289,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2667
3289
  password && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "8px" }, children: [
2668
3290
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2669
3291
  height: "4px",
2670
- backgroundColor: "#eee",
3292
+ backgroundColor: colors.borderSecondary,
2671
3293
  borderRadius: "2px",
2672
3294
  overflow: "hidden"
2673
3295
  }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
@@ -2692,7 +3314,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2692
3314
  display: "block",
2693
3315
  marginBottom: "8px",
2694
3316
  fontWeight: 500,
2695
- color: "#374151",
3317
+ color: colors.textSecondary,
2696
3318
  fontSize: "14px"
2697
3319
  }, children: "Confirm password" }),
2698
3320
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2702,15 +3324,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2702
3324
  type: showPassword ? "text" : "password",
2703
3325
  value: confirmPassword,
2704
3326
  onChange: (e) => setConfirmPassword(e.target.value),
3327
+ onFocus: (e) => {
3328
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3329
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3330
+ },
3331
+ onBlur: (e) => {
3332
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3333
+ e.currentTarget.style.outline = "none";
3334
+ },
2705
3335
  required: true,
2706
3336
  disabled: isLoading,
2707
3337
  style: {
2708
3338
  width: "100%",
2709
3339
  padding: "12px 16px",
2710
- border: "1px solid #ddd",
3340
+ border: `1px solid ${colors.borderSecondary}`,
2711
3341
  borderRadius: "8px",
2712
3342
  fontSize: "16px",
2713
3343
  boxSizing: "border-box",
3344
+ backgroundColor: colors.bgSecondary,
3345
+ color: colors.textPrimary,
3346
+ transition: "all 0.2s ease",
3347
+ WebkitTextFillColor: colors.textPrimary,
3348
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2714
3349
  ...appearance?.elements?.formFieldInput
2715
3350
  },
2716
3351
  placeholder: "Confirm your password"
@@ -2722,16 +3357,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
2722
3357
  {
2723
3358
  type: "submit",
2724
3359
  disabled: isLoading,
3360
+ onMouseEnter: (e) => {
3361
+ if (!isLoading) {
3362
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
3363
+ }
3364
+ },
3365
+ onMouseLeave: (e) => {
3366
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3367
+ },
2725
3368
  style: {
2726
3369
  width: "100%",
2727
3370
  padding: "14px",
2728
- backgroundColor: "#007bff",
3371
+ backgroundColor: colors.buttonPrimary,
2729
3372
  color: "white",
2730
3373
  border: "none",
2731
3374
  borderRadius: "8px",
2732
3375
  fontSize: "16px",
2733
3376
  fontWeight: 600,
2734
- cursor: "pointer",
3377
+ cursor: isLoading ? "not-allowed" : "pointer",
3378
+ opacity: isLoading ? 0.6 : 1,
2735
3379
  transition: "all 0.2s ease",
2736
3380
  ...appearance?.elements?.formButtonPrimary
2737
3381
  },
@@ -2742,12 +3386,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2742
3386
  };
2743
3387
  var SignOut = ({ redirectUrl }) => {
2744
3388
  const { signOut } = useAuth2();
2745
- react.useEffect(() => {
3389
+ React3.useEffect(() => {
2746
3390
  const performSignOut = async () => {
2747
3391
  await signOut();
2748
- const redirect2 = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
3392
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
2749
3393
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2750
- window.location.href = `${baseUrl}${redirect2}`;
3394
+ window.location.href = `${baseUrl}${redirect}`;
2751
3395
  };
2752
3396
  performSignOut();
2753
3397
  }, [signOut, redirectUrl]);
@@ -2755,9 +3399,10 @@ var SignOut = ({ redirectUrl }) => {
2755
3399
  };
2756
3400
  var UserButton = ({ showName = false, appearance }) => {
2757
3401
  const { user, signOut } = useAuth2();
2758
- const [isOpen, setIsOpen] = react.useState(false);
2759
- const dropdownRef = react.useRef(null);
2760
- react.useEffect(() => {
3402
+ const colors = useThemeColors();
3403
+ const [isOpen, setIsOpen] = React3.useState(false);
3404
+ const dropdownRef = React3.useRef(null);
3405
+ React3.useEffect(() => {
2761
3406
  const handleClickOutside = (event) => {
2762
3407
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
2763
3408
  setIsOpen(false);
@@ -2773,11 +3418,11 @@ var UserButton = ({ showName = false, appearance }) => {
2773
3418
  };
2774
3419
  const handleSignOut = async () => {
2775
3420
  await signOut();
2776
- const redirect2 = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
3421
+ const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
2777
3422
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2778
- window.location.href = `${baseUrl}${redirect2}`;
3423
+ window.location.href = `${baseUrl}${redirect}`;
2779
3424
  };
2780
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
3425
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
2781
3426
  /* @__PURE__ */ jsxRuntime.jsxs(
2782
3427
  "button",
2783
3428
  {
@@ -2795,7 +3440,7 @@ var UserButton = ({ showName = false, appearance }) => {
2795
3440
  ...appearance?.elements?.userButtonTrigger
2796
3441
  },
2797
3442
  onMouseEnter: (e) => {
2798
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3443
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2799
3444
  },
2800
3445
  onMouseLeave: (e) => {
2801
3446
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2805,15 +3450,15 @@ var UserButton = ({ showName = false, appearance }) => {
2805
3450
  width: "36px",
2806
3451
  height: "36px",
2807
3452
  borderRadius: "50%",
2808
- backgroundColor: "#007bff",
2809
- color: "white",
3453
+ backgroundColor: colors.buttonPrimary,
3454
+ color: colors.textPrimary,
2810
3455
  display: "flex",
2811
3456
  alignItems: "center",
2812
3457
  justifyContent: "center",
2813
3458
  fontSize: "14px",
2814
3459
  fontWeight: 600
2815
3460
  }, children: getInitials(user.name) }),
2816
- showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: "#333" }, children: user.name })
3461
+ showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
2817
3462
  ]
2818
3463
  }
2819
3464
  ),
@@ -2823,16 +3468,16 @@ var UserButton = ({ showName = false, appearance }) => {
2823
3468
  right: 0,
2824
3469
  marginTop: "8px",
2825
3470
  width: "240px",
2826
- backgroundColor: "white",
3471
+ backgroundColor: colors.bgPrimary,
2827
3472
  borderRadius: "12px",
2828
3473
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
2829
- border: "1px solid #eaeaea",
3474
+ border: `1px solid ${colors.borderPrimary}`,
2830
3475
  zIndex: 1e3,
2831
3476
  ...appearance?.elements?.userButtonPopoverCard
2832
3477
  }, children: [
2833
3478
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2834
3479
  padding: "16px",
2835
- borderBottom: "1px solid #eee"
3480
+ borderBottom: `1px solid ${colors.borderPrimary}`
2836
3481
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2837
3482
  display: "flex",
2838
3483
  alignItems: "center",
@@ -2842,8 +3487,8 @@ var UserButton = ({ showName = false, appearance }) => {
2842
3487
  width: "48px",
2843
3488
  height: "48px",
2844
3489
  borderRadius: "50%",
2845
- backgroundColor: "#007bff",
2846
- color: "white",
3490
+ backgroundColor: colors.buttonPrimary,
3491
+ color: colors.textPrimary,
2847
3492
  display: "flex",
2848
3493
  alignItems: "center",
2849
3494
  justifyContent: "center",
@@ -2854,14 +3499,14 @@ var UserButton = ({ showName = false, appearance }) => {
2854
3499
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2855
3500
  fontSize: "14px",
2856
3501
  fontWeight: 600,
2857
- color: "#333",
3502
+ color: colors.textPrimary,
2858
3503
  overflow: "hidden",
2859
3504
  textOverflow: "ellipsis",
2860
3505
  whiteSpace: "nowrap"
2861
3506
  }, children: user.name }),
2862
3507
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2863
3508
  fontSize: "12px",
2864
- color: "#666",
3509
+ color: colors.textTertiary,
2865
3510
  overflow: "hidden",
2866
3511
  textOverflow: "ellipsis",
2867
3512
  whiteSpace: "nowrap"
@@ -2881,12 +3526,12 @@ var UserButton = ({ showName = false, appearance }) => {
2881
3526
  textAlign: "left",
2882
3527
  cursor: "pointer",
2883
3528
  fontSize: "14px",
2884
- color: "#333",
3529
+ color: colors.textPrimary,
2885
3530
  fontWeight: 500,
2886
3531
  transition: "background-color 0.2s"
2887
3532
  },
2888
3533
  onMouseEnter: (e) => {
2889
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3534
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2890
3535
  },
2891
3536
  onMouseLeave: (e) => {
2892
3537
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2903,7 +3548,7 @@ var ProtectedRoute = ({
2903
3548
  redirectTo
2904
3549
  }) => {
2905
3550
  const { isSignedIn, isLoaded } = useAuth2();
2906
- react.useEffect(() => {
3551
+ React3.useEffect(() => {
2907
3552
  if (isLoaded && !isSignedIn) {
2908
3553
  const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
2909
3554
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -2928,7 +3573,7 @@ var PublicRoute = ({
2928
3573
  redirectTo
2929
3574
  }) => {
2930
3575
  const { isSignedIn, isLoaded } = useAuth2();
2931
- react.useEffect(() => {
3576
+ React3.useEffect(() => {
2932
3577
  if (isLoaded && isSignedIn) {
2933
3578
  const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2934
3579
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -2950,9 +3595,9 @@ var PublicRoute = ({
2950
3595
  };
2951
3596
  var VerifyEmail = ({ token, onSuccess, onError }) => {
2952
3597
  const { verifyEmailToken } = useAuth2();
2953
- const [status, setStatus] = react.useState("loading");
2954
- const [message, setMessage] = react.useState("");
2955
- react.useEffect(() => {
3598
+ const [status, setStatus] = React3.useState("loading");
3599
+ const [message, setMessage] = React3.useState("");
3600
+ React3.useEffect(() => {
2956
3601
  const verify = async () => {
2957
3602
  const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
2958
3603
  if (!verifyToken) {
@@ -2968,9 +3613,9 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
2968
3613
  setMessage("Email verified successfully! Redirecting...");
2969
3614
  onSuccess?.();
2970
3615
  setTimeout(() => {
2971
- const redirect2 = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_VERIFY || process.env.REACT_APP_AUTH_REDIRECT_AFTER_VERIFY || "/dashboard";
3616
+ const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_VERIFY || process.env.REACT_APP_AUTH_REDIRECT_AFTER_VERIFY || "/dashboard";
2972
3617
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2973
- window.location.href = `${baseUrl}${redirect2}`;
3618
+ window.location.href = `${baseUrl}${redirect}`;
2974
3619
  }, 2e3);
2975
3620
  } else {
2976
3621
  setStatus("error");
@@ -3086,10 +3731,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
3086
3731
  };
3087
3732
  var ForgotPassword = ({ appearance }) => {
3088
3733
  const { forgotPassword } = useAuth2();
3089
- const [email, setEmail] = react.useState("");
3090
- const [isLoading, setIsLoading] = react.useState(false);
3091
- const [error, setError] = react.useState(null);
3092
- const [success, setSuccess] = react.useState(null);
3734
+ const [email, setEmail] = React3.useState("");
3735
+ const [isLoading, setIsLoading] = React3.useState(false);
3736
+ const [error, setError] = React3.useState(null);
3737
+ const [success, setSuccess] = React3.useState(null);
3093
3738
  const handleSubmit = async (e) => {
3094
3739
  e.preventDefault();
3095
3740
  setIsLoading(true);
@@ -3228,14 +3873,14 @@ var ForgotPassword = ({ appearance }) => {
3228
3873
  };
3229
3874
  var ResetPassword = ({ token, appearance }) => {
3230
3875
  const { resetPassword } = useAuth2();
3231
- const [resetToken, setResetToken] = react.useState(token || "");
3232
- const [password, setPassword] = react.useState("");
3233
- const [confirmPassword, setConfirmPassword] = react.useState("");
3234
- const [showPassword, setShowPassword] = react.useState(false);
3235
- const [isLoading, setIsLoading] = react.useState(false);
3236
- const [error, setError] = react.useState(null);
3237
- const [success, setSuccess] = react.useState(false);
3238
- react.useEffect(() => {
3876
+ const [resetToken, setResetToken] = React3.useState(token || "");
3877
+ const [password, setPassword] = React3.useState("");
3878
+ const [confirmPassword, setConfirmPassword] = React3.useState("");
3879
+ const [showPassword, setShowPassword] = React3.useState(false);
3880
+ const [isLoading, setIsLoading] = React3.useState(false);
3881
+ const [error, setError] = React3.useState(null);
3882
+ const [success, setSuccess] = React3.useState(false);
3883
+ React3.useEffect(() => {
3239
3884
  if (!resetToken && typeof window !== "undefined") {
3240
3885
  const urlToken = new URLSearchParams(window.location.search).get("token");
3241
3886
  if (urlToken) {
@@ -3490,13 +4135,13 @@ var ResetPassword = ({ token, appearance }) => {
3490
4135
  };
3491
4136
  var ChangePassword = ({ onSuccess, appearance }) => {
3492
4137
  const { changePassword } = useAuth2();
3493
- const [oldPassword, setOldPassword] = react.useState("");
3494
- const [newPassword, setNewPassword] = react.useState("");
3495
- const [confirmPassword, setConfirmPassword] = react.useState("");
3496
- const [showPasswords, setShowPasswords] = react.useState(false);
3497
- const [isLoading, setIsLoading] = react.useState(false);
3498
- const [error, setError] = react.useState(null);
3499
- const [success, setSuccess] = react.useState(false);
4138
+ const [oldPassword, setOldPassword] = React3.useState("");
4139
+ const [newPassword, setNewPassword] = React3.useState("");
4140
+ const [confirmPassword, setConfirmPassword] = React3.useState("");
4141
+ const [showPasswords, setShowPasswords] = React3.useState(false);
4142
+ const [isLoading, setIsLoading] = React3.useState(false);
4143
+ const [error, setError] = React3.useState(null);
4144
+ const [success, setSuccess] = React3.useState(false);
3500
4145
  const getPasswordStrength = (pwd) => {
3501
4146
  if (!pwd)
3502
4147
  return { strength: "weak", color: "#ddd" };
@@ -3739,43 +4384,41 @@ var UserProfile = ({
3739
4384
  showEmailChange = true,
3740
4385
  showPasswordChange = true
3741
4386
  }) => {
3742
- const { user, updateProfile, updateAvatar, requestEmailChange } = useAuth2();
3743
- const [name, setName] = react.useState(user?.name || "");
3744
- const [avatar, setAvatar] = react.useState("");
3745
- const [newEmail, setNewEmail] = react.useState("");
3746
- const [isLoading, setIsLoading] = react.useState(false);
3747
- const [error, setError] = react.useState(null);
3748
- const [success, setSuccess] = react.useState(null);
3749
- const handleUpdateName = async (e) => {
4387
+ const { user, updateProfile, requestEmailChange } = useAuth2();
4388
+ const colors = useThemeColors();
4389
+ const [name, setName] = React3.useState(user?.name || "");
4390
+ const [avatar, setAvatar] = React3.useState(user?.avatar || "");
4391
+ const [phoneNumber, setPhoneNumber] = React3.useState(user?.phoneNumber || "");
4392
+ const [newEmail, setNewEmail] = React3.useState("");
4393
+ const [isLoading, setIsLoading] = React3.useState(false);
4394
+ const [error, setError] = React3.useState(null);
4395
+ const [success, setSuccess] = React3.useState(null);
4396
+ const handleUpdateProfile = async (e) => {
3750
4397
  e.preventDefault();
3751
4398
  setIsLoading(true);
3752
4399
  setError(null);
3753
4400
  setSuccess(null);
3754
4401
  try {
3755
- const response = await updateProfile({ name });
3756
- if (response.success) {
3757
- setSuccess("Name updated successfully!");
3758
- } else {
3759
- setError(response.message || "Failed to update name");
4402
+ const updates = {};
4403
+ if (name !== user?.name) {
4404
+ updates.name = name;
3760
4405
  }
3761
- } catch (err) {
3762
- setError(err instanceof Error ? err.message : "An error occurred");
3763
- } finally {
3764
- setIsLoading(false);
3765
- }
3766
- };
3767
- const handleUpdateAvatar = async (e) => {
3768
- e.preventDefault();
3769
- setIsLoading(true);
3770
- setError(null);
3771
- setSuccess(null);
3772
- try {
3773
- const response = await updateAvatar(avatar);
4406
+ if (showAvatar && avatar !== user?.avatar) {
4407
+ updates.avatar = avatar;
4408
+ }
4409
+ if (phoneNumber !== user?.phoneNumber) {
4410
+ updates.phoneNumber = phoneNumber;
4411
+ }
4412
+ if (Object.keys(updates).length === 0) {
4413
+ setError("No changes to save");
4414
+ setIsLoading(false);
4415
+ return;
4416
+ }
4417
+ const response = await updateProfile(updates);
3774
4418
  if (response.success) {
3775
- setSuccess("Avatar updated successfully!");
3776
- setAvatar("");
4419
+ setSuccess("Profile updated successfully!");
3777
4420
  } else {
3778
- setError(response.message || "Failed to update avatar");
4421
+ setError(response.message || "Failed to update profile");
3779
4422
  }
3780
4423
  } catch (err) {
3781
4424
  setError(err instanceof Error ? err.message : "An error occurred");
@@ -3804,173 +4447,220 @@ var UserProfile = ({
3804
4447
  };
3805
4448
  if (!user)
3806
4449
  return null;
3807
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "600px", margin: "0 auto", padding: "20px" }, children: [
3808
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
4450
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4451
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
3809
4452
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3810
4453
  padding: "12px 16px",
3811
4454
  marginBottom: "20px",
3812
- backgroundColor: "#fee",
3813
- color: "#c33",
3814
- border: "1px solid #fcc",
4455
+ backgroundColor: colors.errorBg,
4456
+ color: colors.errorText,
4457
+ border: `1px solid ${colors.errorBorder}`,
3815
4458
  borderRadius: "8px",
3816
4459
  fontSize: "14px"
3817
4460
  }, children: error }),
3818
4461
  success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3819
4462
  padding: "12px 16px",
3820
4463
  marginBottom: "20px",
3821
- backgroundColor: "#efe",
3822
- color: "#3c3",
3823
- border: "1px solid #cfc",
4464
+ backgroundColor: colors.successBg,
4465
+ color: colors.successText,
4466
+ border: `1px solid ${colors.successBorder}`,
3824
4467
  borderRadius: "8px",
3825
4468
  fontSize: "14px"
3826
4469
  }, children: success }),
3827
4470
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3828
- padding: "20px",
3829
- backgroundColor: "#fff",
3830
- borderRadius: "8px",
4471
+ padding: "24px",
4472
+ backgroundColor: colors.bgPrimary,
4473
+ borderRadius: "12px",
3831
4474
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3832
- marginBottom: "20px"
4475
+ marginBottom: "24px",
4476
+ border: `1px solid ${colors.borderPrimary}`
3833
4477
  }, children: [
3834
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Name" }),
3835
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateName, children: [
3836
- /* @__PURE__ */ jsxRuntime.jsx(
3837
- "input",
3838
- {
3839
- type: "text",
3840
- value: name,
3841
- onChange: (e) => setName(e.target.value),
3842
- required: true,
3843
- disabled: isLoading,
3844
- style: {
3845
- width: "100%",
3846
- padding: "12px 16px",
3847
- border: "1px solid #ddd",
3848
- borderRadius: "8px",
3849
- fontSize: "16px",
3850
- boxSizing: "border-box",
3851
- marginBottom: "12px"
3852
- },
3853
- placeholder: "Your name"
3854
- }
3855
- ),
4478
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
4479
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateProfile, children: [
4480
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4481
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
4482
+ display: "block",
4483
+ marginBottom: "8px",
4484
+ fontWeight: 500,
4485
+ color: colors.textSecondary,
4486
+ fontSize: "14px"
4487
+ }, children: "Full Name" }),
4488
+ /* @__PURE__ */ jsxRuntime.jsx(
4489
+ "input",
4490
+ {
4491
+ id: "name",
4492
+ type: "text",
4493
+ value: name,
4494
+ onChange: (e) => setName(e.target.value),
4495
+ required: true,
4496
+ disabled: isLoading,
4497
+ style: {
4498
+ width: "100%",
4499
+ padding: "12px 16px",
4500
+ border: `1px solid ${colors.borderSecondary}`,
4501
+ borderRadius: "8px",
4502
+ fontSize: "16px",
4503
+ boxSizing: "border-box",
4504
+ backgroundColor: colors.bgSecondary,
4505
+ color: colors.textPrimary,
4506
+ transition: "all 0.2s ease"
4507
+ },
4508
+ placeholder: "Manish Batra"
4509
+ }
4510
+ )
4511
+ ] }),
4512
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4513
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
4514
+ display: "block",
4515
+ marginBottom: "8px",
4516
+ fontWeight: 500,
4517
+ color: colors.textSecondary,
4518
+ fontSize: "14px"
4519
+ }, children: "Phone Number" }),
4520
+ /* @__PURE__ */ jsxRuntime.jsx(
4521
+ PhoneInput,
4522
+ {
4523
+ id: "phoneNumber",
4524
+ value: phoneNumber,
4525
+ onChange: setPhoneNumber,
4526
+ disabled: isLoading,
4527
+ placeholder: "1234567890"
4528
+ }
4529
+ )
4530
+ ] }),
4531
+ showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4532
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "avatar", style: {
4533
+ display: "block",
4534
+ marginBottom: "8px",
4535
+ fontWeight: 500,
4536
+ color: colors.textSecondary,
4537
+ fontSize: "14px"
4538
+ }, children: "Avatar URL" }),
4539
+ /* @__PURE__ */ jsxRuntime.jsx(
4540
+ "input",
4541
+ {
4542
+ id: "avatar",
4543
+ type: "url",
4544
+ value: avatar,
4545
+ onChange: (e) => setAvatar(e.target.value),
4546
+ disabled: isLoading,
4547
+ style: {
4548
+ width: "100%",
4549
+ padding: "12px 16px",
4550
+ border: `1px solid ${colors.borderSecondary}`,
4551
+ borderRadius: "8px",
4552
+ fontSize: "16px",
4553
+ boxSizing: "border-box",
4554
+ backgroundColor: colors.bgSecondary,
4555
+ color: colors.textPrimary,
4556
+ transition: "all 0.2s ease"
4557
+ },
4558
+ placeholder: "https://example.com/avatar.jpg"
4559
+ }
4560
+ )
4561
+ ] }),
3856
4562
  /* @__PURE__ */ jsxRuntime.jsx(
3857
4563
  "button",
3858
4564
  {
3859
4565
  type: "submit",
3860
4566
  disabled: isLoading,
3861
- style: {
3862
- padding: "10px 20px",
3863
- backgroundColor: "#007bff",
3864
- color: "white",
3865
- border: "none",
3866
- borderRadius: "8px",
3867
- fontSize: "14px",
3868
- fontWeight: 600,
3869
- cursor: "pointer"
4567
+ onMouseEnter: (e) => {
4568
+ if (!isLoading) {
4569
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4570
+ }
3870
4571
  },
3871
- children: "Update Name"
3872
- }
3873
- )
3874
- ] })
3875
- ] }),
3876
- showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3877
- padding: "20px",
3878
- backgroundColor: "#fff",
3879
- borderRadius: "8px",
3880
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3881
- marginBottom: "20px"
3882
- }, children: [
3883
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
3884
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateAvatar, children: [
3885
- /* @__PURE__ */ jsxRuntime.jsx(
3886
- "input",
3887
- {
3888
- type: "url",
3889
- value: avatar,
3890
- onChange: (e) => setAvatar(e.target.value),
3891
- required: true,
3892
- disabled: isLoading,
3893
- style: {
3894
- width: "100%",
3895
- padding: "12px 16px",
3896
- border: "1px solid #ddd",
3897
- borderRadius: "8px",
3898
- fontSize: "16px",
3899
- boxSizing: "border-box",
3900
- marginBottom: "12px"
4572
+ onMouseLeave: (e) => {
4573
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3901
4574
  },
3902
- placeholder: "Avatar URL"
3903
- }
3904
- ),
3905
- /* @__PURE__ */ jsxRuntime.jsx(
3906
- "button",
3907
- {
3908
- type: "submit",
3909
- disabled: isLoading,
3910
4575
  style: {
3911
- padding: "10px 20px",
3912
- backgroundColor: "#007bff",
4576
+ padding: "12px 24px",
4577
+ backgroundColor: colors.buttonPrimary,
3913
4578
  color: "white",
3914
4579
  border: "none",
3915
4580
  borderRadius: "8px",
3916
4581
  fontSize: "14px",
3917
4582
  fontWeight: 600,
3918
- cursor: "pointer"
4583
+ cursor: isLoading ? "not-allowed" : "pointer",
4584
+ opacity: isLoading ? 0.6 : 1,
4585
+ transition: "all 0.2s ease"
3919
4586
  },
3920
- children: "Update Avatar"
4587
+ children: isLoading ? "Saving..." : "Save Changes"
3921
4588
  }
3922
4589
  )
3923
4590
  ] })
3924
4591
  ] }),
3925
4592
  showEmailChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3926
- padding: "20px",
3927
- backgroundColor: "#fff",
3928
- borderRadius: "8px",
4593
+ padding: "24px",
4594
+ backgroundColor: colors.bgPrimary,
4595
+ borderRadius: "12px",
3929
4596
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3930
- marginBottom: "20px"
4597
+ marginBottom: "20px",
4598
+ border: `1px solid ${colors.borderPrimary}`
3931
4599
  }, children: [
3932
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
3933
- /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: "#666", marginBottom: "12px" }, children: [
4600
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
4601
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
3934
4602
  "Current email: ",
3935
4603
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: user.email })
3936
4604
  ] }),
3937
4605
  /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleRequestEmailChange, children: [
3938
- /* @__PURE__ */ jsxRuntime.jsx(
3939
- "input",
3940
- {
3941
- type: "email",
3942
- value: newEmail,
3943
- onChange: (e) => setNewEmail(e.target.value),
3944
- required: true,
3945
- disabled: isLoading,
3946
- style: {
3947
- width: "100%",
3948
- padding: "12px 16px",
3949
- border: "1px solid #ddd",
3950
- borderRadius: "8px",
3951
- fontSize: "16px",
3952
- boxSizing: "border-box",
3953
- marginBottom: "12px"
3954
- },
3955
- placeholder: "New email address"
3956
- }
3957
- ),
4606
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
4607
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "newEmail", style: {
4608
+ display: "block",
4609
+ marginBottom: "8px",
4610
+ fontWeight: 500,
4611
+ color: colors.textSecondary,
4612
+ fontSize: "14px"
4613
+ }, children: "New Email Address" }),
4614
+ /* @__PURE__ */ jsxRuntime.jsx(
4615
+ "input",
4616
+ {
4617
+ id: "newEmail",
4618
+ type: "email",
4619
+ value: newEmail,
4620
+ onChange: (e) => setNewEmail(e.target.value),
4621
+ required: true,
4622
+ disabled: isLoading,
4623
+ style: {
4624
+ width: "100%",
4625
+ padding: "12px 16px",
4626
+ border: `1px solid ${colors.borderSecondary}`,
4627
+ borderRadius: "8px",
4628
+ fontSize: "16px",
4629
+ boxSizing: "border-box",
4630
+ backgroundColor: colors.bgSecondary,
4631
+ color: colors.textPrimary,
4632
+ transition: "all 0.2s ease"
4633
+ },
4634
+ placeholder: "newemail@example.com"
4635
+ }
4636
+ )
4637
+ ] }),
3958
4638
  /* @__PURE__ */ jsxRuntime.jsx(
3959
4639
  "button",
3960
4640
  {
3961
4641
  type: "submit",
3962
4642
  disabled: isLoading,
4643
+ onMouseEnter: (e) => {
4644
+ if (!isLoading) {
4645
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4646
+ }
4647
+ },
4648
+ onMouseLeave: (e) => {
4649
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
4650
+ },
3963
4651
  style: {
3964
- padding: "10px 20px",
3965
- backgroundColor: "#007bff",
4652
+ padding: "12px 24px",
4653
+ backgroundColor: colors.buttonPrimary,
3966
4654
  color: "white",
3967
4655
  border: "none",
3968
4656
  borderRadius: "8px",
3969
4657
  fontSize: "14px",
3970
4658
  fontWeight: 600,
3971
- cursor: "pointer"
4659
+ cursor: isLoading ? "not-allowed" : "pointer",
4660
+ opacity: isLoading ? 0.6 : 1,
4661
+ transition: "all 0.2s ease"
3972
4662
  },
3973
- children: "Request Email Change"
4663
+ children: isLoading ? "Sending..." : "Request Email Change"
3974
4664
  }
3975
4665
  )
3976
4666
  ] })
@@ -3979,7 +4669,7 @@ var UserProfile = ({
3979
4669
  };
3980
4670
  var isServer = typeof window === "undefined";
3981
4671
  var useNextAuth = (config) => {
3982
- const [authService] = react.useState(() => {
4672
+ const [authService] = React3.useState(() => {
3983
4673
  const service = new AuthService(config);
3984
4674
  if (isServer && config.token) {
3985
4675
  service["token"] = config.token;
@@ -3987,10 +4677,10 @@ var useNextAuth = (config) => {
3987
4677
  }
3988
4678
  return service;
3989
4679
  });
3990
- const [user, setUser] = react.useState(null);
3991
- const [isAuthenticated, setIsAuthenticated] = react.useState(false);
3992
- const [loading, setLoading] = react.useState(true);
3993
- const checkAuthStatus = react.useCallback(() => {
4680
+ const [user, setUser] = React3.useState(null);
4681
+ const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
4682
+ const [loading, setLoading] = React3.useState(true);
4683
+ const checkAuthStatus = React3.useCallback(() => {
3994
4684
  if (isServer) {
3995
4685
  const token = config.token || authService.getToken();
3996
4686
  const authenticated = !!token;
@@ -4010,18 +4700,18 @@ var useNextAuth = (config) => {
4010
4700
  const authenticated = authService.isAuthenticated();
4011
4701
  setIsAuthenticated(authenticated);
4012
4702
  if (authenticated) {
4013
- const currentUser2 = authService.getCurrentUser();
4014
- setUser(currentUser2);
4703
+ const currentUser = authService.getCurrentUser();
4704
+ setUser(currentUser);
4015
4705
  } else {
4016
4706
  setUser(null);
4017
4707
  }
4018
4708
  }
4019
4709
  setLoading(false);
4020
4710
  }, [authService, config.token]);
4021
- react.useEffect(() => {
4711
+ React3.useEffect(() => {
4022
4712
  checkAuthStatus();
4023
4713
  }, [checkAuthStatus]);
4024
- const register = react.useCallback(async (data) => {
4714
+ const register = React3.useCallback(async (data) => {
4025
4715
  setLoading(true);
4026
4716
  try {
4027
4717
  const response = await authService.register(data);
@@ -4030,7 +4720,7 @@ var useNextAuth = (config) => {
4030
4720
  setLoading(false);
4031
4721
  }
4032
4722
  }, [authService]);
4033
- const login = react.useCallback(async (data) => {
4723
+ const login = React3.useCallback(async (data) => {
4034
4724
  setLoading(true);
4035
4725
  try {
4036
4726
  const response = await authService.login(data);
@@ -4039,7 +4729,7 @@ var useNextAuth = (config) => {
4039
4729
  setLoading(false);
4040
4730
  }
4041
4731
  }, [authService]);
4042
- const verify = react.useCallback(async (data) => {
4732
+ const verify = React3.useCallback(async (data) => {
4043
4733
  setLoading(true);
4044
4734
  try {
4045
4735
  const response = await authService.verify(data);
@@ -4052,7 +4742,7 @@ var useNextAuth = (config) => {
4052
4742
  setLoading(false);
4053
4743
  }
4054
4744
  }, [authService]);
4055
- const verifyEmailToken = react.useCallback(async (token) => {
4745
+ const verifyEmailToken = React3.useCallback(async (token) => {
4056
4746
  setLoading(true);
4057
4747
  try {
4058
4748
  const response = await authService.verifyEmailToken(token);
@@ -4065,7 +4755,7 @@ var useNextAuth = (config) => {
4065
4755
  setLoading(false);
4066
4756
  }
4067
4757
  }, [authService]);
4068
- const logout = react.useCallback(async () => {
4758
+ const logout = React3.useCallback(async () => {
4069
4759
  setLoading(true);
4070
4760
  try {
4071
4761
  await authService.logout();
@@ -4075,7 +4765,7 @@ var useNextAuth = (config) => {
4075
4765
  setLoading(false);
4076
4766
  }
4077
4767
  }, [authService]);
4078
- const updateProfile = react.useCallback(async (data) => {
4768
+ const updateProfile = React3.useCallback(async (data) => {
4079
4769
  setLoading(true);
4080
4770
  try {
4081
4771
  const response = await authService.updateProfile(data);
@@ -4087,7 +4777,7 @@ var useNextAuth = (config) => {
4087
4777
  setLoading(false);
4088
4778
  }
4089
4779
  }, [authService]);
4090
- const getProfile = react.useCallback(async () => {
4780
+ const getProfile = React3.useCallback(async () => {
4091
4781
  setLoading(true);
4092
4782
  try {
4093
4783
  const userData = await authService.getProfile();
@@ -4097,7 +4787,7 @@ var useNextAuth = (config) => {
4097
4787
  setLoading(false);
4098
4788
  }
4099
4789
  }, [authService]);
4100
- const getAllUsers = react.useCallback(async () => {
4790
+ const getAllUsers = React3.useCallback(async () => {
4101
4791
  setLoading(true);
4102
4792
  try {
4103
4793
  return await authService.getAllUsers();
@@ -4105,7 +4795,7 @@ var useNextAuth = (config) => {
4105
4795
  setLoading(false);
4106
4796
  }
4107
4797
  }, [authService]);
4108
- const getUserById = react.useCallback(async (id) => {
4798
+ const getUserById = React3.useCallback(async (id) => {
4109
4799
  setLoading(true);
4110
4800
  try {
4111
4801
  return await authService.getUserById(id);
@@ -4113,7 +4803,7 @@ var useNextAuth = (config) => {
4113
4803
  setLoading(false);
4114
4804
  }
4115
4805
  }, [authService]);
4116
- const forgotPassword = react.useCallback(async (email) => {
4806
+ const forgotPassword = React3.useCallback(async (email) => {
4117
4807
  setLoading(true);
4118
4808
  try {
4119
4809
  const response = await authService.forgotPassword(email);
@@ -4122,7 +4812,7 @@ var useNextAuth = (config) => {
4122
4812
  setLoading(false);
4123
4813
  }
4124
4814
  }, [authService]);
4125
- const resetPassword = react.useCallback(async (token, password) => {
4815
+ const resetPassword = React3.useCallback(async (token, password) => {
4126
4816
  setLoading(true);
4127
4817
  try {
4128
4818
  const response = await authService.resetPassword(token, password);
@@ -4131,7 +4821,7 @@ var useNextAuth = (config) => {
4131
4821
  setLoading(false);
4132
4822
  }
4133
4823
  }, [authService]);
4134
- const setToken = react.useCallback((token) => {
4824
+ const setToken = React3.useCallback((token) => {
4135
4825
  authService["token"] = token;
4136
4826
  authService["httpClient"].setAuthToken(token);
4137
4827
  setIsAuthenticated(true);
@@ -4143,7 +4833,7 @@ var useNextAuth = (config) => {
4143
4833
  setUser(null);
4144
4834
  }
4145
4835
  }, [authService]);
4146
- const clearToken = react.useCallback(() => {
4836
+ const clearToken = React3.useCallback(() => {
4147
4837
  authService["token"] = null;
4148
4838
  authService["httpClient"].removeAuthToken();
4149
4839
  setIsAuthenticated(false);
@@ -4169,287 +4859,17 @@ var useNextAuth = (config) => {
4169
4859
  };
4170
4860
  };
4171
4861
 
4172
- // src/node/auth-client.ts
4173
- var AuthClient = class extends AuthService {
4174
- constructor(config) {
4175
- super(config);
4176
- }
4177
- // Override methods that require browser-specific features
4178
- // For Node.js, token persistence must be handled manually
4179
- async register(data) {
4180
- const frontendBaseUrl = process.env.FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL;
4181
- if (frontendBaseUrl) {
4182
- this["httpClient"].setFrontendBaseUrl(frontendBaseUrl);
4183
- }
4184
- const response = await this["httpClient"].post("/api/v1/auth/register", data);
4185
- if (response.success && response.message === "Registration data saved. Verification email sent. Please check your inbox.") {
4186
- return response;
4187
- }
4188
- throw new Error(response.message || "Registration failed");
4189
- }
4190
- async login(data) {
4191
- const response = await this["httpClient"].post("/api/v1/auth/login", data);
4192
- if (response.success && response.token) {
4193
- this["token"] = response.token;
4194
- this["httpClient"].setAuthToken(response.token);
4195
- return response;
4196
- }
4197
- if (response.success && response.message === "OTP sent to your email.") {
4198
- return response;
4199
- }
4200
- if (response.success && response.message === "OTP verified successfully." && response.token) {
4201
- this["token"] = response.token;
4202
- this["httpClient"].setAuthToken(response.token);
4203
- return response;
4204
- }
4205
- throw new Error(response.message || "Login failed");
4206
- }
4207
- async verify(data) {
4208
- const response = await this["httpClient"].post("/api/v1/auth/verify", data);
4209
- if (response.success && response.token) {
4210
- this["token"] = response.token;
4211
- this["httpClient"].setAuthToken(response.token);
4212
- }
4213
- return response;
4214
- }
4215
- async logout() {
4216
- this["token"] = null;
4217
- this["httpClient"].removeAuthToken();
4218
- }
4219
- async getProfile() {
4220
- if (!this["token"]) {
4221
- throw new Error("Not authenticated");
4222
- }
4223
- const response = await this["httpClient"].get("/api/v1/user/me");
4224
- return response.user;
4225
- }
4226
- async getUserById(id) {
4227
- const response = await this["httpClient"].get(`/api/v1/user/${id}`);
4228
- return response.user;
4229
- }
4230
- async updateProfile(data) {
4231
- if (!this["token"]) {
4232
- throw new Error("Not authenticated");
4233
- }
4234
- const response = await this["httpClient"].post("/api/v1/user/update/name", data);
4235
- if (response.success && response.token) {
4236
- this["token"] = response.token;
4237
- this["httpClient"].setAuthToken(response.token);
4238
- }
4239
- return response;
4240
- }
4241
- async getAllUsers() {
4242
- if (!this["token"]) {
4243
- throw new Error("Not authenticated");
4244
- }
4245
- const response = await this["httpClient"].get("/api/v1/user/all");
4246
- return response.users;
4247
- }
4248
- };
4249
-
4250
- // src/nextjs/server-auth.ts
4251
- var NextServerAuth = class extends AuthClient {
4252
- constructor(config) {
4253
- super(config);
4254
- }
4255
- // Parse token from request headers
4256
- static parseTokenFromHeaders(headers) {
4257
- const authHeader = headers.get("authorization");
4258
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
4259
- return null;
4260
- }
4261
- return authHeader.substring(7);
4262
- }
4263
- // Parse token from cookies
4264
- static parseTokenFromCookies(cookies2) {
4265
- const cookieArray = cookies2.split(";");
4266
- for (const cookie of cookieArray) {
4267
- const [name, value] = cookie.trim().split("=");
4268
- if (name === "auth_token") {
4269
- return decodeURIComponent(value);
4270
- }
4271
- }
4272
- return null;
4273
- }
4274
- // Parse token from Next.js request object
4275
- static parseTokenFromRequest(req) {
4276
- if (req.headers) {
4277
- const authHeader = req.headers.authorization || req.headers.Authorization;
4278
- if (authHeader && authHeader.startsWith("Bearer ")) {
4279
- return authHeader.substring(7);
4280
- }
4281
- }
4282
- if (req.cookies) {
4283
- return req.cookies.auth_token || null;
4284
- }
4285
- if (req.headers && req.headers.cookie) {
4286
- return this.parseTokenFromCookies(req.headers.cookie);
4287
- }
4288
- return null;
4289
- }
4290
- // Verify token and get user
4291
- async verifyToken(token) {
4292
- try {
4293
- this["httpClient"].setAuthToken(token);
4294
- const user = await this.getProfile();
4295
- return user;
4296
- } catch (error) {
4297
- console.error("Token verification failed:", error);
4298
- return null;
4299
- }
4300
- }
4301
- // Create authenticated client with token
4302
- static createAuthenticatedClient(config, token) {
4303
- const client = new NextServerAuth(config);
4304
- client["httpClient"].setAuthToken(token);
4305
- client["token"] = token;
4306
- return client;
4307
- }
4308
- };
4309
- var AuthServer = class {
4310
- constructor(config) {
4311
- this.config = {
4312
- authApiUrl: config?.authApiUrl || process.env.AUTH_API_URL || "http://localhost:7000",
4313
- tokenCookieName: config?.tokenCookieName || "auth_token"
4314
- };
4315
- }
4316
- async getToken() {
4317
- const cookieStore = await headers.cookies();
4318
- const token = cookieStore.get(this.config.tokenCookieName);
4319
- return token?.value || null;
4320
- }
4321
- async getCurrentUser() {
4322
- const token = await this.getToken();
4323
- if (!token)
4324
- return null;
4325
- try {
4326
- const payload = JSON.parse(Buffer.from(token.split(".")[1], "base64").toString());
4327
- return payload.user || null;
4328
- } catch (error) {
4329
- console.error("Failed to parse user from token:", error);
4330
- return null;
4331
- }
4332
- }
4333
- async isAuthenticated() {
4334
- const token = await this.getToken();
4335
- return !!token;
4336
- }
4337
- async requireAuth(redirectTo) {
4338
- const user = await this.getCurrentUser();
4339
- if (!user) {
4340
- const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
4341
- navigation.redirect(loginPath);
4342
- }
4343
- return user;
4344
- }
4345
- async redirectIfAuthenticated(redirectTo) {
4346
- const isAuth = await this.isAuthenticated();
4347
- if (isAuth) {
4348
- const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
4349
- navigation.redirect(dashboardPath);
4350
- }
4351
- }
4352
- async getProfile() {
4353
- const token = await this.getToken();
4354
- if (!token)
4355
- return null;
4356
- try {
4357
- const response = await fetch(`${this.config.authApiUrl}/api/v1/user/me`, {
4358
- headers: {
4359
- "Authorization": `Bearer ${token}`
4360
- }
4361
- });
4362
- if (!response.ok) {
4363
- return null;
4364
- }
4365
- const data = await response.json();
4366
- return data.user;
4367
- } catch (error) {
4368
- console.error("Failed to fetch profile:", error);
4369
- return null;
4370
- }
4371
- }
4372
- };
4373
- var authServerInstance = null;
4374
- function getAuthServer(config) {
4375
- if (!authServerInstance) {
4376
- authServerInstance = new AuthServer(config);
4377
- }
4378
- return authServerInstance;
4379
- }
4380
- async function currentUser() {
4381
- const auth2 = getAuthServer();
4382
- return auth2.getCurrentUser();
4383
- }
4384
- async function auth() {
4385
- const authServer = getAuthServer();
4386
- const user = await authServer.getCurrentUser();
4387
- const token = await authServer.getToken();
4388
- return {
4389
- user,
4390
- userId: user?._id || null,
4391
- isAuthenticated: !!user,
4392
- token
4393
- };
4394
- }
4395
- async function requireAuth(redirectTo) {
4396
- const authServer = getAuthServer();
4397
- return authServer.requireAuth(redirectTo);
4398
- }
4399
- async function redirectIfAuthenticated(redirectTo) {
4400
- const authServer = getAuthServer();
4401
- return authServer.redirectIfAuthenticated(redirectTo);
4402
- }
4403
- function authMiddleware(config) {
4404
- const {
4405
- publicRoutes = ["/auth/login", "/auth/register", "/auth/verify-email", "/auth/forgot-password", "/auth/reset-password"],
4406
- protectedRoutes = ["/dashboard"],
4407
- loginUrl = "/auth/login",
4408
- afterLoginUrl = "/dashboard",
4409
- tokenCookieName = "auth_token"
4410
- } = config || {};
4411
- return function middleware(request) {
4412
- const { pathname } = request.nextUrl;
4413
- const token = request.cookies.get(tokenCookieName)?.value;
4414
- const isAuthenticated = !!token;
4415
- const isPublicRoute = publicRoutes.some((route) => {
4416
- if (route.endsWith("*")) {
4417
- return pathname.startsWith(route.slice(0, -1));
4418
- }
4419
- return pathname === route || pathname.startsWith(route + "/");
4420
- });
4421
- const isProtectedRoute = protectedRoutes.some((route) => {
4422
- if (route.endsWith("*")) {
4423
- return pathname.startsWith(route.slice(0, -1));
4424
- }
4425
- return pathname === route || pathname.startsWith(route + "/");
4426
- });
4427
- if (isAuthenticated && isPublicRoute) {
4428
- return server.NextResponse.redirect(new URL(afterLoginUrl, request.url));
4429
- }
4430
- if (!isAuthenticated && isProtectedRoute) {
4431
- const loginUrlWithRedirect = new URL(loginUrl, request.url);
4432
- loginUrlWithRedirect.searchParams.set("redirect", pathname);
4433
- return server.NextResponse.redirect(loginUrlWithRedirect);
4434
- }
4435
- return server.NextResponse.next();
4436
- };
4437
- }
4438
- function createAuthMiddleware(config) {
4439
- return authMiddleware(config);
4440
- }
4441
-
4442
4862
  exports.AuthFlow = AuthFlow;
4443
4863
  exports.AuthProvider = AuthProvider;
4444
- exports.AuthServer = AuthServer;
4445
4864
  exports.AuthService = AuthService;
4865
+ exports.AuthThemeProvider = AuthThemeProvider;
4446
4866
  exports.ChangePassword = ChangePassword;
4447
4867
  exports.EmailVerificationPage = EmailVerificationPage;
4448
4868
  exports.ForgotPassword = ForgotPassword;
4449
4869
  exports.HttpClient = HttpClient;
4450
4870
  exports.LoginForm = LoginForm;
4451
- exports.NextServerAuth = NextServerAuth;
4452
4871
  exports.OtpForm = OtpForm;
4872
+ exports.PhoneInput = PhoneInput;
4453
4873
  exports.ProtectedRoute = ProtectedRoute;
4454
4874
  exports.PublicRoute = PublicRoute;
4455
4875
  exports.RegisterForm = RegisterForm;
@@ -4460,15 +4880,9 @@ exports.SignUp = SignUp;
4460
4880
  exports.UserButton = UserButton;
4461
4881
  exports.UserProfile = UserProfile;
4462
4882
  exports.VerifyEmail = VerifyEmail;
4463
- exports.auth = auth;
4464
- exports.authMiddleware = authMiddleware;
4465
- exports.createAuthMiddleware = createAuthMiddleware;
4466
- exports.currentUser = currentUser;
4467
- exports.getAuthServer = getAuthServer;
4468
- exports.redirectIfAuthenticated = redirectIfAuthenticated;
4469
- exports.requireAuth = requireAuth;
4470
4883
  exports.useAuth = useAuth2;
4471
4884
  exports.useAuthLegacy = useAuth;
4885
+ exports.useAuthTheme = useAuthTheme;
4472
4886
  exports.useNextAuth = useNextAuth;
4473
4887
  //# sourceMappingURL=out.js.map
4474
4888
  //# sourceMappingURL=index.next.js.map