@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.
@@ -12,12 +12,16 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
  var React__default = /*#__PURE__*/_interopDefault(React);
13
13
  var axios__default = /*#__PURE__*/_interopDefault(axios);
14
14
 
15
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
- }) : x)(function(x) {
18
- if (typeof require !== "undefined") return require.apply(this, arguments);
19
- throw Error('Dynamic require of "' + x + '" is not supported');
20
- });
15
+ var ERROR_MESSAGES = {
16
+ NETWORK_ERROR: "Unable to connect to the server. Please check your internet connection and try again.",
17
+ TIMEOUT: "The request took too long. Please try again.",
18
+ SERVER_ERROR: "Something went wrong on our end. Please try again later.",
19
+ UNAUTHORIZED: "Your session has expired. Please log in again.",
20
+ FORBIDDEN: "You do not have permission to perform this action.",
21
+ NOT_FOUND: "The requested resource was not found.",
22
+ RATE_LIMITED: "Too many requests. Please wait a moment and try again.",
23
+ UNKNOWN: "An unexpected error occurred. Please try again."
24
+ };
21
25
  var HttpClient = class {
22
26
  constructor(baseUrl, defaultHeaders = {}) {
23
27
  this.csrfToken = null;
@@ -52,7 +56,7 @@ var HttpClient = class {
52
56
  }
53
57
  return config;
54
58
  },
55
- (error) => Promise.reject(error)
59
+ (error) => Promise.reject(this.createUserFriendlyError(error))
56
60
  );
57
61
  this.axiosInstance.interceptors.response.use(
58
62
  (response) => response,
@@ -67,18 +71,71 @@ var HttpClient = class {
67
71
  }
68
72
  return this.axiosInstance(originalRequest);
69
73
  } catch (refreshError) {
70
- return Promise.reject(refreshError);
74
+ return Promise.reject(this.createUserFriendlyError(refreshError));
71
75
  }
72
76
  }
73
- if (error.response && error.response.data && error.response.data.message) {
74
- const customError = new Error(error.response.data.message);
75
- customError.response = error.response;
76
- return Promise.reject(customError);
77
- }
78
- return Promise.reject(error);
77
+ return Promise.reject(this.createUserFriendlyError(error));
79
78
  }
80
79
  );
81
80
  }
81
+ /**
82
+ * Creates a user-friendly error message from an Axios error
83
+ */
84
+ createUserFriendlyError(error) {
85
+ if (error instanceof Error && !error.isAxiosError) {
86
+ return error;
87
+ }
88
+ let message;
89
+ let statusCode;
90
+ if (axios__default.default.isAxiosError(error)) {
91
+ statusCode = error.response?.status;
92
+ const responseData = error.response?.data;
93
+ if (responseData?.message) {
94
+ message = responseData.message;
95
+ } else if (!error.response) {
96
+ if (error.code === "ECONNABORTED" || error.message.includes("timeout")) {
97
+ message = ERROR_MESSAGES.TIMEOUT;
98
+ } else if (error.code === "ERR_NETWORK" || error.message === "Network Error") {
99
+ message = ERROR_MESSAGES.NETWORK_ERROR;
100
+ } else {
101
+ message = ERROR_MESSAGES.NETWORK_ERROR;
102
+ }
103
+ } else {
104
+ switch (statusCode) {
105
+ case 400:
106
+ message = responseData?.message || "Invalid request. Please check your input.";
107
+ break;
108
+ case 401:
109
+ message = responseData?.message || ERROR_MESSAGES.UNAUTHORIZED;
110
+ break;
111
+ case 403:
112
+ message = responseData?.message || ERROR_MESSAGES.FORBIDDEN;
113
+ break;
114
+ case 404:
115
+ message = responseData?.message || ERROR_MESSAGES.NOT_FOUND;
116
+ break;
117
+ case 429:
118
+ message = ERROR_MESSAGES.RATE_LIMITED;
119
+ break;
120
+ case 500:
121
+ case 502:
122
+ case 503:
123
+ case 504:
124
+ message = ERROR_MESSAGES.SERVER_ERROR;
125
+ break;
126
+ default:
127
+ message = responseData?.message || ERROR_MESSAGES.UNKNOWN;
128
+ }
129
+ }
130
+ } else {
131
+ message = error?.message || ERROR_MESSAGES.UNKNOWN;
132
+ }
133
+ const customError = new Error(message);
134
+ customError.response = error?.response;
135
+ customError.statusCode = statusCode;
136
+ customError.originalError = error;
137
+ return customError;
138
+ }
82
139
  async get(endpoint, headers) {
83
140
  const response = await this.axiosInstance.get(endpoint, { headers });
84
141
  return response.data;
@@ -284,6 +341,7 @@ var AuthService = class {
284
341
  if (token) {
285
342
  this.token = token;
286
343
  this.httpClient.setAuthToken(token);
344
+ this.setTokenCookie(token);
287
345
  }
288
346
  } catch (error) {
289
347
  console.warn("Failed to load token from storage:", error);
@@ -294,15 +352,28 @@ var AuthService = class {
294
352
  if (typeof window !== "undefined" && this.config.localStorageKey) {
295
353
  try {
296
354
  localStorage.setItem(this.config.localStorageKey, token);
355
+ this.setTokenCookie(token);
297
356
  } catch (error) {
298
357
  console.warn("Failed to save token to storage:", error);
299
358
  }
300
359
  }
301
360
  }
361
+ setTokenCookie(token) {
362
+ if (typeof window !== "undefined") {
363
+ const maxAge = 7 * 24 * 60 * 60;
364
+ document.cookie = `auth_token=${token}; path=/; max-age=${maxAge}; SameSite=Lax`;
365
+ }
366
+ }
367
+ removeTokenCookie() {
368
+ if (typeof window !== "undefined") {
369
+ document.cookie = "auth_token=; path=/; max-age=0; SameSite=Lax";
370
+ }
371
+ }
302
372
  removeTokenFromStorage() {
303
373
  if (typeof window !== "undefined" && this.config.localStorageKey) {
304
374
  try {
305
375
  localStorage.removeItem(this.config.localStorageKey);
376
+ this.removeTokenCookie();
306
377
  } catch (error) {
307
378
  console.warn("Failed to remove token from storage:", error);
308
379
  }
@@ -902,14 +973,6 @@ function useThemeColors() {
902
973
  const { theme } = useAuthTheme();
903
974
  return theme === "dark" ? darkTheme : lightTheme;
904
975
  }
905
- var PhoneInputWithCountry = null;
906
- try {
907
- const module = __require("react-phone-number-input");
908
- PhoneInputWithCountry = module.default || module;
909
- __require("react-phone-number-input/style.css");
910
- } catch (error) {
911
- console.warn("react-phone-number-input not available, using fallback");
912
- }
913
976
  var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
914
977
  "input",
915
978
  {
@@ -930,6 +993,8 @@ var PhoneInput = ({
930
993
  }) => {
931
994
  const colors = useThemeColors();
932
995
  const [defaultCountry, setDefaultCountry] = React.useState("US");
996
+ const [PhoneInputComponent, setPhoneInputComponent] = React.useState(null);
997
+ const [isLoading, setIsLoading] = React.useState(true);
933
998
  const styleContent = React.useMemo(() => `
934
999
  .PhoneInput {
935
1000
  display: flex;
@@ -1042,6 +1107,29 @@ var PhoneInput = ({
1042
1107
  opacity: 0.6;
1043
1108
  }
1044
1109
  `, [colors]);
1110
+ React.useEffect(() => {
1111
+ let mounted = true;
1112
+ const loadPhoneInput = async () => {
1113
+ try {
1114
+ const module = await import('react-phone-number-input');
1115
+ if (mounted) {
1116
+ setPhoneInputComponent(() => module.default);
1117
+ }
1118
+ } catch (error) {
1119
+ if (mounted) {
1120
+ setPhoneInputComponent(null);
1121
+ }
1122
+ } finally {
1123
+ if (mounted) {
1124
+ setIsLoading(false);
1125
+ }
1126
+ }
1127
+ };
1128
+ loadPhoneInput();
1129
+ return () => {
1130
+ mounted = false;
1131
+ };
1132
+ }, []);
1045
1133
  React.useEffect(() => {
1046
1134
  const detectCountry = async () => {
1047
1135
  try {
@@ -1094,7 +1182,6 @@ var PhoneInput = ({
1094
1182
  }
1095
1183
  }
1096
1184
  } catch (error) {
1097
- console.log("Country detection failed, using default US");
1098
1185
  }
1099
1186
  };
1100
1187
  detectCountry();
@@ -1102,7 +1189,31 @@ var PhoneInput = ({
1102
1189
  const handleChange = React.useMemo(() => (val) => {
1103
1190
  onChange(val || "");
1104
1191
  }, [onChange]);
1105
- if (!PhoneInputWithCountry) {
1192
+ if (isLoading) {
1193
+ return /* @__PURE__ */ jsxRuntime.jsx(
1194
+ "input",
1195
+ {
1196
+ id,
1197
+ type: "tel",
1198
+ value,
1199
+ onChange: (e) => onChange(e.target.value),
1200
+ disabled,
1201
+ required,
1202
+ placeholder,
1203
+ style: {
1204
+ width: "100%",
1205
+ padding: "12px 16px",
1206
+ border: `1px solid ${colors.borderSecondary}`,
1207
+ borderRadius: "8px",
1208
+ fontSize: "16px",
1209
+ backgroundColor: colors.bgSecondary,
1210
+ color: colors.textPrimary,
1211
+ ...style
1212
+ }
1213
+ }
1214
+ );
1215
+ }
1216
+ if (!PhoneInputComponent) {
1106
1217
  return /* @__PURE__ */ jsxRuntime.jsx(
1107
1218
  "input",
1108
1219
  {
@@ -1136,7 +1247,7 @@ var PhoneInput = ({
1136
1247
  children: [
1137
1248
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
1138
1249
  /* @__PURE__ */ jsxRuntime.jsx(
1139
- PhoneInputWithCountry,
1250
+ PhoneInputComponent,
1140
1251
  {
1141
1252
  id,
1142
1253
  international: true,
@@ -1634,6 +1745,28 @@ var RegisterForm = ({
1634
1745
  const [error, setError] = React.useState(null);
1635
1746
  const [showPassword, setShowPassword] = React.useState(false);
1636
1747
  const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
1748
+ const [invitationDetails, setInvitationDetails] = React.useState(null);
1749
+ const [isLoadingInvitation, setIsLoadingInvitation] = React.useState(false);
1750
+ const config = authConfig || {
1751
+ baseUrl: "http://localhost:7000"
1752
+ };
1753
+ React.useEffect(() => {
1754
+ if (invitationToken) {
1755
+ setIsLoadingInvitation(true);
1756
+ fetch(`${config.baseUrl}/api/v1/auth/verify-invitation/${invitationToken}`).then((res) => res.json()).then((data) => {
1757
+ setInvitationDetails(data);
1758
+ if (data.valid && data.email) {
1759
+ setEmail(data.email);
1760
+ }
1761
+ }).catch((err) => {
1762
+ console.error("Failed to verify invitation:", err);
1763
+ setError("Failed to verify invitation. Please try again.");
1764
+ }).finally(() => {
1765
+ setIsLoadingInvitation(false);
1766
+ });
1767
+ }
1768
+ }, [invitationToken, config.baseUrl]);
1769
+ const isEmailDisabled = isLoading || invitationDetails?.valid && !!invitationDetails?.email;
1637
1770
  const getPasswordStrength = (pwd) => {
1638
1771
  if (!pwd) return { strength: "weak", score: 0, label: "" };
1639
1772
  let score = 0;
@@ -1647,9 +1780,6 @@ var RegisterForm = ({
1647
1780
  return { strength: "strong", score, label: "Strong" };
1648
1781
  };
1649
1782
  getPasswordStrength(password);
1650
- const config = authConfig || {
1651
- baseUrl: "http://localhost:7000"
1652
- };
1653
1783
  const { register } = useAuth(config);
1654
1784
  const handleSubmit = async (e) => {
1655
1785
  e.preventDefault();
@@ -1684,6 +1814,25 @@ var RegisterForm = ({
1684
1814
  if (response.ok && data.success) {
1685
1815
  if (typeof window !== "undefined" && data.token) {
1686
1816
  localStorage.setItem("auth_token", data.token);
1817
+ if (data.invitation?.organizationId && data.invitation?.role) {
1818
+ localStorage.setItem("currentOrganizationId", data.invitation.organizationId);
1819
+ 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";
1820
+ try {
1821
+ await fetch(`${backendUrl}/api/auth/sync-with-role`, {
1822
+ method: "POST",
1823
+ headers: {
1824
+ "Content-Type": "application/json",
1825
+ "Authorization": `Bearer ${data.token}`
1826
+ },
1827
+ body: JSON.stringify({
1828
+ organizationId: data.invitation.organizationId,
1829
+ roleName: data.invitation.role
1830
+ })
1831
+ });
1832
+ } catch (syncError) {
1833
+ console.error("Failed to sync user role with backend:", syncError);
1834
+ }
1835
+ }
1687
1836
  }
1688
1837
  onRegisterSuccess?.();
1689
1838
  } else {
@@ -1791,7 +1940,7 @@ var RegisterForm = ({
1791
1940
  value: email,
1792
1941
  onChange: (e) => setEmail(e.target.value),
1793
1942
  required: !phoneNumber,
1794
- disabled: isLoading,
1943
+ disabled: isEmailDisabled,
1795
1944
  style: {
1796
1945
  width: "100%",
1797
1946
  padding: "12px 16px",
@@ -1799,9 +1948,11 @@ var RegisterForm = ({
1799
1948
  borderRadius: "8px",
1800
1949
  fontSize: "16px",
1801
1950
  boxSizing: "border-box",
1802
- color: colors.textPrimary,
1951
+ color: isEmailDisabled ? colors.textSecondary : colors.textPrimary,
1803
1952
  transition: "all 0.2s ease",
1804
- backgroundColor: colors.bgSecondary
1953
+ backgroundColor: isEmailDisabled ? colors.bgHover : colors.bgSecondary,
1954
+ cursor: isEmailDisabled ? "not-allowed" : "text",
1955
+ opacity: isEmailDisabled ? 0.7 : 1
1805
1956
  },
1806
1957
  placeholder: "Enter your email"
1807
1958
  }
@@ -2504,7 +2655,7 @@ var EmailVerificationPage = ({
2504
2655
  } })
2505
2656
  ] }) });
2506
2657
  }
2507
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2658
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2508
2659
  maxWidth: "500px",
2509
2660
  margin: "0 auto",
2510
2661
  padding: "30px",
@@ -2513,44 +2664,86 @@ var EmailVerificationPage = ({
2513
2664
  backgroundColor: "#ffffff",
2514
2665
  textAlign: "center",
2515
2666
  border: "1px solid #eaeaea"
2516
- }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2517
- padding: "20px"
2518
2667
  }, children: [
2519
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "black" }, children: "Email Verification" }),
2520
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2521
- padding: "16px 20px",
2522
- margin: "24px 0",
2523
- borderRadius: "8px",
2524
- fontSize: "15px",
2525
- fontWeight: 500,
2526
- backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2527
- color: isSuccess ? "#155724" : "#721c24",
2528
- border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2529
- }, children: message }),
2530
- isSuccess && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2531
- marginTop: "24px"
2668
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2669
+ padding: "20px"
2532
2670
  }, children: [
2533
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "black" }, children: "Your email has been successfully verified!" }),
2534
- /* @__PURE__ */ jsxRuntime.jsx(
2535
- "button",
2536
- {
2537
- onClick: () => window.location.href = "/login",
2538
- style: {
2539
- padding: "12px 24px",
2540
- backgroundColor: "#007bff",
2541
- color: "white",
2542
- border: "none",
2543
- borderRadius: "8px",
2544
- fontSize: "16px",
2545
- fontWeight: 600,
2546
- cursor: "pointer",
2547
- transition: "all 0.2s ease"
2548
- },
2549
- children: "Go to Login"
2671
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "black" }, children: isSuccess ? "\u2713 Email Verified!" : "\u2717 Verification Failed" }),
2672
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2673
+ padding: "16px 20px",
2674
+ margin: "24px 0",
2675
+ borderRadius: "8px",
2676
+ fontSize: "15px",
2677
+ fontWeight: 500,
2678
+ backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2679
+ color: isSuccess ? "#155724" : "#721c24",
2680
+ border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2681
+ }, children: message }),
2682
+ isSuccess ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "24px" }, children: [
2683
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "Redirecting to login..." }),
2684
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2685
+ border: "3px solid #d4edda",
2686
+ borderTop: "3px solid #28a745",
2687
+ borderRadius: "50%",
2688
+ width: "30px",
2689
+ height: "30px",
2690
+ animation: "spin 1s linear infinite",
2691
+ margin: "0 auto"
2692
+ } })
2693
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "24px" }, children: [
2694
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "The verification link may have expired or already been used." }),
2695
+ /* @__PURE__ */ jsxRuntime.jsx(
2696
+ "button",
2697
+ {
2698
+ onClick: () => {
2699
+ const registerPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_TO_REGISTER || "/auth/register";
2700
+ window.location.href = registerPath;
2701
+ },
2702
+ style: {
2703
+ padding: "12px 24px",
2704
+ backgroundColor: "#007bff",
2705
+ color: "white",
2706
+ border: "none",
2707
+ borderRadius: "8px",
2708
+ fontSize: "16px",
2709
+ fontWeight: 600,
2710
+ cursor: "pointer",
2711
+ transition: "all 0.2s ease",
2712
+ marginRight: "12px"
2713
+ },
2714
+ children: "Register Again"
2715
+ }
2716
+ ),
2717
+ /* @__PURE__ */ jsxRuntime.jsx(
2718
+ "button",
2719
+ {
2720
+ onClick: () => {
2721
+ const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
2722
+ window.location.href = loginPath;
2723
+ },
2724
+ style: {
2725
+ padding: "12px 24px",
2726
+ backgroundColor: "#6c757d",
2727
+ color: "white",
2728
+ border: "none",
2729
+ borderRadius: "8px",
2730
+ fontSize: "16px",
2731
+ fontWeight: 600,
2732
+ cursor: "pointer",
2733
+ transition: "all 0.2s ease"
2734
+ },
2735
+ children: "Go to Login"
2736
+ }
2737
+ )
2738
+ ] })
2739
+ ] }),
2740
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
2741
+ @keyframes spin {
2742
+ 0% { transform: rotate(0deg); }
2743
+ 100% { transform: rotate(360deg); }
2550
2744
  }
2551
- )
2552
- ] })
2553
- ] }) });
2745
+ ` })
2746
+ ] });
2554
2747
  };
2555
2748
  var AuthContext = React.createContext(void 0);
2556
2749
  var useAuth2 = () => {
@@ -4769,6 +4962,274 @@ var UserProfile = ({
4769
4962
  ] })
4770
4963
  ] });
4771
4964
  };
4965
+ var SuperAdminSignIn = ({ redirectUrl, appearance }) => {
4966
+ const { signIn, isSignedIn, loading: authLoading, user } = useAuth2();
4967
+ const colors = useThemeColors();
4968
+ const [email, setEmail] = React.useState("");
4969
+ const [password, setPassword] = React.useState("");
4970
+ const [showPassword, setShowPassword] = React.useState(false);
4971
+ const [isLoading, setIsLoading] = React.useState(false);
4972
+ const [error, setError] = React.useState(null);
4973
+ const [success, setSuccess] = React.useState(null);
4974
+ React.useEffect(() => {
4975
+ if (isSignedIn && user) {
4976
+ const isSuperAdmin = user.role === "SUPER_ADMIN" || user.role === "SUPERADMIN";
4977
+ if (isSuperAdmin) {
4978
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
4979
+ const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
4980
+ window.location.href = `${baseUrl}${redirect}`;
4981
+ } else {
4982
+ setError("Access denied. Only Super Admin users can access this portal.");
4983
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4984
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
4985
+ }
4986
+ }
4987
+ }, [isSignedIn, user, redirectUrl]);
4988
+ const handleSubmit = async (e) => {
4989
+ e.preventDefault();
4990
+ setIsLoading(true);
4991
+ setError(null);
4992
+ setSuccess(null);
4993
+ try {
4994
+ const response = await signIn({ email, password });
4995
+ if (response.success) {
4996
+ const userRole = response.user?.role;
4997
+ const isSuperAdmin = userRole === "SUPER_ADMIN" || userRole === "SUPERADMIN";
4998
+ if (!isSuperAdmin) {
4999
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5000
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5001
+ setError("Access denied. Only Super Admin users can access this portal.");
5002
+ return;
5003
+ }
5004
+ setSuccess("Login successful! Redirecting...");
5005
+ } else {
5006
+ setError(response.message || "Login failed. Please check your credentials.");
5007
+ }
5008
+ } catch (err) {
5009
+ setError(err instanceof Error ? err.message : "An error occurred during login.");
5010
+ } finally {
5011
+ setIsLoading(false);
5012
+ }
5013
+ };
5014
+ if (authLoading) {
5015
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
5016
+ }
5017
+ return /* @__PURE__ */ jsxRuntime.jsx(
5018
+ ThemeWrapper,
5019
+ {
5020
+ style: {
5021
+ maxWidth: "400px",
5022
+ margin: "0 auto",
5023
+ padding: "30px",
5024
+ borderRadius: "12px",
5025
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
5026
+ backgroundColor: colors.bgPrimary,
5027
+ border: `1px solid ${colors.borderPrimary}`,
5028
+ ...appearance?.elements?.card
5029
+ },
5030
+ children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
5031
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginBottom: "24px" }, children: [
5032
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5033
+ width: "60px",
5034
+ height: "60px",
5035
+ margin: "0 auto 16px",
5036
+ backgroundColor: colors.buttonPrimary + "20",
5037
+ borderRadius: "12px",
5038
+ display: "flex",
5039
+ alignItems: "center",
5040
+ justifyContent: "center"
5041
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: colors.buttonPrimary, strokeWidth: "2", children: [
5042
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }),
5043
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 12l2 2 4-4" })
5044
+ ] }) }),
5045
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
5046
+ color: colors.textPrimary,
5047
+ fontSize: "24px",
5048
+ fontWeight: 600,
5049
+ margin: 0,
5050
+ ...appearance?.elements?.headerTitle
5051
+ }, children: "Super Admin Portal" }),
5052
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: {
5053
+ color: colors.textSecondary,
5054
+ fontSize: "14px",
5055
+ marginTop: "8px"
5056
+ }, children: "Sign in with your administrator credentials" })
5057
+ ] }),
5058
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5059
+ padding: "12px 16px",
5060
+ marginBottom: "20px",
5061
+ backgroundColor: colors.errorBg,
5062
+ color: colors.errorText,
5063
+ border: `1px solid ${colors.errorBorder}`,
5064
+ borderRadius: "8px",
5065
+ fontSize: "14px"
5066
+ }, children: error }),
5067
+ success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5068
+ padding: "12px 16px",
5069
+ marginBottom: "20px",
5070
+ backgroundColor: colors.successBg,
5071
+ color: colors.successText,
5072
+ border: `1px solid ${colors.successBorder}`,
5073
+ borderRadius: "8px",
5074
+ fontSize: "14px"
5075
+ }, children: success }),
5076
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
5077
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
5078
+ display: "block",
5079
+ marginBottom: "8px",
5080
+ fontWeight: 500,
5081
+ color: colors.textSecondary,
5082
+ fontSize: "14px"
5083
+ }, children: "Email Address" }),
5084
+ /* @__PURE__ */ jsxRuntime.jsx(
5085
+ "input",
5086
+ {
5087
+ id: "email",
5088
+ type: "email",
5089
+ value: email,
5090
+ onChange: (e) => setEmail(e.target.value),
5091
+ onFocus: (e) => {
5092
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5093
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5094
+ },
5095
+ onBlur: (e) => {
5096
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5097
+ e.currentTarget.style.outline = "none";
5098
+ },
5099
+ required: true,
5100
+ disabled: isLoading,
5101
+ autoComplete: "email",
5102
+ style: {
5103
+ width: "100%",
5104
+ padding: "12px 16px",
5105
+ border: `1px solid ${colors.borderSecondary}`,
5106
+ borderRadius: "8px",
5107
+ fontSize: "16px",
5108
+ boxSizing: "border-box",
5109
+ backgroundColor: colors.bgSecondary,
5110
+ color: colors.textPrimary,
5111
+ transition: "all 0.2s ease",
5112
+ WebkitTextFillColor: colors.textPrimary,
5113
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5114
+ ...appearance?.elements?.formFieldInput
5115
+ },
5116
+ placeholder: "admin@example.com"
5117
+ }
5118
+ )
5119
+ ] }),
5120
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "24px", position: "relative" }, children: [
5121
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
5122
+ display: "block",
5123
+ marginBottom: "8px",
5124
+ fontWeight: 500,
5125
+ color: colors.textSecondary,
5126
+ fontSize: "14px"
5127
+ }, children: "Password" }),
5128
+ /* @__PURE__ */ jsxRuntime.jsx(
5129
+ "input",
5130
+ {
5131
+ id: "password",
5132
+ type: showPassword ? "text" : "password",
5133
+ value: password,
5134
+ onChange: (e) => setPassword(e.target.value),
5135
+ onFocus: (e) => {
5136
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5137
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5138
+ },
5139
+ onBlur: (e) => {
5140
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5141
+ e.currentTarget.style.outline = "none";
5142
+ },
5143
+ required: true,
5144
+ disabled: isLoading,
5145
+ autoComplete: "current-password",
5146
+ style: {
5147
+ width: "100%",
5148
+ padding: "12px 16px",
5149
+ paddingRight: "60px",
5150
+ border: `1px solid ${colors.borderSecondary}`,
5151
+ borderRadius: "8px",
5152
+ fontSize: "16px",
5153
+ boxSizing: "border-box",
5154
+ backgroundColor: colors.bgSecondary,
5155
+ color: colors.textPrimary,
5156
+ transition: "all 0.2s ease",
5157
+ WebkitTextFillColor: colors.textPrimary,
5158
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5159
+ ...appearance?.elements?.formFieldInput
5160
+ },
5161
+ placeholder: "Enter your password"
5162
+ }
5163
+ ),
5164
+ /* @__PURE__ */ jsxRuntime.jsx(
5165
+ "button",
5166
+ {
5167
+ type: "button",
5168
+ onClick: () => setShowPassword(!showPassword),
5169
+ style: {
5170
+ position: "absolute",
5171
+ right: "12px",
5172
+ top: "38px",
5173
+ background: "none",
5174
+ border: "none",
5175
+ cursor: "pointer",
5176
+ color: colors.textTertiary,
5177
+ fontSize: "14px",
5178
+ padding: "4px 8px"
5179
+ },
5180
+ children: showPassword ? "Hide" : "Show"
5181
+ }
5182
+ )
5183
+ ] }),
5184
+ /* @__PURE__ */ jsxRuntime.jsx(
5185
+ "button",
5186
+ {
5187
+ type: "submit",
5188
+ disabled: isLoading || !email || !password,
5189
+ onMouseEnter: (e) => {
5190
+ if (!isLoading && email && password) {
5191
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
5192
+ }
5193
+ },
5194
+ onMouseLeave: (e) => {
5195
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
5196
+ },
5197
+ style: {
5198
+ width: "100%",
5199
+ padding: "14px",
5200
+ backgroundColor: colors.buttonPrimary,
5201
+ color: "white",
5202
+ border: "none",
5203
+ borderRadius: "8px",
5204
+ fontSize: "16px",
5205
+ fontWeight: 600,
5206
+ cursor: isLoading || !email || !password ? "not-allowed" : "pointer",
5207
+ opacity: isLoading || !email || !password ? 0.6 : 1,
5208
+ transition: "all 0.2s ease",
5209
+ ...appearance?.elements?.formButtonPrimary
5210
+ },
5211
+ children: isLoading ? "Signing in..." : "Sign In"
5212
+ }
5213
+ ),
5214
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5215
+ marginTop: "20px",
5216
+ padding: "12px",
5217
+ backgroundColor: colors.bgSecondary,
5218
+ borderRadius: "8px",
5219
+ textAlign: "center"
5220
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
5221
+ color: colors.textTertiary,
5222
+ fontSize: "12px",
5223
+ margin: 0
5224
+ }, children: [
5225
+ "\u{1F512} This portal is restricted to Super Admin users only.",
5226
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
5227
+ "Contact your system administrator if you need access."
5228
+ ] }) })
5229
+ ] })
5230
+ }
5231
+ );
5232
+ };
4772
5233
  var AvatarManager = ({
4773
5234
  open,
4774
5235
  onOpenChange,
@@ -4867,6 +5328,7 @@ exports.ResetPassword = ResetPassword;
4867
5328
  exports.SignIn = SignIn;
4868
5329
  exports.SignOut = SignOut;
4869
5330
  exports.SignUp = SignUp;
5331
+ exports.SuperAdminSignIn = SuperAdminSignIn;
4870
5332
  exports.UserButton = UserButton;
4871
5333
  exports.UserProfile = UserProfile;
4872
5334
  exports.VerifyEmail = VerifyEmail;