@skylabs-digital/react-identity-access 2.27.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,5 +1,5 @@
1
- import { jsx as s, Fragment as _, jsxs as u } from "react/jsx-runtime";
2
- import { createContext as ye, useMemo as Z, useState as x, useCallback as ie, useEffect as ne, useContext as le, useRef as Ne } from "react";
1
+ import { jsx as s, Fragment as _, jsxs as h } from "react/jsx-runtime";
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 {
5
5
  constructor(e, t = 1e4) {
@@ -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 D = f.headers.get("content-type");
35
- return !D || !D.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) {
@@ -109,13 +109,13 @@ class Ve {
109
109
  })).data;
110
110
  }
111
111
  }
112
- const De = ye(null);
112
+ 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 = ie(
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,44 +164,44 @@ 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
  }
171
171
  },
172
172
  [n.baseUrl, n.appId, t, r]
173
- ), D = ie(async () => {
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 ? D() : f();
195
- }, []), /* @__PURE__ */ s(De.Provider, { value: y, children: e });
194
+ r ? F() : g();
195
+ }, []), /* @__PURE__ */ s(Fe.Provider, { value: y, children: e });
196
196
  }
197
197
  function Ae() {
198
- const n = le(De);
198
+ const n = le(Fe);
199
199
  if (!n)
200
200
  throw new Error("useApp must be used within an AppProvider");
201
201
  return n;
202
202
  }
203
- function Fe() {
204
- return le(De);
203
+ function De() {
204
+ return le(Fe);
205
205
  }
206
206
  const vr = Ae;
207
207
  class se extends Error {
@@ -226,9 +226,9 @@ class bt extends Error {
226
226
  ), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
227
227
  }
228
228
  }
229
- const oe = class oe {
229
+ const ie = class ie {
230
230
  constructor(e = {}) {
231
- this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
231
+ this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
232
232
  }
233
233
  /**
234
234
  * Get or create a SessionManager instance for the given config.
@@ -236,17 +236,17 @@ const oe = class oe {
236
236
  * Mutable config (callbacks, baseUrl) is updated on the existing instance.
237
237
  */
238
238
  static getInstance(e = {}) {
239
- const t = oe.resolveStorageKey(e), r = oe.instances.get(t);
239
+ const t = ie.resolveStorageKey(e), r = ie.instances.get(t);
240
240
  if (r)
241
241
  return r.updateConfig(e), r;
242
- const i = new oe(e);
243
- return oe.instances.set(t, i), i;
242
+ const i = new ie(e);
243
+ return ie.instances.set(t, i), i;
244
244
  }
245
245
  /** Reset all singleton instances. For testing only. */
246
246
  static resetAllInstances() {
247
- for (const e of oe.instances.values())
247
+ for (const e of ie.instances.values())
248
248
  e.destroy();
249
- oe.instances.clear();
249
+ ie.instances.clear();
250
250
  }
251
251
  static resolveStorageKey(e) {
252
252
  return e.storageKey ? e.storageKey : e.tenantSlug !== void 0 && e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens";
@@ -296,7 +296,7 @@ const oe = class oe {
296
296
  }
297
297
  }
298
298
  setTokens(e) {
299
- const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || oe.extractJwtExpiry(e.accessToken), r = {
299
+ const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || ie.extractJwtExpiry(e.accessToken), r = {
300
300
  ...e,
301
301
  expiresAt: t
302
302
  }, i = this.tokenStorage.get() || {};
@@ -306,7 +306,7 @@ const oe = class oe {
306
306
  const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
307
307
  if (!e)
308
308
  return null;
309
- const a = r || oe.extractJwtExpiry(e);
309
+ const a = r || ie.extractJwtExpiry(e);
310
310
  return {
311
311
  accessToken: e,
312
312
  refreshToken: t,
@@ -353,13 +353,26 @@ const oe = class oe {
353
353
  if (!(e != null && e.refreshToken) || this.refreshPromise) return;
354
354
  const t = this.sessionGeneration;
355
355
  this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
356
+ this.consecutiveBackgroundFailures = 0;
356
357
  }).catch((r) => {
357
- r instanceof se || this.sessionGeneration === t && (process.env.NODE_ENV === "development" && console.warn(
358
- "[SessionManager] Background refresh failed, retrying in 30s:",
359
- r.message
360
- ), this.backgroundRetryTimerId = setTimeout(() => {
361
- this.backgroundRefresh();
362
- }, 3e4));
358
+ if (!(r instanceof se)) {
359
+ if (this.sessionGeneration === t) {
360
+ if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= ie.MAX_BACKGROUND_FAILURES) {
361
+ process.env.NODE_ENV === "development" && console.error(
362
+ `[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
363
+ ), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
364
+ new se("token_invalid", "Background refresh failed repeatedly")
365
+ );
366
+ return;
367
+ }
368
+ process.env.NODE_ENV === "development" && console.warn(
369
+ "[SessionManager] Background refresh failed, retrying in 30s:",
370
+ r.message
371
+ ), this.backgroundRetryTimerId = setTimeout(() => {
372
+ this.backgroundRefresh();
373
+ }, 3e4);
374
+ }
375
+ }
363
376
  });
364
377
  }
365
378
  /**
@@ -456,8 +469,8 @@ const oe = class oe {
456
469
  if (a instanceof se)
457
470
  throw a;
458
471
  if (t = a, i < this.maxRefreshRetries) {
459
- const c = this.retryBackoffBase * Math.pow(2, i);
460
- await this.sleep(c);
472
+ const d = this.retryBackoffBase * Math.pow(2, i);
473
+ await this.sleep(d);
461
474
  }
462
475
  }
463
476
  }
@@ -469,36 +482,45 @@ const oe = class oe {
469
482
  * Throws generic Error for transient errors (will be retried).
470
483
  */
471
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) {
472
491
  if (!this.baseUrl)
473
492
  throw new Error("Base URL not configured for token refresh");
474
- const r = `${this.baseUrl}/auth/refresh`;
475
- 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;
476
498
  try {
477
- i = await fetch(r, {
499
+ a = await fetch(o, {
478
500
  method: "POST",
479
501
  headers: { "Content-Type": "application/json" },
480
- body: JSON.stringify({ refreshToken: e })
502
+ body: JSON.stringify({ refreshToken: i })
481
503
  });
482
- } catch (a) {
483
- 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");
484
506
  }
485
- if (!i.ok) {
486
- let a = "";
507
+ if (!a.ok) {
508
+ let c = "";
487
509
  try {
488
- const c = await i.json();
489
- a = (c.message || c.error || "").toLowerCase();
510
+ const y = await a.json();
511
+ c = (y.message || y.error || "").toLowerCase();
490
512
  } catch {
491
- a = i.statusText.toLowerCase();
513
+ c = a.statusText.toLowerCase();
492
514
  }
493
- 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) : 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}`);
494
516
  }
495
517
  if (this.sessionGeneration !== t)
496
518
  throw new se("token_invalid", "Session cleared during refresh");
497
- const o = await i.json();
519
+ const d = await a.json();
498
520
  this.setTokens({
499
- accessToken: o.accessToken,
500
- refreshToken: o.refreshToken || e,
501
- expiresIn: o.expiresIn
521
+ accessToken: d.accessToken,
522
+ refreshToken: d.refreshToken || i,
523
+ expiresIn: d.expiresIn
502
524
  });
503
525
  }
504
526
  // --- Session expiry handler ---
@@ -529,7 +551,7 @@ const oe = class oe {
529
551
  * Cancels all timers and rejects pending queue entries.
530
552
  */
531
553
  destroy() {
532
- this.isDestroyed = !0, oe.instances.delete(this.storageKey), this.cancelProactiveTimer();
554
+ this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer();
533
555
  const e = new se("token_invalid", "SessionManager destroyed");
534
556
  this.rejectQueue(e);
535
557
  }
@@ -568,8 +590,8 @@ const oe = class oe {
568
590
  return new Promise((t) => setTimeout(t, e));
569
591
  }
570
592
  };
571
- oe.instances = /* @__PURE__ */ new Map();
572
- let be = oe;
593
+ ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
594
+ let be = ie;
573
595
  const Ie = /* @__PURE__ */ new Map();
574
596
  class vt {
575
597
  constructor(e) {
@@ -882,7 +904,7 @@ function Et() {
882
904
  }
883
905
  const Ue = ye(null);
884
906
  function Sr({ config: n, children: e }) {
885
- const { baseUrl: t, appInfo: r, appId: i } = Ae(), o = ie(() => typeof window > "u" ? null : xt(
907
+ const { baseUrl: t, appInfo: r, appId: i } = Ae(), o = oe(() => typeof window > "u" ? null : xt(
886
908
  {
887
909
  tenantMode: n.tenantMode || "selector",
888
910
  baseDomain: n.baseDomain,
@@ -894,115 +916,115 @@ function Sr({ config: n, children: e }) {
894
916
  search: window.location.search
895
917
  },
896
918
  window.localStorage
897
- ), [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(
898
920
  () => {
899
- var p, U, b;
921
+ var f, U, b;
900
922
  return {
901
- enabled: ((p = n.cache) == null ? void 0 : p.enabled) ?? !0,
923
+ enabled: ((f = n.cache) == null ? void 0 : f.enabled) ?? !0,
902
924
  ttl: ((U = n.cache) == null ? void 0 : U.ttl) ?? 5 * 60 * 1e3,
903
925
  // 5 minutes default
904
926
  storageKey: ((b = n.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${a || "default"}`
905
927
  };
906
928
  },
907
929
  [n.cache, a]
908
- ), [y, f] = x(() => {
930
+ ), [y, g] = x(() => {
909
931
  if (n.initialTenant) return n.initialTenant;
910
- if (!m.enabled || !a) return null;
932
+ if (!c.enabled || !a) return null;
911
933
  try {
912
- const p = localStorage.getItem(m.storageKey);
913
- if (!p) return null;
914
- const U = JSON.parse(p);
915
- 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);
916
938
  } catch {
917
939
  return null;
918
940
  }
919
- }), [D, 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);
920
942
  ne(() => {
921
943
  if (n.tenantMode === "fixed") return;
922
- const p = o();
923
- c(p);
944
+ const f = o();
945
+ d(f);
924
946
  }, [o, n.tenantMode]);
925
- const $ = (r == null ? void 0 : r.settingsSchema) || null, w = ie(
926
- async (p, U = !1) => {
927
- 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))
928
950
  try {
929
- g(!0), A(null);
930
- const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(p);
931
- 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)
932
954
  try {
933
955
  const E = {
934
956
  data: S,
935
957
  timestamp: Date.now(),
936
- tenantSlug: p
958
+ tenantSlug: f
937
959
  };
938
- localStorage.setItem(m.storageKey, JSON.stringify(E));
960
+ localStorage.setItem(c.storageKey, JSON.stringify(E));
939
961
  } catch (E) {
940
962
  process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", E);
941
963
  }
942
964
  } catch (b) {
943
- const h = b instanceof Error ? b : new Error("Failed to load tenant information");
944
- A(h), f(null);
965
+ const p = b instanceof Error ? b : new Error("Failed to load tenant information");
966
+ A(p), g(null);
945
967
  } finally {
946
- g(!1);
968
+ m(!1);
947
969
  }
948
970
  },
949
- [t, i, m, y]
950
- ), R = ie(async () => {
951
- if (!(!m.enabled || !y || !a))
971
+ [t, i, c, y]
972
+ ), R = oe(async () => {
973
+ if (!(!c.enabled || !y || !a))
952
974
  try {
953
- const p = localStorage.getItem(m.storageKey);
954
- if (!p) return;
955
- const U = JSON.parse(p);
956
- if (Date.now() - U.timestamp > m.ttl * 0.5) {
957
- const h = new de(t), E = await new ve(h, i).getPublicTenantInfo(a);
958
- f(E);
959
- const Q = {
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);
981
+ const K = {
960
982
  data: E,
961
983
  timestamp: Date.now(),
962
984
  tenantSlug: a
963
985
  };
964
- localStorage.setItem(m.storageKey, JSON.stringify(Q));
986
+ localStorage.setItem(c.storageKey, JSON.stringify(K));
965
987
  }
966
- } catch (p) {
967
- 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);
968
990
  }
969
- }, [t, i, m, y, a]), k = ie(async () => {
991
+ }, [t, i, c, y, a]), k = oe(async () => {
970
992
  if (y != null && y.id)
971
993
  try {
972
- d(!0), N(null);
973
- 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);
974
996
  M(b);
975
- } catch (p) {
976
- 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");
977
999
  N(U), M(null);
978
1000
  } finally {
979
- d(!1);
1001
+ u(!1);
980
1002
  }
981
- }, [t, y]), I = ie(() => {
1003
+ }, [t, y]), I = oe(() => {
982
1004
  k();
983
- }, [k]), l = ie(
984
- (p) => {
1005
+ }, [k]), l = oe(
1006
+ (f) => {
985
1007
  if (!$)
986
1008
  return { isValid: !0, errors: [] };
987
1009
  const U = [];
988
1010
  try {
989
- return $.properties && Object.entries($.properties).forEach(([b, h]) => {
1011
+ return $.properties && Object.entries($.properties).forEach(([b, p]) => {
990
1012
  var E;
991
- const S = p[b];
1013
+ const S = f[b];
992
1014
  if ((E = $.required) != null && E.includes(b) && S == null) {
993
1015
  U.push(`Field '${b}' is required`);
994
1016
  return;
995
1017
  }
996
1018
  if (S != null) {
997
- if (h.type) {
998
- const Q = h.type, G = typeof S;
999
- Q === "string" && G !== "string" ? U.push(`Field '${b}' must be a string`) : (Q === "number" || Q === "integer") && G !== "number" ? U.push(`Field '${b}' must be a number`) : Q === "boolean" && G !== "boolean" ? U.push(`Field '${b}' must be a boolean`) : Q === "array" && !Array.isArray(S) && U.push(`Field '${b}' must be an array`);
1019
+ if (p.type) {
1020
+ const K = p.type, G = typeof S;
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`);
1000
1022
  }
1001
- h.minLength !== void 0 && typeof S == "string" && S.length < h.minLength && U.push(
1002
- `Field '${b}' must be at least ${h.minLength} characters long`
1003
- ), h.maxLength !== void 0 && typeof S == "string" && S.length > h.maxLength && U.push(
1004
- `Field '${b}' must be no more than ${h.maxLength} characters long`
1005
- ), 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(", ")}`);
1006
1028
  }
1007
1029
  }), {
1008
1030
  isValid: U.length === 0,
@@ -1018,13 +1040,13 @@ function Sr({ config: n, children: e }) {
1018
1040
  [$]
1019
1041
  );
1020
1042
  ne(() => {
1021
- !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));
1022
1044
  }, [n.initialTenant, a, y, w, R]), ne(() => {
1023
- y != null && y.id ? k() : (M(null), N(null), d(!1));
1045
+ y != null && y.id ? k() : (M(null), N(null), u(!1));
1024
1046
  }, [y == null ? void 0 : y.id, k]);
1025
- const z = ie(
1026
- (p, U) => {
1027
- const { mode: b = "reload", tokens: h, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
1047
+ const z = oe(
1048
+ (f, U) => {
1049
+ const { mode: b = "reload", tokens: p, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
1028
1050
  if (E === "fixed") {
1029
1051
  process.env.NODE_ENV === "development" && console.warn(
1030
1052
  "[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
@@ -1032,40 +1054,40 @@ function Sr({ config: n, children: e }) {
1032
1054
  ), S && (window.location.href = S);
1033
1055
  return;
1034
1056
  }
1035
- if (localStorage.setItem("tenant", p), E === "subdomain") {
1036
- const Q = window.location.hostname, G = At(
1037
- p,
1038
- Q,
1057
+ if (localStorage.setItem("tenant", f), E === "subdomain") {
1058
+ const K = window.location.hostname, G = At(
1059
+ f,
1060
+ K,
1039
1061
  n.baseDomain
1040
1062
  );
1041
1063
  if (!G) {
1042
1064
  process.env.NODE_ENV === "development" && console.warn(
1043
1065
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
1044
- Q
1066
+ K
1045
1067
  );
1046
1068
  return;
1047
1069
  }
1048
1070
  const X = S || window.location.pathname, W = new URL(`${window.location.protocol}//${G}${X}`);
1049
- new URLSearchParams(window.location.search).forEach((V, B) => {
1050
- B !== me && W.searchParams.set(B, V);
1051
- }), h && W.searchParams.set(me, je(h)), window.location.href = W.toString();
1071
+ new URLSearchParams(window.location.search).forEach((V, H) => {
1072
+ H !== me && W.searchParams.set(H, V);
1073
+ }), p && W.searchParams.set(me, je(p)), window.location.href = W.toString();
1052
1074
  } else if (E === "selector") {
1053
- const Q = S || window.location.pathname, G = new URLSearchParams(window.location.search);
1054
- if (G.set(n.selectorParam || "tenant", p), G.delete(me), h && G.set(me, je(h)), b === "reload") {
1055
- const X = `${Q}?${G.toString()}${window.location.hash}`;
1075
+ const K = S || window.location.pathname, G = new URLSearchParams(window.location.search);
1076
+ if (G.set(n.selectorParam || "tenant", f), G.delete(me), p && G.set(me, je(p)), b === "reload") {
1077
+ const X = `${K}?${G.toString()}${window.location.hash}`;
1056
1078
  window.location.href = X;
1057
1079
  } else {
1058
- const X = `${Q}?${G.toString()}${window.location.hash}`;
1059
- window.history.pushState({}, "", X), c(p), w(p);
1080
+ const X = `${K}?${G.toString()}${window.location.hash}`;
1081
+ window.history.pushState({}, "", X), d(f), w(f);
1060
1082
  }
1061
1083
  }
1062
1084
  },
1063
1085
  [n.tenantMode, n.selectorParam, n.baseDomain, w]
1064
- ), F = Z(() => ({
1086
+ ), D = Z(() => ({
1065
1087
  // Tenant info
1066
1088
  tenant: y,
1067
1089
  tenantSlug: a,
1068
- isTenantLoading: D,
1090
+ isTenantLoading: F,
1069
1091
  tenantError: T,
1070
1092
  retryTenant: () => {
1071
1093
  a && w(a);
@@ -1083,7 +1105,7 @@ function Sr({ config: n, children: e }) {
1083
1105
  }), [
1084
1106
  y,
1085
1107
  a,
1086
- D,
1108
+ F,
1087
1109
  T,
1088
1110
  L,
1089
1111
  $,
@@ -1093,7 +1115,7 @@ function Sr({ config: n, children: e }) {
1093
1115
  z,
1094
1116
  l
1095
1117
  ]);
1096
- return /* @__PURE__ */ s(Ue.Provider, { value: F, children: e });
1118
+ return /* @__PURE__ */ s(Ue.Provider, { value: D, children: e });
1097
1119
  }
1098
1120
  function Te() {
1099
1121
  const n = le(Ue);
@@ -1127,29 +1149,29 @@ function Je() {
1127
1149
  }
1128
1150
  const $e = ye(null);
1129
1151
  function xr({ config: n = {}, children: e }) {
1130
- const t = Fe(), 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) ?? (() => {
1131
1153
  });
1132
1154
  if (!i)
1133
1155
  throw new Error(
1134
1156
  "[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
1135
1157
  );
1136
- const [y, f] = x(n.initialRoles || []), [D, 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(() => {
1137
1159
  try {
1138
- const C = localStorage.getItem("userTenants");
1139
- return C ? JSON.parse(C) : [];
1160
+ const B = localStorage.getItem("userTenants");
1161
+ return B ? JSON.parse(B) : [];
1140
1162
  } catch {
1141
1163
  return [];
1142
1164
  }
1143
1165
  }), [$, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
1144
1166
  R.current.done || (R.current.done = !0, R.current.urlTokens = Rt());
1145
1167
  const [k, I] = x(() => R.current.urlTokens !== null), l = Z(() => {
1146
- const C = be.getInstance({
1147
- tenantSlug: c,
1168
+ const B = be.getInstance({
1169
+ tenantSlug: d,
1148
1170
  baseUrl: i,
1149
1171
  refreshQueueTimeout: n.refreshQueueTimeout,
1150
1172
  proactiveRefreshMargin: n.proactiveRefreshMargin,
1151
1173
  onSessionExpired: (ce) => {
1152
- A(null), d(null), N([]), w(!1);
1174
+ A(null), u(null), N([]), w(!1);
1153
1175
  try {
1154
1176
  localStorage.removeItem("userTenants");
1155
1177
  } catch {
@@ -1157,94 +1179,94 @@ function xr({ config: n = {}, children: e }) {
1157
1179
  n.onSessionExpired ? n.onSessionExpired(ce) : n.onRefreshFailed && n.onRefreshFailed();
1158
1180
  }
1159
1181
  });
1160
- return R.current.urlTokens && C.setTokens({
1182
+ return R.current.urlTokens && B.setTokens({
1161
1183
  accessToken: R.current.urlTokens.accessToken,
1162
1184
  refreshToken: R.current.urlTokens.refreshToken,
1163
1185
  expiresIn: R.current.urlTokens.expiresIn
1164
- }), C;
1165
- }, [c, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, F] = x(() => {
1186
+ }), B;
1187
+ }, [d, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
1166
1188
  if (R.current.urlTokens) return !1;
1167
- const C = l.getTokens();
1168
- return C ? l.hasValidSession() || !!C.refreshToken : !1;
1169
- }), p = R.current.done && !k && !z, U = Z(() => {
1170
- const C = new de(i);
1171
- return C.setSessionManager(l), C;
1172
- }, [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]), Q = Z(() => E != null && E.roleId && y.find((C) => C.id === E.roleId) || null, [E, y]), G = Z(() => (Q == null ? void 0 : Q.permissions) || [], [Q]), 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 () => {
1173
1195
  }), q = Z(() => {
1174
- const C = async (H = !1) => {
1196
+ const B = async (C = !1) => {
1175
1197
  try {
1176
- if (!l.hasValidSession() || !H && T)
1198
+ if (!l.hasValidSession() || !C && T)
1177
1199
  return;
1178
1200
  const O = l.getUserId();
1179
1201
  if (!O) {
1180
1202
  process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
1181
1203
  return;
1182
1204
  }
1183
- M(!0), d(null);
1184
- const J = await h.getUserById(O);
1205
+ M(!0), u(null);
1206
+ const J = await p.getUserById(O);
1185
1207
  A(J), l.setUser(J);
1186
1208
  } catch (O) {
1187
1209
  const J = O instanceof Error ? O : new Error("Failed to load user data");
1188
- 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);
1189
1211
  } finally {
1190
1212
  M(!1);
1191
1213
  }
1192
1214
  }, ce = async () => {
1193
- await C();
1194
- }, fe = async (H) => {
1215
+ await B();
1216
+ }, fe = async (C) => {
1195
1217
  var _e;
1196
- const { username: O, password: J, tenantSlug: j, redirectPath: Y } = H;
1197
- let ee = a == null ? void 0 : a.id, te = c, re = l;
1218
+ const { username: O, password: J, tenantSlug: j, redirectPath: Y } = C;
1219
+ let ee = a == null ? void 0 : a.id, te = d, re = l;
1198
1220
  j && (ee = (await new ve(U, o).getPublicTenantInfo(j)).id, te = j);
1199
- const K = await b.login({
1221
+ const Q = await b.login({
1200
1222
  username: O,
1201
1223
  password: J,
1202
1224
  appId: o,
1203
1225
  tenantId: ee
1204
- }), we = j && j !== c;
1226
+ }), we = j && j !== d;
1205
1227
  if (we && (re = new be({
1206
1228
  tenantSlug: te,
1207
1229
  baseUrl: i
1208
1230
  })), re.setTokens({
1209
- accessToken: K.accessToken,
1210
- refreshToken: K.refreshToken,
1211
- expiresIn: K.expiresIn
1212
- }), K.user) {
1213
- re.setUser(K.user), A(K.user);
1231
+ accessToken: Q.accessToken,
1232
+ refreshToken: Q.refreshToken,
1233
+ expiresIn: Q.expiresIn
1234
+ }), Q.user) {
1235
+ re.setUser(Q.user), A(Q.user);
1214
1236
  try {
1215
- await C();
1237
+ await B();
1216
1238
  } catch (ke) {
1217
1239
  process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
1218
1240
  }
1219
1241
  }
1220
- if (K.tenants && K.tenants.length > 0) {
1221
- N(K.tenants);
1242
+ if (Q.tenants && Q.tenants.length > 0) {
1243
+ N(Q.tenants);
1222
1244
  try {
1223
- localStorage.setItem("userTenants", JSON.stringify(K.tenants));
1245
+ localStorage.setItem("userTenants", JSON.stringify(Q.tenants));
1224
1246
  } catch {
1225
1247
  }
1226
1248
  }
1227
- const Re = ((_e = K.user) == null ? void 0 : _e.tenantId) !== null;
1249
+ const Re = ((_e = Q.user) == null ? void 0 : _e.tenantId) !== null;
1228
1250
  w(Re);
1229
1251
  const Ee = {
1230
- accessToken: K.accessToken,
1231
- refreshToken: K.refreshToken,
1232
- expiresIn: K.expiresIn
1252
+ accessToken: Q.accessToken,
1253
+ refreshToken: Q.refreshToken,
1254
+ expiresIn: Q.expiresIn
1233
1255
  };
1234
1256
  if (we && te)
1235
- return m(te, { tokens: Ee, redirectPath: Y }), K;
1257
+ return c(te, { tokens: Ee, redirectPath: Y }), Q;
1236
1258
  if (Y && Y !== window.location.pathname)
1237
- return m(te || c || "", { tokens: Ee, redirectPath: Y }), K;
1238
- if (!Re && K.tenants && K.tenants.length > 0) {
1239
- const ke = H.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
1240
- if (K.tenants.length === 1 && ke) {
1241
- const ze = K.tenants[0];
1242
- return m(ze.subdomain, { tokens: Ee, redirectPath: Y }), K;
1243
- } else K.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(K.tenants);
1259
+ return c(te || d || "", { tokens: Ee, redirectPath: Y }), Q;
1260
+ if (!Re && Q.tenants && Q.tenants.length > 0) {
1261
+ const ke = C.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
1262
+ if (Q.tenants.length === 1 && ke) {
1263
+ const ze = Q.tenants[0];
1264
+ return c(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
1265
+ } else Q.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Q.tenants);
1244
1266
  }
1245
- return K;
1246
- }, ge = async (H) => {
1247
- const { email: O, phoneNumber: J, name: j, password: Y, lastName: ee, tenantId: te } = H;
1267
+ return Q;
1268
+ }, ge = async (C) => {
1269
+ const { email: O, phoneNumber: J, name: j, password: Y, lastName: ee, tenantId: te } = C;
1248
1270
  if (!O && !J)
1249
1271
  throw new Error("Either email or phoneNumber is required");
1250
1272
  if (!j || !Y)
@@ -1259,8 +1281,8 @@ function xr({ config: n = {}, children: e }) {
1259
1281
  lastName: ee,
1260
1282
  appId: o
1261
1283
  });
1262
- }, nt = async (H) => {
1263
- const { email: O, phoneNumber: J, name: j, password: Y, tenantName: ee, lastName: te } = H;
1284
+ }, nt = async (C) => {
1285
+ const { email: O, phoneNumber: J, name: j, password: Y, tenantName: ee, lastName: te } = C;
1264
1286
  if (!O && !J)
1265
1287
  throw new Error("Either email or phoneNumber is required");
1266
1288
  if (!j || !Y || !ee)
@@ -1274,19 +1296,19 @@ function xr({ config: n = {}, children: e }) {
1274
1296
  appId: o,
1275
1297
  lastName: te
1276
1298
  });
1277
- }, st = async (H) => {
1278
- const { currentPassword: O, newPassword: J } = H, j = await l.getAuthHeaders();
1299
+ }, st = async (C) => {
1300
+ const { currentPassword: O, newPassword: J } = C, j = await l.getAuthHeaders();
1279
1301
  await b.changePassword({ currentPassword: O, newPassword: J }, j);
1280
- }, it = async (H) => {
1281
- const { email: O, tenantId: J } = H, j = J ?? (a == null ? void 0 : a.id);
1302
+ }, it = async (C) => {
1303
+ const { email: O, tenantId: J } = C, j = J ?? (a == null ? void 0 : a.id);
1282
1304
  if (!j)
1283
1305
  throw new Error("tenantId is required for password reset");
1284
1306
  await b.requestPasswordReset({ email: O, tenantId: j });
1285
- }, ot = async (H) => {
1286
- const { token: O, newPassword: J } = H;
1307
+ }, ot = async (C) => {
1308
+ const { token: O, newPassword: J } = C;
1287
1309
  await b.confirmPasswordReset({ token: O, newPassword: J });
1288
- }, at = async (H) => {
1289
- const { email: O, frontendUrl: J, name: j, lastName: Y, tenantId: ee } = H, te = ee ?? (a == null ? void 0 : a.id);
1310
+ }, at = async (C) => {
1311
+ const { email: O, frontendUrl: J, name: j, lastName: Y, tenantId: ee } = C, te = ee ?? (a == null ? void 0 : a.id);
1290
1312
  if (!te)
1291
1313
  throw new Error("tenantId is required for magic link authentication");
1292
1314
  return await b.sendMagicLink({
@@ -1297,17 +1319,17 @@ function xr({ config: n = {}, children: e }) {
1297
1319
  lastName: Y,
1298
1320
  appId: o
1299
1321
  });
1300
- }, lt = async (H) => {
1301
- const { token: O, email: J, tenantSlug: j } = H;
1302
- let Y = a == null ? void 0 : a.id, ee = c, te = l;
1322
+ }, lt = async (C) => {
1323
+ const { token: O, email: J, tenantSlug: j } = C;
1324
+ let Y = a == null ? void 0 : a.id, ee = d, te = l;
1303
1325
  j && (Y = (await new ve(U, o).getPublicTenantInfo(j)).id, ee = j);
1304
1326
  const re = await b.verifyMagicLink({
1305
1327
  token: O,
1306
1328
  email: J,
1307
1329
  appId: o,
1308
1330
  tenantId: Y
1309
- }), K = j && j !== c;
1310
- if (K && (te = new be({
1331
+ }), Q = j && j !== d;
1332
+ if (Q && (te = new be({
1311
1333
  tenantSlug: ee,
1312
1334
  baseUrl: i
1313
1335
  })), te.setTokens({
@@ -1317,7 +1339,7 @@ function xr({ config: n = {}, children: e }) {
1317
1339
  }), re.user) {
1318
1340
  te.setUser(re.user), A(re.user);
1319
1341
  try {
1320
- await C();
1342
+ await B();
1321
1343
  } catch (we) {
1322
1344
  process.env.NODE_ENV === "development" && console.warn(
1323
1345
  "[AuthProvider] Failed to load complete user data after magic link:",
@@ -1325,7 +1347,7 @@ function xr({ config: n = {}, children: e }) {
1325
1347
  );
1326
1348
  }
1327
1349
  }
1328
- return K && ee && ee !== c && m(ee, {
1350
+ return Q && ee && ee !== d && c(ee, {
1329
1351
  tokens: {
1330
1352
  accessToken: re.accessToken,
1331
1353
  refreshToken: re.refreshToken,
@@ -1333,46 +1355,46 @@ function xr({ config: n = {}, children: e }) {
1333
1355
  }
1334
1356
  }), re;
1335
1357
  }, ct = async () => {
1336
- const H = l.getTokens();
1337
- if (!(H != null && H.refreshToken))
1358
+ const C = l.getTokens();
1359
+ if (!(C != null && C.refreshToken))
1338
1360
  throw new Error("No refresh token available");
1339
1361
  const O = await b.refreshToken({
1340
- refreshToken: H.refreshToken
1362
+ refreshToken: C.refreshToken
1341
1363
  });
1342
1364
  l.setTokens({
1343
1365
  accessToken: O.accessToken,
1344
- refreshToken: O.refreshToken || H.refreshToken,
1366
+ refreshToken: O.refreshToken || C.refreshToken,
1345
1367
  expiresIn: O.expiresIn
1346
1368
  });
1347
1369
  }, dt = () => {
1348
- l.clearSession(), A(null), d(null), N([]), w(!1);
1370
+ l.clearSession(), A(null), u(null), N([]), w(!1);
1349
1371
  try {
1350
1372
  localStorage.removeItem("userTenants");
1351
1373
  } catch {
1352
1374
  }
1353
- }, ut = (H) => {
1354
- l.setTokens(H);
1375
+ }, ut = (C) => {
1376
+ l.setTokens(C);
1355
1377
  }, ht = () => l.hasValidSession(), pt = () => {
1356
- l.clearSession(), A(null), d(null);
1378
+ l.clearSession(), A(null), u(null);
1357
1379
  }, ft = async () => {
1358
1380
  if (o)
1359
1381
  try {
1360
- g(!0);
1361
- const { roles: H } = await S.getRolesByApp(o);
1362
- f(H);
1363
- } catch (H) {
1364
- process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", H);
1382
+ m(!0);
1383
+ const { roles: C } = await S.getRolesByApp(o);
1384
+ g(C);
1385
+ } catch (C) {
1386
+ process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", C);
1365
1387
  } finally {
1366
- g(!1);
1388
+ m(!1);
1367
1389
  }
1368
1390
  }, gt = async () => {
1369
1391
  await ft();
1370
- }, Pe = (H) => {
1392
+ }, Pe = (C) => {
1371
1393
  if (!G || G.length === 0)
1372
1394
  return !1;
1373
- if (typeof H == "string")
1374
- return G.includes(H);
1375
- const O = `${H.resource}.${H.action}`;
1395
+ if (typeof C == "string")
1396
+ return G.includes(C);
1397
+ const O = `${C.resource}.${C.action}`;
1376
1398
  return G.includes(O);
1377
1399
  };
1378
1400
  return {
@@ -1396,29 +1418,29 @@ function xr({ config: n = {}, children: e }) {
1396
1418
  currentUser: T,
1397
1419
  isUserLoading: L,
1398
1420
  userError: P,
1399
- loadUserData: C,
1421
+ loadUserData: B,
1400
1422
  refreshUser: ce,
1401
- isAuthInitializing: !p,
1402
- isAuthReady: p,
1403
- userRole: Q,
1423
+ isAuthInitializing: !f,
1424
+ isAuthReady: f,
1425
+ userRole: K,
1404
1426
  userPermissions: G,
1405
1427
  availableRoles: y,
1406
- rolesLoading: D,
1428
+ rolesLoading: F,
1407
1429
  hasPermission: Pe,
1408
- hasAnyPermission: (H) => H.some((O) => Pe(O)),
1409
- hasAllPermissions: (H) => H.every((O) => Pe(O)),
1430
+ hasAnyPermission: (C) => C.some((O) => Pe(O)),
1431
+ hasAllPermissions: (C) => C.every((O) => Pe(O)),
1410
1432
  getUserPermissionStrings: () => G || [],
1411
1433
  refreshRoles: gt,
1412
1434
  // RFC-004: Multi-tenant user membership
1413
1435
  userTenants: v,
1414
1436
  hasTenantContext: $,
1415
- switchToTenant: async (H, O) => {
1437
+ switchToTenant: async (C, O) => {
1416
1438
  const { redirectPath: J } = O || {}, j = l.getTokens();
1417
1439
  if (!(j != null && j.refreshToken))
1418
1440
  throw new Error("No refresh token available for tenant switch");
1419
1441
  const Y = await b.switchTenant({
1420
1442
  refreshToken: j.refreshToken,
1421
- tenantId: H
1443
+ tenantId: C
1422
1444
  });
1423
1445
  l.setTokens({
1424
1446
  accessToken: Y.accessToken,
@@ -1426,8 +1448,8 @@ function xr({ config: n = {}, children: e }) {
1426
1448
  // Keep the same refresh token
1427
1449
  expiresIn: Y.expiresIn
1428
1450
  }), A(Y.user), l.setUser(Y.user), w(!0);
1429
- const ee = v.find((te) => te.id === H);
1430
- ee && m(ee.subdomain, {
1451
+ const ee = v.find((te) => te.id === C);
1452
+ ee && c(ee.subdomain, {
1431
1453
  tokens: {
1432
1454
  accessToken: Y.accessToken,
1433
1455
  refreshToken: j.refreshToken,
@@ -1437,7 +1459,7 @@ function xr({ config: n = {}, children: e }) {
1437
1459
  });
1438
1460
  },
1439
1461
  refreshUserTenants: async () => {
1440
- const H = await l.getAuthHeaders(), O = await b.getUserTenants(H);
1462
+ const C = await l.getAuthHeaders(), O = await b.getUserTenants(C);
1441
1463
  N(O);
1442
1464
  try {
1443
1465
  localStorage.setItem("userTenants", JSON.stringify(O));
@@ -1451,57 +1473,57 @@ function xr({ config: n = {}, children: e }) {
1451
1473
  l,
1452
1474
  U,
1453
1475
  b,
1454
- h,
1476
+ p,
1455
1477
  S,
1456
1478
  o,
1457
1479
  a,
1480
+ d,
1458
1481
  c,
1459
- m,
1460
1482
  y,
1461
1483
  T,
1462
1484
  L,
1463
1485
  P,
1464
1486
  v,
1465
1487
  $,
1466
- p,
1467
- Q,
1488
+ f,
1489
+ K,
1468
1490
  G
1469
1491
  ]);
1470
1492
  W.current = q.loadUserData, ne(() => {
1471
1493
  !n.initialRoles && o && (async () => {
1472
1494
  try {
1473
- g(!0);
1495
+ m(!0);
1474
1496
  const ce = new de(i), fe = new We(ce), { roles: ge } = await fe.getRolesByApp(o);
1475
- f(ge);
1497
+ g(ge);
1476
1498
  } catch (ce) {
1477
1499
  process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", ce);
1478
1500
  } finally {
1479
- g(!1);
1501
+ m(!1);
1480
1502
  }
1481
1503
  })();
1482
1504
  }, [o, i, n.initialRoles]);
1483
- const [V, B] = x(!1);
1505
+ const [V, H] = x(!1);
1484
1506
  return ne(() => {
1485
- V || (B(!0), R.current.urlTokens && (Et(), I(!0), q.loadUserData().catch((C) => {
1486
- process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", C);
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);
1487
1509
  }).finally(() => {
1488
1510
  I(!1);
1489
1511
  })));
1490
1512
  }, [q, V]), ne(() => {
1491
- let C = !1;
1513
+ let B = !1;
1492
1514
  return (async () => {
1493
1515
  var ge;
1494
- if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), C) return;
1516
+ if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), B) return;
1495
1517
  const fe = l.getUser();
1496
- fe && l.hasValidSession() && A(fe), F(!1);
1518
+ fe && l.hasValidSession() && A(fe), D(!1);
1497
1519
  })(), () => {
1498
- C = !0;
1520
+ B = !0;
1499
1521
  };
1500
1522
  }, [l]), ne(() => {
1501
1523
  V && (R.current.urlTokens || (!T && !L && !P && l.hasValidSession() ? W.current().catch(() => {
1502
1524
  }).finally(() => {
1503
- F(!1);
1504
- }) : F(!1)));
1525
+ D(!1);
1526
+ }) : D(!1)));
1505
1527
  }, [T, L, P, l, V]), /* @__PURE__ */ s($e.Provider, { value: q, children: e });
1506
1528
  }
1507
1529
  function he() {
@@ -1510,7 +1532,7 @@ function he() {
1510
1532
  throw new Error("useAuth must be used within an AuthProvider");
1511
1533
  return n;
1512
1534
  }
1513
- function Ce() {
1535
+ function Be() {
1514
1536
  return le($e);
1515
1537
  }
1516
1538
  class It {
@@ -1593,64 +1615,64 @@ class It {
1593
1615
  })).data;
1594
1616
  }
1595
1617
  }
1596
- const He = ye(null);
1618
+ const Ce = ye(null);
1597
1619
  function Ar({ config: n = {}, children: e }) {
1598
- const t = Fe(), 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), [D, g] = x(null), [T, A] = x(!1), L = Z(() => {
1599
- const d = new de(i);
1600
- 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);
1601
1623
  }, [i]), M = async () => {
1602
1624
  if (!(a != null && a.id)) {
1603
- m([]);
1625
+ c([]);
1604
1626
  return;
1605
1627
  }
1606
- f(!0), g(null);
1628
+ g(!0), m(null);
1607
1629
  try {
1608
- const d = await L.getTenantFeatureFlags(a.id, o);
1609
- m(d);
1610
- } catch (d) {
1611
- const v = d instanceof Error ? d.message : "Failed to fetch feature flags";
1612
- 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));
1613
1635
  } finally {
1614
- f(!1);
1636
+ g(!1);
1615
1637
  }
1616
1638
  };
1617
1639
  ne(() => {
1618
1640
  if (!i || !o) return;
1619
1641
  M().finally(() => A(!0));
1620
- const d = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, d);
1642
+ const u = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, u);
1621
1643
  return () => clearInterval(v);
1622
1644
  }, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
1623
1645
  const P = Z(() => {
1624
- const d = (R) => {
1625
- const k = c.find((I) => I.key === R);
1646
+ const u = (R) => {
1647
+ const k = d.find((I) => I.key === R);
1626
1648
  return (k == null ? void 0 : k.value) === !0;
1627
- }, v = (R) => c.find((k) => k.key === R), N = (R) => {
1628
- 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);
1629
1651
  return k ? k.value ? "enabled" : "disabled" : "not_found";
1630
1652
  }, $ = async () => {
1631
1653
  await M();
1632
1654
  }, w = !!(i && o) && (T || !(a != null && a.id));
1633
1655
  return {
1634
- featureFlags: c,
1656
+ featureFlags: d,
1635
1657
  loading: y,
1636
- error: D,
1658
+ error: F,
1637
1659
  isReady: w,
1638
- isEnabled: d,
1660
+ isEnabled: u,
1639
1661
  getFlag: v,
1640
1662
  getFlagState: N,
1641
1663
  refresh: $
1642
1664
  };
1643
- }, [c, y, D, i, o, a == null ? void 0 : a.id, T]);
1644
- return /* @__PURE__ */ s(He.Provider, { value: P, children: e });
1665
+ }, [d, y, F, i, o, a == null ? void 0 : a.id, T]);
1666
+ return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
1645
1667
  }
1646
1668
  function Mt() {
1647
- const n = le(He);
1669
+ const n = le(Ce);
1648
1670
  if (!n)
1649
1671
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1650
1672
  return n;
1651
1673
  }
1652
1674
  function Ye() {
1653
- return le(He);
1675
+ return le(Ce);
1654
1676
  }
1655
1677
  class Lt {
1656
1678
  constructor(e, t) {
@@ -1718,34 +1740,34 @@ class Lt {
1718
1740
  )).data;
1719
1741
  }
1720
1742
  }
1721
- const Be = ye(void 0);
1743
+ const He = ye(void 0);
1722
1744
  function Pr({ config: n = {}, children: e }) {
1723
- const t = Fe(), 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, D] = 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(() => {
1724
1746
  const P = new de(i);
1725
1747
  return new Lt(P);
1726
1748
  }, [i]), L = async () => {
1727
1749
  if (!(o != null && o.id)) {
1728
- c(null);
1750
+ d(null);
1729
1751
  return;
1730
1752
  }
1731
- y(!0), D(null);
1753
+ y(!0), F(null);
1732
1754
  try {
1733
1755
  const P = await A.getTenantSubscriptionFeatures(o.id);
1734
- c(P);
1756
+ d(P);
1735
1757
  } catch (P) {
1736
- const d = P instanceof Error ? P.message : "Failed to fetch subscription";
1737
- D(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));
1738
1760
  } finally {
1739
1761
  y(!1);
1740
1762
  }
1741
1763
  };
1742
1764
  ne(() => {
1743
1765
  if (!i || (L().finally(() => T(!0)), !n.refreshInterval)) return;
1744
- const P = n.refreshInterval || 10 * 60 * 1e3, d = setInterval(L, P);
1745
- return () => clearInterval(d);
1766
+ const P = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(L, P);
1767
+ return () => clearInterval(u);
1746
1768
  }, [o == null ? void 0 : o.id, i, n.refreshInterval]);
1747
1769
  const M = Z(() => {
1748
- const P = (a == null ? void 0 : a.features) || [], d = (k) => {
1770
+ const P = (a == null ? void 0 : a.features) || [], u = (k) => {
1749
1771
  const I = P.find((l) => l.key === k);
1750
1772
  return I ? I.type === "BOOLEAN" || I.type === "boolean" ? I.value === !0 : !!I.value : !1;
1751
1773
  }, v = (k) => P.find((I) => I.key === k), N = (k, I) => {
@@ -1753,30 +1775,30 @@ function Pr({ config: n = {}, children: e }) {
1753
1775
  return l ? l.value : I;
1754
1776
  }, $ = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
1755
1777
  await L();
1756
- }, R = !!i && (g || !(o != null && o.id));
1778
+ }, R = !!i && (m || !(o != null && o.id));
1757
1779
  return {
1758
1780
  subscription: a,
1759
1781
  features: P,
1760
- loading: m,
1761
- error: f,
1782
+ loading: c,
1783
+ error: g,
1762
1784
  isReady: R,
1763
- isFeatureEnabled: d,
1785
+ isFeatureEnabled: u,
1764
1786
  getFeature: v,
1765
1787
  getFeatureValue: N,
1766
1788
  hasAllowedPlan: $,
1767
1789
  refresh: w
1768
1790
  };
1769
- }, [a, m, f, i, o == null ? void 0 : o.id, g]);
1770
- return /* @__PURE__ */ s(Be.Provider, { value: M, children: e });
1791
+ }, [a, c, g, i, o == null ? void 0 : o.id, m]);
1792
+ return /* @__PURE__ */ s(He.Provider, { value: M, children: e });
1771
1793
  }
1772
1794
  function Nt() {
1773
- const n = le(Be);
1795
+ const n = le(He);
1774
1796
  if (n === void 0)
1775
1797
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1776
1798
  return n;
1777
1799
  }
1778
1800
  function Xe() {
1779
- return le(Be) ?? null;
1801
+ return le(He) ?? null;
1780
1802
  }
1781
1803
  var ae = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(ae || {});
1782
1804
  const Oe = {
@@ -1832,7 +1854,7 @@ function Er() {
1832
1854
  throw new Error("useRouting must be used within a RoutingProvider");
1833
1855
  return n;
1834
1856
  }
1835
- function Dt() {
1857
+ function Ft() {
1836
1858
  const n = le(qe);
1837
1859
  return n || {
1838
1860
  zoneRoots: Oe,
@@ -1844,7 +1866,7 @@ function Dt() {
1844
1866
  returnToStorage: "url"
1845
1867
  };
1846
1868
  }
1847
- const Ge = () => /* @__PURE__ */ u(
1869
+ const Ge = () => /* @__PURE__ */ h(
1848
1870
  "div",
1849
1871
  {
1850
1872
  style: {
@@ -1881,11 +1903,11 @@ const Ge = () => /* @__PURE__ */ u(
1881
1903
  )
1882
1904
  ]
1883
1905
  }
1884
- ), Qe = ({
1906
+ ), Ke = ({
1885
1907
  userType: n,
1886
1908
  minUserType: e,
1887
1909
  missingPermissions: t
1888
- }) => /* @__PURE__ */ u(
1910
+ }) => /* @__PURE__ */ h(
1889
1911
  "div",
1890
1912
  {
1891
1913
  style: {
@@ -1903,26 +1925,26 @@ const Ge = () => /* @__PURE__ */ u(
1903
1925
  children: [
1904
1926
  /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1905
1927
  /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1906
- e && n ? /* @__PURE__ */ u(_, { children: [
1907
- /* @__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: [
1908
1930
  "This content requires ",
1909
1931
  /* @__PURE__ */ s("strong", { children: e }),
1910
1932
  " access level or higher."
1911
1933
  ] }),
1912
- /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1934
+ /* @__PURE__ */ h("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1913
1935
  "Your current access level: ",
1914
1936
  /* @__PURE__ */ s("strong", { children: n })
1915
1937
  ] })
1916
- ] }) : /* @__PURE__ */ u(_, { children: [
1938
+ ] }) : /* @__PURE__ */ h(_, { children: [
1917
1939
  /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1918
- 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: [
1919
1941
  "Required permissions: ",
1920
1942
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
1921
1943
  ] })
1922
1944
  ] })
1923
1945
  ]
1924
1946
  }
1925
- ), Ft = (n, e) => {
1947
+ ), Dt = (n, e) => {
1926
1948
  const t = {
1927
1949
  [ae.USER]: 1,
1928
1950
  [ae.TENANT_ADMIN]: 2,
@@ -1937,17 +1959,17 @@ function Ir({
1937
1959
  requiredPermissions: r,
1938
1960
  requireAllPermissions: i = !1
1939
1961
  }) {
1940
- 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();
1941
1963
  if (!o())
1942
1964
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
1943
- const f = a.getUser();
1944
- if (!f)
1965
+ const g = a.getUser();
1966
+ if (!g)
1945
1967
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
1946
- if (t && !Ft(f.userType, t))
1947
- return /* @__PURE__ */ s(Qe, { userType: f.userType, minUserType: t });
1948
- if (r && r.length > 0 && !(i ? y(r) : m(r))) {
1949
- const g = r.filter((T) => !c(T)).map((T) => typeof T == "string" ? T : T.name);
1950
- return /* @__PURE__ */ s(Qe, { 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 });
1951
1973
  }
1952
1974
  return /* @__PURE__ */ s(_, { children: n });
1953
1975
  }
@@ -1964,7 +1986,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
1964
1986
  backgroundColor: "#f9fafb",
1965
1987
  textAlign: "center"
1966
1988
  },
1967
- children: /* @__PURE__ */ u(
1989
+ children: /* @__PURE__ */ h(
1968
1990
  "div",
1969
1991
  {
1970
1992
  style: {
@@ -1978,7 +2000,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
1978
2000
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1979
2001
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1980
2002
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1981
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2003
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1982
2004
  "Redirecting to ",
1983
2005
  n,
1984
2006
  "..."
@@ -1987,7 +2009,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
1987
2009
  }
1988
2010
  )
1989
2011
  }
1990
- ), Ke = ({
2012
+ ), Qe = ({
1991
2013
  userType: n,
1992
2014
  requiredUserType: e,
1993
2015
  missingPermissions: t
@@ -2004,7 +2026,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
2004
2026
  backgroundColor: "#f9fafb",
2005
2027
  textAlign: "center"
2006
2028
  },
2007
- children: /* @__PURE__ */ u(
2029
+ children: /* @__PURE__ */ h(
2008
2030
  "div",
2009
2031
  {
2010
2032
  style: {
@@ -2017,19 +2039,19 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
2017
2039
  children: [
2018
2040
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
2019
2041
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
2020
- e && n ? /* @__PURE__ */ u(_, { children: [
2021
- /* @__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: [
2022
2044
  "This page requires ",
2023
2045
  /* @__PURE__ */ s("strong", { children: e }),
2024
2046
  " access."
2025
2047
  ] }),
2026
- /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2048
+ /* @__PURE__ */ h("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
2027
2049
  "Your current user type: ",
2028
2050
  /* @__PURE__ */ s("strong", { children: n })
2029
2051
  ] })
2030
- ] }) : /* @__PURE__ */ u(_, { children: [
2052
+ ] }) : /* @__PURE__ */ h(_, { children: [
2031
2053
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
2032
- 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: [
2033
2055
  "Required permissions: ",
2034
2056
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
2035
2057
  ] })
@@ -2047,34 +2069,34 @@ function Mr({
2047
2069
  requireAllPermissions: i = !1,
2048
2070
  fallback: o
2049
2071
  }) {
2050
- const { hasValidSession: a, sessionManager: c, hasPermission: m, hasAnyPermission: y, hasAllPermissions: f } = he(), D = xe();
2072
+ const { hasValidSession: a, sessionManager: d, hasPermission: c, hasAnyPermission: y, hasAllPermissions: g } = he(), F = xe();
2051
2073
  if (ne(() => {
2052
2074
  process.env.NODE_ENV === "development" && console.warn(
2053
2075
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
2054
2076
  );
2055
2077
  }, []), !a())
2056
- return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ u(_, { children: [
2078
+ return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ h(_, { children: [
2057
2079
  /* @__PURE__ */ s(Ut, { redirectPath: e }),
2058
- /* @__PURE__ */ s(Se, { to: e, state: { from: D.pathname }, replace: !0 })
2080
+ /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 })
2059
2081
  ] });
2060
- const g = c.getUser();
2061
- if (!g)
2062
- return /* @__PURE__ */ s(Se, { to: e, state: { from: D.pathname }, replace: !0 });
2063
- if (t && !$t(g.userType, t))
2082
+ const m = d.getUser();
2083
+ if (!m)
2084
+ return /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 });
2085
+ if (t && !$t(m.userType, t))
2064
2086
  return /* @__PURE__ */ s(
2065
- Ke,
2087
+ Qe,
2066
2088
  {
2067
- userType: g.userType,
2089
+ userType: m.userType,
2068
2090
  requiredUserType: t
2069
2091
  }
2070
2092
  );
2071
- if (r && r.length > 0 && !(i ? f(r) : y(r))) {
2072
- const A = r.filter((L) => !m(L)).map((L) => typeof L == "string" ? L : L.name);
2073
- return /* @__PURE__ */ s(Ke, { missingPermissions: A });
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);
2095
+ return /* @__PURE__ */ s(Qe, { missingPermissions: A });
2074
2096
  }
2075
2097
  return /* @__PURE__ */ s(_, { children: n });
2076
2098
  }
2077
- const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2099
+ const Bt = ({ redirectPath: n }) => /* @__PURE__ */ s(
2078
2100
  "div",
2079
2101
  {
2080
2102
  style: {
@@ -2087,7 +2109,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2087
2109
  backgroundColor: "#f9fafb",
2088
2110
  textAlign: "center"
2089
2111
  },
2090
- children: /* @__PURE__ */ u(
2112
+ children: /* @__PURE__ */ h(
2091
2113
  "div",
2092
2114
  {
2093
2115
  style: {
@@ -2101,7 +2123,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2101
2123
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
2102
2124
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
2103
2125
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
2104
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2126
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2105
2127
  "Redirecting to ",
2106
2128
  n,
2107
2129
  "..."
@@ -2117,12 +2139,12 @@ function Lr({ children: n, redirectTo: e = "/", fallback: t }) {
2117
2139
  process.env.NODE_ENV === "development" && console.warn(
2118
2140
  "[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
2119
2141
  );
2120
- }, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
2121
- /* @__PURE__ */ s(Ct, { 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 }),
2122
2144
  /* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
2123
2145
  ] });
2124
2146
  }
2125
- const Ht = ({ redirectPath: n }) => /* @__PURE__ */ s(
2147
+ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
2126
2148
  "div",
2127
2149
  {
2128
2150
  style: {
@@ -2135,7 +2157,7 @@ const Ht = ({ redirectPath: n }) => /* @__PURE__ */ s(
2135
2157
  backgroundColor: "#f9fafb",
2136
2158
  textAlign: "center"
2137
2159
  },
2138
- children: /* @__PURE__ */ u(
2160
+ children: /* @__PURE__ */ h(
2139
2161
  "div",
2140
2162
  {
2141
2163
  style: {
@@ -2149,7 +2171,7 @@ const Ht = ({ redirectPath: n }) => /* @__PURE__ */ s(
2149
2171
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
2150
2172
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
2151
2173
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
2152
- /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2174
+ /* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
2153
2175
  "Redirecting to ",
2154
2176
  n,
2155
2177
  "..."
@@ -2165,19 +2187,19 @@ function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
2165
2187
  process.env.NODE_ENV === "development" && console.warn(
2166
2188
  "[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
2167
2189
  );
2168
- }, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
2169
- /* @__PURE__ */ s(Ht, { redirectPath: e }),
2190
+ }, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ h(_, { children: [
2191
+ /* @__PURE__ */ s(Ct, { redirectPath: e }),
2170
2192
  /* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
2171
2193
  ] }) : /* @__PURE__ */ s(_, { children: n });
2172
2194
  }
2173
- function Bt(n, e) {
2195
+ function Ht(n, e) {
2174
2196
  return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
2175
2197
  }
2176
2198
  function Ze(n, e) {
2177
2199
  return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
2178
2200
  }
2179
2201
  function Ot(n, e) {
2180
- return Ze(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ze(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Bt(e.userType, n.userType) ? "wrong_user_type" : n.permissions && n.permissions.length > 0 && !(n.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(n.permissions) ? "missing_permissions" : null;
2202
+ return Ze(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ze(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Ht(e.userType, n.userType) ? "wrong_user_type" : n.permissions && n.permissions.length > 0 && !(n.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(n.permissions) ? "missing_permissions" : null;
2181
2203
  }
2182
2204
  function qt(n, e) {
2183
2205
  return n.hasTenant ? n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
@@ -2201,13 +2223,13 @@ const ue = ({
2201
2223
  userType: i,
2202
2224
  requiredPermissions: o,
2203
2225
  requireAllPermissions: a = !0,
2204
- returnTo: c,
2205
- onAccessDenied: m,
2226
+ returnTo: d,
2227
+ onAccessDenied: c,
2206
2228
  redirectTo: y,
2207
- loadingFallback: f,
2208
- accessDeniedFallback: D
2229
+ loadingFallback: g,
2230
+ accessDeniedFallback: F
2209
2231
  }) => {
2210
- const g = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: d } = Te(), v = Dt(), N = Z(() => {
2232
+ const m = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: u } = Te(), v = Ft(), N = Z(() => {
2211
2233
  if (e)
2212
2234
  return v.presets[e];
2213
2235
  }, [e, v.presets]), $ = Z(
@@ -2225,7 +2247,7 @@ const ue = ({
2225
2247
  isAuthenticated: T,
2226
2248
  userType: L == null ? void 0 : L.userType,
2227
2249
  permissions: M,
2228
- isLoading: A || d
2250
+ isLoading: A || u
2229
2251
  }),
2230
2252
  [
2231
2253
  P,
@@ -2233,7 +2255,7 @@ const ue = ({
2233
2255
  L == null ? void 0 : L.userType,
2234
2256
  M,
2235
2257
  A,
2236
- d
2258
+ u
2237
2259
  ]
2238
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 : {
2239
2261
  type: R,
@@ -2252,32 +2274,32 @@ const ue = ({
2252
2274
  redirectTo: k
2253
2275
  }, [R, k, $, w]);
2254
2276
  if (ne(() => {
2255
- I && (m ? m(I) : v.onAccessDenied && v.onAccessDenied(I));
2256
- }, [I, m, v]), ne(() => {
2257
- 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);
2258
2280
  }, [
2259
2281
  I,
2260
- c,
2261
- g.pathname,
2262
- g.search,
2282
+ d,
2283
+ m.pathname,
2284
+ m.search,
2263
2285
  v.returnToStorage
2264
2286
  ]), w.isLoading)
2265
- return /* @__PURE__ */ s(_, { children: f ?? v.loadingFallback ?? null });
2287
+ return /* @__PURE__ */ s(_, { children: g ?? v.loadingFallback ?? null });
2266
2288
  if (I && k) {
2267
- const l = D ?? v.accessDeniedFallback;
2289
+ const l = F ?? v.accessDeniedFallback;
2268
2290
  if (l)
2269
2291
  return /* @__PURE__ */ s(_, { children: l });
2270
2292
  const z = _t(
2271
2293
  k,
2272
- c,
2273
- g.pathname + g.search,
2294
+ d,
2295
+ m.pathname + m.search,
2274
2296
  v.returnToParam,
2275
2297
  v.returnToStorage
2276
2298
  );
2277
2299
  return /* @__PURE__ */ s(Se, { to: z, replace: !0 });
2278
2300
  }
2279
2301
  return /* @__PURE__ */ s(_, { children: n });
2280
- }, Dr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", ...n }), Fr = (n) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(ue, { auth: "required", ...n }), $r = (n) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...n }), Cr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Hr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...n }), Br = (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(
2281
2303
  "div",
2282
2304
  {
2283
2305
  style: {
@@ -2300,8 +2322,8 @@ function zr({
2300
2322
  allowedPlans: t,
2301
2323
  requiredFeature: r
2302
2324
  }) {
2303
- const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: c } = Nt();
2304
- return c ? /* @__PURE__ */ s(
2325
+ const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: d } = Nt();
2326
+ return d ? /* @__PURE__ */ s(
2305
2327
  "div",
2306
2328
  {
2307
2329
  style: {
@@ -2313,7 +2335,7 @@ function zr({
2313
2335
  }
2314
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 });
2315
2337
  }
2316
- const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
2338
+ const Wt = ({ flagName: n }) => /* @__PURE__ */ h(
2317
2339
  "div",
2318
2340
  {
2319
2341
  style: {
@@ -2332,7 +2354,7 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
2332
2354
  children: [
2333
2355
  /* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
2334
2356
  /* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
2335
- /* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2357
+ /* @__PURE__ */ h("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2336
2358
  'Feature flag "',
2337
2359
  n,
2338
2360
  '" is disabled'
@@ -2357,7 +2379,7 @@ function Vr({ name: n, children: e, fallback: t }) {
2357
2379
  }
2358
2380
  ) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Wt, { flagName: n }) });
2359
2381
  }
2360
- const jt = () => /* @__PURE__ */ u(
2382
+ const jt = () => /* @__PURE__ */ h(
2361
2383
  "svg",
2362
2384
  {
2363
2385
  width: "16",
@@ -2374,7 +2396,7 @@ const jt = () => /* @__PURE__ */ u(
2374
2396
  /* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
2375
2397
  ]
2376
2398
  }
2377
- ), Gt = () => /* @__PURE__ */ u(
2399
+ ), Gt = () => /* @__PURE__ */ h(
2378
2400
  "svg",
2379
2401
  {
2380
2402
  width: "16",
@@ -2391,10 +2413,10 @@ const jt = () => /* @__PURE__ */ u(
2391
2413
  /* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
2392
2414
  ]
2393
2415
  }
2394
- ), Qt = {
2416
+ ), Kt = {
2395
2417
  showPassword: /* @__PURE__ */ s(jt, {}),
2396
2418
  hidePassword: /* @__PURE__ */ s(Gt, {})
2397
- }, Kt = {
2419
+ }, Qt = {
2398
2420
  title: "Sign In",
2399
2421
  usernameLabel: "Email or Phone",
2400
2422
  usernamePlaceholder: "Enter your email or phone number",
@@ -2530,21 +2552,21 @@ function Wr({
2530
2552
  onError: i,
2531
2553
  onForgotPassword: o,
2532
2554
  onSignupClick: a,
2533
- onMagicLinkClick: c,
2534
- showForgotPassword: m = !0,
2555
+ onMagicLinkClick: d,
2556
+ showForgotPassword: c = !0,
2535
2557
  showSignupLink: y = !0,
2536
- showMagicLinkOption: f = !0,
2537
- className: D
2558
+ showMagicLinkOption: g = !0,
2559
+ className: F
2538
2560
  }) {
2539
- const [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, $] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Kt, ...n }, l = { ...Zt, ...e }, z = { ...Qt, ...t }, F = () => {
2540
- const h = {};
2541
- return g.trim() || (h.username = !0), A.trim() || (h.password = !0), R(h), Object.keys(h).length === 0;
2542
- }, p = async (h) => {
2543
- if (h.preventDefault(), !!F()) {
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()) {
2544
2566
  v(!0), $("");
2545
2567
  try {
2546
2568
  const S = await k({
2547
- username: g,
2569
+ username: m,
2548
2570
  password: A
2549
2571
  // tenantId inferred from context automatically
2550
2572
  });
@@ -2556,18 +2578,18 @@ function Wr({
2556
2578
  v(!1);
2557
2579
  }
2558
2580
  }
2559
- }, U = (h) => ({
2581
+ }, U = (p) => ({
2560
2582
  ...l.input,
2561
- ...w[h] ? l.inputError : {}
2583
+ ...w[p] ? l.inputError : {}
2562
2584
  }), b = () => ({
2563
2585
  ...l.button,
2564
- ...d ? l.buttonLoading : {},
2565
- ...!g || !A || d ? l.buttonDisabled : {}
2586
+ ...u ? l.buttonLoading : {},
2587
+ ...!m || !A || u ? l.buttonDisabled : {}
2566
2588
  });
2567
- return /* @__PURE__ */ u("div", { className: D, style: l.container, children: [
2589
+ return /* @__PURE__ */ h("div", { className: F, style: l.container, children: [
2568
2590
  /* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
2569
- /* @__PURE__ */ u("form", { onSubmit: p, style: l.form, children: [
2570
- /* @__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: [
2571
2593
  /* @__PURE__ */ s("label", { style: l.label, children: I.usernameLabel }),
2572
2594
  /* @__PURE__ */ s(
2573
2595
  "input",
@@ -2575,19 +2597,19 @@ function Wr({
2575
2597
  id: "username",
2576
2598
  name: "username",
2577
2599
  type: "text",
2578
- value: g,
2579
- onChange: (h) => {
2580
- 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 }));
2581
2603
  },
2582
2604
  placeholder: I.usernamePlaceholder,
2583
2605
  style: U("username"),
2584
- disabled: d
2606
+ disabled: u
2585
2607
  }
2586
2608
  )
2587
2609
  ] }),
2588
- /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2610
+ /* @__PURE__ */ h("div", { style: l.fieldGroup, children: [
2589
2611
  /* @__PURE__ */ s("label", { style: l.label, children: I.passwordLabel }),
2590
- /* @__PURE__ */ u("div", { style: l.inputContainer, children: [
2612
+ /* @__PURE__ */ h("div", { style: l.inputContainer, children: [
2591
2613
  /* @__PURE__ */ s(
2592
2614
  "input",
2593
2615
  {
@@ -2595,15 +2617,15 @@ function Wr({
2595
2617
  name: "password",
2596
2618
  type: M ? "text" : "password",
2597
2619
  value: A,
2598
- onChange: (h) => {
2599
- 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 }));
2600
2622
  },
2601
2623
  placeholder: I.passwordPlaceholder,
2602
2624
  style: {
2603
2625
  ...U("password"),
2604
2626
  ...l.inputWithIcon
2605
2627
  },
2606
- disabled: d
2628
+ disabled: u
2607
2629
  }
2608
2630
  ),
2609
2631
  /* @__PURE__ */ s(
@@ -2612,29 +2634,29 @@ function Wr({
2612
2634
  type: "button",
2613
2635
  onClick: () => P(!M),
2614
2636
  style: l.passwordToggle,
2615
- disabled: d,
2637
+ disabled: u,
2616
2638
  "aria-label": M ? I.hidePasswordAriaLabel : I.showPasswordAriaLabel,
2617
2639
  children: M ? z.hidePassword : z.showPassword
2618
2640
  }
2619
2641
  )
2620
2642
  ] })
2621
2643
  ] }),
2622
- /* @__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 }),
2623
2645
  N && /* @__PURE__ */ s("div", { style: l.errorText, children: N })
2624
2646
  ] }),
2625
- (m || y || f) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2626
- f && /* @__PURE__ */ u("div", { children: [
2627
- /* @__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: [
2628
2650
  I.magicLinkText,
2629
2651
  " "
2630
2652
  ] }),
2631
- /* @__PURE__ */ s("a", { onClick: c, style: l.link, children: I.magicLinkLink })
2653
+ /* @__PURE__ */ s("a", { onClick: d, style: l.link, children: I.magicLinkLink })
2632
2654
  ] }),
2633
- f && (m || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2634
- m && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
2635
- m && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
2636
- y && /* @__PURE__ */ u("div", { children: [
2637
- /* @__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: [
2638
2660
  I.signupText,
2639
2661
  " "
2640
2662
  ] }),
@@ -2785,61 +2807,61 @@ function jr({
2785
2807
  onError: i,
2786
2808
  onLoginClick: o,
2787
2809
  onMagicLinkClick: a,
2788
- showLoginLink: c = !0,
2789
- showMagicLinkOption: m = !0,
2810
+ showLoginLink: d = !0,
2811
+ showMagicLinkOption: c = !0,
2790
2812
  className: y
2791
2813
  }) {
2792
2814
  var V;
2793
- const [f, D] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(""), [d, v] = x(""), [N, $] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [F, p] = x({}), { signup: U, signupTenantAdmin: b } = he(), h = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Jt, ...n }, E = { ...Yt, ...e }, Q = () => {
2794
- const B = {};
2795
- return f.trim() || (B.name = !0), !A.trim() && !M.trim() && (B.email = !0, B.phoneNumber = !0), d.trim() || (B.password = !0), N.trim() || (B.confirmPassword = !0), t === "tenant" && !w.trim() && (B.tenantName = !0), p(B), Object.keys(B).length === 0;
2796
- }, G = async (B) => {
2797
- if (B.preventDefault(), !!Q()) {
2798
- if (d !== N) {
2799
- z(S.passwordMismatchError), p({ confirmPassword: !0 });
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 = () => {
2816
+ const H = {};
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;
2818
+ }, G = async (H) => {
2819
+ if (H.preventDefault(), !!K()) {
2820
+ if (u !== N) {
2821
+ z(S.passwordMismatchError), f({ confirmPassword: !0 });
2800
2822
  return;
2801
2823
  }
2802
- if (t === "user" && !(h != null && h.id)) {
2824
+ if (t === "user" && !(p != null && p.id)) {
2803
2825
  z(S.tenantNotFoundError);
2804
2826
  return;
2805
2827
  }
2806
2828
  I(!0), z("");
2807
2829
  try {
2808
- let C;
2809
- t === "tenant" ? C = await b({
2830
+ let B;
2831
+ t === "tenant" ? B = await b({
2810
2832
  email: A || void 0,
2811
2833
  phoneNumber: M || void 0,
2812
- name: f,
2813
- password: d,
2834
+ name: g,
2835
+ password: u,
2814
2836
  tenantName: w,
2815
- lastName: g || void 0
2816
- }) : C = await U({
2837
+ lastName: m || void 0
2838
+ }) : B = await U({
2817
2839
  email: A || void 0,
2818
2840
  phoneNumber: M || void 0,
2819
- name: f,
2820
- password: d,
2821
- tenantId: h.id,
2822
- lastName: g || void 0
2823
- }), r == null || r(C);
2824
- } catch (C) {
2825
- const ce = C.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;
2826
2848
  z(ce), i == null || i(ce);
2827
2849
  } finally {
2828
2850
  I(!1);
2829
2851
  }
2830
2852
  }
2831
- }, X = (B) => ({
2853
+ }, X = (H) => ({
2832
2854
  ...E.input,
2833
- ...F[B] ? E.inputError : {}
2855
+ ...D[H] ? E.inputError : {}
2834
2856
  }), W = () => ({
2835
2857
  ...E.button,
2836
2858
  ...k ? E.buttonLoading : {},
2837
- ...!f || !A && !M || !d || !N || k || t === "tenant" && !w ? E.buttonDisabled : {}
2838
- }), q = f && (A || M) && d && N && (t === "user" || w);
2839
- 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: [
2840
2862
  /* @__PURE__ */ s("h2", { style: E.title, children: S.title }),
2841
- /* @__PURE__ */ u("form", { onSubmit: G, style: E.form, children: [
2842
- /* @__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: [
2843
2865
  /* @__PURE__ */ s("label", { style: E.label, children: S.nameLabel }),
2844
2866
  /* @__PURE__ */ s(
2845
2867
  "input",
@@ -2847,9 +2869,9 @@ function jr({
2847
2869
  id: "name",
2848
2870
  name: "name",
2849
2871
  type: "text",
2850
- value: f,
2851
- onChange: (B) => {
2852
- D(B.target.value), F.name && p((C) => ({ ...C, name: !1 }));
2872
+ value: g,
2873
+ onChange: (H) => {
2874
+ F(H.target.value), D.name && f((B) => ({ ...B, name: !1 }));
2853
2875
  },
2854
2876
  placeholder: S.namePlaceholder,
2855
2877
  style: X("name"),
@@ -2857,7 +2879,7 @@ function jr({
2857
2879
  }
2858
2880
  )
2859
2881
  ] }),
2860
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2882
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2861
2883
  /* @__PURE__ */ s("label", { style: E.label, children: S.lastNameLabel }),
2862
2884
  /* @__PURE__ */ s(
2863
2885
  "input",
@@ -2865,15 +2887,15 @@ function jr({
2865
2887
  id: "lastName",
2866
2888
  name: "lastName",
2867
2889
  type: "text",
2868
- value: g,
2869
- onChange: (B) => T(B.target.value),
2890
+ value: m,
2891
+ onChange: (H) => T(H.target.value),
2870
2892
  placeholder: S.lastNamePlaceholder,
2871
2893
  style: E.input,
2872
2894
  disabled: k
2873
2895
  }
2874
2896
  )
2875
2897
  ] }),
2876
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2898
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2877
2899
  /* @__PURE__ */ s("label", { style: E.label, children: S.emailLabel }),
2878
2900
  /* @__PURE__ */ s(
2879
2901
  "input",
@@ -2882,8 +2904,8 @@ function jr({
2882
2904
  name: "email",
2883
2905
  type: "email",
2884
2906
  value: A,
2885
- onChange: (B) => {
2886
- L(B.target.value), F.email && p((C) => ({ ...C, email: !1, phoneNumber: !1 }));
2907
+ onChange: (H) => {
2908
+ L(H.target.value), D.email && f((B) => ({ ...B, email: !1, phoneNumber: !1 }));
2887
2909
  },
2888
2910
  placeholder: S.emailPlaceholder,
2889
2911
  style: X("email"),
@@ -2891,7 +2913,7 @@ function jr({
2891
2913
  }
2892
2914
  )
2893
2915
  ] }),
2894
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2916
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2895
2917
  /* @__PURE__ */ s("label", { style: E.label, children: S.phoneNumberLabel }),
2896
2918
  /* @__PURE__ */ s(
2897
2919
  "input",
@@ -2900,8 +2922,8 @@ function jr({
2900
2922
  name: "phoneNumber",
2901
2923
  type: "tel",
2902
2924
  value: M,
2903
- onChange: (B) => {
2904
- P(B.target.value), F.phoneNumber && p((C) => ({ ...C, email: !1, phoneNumber: !1 }));
2925
+ onChange: (H) => {
2926
+ P(H.target.value), D.phoneNumber && f((B) => ({ ...B, email: !1, phoneNumber: !1 }));
2905
2927
  },
2906
2928
  placeholder: S.phoneNumberPlaceholder,
2907
2929
  style: X("phoneNumber"),
@@ -2910,7 +2932,7 @@ function jr({
2910
2932
  )
2911
2933
  ] }),
2912
2934
  /* @__PURE__ */ s("div", { style: E.hintText, children: S.contactMethodHint }),
2913
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2935
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2914
2936
  /* @__PURE__ */ s("label", { style: E.label, children: S.passwordLabel }),
2915
2937
  /* @__PURE__ */ s(
2916
2938
  "input",
@@ -2918,9 +2940,9 @@ function jr({
2918
2940
  id: "password",
2919
2941
  name: "password",
2920
2942
  type: "password",
2921
- value: d,
2922
- onChange: (B) => {
2923
- v(B.target.value), F.password && p((C) => ({ ...C, password: !1 }));
2943
+ value: u,
2944
+ onChange: (H) => {
2945
+ v(H.target.value), D.password && f((B) => ({ ...B, password: !1 }));
2924
2946
  },
2925
2947
  placeholder: S.passwordPlaceholder,
2926
2948
  style: X("password"),
@@ -2928,7 +2950,7 @@ function jr({
2928
2950
  }
2929
2951
  )
2930
2952
  ] }),
2931
- /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2953
+ /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2932
2954
  /* @__PURE__ */ s("label", { style: E.label, children: S.confirmPasswordLabel }),
2933
2955
  /* @__PURE__ */ s(
2934
2956
  "input",
@@ -2937,8 +2959,8 @@ function jr({
2937
2959
  name: "confirmPassword",
2938
2960
  type: "password",
2939
2961
  value: N,
2940
- onChange: (B) => {
2941
- $(B.target.value), F.confirmPassword && p((C) => ({ ...C, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
2962
+ onChange: (H) => {
2963
+ $(H.target.value), D.confirmPassword && f((B) => ({ ...B, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
2942
2964
  },
2943
2965
  placeholder: S.confirmPasswordPlaceholder,
2944
2966
  style: X("confirmPassword"),
@@ -2946,7 +2968,7 @@ function jr({
2946
2968
  }
2947
2969
  )
2948
2970
  ] }),
2949
- t === "tenant" && /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
2971
+ t === "tenant" && /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
2950
2972
  /* @__PURE__ */ s("label", { style: E.label, children: S.tenantNameLabel }),
2951
2973
  /* @__PURE__ */ s(
2952
2974
  "input",
@@ -2955,8 +2977,8 @@ function jr({
2955
2977
  name: "tenantName",
2956
2978
  type: "text",
2957
2979
  value: w,
2958
- onChange: (B) => {
2959
- R(B.target.value), F.tenantName && p((C) => ({ ...C, tenantName: !1 }));
2980
+ onChange: (H) => {
2981
+ R(H.target.value), D.tenantName && f((B) => ({ ...B, tenantName: !1 }));
2960
2982
  },
2961
2983
  placeholder: S.tenantNamePlaceholder,
2962
2984
  style: X("tenantName"),
@@ -2967,17 +2989,17 @@ function jr({
2967
2989
  /* @__PURE__ */ s("button", { type: "submit", disabled: !q || k, style: W(), children: k ? S.loadingText : S.submitButton }),
2968
2990
  l && /* @__PURE__ */ s("div", { style: E.errorText, children: l })
2969
2991
  ] }),
2970
- (c || m) && /* @__PURE__ */ u("div", { style: E.linkContainer, children: [
2971
- m && /* @__PURE__ */ u("div", { children: [
2972
- /* @__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: [
2973
2995
  S.magicLinkText,
2974
2996
  " "
2975
2997
  ] }),
2976
2998
  /* @__PURE__ */ s("a", { onClick: a, style: E.link, children: S.magicLinkLink })
2977
2999
  ] }),
2978
- m && c && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
2979
- c && /* @__PURE__ */ u("div", { children: [
2980
- /* @__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: [
2981
3003
  S.loginText,
2982
3004
  " "
2983
3005
  ] }),
@@ -3141,38 +3163,38 @@ function Gr({
3141
3163
  onLoginClick: i,
3142
3164
  onSignupClick: o,
3143
3165
  showTraditionalLinks: a = !0,
3144
- className: c,
3145
- verifyToken: m,
3166
+ className: d,
3167
+ verifyToken: c,
3146
3168
  frontendUrl: y
3147
3169
  }) {
3148
3170
  var W;
3149
- const [f, D] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, $] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: F, 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 };
3150
3172
  ne(() => {
3151
- m && S(m);
3152
- }, [m]);
3173
+ c && S(c);
3174
+ }, [c]);
3153
3175
  const S = async (q) => {
3154
- if (!U || !f) {
3176
+ if (!U || !g) {
3155
3177
  $(b.missingTenantOrEmailError);
3156
3178
  return;
3157
3179
  }
3158
3180
  v(!0), $("");
3159
3181
  try {
3160
- const V = await p({
3182
+ const V = await f({
3161
3183
  token: q,
3162
- email: f
3184
+ email: g
3163
3185
  // tenantId inferred from context automatically
3164
3186
  });
3165
3187
  t == null || t(V);
3166
3188
  } catch (V) {
3167
- const B = V.message || "Failed to verify magic link";
3168
- $(B), r == null || r(B);
3189
+ const H = V.message || "Failed to verify magic link";
3190
+ $(H), r == null || r(H);
3169
3191
  } finally {
3170
3192
  v(!1);
3171
3193
  }
3172
3194
  }, E = () => {
3173
3195
  const q = {};
3174
- return f.trim() || (q.email = !0), l && !g.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
3175
- }, Q = async (q) => {
3196
+ return g.trim() || (q.email = !0), l && !m.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
3197
+ }, K = async (q) => {
3176
3198
  if (q.preventDefault(), !!E()) {
3177
3199
  if (!(U != null && U.id)) {
3178
3200
  $(b.tenantNotFoundError);
@@ -3180,84 +3202,84 @@ function Gr({
3180
3202
  }
3181
3203
  P(!0), $(""), R("");
3182
3204
  try {
3183
- const V = y || (typeof window < "u" ? window.location.origin : ""), B = await F({
3184
- email: f,
3205
+ const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
3206
+ email: g,
3185
3207
  tenantId: U.id,
3186
3208
  frontendUrl: V,
3187
- name: l ? g : void 0,
3209
+ name: l ? m : void 0,
3188
3210
  lastName: l ? A : void 0
3189
3211
  });
3190
- R(b.successMessage), t == null || t(B);
3212
+ R(b.successMessage), t == null || t(H);
3191
3213
  } catch (V) {
3192
- const B = V.message || b.errorMessage;
3193
- $(B), r == null || r(B);
3214
+ const H = V.message || b.errorMessage;
3215
+ $(H), r == null || r(H);
3194
3216
  } finally {
3195
3217
  P(!1);
3196
3218
  }
3197
3219
  }
3198
3220
  }, G = (q) => ({
3199
- ...h.input,
3200
- ...k[q] ? h.inputError : {}
3221
+ ...p.input,
3222
+ ...k[q] ? p.inputError : {}
3201
3223
  }), X = () => ({
3202
- ...h.button,
3203
- ...M || d ? h.buttonLoading : {},
3204
- ...!f || M || d ? h.buttonDisabled : {}
3224
+ ...p.button,
3225
+ ...M || u ? p.buttonLoading : {},
3226
+ ...!g || M || u ? p.buttonDisabled : {}
3205
3227
  });
3206
- return d ? /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
3207
- /* @__PURE__ */ s("h2", { style: h.title, children: b.verifyingText }),
3208
- /* @__PURE__ */ s("div", { style: h.verifyingContainer, children: /* @__PURE__ */ s("div", { style: h.verifyingText, children: b.verifyingDescription }) })
3209
- ] }) : /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
3210
- /* @__PURE__ */ s("h2", { style: h.title, children: b.title }),
3211
- /* @__PURE__ */ s("p", { style: h.description, children: b.description }),
3212
- /* @__PURE__ */ u("form", { onSubmit: Q, style: h.form, children: [
3213
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3214
- /* @__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 }),
3215
3237
  /* @__PURE__ */ s(
3216
3238
  "input",
3217
3239
  {
3218
3240
  id: "email",
3219
3241
  name: "email",
3220
3242
  type: "email",
3221
- value: f,
3243
+ value: g,
3222
3244
  onChange: (q) => {
3223
- D(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
3245
+ F(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
3224
3246
  },
3225
3247
  placeholder: b.emailPlaceholder,
3226
3248
  style: G("email"),
3227
- disabled: M || d
3249
+ disabled: M || u
3228
3250
  }
3229
3251
  )
3230
3252
  ] }),
3231
- !l && /* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
3253
+ !l && /* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
3232
3254
  "button",
3233
3255
  {
3234
3256
  type: "button",
3235
3257
  onClick: () => z(!0),
3236
- style: h.toggleLink,
3258
+ style: p.toggleLink,
3237
3259
  children: b.showNameToggle
3238
3260
  }
3239
3261
  ) }),
3240
- l && /* @__PURE__ */ u(_, { children: [
3241
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3242
- /* @__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 }),
3243
3265
  /* @__PURE__ */ s(
3244
3266
  "input",
3245
3267
  {
3246
3268
  id: "name",
3247
3269
  name: "name",
3248
3270
  type: "text",
3249
- value: g,
3271
+ value: m,
3250
3272
  onChange: (q) => {
3251
3273
  T(q.target.value), k.name && I((V) => ({ ...V, name: !1 }));
3252
3274
  },
3253
3275
  placeholder: b.namePlaceholder,
3254
3276
  style: G("name"),
3255
- disabled: M || d
3277
+ disabled: M || u
3256
3278
  }
3257
3279
  )
3258
3280
  ] }),
3259
- /* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
3260
- /* @__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 }),
3261
3283
  /* @__PURE__ */ s(
3262
3284
  "input",
3263
3285
  {
@@ -3267,42 +3289,42 @@ function Gr({
3267
3289
  value: A,
3268
3290
  onChange: (q) => L(q.target.value),
3269
3291
  placeholder: b.lastNamePlaceholder,
3270
- style: h.input,
3271
- disabled: M || d
3292
+ style: p.input,
3293
+ disabled: M || u
3272
3294
  }
3273
3295
  )
3274
3296
  ] }),
3275
- /* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
3297
+ /* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
3276
3298
  "button",
3277
3299
  {
3278
3300
  type: "button",
3279
3301
  onClick: () => {
3280
3302
  z(!1), T(""), L("");
3281
3303
  },
3282
- style: h.toggleLink,
3304
+ style: p.toggleLink,
3283
3305
  children: b.hideNameToggle
3284
3306
  }
3285
3307
  ) })
3286
3308
  ] }),
3287
- /* @__PURE__ */ s("button", { type: "submit", disabled: !f || M || d, style: X(), children: M ? b.loadingText : b.submitButton }),
3288
- N && /* @__PURE__ */ s("div", { style: h.errorText, children: N }),
3289
- 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 })
3290
3312
  ] }),
3291
- a && /* @__PURE__ */ u("div", { style: h.linkContainer, children: [
3292
- /* @__PURE__ */ u("div", { children: [
3293
- /* @__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: [
3294
3316
  b.loginText,
3295
3317
  " "
3296
3318
  ] }),
3297
- /* @__PURE__ */ s("a", { onClick: i, style: h.link, children: b.loginLink })
3319
+ /* @__PURE__ */ s("a", { onClick: i, style: p.link, children: b.loginLink })
3298
3320
  ] }),
3299
- /* @__PURE__ */ s("div", { style: h.divider, children: b.dividerBullet }),
3300
- /* @__PURE__ */ u("div", { children: [
3301
- /* @__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: [
3302
3324
  b.signupText,
3303
3325
  " "
3304
3326
  ] }),
3305
- /* @__PURE__ */ s("a", { onClick: o, style: h.link, children: b.signupLink })
3327
+ /* @__PURE__ */ s("a", { onClick: o, style: p.link, children: b.signupLink })
3306
3328
  ] })
3307
3329
  ] })
3308
3330
  ] });
@@ -3409,7 +3431,7 @@ const tr = {
3409
3431
  backButtonHover: {
3410
3432
  backgroundColor: "#e5e7eb"
3411
3433
  }
3412
- }, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ u(
3434
+ }, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ h(
3413
3435
  "svg",
3414
3436
  {
3415
3437
  width: "48",
@@ -3426,7 +3448,7 @@ const tr = {
3426
3448
  /* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
3427
3449
  ]
3428
3450
  }
3429
- ), sr = () => /* @__PURE__ */ u(
3451
+ ), sr = () => /* @__PURE__ */ h(
3430
3452
  "svg",
3431
3453
  {
3432
3454
  width: "48",
@@ -3449,7 +3471,7 @@ const tr = {
3449
3471
  success: /* @__PURE__ */ s(nr, {}),
3450
3472
  error: /* @__PURE__ */ s(sr, {})
3451
3473
  };
3452
- function Qr({
3474
+ function Kr({
3453
3475
  copy: n = {},
3454
3476
  styles: e = {},
3455
3477
  icons: t = {},
@@ -3457,38 +3479,38 @@ function Qr({
3457
3479
  onError: i,
3458
3480
  onRetry: o,
3459
3481
  onBackToLogin: a,
3460
- className: c,
3461
- token: m,
3482
+ className: d,
3483
+ token: c,
3462
3484
  email: y,
3463
- appId: f,
3464
- tenantSlug: D,
3465
- autoRedirectDelay: g = 3e3
3485
+ appId: g,
3486
+ tenantSlug: F,
3487
+ autoRedirectDelay: m = 3e3
3466
3488
  }) {
3467
- const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), d = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, $ = () => {
3489
+ const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), u = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, $ = () => {
3468
3490
  if (typeof window > "u") return {};
3469
3491
  const l = new URLSearchParams(window.location.search);
3470
3492
  return {
3471
- token: m || l.get("token") || "",
3493
+ token: c || l.get("token") || "",
3472
3494
  email: y || l.get("email") || "",
3473
- appId: f || l.get("appId") || "",
3474
- tenantSlug: D || l.get("tenantSlug") || void 0
3495
+ appId: g || l.get("appId") || "",
3496
+ tenantSlug: F || l.get("tenantSlug") || void 0
3475
3497
  };
3476
3498
  }, w = async () => {
3477
3499
  A("verifying"), M("");
3478
3500
  try {
3479
3501
  const l = $();
3480
3502
  if (!l.token || !l.email)
3481
- throw new Error(d.missingParamsError);
3503
+ throw new Error(u.missingParamsError);
3482
3504
  const z = await P({
3483
3505
  token: l.token,
3484
3506
  email: l.email,
3485
3507
  tenantSlug: l.tenantSlug
3486
3508
  });
3487
- A("success"), r == null || r(z), g > 0 && setTimeout(() => {
3509
+ A("success"), r == null || r(z), m > 0 && setTimeout(() => {
3488
3510
  A("redirecting");
3489
- }, g);
3511
+ }, m);
3490
3512
  } catch (l) {
3491
- const z = l.message || d.errorMessage;
3513
+ const z = l.message || u.errorMessage;
3492
3514
  M(z), A("error"), i == null || i(z);
3493
3515
  }
3494
3516
  }, R = () => {
@@ -3502,25 +3524,25 @@ function Qr({
3502
3524
  const I = () => {
3503
3525
  switch (T) {
3504
3526
  case "verifying":
3505
- return /* @__PURE__ */ u("div", { style: v.message, children: [
3527
+ return /* @__PURE__ */ h("div", { style: v.message, children: [
3506
3528
  N.loading,
3507
- d.verifyingMessage
3529
+ u.verifyingMessage
3508
3530
  ] });
3509
3531
  case "success":
3510
- return /* @__PURE__ */ u(_, { children: [
3532
+ return /* @__PURE__ */ h(_, { children: [
3511
3533
  N.success,
3512
- /* @__PURE__ */ s("div", { style: v.successMessage, children: d.successMessage })
3534
+ /* @__PURE__ */ s("div", { style: v.successMessage, children: u.successMessage })
3513
3535
  ] });
3514
3536
  case "redirecting":
3515
- return /* @__PURE__ */ u(_, { children: [
3537
+ return /* @__PURE__ */ h(_, { children: [
3516
3538
  N.loading,
3517
- /* @__PURE__ */ s("div", { style: v.message, children: d.redirectingMessage })
3539
+ /* @__PURE__ */ s("div", { style: v.message, children: u.redirectingMessage })
3518
3540
  ] });
3519
3541
  case "error":
3520
- return /* @__PURE__ */ u(_, { children: [
3542
+ return /* @__PURE__ */ h(_, { children: [
3521
3543
  N.error,
3522
- /* @__PURE__ */ s("div", { style: v.errorMessage, children: L || d.errorMessage }),
3523
- /* @__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: [
3524
3546
  /* @__PURE__ */ s(
3525
3547
  "button",
3526
3548
  {
@@ -3531,11 +3553,11 @@ function Qr({
3531
3553
  },
3532
3554
  onMouseOut: (l) => {
3533
3555
  const z = v.retryButton || {};
3534
- Object.keys(v.retryButtonHover || {}).forEach((F) => {
3535
- l.currentTarget.style[F] = z[F] ?? "";
3556
+ Object.keys(v.retryButtonHover || {}).forEach((D) => {
3557
+ l.currentTarget.style[D] = z[D] ?? "";
3536
3558
  });
3537
3559
  },
3538
- children: d.retryButton
3560
+ children: u.retryButton
3539
3561
  }
3540
3562
  ),
3541
3563
  /* @__PURE__ */ s(
@@ -3548,11 +3570,11 @@ function Qr({
3548
3570
  },
3549
3571
  onMouseOut: (l) => {
3550
3572
  const z = v.backButton || {};
3551
- Object.keys(v.backButtonHover || {}).forEach((F) => {
3552
- l.currentTarget.style[F] = z[F] ?? "";
3573
+ Object.keys(v.backButtonHover || {}).forEach((D) => {
3574
+ l.currentTarget.style[D] = z[D] ?? "";
3553
3575
  });
3554
3576
  },
3555
- children: d.backToLoginButton
3577
+ children: u.backToLoginButton
3556
3578
  }
3557
3579
  )
3558
3580
  ] })
@@ -3561,14 +3583,14 @@ function Qr({
3561
3583
  return null;
3562
3584
  }
3563
3585
  };
3564
- return /* @__PURE__ */ u("div", { style: v.container, className: c, children: [
3586
+ return /* @__PURE__ */ h("div", { style: v.container, className: d, children: [
3565
3587
  /* @__PURE__ */ s("style", { children: `
3566
3588
  @keyframes spin {
3567
3589
  0% { transform: rotate(0deg); }
3568
3590
  100% { transform: rotate(360deg); }
3569
3591
  }
3570
3592
  ` }),
3571
- /* @__PURE__ */ s("h1", { style: v.title, children: d.title }),
3593
+ /* @__PURE__ */ s("h1", { style: v.title, children: u.title }),
3572
3594
  I()
3573
3595
  ] });
3574
3596
  }
@@ -3694,7 +3716,7 @@ const or = {
3694
3716
  color: "#6b7280"
3695
3717
  }
3696
3718
  };
3697
- function Kr({
3719
+ function Qr({
3698
3720
  copy: n = {},
3699
3721
  styles: e = {},
3700
3722
  mode: t = "request",
@@ -3702,79 +3724,79 @@ function Kr({
3702
3724
  onSuccess: i,
3703
3725
  onError: o,
3704
3726
  onBackToLogin: a,
3705
- onModeChange: c,
3706
- className: m
3727
+ onModeChange: d,
3728
+ className: c
3707
3729
  }) {
3708
3730
  var X;
3709
- const [y, f] = x(""), [D, g] = x(r), [T, A] = x(""), [L, M] = x(""), [P, d] = x(!1), [v, N] = x(""), [$, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, F = { ...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 = () => {
3710
3732
  const W = {};
3711
3733
  return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
3712
3734
  }, b = () => {
3713
3735
  const W = {};
3714
- return D.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), L.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
3715
- }, h = async (W) => {
3736
+ return F.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), L.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
3737
+ }, p = async (W) => {
3716
3738
  if (W.preventDefault(), !!U()) {
3717
3739
  if (!(z != null && z.id)) {
3718
- N(F.tenantNotFoundError);
3740
+ N(D.tenantNotFoundError);
3719
3741
  return;
3720
3742
  }
3721
- d(!0), N(""), w("");
3743
+ u(!0), N(""), w("");
3722
3744
  try {
3723
- await I({ email: y, tenantId: z.id }), w(F.successMessage), i == null || i();
3745
+ await I({ email: y, tenantId: z.id }), w(D.successMessage), i == null || i();
3724
3746
  } catch (q) {
3725
- const V = q.message || F.errorMessage;
3747
+ const V = q.message || D.errorMessage;
3726
3748
  N(V), o == null || o(V);
3727
3749
  } finally {
3728
- d(!1);
3750
+ u(!1);
3729
3751
  }
3730
3752
  }
3731
3753
  }, S = async (W) => {
3732
3754
  if (W.preventDefault(), !!b()) {
3733
3755
  if (T !== L) {
3734
- N(F.passwordMismatchError), k({ confirmPassword: !0 });
3756
+ N(D.passwordMismatchError), k({ confirmPassword: !0 });
3735
3757
  return;
3736
3758
  }
3737
- d(!0), N(""), w("");
3759
+ u(!0), N(""), w("");
3738
3760
  try {
3739
- await l({ token: D, newPassword: T }), w(F.resetSuccessMessage), i == null || i();
3761
+ await l({ token: F, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
3740
3762
  } catch (q) {
3741
- const V = q.message || F.errorMessage;
3763
+ const V = q.message || D.errorMessage;
3742
3764
  N(V), o == null || o(V);
3743
3765
  } finally {
3744
- d(!1);
3766
+ u(!1);
3745
3767
  }
3746
3768
  }
3747
3769
  }, E = (W) => ({
3748
- ...p.input,
3749
- ...R[W] ? p.inputError : {}
3750
- }), Q = () => ({
3751
- ...p.button,
3752
- ...P ? p.buttonLoading : {}
3770
+ ...f.input,
3771
+ ...R[W] ? f.inputError : {}
3772
+ }), K = () => ({
3773
+ ...f.button,
3774
+ ...P ? f.buttonLoading : {}
3753
3775
  });
3754
3776
  if (t === "reset") {
3755
- const W = D && T && L;
3756
- return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
3757
- /* @__PURE__ */ s("h2", { style: p.title, children: F.resetTitle }),
3758
- /* @__PURE__ */ s("p", { style: p.subtitle, children: F.resetSubtitle }),
3759
- /* @__PURE__ */ u("form", { onSubmit: S, style: p.form, children: [
3760
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3761
- /* @__PURE__ */ s("label", { style: p.label, children: F.tokenLabel }),
3777
+ const W = F && T && L;
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 }),
3762
3784
  /* @__PURE__ */ s(
3763
3785
  "input",
3764
3786
  {
3765
3787
  type: "text",
3766
- value: D,
3788
+ value: F,
3767
3789
  onChange: (q) => {
3768
- g(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
3790
+ m(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
3769
3791
  },
3770
- placeholder: F.tokenPlaceholder,
3792
+ placeholder: D.tokenPlaceholder,
3771
3793
  style: E("token"),
3772
3794
  disabled: P
3773
3795
  }
3774
3796
  )
3775
3797
  ] }),
3776
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3777
- /* @__PURE__ */ s("label", { style: p.label, children: F.newPasswordLabel }),
3798
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3799
+ /* @__PURE__ */ s("label", { style: f.label, children: D.newPasswordLabel }),
3778
3800
  /* @__PURE__ */ s(
3779
3801
  "input",
3780
3802
  {
@@ -3783,23 +3805,23 @@ function Kr({
3783
3805
  onChange: (q) => {
3784
3806
  A(q.target.value), R.newPassword && k((V) => ({ ...V, newPassword: !1 }));
3785
3807
  },
3786
- placeholder: F.newPasswordPlaceholder,
3808
+ placeholder: D.newPasswordPlaceholder,
3787
3809
  style: E("newPassword"),
3788
3810
  disabled: P
3789
3811
  }
3790
3812
  )
3791
3813
  ] }),
3792
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3793
- /* @__PURE__ */ s("label", { style: p.label, children: F.confirmPasswordLabel }),
3814
+ /* @__PURE__ */ h("div", { style: f.fieldGroup, children: [
3815
+ /* @__PURE__ */ s("label", { style: f.label, children: D.confirmPasswordLabel }),
3794
3816
  /* @__PURE__ */ s(
3795
3817
  "input",
3796
3818
  {
3797
3819
  type: "password",
3798
3820
  value: L,
3799
3821
  onChange: (q) => {
3800
- M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === F.passwordMismatchError && N("");
3822
+ M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === D.passwordMismatchError && N("");
3801
3823
  },
3802
- placeholder: F.confirmPasswordPlaceholder,
3824
+ placeholder: D.confirmPasswordPlaceholder,
3803
3825
  style: E("confirmPassword"),
3804
3826
  disabled: P
3805
3827
  }
@@ -3811,40 +3833,40 @@ function Kr({
3811
3833
  type: "submit",
3812
3834
  disabled: !W || P,
3813
3835
  style: {
3814
- ...Q(),
3815
- ...!W || P ? p.buttonDisabled : {}
3836
+ ...K(),
3837
+ ...!W || P ? f.buttonDisabled : {}
3816
3838
  },
3817
- children: P ? F.resetLoadingText : F.resetSubmitButton
3839
+ children: P ? D.resetLoadingText : D.resetSubmitButton
3818
3840
  }
3819
3841
  ),
3820
- v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
3821
- $ && /* @__PURE__ */ s("div", { style: p.successText, children: $ })
3842
+ v && /* @__PURE__ */ s("div", { style: f.errorText, children: v }),
3843
+ $ && /* @__PURE__ */ s("div", { style: f.successText, children: $ })
3822
3844
  ] }),
3823
- /* @__PURE__ */ u("div", { style: p.linkContainer, children: [
3824
- /* @__PURE__ */ s("a", { onClick: a, style: p.link, children: F.backToLoginLink }),
3825
- c && /* @__PURE__ */ u(_, { children: [
3826
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: F.dividerBullet }),
3827
- /* @__PURE__ */ s("a", { onClick: () => c("request"), style: p.link, children: F.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 })
3828
3850
  ] })
3829
3851
  ] })
3830
3852
  ] });
3831
3853
  }
3832
3854
  const G = y;
3833
- return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
3834
- /* @__PURE__ */ s("h2", { style: p.title, children: F.title }),
3835
- /* @__PURE__ */ s("p", { style: p.subtitle, children: F.subtitle }),
3836
- /* @__PURE__ */ u("form", { onSubmit: h, style: p.form, children: [
3837
- /* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
3838
- /* @__PURE__ */ s("label", { style: p.label, children: F.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 }),
3839
3861
  /* @__PURE__ */ s(
3840
3862
  "input",
3841
3863
  {
3842
3864
  type: "email",
3843
3865
  value: y,
3844
3866
  onChange: (W) => {
3845
- f(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
3867
+ g(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
3846
3868
  },
3847
- placeholder: F.emailPlaceholder,
3869
+ placeholder: D.emailPlaceholder,
3848
3870
  style: E("email"),
3849
3871
  disabled: P
3850
3872
  }
@@ -3856,20 +3878,20 @@ function Kr({
3856
3878
  type: "submit",
3857
3879
  disabled: !G || P,
3858
3880
  style: {
3859
- ...Q(),
3860
- ...!G || P ? p.buttonDisabled : {}
3881
+ ...K(),
3882
+ ...!G || P ? f.buttonDisabled : {}
3861
3883
  },
3862
- children: P ? F.loadingText : F.submitButton
3884
+ children: P ? D.loadingText : D.submitButton
3863
3885
  }
3864
3886
  ),
3865
- v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
3866
- $ && /* @__PURE__ */ s("div", { style: p.successText, children: $ })
3887
+ v && /* @__PURE__ */ s("div", { style: f.errorText, children: v }),
3888
+ $ && /* @__PURE__ */ s("div", { style: f.successText, children: $ })
3867
3889
  ] }),
3868
- /* @__PURE__ */ u("div", { style: p.linkContainer, children: [
3869
- /* @__PURE__ */ s("a", { onClick: a, style: p.link, children: F.backToLoginLink }),
3870
- c && /* @__PURE__ */ u(_, { children: [
3871
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: F.dividerBullet }),
3872
- /* @__PURE__ */ s("a", { onClick: () => c("reset"), style: p.link, children: F.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 })
3873
3895
  ] })
3874
3896
  ] })
3875
3897
  ] });
@@ -3886,7 +3908,7 @@ const lr = () => /* @__PURE__ */ s(
3886
3908
  },
3887
3909
  children: /* @__PURE__ */ s("div", { children: "Loading..." })
3888
3910
  }
3889
- ), cr = ({ error: n, retry: e }) => /* @__PURE__ */ u(
3911
+ ), cr = ({ error: n, retry: e }) => /* @__PURE__ */ h(
3890
3912
  "div",
3891
3913
  {
3892
3914
  style: {
@@ -3926,9 +3948,9 @@ function Zr({
3926
3948
  errorFallback: t,
3927
3949
  requireTenant: r = !0
3928
3950
  }) {
3929
- const { isAppLoading: i, appError: o, retryApp: a } = Ae(), c = pe(), m = Ce(), y = Ye(), f = Xe(), D = (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) ?? (() => {
3930
- }), 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 && D || m && !L || y && !M || f && !P, R = o || (d ? g : null), k = () => {
3931
- 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();
3932
3954
  };
3933
3955
  if (w)
3934
3956
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(lr, {}) });
@@ -3939,21 +3961,21 @@ function Zr({
3939
3961
  return /* @__PURE__ */ s(_, { children: n });
3940
3962
  }
3941
3963
  function Jr(n = !0) {
3942
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = Ce(), c = Ye(), m = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, f = (o == null ? void 0 : o.tenantError) ?? null, D = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3943
- }), 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, $ = 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);
3944
3966
  return {
3945
3967
  isLoading: $,
3946
3968
  error: w,
3947
- isReady: !$ && !w && i !== null && (!P || D !== null),
3969
+ isReady: !$ && !w && i !== null && (!P || F !== null),
3948
3970
  retry: () => {
3949
- t && r(), f && o && T();
3971
+ t && r(), g && o && T();
3950
3972
  },
3951
3973
  // Individual states
3952
3974
  app: { isLoading: e, error: t, data: i },
3953
- tenant: o ? { isLoading: y, error: f, data: D } : null,
3975
+ tenant: o ? { isLoading: y, error: g, data: F } : null,
3954
3976
  auth: a ? { isReady: A } : null,
3955
- featureFlags: c ? { isReady: L } : null,
3956
- subscription: m ? { isReady: M } : null
3977
+ featureFlags: d ? { isReady: L } : null,
3978
+ subscription: c ? { isReady: M } : null
3957
3979
  };
3958
3980
  }
3959
3981
  const dr = {
@@ -4008,14 +4030,14 @@ function Yr({
4008
4030
  className: i = "",
4009
4031
  dropdownClassName: o = "",
4010
4032
  itemClassName: a = "",
4011
- renderItem: c,
4012
- placeholder: m = "Select tenant",
4033
+ renderItem: d,
4034
+ placeholder: c = "Select tenant",
4013
4035
  disabled: y = !1,
4014
- showCurrentTenant: f = !0
4036
+ showCurrentTenant: g = !0
4015
4037
  }) {
4016
4038
  var $;
4017
- const D = { ...dr, ...r }, g = Ce(), [T, A] = x(!1), L = Ne(null), M = n ?? (g == null ? void 0 : g.userTenants) ?? [], P = e ?? (($ = g == null ? void 0 : g.currentUser) == null ? void 0 : $.tenantId) ?? null, d = async (w) => {
4018
- A(!1), t ? t(w) : g != null && g.switchToTenant && await g.switchToTenant(w);
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);
4019
4041
  };
4020
4042
  ne(() => {
4021
4043
  const w = (R) => {
@@ -4026,56 +4048,56 @@ function Yr({
4026
4048
  const v = M.find((w) => w.id === P);
4027
4049
  if (M.length === 0)
4028
4050
  return null;
4029
- if (M.length === 1 && f)
4051
+ if (M.length === 1 && g)
4030
4052
  return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
4031
- 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: [
4032
4054
  w.name,
4033
- w.role && /* @__PURE__ */ u("span", { style: D.itemRole, children: [
4055
+ w.role && /* @__PURE__ */ h("span", { style: F.itemRole, children: [
4034
4056
  "(",
4035
4057
  w.role,
4036
4058
  ")"
4037
4059
  ] })
4038
4060
  ] });
4039
- return /* @__PURE__ */ u("div", { ref: L, className: i, style: D.wrapper, children: [
4040
- /* @__PURE__ */ u(
4061
+ return /* @__PURE__ */ h("div", { ref: L, className: i, style: F.wrapper, children: [
4062
+ /* @__PURE__ */ h(
4041
4063
  "button",
4042
4064
  {
4043
4065
  type: "button",
4044
4066
  onClick: () => !y && A(!T),
4045
4067
  disabled: y,
4046
4068
  style: {
4047
- ...D.button,
4048
- ...y ? D.buttonDisabled : {}
4069
+ ...F.button,
4070
+ ...y ? F.buttonDisabled : {}
4049
4071
  },
4050
4072
  children: [
4051
- v ? v.name : m,
4052
- /* @__PURE__ */ s("span", { style: D.arrow, children: T ? "▲" : "▼" })
4073
+ v ? v.name : c,
4074
+ /* @__PURE__ */ s("span", { style: F.arrow, children: T ? "▲" : "▼" })
4053
4075
  ]
4054
4076
  }
4055
4077
  ),
4056
- T && /* @__PURE__ */ s("div", { className: o, style: D.dropdown, children: M.map((w) => {
4078
+ T && /* @__PURE__ */ s("div", { className: o, style: F.dropdown, children: M.map((w) => {
4057
4079
  const R = w.id === P;
4058
4080
  return /* @__PURE__ */ s(
4059
4081
  "div",
4060
4082
  {
4061
4083
  className: a,
4062
- onClick: () => d(w.id),
4084
+ onClick: () => u(w.id),
4063
4085
  style: {
4064
- ...D.item,
4065
- ...R ? D.itemSelected : {}
4086
+ ...F.item,
4087
+ ...R ? F.itemSelected : {}
4066
4088
  },
4067
4089
  onMouseEnter: (k) => {
4068
- R || Object.assign(k.currentTarget.style, D.itemHover);
4090
+ R || Object.assign(k.currentTarget.style, F.itemHover);
4069
4091
  },
4070
4092
  onMouseLeave: (k) => {
4071
4093
  if (!R) {
4072
- const I = D.item || {};
4073
- Object.keys(D.itemHover || {}).forEach((l) => {
4094
+ const I = F.item || {};
4095
+ Object.keys(F.itemHover || {}).forEach((l) => {
4074
4096
  k.currentTarget.style[l] = I[l] ?? "";
4075
4097
  });
4076
4098
  }
4077
4099
  },
4078
- children: c ? c(w, R) : N(w, R)
4100
+ children: d ? d(w, R) : N(w, R)
4079
4101
  },
4080
4102
  w.id
4081
4103
  );
@@ -4338,7 +4360,7 @@ function nn(n = {}) {
4338
4360
  zoneRoots: e = {},
4339
4361
  returnToParam: t = rt,
4340
4362
  returnToStorage: r = "url"
4341
- } = n, i = mt(), [o, a] = yt(), { isAuthenticated: c, currentUser: m } = he(), { tenant: y } = Te(), f = Z(() => ({ ...Oe, ...e }), [e]), D = !!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(() => {
4342
4364
  switch (r) {
4343
4365
  case "url":
4344
4366
  return o.get(t);
@@ -4349,11 +4371,11 @@ function nn(n = {}) {
4349
4371
  default:
4350
4372
  return null;
4351
4373
  }
4352
- }, [r, o, t]), A = ie(() => {
4374
+ }, [r, o, t]), A = oe(() => {
4353
4375
  switch (r) {
4354
4376
  case "url": {
4355
- const d = new URLSearchParams(o);
4356
- d.delete(t), a(d, { replace: !0 });
4377
+ const u = new URLSearchParams(o);
4378
+ u.delete(t), a(u, { replace: !0 });
4357
4379
  break;
4358
4380
  }
4359
4381
  case "session":
@@ -4363,30 +4385,30 @@ function nn(n = {}) {
4363
4385
  localStorage.removeItem(Le);
4364
4386
  break;
4365
4387
  }
4366
- }, [r, o, t, a]), L = ie(
4367
- (d) => {
4388
+ }, [r, o, t, a]), L = oe(
4389
+ (u) => {
4368
4390
  switch (r) {
4369
4391
  case "url": {
4370
4392
  const v = new URLSearchParams(o);
4371
- v.set(t, d), a(v, { replace: !0 });
4393
+ v.set(t, u), a(v, { replace: !0 });
4372
4394
  break;
4373
4395
  }
4374
4396
  case "session":
4375
- sessionStorage.setItem(Me, d);
4397
+ sessionStorage.setItem(Me, u);
4376
4398
  break;
4377
4399
  case "local":
4378
- localStorage.setItem(Le, d);
4400
+ localStorage.setItem(Le, u);
4379
4401
  break;
4380
4402
  }
4381
4403
  },
4382
4404
  [r, o, t, a]
4383
- ), M = ie(
4384
- (d) => {
4385
- const v = f[d] || f.default;
4405
+ ), M = oe(
4406
+ (u) => {
4407
+ const v = g[u] || g.default;
4386
4408
  i(v);
4387
4409
  },
4388
- [i, f]
4389
- ), P = ie(() => D ? c ? g === ae.TENANT_ADMIN ? f.tenantAdmin : f.tenantUser : f.tenantGuest : c ? g === ae.TENANT_ADMIN ? f.publicAdmin : f.publicUser : f.publicGuest, [D, 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]);
4390
4412
  return {
4391
4413
  returnToUrl: T,
4392
4414
  clearReturnTo: A,
@@ -4402,7 +4424,7 @@ function sn(n, e, t = rt, r = "url") {
4402
4424
  return i.searchParams.set(t, e), i.pathname + i.search;
4403
4425
  }
4404
4426
  export {
4405
- Cr as AdminZone,
4427
+ Br as AdminZone,
4406
4428
  rn as ApiMappers,
4407
4429
  Ve as AppApiService,
4408
4430
  Zr as AppLoader,
@@ -4421,13 +4443,13 @@ export {
4421
4443
  Nr as LandingRoute,
4422
4444
  Wr as LoginForm,
4423
4445
  Gr as MagicLinkForm,
4424
- Qr as MagicLinkVerify,
4425
- Br as OpenZone,
4426
- Kr as PasswordRecoveryForm,
4446
+ Kr as MagicLinkVerify,
4447
+ Hr as OpenZone,
4448
+ Qr as PasswordRecoveryForm,
4427
4449
  Xr as PermissionApiService,
4428
4450
  Ir as Protected,
4429
4451
  Mr as ProtectedRoute,
4430
- Fr as PublicZone,
4452
+ Dr as PublicZone,
4431
4453
  We as RoleApiService,
4432
4454
  Rr as RoutingProvider,
4433
4455
  se as SessionExpiredError,
@@ -4444,12 +4466,12 @@ export {
4444
4466
  Sr as TenantProvider,
4445
4467
  Lr as TenantRoute,
4446
4468
  Yr as TenantSelector,
4447
- Dr as TenantZone,
4469
+ Fr as TenantZone,
4448
4470
  bt as TokenRefreshError,
4449
4471
  wt as TokenRefreshTimeoutError,
4450
4472
  St as UserApiService,
4451
4473
  ae as UserType,
4452
- Hr as UserZone,
4474
+ Cr as UserZone,
4453
4475
  ue as ZoneRoute,
4454
4476
  sn as buildRedirectUrl,
4455
4477
  vr as useApi,
@@ -4458,7 +4480,7 @@ export {
4458
4480
  he as useAuth,
4459
4481
  Mt as useFeatureFlags,
4460
4482
  Er as useRouting,
4461
- Dt as useRoutingOptional,
4483
+ Ft as useRoutingOptional,
4462
4484
  kr as useSettings,
4463
4485
  Nt as useSubscription,
4464
4486
  Te as useTenant,