@thetechfossil/auth2 1.2.20 → 1.2.22

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.
@@ -5,12 +5,16 @@ import { io } from 'socket.io-client';
5
5
  import { ImageManager, UpfilesClient } from '@thetechfossil/upfiles';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
 
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
8
+ var ERROR_MESSAGES = {
9
+ NETWORK_ERROR: "Unable to connect to the server. Please check your internet connection and try again.",
10
+ TIMEOUT: "The request took too long. Please try again.",
11
+ SERVER_ERROR: "Something went wrong on our end. Please try again later.",
12
+ UNAUTHORIZED: "Your session has expired. Please log in again.",
13
+ FORBIDDEN: "You do not have permission to perform this action.",
14
+ NOT_FOUND: "The requested resource was not found.",
15
+ RATE_LIMITED: "Too many requests. Please wait a moment and try again.",
16
+ UNKNOWN: "An unexpected error occurred. Please try again."
17
+ };
14
18
  var HttpClient = class {
15
19
  constructor(baseUrl, defaultHeaders = {}) {
16
20
  this.csrfToken = null;
@@ -45,7 +49,7 @@ var HttpClient = class {
45
49
  }
46
50
  return config;
47
51
  },
48
- (error) => Promise.reject(error)
52
+ (error) => Promise.reject(this.createUserFriendlyError(error))
49
53
  );
50
54
  this.axiosInstance.interceptors.response.use(
51
55
  (response) => response,
@@ -60,18 +64,71 @@ var HttpClient = class {
60
64
  }
61
65
  return this.axiosInstance(originalRequest);
62
66
  } catch (refreshError) {
63
- return Promise.reject(refreshError);
67
+ return Promise.reject(this.createUserFriendlyError(refreshError));
64
68
  }
65
69
  }
66
- if (error.response && error.response.data && error.response.data.message) {
67
- const customError = new Error(error.response.data.message);
68
- customError.response = error.response;
69
- return Promise.reject(customError);
70
- }
71
- return Promise.reject(error);
70
+ return Promise.reject(this.createUserFriendlyError(error));
72
71
  }
73
72
  );
74
73
  }
74
+ /**
75
+ * Creates a user-friendly error message from an Axios error
76
+ */
77
+ createUserFriendlyError(error) {
78
+ if (error instanceof Error && !error.isAxiosError) {
79
+ return error;
80
+ }
81
+ let message;
82
+ let statusCode;
83
+ if (axios.isAxiosError(error)) {
84
+ statusCode = error.response?.status;
85
+ const responseData = error.response?.data;
86
+ if (responseData?.message) {
87
+ message = responseData.message;
88
+ } else if (!error.response) {
89
+ if (error.code === "ECONNABORTED" || error.message.includes("timeout")) {
90
+ message = ERROR_MESSAGES.TIMEOUT;
91
+ } else if (error.code === "ERR_NETWORK" || error.message === "Network Error") {
92
+ message = ERROR_MESSAGES.NETWORK_ERROR;
93
+ } else {
94
+ message = ERROR_MESSAGES.NETWORK_ERROR;
95
+ }
96
+ } else {
97
+ switch (statusCode) {
98
+ case 400:
99
+ message = responseData?.message || "Invalid request. Please check your input.";
100
+ break;
101
+ case 401:
102
+ message = responseData?.message || ERROR_MESSAGES.UNAUTHORIZED;
103
+ break;
104
+ case 403:
105
+ message = responseData?.message || ERROR_MESSAGES.FORBIDDEN;
106
+ break;
107
+ case 404:
108
+ message = responseData?.message || ERROR_MESSAGES.NOT_FOUND;
109
+ break;
110
+ case 429:
111
+ message = ERROR_MESSAGES.RATE_LIMITED;
112
+ break;
113
+ case 500:
114
+ case 502:
115
+ case 503:
116
+ case 504:
117
+ message = ERROR_MESSAGES.SERVER_ERROR;
118
+ break;
119
+ default:
120
+ message = responseData?.message || ERROR_MESSAGES.UNKNOWN;
121
+ }
122
+ }
123
+ } else {
124
+ message = error?.message || ERROR_MESSAGES.UNKNOWN;
125
+ }
126
+ const customError = new Error(message);
127
+ customError.response = error?.response;
128
+ customError.statusCode = statusCode;
129
+ customError.originalError = error;
130
+ return customError;
131
+ }
75
132
  async get(endpoint, headers) {
76
133
  const response = await this.axiosInstance.get(endpoint, { headers });
77
134
  return response.data;
@@ -277,6 +334,7 @@ var AuthService = class {
277
334
  if (token) {
278
335
  this.token = token;
279
336
  this.httpClient.setAuthToken(token);
337
+ this.setTokenCookie(token);
280
338
  }
281
339
  } catch (error) {
282
340
  console.warn("Failed to load token from storage:", error);
@@ -287,15 +345,28 @@ var AuthService = class {
287
345
  if (typeof window !== "undefined" && this.config.localStorageKey) {
288
346
  try {
289
347
  localStorage.setItem(this.config.localStorageKey, token);
348
+ this.setTokenCookie(token);
290
349
  } catch (error) {
291
350
  console.warn("Failed to save token to storage:", error);
292
351
  }
293
352
  }
294
353
  }
354
+ setTokenCookie(token) {
355
+ if (typeof window !== "undefined") {
356
+ const maxAge = 7 * 24 * 60 * 60;
357
+ document.cookie = `auth_token=${token}; path=/; max-age=${maxAge}; SameSite=Lax`;
358
+ }
359
+ }
360
+ removeTokenCookie() {
361
+ if (typeof window !== "undefined") {
362
+ document.cookie = "auth_token=; path=/; max-age=0; SameSite=Lax";
363
+ }
364
+ }
295
365
  removeTokenFromStorage() {
296
366
  if (typeof window !== "undefined" && this.config.localStorageKey) {
297
367
  try {
298
368
  localStorage.removeItem(this.config.localStorageKey);
369
+ this.removeTokenCookie();
299
370
  } catch (error) {
300
371
  console.warn("Failed to remove token from storage:", error);
301
372
  }
@@ -895,14 +966,6 @@ function useThemeColors() {
895
966
  const { theme } = useAuthTheme();
896
967
  return theme === "dark" ? darkTheme : lightTheme;
897
968
  }
898
- var PhoneInputWithCountry = null;
899
- try {
900
- const module = __require("react-phone-number-input");
901
- PhoneInputWithCountry = module.default || module;
902
- __require("react-phone-number-input/style.css");
903
- } catch (error) {
904
- console.warn("react-phone-number-input not available, using fallback");
905
- }
906
969
  var CustomPhoneInput = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
907
970
  "input",
908
971
  {
@@ -923,6 +986,8 @@ var PhoneInput = ({
923
986
  }) => {
924
987
  const colors = useThemeColors();
925
988
  const [defaultCountry, setDefaultCountry] = useState("US");
989
+ const [PhoneInputComponent, setPhoneInputComponent] = useState(null);
990
+ const [isLoading, setIsLoading] = useState(true);
926
991
  const styleContent = useMemo(() => `
927
992
  .PhoneInput {
928
993
  display: flex;
@@ -1035,6 +1100,29 @@ var PhoneInput = ({
1035
1100
  opacity: 0.6;
1036
1101
  }
1037
1102
  `, [colors]);
1103
+ useEffect(() => {
1104
+ let mounted = true;
1105
+ const loadPhoneInput = async () => {
1106
+ try {
1107
+ const module = await import('react-phone-number-input');
1108
+ if (mounted) {
1109
+ setPhoneInputComponent(() => module.default);
1110
+ }
1111
+ } catch (error) {
1112
+ if (mounted) {
1113
+ setPhoneInputComponent(null);
1114
+ }
1115
+ } finally {
1116
+ if (mounted) {
1117
+ setIsLoading(false);
1118
+ }
1119
+ }
1120
+ };
1121
+ loadPhoneInput();
1122
+ return () => {
1123
+ mounted = false;
1124
+ };
1125
+ }, []);
1038
1126
  useEffect(() => {
1039
1127
  const detectCountry = async () => {
1040
1128
  try {
@@ -1087,7 +1175,6 @@ var PhoneInput = ({
1087
1175
  }
1088
1176
  }
1089
1177
  } catch (error) {
1090
- console.log("Country detection failed, using default US");
1091
1178
  }
1092
1179
  };
1093
1180
  detectCountry();
@@ -1095,7 +1182,31 @@ var PhoneInput = ({
1095
1182
  const handleChange = useMemo(() => (val) => {
1096
1183
  onChange(val || "");
1097
1184
  }, [onChange]);
1098
- if (!PhoneInputWithCountry) {
1185
+ if (isLoading) {
1186
+ return /* @__PURE__ */ jsx(
1187
+ "input",
1188
+ {
1189
+ id,
1190
+ type: "tel",
1191
+ value,
1192
+ onChange: (e) => onChange(e.target.value),
1193
+ disabled,
1194
+ required,
1195
+ placeholder,
1196
+ style: {
1197
+ width: "100%",
1198
+ padding: "12px 16px",
1199
+ border: `1px solid ${colors.borderSecondary}`,
1200
+ borderRadius: "8px",
1201
+ fontSize: "16px",
1202
+ backgroundColor: colors.bgSecondary,
1203
+ color: colors.textPrimary,
1204
+ ...style
1205
+ }
1206
+ }
1207
+ );
1208
+ }
1209
+ if (!PhoneInputComponent) {
1099
1210
  return /* @__PURE__ */ jsx(
1100
1211
  "input",
1101
1212
  {
@@ -1129,7 +1240,7 @@ var PhoneInput = ({
1129
1240
  children: [
1130
1241
  /* @__PURE__ */ jsx("style", { children: styleContent }),
1131
1242
  /* @__PURE__ */ jsx(
1132
- PhoneInputWithCountry,
1243
+ PhoneInputComponent,
1133
1244
  {
1134
1245
  id,
1135
1246
  international: true,
@@ -1627,6 +1738,28 @@ var RegisterForm = ({
1627
1738
  const [error, setError] = useState(null);
1628
1739
  const [showPassword, setShowPassword] = useState(false);
1629
1740
  const [showConfirmPassword, setShowConfirmPassword] = useState(false);
1741
+ const [invitationDetails, setInvitationDetails] = useState(null);
1742
+ const [isLoadingInvitation, setIsLoadingInvitation] = useState(false);
1743
+ const config = authConfig || {
1744
+ baseUrl: "http://localhost:7000"
1745
+ };
1746
+ useEffect(() => {
1747
+ if (invitationToken) {
1748
+ setIsLoadingInvitation(true);
1749
+ fetch(`${config.baseUrl}/api/v1/auth/verify-invitation/${invitationToken}`).then((res) => res.json()).then((data) => {
1750
+ setInvitationDetails(data);
1751
+ if (data.valid && data.email) {
1752
+ setEmail(data.email);
1753
+ }
1754
+ }).catch((err) => {
1755
+ console.error("Failed to verify invitation:", err);
1756
+ setError("Failed to verify invitation. Please try again.");
1757
+ }).finally(() => {
1758
+ setIsLoadingInvitation(false);
1759
+ });
1760
+ }
1761
+ }, [invitationToken, config.baseUrl]);
1762
+ const isEmailDisabled = isLoading || invitationDetails?.valid && !!invitationDetails?.email;
1630
1763
  const getPasswordStrength = (pwd) => {
1631
1764
  if (!pwd) return { strength: "weak", score: 0, label: "" };
1632
1765
  let score = 0;
@@ -1640,9 +1773,6 @@ var RegisterForm = ({
1640
1773
  return { strength: "strong", score, label: "Strong" };
1641
1774
  };
1642
1775
  getPasswordStrength(password);
1643
- const config = authConfig || {
1644
- baseUrl: "http://localhost:7000"
1645
- };
1646
1776
  const { register } = useAuth(config);
1647
1777
  const handleSubmit = async (e) => {
1648
1778
  e.preventDefault();
@@ -1677,6 +1807,25 @@ var RegisterForm = ({
1677
1807
  if (response.ok && data.success) {
1678
1808
  if (typeof window !== "undefined" && data.token) {
1679
1809
  localStorage.setItem("auth_token", data.token);
1810
+ if (data.invitation?.organizationId && data.invitation?.role) {
1811
+ localStorage.setItem("currentOrganizationId", data.invitation.organizationId);
1812
+ const backendUrl = typeof window !== "undefined" ? process.env.NEXT_PUBLIC_INVENTORY_API_URL || process.env.NEXT_PUBLIC_BIZFLOW_API_URL || "http://localhost:5002" : "http://localhost:5002";
1813
+ try {
1814
+ await fetch(`${backendUrl}/api/auth/sync-with-role`, {
1815
+ method: "POST",
1816
+ headers: {
1817
+ "Content-Type": "application/json",
1818
+ "Authorization": `Bearer ${data.token}`
1819
+ },
1820
+ body: JSON.stringify({
1821
+ organizationId: data.invitation.organizationId,
1822
+ roleName: data.invitation.role
1823
+ })
1824
+ });
1825
+ } catch (syncError) {
1826
+ console.error("Failed to sync user role with backend:", syncError);
1827
+ }
1828
+ }
1680
1829
  }
1681
1830
  onRegisterSuccess?.();
1682
1831
  } else {
@@ -1784,7 +1933,7 @@ var RegisterForm = ({
1784
1933
  value: email,
1785
1934
  onChange: (e) => setEmail(e.target.value),
1786
1935
  required: !phoneNumber,
1787
- disabled: isLoading,
1936
+ disabled: isEmailDisabled,
1788
1937
  style: {
1789
1938
  width: "100%",
1790
1939
  padding: "12px 16px",
@@ -1792,9 +1941,11 @@ var RegisterForm = ({
1792
1941
  borderRadius: "8px",
1793
1942
  fontSize: "16px",
1794
1943
  boxSizing: "border-box",
1795
- color: colors.textPrimary,
1944
+ color: isEmailDisabled ? colors.textSecondary : colors.textPrimary,
1796
1945
  transition: "all 0.2s ease",
1797
- backgroundColor: colors.bgSecondary
1946
+ backgroundColor: isEmailDisabled ? colors.bgHover : colors.bgSecondary,
1947
+ cursor: isEmailDisabled ? "not-allowed" : "text",
1948
+ opacity: isEmailDisabled ? 0.7 : 1
1798
1949
  },
1799
1950
  placeholder: "Enter your email"
1800
1951
  }
@@ -2497,7 +2648,7 @@ var EmailVerificationPage = ({
2497
2648
  } })
2498
2649
  ] }) });
2499
2650
  }
2500
- return /* @__PURE__ */ jsx("div", { style: {
2651
+ return /* @__PURE__ */ jsxs("div", { style: {
2501
2652
  maxWidth: "500px",
2502
2653
  margin: "0 auto",
2503
2654
  padding: "30px",
@@ -2506,44 +2657,86 @@ var EmailVerificationPage = ({
2506
2657
  backgroundColor: "#ffffff",
2507
2658
  textAlign: "center",
2508
2659
  border: "1px solid #eaeaea"
2509
- }, children: /* @__PURE__ */ jsxs("div", { style: {
2510
- padding: "20px"
2511
2660
  }, children: [
2512
- /* @__PURE__ */ jsx("h2", { style: { color: "black" }, children: "Email Verification" }),
2513
- /* @__PURE__ */ jsx("div", { style: {
2514
- padding: "16px 20px",
2515
- margin: "24px 0",
2516
- borderRadius: "8px",
2517
- fontSize: "15px",
2518
- fontWeight: 500,
2519
- backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2520
- color: isSuccess ? "#155724" : "#721c24",
2521
- border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2522
- }, children: message }),
2523
- isSuccess && /* @__PURE__ */ jsxs("div", { style: {
2524
- marginTop: "24px"
2661
+ /* @__PURE__ */ jsxs("div", { style: {
2662
+ padding: "20px"
2525
2663
  }, children: [
2526
- /* @__PURE__ */ jsx("p", { style: { color: "black" }, children: "Your email has been successfully verified!" }),
2527
- /* @__PURE__ */ jsx(
2528
- "button",
2529
- {
2530
- onClick: () => window.location.href = "/login",
2531
- style: {
2532
- padding: "12px 24px",
2533
- backgroundColor: "#007bff",
2534
- color: "white",
2535
- border: "none",
2536
- borderRadius: "8px",
2537
- fontSize: "16px",
2538
- fontWeight: 600,
2539
- cursor: "pointer",
2540
- transition: "all 0.2s ease"
2541
- },
2542
- children: "Go to Login"
2664
+ /* @__PURE__ */ jsx("h2", { style: { color: "black" }, children: isSuccess ? "\u2713 Email Verified!" : "\u2717 Verification Failed" }),
2665
+ /* @__PURE__ */ jsx("div", { style: {
2666
+ padding: "16px 20px",
2667
+ margin: "24px 0",
2668
+ borderRadius: "8px",
2669
+ fontSize: "15px",
2670
+ fontWeight: 500,
2671
+ backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2672
+ color: isSuccess ? "#155724" : "#721c24",
2673
+ border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2674
+ }, children: message }),
2675
+ isSuccess ? /* @__PURE__ */ jsxs("div", { style: { marginTop: "24px" }, children: [
2676
+ /* @__PURE__ */ jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "Redirecting to login..." }),
2677
+ /* @__PURE__ */ jsx("div", { style: {
2678
+ border: "3px solid #d4edda",
2679
+ borderTop: "3px solid #28a745",
2680
+ borderRadius: "50%",
2681
+ width: "30px",
2682
+ height: "30px",
2683
+ animation: "spin 1s linear infinite",
2684
+ margin: "0 auto"
2685
+ } })
2686
+ ] }) : /* @__PURE__ */ jsxs("div", { style: { marginTop: "24px" }, children: [
2687
+ /* @__PURE__ */ jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "The verification link may have expired or already been used." }),
2688
+ /* @__PURE__ */ jsx(
2689
+ "button",
2690
+ {
2691
+ onClick: () => {
2692
+ const registerPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_TO_REGISTER || "/auth/register";
2693
+ window.location.href = registerPath;
2694
+ },
2695
+ style: {
2696
+ padding: "12px 24px",
2697
+ backgroundColor: "#007bff",
2698
+ color: "white",
2699
+ border: "none",
2700
+ borderRadius: "8px",
2701
+ fontSize: "16px",
2702
+ fontWeight: 600,
2703
+ cursor: "pointer",
2704
+ transition: "all 0.2s ease",
2705
+ marginRight: "12px"
2706
+ },
2707
+ children: "Register Again"
2708
+ }
2709
+ ),
2710
+ /* @__PURE__ */ jsx(
2711
+ "button",
2712
+ {
2713
+ onClick: () => {
2714
+ const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
2715
+ window.location.href = loginPath;
2716
+ },
2717
+ style: {
2718
+ padding: "12px 24px",
2719
+ backgroundColor: "#6c757d",
2720
+ color: "white",
2721
+ border: "none",
2722
+ borderRadius: "8px",
2723
+ fontSize: "16px",
2724
+ fontWeight: 600,
2725
+ cursor: "pointer",
2726
+ transition: "all 0.2s ease"
2727
+ },
2728
+ children: "Go to Login"
2729
+ }
2730
+ )
2731
+ ] })
2732
+ ] }),
2733
+ /* @__PURE__ */ jsx("style", { children: `
2734
+ @keyframes spin {
2735
+ 0% { transform: rotate(0deg); }
2736
+ 100% { transform: rotate(360deg); }
2543
2737
  }
2544
- )
2545
- ] })
2546
- ] }) });
2738
+ ` })
2739
+ ] });
2547
2740
  };
2548
2741
  var AuthContext = createContext(void 0);
2549
2742
  var useAuth2 = () => {
@@ -4762,6 +4955,274 @@ var UserProfile = ({
4762
4955
  ] })
4763
4956
  ] });
4764
4957
  };
4958
+ var SuperAdminSignIn = ({ redirectUrl, appearance }) => {
4959
+ const { signIn, isSignedIn, loading: authLoading, user } = useAuth2();
4960
+ const colors = useThemeColors();
4961
+ const [email, setEmail] = useState("");
4962
+ const [password, setPassword] = useState("");
4963
+ const [showPassword, setShowPassword] = useState(false);
4964
+ const [isLoading, setIsLoading] = useState(false);
4965
+ const [error, setError] = useState(null);
4966
+ const [success, setSuccess] = useState(null);
4967
+ useEffect(() => {
4968
+ if (isSignedIn && user) {
4969
+ const isSuperAdmin = user.role === "SUPER_ADMIN" || user.role === "SUPERADMIN";
4970
+ if (isSuperAdmin) {
4971
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
4972
+ const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
4973
+ window.location.href = `${baseUrl}${redirect}`;
4974
+ } else {
4975
+ setError("Access denied. Only Super Admin users can access this portal.");
4976
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4977
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4978
+ }
4979
+ }
4980
+ }, [isSignedIn, user, redirectUrl]);
4981
+ const handleSubmit = async (e) => {
4982
+ e.preventDefault();
4983
+ setIsLoading(true);
4984
+ setError(null);
4985
+ setSuccess(null);
4986
+ try {
4987
+ const response = await signIn({ email, password });
4988
+ if (response.success) {
4989
+ const userRole = response.user?.role;
4990
+ const isSuperAdmin = userRole === "SUPER_ADMIN" || userRole === "SUPERADMIN";
4991
+ if (!isSuperAdmin) {
4992
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4993
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4994
+ setError("Access denied. Only Super Admin users can access this portal.");
4995
+ return;
4996
+ }
4997
+ setSuccess("Login successful! Redirecting...");
4998
+ } else {
4999
+ setError(response.message || "Login failed. Please check your credentials.");
5000
+ }
5001
+ } catch (err) {
5002
+ setError(err instanceof Error ? err.message : "An error occurred during login.");
5003
+ } finally {
5004
+ setIsLoading(false);
5005
+ }
5006
+ };
5007
+ if (authLoading) {
5008
+ return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
5009
+ }
5010
+ return /* @__PURE__ */ jsx(
5011
+ ThemeWrapper,
5012
+ {
5013
+ style: {
5014
+ maxWidth: "400px",
5015
+ margin: "0 auto",
5016
+ padding: "30px",
5017
+ borderRadius: "12px",
5018
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
5019
+ backgroundColor: colors.bgPrimary,
5020
+ border: `1px solid ${colors.borderPrimary}`,
5021
+ ...appearance?.elements?.card
5022
+ },
5023
+ children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
5024
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: "24px" }, children: [
5025
+ /* @__PURE__ */ jsx("div", { style: {
5026
+ width: "60px",
5027
+ height: "60px",
5028
+ margin: "0 auto 16px",
5029
+ backgroundColor: colors.buttonPrimary + "20",
5030
+ borderRadius: "12px",
5031
+ display: "flex",
5032
+ alignItems: "center",
5033
+ justifyContent: "center"
5034
+ }, children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: colors.buttonPrimary, strokeWidth: "2", children: [
5035
+ /* @__PURE__ */ jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }),
5036
+ /* @__PURE__ */ jsx("path", { d: "M9 12l2 2 4-4" })
5037
+ ] }) }),
5038
+ /* @__PURE__ */ jsx("h2", { style: {
5039
+ color: colors.textPrimary,
5040
+ fontSize: "24px",
5041
+ fontWeight: 600,
5042
+ margin: 0,
5043
+ ...appearance?.elements?.headerTitle
5044
+ }, children: "Super Admin Portal" }),
5045
+ /* @__PURE__ */ jsx("p", { style: {
5046
+ color: colors.textSecondary,
5047
+ fontSize: "14px",
5048
+ marginTop: "8px"
5049
+ }, children: "Sign in with your administrator credentials" })
5050
+ ] }),
5051
+ error && /* @__PURE__ */ jsx("div", { style: {
5052
+ padding: "12px 16px",
5053
+ marginBottom: "20px",
5054
+ backgroundColor: colors.errorBg,
5055
+ color: colors.errorText,
5056
+ border: `1px solid ${colors.errorBorder}`,
5057
+ borderRadius: "8px",
5058
+ fontSize: "14px"
5059
+ }, children: error }),
5060
+ success && /* @__PURE__ */ jsx("div", { style: {
5061
+ padding: "12px 16px",
5062
+ marginBottom: "20px",
5063
+ backgroundColor: colors.successBg,
5064
+ color: colors.successText,
5065
+ border: `1px solid ${colors.successBorder}`,
5066
+ borderRadius: "8px",
5067
+ fontSize: "14px"
5068
+ }, children: success }),
5069
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
5070
+ /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
5071
+ display: "block",
5072
+ marginBottom: "8px",
5073
+ fontWeight: 500,
5074
+ color: colors.textSecondary,
5075
+ fontSize: "14px"
5076
+ }, children: "Email Address" }),
5077
+ /* @__PURE__ */ jsx(
5078
+ "input",
5079
+ {
5080
+ id: "email",
5081
+ type: "email",
5082
+ value: email,
5083
+ onChange: (e) => setEmail(e.target.value),
5084
+ onFocus: (e) => {
5085
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5086
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5087
+ },
5088
+ onBlur: (e) => {
5089
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5090
+ e.currentTarget.style.outline = "none";
5091
+ },
5092
+ required: true,
5093
+ disabled: isLoading,
5094
+ autoComplete: "email",
5095
+ style: {
5096
+ width: "100%",
5097
+ padding: "12px 16px",
5098
+ border: `1px solid ${colors.borderSecondary}`,
5099
+ borderRadius: "8px",
5100
+ fontSize: "16px",
5101
+ boxSizing: "border-box",
5102
+ backgroundColor: colors.bgSecondary,
5103
+ color: colors.textPrimary,
5104
+ transition: "all 0.2s ease",
5105
+ WebkitTextFillColor: colors.textPrimary,
5106
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5107
+ ...appearance?.elements?.formFieldInput
5108
+ },
5109
+ placeholder: "admin@example.com"
5110
+ }
5111
+ )
5112
+ ] }),
5113
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "24px", position: "relative" }, children: [
5114
+ /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
5115
+ display: "block",
5116
+ marginBottom: "8px",
5117
+ fontWeight: 500,
5118
+ color: colors.textSecondary,
5119
+ fontSize: "14px"
5120
+ }, children: "Password" }),
5121
+ /* @__PURE__ */ jsx(
5122
+ "input",
5123
+ {
5124
+ id: "password",
5125
+ type: showPassword ? "text" : "password",
5126
+ value: password,
5127
+ onChange: (e) => setPassword(e.target.value),
5128
+ onFocus: (e) => {
5129
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5130
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5131
+ },
5132
+ onBlur: (e) => {
5133
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5134
+ e.currentTarget.style.outline = "none";
5135
+ },
5136
+ required: true,
5137
+ disabled: isLoading,
5138
+ autoComplete: "current-password",
5139
+ style: {
5140
+ width: "100%",
5141
+ padding: "12px 16px",
5142
+ paddingRight: "60px",
5143
+ border: `1px solid ${colors.borderSecondary}`,
5144
+ borderRadius: "8px",
5145
+ fontSize: "16px",
5146
+ boxSizing: "border-box",
5147
+ backgroundColor: colors.bgSecondary,
5148
+ color: colors.textPrimary,
5149
+ transition: "all 0.2s ease",
5150
+ WebkitTextFillColor: colors.textPrimary,
5151
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5152
+ ...appearance?.elements?.formFieldInput
5153
+ },
5154
+ placeholder: "Enter your password"
5155
+ }
5156
+ ),
5157
+ /* @__PURE__ */ jsx(
5158
+ "button",
5159
+ {
5160
+ type: "button",
5161
+ onClick: () => setShowPassword(!showPassword),
5162
+ style: {
5163
+ position: "absolute",
5164
+ right: "12px",
5165
+ top: "38px",
5166
+ background: "none",
5167
+ border: "none",
5168
+ cursor: "pointer",
5169
+ color: colors.textTertiary,
5170
+ fontSize: "14px",
5171
+ padding: "4px 8px"
5172
+ },
5173
+ children: showPassword ? "Hide" : "Show"
5174
+ }
5175
+ )
5176
+ ] }),
5177
+ /* @__PURE__ */ jsx(
5178
+ "button",
5179
+ {
5180
+ type: "submit",
5181
+ disabled: isLoading || !email || !password,
5182
+ onMouseEnter: (e) => {
5183
+ if (!isLoading && email && password) {
5184
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
5185
+ }
5186
+ },
5187
+ onMouseLeave: (e) => {
5188
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
5189
+ },
5190
+ style: {
5191
+ width: "100%",
5192
+ padding: "14px",
5193
+ backgroundColor: colors.buttonPrimary,
5194
+ color: "white",
5195
+ border: "none",
5196
+ borderRadius: "8px",
5197
+ fontSize: "16px",
5198
+ fontWeight: 600,
5199
+ cursor: isLoading || !email || !password ? "not-allowed" : "pointer",
5200
+ opacity: isLoading || !email || !password ? 0.6 : 1,
5201
+ transition: "all 0.2s ease",
5202
+ ...appearance?.elements?.formButtonPrimary
5203
+ },
5204
+ children: isLoading ? "Signing in..." : "Sign In"
5205
+ }
5206
+ ),
5207
+ /* @__PURE__ */ jsx("div", { style: {
5208
+ marginTop: "20px",
5209
+ padding: "12px",
5210
+ backgroundColor: colors.bgSecondary,
5211
+ borderRadius: "8px",
5212
+ textAlign: "center"
5213
+ }, children: /* @__PURE__ */ jsxs("p", { style: {
5214
+ color: colors.textTertiary,
5215
+ fontSize: "12px",
5216
+ margin: 0
5217
+ }, children: [
5218
+ "\u{1F512} This portal is restricted to Super Admin users only.",
5219
+ /* @__PURE__ */ jsx("br", {}),
5220
+ "Contact your system administrator if you need access."
5221
+ ] }) })
5222
+ ] })
5223
+ }
5224
+ );
5225
+ };
4765
5226
  var AvatarManager = ({
4766
5227
  open,
4767
5228
  onOpenChange,
@@ -4844,6 +5305,6 @@ var AvatarManager = ({
4844
5305
  );
4845
5306
  };
4846
5307
 
4847
- export { AuthFlow, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
5308
+ export { AuthFlow, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, SuperAdminSignIn, UserButton, UserProfile, VerifyEmail };
4848
5309
  //# sourceMappingURL=index.components.mjs.map
4849
5310
  //# sourceMappingURL=index.components.mjs.map