@skylabs-digital/react-identity-access 2.28.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as s, Fragment as _, jsxs as u } from "react/jsx-runtime";
1
+ import { jsx as s, Fragment as _, jsxs as h } from "react/jsx-runtime";
2
2
  import { createContext as ye, useMemo as Z, useState as x, useCallback as oe, useEffect as ne, useContext as le, useRef as Ne } from "react";
3
3
  import { useLocation as xe, Navigate as Se, useNavigate as mt, useSearchParams as yt } from "react-router-dom";
4
4
  class de {
@@ -13,28 +13,28 @@ class de {
13
13
  }
14
14
  async executeRequest(e, t, r, i) {
15
15
  const o = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, a = (i == null ? void 0 : i.timeout) || this.timeout;
16
- let c = {
16
+ let d = {
17
17
  "Content-Type": "application/json",
18
18
  ...i == null ? void 0 : i.headers
19
19
  };
20
20
  if (!(i != null && i.skipAuth) && this.sessionManager) {
21
- const f = await this.sessionManager.getValidAccessToken();
22
- c = { ...c, Authorization: `Bearer ${f}` };
21
+ const g = await this.sessionManager.getValidAccessToken();
22
+ d = { ...d, Authorization: `Bearer ${g}` };
23
23
  }
24
- const m = new AbortController(), y = setTimeout(() => m.abort(), a);
24
+ const c = new AbortController(), y = setTimeout(() => c.abort(), a);
25
25
  try {
26
- const f = await fetch(o, {
26
+ const g = await fetch(o, {
27
27
  method: e,
28
- headers: c,
28
+ headers: d,
29
29
  body: r ? JSON.stringify(r) : void 0,
30
- signal: m.signal
30
+ signal: c.signal
31
31
  });
32
- if (clearTimeout(y), !f.ok)
33
- throw new Error(`HTTP ${f.status}: ${f.statusText}`);
34
- const F = f.headers.get("content-type");
35
- return !F || !F.includes("application/json") ? {} : await f.json();
36
- } catch (f) {
37
- throw clearTimeout(y), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : f;
32
+ if (clearTimeout(y), !g.ok)
33
+ throw new Error(`HTTP ${g.status}: ${g.statusText}`);
34
+ const F = g.headers.get("content-type");
35
+ return !F || !F.includes("application/json") ? {} : await g.json();
36
+ } catch (g) {
37
+ throw clearTimeout(y), g instanceof Error && g.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : g;
38
38
  }
39
39
  }
40
40
  async get(e, t) {
@@ -113,9 +113,9 @@ const Fe = ye(null);
113
113
  function br({ config: n, children: e }) {
114
114
  const t = Z(
115
115
  () => {
116
- var g, T, A;
116
+ var m, T, A;
117
117
  return {
118
- enabled: ((g = n.cache) == null ? void 0 : g.enabled) ?? !0,
118
+ enabled: ((m = n.cache) == null ? void 0 : m.enabled) ?? !0,
119
119
  ttl: ((T = n.cache) == null ? void 0 : T.ttl) ?? 3e5,
120
120
  // 5 minutes default
121
121
  storageKey: ((A = n.cache) == null ? void 0 : A.storageKey) ?? `app_cache_${n.appId}`
@@ -125,16 +125,16 @@ function br({ config: n, children: e }) {
125
125
  ), [r, i] = x(() => {
126
126
  if (!t.enabled) return null;
127
127
  try {
128
- const g = localStorage.getItem(t.storageKey);
129
- if (!g) return null;
130
- const T = JSON.parse(g);
128
+ const m = localStorage.getItem(t.storageKey);
129
+ if (!m) return null;
130
+ const T = JSON.parse(m);
131
131
  return Date.now() - T.timestamp < t.ttl && T.appId === n.appId ? T.data : (localStorage.removeItem(t.storageKey), null);
132
132
  } catch {
133
133
  return null;
134
134
  }
135
- }), [o, a] = x(!r), [c, m] = x(null), y = Z(() => {
136
- const g = () => {
137
- f();
135
+ }), [o, a] = x(!r), [d, c] = x(null), y = Z(() => {
136
+ const m = () => {
137
+ g();
138
138
  };
139
139
  return {
140
140
  appId: n.appId,
@@ -142,14 +142,14 @@ function br({ config: n, children: e }) {
142
142
  // App info
143
143
  appInfo: r,
144
144
  isAppLoading: o,
145
- appError: c,
146
- retryApp: g
145
+ appError: d,
146
+ retryApp: m
147
147
  };
148
- }, [n, r, o, c]), f = oe(
149
- async (g = !1) => {
150
- if (!(!g && t.enabled && r))
148
+ }, [n, r, o, d]), g = oe(
149
+ async (m = !1) => {
150
+ if (!(!m && t.enabled && r))
151
151
  try {
152
- a(!0), m(null);
152
+ a(!0), c(null);
153
153
  const T = new de(n.baseUrl), L = await new Ve(T, {}).getPublicAppInfo(n.appId);
154
154
  if (i(L), t.enabled)
155
155
  try {
@@ -164,7 +164,7 @@ function br({ config: n, children: e }) {
164
164
  }
165
165
  } catch (T) {
166
166
  const A = T instanceof Error ? T : new Error("Failed to load app information");
167
- m(A), i(null);
167
+ c(A), i(null);
168
168
  } finally {
169
169
  a(!1);
170
170
  }
@@ -173,25 +173,25 @@ function br({ config: n, children: e }) {
173
173
  ), F = oe(async () => {
174
174
  if (!(!t.enabled || !r))
175
175
  try {
176
- const g = localStorage.getItem(t.storageKey);
177
- if (!g) return;
178
- const T = JSON.parse(g);
176
+ const m = localStorage.getItem(t.storageKey);
177
+ if (!m) return;
178
+ const T = JSON.parse(m);
179
179
  if (Date.now() - T.timestamp > t.ttl * 0.5) {
180
180
  const L = new de(n.baseUrl), P = await new Ve(L, {}).getPublicAppInfo(n.appId);
181
181
  i(P);
182
- const d = {
182
+ const u = {
183
183
  data: P,
184
184
  timestamp: Date.now(),
185
185
  appId: n.appId
186
186
  };
187
- localStorage.setItem(t.storageKey, JSON.stringify(d));
187
+ localStorage.setItem(t.storageKey, JSON.stringify(u));
188
188
  }
189
- } catch (g) {
190
- process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", g);
189
+ } catch (m) {
190
+ process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", m);
191
191
  }
192
192
  }, [n, t, r]);
193
193
  return ne(() => {
194
- r ? F() : f();
194
+ r ? F() : g();
195
195
  }, []), /* @__PURE__ */ s(Fe.Provider, { value: y, children: e });
196
196
  }
197
197
  function Ae() {
@@ -469,8 +469,8 @@ const ie = class ie {
469
469
  if (a instanceof se)
470
470
  throw a;
471
471
  if (t = a, i < this.maxRefreshRetries) {
472
- const c = this.retryBackoffBase * Math.pow(2, i);
473
- await this.sleep(c);
472
+ const d = this.retryBackoffBase * Math.pow(2, i);
473
+ await this.sleep(d);
474
474
  }
475
475
  }
476
476
  }
@@ -482,36 +482,45 @@ const ie = class ie {
482
482
  * Throws generic Error for transient errors (will be retried).
483
483
  */
484
484
  async performTokenRefresh(e, t) {
485
+ return typeof navigator < "u" && navigator.locks ? navigator.locks.request(
486
+ `session-refresh:${this.storageKey}`,
487
+ () => this.performTokenRefreshInner(e, t)
488
+ ) : this.performTokenRefreshInner(e, t);
489
+ }
490
+ async performTokenRefreshInner(e, t) {
485
491
  if (!this.baseUrl)
486
492
  throw new Error("Base URL not configured for token refresh");
487
- const r = `${this.baseUrl}/auth/refresh`;
488
- let i;
493
+ const r = this.getTokens();
494
+ if (r != null && r.accessToken && !this.isTokenExpired(r) && !this.shouldRefreshToken(r))
495
+ return;
496
+ const i = (r == null ? void 0 : r.refreshToken) || e, o = `${this.baseUrl}/auth/refresh`;
497
+ let a;
489
498
  try {
490
- i = await fetch(r, {
499
+ a = await fetch(o, {
491
500
  method: "POST",
492
501
  headers: { "Content-Type": "application/json" },
493
- body: JSON.stringify({ refreshToken: e })
502
+ body: JSON.stringify({ refreshToken: i })
494
503
  });
495
- } catch (a) {
496
- throw a instanceof Error ? a : new Error("Network error during token refresh");
504
+ } catch (c) {
505
+ throw c instanceof Error ? c : new Error("Network error during token refresh");
497
506
  }
498
- if (!i.ok) {
499
- let a = "";
507
+ if (!a.ok) {
508
+ let c = "";
500
509
  try {
501
- const c = await i.json();
502
- a = (c.message || c.error || "").toLowerCase();
510
+ const y = await a.json();
511
+ c = (y.message || y.error || "").toLowerCase();
503
512
  } catch {
504
- a = i.statusText.toLowerCase();
513
+ c = a.statusText.toLowerCase();
505
514
  }
506
- throw i.status === 401 ? a.includes("expired") ? new se("token_expired") : a.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new se("user_inactive") : a.includes("expired") || a.includes("invalid") ? new se("token_invalid", a) : a.includes("reuse") || a.includes("revoked") ? new se("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
515
+ throw a.status === 401 ? c.includes("expired") ? new se("token_expired") : c.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${c}`) : a.status === 400 ? c.includes("inactive") ? new se("user_inactive") : c.includes("expired") || c.includes("invalid") ? new se("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new se("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${a.status} ${c}`);
507
516
  }
508
517
  if (this.sessionGeneration !== t)
509
518
  throw new se("token_invalid", "Session cleared during refresh");
510
- const o = await i.json();
519
+ const d = await a.json();
511
520
  this.setTokens({
512
- accessToken: o.accessToken,
513
- refreshToken: o.refreshToken || e,
514
- expiresIn: o.expiresIn
521
+ accessToken: d.accessToken,
522
+ refreshToken: d.refreshToken || i,
523
+ expiresIn: d.expiresIn
515
524
  });
516
525
  }
517
526
  // --- Session expiry handler ---
@@ -907,115 +916,115 @@ function Sr({ config: n, children: e }) {
907
916
  search: window.location.search
908
917
  },
909
918
  window.localStorage
910
- ), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, c] = x(() => o()), m = Z(
919
+ ), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, d] = x(() => o()), c = Z(
911
920
  () => {
912
- var p, U, b;
921
+ var f, U, b;
913
922
  return {
914
- enabled: ((p = n.cache) == null ? void 0 : p.enabled) ?? !0,
923
+ enabled: ((f = n.cache) == null ? void 0 : f.enabled) ?? !0,
915
924
  ttl: ((U = n.cache) == null ? void 0 : U.ttl) ?? 5 * 60 * 1e3,
916
925
  // 5 minutes default
917
926
  storageKey: ((b = n.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${a || "default"}`
918
927
  };
919
928
  },
920
929
  [n.cache, a]
921
- ), [y, f] = x(() => {
930
+ ), [y, g] = x(() => {
922
931
  if (n.initialTenant) return n.initialTenant;
923
- if (!m.enabled || !a) return null;
932
+ if (!c.enabled || !a) return null;
924
933
  try {
925
- const p = localStorage.getItem(m.storageKey);
926
- if (!p) return null;
927
- const U = JSON.parse(p);
928
- return Date.now() - U.timestamp < m.ttl && U.tenantSlug === a ? U.data : (localStorage.removeItem(m.storageKey), null);
934
+ const f = localStorage.getItem(c.storageKey);
935
+ if (!f) return null;
936
+ const U = JSON.parse(f);
937
+ return Date.now() - U.timestamp < c.ttl && U.tenantSlug === a ? U.data : (localStorage.removeItem(c.storageKey), null);
929
938
  } catch {
930
939
  return null;
931
940
  }
932
- }), [F, g] = x(!y && !n.initialTenant), [T, A] = x(null), [L, M] = x(null), [P, d] = x(!1), [v, N] = x(null);
941
+ }), [F, m] = x(!y && !n.initialTenant), [T, A] = x(null), [L, M] = x(null), [P, u] = x(!1), [v, N] = x(null);
933
942
  ne(() => {
934
943
  if (n.tenantMode === "fixed") return;
935
- const p = o();
936
- c(p);
944
+ const f = o();
945
+ d(f);
937
946
  }, [o, n.tenantMode]);
938
- const B = (r == null ? void 0 : r.settingsSchema) || null, w = oe(
939
- async (p, U = !1) => {
940
- if (!(!U && m.enabled && y && y.domain === p))
947
+ const $ = (r == null ? void 0 : r.settingsSchema) || null, w = oe(
948
+ async (f, U = !1) => {
949
+ if (!(!U && c.enabled && y && y.domain === f))
941
950
  try {
942
- g(!0), A(null);
943
- const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(p);
944
- if (f(S), m.enabled)
951
+ m(!0), A(null);
952
+ const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(f);
953
+ if (g(S), c.enabled)
945
954
  try {
946
955
  const E = {
947
956
  data: S,
948
957
  timestamp: Date.now(),
949
- tenantSlug: p
958
+ tenantSlug: f
950
959
  };
951
- localStorage.setItem(m.storageKey, JSON.stringify(E));
960
+ localStorage.setItem(c.storageKey, JSON.stringify(E));
952
961
  } catch (E) {
953
962
  process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", E);
954
963
  }
955
964
  } catch (b) {
956
- const h = b instanceof Error ? b : new Error("Failed to load tenant information");
957
- A(h), f(null);
965
+ const p = b instanceof Error ? b : new Error("Failed to load tenant information");
966
+ A(p), g(null);
958
967
  } finally {
959
- g(!1);
968
+ m(!1);
960
969
  }
961
970
  },
962
- [t, i, m, y]
971
+ [t, i, c, y]
963
972
  ), R = oe(async () => {
964
- if (!(!m.enabled || !y || !a))
973
+ if (!(!c.enabled || !y || !a))
965
974
  try {
966
- const p = localStorage.getItem(m.storageKey);
967
- if (!p) return;
968
- const U = JSON.parse(p);
969
- if (Date.now() - U.timestamp > m.ttl * 0.5) {
970
- const h = new de(t), E = await new ve(h, i).getPublicTenantInfo(a);
971
- f(E);
975
+ const f = localStorage.getItem(c.storageKey);
976
+ if (!f) return;
977
+ const U = JSON.parse(f);
978
+ if (Date.now() - U.timestamp > c.ttl * 0.5) {
979
+ const p = new de(t), E = await new ve(p, i).getPublicTenantInfo(a);
980
+ g(E);
972
981
  const K = {
973
982
  data: E,
974
983
  timestamp: Date.now(),
975
984
  tenantSlug: a
976
985
  };
977
- localStorage.setItem(m.storageKey, JSON.stringify(K));
986
+ localStorage.setItem(c.storageKey, JSON.stringify(K));
978
987
  }
979
- } catch (p) {
980
- process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", p);
988
+ } catch (f) {
989
+ process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", f);
981
990
  }
982
- }, [t, i, m, y, a]), k = oe(async () => {
991
+ }, [t, i, c, y, a]), k = oe(async () => {
983
992
  if (y != null && y.id)
984
993
  try {
985
- d(!0), N(null);
986
- const p = new de(t), b = await new ve(p, y.appId).getTenantSettings(y.id);
994
+ u(!0), N(null);
995
+ const f = new de(t), b = await new ve(f, y.appId).getTenantSettings(y.id);
987
996
  M(b);
988
- } catch (p) {
989
- const U = p instanceof Error ? p : new Error("Failed to load tenant settings");
997
+ } catch (f) {
998
+ const U = f instanceof Error ? f : new Error("Failed to load tenant settings");
990
999
  N(U), M(null);
991
1000
  } finally {
992
- d(!1);
1001
+ u(!1);
993
1002
  }
994
1003
  }, [t, y]), I = oe(() => {
995
1004
  k();
996
1005
  }, [k]), l = oe(
997
- (p) => {
998
- if (!B)
1006
+ (f) => {
1007
+ if (!$)
999
1008
  return { isValid: !0, errors: [] };
1000
1009
  const U = [];
1001
1010
  try {
1002
- return B.properties && Object.entries(B.properties).forEach(([b, h]) => {
1011
+ return $.properties && Object.entries($.properties).forEach(([b, p]) => {
1003
1012
  var E;
1004
- const S = p[b];
1005
- if ((E = B.required) != null && E.includes(b) && S == null) {
1013
+ const S = f[b];
1014
+ if ((E = $.required) != null && E.includes(b) && S == null) {
1006
1015
  U.push(`Field '${b}' is required`);
1007
1016
  return;
1008
1017
  }
1009
1018
  if (S != null) {
1010
- if (h.type) {
1011
- const K = h.type, G = typeof S;
1019
+ if (p.type) {
1020
+ const K = p.type, G = typeof S;
1012
1021
  K === "string" && G !== "string" ? U.push(`Field '${b}' must be a string`) : (K === "number" || K === "integer") && G !== "number" ? U.push(`Field '${b}' must be a number`) : K === "boolean" && G !== "boolean" ? U.push(`Field '${b}' must be a boolean`) : K === "array" && !Array.isArray(S) && U.push(`Field '${b}' must be an array`);
1013
1022
  }
1014
- h.minLength !== void 0 && typeof S == "string" && S.length < h.minLength && U.push(
1015
- `Field '${b}' must be at least ${h.minLength} characters long`
1016
- ), h.maxLength !== void 0 && typeof S == "string" && S.length > h.maxLength && U.push(
1017
- `Field '${b}' must be no more than ${h.maxLength} characters long`
1018
- ), h.minimum !== void 0 && typeof S == "number" && S < h.minimum && U.push(`Field '${b}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof S == "number" && S > h.maximum && U.push(`Field '${b}' must be no more than ${h.maximum}`), h.pattern && typeof S == "string" && (new RegExp(h.pattern).test(S) || U.push(`Field '${b}' does not match the required pattern`)), h.enum && !h.enum.includes(S) && U.push(`Field '${b}' must be one of: ${h.enum.join(", ")}`);
1023
+ p.minLength !== void 0 && typeof S == "string" && S.length < p.minLength && U.push(
1024
+ `Field '${b}' must be at least ${p.minLength} characters long`
1025
+ ), p.maxLength !== void 0 && typeof S == "string" && S.length > p.maxLength && U.push(
1026
+ `Field '${b}' must be no more than ${p.maxLength} characters long`
1027
+ ), p.minimum !== void 0 && typeof S == "number" && S < p.minimum && U.push(`Field '${b}' must be at least ${p.minimum}`), p.maximum !== void 0 && typeof S == "number" && S > p.maximum && U.push(`Field '${b}' must be no more than ${p.maximum}`), p.pattern && typeof S == "string" && (new RegExp(p.pattern).test(S) || U.push(`Field '${b}' does not match the required pattern`)), p.enum && !p.enum.includes(S) && U.push(`Field '${b}' must be one of: ${p.enum.join(", ")}`);
1019
1028
  }
1020
1029
  }), {
1021
1030
  isValid: U.length === 0,
@@ -1028,16 +1037,16 @@ function Sr({ config: n, children: e }) {
1028
1037
  };
1029
1038
  }
1030
1039
  },
1031
- [B]
1040
+ [$]
1032
1041
  );
1033
1042
  ne(() => {
1034
- !n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (f(null), A(null), g(!1));
1043
+ !n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (g(null), A(null), m(!1));
1035
1044
  }, [n.initialTenant, a, y, w, R]), ne(() => {
1036
- y != null && y.id ? k() : (M(null), N(null), d(!1));
1045
+ y != null && y.id ? k() : (M(null), N(null), u(!1));
1037
1046
  }, [y == null ? void 0 : y.id, k]);
1038
1047
  const z = oe(
1039
- (p, U) => {
1040
- const { mode: b = "reload", tokens: h, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
1048
+ (f, U) => {
1049
+ const { mode: b = "reload", tokens: p, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
1041
1050
  if (E === "fixed") {
1042
1051
  process.env.NODE_ENV === "development" && console.warn(
1043
1052
  "[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
@@ -1045,9 +1054,9 @@ function Sr({ config: n, children: e }) {
1045
1054
  ), S && (window.location.href = S);
1046
1055
  return;
1047
1056
  }
1048
- if (localStorage.setItem("tenant", p), E === "subdomain") {
1057
+ if (localStorage.setItem("tenant", f), E === "subdomain") {
1049
1058
  const K = window.location.hostname, G = At(
1050
- p,
1059
+ f,
1051
1060
  K,
1052
1061
  n.baseDomain
1053
1062
  );
@@ -1061,15 +1070,15 @@ function Sr({ config: n, children: e }) {
1061
1070
  const X = S || window.location.pathname, W = new URL(`${window.location.protocol}//${G}${X}`);
1062
1071
  new URLSearchParams(window.location.search).forEach((V, H) => {
1063
1072
  H !== me && W.searchParams.set(H, V);
1064
- }), h && W.searchParams.set(me, je(h)), window.location.href = W.toString();
1073
+ }), p && W.searchParams.set(me, je(p)), window.location.href = W.toString();
1065
1074
  } else if (E === "selector") {
1066
1075
  const K = S || window.location.pathname, G = new URLSearchParams(window.location.search);
1067
- if (G.set(n.selectorParam || "tenant", p), G.delete(me), h && G.set(me, je(h)), b === "reload") {
1076
+ if (G.set(n.selectorParam || "tenant", f), G.delete(me), p && G.set(me, je(p)), b === "reload") {
1068
1077
  const X = `${K}?${G.toString()}${window.location.hash}`;
1069
1078
  window.location.href = X;
1070
1079
  } else {
1071
1080
  const X = `${K}?${G.toString()}${window.location.hash}`;
1072
- window.history.pushState({}, "", X), c(p), w(p);
1081
+ window.history.pushState({}, "", X), d(f), w(f);
1073
1082
  }
1074
1083
  }
1075
1084
  },
@@ -1085,7 +1094,7 @@ function Sr({ config: n, children: e }) {
1085
1094
  },
1086
1095
  // Settings
1087
1096
  settings: L,
1088
- settingsSchema: B,
1097
+ settingsSchema: $,
1089
1098
  isSettingsLoading: P,
1090
1099
  settingsError: v,
1091
1100
  // Actions
@@ -1099,7 +1108,7 @@ function Sr({ config: n, children: e }) {
1099
1108
  F,
1100
1109
  T,
1101
1110
  L,
1102
- B,
1111
+ $,
1103
1112
  P,
1104
1113
  v,
1105
1114
  I,
@@ -1138,31 +1147,31 @@ function Je() {
1138
1147
  retry: i
1139
1148
  };
1140
1149
  }
1141
- const Be = ye(null);
1150
+ const $e = ye(null);
1142
1151
  function xr({ config: n = {}, children: e }) {
1143
- const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? n.baseUrl ?? "", o = (t == null ? void 0 : t.appId) ?? n.appId, a = (r == null ? void 0 : r.tenant) ?? null, c = (r == null ? void 0 : r.tenantSlug) ?? null, m = (r == null ? void 0 : r.switchTenant) ?? (() => {
1152
+ const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? n.baseUrl ?? "", o = (t == null ? void 0 : t.appId) ?? n.appId, a = (r == null ? void 0 : r.tenant) ?? null, d = (r == null ? void 0 : r.tenantSlug) ?? null, c = (r == null ? void 0 : r.switchTenant) ?? (() => {
1144
1153
  });
1145
1154
  if (!i)
1146
1155
  throw new Error(
1147
1156
  "[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
1148
1157
  );
1149
- const [y, f] = x(n.initialRoles || []), [F, g] = x(!n.initialRoles), [T, A] = x(null), [L, M] = x(!1), [P, d] = x(null), [v, N] = x(() => {
1158
+ const [y, g] = x(n.initialRoles || []), [F, m] = x(!n.initialRoles), [T, A] = x(null), [L, M] = x(!1), [P, u] = x(null), [v, N] = x(() => {
1150
1159
  try {
1151
- const $ = localStorage.getItem("userTenants");
1152
- return $ ? JSON.parse($) : [];
1160
+ const B = localStorage.getItem("userTenants");
1161
+ return B ? JSON.parse(B) : [];
1153
1162
  } catch {
1154
1163
  return [];
1155
1164
  }
1156
- }), [B, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
1165
+ }), [$, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
1157
1166
  R.current.done || (R.current.done = !0, R.current.urlTokens = Rt());
1158
1167
  const [k, I] = x(() => R.current.urlTokens !== null), l = Z(() => {
1159
- const $ = be.getInstance({
1160
- tenantSlug: c,
1168
+ const B = be.getInstance({
1169
+ tenantSlug: d,
1161
1170
  baseUrl: i,
1162
1171
  refreshQueueTimeout: n.refreshQueueTimeout,
1163
1172
  proactiveRefreshMargin: n.proactiveRefreshMargin,
1164
1173
  onSessionExpired: (ce) => {
1165
- A(null), d(null), N([]), w(!1);
1174
+ A(null), u(null), N([]), w(!1);
1166
1175
  try {
1167
1176
  localStorage.removeItem("userTenants");
1168
1177
  } catch {
@@ -1170,21 +1179,21 @@ function xr({ config: n = {}, children: e }) {
1170
1179
  n.onSessionExpired ? n.onSessionExpired(ce) : n.onRefreshFailed && n.onRefreshFailed();
1171
1180
  }
1172
1181
  });
1173
- return R.current.urlTokens && $.setTokens({
1182
+ return R.current.urlTokens && B.setTokens({
1174
1183
  accessToken: R.current.urlTokens.accessToken,
1175
1184
  refreshToken: R.current.urlTokens.refreshToken,
1176
1185
  expiresIn: R.current.urlTokens.expiresIn
1177
- }), $;
1178
- }, [c, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
1186
+ }), B;
1187
+ }, [d, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
1179
1188
  if (R.current.urlTokens) return !1;
1180
- const $ = l.getTokens();
1181
- return $ ? l.hasValidSession() || !!$.refreshToken : !1;
1182
- }), p = R.current.done && !k && !z, U = Z(() => {
1183
- const $ = new de(i);
1184
- return $.setSessionManager(l), $;
1185
- }, [i, l]), b = Z(() => new vt(new de(i)), [i]), h = Z(() => new St(U, l), [U, l]), S = Z(() => new We(new de(i)), [i]), E = Z(() => T || l.getUser(), [T, l]), K = Z(() => E != null && E.roleId && y.find(($) => $.id === E.roleId) || null, [E, y]), G = Z(() => (K == null ? void 0 : K.permissions) || [], [K]), X = Z(() => l.hasValidSession() && T !== null, [l, T]), W = Ne(async () => {
1189
+ const B = l.getTokens();
1190
+ return B ? l.hasValidSession() || !!B.refreshToken : !1;
1191
+ }), f = R.current.done && !k && !z, U = Z(() => {
1192
+ const B = new de(i);
1193
+ return B.setSessionManager(l), B;
1194
+ }, [i, l]), b = Z(() => new vt(new de(i)), [i]), p = Z(() => new St(U, l), [U, l]), S = Z(() => new We(new de(i)), [i]), E = Z(() => T || l.getUser(), [T, l]), K = Z(() => E != null && E.roleId && y.find((B) => B.id === E.roleId) || null, [E, y]), G = Z(() => (K == null ? void 0 : K.permissions) || [], [K]), X = Z(() => l.hasValidSession() && T !== null, [l, T]), W = Ne(async () => {
1186
1195
  }), q = Z(() => {
1187
- const $ = async (C = !1) => {
1196
+ const B = async (C = !1) => {
1188
1197
  try {
1189
1198
  if (!l.hasValidSession() || !C && T)
1190
1199
  return;
@@ -1193,28 +1202,28 @@ function xr({ config: n = {}, children: e }) {
1193
1202
  process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
1194
1203
  return;
1195
1204
  }
1196
- M(!0), d(null);
1197
- const J = await h.getUserById(O);
1205
+ M(!0), u(null);
1206
+ const J = await p.getUserById(O);
1198
1207
  A(J), l.setUser(J);
1199
1208
  } catch (O) {
1200
1209
  const J = O instanceof Error ? O : new Error("Failed to load user data");
1201
- d(J), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", J);
1210
+ u(J), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", J);
1202
1211
  } finally {
1203
1212
  M(!1);
1204
1213
  }
1205
1214
  }, ce = async () => {
1206
- await $();
1215
+ await B();
1207
1216
  }, fe = async (C) => {
1208
1217
  var _e;
1209
1218
  const { username: O, password: J, tenantSlug: j, redirectPath: Y } = C;
1210
- let ee = a == null ? void 0 : a.id, te = c, re = l;
1219
+ let ee = a == null ? void 0 : a.id, te = d, re = l;
1211
1220
  j && (ee = (await new ve(U, o).getPublicTenantInfo(j)).id, te = j);
1212
1221
  const Q = await b.login({
1213
1222
  username: O,
1214
1223
  password: J,
1215
1224
  appId: o,
1216
1225
  tenantId: ee
1217
- }), we = j && j !== c;
1226
+ }), we = j && j !== d;
1218
1227
  if (we && (re = new be({
1219
1228
  tenantSlug: te,
1220
1229
  baseUrl: i
@@ -1225,7 +1234,7 @@ function xr({ config: n = {}, children: e }) {
1225
1234
  }), Q.user) {
1226
1235
  re.setUser(Q.user), A(Q.user);
1227
1236
  try {
1228
- await $();
1237
+ await B();
1229
1238
  } catch (ke) {
1230
1239
  process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
1231
1240
  }
@@ -1245,14 +1254,14 @@ function xr({ config: n = {}, children: e }) {
1245
1254
  expiresIn: Q.expiresIn
1246
1255
  };
1247
1256
  if (we && te)
1248
- return m(te, { tokens: Ee, redirectPath: Y }), Q;
1257
+ return c(te, { tokens: Ee, redirectPath: Y }), Q;
1249
1258
  if (Y && Y !== window.location.pathname)
1250
- return m(te || c || "", { tokens: Ee, redirectPath: Y }), Q;
1259
+ return c(te || d || "", { tokens: Ee, redirectPath: Y }), Q;
1251
1260
  if (!Re && Q.tenants && Q.tenants.length > 0) {
1252
1261
  const ke = C.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
1253
1262
  if (Q.tenants.length === 1 && ke) {
1254
1263
  const ze = Q.tenants[0];
1255
- return m(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
1264
+ return c(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
1256
1265
  } else Q.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Q.tenants);
1257
1266
  }
1258
1267
  return Q;
@@ -1312,14 +1321,14 @@ function xr({ config: n = {}, children: e }) {
1312
1321
  });
1313
1322
  }, lt = async (C) => {
1314
1323
  const { token: O, email: J, tenantSlug: j } = C;
1315
- let Y = a == null ? void 0 : a.id, ee = c, te = l;
1324
+ let Y = a == null ? void 0 : a.id, ee = d, te = l;
1316
1325
  j && (Y = (await new ve(U, o).getPublicTenantInfo(j)).id, ee = j);
1317
1326
  const re = await b.verifyMagicLink({
1318
1327
  token: O,
1319
1328
  email: J,
1320
1329
  appId: o,
1321
1330
  tenantId: Y
1322
- }), Q = j && j !== c;
1331
+ }), Q = j && j !== d;
1323
1332
  if (Q && (te = new be({
1324
1333
  tenantSlug: ee,
1325
1334
  baseUrl: i
@@ -1330,7 +1339,7 @@ function xr({ config: n = {}, children: e }) {
1330
1339
  }), re.user) {
1331
1340
  te.setUser(re.user), A(re.user);
1332
1341
  try {
1333
- await $();
1342
+ await B();
1334
1343
  } catch (we) {
1335
1344
  process.env.NODE_ENV === "development" && console.warn(
1336
1345
  "[AuthProvider] Failed to load complete user data after magic link:",
@@ -1338,7 +1347,7 @@ function xr({ config: n = {}, children: e }) {
1338
1347
  );
1339
1348
  }
1340
1349
  }
1341
- return Q && ee && ee !== c && m(ee, {
1350
+ return Q && ee && ee !== d && c(ee, {
1342
1351
  tokens: {
1343
1352
  accessToken: re.accessToken,
1344
1353
  refreshToken: re.refreshToken,
@@ -1358,7 +1367,7 @@ function xr({ config: n = {}, children: e }) {
1358
1367
  expiresIn: O.expiresIn
1359
1368
  });
1360
1369
  }, dt = () => {
1361
- l.clearSession(), A(null), d(null), N([]), w(!1);
1370
+ l.clearSession(), A(null), u(null), N([]), w(!1);
1362
1371
  try {
1363
1372
  localStorage.removeItem("userTenants");
1364
1373
  } catch {
@@ -1366,17 +1375,17 @@ function xr({ config: n = {}, children: e }) {
1366
1375
  }, ut = (C) => {
1367
1376
  l.setTokens(C);
1368
1377
  }, ht = () => l.hasValidSession(), pt = () => {
1369
- l.clearSession(), A(null), d(null);
1378
+ l.clearSession(), A(null), u(null);
1370
1379
  }, ft = async () => {
1371
1380
  if (o)
1372
1381
  try {
1373
- g(!0);
1382
+ m(!0);
1374
1383
  const { roles: C } = await S.getRolesByApp(o);
1375
- f(C);
1384
+ g(C);
1376
1385
  } catch (C) {
1377
1386
  process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", C);
1378
1387
  } finally {
1379
- g(!1);
1388
+ m(!1);
1380
1389
  }
1381
1390
  }, gt = async () => {
1382
1391
  await ft();
@@ -1409,10 +1418,10 @@ function xr({ config: n = {}, children: e }) {
1409
1418
  currentUser: T,
1410
1419
  isUserLoading: L,
1411
1420
  userError: P,
1412
- loadUserData: $,
1421
+ loadUserData: B,
1413
1422
  refreshUser: ce,
1414
- isAuthInitializing: !p,
1415
- isAuthReady: p,
1423
+ isAuthInitializing: !f,
1424
+ isAuthReady: f,
1416
1425
  userRole: K,
1417
1426
  userPermissions: G,
1418
1427
  availableRoles: y,
@@ -1424,7 +1433,7 @@ function xr({ config: n = {}, children: e }) {
1424
1433
  refreshRoles: gt,
1425
1434
  // RFC-004: Multi-tenant user membership
1426
1435
  userTenants: v,
1427
- hasTenantContext: B,
1436
+ hasTenantContext: $,
1428
1437
  switchToTenant: async (C, O) => {
1429
1438
  const { redirectPath: J } = O || {}, j = l.getTokens();
1430
1439
  if (!(j != null && j.refreshToken))
@@ -1440,7 +1449,7 @@ function xr({ config: n = {}, children: e }) {
1440
1449
  expiresIn: Y.expiresIn
1441
1450
  }), A(Y.user), l.setUser(Y.user), w(!0);
1442
1451
  const ee = v.find((te) => te.id === C);
1443
- ee && m(ee.subdomain, {
1452
+ ee && c(ee.subdomain, {
1444
1453
  tokens: {
1445
1454
  accessToken: Y.accessToken,
1446
1455
  refreshToken: j.refreshToken,
@@ -1464,67 +1473,67 @@ function xr({ config: n = {}, children: e }) {
1464
1473
  l,
1465
1474
  U,
1466
1475
  b,
1467
- h,
1476
+ p,
1468
1477
  S,
1469
1478
  o,
1470
1479
  a,
1480
+ d,
1471
1481
  c,
1472
- m,
1473
1482
  y,
1474
1483
  T,
1475
1484
  L,
1476
1485
  P,
1477
1486
  v,
1478
- B,
1479
- p,
1487
+ $,
1488
+ f,
1480
1489
  K,
1481
1490
  G
1482
1491
  ]);
1483
1492
  W.current = q.loadUserData, ne(() => {
1484
1493
  !n.initialRoles && o && (async () => {
1485
1494
  try {
1486
- g(!0);
1495
+ m(!0);
1487
1496
  const ce = new de(i), fe = new We(ce), { roles: ge } = await fe.getRolesByApp(o);
1488
- f(ge);
1497
+ g(ge);
1489
1498
  } catch (ce) {
1490
1499
  process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", ce);
1491
1500
  } finally {
1492
- g(!1);
1501
+ m(!1);
1493
1502
  }
1494
1503
  })();
1495
1504
  }, [o, i, n.initialRoles]);
1496
1505
  const [V, H] = x(!1);
1497
1506
  return ne(() => {
1498
- V || (H(!0), R.current.urlTokens && (Et(), I(!0), q.loadUserData().catch(($) => {
1499
- process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", $);
1507
+ V || (H(!0), R.current.urlTokens && (Et(), I(!0), q.loadUserData().catch((B) => {
1508
+ process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", B);
1500
1509
  }).finally(() => {
1501
1510
  I(!1);
1502
1511
  })));
1503
1512
  }, [q, V]), ne(() => {
1504
- let $ = !1;
1513
+ let B = !1;
1505
1514
  return (async () => {
1506
1515
  var ge;
1507
- if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), $) return;
1516
+ if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), B) return;
1508
1517
  const fe = l.getUser();
1509
1518
  fe && l.hasValidSession() && A(fe), D(!1);
1510
1519
  })(), () => {
1511
- $ = !0;
1520
+ B = !0;
1512
1521
  };
1513
1522
  }, [l]), ne(() => {
1514
1523
  V && (R.current.urlTokens || (!T && !L && !P && l.hasValidSession() ? W.current().catch(() => {
1515
1524
  }).finally(() => {
1516
1525
  D(!1);
1517
1526
  }) : D(!1)));
1518
- }, [T, L, P, l, V]), /* @__PURE__ */ s(Be.Provider, { value: q, children: e });
1527
+ }, [T, L, P, l, V]), /* @__PURE__ */ s($e.Provider, { value: q, children: e });
1519
1528
  }
1520
1529
  function he() {
1521
- const n = le(Be);
1530
+ const n = le($e);
1522
1531
  if (!n)
1523
1532
  throw new Error("useAuth must be used within an AuthProvider");
1524
1533
  return n;
1525
1534
  }
1526
- function $e() {
1527
- return le(Be);
1535
+ function Be() {
1536
+ return le($e);
1528
1537
  }
1529
1538
  class It {
1530
1539
  constructor(e, t) {
@@ -1608,52 +1617,52 @@ class It {
1608
1617
  }
1609
1618
  const Ce = ye(null);
1610
1619
  function Ar({ config: n = {}, children: e }) {
1611
- const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [c, m] = x([]), [y, f] = x(!1), [F, g] = x(null), [T, A] = x(!1), L = Z(() => {
1612
- const d = new de(i);
1613
- return new It(d);
1620
+ const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [d, c] = x([]), [y, g] = x(!1), [F, m] = x(null), [T, A] = x(!1), L = Z(() => {
1621
+ const u = new de(i);
1622
+ return new It(u);
1614
1623
  }, [i]), M = async () => {
1615
1624
  if (!(a != null && a.id)) {
1616
- m([]);
1625
+ c([]);
1617
1626
  return;
1618
1627
  }
1619
- f(!0), g(null);
1628
+ g(!0), m(null);
1620
1629
  try {
1621
- const d = await L.getTenantFeatureFlags(a.id, o);
1622
- m(d);
1623
- } catch (d) {
1624
- const v = d instanceof Error ? d.message : "Failed to fetch feature flags";
1625
- g(v), n.onError && n.onError(d instanceof Error ? d : new Error(v));
1630
+ const u = await L.getTenantFeatureFlags(a.id, o);
1631
+ c(u);
1632
+ } catch (u) {
1633
+ const v = u instanceof Error ? u.message : "Failed to fetch feature flags";
1634
+ m(v), n.onError && n.onError(u instanceof Error ? u : new Error(v));
1626
1635
  } finally {
1627
- f(!1);
1636
+ g(!1);
1628
1637
  }
1629
1638
  };
1630
1639
  ne(() => {
1631
1640
  if (!i || !o) return;
1632
1641
  M().finally(() => A(!0));
1633
- const d = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, d);
1642
+ const u = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, u);
1634
1643
  return () => clearInterval(v);
1635
1644
  }, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
1636
1645
  const P = Z(() => {
1637
- const d = (R) => {
1638
- const k = c.find((I) => I.key === R);
1646
+ const u = (R) => {
1647
+ const k = d.find((I) => I.key === R);
1639
1648
  return (k == null ? void 0 : k.value) === !0;
1640
- }, v = (R) => c.find((k) => k.key === R), N = (R) => {
1641
- const k = c.find((I) => I.key === R);
1649
+ }, v = (R) => d.find((k) => k.key === R), N = (R) => {
1650
+ const k = d.find((I) => I.key === R);
1642
1651
  return k ? k.value ? "enabled" : "disabled" : "not_found";
1643
- }, B = async () => {
1652
+ }, $ = async () => {
1644
1653
  await M();
1645
1654
  }, w = !!(i && o) && (T || !(a != null && a.id));
1646
1655
  return {
1647
- featureFlags: c,
1656
+ featureFlags: d,
1648
1657
  loading: y,
1649
1658
  error: F,
1650
1659
  isReady: w,
1651
- isEnabled: d,
1660
+ isEnabled: u,
1652
1661
  getFlag: v,
1653
1662
  getFlagState: N,
1654
- refresh: B
1663
+ refresh: $
1655
1664
  };
1656
- }, [c, y, F, i, o, a == null ? void 0 : a.id, T]);
1665
+ }, [d, y, F, i, o, a == null ? void 0 : a.id, T]);
1657
1666
  return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
1658
1667
  }
1659
1668
  function Mt() {
@@ -1733,53 +1742,53 @@ class Lt {
1733
1742
  }
1734
1743
  const He = ye(void 0);
1735
1744
  function Pr({ config: n = {}, children: e }) {
1736
- const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, c] = x(null), [m, y] = x(!1), [f, F] = x(null), [g, T] = x(!1), A = Z(() => {
1745
+ const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, d] = x(null), [c, y] = x(!1), [g, F] = x(null), [m, T] = x(!1), A = Z(() => {
1737
1746
  const P = new de(i);
1738
1747
  return new Lt(P);
1739
1748
  }, [i]), L = async () => {
1740
1749
  if (!(o != null && o.id)) {
1741
- c(null);
1750
+ d(null);
1742
1751
  return;
1743
1752
  }
1744
1753
  y(!0), F(null);
1745
1754
  try {
1746
1755
  const P = await A.getTenantSubscriptionFeatures(o.id);
1747
- c(P);
1756
+ d(P);
1748
1757
  } catch (P) {
1749
- const d = P instanceof Error ? P.message : "Failed to fetch subscription";
1750
- F(d), n.onError && n.onError(P instanceof Error ? P : new Error(d));
1758
+ const u = P instanceof Error ? P.message : "Failed to fetch subscription";
1759
+ F(u), n.onError && n.onError(P instanceof Error ? P : new Error(u));
1751
1760
  } finally {
1752
1761
  y(!1);
1753
1762
  }
1754
1763
  };
1755
1764
  ne(() => {
1756
1765
  if (!i || (L().finally(() => T(!0)), !n.refreshInterval)) return;
1757
- const P = n.refreshInterval || 10 * 60 * 1e3, d = setInterval(L, P);
1758
- return () => clearInterval(d);
1766
+ const P = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(L, P);
1767
+ return () => clearInterval(u);
1759
1768
  }, [o == null ? void 0 : o.id, i, n.refreshInterval]);
1760
1769
  const M = Z(() => {
1761
- const P = (a == null ? void 0 : a.features) || [], d = (k) => {
1770
+ const P = (a == null ? void 0 : a.features) || [], u = (k) => {
1762
1771
  const I = P.find((l) => l.key === k);
1763
1772
  return I ? I.type === "BOOLEAN" || I.type === "boolean" ? I.value === !0 : !!I.value : !1;
1764
1773
  }, v = (k) => P.find((I) => I.key === k), N = (k, I) => {
1765
1774
  const l = P.find((z) => z.key === k);
1766
1775
  return l ? l.value : I;
1767
- }, B = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
1776
+ }, $ = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
1768
1777
  await L();
1769
- }, R = !!i && (g || !(o != null && o.id));
1778
+ }, R = !!i && (m || !(o != null && o.id));
1770
1779
  return {
1771
1780
  subscription: a,
1772
1781
  features: P,
1773
- loading: m,
1774
- error: f,
1782
+ loading: c,
1783
+ error: g,
1775
1784
  isReady: R,
1776
- isFeatureEnabled: d,
1785
+ isFeatureEnabled: u,
1777
1786
  getFeature: v,
1778
1787
  getFeatureValue: N,
1779
- hasAllowedPlan: B,
1788
+ hasAllowedPlan: $,
1780
1789
  refresh: w
1781
1790
  };
1782
- }, [a, m, f, i, o == null ? void 0 : o.id, g]);
1791
+ }, [a, c, g, i, o == null ? void 0 : o.id, m]);
1783
1792
  return /* @__PURE__ */ s(He.Provider, { value: M, children: e });
1784
1793
  }
1785
1794
  function Nt() {
@@ -1857,7 +1866,7 @@ function Ft() {
1857
1866
  returnToStorage: "url"
1858
1867
  };
1859
1868
  }
1860
- const Ge = () => /* @__PURE__ */ u(
1869
+ const Ge = () => /* @__PURE__ */ h(
1861
1870
  "div",
1862
1871
  {
1863
1872
  style: {
@@ -1898,7 +1907,7 @@ const Ge = () => /* @__PURE__ */ u(
1898
1907
  userType: n,
1899
1908
  minUserType: e,
1900
1909
  missingPermissions: t
1901
- }) => /* @__PURE__ */ u(
1910
+ }) => /* @__PURE__ */ h(
1902
1911
  "div",
1903
1912
  {
1904
1913
  style: {
@@ -1916,19 +1925,19 @@ const Ge = () => /* @__PURE__ */ u(
1916
1925
  children: [
1917
1926
  /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1918
1927
  /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1919
- e && n ? /* @__PURE__ */ u(_, { children: [
1920
- /* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1928
+ e && n ? /* @__PURE__ */ h(_, { children: [
1929
+ /* @__PURE__ */ h("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1921
1930
  "This content requires ",
1922
1931
  /* @__PURE__ */ s("strong", { children: e }),
1923
1932
  " access level or higher."
1924
1933
  ] }),
1925
- /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1934
+ /* @__PURE__ */ h("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1926
1935
  "Your current access level: ",
1927
1936
  /* @__PURE__ */ s("strong", { children: n })
1928
1937
  ] })
1929
- ] }) : /* @__PURE__ */ u(_, { children: [
1938
+ ] }) : /* @__PURE__ */ h(_, { children: [
1930
1939
  /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1931
- t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1940
+ t && t.length > 0 && /* @__PURE__ */ h("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1932
1941
  "Required permissions: ",
1933
1942
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
1934
1943
  ] })
@@ -1950,17 +1959,17 @@ function Ir({
1950
1959
  requiredPermissions: r,
1951
1960
  requireAllPermissions: i = !1
1952
1961
  }) {
1953
- const { hasValidSession: o, sessionManager: a, hasPermission: c, hasAnyPermission: m, hasAllPermissions: y } = he();
1962
+ const { hasValidSession: o, sessionManager: a, hasPermission: d, hasAnyPermission: c, hasAllPermissions: y } = he();
1954
1963
  if (!o())
1955
1964
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
1956
- const f = a.getUser();
1957
- if (!f)
1965
+ const g = a.getUser();
1966
+ if (!g)
1958
1967
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
1959
- if (t && !Dt(f.userType, t))
1960
- return /* @__PURE__ */ s(Ke, { userType: f.userType, minUserType: t });
1961
- if (r && r.length > 0 && !(i ? y(r) : m(r))) {
1962
- const g = r.filter((T) => !c(T)).map((T) => typeof T == "string" ? T : T.name);
1963
- return /* @__PURE__ */ s(Ke, { missingPermissions: g });
1968
+ if (t && !Dt(g.userType, t))
1969
+ return /* @__PURE__ */ s(Ke, { userType: g.userType, minUserType: t });
1970
+ if (r && r.length > 0 && !(i ? y(r) : c(r))) {
1971
+ const m = r.filter((T) => !d(T)).map((T) => typeof T == "string" ? T : T.name);
1972
+ return /* @__PURE__ */ s(Ke, { missingPermissions: m });
1964
1973
  }
1965
1974
  return /* @__PURE__ */ s(_, { children: n });
1966
1975
  }
@@ -1977,7 +1986,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
1977
1986
  backgroundColor: "#f9fafb",
1978
1987
  textAlign: "center"
1979
1988
  },
1980
- children: /* @__PURE__ */ u(
1989
+ children: /* @__PURE__ */ h(
1981
1990
  "div",
1982
1991
  {
1983
1992
  style: {
@@ -1991,7 +2000,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
1991
2000
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1992
2001
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1993
2002
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1994
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2003
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1995
2004
  "Redirecting to ",
1996
2005
  n,
1997
2006
  "..."
@@ -2017,7 +2026,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
2017
2026
  backgroundColor: "#f9fafb",
2018
2027
  textAlign: "center"
2019
2028
  },
2020
- children: /* @__PURE__ */ u(
2029
+ children: /* @__PURE__ */ h(
2021
2030
  "div",
2022
2031
  {
2023
2032
  style: {
@@ -2030,19 +2039,19 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
2030
2039
  children: [
2031
2040
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
2032
2041
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
2033
- e && n ? /* @__PURE__ */ u(_, { children: [
2034
- /* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
2042
+ e && n ? /* @__PURE__ */ h(_, { children: [
2043
+ /* @__PURE__ */ h("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
2035
2044
  "This page requires ",
2036
2045
  /* @__PURE__ */ s("strong", { children: e }),
2037
2046
  " access."
2038
2047
  ] }),
2039
- /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2048
+ /* @__PURE__ */ h("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2040
2049
  "Your current user type: ",
2041
2050
  /* @__PURE__ */ s("strong", { children: n })
2042
2051
  ] })
2043
- ] }) : /* @__PURE__ */ u(_, { children: [
2052
+ ] }) : /* @__PURE__ */ h(_, { children: [
2044
2053
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
2045
- t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2054
+ t && t.length > 0 && /* @__PURE__ */ h("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2046
2055
  "Required permissions: ",
2047
2056
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
2048
2057
  ] })
@@ -2051,7 +2060,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
2051
2060
  }
2052
2061
  )
2053
2062
  }
2054
- ), Bt = (n, e) => n === e;
2063
+ ), $t = (n, e) => n === e;
2055
2064
  function Mr({
2056
2065
  children: n,
2057
2066
  redirectTo: e = "/login",
@@ -2060,34 +2069,34 @@ function Mr({
2060
2069
  requireAllPermissions: i = !1,
2061
2070
  fallback: o
2062
2071
  }) {
2063
- const { hasValidSession: a, sessionManager: c, hasPermission: m, hasAnyPermission: y, hasAllPermissions: f } = he(), F = xe();
2072
+ const { hasValidSession: a, sessionManager: d, hasPermission: c, hasAnyPermission: y, hasAllPermissions: g } = he(), F = xe();
2064
2073
  if (ne(() => {
2065
2074
  process.env.NODE_ENV === "development" && console.warn(
2066
2075
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
2067
2076
  );
2068
2077
  }, []), !a())
2069
- return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ u(_, { children: [
2078
+ return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ h(_, { children: [
2070
2079
  /* @__PURE__ */ s(Ut, { redirectPath: e }),
2071
2080
  /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 })
2072
2081
  ] });
2073
- const g = c.getUser();
2074
- if (!g)
2082
+ const m = d.getUser();
2083
+ if (!m)
2075
2084
  return /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 });
2076
- if (t && !Bt(g.userType, t))
2085
+ if (t && !$t(m.userType, t))
2077
2086
  return /* @__PURE__ */ s(
2078
2087
  Qe,
2079
2088
  {
2080
- userType: g.userType,
2089
+ userType: m.userType,
2081
2090
  requiredUserType: t
2082
2091
  }
2083
2092
  );
2084
- if (r && r.length > 0 && !(i ? f(r) : y(r))) {
2085
- const A = r.filter((L) => !m(L)).map((L) => typeof L == "string" ? L : L.name);
2093
+ if (r && r.length > 0 && !(i ? g(r) : y(r))) {
2094
+ const A = r.filter((L) => !c(L)).map((L) => typeof L == "string" ? L : L.name);
2086
2095
  return /* @__PURE__ */ s(Qe, { missingPermissions: A });
2087
2096
  }
2088
2097
  return /* @__PURE__ */ s(_, { children: n });
2089
2098
  }
2090
- const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
2099
+ const Bt = ({ redirectPath: n }) => /* @__PURE__ */ s(
2091
2100
  "div",
2092
2101
  {
2093
2102
  style: {
@@ -2100,7 +2109,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
2100
2109
  backgroundColor: "#f9fafb",
2101
2110
  textAlign: "center"
2102
2111
  },
2103
- children: /* @__PURE__ */ u(
2112
+ children: /* @__PURE__ */ h(
2104
2113
  "div",
2105
2114
  {
2106
2115
  style: {
@@ -2114,7 +2123,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
2114
2123
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
2115
2124
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
2116
2125
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
2117
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2126
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2118
2127
  "Redirecting to ",
2119
2128
  n,
2120
2129
  "..."
@@ -2130,8 +2139,8 @@ function Lr({ children: n, redirectTo: e = "/", fallback: t }) {
2130
2139
  process.env.NODE_ENV === "development" && console.warn(
2131
2140
  "[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
2132
2141
  );
2133
- }, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
2134
- /* @__PURE__ */ s($t, { redirectPath: e }),
2142
+ }, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ h(_, { children: [
2143
+ /* @__PURE__ */ s(Bt, { redirectPath: e }),
2135
2144
  /* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
2136
2145
  ] });
2137
2146
  }
@@ -2148,7 +2157,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2148
2157
  backgroundColor: "#f9fafb",
2149
2158
  textAlign: "center"
2150
2159
  },
2151
- children: /* @__PURE__ */ u(
2160
+ children: /* @__PURE__ */ h(
2152
2161
  "div",
2153
2162
  {
2154
2163
  style: {
@@ -2162,7 +2171,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2162
2171
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
2163
2172
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
2164
2173
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
2165
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2174
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2166
2175
  "Redirecting to ",
2167
2176
  n,
2168
2177
  "..."
@@ -2178,7 +2187,7 @@ function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
2178
2187
  process.env.NODE_ENV === "development" && console.warn(
2179
2188
  "[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
2180
2189
  );
2181
- }, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
2190
+ }, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ h(_, { children: [
2182
2191
  /* @__PURE__ */ s(Ct, { redirectPath: e }),
2183
2192
  /* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
2184
2193
  ] }) : /* @__PURE__ */ s(_, { children: n });
@@ -2214,16 +2223,16 @@ const ue = ({
2214
2223
  userType: i,
2215
2224
  requiredPermissions: o,
2216
2225
  requireAllPermissions: a = !0,
2217
- returnTo: c,
2218
- onAccessDenied: m,
2226
+ returnTo: d,
2227
+ onAccessDenied: c,
2219
2228
  redirectTo: y,
2220
- loadingFallback: f,
2229
+ loadingFallback: g,
2221
2230
  accessDeniedFallback: F
2222
2231
  }) => {
2223
- const g = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: d } = Te(), v = Ft(), N = Z(() => {
2232
+ const m = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: u } = Te(), v = Ft(), N = Z(() => {
2224
2233
  if (e)
2225
2234
  return v.presets[e];
2226
- }, [e, v.presets]), B = Z(
2235
+ }, [e, v.presets]), $ = Z(
2227
2236
  () => ({
2228
2237
  tenant: t ?? (N == null ? void 0 : N.tenant),
2229
2238
  auth: r ?? (N == null ? void 0 : N.auth),
@@ -2238,7 +2247,7 @@ const ue = ({
2238
2247
  isAuthenticated: T,
2239
2248
  userType: L == null ? void 0 : L.userType,
2240
2249
  permissions: M,
2241
- isLoading: A || d
2250
+ isLoading: A || u
2242
2251
  }),
2243
2252
  [
2244
2253
  P,
@@ -2246,15 +2255,15 @@ const ue = ({
2246
2255
  L == null ? void 0 : L.userType,
2247
2256
  M,
2248
2257
  A,
2249
- d
2258
+ u
2250
2259
  ]
2251
- ), R = Z(() => w.isLoading ? null : Ot(B, w), [B, w]), k = Z(() => R ? y || qt(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = Z(() => !R || !k ? null : {
2260
+ ), R = Z(() => w.isLoading ? null : Ot($, w), [$, w]), k = Z(() => R ? y || qt(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = Z(() => !R || !k ? null : {
2252
2261
  type: R,
2253
2262
  required: {
2254
- tenant: B.tenant,
2255
- auth: B.auth,
2256
- userType: B.userType,
2257
- permissions: B.permissions
2263
+ tenant: $.tenant,
2264
+ auth: $.auth,
2265
+ userType: $.userType,
2266
+ permissions: $.permissions
2258
2267
  },
2259
2268
  current: {
2260
2269
  hasTenant: w.hasTenant,
@@ -2263,34 +2272,34 @@ const ue = ({
2263
2272
  permissions: w.permissions
2264
2273
  },
2265
2274
  redirectTo: k
2266
- }, [R, k, B, w]);
2275
+ }, [R, k, $, w]);
2267
2276
  if (ne(() => {
2268
- I && (m ? m(I) : v.onAccessDenied && v.onAccessDenied(I));
2269
- }, [I, m, v]), ne(() => {
2270
- I && c && zt(c, g.pathname + g.search, v.returnToStorage);
2277
+ I && (c ? c(I) : v.onAccessDenied && v.onAccessDenied(I));
2278
+ }, [I, c, v]), ne(() => {
2279
+ I && d && zt(d, m.pathname + m.search, v.returnToStorage);
2271
2280
  }, [
2272
2281
  I,
2273
- c,
2274
- g.pathname,
2275
- g.search,
2282
+ d,
2283
+ m.pathname,
2284
+ m.search,
2276
2285
  v.returnToStorage
2277
2286
  ]), w.isLoading)
2278
- return /* @__PURE__ */ s(_, { children: f ?? v.loadingFallback ?? null });
2287
+ return /* @__PURE__ */ s(_, { children: g ?? v.loadingFallback ?? null });
2279
2288
  if (I && k) {
2280
2289
  const l = F ?? v.accessDeniedFallback;
2281
2290
  if (l)
2282
2291
  return /* @__PURE__ */ s(_, { children: l });
2283
2292
  const z = _t(
2284
2293
  k,
2285
- c,
2286
- g.pathname + g.search,
2294
+ d,
2295
+ m.pathname + m.search,
2287
2296
  v.returnToParam,
2288
2297
  v.returnToStorage
2289
2298
  );
2290
2299
  return /* @__PURE__ */ s(Se, { to: z, replace: !0 });
2291
2300
  }
2292
2301
  return /* @__PURE__ */ s(_, { children: n });
2293
- }, Fr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(ue, { auth: "required", ...n }), Br = (n) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...n }), $r = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...n }), Hr = (n) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...n }), Or = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...n }), qr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...n }), _r = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...n }), Vt = () => /* @__PURE__ */ u(
2302
+ }, Fr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(ue, { auth: "required", ...n }), $r = (n) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...n }), Br = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...n }), Hr = (n) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...n }), Or = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...n }), qr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...n }), _r = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...n }), Vt = () => /* @__PURE__ */ h(
2294
2303
  "div",
2295
2304
  {
2296
2305
  style: {
@@ -2313,8 +2322,8 @@ function zr({
2313
2322
  allowedPlans: t,
2314
2323
  requiredFeature: r
2315
2324
  }) {
2316
- const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: c } = Nt();
2317
- return c ? /* @__PURE__ */ s(
2325
+ const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: d } = Nt();
2326
+ return d ? /* @__PURE__ */ s(
2318
2327
  "div",
2319
2328
  {
2320
2329
  style: {
@@ -2326,7 +2335,7 @@ function zr({
2326
2335
  }
2327
2336
  ) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : r && !a(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: n }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
2328
2337
  }
2329
- const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
2338
+ const Wt = ({ flagName: n }) => /* @__PURE__ */ h(
2330
2339
  "div",
2331
2340
  {
2332
2341
  style: {
@@ -2345,7 +2354,7 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
2345
2354
  children: [
2346
2355
  /* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
2347
2356
  /* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
2348
- /* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2357
+ /* @__PURE__ */ h("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2349
2358
  'Feature flag "',
2350
2359
  n,
2351
2360
  '" is disabled'
@@ -2370,7 +2379,7 @@ function Vr({ name: n, children: e, fallback: t }) {
2370
2379
  }
2371
2380
  ) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Wt, { flagName: n }) });
2372
2381
  }
2373
- const jt = () => /* @__PURE__ */ u(
2382
+ const jt = () => /* @__PURE__ */ h(
2374
2383
  "svg",
2375
2384
  {
2376
2385
  width: "16",
@@ -2387,7 +2396,7 @@ const jt = () => /* @__PURE__ */ u(
2387
2396
  /* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
2388
2397
  ]
2389
2398
  }
2390
- ), Gt = () => /* @__PURE__ */ u(
2399
+ ), Gt = () => /* @__PURE__ */ h(
2391
2400
  "svg",
2392
2401
  {
2393
2402
  width: "16",
@@ -2543,44 +2552,44 @@ function Wr({
2543
2552
  onError: i,
2544
2553
  onForgotPassword: o,
2545
2554
  onSignupClick: a,
2546
- onMagicLinkClick: c,
2547
- showForgotPassword: m = !0,
2555
+ onMagicLinkClick: d,
2556
+ showForgotPassword: c = !0,
2548
2557
  showSignupLink: y = !0,
2549
- showMagicLinkOption: f = !0,
2558
+ showMagicLinkOption: g = !0,
2550
2559
  className: F
2551
2560
  }) {
2552
- const [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Qt, ...n }, l = { ...Zt, ...e }, z = { ...Kt, ...t }, D = () => {
2553
- const h = {};
2554
- return g.trim() || (h.username = !0), A.trim() || (h.password = !0), R(h), Object.keys(h).length === 0;
2555
- }, p = async (h) => {
2556
- if (h.preventDefault(), !!D()) {
2557
- v(!0), B("");
2561
+ const [m, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [u, v] = x(!1), [N, $] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Qt, ...n }, l = { ...Zt, ...e }, z = { ...Kt, ...t }, D = () => {
2562
+ const p = {};
2563
+ return m.trim() || (p.username = !0), A.trim() || (p.password = !0), R(p), Object.keys(p).length === 0;
2564
+ }, f = async (p) => {
2565
+ if (p.preventDefault(), !!D()) {
2566
+ v(!0), $("");
2558
2567
  try {
2559
2568
  const S = await k({
2560
- username: g,
2569
+ username: m,
2561
2570
  password: A
2562
2571
  // tenantId inferred from context automatically
2563
2572
  });
2564
2573
  r == null || r(S);
2565
2574
  } catch (S) {
2566
2575
  const E = S.message || I.errorMessage;
2567
- B(E), i == null || i(E);
2576
+ $(E), i == null || i(E);
2568
2577
  } finally {
2569
2578
  v(!1);
2570
2579
  }
2571
2580
  }
2572
- }, U = (h) => ({
2581
+ }, U = (p) => ({
2573
2582
  ...l.input,
2574
- ...w[h] ? l.inputError : {}
2583
+ ...w[p] ? l.inputError : {}
2575
2584
  }), b = () => ({
2576
2585
  ...l.button,
2577
- ...d ? l.buttonLoading : {},
2578
- ...!g || !A || d ? l.buttonDisabled : {}
2586
+ ...u ? l.buttonLoading : {},
2587
+ ...!m || !A || u ? l.buttonDisabled : {}
2579
2588
  });
2580
- return /* @__PURE__ */ u("div", { className: F, style: l.container, children: [
2589
+ return /* @__PURE__ */ h("div", { className: F, style: l.container, children: [
2581
2590
  /* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
2582
- /* @__PURE__ */ u("form", { onSubmit: p, style: l.form, children: [
2583
- /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2591
+ /* @__PURE__ */ h("form", { onSubmit: f, style: l.form, children: [
2592
+ /* @__PURE__ */ h("div", { style: l.fieldGroup, children: [
2584
2593
  /* @__PURE__ */ s("label", { style: l.label, children: I.usernameLabel }),
2585
2594
  /* @__PURE__ */ s(
2586
2595
  "input",
@@ -2588,19 +2597,19 @@ function Wr({
2588
2597
  id: "username",
2589
2598
  name: "username",
2590
2599
  type: "text",
2591
- value: g,
2592
- onChange: (h) => {
2593
- T(h.target.value), w.username && R((S) => ({ ...S, username: !1 }));
2600
+ value: m,
2601
+ onChange: (p) => {
2602
+ T(p.target.value), w.username && R((S) => ({ ...S, username: !1 }));
2594
2603
  },
2595
2604
  placeholder: I.usernamePlaceholder,
2596
2605
  style: U("username"),
2597
- disabled: d
2606
+ disabled: u
2598
2607
  }
2599
2608
  )
2600
2609
  ] }),
2601
- /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2610
+ /* @__PURE__ */ h("div", { style: l.fieldGroup, children: [
2602
2611
  /* @__PURE__ */ s("label", { style: l.label, children: I.passwordLabel }),
2603
- /* @__PURE__ */ u("div", { style: l.inputContainer, children: [
2612
+ /* @__PURE__ */ h("div", { style: l.inputContainer, children: [
2604
2613
  /* @__PURE__ */ s(
2605
2614
  "input",
2606
2615
  {
@@ -2608,15 +2617,15 @@ function Wr({
2608
2617
  name: "password",
2609
2618
  type: M ? "text" : "password",
2610
2619
  value: A,
2611
- onChange: (h) => {
2612
- L(h.target.value), w.password && R((S) => ({ ...S, password: !1 }));
2620
+ onChange: (p) => {
2621
+ L(p.target.value), w.password && R((S) => ({ ...S, password: !1 }));
2613
2622
  },
2614
2623
  placeholder: I.passwordPlaceholder,
2615
2624
  style: {
2616
2625
  ...U("password"),
2617
2626
  ...l.inputWithIcon
2618
2627
  },
2619
- disabled: d
2628
+ disabled: u
2620
2629
  }
2621
2630
  ),
2622
2631
  /* @__PURE__ */ s(
@@ -2625,29 +2634,29 @@ function Wr({
2625
2634
  type: "button",
2626
2635
  onClick: () => P(!M),
2627
2636
  style: l.passwordToggle,
2628
- disabled: d,
2637
+ disabled: u,
2629
2638
  "aria-label": M ? I.hidePasswordAriaLabel : I.showPasswordAriaLabel,
2630
2639
  children: M ? z.hidePassword : z.showPassword
2631
2640
  }
2632
2641
  )
2633
2642
  ] })
2634
2643
  ] }),
2635
- /* @__PURE__ */ s("button", { type: "submit", disabled: !g || !A || d, style: b(), children: d ? I.loadingText : I.submitButton }),
2644
+ /* @__PURE__ */ s("button", { type: "submit", disabled: !m || !A || u, style: b(), children: u ? I.loadingText : I.submitButton }),
2636
2645
  N && /* @__PURE__ */ s("div", { style: l.errorText, children: N })
2637
2646
  ] }),
2638
- (m || y || f) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2639
- f && /* @__PURE__ */ u("div", { children: [
2640
- /* @__PURE__ */ u("span", { style: l.divider, children: [
2647
+ (c || y || g) && /* @__PURE__ */ h("div", { style: l.linkContainer, children: [
2648
+ g && /* @__PURE__ */ h("div", { children: [
2649
+ /* @__PURE__ */ h("span", { style: l.divider, children: [
2641
2650
  I.magicLinkText,
2642
2651
  " "
2643
2652
  ] }),
2644
- /* @__PURE__ */ s("a", { onClick: c, style: l.link, children: I.magicLinkLink })
2653
+ /* @__PURE__ */ s("a", { onClick: d, style: l.link, children: I.magicLinkLink })
2645
2654
  ] }),
2646
- f && (m || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2647
- m && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
2648
- m && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2649
- y && /* @__PURE__ */ u("div", { children: [
2650
- /* @__PURE__ */ u("span", { style: l.divider, children: [
2655
+ g && (c || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2656
+ c && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
2657
+ c && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2658
+ y && /* @__PURE__ */ h("div", { children: [
2659
+ /* @__PURE__ */ h("span", { style: l.divider, children: [
2651
2660
  I.signupText,
2652
2661
  " "
2653
2662
  ] }),
@@ -2798,44 +2807,44 @@ function jr({
2798
2807
  onError: i,
2799
2808
  onLoginClick: o,
2800
2809
  onMagicLinkClick: a,
2801
- showLoginLink: c = !0,
2802
- showMagicLinkOption: m = !0,
2810
+ showLoginLink: d = !0,
2811
+ showMagicLinkOption: c = !0,
2803
2812
  className: y
2804
2813
  }) {
2805
2814
  var V;
2806
- const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(""), [d, v] = x(""), [N, B] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [D, p] = x({}), { signup: U, signupTenantAdmin: b } = he(), h = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Jt, ...n }, E = { ...Yt, ...e }, K = () => {
2815
+ const [g, F] = x(""), [m, T] = x(""), [A, L] = x(""), [M, P] = x(""), [u, v] = x(""), [N, $] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [D, f] = x({}), { signup: U, signupTenantAdmin: b } = he(), p = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Jt, ...n }, E = { ...Yt, ...e }, K = () => {
2807
2816
  const H = {};
2808
- return f.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), d.trim() || (H.password = !0), N.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), p(H), Object.keys(H).length === 0;
2817
+ return g.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), u.trim() || (H.password = !0), N.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), f(H), Object.keys(H).length === 0;
2809
2818
  }, G = async (H) => {
2810
2819
  if (H.preventDefault(), !!K()) {
2811
- if (d !== N) {
2812
- z(S.passwordMismatchError), p({ confirmPassword: !0 });
2820
+ if (u !== N) {
2821
+ z(S.passwordMismatchError), f({ confirmPassword: !0 });
2813
2822
  return;
2814
2823
  }
2815
- if (t === "user" && !(h != null && h.id)) {
2824
+ if (t === "user" && !(p != null && p.id)) {
2816
2825
  z(S.tenantNotFoundError);
2817
2826
  return;
2818
2827
  }
2819
2828
  I(!0), z("");
2820
2829
  try {
2821
- let $;
2822
- t === "tenant" ? $ = await b({
2830
+ let B;
2831
+ t === "tenant" ? B = await b({
2823
2832
  email: A || void 0,
2824
2833
  phoneNumber: M || void 0,
2825
- name: f,
2826
- password: d,
2834
+ name: g,
2835
+ password: u,
2827
2836
  tenantName: w,
2828
- lastName: g || void 0
2829
- }) : $ = await U({
2837
+ lastName: m || void 0
2838
+ }) : B = await U({
2830
2839
  email: A || void 0,
2831
2840
  phoneNumber: M || void 0,
2832
- name: f,
2833
- password: d,
2834
- tenantId: h.id,
2835
- lastName: g || void 0
2836
- }), r == null || r($);
2837
- } catch ($) {
2838
- const ce = $.message || S.errorMessage;
2841
+ name: g,
2842
+ password: u,
2843
+ tenantId: p.id,
2844
+ lastName: m || void 0
2845
+ }), r == null || r(B);
2846
+ } catch (B) {
2847
+ const ce = B.message || S.errorMessage;
2839
2848
  z(ce), i == null || i(ce);
2840
2849
  } finally {
2841
2850
  I(!1);
@@ -2847,12 +2856,12 @@ function jr({
2847
2856
  }), W = () => ({
2848
2857
  ...E.button,
2849
2858
  ...k ? E.buttonLoading : {},
2850
- ...!f || !A && !M || !d || !N || k || t === "tenant" && !w ? E.buttonDisabled : {}
2851
- }), q = f && (A || M) && d && N && (t === "user" || w);
2852
- return /* @__PURE__ */ u("div", { className: y, style: E.container, children: [
2859
+ ...!g || !A && !M || !u || !N || k || t === "tenant" && !w ? E.buttonDisabled : {}
2860
+ }), q = g && (A || M) && u && N && (t === "user" || w);
2861
+ return /* @__PURE__ */ h("div", { className: y, style: E.container, children: [
2853
2862
  /* @__PURE__ */ s("h2", { style: E.title, children: S.title }),
2854
- /* @__PURE__ */ u("form", { onSubmit: G, style: E.form, children: [
2855
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2863
+ /* @__PURE__ */ h("form", { onSubmit: G, style: E.form, children: [
2864
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2856
2865
  /* @__PURE__ */ s("label", { style: E.label, children: S.nameLabel }),
2857
2866
  /* @__PURE__ */ s(
2858
2867
  "input",
@@ -2860,9 +2869,9 @@ function jr({
2860
2869
  id: "name",
2861
2870
  name: "name",
2862
2871
  type: "text",
2863
- value: f,
2872
+ value: g,
2864
2873
  onChange: (H) => {
2865
- F(H.target.value), D.name && p(($) => ({ ...$, name: !1 }));
2874
+ F(H.target.value), D.name && f((B) => ({ ...B, name: !1 }));
2866
2875
  },
2867
2876
  placeholder: S.namePlaceholder,
2868
2877
  style: X("name"),
@@ -2870,7 +2879,7 @@ function jr({
2870
2879
  }
2871
2880
  )
2872
2881
  ] }),
2873
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2882
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2874
2883
  /* @__PURE__ */ s("label", { style: E.label, children: S.lastNameLabel }),
2875
2884
  /* @__PURE__ */ s(
2876
2885
  "input",
@@ -2878,7 +2887,7 @@ function jr({
2878
2887
  id: "lastName",
2879
2888
  name: "lastName",
2880
2889
  type: "text",
2881
- value: g,
2890
+ value: m,
2882
2891
  onChange: (H) => T(H.target.value),
2883
2892
  placeholder: S.lastNamePlaceholder,
2884
2893
  style: E.input,
@@ -2886,7 +2895,7 @@ function jr({
2886
2895
  }
2887
2896
  )
2888
2897
  ] }),
2889
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2898
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2890
2899
  /* @__PURE__ */ s("label", { style: E.label, children: S.emailLabel }),
2891
2900
  /* @__PURE__ */ s(
2892
2901
  "input",
@@ -2896,7 +2905,7 @@ function jr({
2896
2905
  type: "email",
2897
2906
  value: A,
2898
2907
  onChange: (H) => {
2899
- L(H.target.value), D.email && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
2908
+ L(H.target.value), D.email && f((B) => ({ ...B, email: !1, phoneNumber: !1 }));
2900
2909
  },
2901
2910
  placeholder: S.emailPlaceholder,
2902
2911
  style: X("email"),
@@ -2904,7 +2913,7 @@ function jr({
2904
2913
  }
2905
2914
  )
2906
2915
  ] }),
2907
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2916
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2908
2917
  /* @__PURE__ */ s("label", { style: E.label, children: S.phoneNumberLabel }),
2909
2918
  /* @__PURE__ */ s(
2910
2919
  "input",
@@ -2914,7 +2923,7 @@ function jr({
2914
2923
  type: "tel",
2915
2924
  value: M,
2916
2925
  onChange: (H) => {
2917
- P(H.target.value), D.phoneNumber && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
2926
+ P(H.target.value), D.phoneNumber && f((B) => ({ ...B, email: !1, phoneNumber: !1 }));
2918
2927
  },
2919
2928
  placeholder: S.phoneNumberPlaceholder,
2920
2929
  style: X("phoneNumber"),
@@ -2923,7 +2932,7 @@ function jr({
2923
2932
  )
2924
2933
  ] }),
2925
2934
  /* @__PURE__ */ s("div", { style: E.hintText, children: S.contactMethodHint }),
2926
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2935
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2927
2936
  /* @__PURE__ */ s("label", { style: E.label, children: S.passwordLabel }),
2928
2937
  /* @__PURE__ */ s(
2929
2938
  "input",
@@ -2931,9 +2940,9 @@ function jr({
2931
2940
  id: "password",
2932
2941
  name: "password",
2933
2942
  type: "password",
2934
- value: d,
2943
+ value: u,
2935
2944
  onChange: (H) => {
2936
- v(H.target.value), D.password && p(($) => ({ ...$, password: !1 }));
2945
+ v(H.target.value), D.password && f((B) => ({ ...B, password: !1 }));
2937
2946
  },
2938
2947
  placeholder: S.passwordPlaceholder,
2939
2948
  style: X("password"),
@@ -2941,7 +2950,7 @@ function jr({
2941
2950
  }
2942
2951
  )
2943
2952
  ] }),
2944
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2953
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2945
2954
  /* @__PURE__ */ s("label", { style: E.label, children: S.confirmPasswordLabel }),
2946
2955
  /* @__PURE__ */ s(
2947
2956
  "input",
@@ -2951,7 +2960,7 @@ function jr({
2951
2960
  type: "password",
2952
2961
  value: N,
2953
2962
  onChange: (H) => {
2954
- B(H.target.value), D.confirmPassword && p(($) => ({ ...$, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
2963
+ $(H.target.value), D.confirmPassword && f((B) => ({ ...B, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
2955
2964
  },
2956
2965
  placeholder: S.confirmPasswordPlaceholder,
2957
2966
  style: X("confirmPassword"),
@@ -2959,7 +2968,7 @@ function jr({
2959
2968
  }
2960
2969
  )
2961
2970
  ] }),
2962
- t === "tenant" && /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2971
+ t === "tenant" && /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2963
2972
  /* @__PURE__ */ s("label", { style: E.label, children: S.tenantNameLabel }),
2964
2973
  /* @__PURE__ */ s(
2965
2974
  "input",
@@ -2969,7 +2978,7 @@ function jr({
2969
2978
  type: "text",
2970
2979
  value: w,
2971
2980
  onChange: (H) => {
2972
- R(H.target.value), D.tenantName && p(($) => ({ ...$, tenantName: !1 }));
2981
+ R(H.target.value), D.tenantName && f((B) => ({ ...B, tenantName: !1 }));
2973
2982
  },
2974
2983
  placeholder: S.tenantNamePlaceholder,
2975
2984
  style: X("tenantName"),
@@ -2980,17 +2989,17 @@ function jr({
2980
2989
  /* @__PURE__ */ s("button", { type: "submit", disabled: !q || k, style: W(), children: k ? S.loadingText : S.submitButton }),
2981
2990
  l && /* @__PURE__ */ s("div", { style: E.errorText, children: l })
2982
2991
  ] }),
2983
- (c || m) && /* @__PURE__ */ u("div", { style: E.linkContainer, children: [
2984
- m && /* @__PURE__ */ u("div", { children: [
2985
- /* @__PURE__ */ u("span", { style: E.divider, children: [
2992
+ (d || c) && /* @__PURE__ */ h("div", { style: E.linkContainer, children: [
2993
+ c && /* @__PURE__ */ h("div", { children: [
2994
+ /* @__PURE__ */ h("span", { style: E.divider, children: [
2986
2995
  S.magicLinkText,
2987
2996
  " "
2988
2997
  ] }),
2989
2998
  /* @__PURE__ */ s("a", { onClick: a, style: E.link, children: S.magicLinkLink })
2990
2999
  ] }),
2991
- m && c && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
2992
- c && /* @__PURE__ */ u("div", { children: [
2993
- /* @__PURE__ */ u("span", { style: E.divider, children: [
3000
+ c && d && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
3001
+ d && /* @__PURE__ */ h("div", { children: [
3002
+ /* @__PURE__ */ h("span", { style: E.divider, children: [
2994
3003
  S.loginText,
2995
3004
  " "
2996
3005
  ] }),
@@ -3154,123 +3163,123 @@ function Gr({
3154
3163
  onLoginClick: i,
3155
3164
  onSignupClick: o,
3156
3165
  showTraditionalLinks: a = !0,
3157
- className: c,
3158
- verifyToken: m,
3166
+ className: d,
3167
+ verifyToken: c,
3159
3168
  frontendUrl: y
3160
3169
  }) {
3161
3170
  var W;
3162
- const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: D, verifyMagicLink: p } = he(), U = ((W = pe()) == null ? void 0 : W.tenant) ?? null, b = { ...Xt, ...n }, h = { ...er, ...e };
3171
+ const [g, F] = x(""), [m, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [u, v] = x(!1), [N, $] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: D, verifyMagicLink: f } = he(), U = ((W = pe()) == null ? void 0 : W.tenant) ?? null, b = { ...Xt, ...n }, p = { ...er, ...e };
3163
3172
  ne(() => {
3164
- m && S(m);
3165
- }, [m]);
3173
+ c && S(c);
3174
+ }, [c]);
3166
3175
  const S = async (q) => {
3167
- if (!U || !f) {
3168
- B(b.missingTenantOrEmailError);
3176
+ if (!U || !g) {
3177
+ $(b.missingTenantOrEmailError);
3169
3178
  return;
3170
3179
  }
3171
- v(!0), B("");
3180
+ v(!0), $("");
3172
3181
  try {
3173
- const V = await p({
3182
+ const V = await f({
3174
3183
  token: q,
3175
- email: f
3184
+ email: g
3176
3185
  // tenantId inferred from context automatically
3177
3186
  });
3178
3187
  t == null || t(V);
3179
3188
  } catch (V) {
3180
3189
  const H = V.message || "Failed to verify magic link";
3181
- B(H), r == null || r(H);
3190
+ $(H), r == null || r(H);
3182
3191
  } finally {
3183
3192
  v(!1);
3184
3193
  }
3185
3194
  }, E = () => {
3186
3195
  const q = {};
3187
- return f.trim() || (q.email = !0), l && !g.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
3196
+ return g.trim() || (q.email = !0), l && !m.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
3188
3197
  }, K = async (q) => {
3189
3198
  if (q.preventDefault(), !!E()) {
3190
3199
  if (!(U != null && U.id)) {
3191
- B(b.tenantNotFoundError);
3200
+ $(b.tenantNotFoundError);
3192
3201
  return;
3193
3202
  }
3194
- P(!0), B(""), R("");
3203
+ P(!0), $(""), R("");
3195
3204
  try {
3196
3205
  const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
3197
- email: f,
3206
+ email: g,
3198
3207
  tenantId: U.id,
3199
3208
  frontendUrl: V,
3200
- name: l ? g : void 0,
3209
+ name: l ? m : void 0,
3201
3210
  lastName: l ? A : void 0
3202
3211
  });
3203
3212
  R(b.successMessage), t == null || t(H);
3204
3213
  } catch (V) {
3205
3214
  const H = V.message || b.errorMessage;
3206
- B(H), r == null || r(H);
3215
+ $(H), r == null || r(H);
3207
3216
  } finally {
3208
3217
  P(!1);
3209
3218
  }
3210
3219
  }
3211
3220
  }, G = (q) => ({
3212
- ...h.input,
3213
- ...k[q] ? h.inputError : {}
3221
+ ...p.input,
3222
+ ...k[q] ? p.inputError : {}
3214
3223
  }), X = () => ({
3215
- ...h.button,
3216
- ...M || d ? h.buttonLoading : {},
3217
- ...!f || M || d ? h.buttonDisabled : {}
3224
+ ...p.button,
3225
+ ...M || u ? p.buttonLoading : {},
3226
+ ...!g || M || u ? p.buttonDisabled : {}
3218
3227
  });
3219
- return d ? /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
3220
- /* @__PURE__ */ s("h2", { style: h.title, children: b.verifyingText }),
3221
- /* @__PURE__ */ s("div", { style: h.verifyingContainer, children: /* @__PURE__ */ s("div", { style: h.verifyingText, children: b.verifyingDescription }) })
3222
- ] }) : /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
3223
- /* @__PURE__ */ s("h2", { style: h.title, children: b.title }),
3224
- /* @__PURE__ */ s("p", { style: h.description, children: b.description }),
3225
- /* @__PURE__ */ u("form", { onSubmit: K, style: h.form, children: [
3226
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3227
- /* @__PURE__ */ s("label", { style: h.label, children: b.emailLabel }),
3228
+ return u ? /* @__PURE__ */ h("div", { className: d, style: p.container, children: [
3229
+ /* @__PURE__ */ s("h2", { style: p.title, children: b.verifyingText }),
3230
+ /* @__PURE__ */ s("div", { style: p.verifyingContainer, children: /* @__PURE__ */ s("div", { style: p.verifyingText, children: b.verifyingDescription }) })
3231
+ ] }) : /* @__PURE__ */ h("div", { className: d, style: p.container, children: [
3232
+ /* @__PURE__ */ s("h2", { style: p.title, children: b.title }),
3233
+ /* @__PURE__ */ s("p", { style: p.description, children: b.description }),
3234
+ /* @__PURE__ */ h("form", { onSubmit: K, style: p.form, children: [
3235
+ /* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
3236
+ /* @__PURE__ */ s("label", { style: p.label, children: b.emailLabel }),
3228
3237
  /* @__PURE__ */ s(
3229
3238
  "input",
3230
3239
  {
3231
3240
  id: "email",
3232
3241
  name: "email",
3233
3242
  type: "email",
3234
- value: f,
3243
+ value: g,
3235
3244
  onChange: (q) => {
3236
3245
  F(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
3237
3246
  },
3238
3247
  placeholder: b.emailPlaceholder,
3239
3248
  style: G("email"),
3240
- disabled: M || d
3249
+ disabled: M || u
3241
3250
  }
3242
3251
  )
3243
3252
  ] }),
3244
- !l && /* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
3253
+ !l && /* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
3245
3254
  "button",
3246
3255
  {
3247
3256
  type: "button",
3248
3257
  onClick: () => z(!0),
3249
- style: h.toggleLink,
3258
+ style: p.toggleLink,
3250
3259
  children: b.showNameToggle
3251
3260
  }
3252
3261
  ) }),
3253
- l && /* @__PURE__ */ u(_, { children: [
3254
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3255
- /* @__PURE__ */ s("label", { style: h.label, children: b.nameLabel }),
3262
+ l && /* @__PURE__ */ h(_, { children: [
3263
+ /* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
3264
+ /* @__PURE__ */ s("label", { style: p.label, children: b.nameLabel }),
3256
3265
  /* @__PURE__ */ s(
3257
3266
  "input",
3258
3267
  {
3259
3268
  id: "name",
3260
3269
  name: "name",
3261
3270
  type: "text",
3262
- value: g,
3271
+ value: m,
3263
3272
  onChange: (q) => {
3264
3273
  T(q.target.value), k.name && I((V) => ({ ...V, name: !1 }));
3265
3274
  },
3266
3275
  placeholder: b.namePlaceholder,
3267
3276
  style: G("name"),
3268
- disabled: M || d
3277
+ disabled: M || u
3269
3278
  }
3270
3279
  )
3271
3280
  ] }),
3272
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3273
- /* @__PURE__ */ s("label", { style: h.label, children: b.lastNameLabel }),
3281
+ /* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
3282
+ /* @__PURE__ */ s("label", { style: p.label, children: b.lastNameLabel }),
3274
3283
  /* @__PURE__ */ s(
3275
3284
  "input",
3276
3285
  {
@@ -3280,42 +3289,42 @@ function Gr({
3280
3289
  value: A,
3281
3290
  onChange: (q) => L(q.target.value),
3282
3291
  placeholder: b.lastNamePlaceholder,
3283
- style: h.input,
3284
- disabled: M || d
3292
+ style: p.input,
3293
+ disabled: M || u
3285
3294
  }
3286
3295
  )
3287
3296
  ] }),
3288
- /* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
3297
+ /* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
3289
3298
  "button",
3290
3299
  {
3291
3300
  type: "button",
3292
3301
  onClick: () => {
3293
3302
  z(!1), T(""), L("");
3294
3303
  },
3295
- style: h.toggleLink,
3304
+ style: p.toggleLink,
3296
3305
  children: b.hideNameToggle
3297
3306
  }
3298
3307
  ) })
3299
3308
  ] }),
3300
- /* @__PURE__ */ s("button", { type: "submit", disabled: !f || M || d, style: X(), children: M ? b.loadingText : b.submitButton }),
3301
- N && /* @__PURE__ */ s("div", { style: h.errorText, children: N }),
3302
- w && /* @__PURE__ */ s("div", { style: h.successText, children: w })
3309
+ /* @__PURE__ */ s("button", { type: "submit", disabled: !g || M || u, style: X(), children: M ? b.loadingText : b.submitButton }),
3310
+ N && /* @__PURE__ */ s("div", { style: p.errorText, children: N }),
3311
+ w && /* @__PURE__ */ s("div", { style: p.successText, children: w })
3303
3312
  ] }),
3304
- a && /* @__PURE__ */ u("div", { style: h.linkContainer, children: [
3305
- /* @__PURE__ */ u("div", { children: [
3306
- /* @__PURE__ */ u("span", { style: h.divider, children: [
3313
+ a && /* @__PURE__ */ h("div", { style: p.linkContainer, children: [
3314
+ /* @__PURE__ */ h("div", { children: [
3315
+ /* @__PURE__ */ h("span", { style: p.divider, children: [
3307
3316
  b.loginText,
3308
3317
  " "
3309
3318
  ] }),
3310
- /* @__PURE__ */ s("a", { onClick: i, style: h.link, children: b.loginLink })
3319
+ /* @__PURE__ */ s("a", { onClick: i, style: p.link, children: b.loginLink })
3311
3320
  ] }),
3312
- /* @__PURE__ */ s("div", { style: h.divider, children: b.dividerBullet }),
3313
- /* @__PURE__ */ u("div", { children: [
3314
- /* @__PURE__ */ u("span", { style: h.divider, children: [
3321
+ /* @__PURE__ */ s("div", { style: p.divider, children: b.dividerBullet }),
3322
+ /* @__PURE__ */ h("div", { children: [
3323
+ /* @__PURE__ */ h("span", { style: p.divider, children: [
3315
3324
  b.signupText,
3316
3325
  " "
3317
3326
  ] }),
3318
- /* @__PURE__ */ s("a", { onClick: o, style: h.link, children: b.signupLink })
3327
+ /* @__PURE__ */ s("a", { onClick: o, style: p.link, children: b.signupLink })
3319
3328
  ] })
3320
3329
  ] })
3321
3330
  ] });
@@ -3422,7 +3431,7 @@ const tr = {
3422
3431
  backButtonHover: {
3423
3432
  backgroundColor: "#e5e7eb"
3424
3433
  }
3425
- }, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ u(
3434
+ }, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ h(
3426
3435
  "svg",
3427
3436
  {
3428
3437
  width: "48",
@@ -3439,7 +3448,7 @@ const tr = {
3439
3448
  /* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
3440
3449
  ]
3441
3450
  }
3442
- ), sr = () => /* @__PURE__ */ u(
3451
+ ), sr = () => /* @__PURE__ */ h(
3443
3452
  "svg",
3444
3453
  {
3445
3454
  width: "48",
@@ -3470,38 +3479,38 @@ function Kr({
3470
3479
  onError: i,
3471
3480
  onRetry: o,
3472
3481
  onBackToLogin: a,
3473
- className: c,
3474
- token: m,
3482
+ className: d,
3483
+ token: c,
3475
3484
  email: y,
3476
- appId: f,
3485
+ appId: g,
3477
3486
  tenantSlug: F,
3478
- autoRedirectDelay: g = 3e3
3487
+ autoRedirectDelay: m = 3e3
3479
3488
  }) {
3480
- const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), d = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, B = () => {
3489
+ const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), u = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, $ = () => {
3481
3490
  if (typeof window > "u") return {};
3482
3491
  const l = new URLSearchParams(window.location.search);
3483
3492
  return {
3484
- token: m || l.get("token") || "",
3493
+ token: c || l.get("token") || "",
3485
3494
  email: y || l.get("email") || "",
3486
- appId: f || l.get("appId") || "",
3495
+ appId: g || l.get("appId") || "",
3487
3496
  tenantSlug: F || l.get("tenantSlug") || void 0
3488
3497
  };
3489
3498
  }, w = async () => {
3490
3499
  A("verifying"), M("");
3491
3500
  try {
3492
- const l = B();
3501
+ const l = $();
3493
3502
  if (!l.token || !l.email)
3494
- throw new Error(d.missingParamsError);
3503
+ throw new Error(u.missingParamsError);
3495
3504
  const z = await P({
3496
3505
  token: l.token,
3497
3506
  email: l.email,
3498
3507
  tenantSlug: l.tenantSlug
3499
3508
  });
3500
- A("success"), r == null || r(z), g > 0 && setTimeout(() => {
3509
+ A("success"), r == null || r(z), m > 0 && setTimeout(() => {
3501
3510
  A("redirecting");
3502
- }, g);
3511
+ }, m);
3503
3512
  } catch (l) {
3504
- const z = l.message || d.errorMessage;
3513
+ const z = l.message || u.errorMessage;
3505
3514
  M(z), A("error"), i == null || i(z);
3506
3515
  }
3507
3516
  }, R = () => {
@@ -3515,25 +3524,25 @@ function Kr({
3515
3524
  const I = () => {
3516
3525
  switch (T) {
3517
3526
  case "verifying":
3518
- return /* @__PURE__ */ u("div", { style: v.message, children: [
3527
+ return /* @__PURE__ */ h("div", { style: v.message, children: [
3519
3528
  N.loading,
3520
- d.verifyingMessage
3529
+ u.verifyingMessage
3521
3530
  ] });
3522
3531
  case "success":
3523
- return /* @__PURE__ */ u(_, { children: [
3532
+ return /* @__PURE__ */ h(_, { children: [
3524
3533
  N.success,
3525
- /* @__PURE__ */ s("div", { style: v.successMessage, children: d.successMessage })
3534
+ /* @__PURE__ */ s("div", { style: v.successMessage, children: u.successMessage })
3526
3535
  ] });
3527
3536
  case "redirecting":
3528
- return /* @__PURE__ */ u(_, { children: [
3537
+ return /* @__PURE__ */ h(_, { children: [
3529
3538
  N.loading,
3530
- /* @__PURE__ */ s("div", { style: v.message, children: d.redirectingMessage })
3539
+ /* @__PURE__ */ s("div", { style: v.message, children: u.redirectingMessage })
3531
3540
  ] });
3532
3541
  case "error":
3533
- return /* @__PURE__ */ u(_, { children: [
3542
+ return /* @__PURE__ */ h(_, { children: [
3534
3543
  N.error,
3535
- /* @__PURE__ */ s("div", { style: v.errorMessage, children: L || d.errorMessage }),
3536
- /* @__PURE__ */ u("div", { style: v.buttonContainer, children: [
3544
+ /* @__PURE__ */ s("div", { style: v.errorMessage, children: L || u.errorMessage }),
3545
+ /* @__PURE__ */ h("div", { style: v.buttonContainer, children: [
3537
3546
  /* @__PURE__ */ s(
3538
3547
  "button",
3539
3548
  {
@@ -3548,7 +3557,7 @@ function Kr({
3548
3557
  l.currentTarget.style[D] = z[D] ?? "";
3549
3558
  });
3550
3559
  },
3551
- children: d.retryButton
3560
+ children: u.retryButton
3552
3561
  }
3553
3562
  ),
3554
3563
  /* @__PURE__ */ s(
@@ -3565,7 +3574,7 @@ function Kr({
3565
3574
  l.currentTarget.style[D] = z[D] ?? "";
3566
3575
  });
3567
3576
  },
3568
- children: d.backToLoginButton
3577
+ children: u.backToLoginButton
3569
3578
  }
3570
3579
  )
3571
3580
  ] })
@@ -3574,14 +3583,14 @@ function Kr({
3574
3583
  return null;
3575
3584
  }
3576
3585
  };
3577
- return /* @__PURE__ */ u("div", { style: v.container, className: c, children: [
3586
+ return /* @__PURE__ */ h("div", { style: v.container, className: d, children: [
3578
3587
  /* @__PURE__ */ s("style", { children: `
3579
3588
  @keyframes spin {
3580
3589
  0% { transform: rotate(0deg); }
3581
3590
  100% { transform: rotate(360deg); }
3582
3591
  }
3583
3592
  ` }),
3584
- /* @__PURE__ */ s("h1", { style: v.title, children: d.title }),
3593
+ /* @__PURE__ */ s("h1", { style: v.title, children: u.title }),
3585
3594
  I()
3586
3595
  ] });
3587
3596
  }
@@ -3715,30 +3724,30 @@ function Qr({
3715
3724
  onSuccess: i,
3716
3725
  onError: o,
3717
3726
  onBackToLogin: a,
3718
- onModeChange: c,
3719
- className: m
3727
+ onModeChange: d,
3728
+ className: c
3720
3729
  }) {
3721
3730
  var X;
3722
- const [y, f] = x(""), [F, g] = x(r), [T, A] = x(""), [L, M] = x(""), [P, d] = x(!1), [v, N] = x(""), [B, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, D = { ...or, ...n }, p = { ...ar, ...e }, U = () => {
3731
+ const [y, g] = x(""), [F, m] = x(r), [T, A] = x(""), [L, M] = x(""), [P, u] = x(!1), [v, N] = x(""), [$, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, D = { ...or, ...n }, f = { ...ar, ...e }, U = () => {
3723
3732
  const W = {};
3724
3733
  return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
3725
3734
  }, b = () => {
3726
3735
  const W = {};
3727
3736
  return F.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), L.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
3728
- }, h = async (W) => {
3737
+ }, p = async (W) => {
3729
3738
  if (W.preventDefault(), !!U()) {
3730
3739
  if (!(z != null && z.id)) {
3731
3740
  N(D.tenantNotFoundError);
3732
3741
  return;
3733
3742
  }
3734
- d(!0), N(""), w("");
3743
+ u(!0), N(""), w("");
3735
3744
  try {
3736
3745
  await I({ email: y, tenantId: z.id }), w(D.successMessage), i == null || i();
3737
3746
  } catch (q) {
3738
3747
  const V = q.message || D.errorMessage;
3739
3748
  N(V), o == null || o(V);
3740
3749
  } finally {
3741
- d(!1);
3750
+ u(!1);
3742
3751
  }
3743
3752
  }
3744
3753
  }, S = async (W) => {
@@ -3747,38 +3756,38 @@ function Qr({
3747
3756
  N(D.passwordMismatchError), k({ confirmPassword: !0 });
3748
3757
  return;
3749
3758
  }
3750
- d(!0), N(""), w("");
3759
+ u(!0), N(""), w("");
3751
3760
  try {
3752
3761
  await l({ token: F, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
3753
3762
  } catch (q) {
3754
3763
  const V = q.message || D.errorMessage;
3755
3764
  N(V), o == null || o(V);
3756
3765
  } finally {
3757
- d(!1);
3766
+ u(!1);
3758
3767
  }
3759
3768
  }
3760
3769
  }, E = (W) => ({
3761
- ...p.input,
3762
- ...R[W] ? p.inputError : {}
3770
+ ...f.input,
3771
+ ...R[W] ? f.inputError : {}
3763
3772
  }), K = () => ({
3764
- ...p.button,
3765
- ...P ? p.buttonLoading : {}
3773
+ ...f.button,
3774
+ ...P ? f.buttonLoading : {}
3766
3775
  });
3767
3776
  if (t === "reset") {
3768
3777
  const W = F && T && L;
3769
- return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
3770
- /* @__PURE__ */ s("h2", { style: p.title, children: D.resetTitle }),
3771
- /* @__PURE__ */ s("p", { style: p.subtitle, children: D.resetSubtitle }),
3772
- /* @__PURE__ */ u("form", { onSubmit: S, style: p.form, children: [
3773
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3774
- /* @__PURE__ */ s("label", { style: p.label, children: D.tokenLabel }),
3778
+ return /* @__PURE__ */ h("div", { className: c, style: f.container, children: [
3779
+ /* @__PURE__ */ s("h2", { style: f.title, children: D.resetTitle }),
3780
+ /* @__PURE__ */ s("p", { style: f.subtitle, children: D.resetSubtitle }),
3781
+ /* @__PURE__ */ h("form", { onSubmit: S, style: f.form, children: [
3782
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3783
+ /* @__PURE__ */ s("label", { style: f.label, children: D.tokenLabel }),
3775
3784
  /* @__PURE__ */ s(
3776
3785
  "input",
3777
3786
  {
3778
3787
  type: "text",
3779
3788
  value: F,
3780
3789
  onChange: (q) => {
3781
- g(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
3790
+ m(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
3782
3791
  },
3783
3792
  placeholder: D.tokenPlaceholder,
3784
3793
  style: E("token"),
@@ -3786,8 +3795,8 @@ function Qr({
3786
3795
  }
3787
3796
  )
3788
3797
  ] }),
3789
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3790
- /* @__PURE__ */ s("label", { style: p.label, children: D.newPasswordLabel }),
3798
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3799
+ /* @__PURE__ */ s("label", { style: f.label, children: D.newPasswordLabel }),
3791
3800
  /* @__PURE__ */ s(
3792
3801
  "input",
3793
3802
  {
@@ -3802,8 +3811,8 @@ function Qr({
3802
3811
  }
3803
3812
  )
3804
3813
  ] }),
3805
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3806
- /* @__PURE__ */ s("label", { style: p.label, children: D.confirmPasswordLabel }),
3814
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3815
+ /* @__PURE__ */ s("label", { style: f.label, children: D.confirmPasswordLabel }),
3807
3816
  /* @__PURE__ */ s(
3808
3817
  "input",
3809
3818
  {
@@ -3825,37 +3834,37 @@ function Qr({
3825
3834
  disabled: !W || P,
3826
3835
  style: {
3827
3836
  ...K(),
3828
- ...!W || P ? p.buttonDisabled : {}
3837
+ ...!W || P ? f.buttonDisabled : {}
3829
3838
  },
3830
3839
  children: P ? D.resetLoadingText : D.resetSubmitButton
3831
3840
  }
3832
3841
  ),
3833
- v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
3834
- B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
3842
+ v && /* @__PURE__ */ s("div", { style: f.errorText, children: v }),
3843
+ $ && /* @__PURE__ */ s("div", { style: f.successText, children: $ })
3835
3844
  ] }),
3836
- /* @__PURE__ */ u("div", { style: p.linkContainer, children: [
3837
- /* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
3838
- c && /* @__PURE__ */ u(_, { children: [
3839
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
3840
- /* @__PURE__ */ s("a", { onClick: () => c("request"), style: p.link, children: D.requestNewLinkLink })
3845
+ /* @__PURE__ */ h("div", { style: f.linkContainer, children: [
3846
+ /* @__PURE__ */ s("a", { onClick: a, style: f.link, children: D.backToLoginLink }),
3847
+ d && /* @__PURE__ */ h(_, { children: [
3848
+ /* @__PURE__ */ s("span", { style: f.modeSwitchDivider, children: D.dividerBullet }),
3849
+ /* @__PURE__ */ s("a", { onClick: () => d("request"), style: f.link, children: D.requestNewLinkLink })
3841
3850
  ] })
3842
3851
  ] })
3843
3852
  ] });
3844
3853
  }
3845
3854
  const G = y;
3846
- return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
3847
- /* @__PURE__ */ s("h2", { style: p.title, children: D.title }),
3848
- /* @__PURE__ */ s("p", { style: p.subtitle, children: D.subtitle }),
3849
- /* @__PURE__ */ u("form", { onSubmit: h, style: p.form, children: [
3850
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3851
- /* @__PURE__ */ s("label", { style: p.label, children: D.emailLabel }),
3855
+ return /* @__PURE__ */ h("div", { className: c, style: f.container, children: [
3856
+ /* @__PURE__ */ s("h2", { style: f.title, children: D.title }),
3857
+ /* @__PURE__ */ s("p", { style: f.subtitle, children: D.subtitle }),
3858
+ /* @__PURE__ */ h("form", { onSubmit: p, style: f.form, children: [
3859
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3860
+ /* @__PURE__ */ s("label", { style: f.label, children: D.emailLabel }),
3852
3861
  /* @__PURE__ */ s(
3853
3862
  "input",
3854
3863
  {
3855
3864
  type: "email",
3856
3865
  value: y,
3857
3866
  onChange: (W) => {
3858
- f(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
3867
+ g(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
3859
3868
  },
3860
3869
  placeholder: D.emailPlaceholder,
3861
3870
  style: E("email"),
@@ -3870,19 +3879,19 @@ function Qr({
3870
3879
  disabled: !G || P,
3871
3880
  style: {
3872
3881
  ...K(),
3873
- ...!G || P ? p.buttonDisabled : {}
3882
+ ...!G || P ? f.buttonDisabled : {}
3874
3883
  },
3875
3884
  children: P ? D.loadingText : D.submitButton
3876
3885
  }
3877
3886
  ),
3878
- v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
3879
- B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
3887
+ v && /* @__PURE__ */ s("div", { style: f.errorText, children: v }),
3888
+ $ && /* @__PURE__ */ s("div", { style: f.successText, children: $ })
3880
3889
  ] }),
3881
- /* @__PURE__ */ u("div", { style: p.linkContainer, children: [
3882
- /* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
3883
- c && /* @__PURE__ */ u(_, { children: [
3884
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
3885
- /* @__PURE__ */ s("a", { onClick: () => c("reset"), style: p.link, children: D.haveTokenLink })
3890
+ /* @__PURE__ */ h("div", { style: f.linkContainer, children: [
3891
+ /* @__PURE__ */ s("a", { onClick: a, style: f.link, children: D.backToLoginLink }),
3892
+ d && /* @__PURE__ */ h(_, { children: [
3893
+ /* @__PURE__ */ s("span", { style: f.modeSwitchDivider, children: D.dividerBullet }),
3894
+ /* @__PURE__ */ s("a", { onClick: () => d("reset"), style: f.link, children: D.haveTokenLink })
3886
3895
  ] })
3887
3896
  ] })
3888
3897
  ] });
@@ -3899,7 +3908,7 @@ const lr = () => /* @__PURE__ */ s(
3899
3908
  },
3900
3909
  children: /* @__PURE__ */ s("div", { children: "Loading..." })
3901
3910
  }
3902
- ), cr = ({ error: n, retry: e }) => /* @__PURE__ */ u(
3911
+ ), cr = ({ error: n, retry: e }) => /* @__PURE__ */ h(
3903
3912
  "div",
3904
3913
  {
3905
3914
  style: {
@@ -3939,9 +3948,9 @@ function Zr({
3939
3948
  errorFallback: t,
3940
3949
  requireTenant: r = !0
3941
3950
  }) {
3942
- const { isAppLoading: i, appError: o, retryApp: a } = Ae(), c = pe(), m = $e(), y = Ye(), f = Xe(), F = (c == null ? void 0 : c.isTenantLoading) ?? !1, g = (c == null ? void 0 : c.tenantError) ?? null, T = (c == null ? void 0 : c.tenantSlug) ?? null, A = (c == null ? void 0 : c.retryTenant) ?? (() => {
3943
- }), L = (m == null ? void 0 : m.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (f == null ? void 0 : f.isReady) ?? !0, d = r && c && T, w = i || d && F || m && !L || y && !M || f && !P, R = o || (d ? g : null), k = () => {
3944
- o && a(), g && c && A();
3951
+ const { isAppLoading: i, appError: o, retryApp: a } = Ae(), d = pe(), c = Be(), y = Ye(), g = Xe(), F = (d == null ? void 0 : d.isTenantLoading) ?? !1, m = (d == null ? void 0 : d.tenantError) ?? null, T = (d == null ? void 0 : d.tenantSlug) ?? null, A = (d == null ? void 0 : d.retryTenant) ?? (() => {
3952
+ }), L = (c == null ? void 0 : c.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (g == null ? void 0 : g.isReady) ?? !0, u = r && d && T, w = i || u && F || c && !L || y && !M || g && !P, R = o || (u ? m : null), k = () => {
3953
+ o && a(), m && d && A();
3945
3954
  };
3946
3955
  if (w)
3947
3956
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(lr, {}) });
@@ -3952,21 +3961,21 @@ function Zr({
3952
3961
  return /* @__PURE__ */ s(_, { children: n });
3953
3962
  }
3954
3963
  function Jr(n = !0) {
3955
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = $e(), c = Ye(), m = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, f = (o == null ? void 0 : o.tenantError) ?? null, F = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3956
- }), A = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (c == null ? void 0 : c.isReady) ?? !0, M = (m == null ? void 0 : m.isReady) ?? !0, P = n && o && g, B = e || P && y || a && !A || c && !L || m && !M, w = t || (P ? f : null);
3964
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = Be(), d = Ye(), c = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, g = (o == null ? void 0 : o.tenantError) ?? null, F = (o == null ? void 0 : o.tenant) ?? null, m = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3965
+ }), A = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (d == null ? void 0 : d.isReady) ?? !0, M = (c == null ? void 0 : c.isReady) ?? !0, P = n && o && m, $ = e || P && y || a && !A || d && !L || c && !M, w = t || (P ? g : null);
3957
3966
  return {
3958
- isLoading: B,
3967
+ isLoading: $,
3959
3968
  error: w,
3960
- isReady: !B && !w && i !== null && (!P || F !== null),
3969
+ isReady: !$ && !w && i !== null && (!P || F !== null),
3961
3970
  retry: () => {
3962
- t && r(), f && o && T();
3971
+ t && r(), g && o && T();
3963
3972
  },
3964
3973
  // Individual states
3965
3974
  app: { isLoading: e, error: t, data: i },
3966
- tenant: o ? { isLoading: y, error: f, data: F } : null,
3975
+ tenant: o ? { isLoading: y, error: g, data: F } : null,
3967
3976
  auth: a ? { isReady: A } : null,
3968
- featureFlags: c ? { isReady: L } : null,
3969
- subscription: m ? { isReady: M } : null
3977
+ featureFlags: d ? { isReady: L } : null,
3978
+ subscription: c ? { isReady: M } : null
3970
3979
  };
3971
3980
  }
3972
3981
  const dr = {
@@ -4021,14 +4030,14 @@ function Yr({
4021
4030
  className: i = "",
4022
4031
  dropdownClassName: o = "",
4023
4032
  itemClassName: a = "",
4024
- renderItem: c,
4025
- placeholder: m = "Select tenant",
4033
+ renderItem: d,
4034
+ placeholder: c = "Select tenant",
4026
4035
  disabled: y = !1,
4027
- showCurrentTenant: f = !0
4036
+ showCurrentTenant: g = !0
4028
4037
  }) {
4029
- var B;
4030
- const F = { ...dr, ...r }, g = $e(), [T, A] = x(!1), L = Ne(null), M = n ?? (g == null ? void 0 : g.userTenants) ?? [], P = e ?? ((B = g == null ? void 0 : g.currentUser) == null ? void 0 : B.tenantId) ?? null, d = async (w) => {
4031
- A(!1), t ? t(w) : g != null && g.switchToTenant && await g.switchToTenant(w);
4038
+ var $;
4039
+ const F = { ...dr, ...r }, m = Be(), [T, A] = x(!1), L = Ne(null), M = n ?? (m == null ? void 0 : m.userTenants) ?? [], P = e ?? (($ = m == null ? void 0 : m.currentUser) == null ? void 0 : $.tenantId) ?? null, u = async (w) => {
4040
+ A(!1), t ? t(w) : m != null && m.switchToTenant && await m.switchToTenant(w);
4032
4041
  };
4033
4042
  ne(() => {
4034
4043
  const w = (R) => {
@@ -4039,18 +4048,18 @@ function Yr({
4039
4048
  const v = M.find((w) => w.id === P);
4040
4049
  if (M.length === 0)
4041
4050
  return null;
4042
- if (M.length === 1 && f)
4051
+ if (M.length === 1 && g)
4043
4052
  return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
4044
- const N = (w, R) => /* @__PURE__ */ u("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
4053
+ const N = (w, R) => /* @__PURE__ */ h("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
4045
4054
  w.name,
4046
- w.role && /* @__PURE__ */ u("span", { style: F.itemRole, children: [
4055
+ w.role && /* @__PURE__ */ h("span", { style: F.itemRole, children: [
4047
4056
  "(",
4048
4057
  w.role,
4049
4058
  ")"
4050
4059
  ] })
4051
4060
  ] });
4052
- return /* @__PURE__ */ u("div", { ref: L, className: i, style: F.wrapper, children: [
4053
- /* @__PURE__ */ u(
4061
+ return /* @__PURE__ */ h("div", { ref: L, className: i, style: F.wrapper, children: [
4062
+ /* @__PURE__ */ h(
4054
4063
  "button",
4055
4064
  {
4056
4065
  type: "button",
@@ -4061,7 +4070,7 @@ function Yr({
4061
4070
  ...y ? F.buttonDisabled : {}
4062
4071
  },
4063
4072
  children: [
4064
- v ? v.name : m,
4073
+ v ? v.name : c,
4065
4074
  /* @__PURE__ */ s("span", { style: F.arrow, children: T ? "▲" : "▼" })
4066
4075
  ]
4067
4076
  }
@@ -4072,7 +4081,7 @@ function Yr({
4072
4081
  "div",
4073
4082
  {
4074
4083
  className: a,
4075
- onClick: () => d(w.id),
4084
+ onClick: () => u(w.id),
4076
4085
  style: {
4077
4086
  ...F.item,
4078
4087
  ...R ? F.itemSelected : {}
@@ -4088,7 +4097,7 @@ function Yr({
4088
4097
  });
4089
4098
  }
4090
4099
  },
4091
- children: c ? c(w, R) : N(w, R)
4100
+ children: d ? d(w, R) : N(w, R)
4092
4101
  },
4093
4102
  w.id
4094
4103
  );
@@ -4351,7 +4360,7 @@ function nn(n = {}) {
4351
4360
  zoneRoots: e = {},
4352
4361
  returnToParam: t = rt,
4353
4362
  returnToStorage: r = "url"
4354
- } = n, i = mt(), [o, a] = yt(), { isAuthenticated: c, currentUser: m } = he(), { tenant: y } = Te(), f = Z(() => ({ ...Oe, ...e }), [e]), F = !!y, g = m == null ? void 0 : m.userType, T = Z(() => {
4363
+ } = n, i = mt(), [o, a] = yt(), { isAuthenticated: d, currentUser: c } = he(), { tenant: y } = Te(), g = Z(() => ({ ...Oe, ...e }), [e]), F = !!y, m = c == null ? void 0 : c.userType, T = Z(() => {
4355
4364
  switch (r) {
4356
4365
  case "url":
4357
4366
  return o.get(t);
@@ -4365,8 +4374,8 @@ function nn(n = {}) {
4365
4374
  }, [r, o, t]), A = oe(() => {
4366
4375
  switch (r) {
4367
4376
  case "url": {
4368
- const d = new URLSearchParams(o);
4369
- d.delete(t), a(d, { replace: !0 });
4377
+ const u = new URLSearchParams(o);
4378
+ u.delete(t), a(u, { replace: !0 });
4370
4379
  break;
4371
4380
  }
4372
4381
  case "session":
@@ -4377,29 +4386,29 @@ function nn(n = {}) {
4377
4386
  break;
4378
4387
  }
4379
4388
  }, [r, o, t, a]), L = oe(
4380
- (d) => {
4389
+ (u) => {
4381
4390
  switch (r) {
4382
4391
  case "url": {
4383
4392
  const v = new URLSearchParams(o);
4384
- v.set(t, d), a(v, { replace: !0 });
4393
+ v.set(t, u), a(v, { replace: !0 });
4385
4394
  break;
4386
4395
  }
4387
4396
  case "session":
4388
- sessionStorage.setItem(Me, d);
4397
+ sessionStorage.setItem(Me, u);
4389
4398
  break;
4390
4399
  case "local":
4391
- localStorage.setItem(Le, d);
4400
+ localStorage.setItem(Le, u);
4392
4401
  break;
4393
4402
  }
4394
4403
  },
4395
4404
  [r, o, t, a]
4396
4405
  ), M = oe(
4397
- (d) => {
4398
- const v = f[d] || f.default;
4406
+ (u) => {
4407
+ const v = g[u] || g.default;
4399
4408
  i(v);
4400
4409
  },
4401
- [i, f]
4402
- ), P = oe(() => F ? c ? g === ae.TENANT_ADMIN ? f.tenantAdmin : f.tenantUser : f.tenantGuest : c ? g === ae.TENANT_ADMIN ? f.publicAdmin : f.publicUser : f.publicGuest, [F, c, g, f]);
4410
+ [i, g]
4411
+ ), P = oe(() => F ? d ? m === ae.TENANT_ADMIN ? g.tenantAdmin : g.tenantUser : g.tenantGuest : d ? m === ae.TENANT_ADMIN ? g.publicAdmin : g.publicUser : g.publicGuest, [F, d, m, g]);
4403
4412
  return {
4404
4413
  returnToUrl: T,
4405
4414
  clearReturnTo: A,
@@ -4415,7 +4424,7 @@ function sn(n, e, t = rt, r = "url") {
4415
4424
  return i.searchParams.set(t, e), i.pathname + i.search;
4416
4425
  }
4417
4426
  export {
4418
- $r as AdminZone,
4427
+ Br as AdminZone,
4419
4428
  rn as ApiMappers,
4420
4429
  Ve as AppApiService,
4421
4430
  Zr as AppLoader,
@@ -4428,7 +4437,7 @@ export {
4428
4437
  Vr as FeatureFlag,
4429
4438
  It as FeatureFlagApiService,
4430
4439
  Ar as FeatureFlagProvider,
4431
- Br as GuestZone,
4440
+ $r as GuestZone,
4432
4441
  tn as HealthApiService,
4433
4442
  de as HttpService,
4434
4443
  Nr as LandingRoute,