@skylabs-digital/react-identity-access 3.2.3 → 3.4.1

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,6 +1,6 @@
1
1
  import { jsx as s, Fragment as U, jsxs as f } from "react/jsx-runtime";
2
- import me, { createContext as fe, useState as N, useRef as ye, useCallback as te, useMemo as V, useEffect as re, useContext as ne } from "react";
3
- import { useLocation as xe, Navigate as we, useNavigate as vt, useSearchParams as Tt } from "react-router-dom";
2
+ import me, { createContext as fe, useState as C, useRef as be, useCallback as te, useMemo as O, useEffect as re, useContext as ne, useSyncExternalStore as Et } from "react";
3
+ import { useLocation as Re, Navigate as ve, useNavigate as xt, useSearchParams as Rt } from "react-router-dom";
4
4
  class he {
5
5
  constructor(e, t = 1e4) {
6
6
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -11,25 +11,25 @@ class he {
11
11
  getBaseUrl() {
12
12
  return this.baseUrl;
13
13
  }
14
- async executeRequest(e, t, n, i, a = !1) {
15
- const l = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, h = (i == null ? void 0 : i.timeout) || this.timeout;
16
- let S = {
14
+ async executeRequest(e, t, n, i, o = !1) {
15
+ const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, p = (i == null ? void 0 : i.timeout) || this.timeout;
16
+ let k = {
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
21
  const c = await this.sessionManager.getValidAccessToken();
22
- S = { ...S, Authorization: `Bearer ${c}` };
22
+ k = { ...k, Authorization: `Bearer ${c}` };
23
23
  }
24
- const k = new AbortController(), T = setTimeout(() => k.abort(), h);
24
+ const E = new AbortController(), S = setTimeout(() => E.abort(), p);
25
25
  try {
26
- const c = await fetch(l, {
26
+ const c = await fetch(a, {
27
27
  method: e,
28
- headers: S,
28
+ headers: k,
29
29
  body: n ? JSON.stringify(n) : void 0,
30
- signal: k.signal
30
+ signal: E.signal
31
31
  });
32
- if (clearTimeout(T), c.status === 401 && !(i != null && i.skipAuth) && this.sessionManager && !a) {
32
+ if (clearTimeout(S), c.status === 401 && !(i != null && i.skipAuth) && this.sessionManager && !o) {
33
33
  try {
34
34
  await c.text();
35
35
  } catch {
@@ -41,7 +41,7 @@ class he {
41
41
  const d = c.headers.get("content-type");
42
42
  return !d || !d.includes("application/json") ? {} : await c.json();
43
43
  } catch (c) {
44
- throw clearTimeout(T), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${h}ms`) : c;
44
+ throw clearTimeout(S), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : c;
45
45
  }
46
46
  }
47
47
  async get(e, t) {
@@ -57,7 +57,7 @@ class he {
57
57
  return this.executeRequest("DELETE", e, void 0, t);
58
58
  }
59
59
  }
60
- function ce(r) {
60
+ function le(r) {
61
61
  if (!r) return "";
62
62
  const e = new URLSearchParams();
63
63
  for (const [n, i] of Object.entries(r))
@@ -65,7 +65,7 @@ function ce(r) {
65
65
  const t = e.toString();
66
66
  return t ? `?${t}` : "";
67
67
  }
68
- class Je {
68
+ class Ye {
69
69
  constructor(e) {
70
70
  this.httpService = e;
71
71
  }
@@ -74,7 +74,7 @@ class Je {
74
74
  }
75
75
  async getApps(e) {
76
76
  const t = await this.httpService.get(
77
- `/apps/${ce(e)}`
77
+ `/apps/${le(e)}`
78
78
  );
79
79
  return { apps: t.data, meta: t.meta };
80
80
  }
@@ -105,92 +105,92 @@ class Je {
105
105
  return (await this.httpService.get(`/apps/${e}/export-config`)).data;
106
106
  }
107
107
  }
108
- const $e = fe(null), St = 5 * 60 * 1e3;
109
- function kr({ config: r, children: e }) {
110
- var E, m, g;
111
- const { appId: t, baseUrl: n } = r, i = (((E = r.cache) == null ? void 0 : E.enabled) ?? !0) && !!t, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? St, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? (t ? `app_cache_${t}` : ""), [h, S] = N(() => {
108
+ const Be = fe(null), At = 300 * 1e3;
109
+ function Pr({ config: r, children: e }) {
110
+ var R, m, g;
111
+ const { appId: t, baseUrl: n } = r, i = (((R = r.cache) == null ? void 0 : R.enabled) ?? !0) && !!t, o = ((m = r.cache) == null ? void 0 : m.ttl) ?? At, a = ((g = r.cache) == null ? void 0 : g.storageKey) ?? (t ? `app_cache_${t}` : ""), [p, k] = C(() => {
112
112
  if (!i) return null;
113
113
  try {
114
- const b = localStorage.getItem(l);
114
+ const b = localStorage.getItem(a);
115
115
  if (!b) return null;
116
- const C = JSON.parse(b);
117
- return Date.now() - C.timestamp < a && C.appId === t ? C.data : (localStorage.removeItem(l), null);
116
+ const w = JSON.parse(b);
117
+ return Date.now() - w.timestamp < o && w.appId === t ? w.data : (localStorage.removeItem(a), null);
118
118
  } catch {
119
119
  return null;
120
120
  }
121
- }), [k, T] = N(!!t && !h), [c, d] = N(null), A = ye(h);
122
- A.current = h;
123
- const P = te(
121
+ }), [E, S] = C(!!t && !p), [c, d] = C(null), x = be(p);
122
+ x.current = p;
123
+ const I = te(
124
124
  async (b = !1) => {
125
- if (t && !(!b && i && A.current))
125
+ if (t && !(!b && i && x.current))
126
126
  try {
127
- T(!0), d(null);
128
- const o = await new Je(new he(n)).getPublicAppInfo(t);
129
- if (S(o), i)
127
+ S(!0), d(null);
128
+ const l = await new Ye(new he(n)).getPublicAppInfo(t);
129
+ if (k(l), i)
130
130
  try {
131
- const p = {
132
- data: o,
131
+ const h = {
132
+ data: l,
133
133
  timestamp: Date.now(),
134
134
  appId: t
135
135
  };
136
- localStorage.setItem(l, JSON.stringify(p));
137
- } catch (p) {
138
- process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:", p);
136
+ localStorage.setItem(a, JSON.stringify(h));
137
+ } catch (h) {
138
+ process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:", h);
139
139
  }
140
- } catch (C) {
141
- const o = C instanceof Error ? C : new Error("Failed to load app information");
142
- d(o), S(null);
140
+ } catch (w) {
141
+ const l = w instanceof Error ? w : new Error("Failed to load app information");
142
+ d(l), k(null);
143
143
  } finally {
144
- T(!1);
144
+ S(!1);
145
145
  }
146
146
  },
147
- [n, t, i, l]
148
- ), I = te(async () => {
149
- if (!(!t || !i || !A.current))
147
+ [n, t, i, a]
148
+ ), L = te(async () => {
149
+ if (!(!t || !i || !x.current))
150
150
  try {
151
- const b = localStorage.getItem(l);
151
+ const b = localStorage.getItem(a);
152
152
  if (!b) return;
153
- const C = JSON.parse(b);
154
- if (Date.now() - C.timestamp <= a * 0.5) return;
155
- const p = await new Je(new he(n)).getPublicAppInfo(t);
156
- S(p);
157
- const x = {
158
- data: p,
153
+ const w = JSON.parse(b);
154
+ if (Date.now() - w.timestamp <= o * 0.5) return;
155
+ const h = await new Ye(new he(n)).getPublicAppInfo(t);
156
+ k(h);
157
+ const A = {
158
+ data: h,
159
159
  timestamp: Date.now(),
160
160
  appId: t
161
161
  };
162
- localStorage.setItem(l, JSON.stringify(x));
162
+ localStorage.setItem(a, JSON.stringify(A));
163
163
  } catch (b) {
164
164
  process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", b);
165
165
  }
166
- }, [n, t, i, a, l]), R = V(
166
+ }, [n, t, i, o, a]), P = O(
167
167
  () => ({
168
168
  appId: t,
169
169
  baseUrl: n,
170
- appInfo: h,
171
- isAppLoading: k,
170
+ appInfo: p,
171
+ isAppLoading: E,
172
172
  appError: c,
173
173
  retryApp: () => {
174
- P(!0);
174
+ I(!0);
175
175
  }
176
176
  }),
177
- [t, n, h, k, c, P]
177
+ [t, n, p, E, c, I]
178
178
  );
179
179
  return re(() => {
180
- t && (A.current ? I() : P());
181
- }, []), /* @__PURE__ */ s($e.Provider, { value: R, children: e });
180
+ t && (x.current ? L() : I());
181
+ }, []), /* @__PURE__ */ s(Be.Provider, { value: P, children: e });
182
182
  }
183
183
  function Ae() {
184
- const r = ne($e);
184
+ const r = ne(Be);
185
185
  if (!r)
186
186
  throw new Error("useApp must be used within an AppProvider");
187
187
  return r;
188
188
  }
189
- function Ue() {
190
- return ne($e);
189
+ function _e() {
190
+ return ne(Be);
191
191
  }
192
- const Er = Ae;
193
- class Z extends Error {
192
+ const Ir = Ae;
193
+ class Q extends Error {
194
194
  constructor(e, t) {
195
195
  const n = {
196
196
  token_expired: "Refresh token has expired",
@@ -200,24 +200,24 @@ class Z extends Error {
200
200
  super(t || n[e]), this.name = "SessionExpiredError", this.reason = e;
201
201
  }
202
202
  }
203
- class kt extends Error {
203
+ class Pt extends Error {
204
204
  constructor(e) {
205
205
  super(`Token refresh timed out after ${e}ms`), this.name = "TokenRefreshTimeoutError", this.timeoutMs = e;
206
206
  }
207
207
  }
208
- class Et extends Error {
208
+ class It extends Error {
209
209
  constructor(e, t) {
210
210
  super(
211
211
  `Token refresh failed after ${e} attempts: ${(t == null ? void 0 : t.message) || "Unknown error"}`
212
212
  ), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
213
213
  }
214
214
  }
215
- class oe extends Error {
215
+ class ie extends Error {
216
216
  constructor(e, t, n) {
217
- super(`Invalid configuration "${e}": ${n} (received: ${xt(t)})`), this.name = "ConfigurationError", this.field = e, this.received = t;
217
+ super(`Invalid configuration "${e}": ${n} (received: ${Lt(t)})`), this.name = "ConfigurationError", this.field = e, this.received = t;
218
218
  }
219
219
  }
220
- function xt(r) {
220
+ function Lt(r) {
221
221
  if (r === void 0) return "undefined";
222
222
  try {
223
223
  const e = JSON.stringify(r);
@@ -226,85 +226,92 @@ function xt(r) {
226
226
  return typeof r;
227
227
  }
228
228
  }
229
- function Ze(r) {
229
+ function Xe(r) {
230
230
  return JSON.parse(atob(r.replace(/-/g, "+").replace(/_/g, "/")));
231
231
  }
232
- function Re(r) {
232
+ function Pe(r) {
233
233
  const e = r.split(".");
234
234
  if (e.length !== 3) return null;
235
235
  try {
236
- return { header: Ze(e[0]), payload: Ze(e[1]) };
236
+ return { header: Xe(e[0]), payload: Xe(e[1]) };
237
237
  } catch {
238
238
  return null;
239
239
  }
240
240
  }
241
- function Ke(r) {
242
- const e = Re(r), t = e == null ? void 0 : e.payload.exp;
241
+ function et(r) {
242
+ const e = Pe(r), t = e == null ? void 0 : e.payload.exp;
243
243
  return typeof t == "number" ? t * 1e3 : void 0;
244
244
  }
245
- function At(r, e) {
245
+ function Ft(r, e) {
246
246
  var n;
247
- const t = (n = Re(r)) == null ? void 0 : n.payload[e];
247
+ const t = (n = Pe(r)) == null ? void 0 : n.payload[e];
248
248
  return typeof t == "string" ? t : void 0;
249
249
  }
250
- const Rt = /^(javascript|data|vbscript|file):/i, Pt = /^https?:\/\//i;
251
- function It(r, e = "baseUrl") {
250
+ const Nt = /^(javascript|data|vbscript|file):/i, Ct = /^https?:\/\//i;
251
+ function Dt(r, e = "baseUrl") {
252
252
  if (!(r == null || r === "")) {
253
253
  if (typeof r != "string")
254
- throw new oe(e, r, "must be a string");
255
- if (Rt.test(r))
256
- throw new oe(e, r, "dangerous URL scheme is not allowed");
257
- if (!Pt.test(r))
258
- throw new oe(e, r, "must start with http:// or https://");
254
+ throw new ie(e, r, "must be a string");
255
+ if (Nt.test(r))
256
+ throw new ie(e, r, "dangerous URL scheme is not allowed");
257
+ if (!Ct.test(r))
258
+ throw new ie(e, r, "must start with http:// or https://");
259
259
  }
260
260
  }
261
261
  function ge(r, e, t = {}) {
262
262
  if (e === void 0) return;
263
263
  if (typeof e != "number" || !Number.isFinite(e))
264
- throw new oe(r, e, "must be a finite number");
264
+ throw new ie(r, e, "must be a finite number");
265
265
  const { min: n = 0, max: i = Number.MAX_SAFE_INTEGER } = t;
266
266
  if (e < n)
267
- throw new oe(r, e, `must be >= ${n}`);
267
+ throw new ie(r, e, `must be >= ${n}`);
268
268
  if (e > i)
269
- throw new oe(r, e, `must be <= ${i}`);
269
+ throw new ie(r, e, `must be <= ${i}`);
270
270
  }
271
- function Ye(r, e) {
271
+ function tt(r, e) {
272
272
  if (e !== void 0 && typeof e != "boolean")
273
- throw new oe(r, e, "must be a boolean");
273
+ throw new ie(r, e, "must be a boolean");
274
274
  }
275
- function Lt(r, e = "accessToken") {
275
+ function Mt(r, e = "accessToken") {
276
276
  if (typeof r != "string" || r.length === 0)
277
- throw new oe(e, r, "must be a non-empty string");
277
+ throw new ie(e, r, "must be a non-empty string");
278
278
  if (!r.includes(".")) return;
279
279
  const t = r.split(".");
280
280
  if (t.length !== 3)
281
- throw new oe(
281
+ throw new ie(
282
282
  e,
283
283
  `<${t.length}-segment token>`,
284
284
  "JWT must have exactly 3 segments (header.payload.signature)"
285
285
  );
286
- if (Re(r) === null)
287
- throw new oe(
286
+ if (Pe(r) === null)
287
+ throw new ie(
288
288
  e,
289
289
  "<malformed JWT>",
290
290
  "JWT header or payload is not valid base64url-encoded JSON"
291
291
  );
292
292
  }
293
- function Ft(r) {
293
+ function $t(r) {
294
294
  if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
295
- throw new oe("expiresIn", r, "must be a finite positive number (seconds)");
295
+ throw new ie("expiresIn", r, "must be a finite positive number (seconds)");
296
296
  }
297
- function Nt(r) {
297
+ function Ut(r) {
298
298
  if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
299
- throw new oe(
299
+ throw new ie(
300
300
  "expiresAt",
301
301
  r,
302
302
  "must be a finite positive timestamp (ms since epoch)"
303
303
  );
304
304
  }
305
- const ie = class ie {
305
+ const rt = "__RIA_SESSION_INSTANCES_V1__", ye = (() => {
306
+ const r = globalThis, e = r[rt];
307
+ if (e instanceof Map) return e;
308
+ const t = /* @__PURE__ */ new Map();
309
+ return r[rt] = t, t;
310
+ })(), de = class de {
306
311
  constructor(e = {}) {
307
- this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, this.memoryStore = null, this.visibilityListener = null, ie.validateConfig(e), 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.enableCookieSession = e.enableCookieSession ?? !1, 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.attachVisibilityListener(), this.scheduleProactiveRefresh();
312
+ this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, this.state = "idle", this.isRefreshing = !1, this.lastExpiryReason = null, this.logoutInFlight = !1, this.listeners = /* @__PURE__ */ new Set(), this.notifyVersion = 0, this.memoryStore = null, this.visibilityListener = null, this.storageListener = null, de.validateConfig(e), 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.enableCookieSession = e.enableCookieSession ?? !1, 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);
313
+ const t = this.tokenStorage.get();
314
+ t != null && t.accessToken && (this.state = "restoring"), this.attachVisibilityListener(), this.attachStorageListener(), this.scheduleProactiveRefresh();
308
315
  }
309
316
  /**
310
317
  * Get or create a SessionManager instance for the given config.
@@ -312,30 +319,30 @@ const ie = class ie {
312
319
  * Mutable config (callbacks, baseUrl) is updated on the existing instance.
313
320
  */
314
321
  static getInstance(e = {}) {
315
- const t = ie.resolveStorageKey(e), n = ie.instances.get(t);
322
+ const t = de.resolveStorageKey(e), n = ye.get(t);
316
323
  if (n)
317
324
  return n.updateConfig(e), n;
318
- const i = new ie(e);
319
- return ie.instances.set(t, i), i;
325
+ const i = new de(e);
326
+ return ye.set(t, i), i;
320
327
  }
321
328
  /** Reset all singleton instances. For testing only. */
322
329
  static resetAllInstances() {
323
- for (const e of ie.instances.values())
330
+ for (const e of ye.values())
324
331
  e.destroy();
325
- ie.instances.clear();
332
+ ye.clear();
326
333
  }
327
334
  static resolveStorageKey(e) {
328
335
  return e.storageKey || "auth_tokens";
329
336
  }
330
337
  static validateConfig(e) {
331
- It(e.baseUrl), Ye("enableCookieSession", e.enableCookieSession), Ye("autoRefresh", e.autoRefresh), ge("refreshThreshold", e.refreshThreshold, { min: 0 }), ge("proactiveRefreshMargin", e.proactiveRefreshMargin, { min: 0 }), ge("refreshQueueTimeout", e.refreshQueueTimeout, { min: 1 }), ge("maxRefreshRetries", e.maxRefreshRetries, { min: 0 }), ge("retryBackoffBase", e.retryBackoffBase, { min: 1 });
338
+ Dt(e.baseUrl), tt("enableCookieSession", e.enableCookieSession), tt("autoRefresh", e.autoRefresh), ge("refreshThreshold", e.refreshThreshold, { min: 0 }), ge("proactiveRefreshMargin", e.proactiveRefreshMargin, { min: 0 }), ge("refreshQueueTimeout", e.refreshQueueTimeout, { min: 1 }), ge("maxRefreshRetries", e.maxRefreshRetries, { min: 0 }), ge("retryBackoffBase", e.retryBackoffBase, { min: 1 });
332
339
  }
333
340
  /** Update mutable config (callbacks, baseUrl) on an existing instance. */
334
341
  updateConfig(e) {
335
342
  e.onSessionExpired !== void 0 && (this.onSessionExpired = e.onSessionExpired), e.onRefreshFailed !== void 0 && (this.onRefreshFailed = e.onRefreshFailed), e.baseUrl && (this.baseUrl = e.baseUrl), e.enableCookieSession !== void 0 && (this.enableCookieSession = e.enableCookieSession);
336
343
  }
337
344
  createTokenStorage(e) {
338
- return ie.probeLocalStorage() || this.activateMemoryFallback(), {
345
+ return de.probeLocalStorage() || this.activateMemoryFallback(), {
339
346
  get: () => {
340
347
  const t = this.storageGet(e);
341
348
  if (!t) return null;
@@ -397,26 +404,26 @@ const ie = class ie {
397
404
  }
398
405
  // --- Token CRUD ---
399
406
  setTokens(e) {
400
- if (Lt(e.accessToken, "accessToken"), e.refreshToken !== void 0 && typeof e.refreshToken != "string")
401
- throw new oe("refreshToken", e.refreshToken, "must be a string");
402
- Ft(e.expiresIn), Nt(e.expiresAt);
403
- const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || Ke(e.accessToken), n = {
407
+ if (Mt(e.accessToken, "accessToken"), e.refreshToken !== void 0 && typeof e.refreshToken != "string")
408
+ throw new ie("refreshToken", e.refreshToken, "must be a string");
409
+ $t(e.expiresIn), Ut(e.expiresAt);
410
+ const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || et(e.accessToken), n = {
404
411
  ...e,
405
412
  expiresAt: t
406
413
  }, i = this.tokenStorage.get() || {};
407
- this.tokenStorage.set({ ...i, ...n }), this.scheduleProactiveRefresh();
414
+ this.tokenStorage.set({ ...i, ...n }), this.scheduleProactiveRefresh(), this.isTokenExpired(n) || this.transitionTo("authenticated"), this.notify();
408
415
  }
409
416
  getTokens() {
410
- const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn: i, tokenType: a } = this.tokenStorage.get() || {};
417
+ const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
411
418
  if (!e)
412
419
  return null;
413
- const l = n || Ke(e);
420
+ const a = n || et(e);
414
421
  return {
415
422
  accessToken: e,
416
423
  refreshToken: t,
417
- expiresAt: l,
424
+ expiresAt: a,
418
425
  expiresIn: i,
419
- tokenType: a
426
+ tokenType: o
420
427
  };
421
428
  }
422
429
  clearTokens() {
@@ -471,6 +478,90 @@ const ie = class ie {
471
478
  }
472
479
  this.visibilityListener = null;
473
480
  }
481
+ attachStorageListener() {
482
+ if (!this.storageListener && !(typeof window > "u" || typeof window.addEventListener != "function")) {
483
+ this.storageListener = (e) => {
484
+ if (e.key === this.storageKey && !(e.storageArea && e.storageArea !== localStorage) && !this.isDestroyed) {
485
+ if (e.newValue === null) {
486
+ this.sessionGeneration++, this.cancelProactiveTimer();
487
+ const t = new Q(
488
+ "token_invalid",
489
+ "Session cleared in another tab"
490
+ );
491
+ this.rejectQueue(t), this.transitionTo("idle");
492
+ } else {
493
+ this.scheduleProactiveRefresh();
494
+ const t = this.getTokens();
495
+ t != null && t.accessToken && !this.isTokenExpired(t) && this.transitionTo("authenticated");
496
+ }
497
+ this.notify();
498
+ }
499
+ };
500
+ try {
501
+ window.addEventListener("storage", this.storageListener);
502
+ } catch {
503
+ this.storageListener = null;
504
+ }
505
+ }
506
+ }
507
+ detachStorageListener() {
508
+ if (this.storageListener && typeof window < "u")
509
+ try {
510
+ window.removeEventListener("storage", this.storageListener);
511
+ } catch {
512
+ }
513
+ this.storageListener = null;
514
+ }
515
+ // --- Reactivity (useSyncExternalStore-compatible) ---
516
+ /**
517
+ * Subscribe to session state changes. Returns an unsubscribe function.
518
+ * Fires on: setTokens, setUser, clearUser, clearSession, handleSessionExpired,
519
+ * refresh in-flight transitions, and cross-tab storage events.
520
+ */
521
+ subscribe(e) {
522
+ return this.listeners.add(e), () => {
523
+ this.listeners.delete(e);
524
+ };
525
+ }
526
+ /**
527
+ * Numeric snapshot for useSyncExternalStore. Strictly monotonic — every
528
+ * call to `notify()` bumps it so React will observe a fresh value even
529
+ * when the higher-level state ordinal and refreshing flag look identical.
530
+ */
531
+ getSnapshot() {
532
+ return this.notifyVersion;
533
+ }
534
+ /** True iff a refresh network call is currently in flight or queued. */
535
+ getRefreshInFlight() {
536
+ return this.refreshPromise !== null;
537
+ }
538
+ /** Current state of the session machine. */
539
+ getState() {
540
+ return this.state;
541
+ }
542
+ /** Diagnostic snapshot — useful for tests and DevTools. */
543
+ getRefreshStats() {
544
+ return {
545
+ state: this.state,
546
+ isRefreshing: this.isRefreshing,
547
+ inFlight: this.refreshPromise !== null,
548
+ queued: this.refreshQueue.length,
549
+ sessionGeneration: this.sessionGeneration,
550
+ consecutiveBackgroundFailures: this.consecutiveBackgroundFailures,
551
+ lastExpiryReason: this.lastExpiryReason
552
+ };
553
+ }
554
+ notify() {
555
+ this.notifyVersion++;
556
+ for (const e of this.listeners)
557
+ try {
558
+ e();
559
+ } catch {
560
+ }
561
+ }
562
+ transitionTo(e) {
563
+ this.state !== e && (this.state = e);
564
+ }
474
565
  backgroundRefresh() {
475
566
  if (this.isDestroyed) return;
476
567
  const e = this.getTokens();
@@ -479,13 +570,13 @@ const ie = class ie {
479
570
  this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
480
571
  this.consecutiveBackgroundFailures = 0;
481
572
  }).catch((n) => {
482
- if (!(n instanceof Z)) {
573
+ if (!(n instanceof Q)) {
483
574
  if (this.sessionGeneration === t) {
484
- if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= ie.MAX_BACKGROUND_FAILURES) {
575
+ if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= de.MAX_BACKGROUND_FAILURES) {
485
576
  process.env.NODE_ENV === "development" && console.error(
486
577
  `[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
487
578
  ), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
488
- new Z("token_invalid", "Background refresh failed repeatedly")
579
+ new Q("token_invalid", "Background refresh failed repeatedly")
489
580
  );
490
581
  return;
491
582
  }
@@ -552,13 +643,13 @@ const ie = class ie {
552
643
  async getValidAccessToken() {
553
644
  const e = this.getTokens();
554
645
  if (!(e != null && e.accessToken)) {
555
- const t = new Z("token_invalid", "No tokens available");
646
+ const t = new Q("token_invalid", "No tokens available");
556
647
  throw this.handleSessionExpired(t), t;
557
648
  }
558
649
  if (!this.shouldRefreshToken(e) && !this.isTokenExpired(e))
559
650
  return e.accessToken;
560
651
  if (!e.refreshToken) {
561
- const t = new Z("token_invalid", "No refresh token available");
652
+ const t = new Q("token_invalid", "No refresh token available");
562
653
  throw this.handleSessionExpired(t), t;
563
654
  }
564
655
  return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken);
@@ -577,15 +668,48 @@ const ie = class ie {
577
668
  async forceRefresh() {
578
669
  const e = this.getTokens();
579
670
  if (!(e != null && e.accessToken)) {
580
- const t = new Z("token_invalid", "No tokens available");
671
+ const t = new Q("token_invalid", "No tokens available");
581
672
  throw this.handleSessionExpired(t), t;
582
673
  }
583
674
  if (!e.refreshToken) {
584
- const t = new Z("token_invalid", "No refresh token available");
675
+ const t = new Q("token_invalid", "No refresh token available");
585
676
  throw this.handleSessionExpired(t), t;
586
677
  }
587
678
  return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken, !0);
588
679
  }
680
+ /**
681
+ * Active bootstrap resolution: drive the session to a terminal state.
682
+ *
683
+ * Unlike `waitForPendingRefresh()` which only awaits a refresh someone else
684
+ * already started, this method actively triggers the refresh when needed.
685
+ * Use it from `AuthProvider` during initial mount so a page load with a
686
+ * stale access token but valid refresh token doesn't expose
687
+ * `isAuthenticated=false` before the refresh even runs.
688
+ *
689
+ * Resolves to:
690
+ * - `'authenticated'`: tokens exist and are valid (refreshed if necessary)
691
+ * - `'unauthenticated'`: no tokens at all (callers should treat as anon)
692
+ * - `'expired'`: tokens existed but refresh failed fatally; the
693
+ * `onSessionExpired` callback was already fired by `handleSessionExpired`.
694
+ *
695
+ * Never throws — all error paths collapse into `'expired'`.
696
+ */
697
+ async ensureValidSession() {
698
+ const e = this.getTokens();
699
+ if (!(e != null && e.accessToken))
700
+ return this.transitionTo("idle"), this.notify(), "unauthenticated";
701
+ if (!this.isTokenExpired(e) && !this.shouldRefreshToken(e))
702
+ return this.transitionTo("authenticated"), this.notify(), "authenticated";
703
+ if (!e.refreshToken)
704
+ return this.handleSessionExpired(
705
+ new Q("token_invalid", "No refresh token available")
706
+ ), "expired";
707
+ try {
708
+ return await this.getValidAccessToken(), this.transitionTo("authenticated"), this.notify(), "authenticated";
709
+ } catch {
710
+ return this.state !== "expired" && (this.transitionTo("expired"), this.notify()), "expired";
711
+ }
712
+ }
589
713
  /**
590
714
  * Backward-compatible getAuthHeaders — now delegates to getValidAccessToken.
591
715
  */
@@ -593,29 +717,30 @@ const ie = class ie {
593
717
  try {
594
718
  return { Authorization: `Bearer ${await this.getValidAccessToken()}` };
595
719
  } catch (e) {
596
- return e instanceof Z && this.onRefreshFailed && this.onRefreshFailed(), {};
720
+ return e instanceof Q && this.onRefreshFailed && this.onRefreshFailed(), {};
597
721
  }
598
722
  }
599
723
  enqueueForToken() {
600
724
  return new Promise((e, t) => {
601
725
  const n = setTimeout(() => {
602
- const i = this.refreshQueue.findIndex((a) => a.timeoutId === n);
603
- i !== -1 && this.refreshQueue.splice(i, 1), t(new kt(this.refreshQueueTimeout));
726
+ const i = this.refreshQueue.findIndex((o) => o.timeoutId === n);
727
+ i !== -1 && this.refreshQueue.splice(i, 1), t(new Pt(this.refreshQueueTimeout));
604
728
  }, this.refreshQueueTimeout);
605
729
  this.refreshQueue.push({ resolve: e, reject: t, timeoutId: n });
606
730
  });
607
731
  }
608
732
  async startRefreshAndResolveQueue(e, t = !1) {
609
- this.refreshPromise = this.executeRefreshWithRetry(e, t);
733
+ const n = this.sessionGeneration;
734
+ this.refreshPromise = this.executeRefreshWithRetry(e, t), this.isRefreshing = !0, this.notify();
610
735
  try {
611
736
  await this.refreshPromise;
612
- const n = this.getTokens(), i = (n == null ? void 0 : n.accessToken) || "";
613
- return this.resolveQueue(i), i;
614
- } catch (n) {
615
- const i = n instanceof Error ? n : new Error("Token refresh failed");
616
- throw i instanceof Z ? (this.rejectQueue(i), this.handleSessionExpired(i)) : this.rejectQueue(i), i;
737
+ const i = this.getTokens(), o = (i == null ? void 0 : i.accessToken) || "";
738
+ return this.resolveQueue(o), o;
739
+ } catch (i) {
740
+ const o = i instanceof Error ? i : new Error("Token refresh failed");
741
+ throw o instanceof Q ? (this.rejectQueue(o), this.sessionGeneration === n && this.handleSessionExpired(o)) : this.rejectQueue(o), o;
617
742
  } finally {
618
- this.refreshPromise = null;
743
+ this.refreshPromise = null, this.isRefreshing = !1, this.notify();
619
744
  }
620
745
  }
621
746
  resolveQueue(e) {
@@ -634,23 +759,23 @@ const ie = class ie {
634
759
  async executeRefreshWithRetry(e, t = !1) {
635
760
  let n;
636
761
  const i = this.sessionGeneration;
637
- for (let a = 0; a <= this.maxRefreshRetries; a++) {
762
+ for (let o = 0; o <= this.maxRefreshRetries; o++) {
638
763
  if (this.sessionGeneration !== i)
639
- throw new Z("token_invalid", "Session cleared during refresh");
764
+ throw new Q("token_invalid", "Session cleared during refresh");
640
765
  try {
641
766
  await this.performTokenRefresh(e, i, t);
642
767
  return;
643
- } catch (l) {
644
- const h = l instanceof Error ? l : new Error(String(l));
645
- if (h instanceof Z)
646
- throw h;
647
- if (n = h, a < this.maxRefreshRetries) {
648
- const S = this.retryBackoffBase * Math.pow(2, a);
649
- await this.sleep(S);
768
+ } catch (a) {
769
+ const p = a instanceof Error ? a : new Error(String(a));
770
+ if (p instanceof Q)
771
+ throw p;
772
+ if (n = p, o < this.maxRefreshRetries) {
773
+ const k = this.retryBackoffBase * Math.pow(2, o);
774
+ await this.sleep(k);
650
775
  }
651
776
  }
652
777
  }
653
- throw new Et(this.maxRefreshRetries + 1, n);
778
+ throw new It(this.maxRefreshRetries + 1, n);
654
779
  }
655
780
  /**
656
781
  * Single refresh attempt with error classification.
@@ -669,46 +794,49 @@ const ie = class ie {
669
794
  const i = this.getTokens();
670
795
  if (!n && (i != null && i.accessToken) && !this.isTokenExpired(i) && !this.shouldRefreshToken(i))
671
796
  return;
672
- const a = (i == null ? void 0 : i.refreshToken) || e, l = `${this.baseUrl}/auth/refresh`, h = At(a, "deviceId"), S = { refreshToken: a };
673
- h && (S.deviceId = h);
674
- let k;
797
+ const o = (i == null ? void 0 : i.refreshToken) || e, a = `${this.baseUrl}/auth/refresh`, p = Ft(o, "deviceId"), k = { refreshToken: o };
798
+ p && (k.deviceId = p);
799
+ let E;
675
800
  try {
676
- k = await fetch(l, {
801
+ E = await fetch(a, {
677
802
  method: "POST",
678
803
  headers: { "Content-Type": "application/json" },
679
- body: JSON.stringify(S),
804
+ body: JSON.stringify(k),
680
805
  ...this.enableCookieSession && { credentials: "include" }
681
806
  });
682
807
  } catch (c) {
683
808
  throw c instanceof Error ? c : new Error("Network error during token refresh");
684
809
  }
685
- if (!k.ok) {
810
+ if (!E.ok) {
686
811
  let c = "";
687
812
  try {
688
- const d = await k.json();
813
+ const d = await E.json();
689
814
  c = (d.message || d.error || "").toLowerCase();
690
815
  } catch {
691
- c = k.statusText.toLowerCase();
816
+ c = E.statusText.toLowerCase();
692
817
  }
693
- throw k.status === 401 ? c.includes("expired") ? new Z("token_expired") : c.includes("invalid") ? new Z("token_invalid") : new Z("token_invalid", `Unauthorized: ${c}`) : k.status === 400 ? c.includes("inactive") ? new Z("user_inactive") : c.includes("expired") || c.includes("invalid") ? new Z("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new Z("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${k.status} ${c}`);
818
+ throw E.status === 401 ? c.includes("expired") ? new Q("token_expired") : c.includes("invalid") ? new Q("token_invalid") : new Q("token_invalid", `Unauthorized: ${c}`) : E.status === 400 ? c.includes("inactive") ? new Q("user_inactive") : c.includes("expired") || c.includes("invalid") ? new Q("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new Q("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${E.status} ${c}`);
694
819
  }
695
820
  if (this.sessionGeneration !== t)
696
- throw new Z("token_invalid", "Session cleared during refresh");
697
- const T = await k.json();
821
+ throw new Q("token_invalid", "Session cleared during refresh");
822
+ const S = await E.json();
698
823
  this.setTokens({
699
- accessToken: T.accessToken,
700
- refreshToken: T.refreshToken || a,
701
- expiresIn: T.expiresIn
824
+ accessToken: S.accessToken,
825
+ refreshToken: S.refreshToken || o,
826
+ expiresIn: S.expiresIn
702
827
  });
703
828
  }
704
829
  // --- Session expiry handler ---
705
830
  handleSessionExpired(e) {
706
- this.cancelProactiveTimer(), this.clearSession(), this.onSessionExpired ? this.onSessionExpired(e) : this.onRefreshFailed && this.onRefreshFailed();
831
+ const t = this.logoutInFlight;
832
+ this.lastExpiryReason = e.message, this.cancelProactiveTimer(), this.sessionGeneration++, this.clearTokens();
833
+ const n = new Q("token_invalid", "Session cleared");
834
+ this.rejectQueue(n), this.transitionTo(t ? "idle" : "expired"), this.notify(), !t && (this.onSessionExpired ? this.onSessionExpired(e) : this.onRefreshFailed && this.onRefreshFailed());
707
835
  }
708
836
  // --- User data ---
709
837
  setUser(e) {
710
838
  const t = this.tokenStorage.get() || {};
711
- this.tokenStorage.set({ ...t, user: e });
839
+ this.tokenStorage.set({ ...t, user: e }), this.notify();
712
840
  }
713
841
  getUser() {
714
842
  const e = this.tokenStorage.get();
@@ -716,28 +844,37 @@ const ie = class ie {
716
844
  }
717
845
  clearUser() {
718
846
  const e = this.tokenStorage.get() || {};
719
- delete e.user, this.tokenStorage.set(e);
847
+ delete e.user, this.tokenStorage.set(e), this.notify();
720
848
  }
721
849
  // --- Session lifecycle ---
722
- clearSession() {
723
- this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
724
- const e = new Z("token_invalid", "Session cleared");
725
- this.rejectQueue(e);
850
+ /**
851
+ * Clear all session state.
852
+ *
853
+ * @param reason - 'logout' for intentional sign-out (suppresses any
854
+ * onSessionExpired callbacks fired by in-flight refreshes that race the
855
+ * logout); 'expired' for fatal-error paths. Defaults to 'expired' for
856
+ * backward compatibility.
857
+ */
858
+ clearSession(e = "expired") {
859
+ const t = e === "logout";
860
+ t && (this.logoutInFlight = !0), this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
861
+ const n = new Q("token_invalid", "Session cleared");
862
+ this.rejectQueue(n), this.transitionTo(t ? "idle" : "expired"), this.notify(), t && (this.logoutInFlight = !1);
726
863
  }
727
864
  /**
728
865
  * Dispose of this SessionManager instance.
729
866
  * Cancels all timers and rejects pending queue entries.
730
867
  */
731
868
  destroy() {
732
- this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer(), this.detachVisibilityListener();
733
- const e = new Z("token_invalid", "SessionManager destroyed");
869
+ this.isDestroyed = !0, ye.delete(this.storageKey), this.cancelProactiveTimer(), this.detachVisibilityListener(), this.detachStorageListener(), this.listeners.clear();
870
+ const e = new Q("token_invalid", "SessionManager destroyed");
734
871
  this.rejectQueue(e);
735
872
  }
736
873
  // --- JWT helpers ---
737
874
  getTokenPayload() {
738
875
  var t, n;
739
876
  const e = (t = this.getTokens()) == null ? void 0 : t.accessToken;
740
- return e ? ((n = Re(e)) == null ? void 0 : n.payload) ?? null : null;
877
+ return e ? ((n = Pe(e)) == null ? void 0 : n.payload) ?? null : null;
741
878
  }
742
879
  /**
743
880
  * Get userId from token (source of truth) or fallback to stored user
@@ -757,9 +894,9 @@ const ie = class ie {
757
894
  return new Promise((t) => setTimeout(t, e));
758
895
  }
759
896
  };
760
- ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
761
- let Me = ie;
762
- class Ct {
897
+ de.MAX_BACKGROUND_FAILURES = 3;
898
+ let Ue = de;
899
+ class Bt {
763
900
  constructor(e) {
764
901
  this.httpService = e, this.verificationCache = /* @__PURE__ */ new Map(), this.VERIFY_CACHE_TTL_MS = 6e4, this.pendingMagicLinks = /* @__PURE__ */ new Map();
765
902
  }
@@ -816,10 +953,10 @@ class Ct {
816
953
  "/auth/magic-link/verify",
817
954
  e,
818
955
  { skipAuth: !0 }
819
- ), a = { promise: i };
820
- return this.verificationCache.set(t, a), i.then(
956
+ ), o = { promise: i };
957
+ return this.verificationCache.set(t, o), i.then(
821
958
  () => {
822
- a.timer = setTimeout(
959
+ o.timer = setTimeout(
823
960
  () => this.verificationCache.delete(t),
824
961
  this.VERIFY_CACHE_TTL_MS
825
962
  );
@@ -836,7 +973,7 @@ class Ct {
836
973
  await this.httpService.post("/auth/change-password", e);
837
974
  }
838
975
  }
839
- class Dt {
976
+ class _t {
840
977
  constructor(e) {
841
978
  this.httpService = e;
842
979
  }
@@ -854,7 +991,7 @@ class Dt {
854
991
  }
855
992
  async getRolesByApp(e, t) {
856
993
  const n = await this.httpService.get(
857
- `/roles/app/${e}${ce(t)}`,
994
+ `/roles/app/${e}${le(t)}`,
858
995
  { skipAuth: !0 }
859
996
  );
860
997
  return { roles: n.data, meta: n.meta };
@@ -867,12 +1004,12 @@ class Dt {
867
1004
  }
868
1005
  async getUserRoles(e, t) {
869
1006
  const n = await this.httpService.get(
870
- `/roles/user/${e}${ce(t)}`
1007
+ `/roles/user/${e}${le(t)}`
871
1008
  );
872
1009
  return { roles: n.data, meta: n.meta };
873
1010
  }
874
1011
  }
875
- class Mt {
1012
+ class Ot {
876
1013
  constructor(e) {
877
1014
  this.httpService = e;
878
1015
  }
@@ -881,7 +1018,7 @@ class Mt {
881
1018
  }
882
1019
  async getUsers(e) {
883
1020
  const t = await this.httpService.get(
884
- `/users/${ce(e)}`
1021
+ `/users/${le(e)}`
885
1022
  );
886
1023
  return { users: t.data, meta: t.meta };
887
1024
  }
@@ -895,7 +1032,7 @@ class Mt {
895
1032
  await this.httpService.delete(`/users/${e}`);
896
1033
  }
897
1034
  }
898
- class be {
1035
+ class we {
899
1036
  constructor(e, t) {
900
1037
  this.httpService = e, this.appId = t;
901
1038
  }
@@ -904,7 +1041,7 @@ class be {
904
1041
  }
905
1042
  async getTenants(e) {
906
1043
  const t = await this.httpService.get(
907
- `/tenants/${ce(e)}`
1044
+ `/tenants/${le(e)}`
908
1045
  );
909
1046
  return { tenants: t.data, meta: t.meta };
910
1047
  }
@@ -939,40 +1076,40 @@ class be {
939
1076
  )).data;
940
1077
  }
941
1078
  }
942
- function $t(r, e) {
1079
+ function Vt(r, e) {
943
1080
  if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
944
1081
  return null;
945
1082
  if (e) {
946
- const i = e.toLowerCase(), a = r.toLowerCase();
947
- if (a === i || a === `www.${i}`)
1083
+ const i = e.toLowerCase(), o = r.toLowerCase();
1084
+ if (o === i || o === `www.${i}`)
948
1085
  return null;
949
- if (a.endsWith(`.${i}`)) {
950
- const l = a.slice(0, -(i.length + 1));
951
- return l === "www" ? null : l;
1086
+ if (o.endsWith(`.${i}`)) {
1087
+ const a = o.slice(0, -(i.length + 1));
1088
+ return a === "www" ? null : a;
952
1089
  }
953
1090
  return null;
954
1091
  }
955
1092
  const n = r.split(".");
956
1093
  return n.length >= 3 && n[0] !== "www" ? n[0] : null;
957
1094
  }
958
- function Ut(r, e = "tenant", t) {
1095
+ function qt(r, e = "tenant", t) {
959
1096
  const i = new URLSearchParams(r).get(e);
960
1097
  return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
961
1098
  }
962
- function Bt(r, e, t) {
963
- const { tenantMode: n, baseDomain: i, selectorParam: a, fixedTenantSlug: l } = r;
964
- return n === "fixed" ? l || null : n === "subdomain" ? $t(e.hostname, i) : n === "selector" ? Ut(e.search, a, t) : null;
1099
+ function zt(r, e, t) {
1100
+ const { tenantMode: n, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = r;
1101
+ return n === "fixed" ? a || null : n === "subdomain" ? Vt(e.hostname, i) : n === "selector" ? qt(e.search, o, t) : null;
965
1102
  }
966
- function _t(r, e, t) {
1103
+ function Gt(r, e, t) {
967
1104
  if (t)
968
1105
  return `${r}.${t}`;
969
1106
  const n = e.split(".");
970
1107
  return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
971
1108
  }
972
- const Be = fe(null);
973
- function xr({ config: r, children: e }) {
974
- var j, K, $;
975
- const { baseUrl: t, appInfo: n, appId: i } = Ae(), a = te(() => typeof window > "u" ? null : Bt(
1109
+ const Oe = fe(null);
1110
+ function Lr({ config: r, children: e }) {
1111
+ var z, Z, K;
1112
+ const { baseUrl: t, appInfo: n, appId: i } = Ae(), o = te(() => typeof window > "u" ? null : zt(
976
1113
  {
977
1114
  tenantMode: r.tenantMode || "selector",
978
1115
  baseDomain: r.baseDomain,
@@ -984,111 +1121,111 @@ function xr({ config: r, children: e }) {
984
1121
  search: window.location.search
985
1122
  },
986
1123
  window.localStorage
987
- ), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, h] = N(() => a()), S = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0, k = ((K = r.cache) == null ? void 0 : K.ttl) ?? 5 * 60 * 1e3, T = (($ = r.cache) == null ? void 0 : $.storageKey) ?? `tenant_cache_${l || "default"}`, c = V(
988
- () => ({ enabled: S, ttl: k, storageKey: T }),
989
- [S, k, T]
990
- ), [d, A] = N(() => {
1124
+ ), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = C(() => o()), k = ((z = r.cache) == null ? void 0 : z.enabled) ?? !0, E = ((Z = r.cache) == null ? void 0 : Z.ttl) ?? 300 * 1e3, S = ((K = r.cache) == null ? void 0 : K.storageKey) ?? `tenant_cache_${a || "default"}`, c = O(
1125
+ () => ({ enabled: k, ttl: E, storageKey: S }),
1126
+ [k, E, S]
1127
+ ), [d, x] = C(() => {
991
1128
  if (r.initialTenant) return r.initialTenant;
992
- if (!c.enabled || !l) return null;
1129
+ if (!c.enabled || !a) return null;
993
1130
  try {
994
- const B = localStorage.getItem(c.storageKey);
995
- if (!B) return null;
996
- const L = JSON.parse(B);
997
- return Date.now() - L.timestamp < c.ttl && L.tenantSlug === l ? L.data : (localStorage.removeItem(c.storageKey), null);
1131
+ const D = localStorage.getItem(c.storageKey);
1132
+ if (!D) return null;
1133
+ const F = JSON.parse(D);
1134
+ return Date.now() - F.timestamp < c.ttl && F.tenantSlug === a ? F.data : (localStorage.removeItem(c.storageKey), null);
998
1135
  } catch {
999
1136
  return null;
1000
1137
  }
1001
- }), [P, I] = N(!d && !r.initialTenant), [R, E] = N(null), [m, g] = N(null), [b, C] = N(!1), [o, p] = N(null);
1138
+ }), [I, L] = C(!d && !r.initialTenant), [P, R] = C(null), [m, g] = C(null), [b, w] = C(!1), [l, h] = C(null);
1002
1139
  re(() => {
1003
1140
  if (r.tenantMode === "fixed") return;
1004
- const B = a();
1005
- h(B);
1006
- }, [a, r.tenantMode]);
1007
- const x = (n == null ? void 0 : n.settingsSchema) || null, y = te(
1008
- async (B, L = !1) => {
1009
- if (!(!L && c.enabled && d && d.subdomain === B))
1141
+ const D = o();
1142
+ p(D);
1143
+ }, [o, r.tenantMode]);
1144
+ const A = (n == null ? void 0 : n.settingsSchema) || null, y = te(
1145
+ async (D, F = !1) => {
1146
+ if (!(!F && c.enabled && d && d.subdomain === D))
1010
1147
  try {
1011
- I(!0), E(null);
1012
- const q = new he(t), W = await new be(q, i).getPublicTenantInfo(B);
1013
- if (A(W), c.enabled)
1148
+ L(!0), R(null);
1149
+ const _ = new he(t), G = await new we(_, i).getPublicTenantInfo(D);
1150
+ if (x(G), c.enabled)
1014
1151
  try {
1015
1152
  const Y = {
1016
- data: W,
1153
+ data: G,
1017
1154
  timestamp: Date.now(),
1018
- tenantSlug: B
1155
+ tenantSlug: D
1019
1156
  };
1020
1157
  localStorage.setItem(c.storageKey, JSON.stringify(Y));
1021
1158
  } catch (Y) {
1022
1159
  process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", Y);
1023
1160
  }
1024
- } catch (q) {
1025
- const _ = q instanceof Error ? q : new Error("Failed to load tenant information");
1026
- E(_), A(null);
1161
+ } catch (_) {
1162
+ const B = _ instanceof Error ? _ : new Error("Failed to load tenant information");
1163
+ R(B), x(null);
1027
1164
  } finally {
1028
- I(!1);
1165
+ L(!1);
1029
1166
  }
1030
1167
  },
1031
1168
  [t, i, c, d]
1032
1169
  ), u = te(async () => {
1033
- if (!(!c.enabled || !d || !l))
1170
+ if (!(!c.enabled || !d || !a))
1034
1171
  try {
1035
- const B = localStorage.getItem(c.storageKey);
1036
- if (!B) return;
1037
- const L = JSON.parse(B);
1038
- if (Date.now() - L.timestamp > c.ttl * 0.5) {
1039
- const _ = new he(t), Y = await new be(_, i).getPublicTenantInfo(l);
1040
- A(Y);
1172
+ const D = localStorage.getItem(c.storageKey);
1173
+ if (!D) return;
1174
+ const F = JSON.parse(D);
1175
+ if (Date.now() - F.timestamp > c.ttl * 0.5) {
1176
+ const B = new he(t), Y = await new we(B, i).getPublicTenantInfo(a);
1177
+ x(Y);
1041
1178
  const X = {
1042
1179
  data: Y,
1043
1180
  timestamp: Date.now(),
1044
- tenantSlug: l
1181
+ tenantSlug: a
1045
1182
  };
1046
1183
  localStorage.setItem(c.storageKey, JSON.stringify(X));
1047
1184
  }
1048
- } catch (B) {
1049
- process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", B);
1185
+ } catch (D) {
1186
+ process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", D);
1050
1187
  }
1051
- }, [t, i, c, d, l]), v = te(async () => {
1188
+ }, [t, i, c, d, a]), T = te(async () => {
1052
1189
  if (d != null && d.id)
1053
1190
  try {
1054
- C(!0), p(null);
1055
- const B = new he(t), q = await new be(B, d.appId).getTenantSettings(d.id);
1056
- g(q);
1057
- } catch (B) {
1058
- const L = B instanceof Error ? B : new Error("Failed to load tenant settings");
1059
- p(L), g(null);
1191
+ w(!0), h(null);
1192
+ const D = new he(t), _ = await new we(D, d.appId).getTenantSettings(d.id);
1193
+ g(_);
1194
+ } catch (D) {
1195
+ const F = D instanceof Error ? D : new Error("Failed to load tenant settings");
1196
+ h(F), g(null);
1060
1197
  } finally {
1061
- C(!1);
1198
+ w(!1);
1062
1199
  }
1063
- }, [t, d]), D = te(() => {
1064
- v();
1065
- }, [v]), se = te(
1066
- (B) => {
1067
- if (!x)
1200
+ }, [t, d]), M = te(() => {
1201
+ T();
1202
+ }, [T]), se = te(
1203
+ (D) => {
1204
+ if (!A)
1068
1205
  return { isValid: !0, errors: [] };
1069
- const L = [];
1206
+ const F = [];
1070
1207
  try {
1071
- return x.properties && Object.entries(x.properties).forEach(([q, _]) => {
1208
+ return A.properties && Object.entries(A.properties).forEach(([_, B]) => {
1072
1209
  var Y;
1073
- const W = B[q];
1074
- if ((Y = x.required) != null && Y.includes(q) && W == null) {
1075
- L.push(`Field '${q}' is required`);
1210
+ const G = D[_];
1211
+ if ((Y = A.required) != null && Y.includes(_) && G == null) {
1212
+ F.push(`Field '${_}' is required`);
1076
1213
  return;
1077
1214
  }
1078
- if (W != null) {
1079
- if (_.type) {
1080
- const X = _.type, le = typeof W;
1081
- X === "string" && le !== "string" ? L.push(`Field '${q}' must be a string`) : (X === "number" || X === "integer") && le !== "number" ? L.push(`Field '${q}' must be a number`) : X === "boolean" && le !== "boolean" ? L.push(`Field '${q}' must be a boolean`) : X === "array" && !Array.isArray(W) && L.push(`Field '${q}' must be an array`);
1215
+ if (G != null) {
1216
+ if (B.type) {
1217
+ const X = B.type, ae = typeof G;
1218
+ X === "string" && ae !== "string" ? F.push(`Field '${_}' must be a string`) : (X === "number" || X === "integer") && ae !== "number" ? F.push(`Field '${_}' must be a number`) : X === "boolean" && ae !== "boolean" ? F.push(`Field '${_}' must be a boolean`) : X === "array" && !Array.isArray(G) && F.push(`Field '${_}' must be an array`);
1082
1219
  }
1083
- _.minLength !== void 0 && typeof W == "string" && W.length < _.minLength && L.push(
1084
- `Field '${q}' must be at least ${_.minLength} characters long`
1085
- ), _.maxLength !== void 0 && typeof W == "string" && W.length > _.maxLength && L.push(
1086
- `Field '${q}' must be no more than ${_.maxLength} characters long`
1087
- ), _.minimum !== void 0 && typeof W == "number" && W < _.minimum && L.push(`Field '${q}' must be at least ${_.minimum}`), _.maximum !== void 0 && typeof W == "number" && W > _.maximum && L.push(`Field '${q}' must be no more than ${_.maximum}`), _.pattern && typeof W == "string" && (new RegExp(_.pattern).test(W) || L.push(`Field '${q}' does not match the required pattern`)), _.enum && !_.enum.includes(W) && L.push(`Field '${q}' must be one of: ${_.enum.join(", ")}`);
1220
+ B.minLength !== void 0 && typeof G == "string" && G.length < B.minLength && F.push(
1221
+ `Field '${_}' must be at least ${B.minLength} characters long`
1222
+ ), B.maxLength !== void 0 && typeof G == "string" && G.length > B.maxLength && F.push(
1223
+ `Field '${_}' must be no more than ${B.maxLength} characters long`
1224
+ ), B.minimum !== void 0 && typeof G == "number" && G < B.minimum && F.push(`Field '${_}' must be at least ${B.minimum}`), B.maximum !== void 0 && typeof G == "number" && G > B.maximum && F.push(`Field '${_}' must be no more than ${B.maximum}`), B.pattern && typeof G == "string" && (new RegExp(B.pattern).test(G) || F.push(`Field '${_}' does not match the required pattern`)), B.enum && !B.enum.includes(G) && F.push(`Field '${_}' must be one of: ${B.enum.join(", ")}`);
1088
1225
  }
1089
1226
  }), {
1090
- isValid: L.length === 0,
1091
- errors: L
1227
+ isValid: F.length === 0,
1228
+ errors: F
1092
1229
  };
1093
1230
  } catch {
1094
1231
  return {
@@ -1097,26 +1234,26 @@ function xr({ config: r, children: e }) {
1097
1234
  };
1098
1235
  }
1099
1236
  },
1100
- [x]
1237
+ [A]
1101
1238
  );
1102
1239
  re(() => {
1103
- !r.initialTenant && l ? d ? u() : y(l) : !r.initialTenant && !l && (A(null), E(null), I(!1));
1104
- }, [r.initialTenant, l, d, y, u]), re(() => {
1105
- d != null && d.id ? v() : (g(null), p(null), C(!1));
1106
- }, [d == null ? void 0 : d.id, v]);
1107
- const F = te(
1108
- (B, L) => {
1109
- const { mode: q = "reload", redirectPath: _ } = L || {}, W = r.tenantMode || "selector";
1110
- if (W === "fixed") {
1240
+ !r.initialTenant && a ? d ? u() : y(a) : !r.initialTenant && !a && (x(null), R(null), L(!1));
1241
+ }, [r.initialTenant, a, d, y, u]), re(() => {
1242
+ d != null && d.id ? T() : (g(null), h(null), w(!1));
1243
+ }, [d == null ? void 0 : d.id, T]);
1244
+ const N = te(
1245
+ (D, F) => {
1246
+ const { mode: _ = "reload", redirectPath: B } = F || {}, G = r.tenantMode || "selector";
1247
+ if (G === "fixed") {
1111
1248
  process.env.NODE_ENV === "development" && console.warn(
1112
1249
  "[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
1113
1250
  r.fixedTenantSlug
1114
- ), _ && (window.location.href = _);
1251
+ ), B && (window.location.href = B);
1115
1252
  return;
1116
1253
  }
1117
- if (localStorage.setItem("tenant", B), W === "subdomain") {
1118
- const Y = window.location.hostname, X = _t(
1119
- B,
1254
+ if (localStorage.setItem("tenant", D), G === "subdomain") {
1255
+ const Y = window.location.hostname, X = Gt(
1256
+ D,
1120
1257
  Y,
1121
1258
  r.baseDomain
1122
1259
  );
@@ -1127,68 +1264,68 @@ function xr({ config: r, children: e }) {
1127
1264
  );
1128
1265
  return;
1129
1266
  }
1130
- const le = _ || window.location.pathname, Se = new URL(`${window.location.protocol}//${X}${le}`);
1131
- new URLSearchParams(window.location.search).forEach((Fe, Ne) => {
1132
- Se.searchParams.set(Ne, Fe);
1133
- }), window.location.href = Se.toString();
1134
- } else if (W === "selector") {
1135
- const Y = _ || window.location.pathname, X = new URLSearchParams(window.location.search);
1136
- if (X.set(r.selectorParam || "tenant", B), q === "reload") {
1137
- const le = `${Y}?${X.toString()}${window.location.hash}`;
1138
- window.location.href = le;
1267
+ const ae = B || window.location.pathname, ke = new URL(`${window.location.protocol}//${X}${ae}`);
1268
+ new URLSearchParams(window.location.search).forEach((Ne, Ce) => {
1269
+ ke.searchParams.set(Ce, Ne);
1270
+ }), window.location.href = ke.toString();
1271
+ } else if (G === "selector") {
1272
+ const Y = B || window.location.pathname, X = new URLSearchParams(window.location.search);
1273
+ if (X.set(r.selectorParam || "tenant", D), _ === "reload") {
1274
+ const ae = `${Y}?${X.toString()}${window.location.hash}`;
1275
+ window.location.href = ae;
1139
1276
  } else {
1140
- const le = `${Y}?${X.toString()}${window.location.hash}`;
1141
- window.history.pushState({}, "", le), h(B), y(B);
1277
+ const ae = `${Y}?${X.toString()}${window.location.hash}`;
1278
+ window.history.pushState({}, "", ae), p(D), y(D);
1142
1279
  }
1143
1280
  }
1144
1281
  },
1145
1282
  [r.tenantMode, r.selectorParam, r.baseDomain, r.fixedTenantSlug, y]
1146
- ), H = V(() => ({
1283
+ ), W = O(() => ({
1147
1284
  // Tenant info
1148
1285
  tenant: d,
1149
- tenantSlug: l,
1150
- isTenantLoading: P,
1151
- tenantError: R,
1286
+ tenantSlug: a,
1287
+ isTenantLoading: I,
1288
+ tenantError: P,
1152
1289
  retryTenant: () => {
1153
- l && y(l);
1290
+ a && y(a);
1154
1291
  },
1155
1292
  // Settings
1156
1293
  settings: m,
1157
- settingsSchema: x,
1294
+ settingsSchema: A,
1158
1295
  isSettingsLoading: b,
1159
- settingsError: o,
1296
+ settingsError: l,
1160
1297
  // Actions
1161
- refreshSettings: D,
1162
- switchTenant: F,
1298
+ refreshSettings: M,
1299
+ switchTenant: N,
1163
1300
  // Validation
1164
1301
  validateSettings: se
1165
1302
  }), [
1166
1303
  d,
1167
- l,
1304
+ a,
1305
+ I,
1168
1306
  P,
1169
- R,
1170
1307
  m,
1171
- x,
1308
+ A,
1172
1309
  b,
1173
- o,
1174
- D,
1175
- F,
1310
+ l,
1311
+ M,
1312
+ N,
1176
1313
  se
1177
1314
  ]);
1178
- return /* @__PURE__ */ s(Be.Provider, { value: H, children: e });
1315
+ return /* @__PURE__ */ s(Oe.Provider, { value: W, children: e });
1179
1316
  }
1180
- function Te() {
1181
- const r = ne(Be);
1317
+ function Se() {
1318
+ const r = ne(Oe);
1182
1319
  if (!r)
1183
1320
  throw new Error("useTenant must be used within a TenantProvider");
1184
1321
  return r;
1185
1322
  }
1186
1323
  function pe() {
1187
- return ne(Be);
1324
+ return ne(Oe);
1188
1325
  }
1189
- const Ar = Te;
1190
- function Rr() {
1191
- const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = Te();
1326
+ const Fr = Se;
1327
+ function Nr() {
1328
+ const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = Se();
1192
1329
  return {
1193
1330
  settings: r,
1194
1331
  settingsSchema: e,
@@ -1197,8 +1334,8 @@ function Rr() {
1197
1334
  validateSettings: i
1198
1335
  };
1199
1336
  }
1200
- function ot() {
1201
- const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = Te();
1337
+ function ct() {
1338
+ const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = Se();
1202
1339
  return {
1203
1340
  tenant: r,
1204
1341
  tenantSlug: e,
@@ -1207,380 +1344,392 @@ function ot() {
1207
1344
  retry: i
1208
1345
  };
1209
1346
  }
1210
- const _e = "userTenants";
1211
- function Ot() {
1347
+ const Ve = "userTenants";
1348
+ function jt() {
1212
1349
  try {
1213
- const r = localStorage.getItem(_e);
1350
+ const r = localStorage.getItem(Ve);
1214
1351
  return r ? JSON.parse(r) : [];
1215
1352
  } catch {
1216
1353
  return [];
1217
1354
  }
1218
1355
  }
1219
- function Xe(r) {
1356
+ function nt(r) {
1220
1357
  try {
1221
- localStorage.setItem(_e, JSON.stringify(r));
1358
+ localStorage.setItem(Ve, JSON.stringify(r));
1222
1359
  } catch {
1223
1360
  }
1224
1361
  }
1225
- function et() {
1362
+ function De() {
1226
1363
  try {
1227
- localStorage.removeItem(_e);
1364
+ localStorage.removeItem(Ve);
1228
1365
  } catch {
1229
1366
  }
1230
1367
  }
1231
- const Pe = fe(null), Ie = fe(null);
1232
- function Pr({ config: r = {}, children: e }) {
1233
- const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", a = (t == null ? void 0 : t.appId) ?? r.appId, l = (n == null ? void 0 : n.tenant) ?? null, h = (n == null ? void 0 : n.tenantSlug) ?? null, S = (n == null ? void 0 : n.switchTenant) ?? (() => {
1368
+ const Ie = fe(null), Le = fe(null);
1369
+ function Cr({ config: r = {}, children: e }) {
1370
+ const t = _e(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", o = (t == null ? void 0 : t.appId) ?? r.appId, a = (n == null ? void 0 : n.tenant) ?? null, p = (n == null ? void 0 : n.tenantSlug) ?? null, k = (n == null ? void 0 : n.switchTenant) ?? (() => {
1234
1371
  });
1235
1372
  if (!i)
1236
1373
  throw new Error(
1237
1374
  "[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
1238
1375
  );
1239
- const [k, T] = N(r.initialRoles || []), [c, d] = N(!r.initialRoles), [A, P] = N(null), [I, R] = N(!1), [E, m] = N(null), [g, b] = N(() => Ot()), C = ye({ done: !1 });
1240
- C.current.done || (C.current.done = !0);
1241
- const o = V(() => Me.getInstance({
1376
+ const [E, S] = C(r.initialRoles || []), [c, d] = C(!r.initialRoles), [x, I] = C(null), [L, P] = C(!1), [R, m] = C(null), [g, b] = C(() => jt()), w = O(() => Ue.getInstance({
1242
1377
  baseUrl: i,
1243
1378
  enableCookieSession: r.enableCookieSession,
1244
1379
  refreshQueueTimeout: r.refreshQueueTimeout,
1245
1380
  proactiveRefreshMargin: r.proactiveRefreshMargin,
1246
- onSessionExpired: (w) => {
1247
- P(null), m(null), b([]), et(), r.onSessionExpired ? r.onSessionExpired(w) : r.onRefreshFailed && r.onRefreshFailed();
1381
+ onSessionExpired: (v) => {
1382
+ I(null), m(null), b([]), De(), r.onSessionExpired ? r.onSessionExpired(v) : r.onRefreshFailed && r.onRefreshFailed();
1248
1383
  }
1249
1384
  }), [
1250
1385
  i,
1251
1386
  r.enableCookieSession,
1252
1387
  r.refreshQueueTimeout,
1253
1388
  r.proactiveRefreshMargin
1254
- ]), [p, x] = N(() => {
1255
- const w = o.getTokens();
1256
- return w ? o.hasValidSession() || !!w.refreshToken : !!r.enableCookieSession;
1257
- }), y = C.current.done && !p, u = V(() => {
1258
- const w = new he(i);
1259
- return w.setSessionManager(o), w;
1260
- }, [i, o]), v = V(
1261
- () => new Ct(u),
1389
+ ]), l = Et(
1390
+ (v) => w.subscribe(v),
1391
+ () => w.getSnapshot(),
1392
+ () => 0
1393
+ ), [h, A] = C(!1), y = h, u = O(() => {
1394
+ const v = new he(i);
1395
+ return v.setSessionManager(w), v;
1396
+ }, [i, w]), T = O(
1397
+ () => new Bt(u),
1262
1398
  [u]
1263
- ), D = V(
1264
- () => new Mt(u),
1399
+ ), M = O(
1400
+ () => new Ot(u),
1265
1401
  [u]
1266
- ), se = V(
1267
- () => new Dt(u),
1402
+ ), se = O(
1403
+ () => new _t(u),
1268
1404
  [u]
1269
- ), F = V(() => A != null && A.roleId && k.find((w) => w.id === A.roleId) || null, [A, k]), H = V(() => (F == null ? void 0 : F.permissions) || [], [F]), j = V(
1270
- () => o.hasValidSession() && A !== null,
1271
- [o, A]
1272
- ), K = V(() => (A == null ? void 0 : A.tenantId) != null, [A]), $ = ye(null), B = ye(/* @__PURE__ */ new Set()), L = async (w = !1) => {
1405
+ ), N = O(() => x != null && x.roleId && E.find((v) => v.id === x.roleId) || null, [x, E]), W = O(() => (N == null ? void 0 : N.permissions) || [], [N]), z = O(
1406
+ () => w.hasValidSession() && x !== null,
1407
+ [w, x, l]
1408
+ ), Z = O(() => h ? w.getState() === "expired" ? "expired" : w.getRefreshInFlight() ? "refreshing" : w.hasValidSession() && x !== null ? "authenticated" : "unauthenticated" : "initializing", [w, h, x, l]), K = O(() => (x == null ? void 0 : x.tenantId) != null, [x]), D = be(null), F = be(/* @__PURE__ */ new Set()), _ = async (v = !1) => {
1273
1409
  try {
1274
- if (!o.hasValidSession() || !w && A) return;
1275
- const M = o.getUserId();
1276
- if (!M) {
1410
+ if (!w.hasValidSession() || !v && x) return;
1411
+ const $ = w.getUserId();
1412
+ if (!$) {
1277
1413
  process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
1278
1414
  return;
1279
1415
  }
1280
- R(!0), m(null);
1281
- const z = await D.getUserById(M);
1282
- P(z), o.setUser(z);
1283
- } catch (M) {
1284
- const z = M instanceof Error ? M : new Error("Failed to load user data");
1285
- m(z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", z);
1416
+ P(!0), m(null);
1417
+ const V = await M.getUserById($);
1418
+ I(V), w.setUser(V);
1419
+ } catch ($) {
1420
+ const V = $ instanceof Error ? $ : new Error("Failed to load user data");
1421
+ m(V), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", V);
1286
1422
  } finally {
1287
- R(!1);
1423
+ P(!1);
1288
1424
  }
1289
- }, q = async (w) => {
1290
- var He;
1291
- const { username: M, password: z, tenantSlug: O, redirectPath: J } = w;
1292
- let ee = l == null ? void 0 : l.id, Q = h;
1293
- O && (ee = (await new be(u, a).getPublicTenantInfo(O)).id, Q = O);
1294
- const G = await v.login({
1295
- username: M,
1296
- password: z,
1297
- appId: a,
1425
+ }, B = async (v) => {
1426
+ var Ke;
1427
+ const { username: $, password: V, tenantSlug: q, redirectPath: J } = v;
1428
+ let ee = a == null ? void 0 : a.id, H = p;
1429
+ q && (ee = (await new we(u, o).getPublicTenantInfo(q)).id, H = q);
1430
+ const j = await T.login({
1431
+ username: $,
1432
+ password: V,
1433
+ appId: o,
1298
1434
  tenantId: ee
1299
- }), ke = O && O !== h;
1300
- if (o.setTokens({
1301
- accessToken: G.accessToken,
1302
- refreshToken: G.refreshToken,
1303
- expiresIn: G.expiresIn
1304
- }), G.user) {
1305
- o.setUser(G.user), P(G.user);
1435
+ }), Ee = q && q !== p;
1436
+ if (w.setTokens({
1437
+ accessToken: j.accessToken,
1438
+ refreshToken: j.refreshToken,
1439
+ expiresIn: j.expiresIn
1440
+ }), j.user) {
1441
+ w.setUser(j.user), I(j.user);
1306
1442
  try {
1307
- await L();
1308
- } catch (Ee) {
1309
- process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", Ee);
1443
+ await _();
1444
+ } catch (xe) {
1445
+ process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", xe);
1310
1446
  }
1311
1447
  }
1312
- G.tenants && G.tenants.length > 0 && (b(G.tenants), Xe(G.tenants));
1313
- const Ge = ((He = G.user) == null ? void 0 : He.tenantId) !== null;
1314
- if (ke && Q)
1315
- return S(Q, { redirectPath: J }), G;
1448
+ j.tenants && j.tenants.length > 0 && (b(j.tenants), nt(j.tenants));
1449
+ const Je = ((Ke = j.user) == null ? void 0 : Ke.tenantId) !== null;
1450
+ if (Ee && H)
1451
+ return k(H, { redirectPath: J }), j;
1316
1452
  if (J && J !== window.location.pathname)
1317
- return S(Q || h || "", { redirectPath: J }), G;
1318
- if (!Ge && G.tenants && G.tenants.length > 0) {
1319
- const Ee = w.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1320
- if (G.tenants.length === 1 && Ee) {
1321
- const Qe = G.tenants[0];
1322
- return S(Qe.subdomain, { redirectPath: J }), G;
1323
- } else G.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(G.tenants);
1453
+ return k(H || p || "", { redirectPath: J }), j;
1454
+ if (!Je && j.tenants && j.tenants.length > 0) {
1455
+ const xe = v.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1456
+ if (j.tenants.length === 1 && xe) {
1457
+ const Ze = j.tenants[0];
1458
+ return k(Ze.subdomain, { redirectPath: J }), j;
1459
+ } else j.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(j.tenants);
1324
1460
  }
1325
- return G;
1326
- }, _ = async (w) => {
1327
- const { email: M, phoneNumber: z, name: O, password: J, lastName: ee, tenantId: Q } = w;
1328
- if (!M && !z)
1461
+ return j;
1462
+ }, G = async (v) => {
1463
+ const { email: $, phoneNumber: V, name: q, password: J, lastName: ee, tenantId: H } = v;
1464
+ if (!$ && !V)
1329
1465
  throw new Error("Either email or phoneNumber is required");
1330
- if (!O || !J)
1466
+ if (!q || !J)
1331
1467
  throw new Error("Name and password are required");
1332
- return v.signup({
1333
- email: M,
1334
- phoneNumber: z,
1335
- name: O,
1468
+ return T.signup({
1469
+ email: $,
1470
+ phoneNumber: V,
1471
+ name: q,
1336
1472
  password: J,
1337
- tenantId: Q ?? (l == null ? void 0 : l.id),
1473
+ tenantId: H ?? (a == null ? void 0 : a.id),
1338
1474
  lastName: ee,
1339
- appId: a
1475
+ appId: o
1340
1476
  });
1341
- }, W = async (w) => {
1342
- const { email: M, phoneNumber: z, name: O, password: J, tenantName: ee, lastName: Q } = w;
1343
- if (!M && !z)
1477
+ }, Y = async (v) => {
1478
+ const { email: $, phoneNumber: V, name: q, password: J, tenantName: ee, lastName: H } = v;
1479
+ if (!$ && !V)
1344
1480
  throw new Error("Either email or phoneNumber is required");
1345
- if (!O || !J || !ee)
1481
+ if (!q || !J || !ee)
1346
1482
  throw new Error("Name, password, and tenantName are required");
1347
- return v.signupTenantAdmin({
1348
- email: M,
1349
- phoneNumber: z,
1350
- name: O,
1483
+ return T.signupTenantAdmin({
1484
+ email: $,
1485
+ phoneNumber: V,
1486
+ name: q,
1351
1487
  password: J,
1352
1488
  tenantName: ee,
1353
- appId: a,
1354
- lastName: Q
1489
+ appId: o,
1490
+ lastName: H
1355
1491
  });
1356
- }, Y = async (w) => {
1357
- await v.changePassword(w);
1358
- }, X = async (w) => {
1359
- const { email: M, tenantId: z } = w, O = z ?? (l == null ? void 0 : l.id);
1360
- if (!O)
1492
+ }, X = async (v) => {
1493
+ await T.changePassword(v);
1494
+ }, ae = async (v) => {
1495
+ const { email: $, tenantId: V } = v, q = V ?? (a == null ? void 0 : a.id);
1496
+ if (!q)
1361
1497
  throw new Error("tenantId is required for password reset");
1362
- await v.requestPasswordReset({ email: M, tenantId: O });
1363
- }, le = async (w) => {
1364
- await v.confirmPasswordReset(w);
1365
- }, Se = async (w) => {
1366
- const { email: M, frontendUrl: z, name: O, lastName: J, tenantId: ee } = w, Q = ee ?? (l == null ? void 0 : l.id);
1367
- if (!Q)
1498
+ await T.requestPasswordReset({ email: $, tenantId: q });
1499
+ }, ke = async (v) => {
1500
+ await T.confirmPasswordReset(v);
1501
+ }, He = async (v) => {
1502
+ const { email: $, frontendUrl: V, name: q, lastName: J, tenantId: ee } = v, H = ee ?? (a == null ? void 0 : a.id);
1503
+ if (!H)
1368
1504
  throw new Error("tenantId is required for magic link authentication");
1369
- return v.sendMagicLink({
1370
- email: M,
1371
- tenantId: Q,
1372
- frontendUrl: z,
1373
- name: O,
1505
+ return T.sendMagicLink({
1506
+ email: $,
1507
+ tenantId: H,
1508
+ frontendUrl: V,
1509
+ name: q,
1374
1510
  lastName: J,
1375
- appId: a
1511
+ appId: o
1376
1512
  });
1377
- }, We = async (w) => {
1378
- const { token: M, email: z, tenantSlug: O } = w;
1379
- let J = l == null ? void 0 : l.id, ee = h;
1380
- O && (J = (await new be(u, a).getPublicTenantInfo(O)).id, ee = O);
1381
- const Q = await v.verifyMagicLink({
1382
- token: M,
1383
- email: z,
1384
- appId: a,
1513
+ }, Ne = async (v) => {
1514
+ const { token: $, email: V, tenantSlug: q } = v;
1515
+ let J = a == null ? void 0 : a.id, ee = p;
1516
+ q && (J = (await new we(u, o).getPublicTenantInfo(q)).id, ee = q);
1517
+ const H = await T.verifyMagicLink({
1518
+ token: $,
1519
+ email: V,
1520
+ appId: o,
1385
1521
  tenantId: J
1386
1522
  });
1387
- if (B.current.has(M))
1388
- return Q;
1389
- B.current.add(M);
1390
- const G = O && O !== h;
1391
- if (o.setTokens({
1392
- accessToken: Q.accessToken,
1393
- refreshToken: Q.refreshToken,
1394
- expiresIn: Q.expiresIn
1395
- }), Q.user) {
1396
- o.setUser(Q.user), P(Q.user);
1523
+ if (F.current.has($))
1524
+ return H;
1525
+ F.current.add($);
1526
+ const j = q && q !== p;
1527
+ if (w.setTokens({
1528
+ accessToken: H.accessToken,
1529
+ refreshToken: H.refreshToken,
1530
+ expiresIn: H.expiresIn
1531
+ }), H.user) {
1532
+ w.setUser(H.user), I(H.user);
1397
1533
  try {
1398
- await L();
1399
- } catch (ke) {
1400
- process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:", ke);
1534
+ await _();
1535
+ } catch (Ee) {
1536
+ process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:", Ee);
1401
1537
  }
1402
1538
  }
1403
- return G && ee && ee !== h && S(ee), Q;
1404
- }, Fe = async () => {
1405
- const w = o.getTokens();
1406
- if (!(w != null && w.refreshToken))
1539
+ return j && ee && ee !== p && k(ee), H;
1540
+ }, Ce = async () => {
1541
+ const v = w.getTokens();
1542
+ if (!(v != null && v.refreshToken))
1407
1543
  throw new Error("No refresh token available");
1408
- const M = await v.refreshToken({
1409
- refreshToken: w.refreshToken
1544
+ const $ = await T.refreshToken({
1545
+ refreshToken: v.refreshToken
1410
1546
  });
1411
- o.setTokens({
1412
- accessToken: M.accessToken,
1413
- refreshToken: M.refreshToken || w.refreshToken,
1414
- expiresIn: M.expiresIn
1547
+ w.setTokens({
1548
+ accessToken: $.accessToken,
1549
+ refreshToken: $.refreshToken || v.refreshToken,
1550
+ expiresIn: $.expiresIn
1415
1551
  });
1416
- }, Ne = () => {
1417
- o.clearSession(), P(null), m(null), b([]), et();
1418
- }, ht = (w) => {
1419
- o.setTokens(w);
1420
- }, pt = () => o.hasValidSession(), ft = () => {
1421
- o.clearSession(), P(null), m(null);
1422
- }, mt = async () => {
1423
- if (a)
1552
+ }, mt = () => {
1553
+ w.clearSession("logout"), I(null), m(null), b([]), De();
1554
+ }, gt = (v) => {
1555
+ w.setTokens(v);
1556
+ }, yt = () => w.hasValidSession(), bt = () => {
1557
+ w.clearSession(), I(null), m(null);
1558
+ }, wt = async () => {
1559
+ if (o)
1424
1560
  try {
1425
1561
  d(!0);
1426
- const { roles: w } = await se.getRolesByApp(a);
1427
- T(w);
1428
- } catch (w) {
1429
- process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", w);
1562
+ const { roles: v } = await se.getRolesByApp(o);
1563
+ S(v);
1564
+ } catch (v) {
1565
+ process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", v);
1430
1566
  } finally {
1431
1567
  d(!1);
1432
1568
  }
1433
- }, gt = async (w, M) => {
1434
- const { redirectPath: z } = M || {}, O = o.getTokens();
1435
- if (!(O != null && O.refreshToken))
1569
+ }, vt = async (v, $) => {
1570
+ const { redirectPath: V } = $ || {}, q = w.getTokens();
1571
+ if (!(q != null && q.refreshToken))
1436
1572
  throw new Error("No refresh token available for tenant switch");
1437
- const J = await v.switchTenant({
1438
- refreshToken: O.refreshToken,
1439
- tenantId: w
1573
+ const J = await T.switchTenant({
1574
+ refreshToken: q.refreshToken,
1575
+ tenantId: v
1440
1576
  });
1441
- o.setTokens({
1577
+ w.setTokens({
1442
1578
  accessToken: J.accessToken,
1443
- refreshToken: O.refreshToken,
1579
+ refreshToken: q.refreshToken,
1444
1580
  expiresIn: J.expiresIn
1445
- }), P(J.user), o.setUser(J.user);
1446
- const ee = g.find((Q) => Q.id === w);
1447
- ee && S(ee.subdomain, { redirectPath: z });
1448
- }, yt = async () => {
1449
- const w = await v.getUserTenants();
1450
- return b(w), Xe(w), w;
1581
+ }), I(J.user), w.setUser(J.user);
1582
+ const ee = g.find((H) => H.id === v);
1583
+ ee && k(ee.subdomain, { redirectPath: V });
1584
+ }, Tt = async () => {
1585
+ const v = await T.getUserTenants();
1586
+ return b(v), nt(v), v;
1451
1587
  };
1452
- $.current = {
1453
- login: q,
1454
- signup: _,
1455
- signupTenantAdmin: W,
1456
- sendMagicLink: Se,
1457
- verifyMagicLink: We,
1458
- changePassword: Y,
1459
- requestPasswordReset: X,
1460
- confirmPasswordReset: le,
1461
- refreshToken: Fe,
1462
- logout: Ne,
1463
- setTokens: ht,
1464
- hasValidSession: pt,
1465
- clearSession: ft,
1466
- loadUserData: L,
1467
- refreshUser: () => L(),
1468
- refreshRoles: mt,
1469
- switchToTenant: gt,
1470
- refreshUserTenants: yt
1588
+ D.current = {
1589
+ login: B,
1590
+ signup: G,
1591
+ signupTenantAdmin: Y,
1592
+ sendMagicLink: He,
1593
+ verifyMagicLink: Ne,
1594
+ changePassword: X,
1595
+ requestPasswordReset: ae,
1596
+ confirmPasswordReset: ke,
1597
+ refreshToken: Ce,
1598
+ logout: mt,
1599
+ setTokens: gt,
1600
+ hasValidSession: yt,
1601
+ clearSession: bt,
1602
+ loadUserData: _,
1603
+ refreshUser: () => _(),
1604
+ refreshRoles: wt,
1605
+ switchToTenant: vt,
1606
+ refreshUserTenants: Tt
1471
1607
  };
1472
- const bt = V(
1608
+ const St = O(
1473
1609
  () => ({
1474
- login: (w) => $.current.login(w),
1475
- signup: (w) => $.current.signup(w),
1476
- signupTenantAdmin: (w) => $.current.signupTenantAdmin(w),
1477
- sendMagicLink: (w) => $.current.sendMagicLink(w),
1478
- verifyMagicLink: (w) => $.current.verifyMagicLink(w),
1479
- changePassword: (w) => $.current.changePassword(w),
1480
- requestPasswordReset: (w) => $.current.requestPasswordReset(w),
1481
- confirmPasswordReset: (w) => $.current.confirmPasswordReset(w),
1482
- refreshToken: () => $.current.refreshToken(),
1483
- logout: () => $.current.logout(),
1484
- setTokens: (w) => $.current.setTokens(w),
1485
- hasValidSession: () => $.current.hasValidSession(),
1486
- clearSession: () => $.current.clearSession(),
1487
- loadUserData: (w) => $.current.loadUserData(w),
1488
- refreshUser: () => $.current.refreshUser(),
1489
- refreshRoles: () => $.current.refreshRoles(),
1490
- switchToTenant: (w, M) => $.current.switchToTenant(w, M),
1491
- refreshUserTenants: () => $.current.refreshUserTenants()
1610
+ login: (v) => D.current.login(v),
1611
+ signup: (v) => D.current.signup(v),
1612
+ signupTenantAdmin: (v) => D.current.signupTenantAdmin(v),
1613
+ sendMagicLink: (v) => D.current.sendMagicLink(v),
1614
+ verifyMagicLink: (v) => D.current.verifyMagicLink(v),
1615
+ changePassword: (v) => D.current.changePassword(v),
1616
+ requestPasswordReset: (v) => D.current.requestPasswordReset(v),
1617
+ confirmPasswordReset: (v) => D.current.confirmPasswordReset(v),
1618
+ refreshToken: () => D.current.refreshToken(),
1619
+ logout: () => D.current.logout(),
1620
+ setTokens: (v) => D.current.setTokens(v),
1621
+ hasValidSession: () => D.current.hasValidSession(),
1622
+ clearSession: () => D.current.clearSession(),
1623
+ loadUserData: (v) => D.current.loadUserData(v),
1624
+ refreshUser: () => D.current.refreshUser(),
1625
+ refreshRoles: () => D.current.refreshRoles(),
1626
+ switchToTenant: (v, $) => D.current.switchToTenant(v, $),
1627
+ refreshUserTenants: () => D.current.refreshUserTenants()
1492
1628
  }),
1493
1629
  []
1494
- ), wt = V(() => {
1495
- const w = (M) => !H || H.length === 0 ? !1 : typeof M == "string" ? H.includes(M) : H.includes(`${M.resource}.${M.action}`);
1630
+ ), kt = O(() => {
1631
+ const v = ($) => !W || W.length === 0 ? !1 : typeof $ == "string" ? W.includes($) : W.includes(`${$.resource}.${$.action}`);
1496
1632
  return {
1497
- isAuthenticated: j,
1633
+ isAuthenticated: z,
1498
1634
  isAuthInitializing: !y,
1499
1635
  isAuthReady: y,
1500
- currentUser: A,
1501
- isUserLoading: I,
1502
- userError: E,
1503
- userRole: F,
1504
- userPermissions: H,
1505
- availableRoles: k,
1636
+ sessionStatus: Z,
1637
+ currentUser: x,
1638
+ isUserLoading: L,
1639
+ userError: R,
1640
+ userRole: N,
1641
+ userPermissions: W,
1642
+ availableRoles: E,
1506
1643
  rolesLoading: c,
1507
1644
  userTenants: g,
1508
1645
  hasTenantContext: K,
1509
- sessionManager: o,
1646
+ sessionManager: w,
1510
1647
  authenticatedHttpService: u,
1511
- hasPermission: w,
1512
- hasAnyPermission: (M) => M.some((z) => w(z)),
1513
- hasAllPermissions: (M) => M.every((z) => w(z)),
1514
- getUserPermissionStrings: () => H || []
1648
+ hasPermission: v,
1649
+ hasAnyPermission: ($) => $.some((V) => v(V)),
1650
+ hasAllPermissions: ($) => $.every((V) => v(V)),
1651
+ getUserPermissionStrings: () => W || []
1515
1652
  };
1516
1653
  }, [
1517
- j,
1654
+ z,
1518
1655
  y,
1519
- A,
1520
- I,
1656
+ Z,
1657
+ x,
1658
+ L,
1659
+ R,
1660
+ N,
1661
+ W,
1521
1662
  E,
1522
- F,
1523
- H,
1524
- k,
1525
1663
  c,
1526
1664
  g,
1527
1665
  K,
1528
- o,
1666
+ w,
1529
1667
  u
1530
1668
  ]);
1531
- return re(() => {
1532
- if (r.initialRoles || !a) return;
1533
- let w = !1;
1534
- return d(!0), se.getRolesByApp(a).then(({ roles: M }) => {
1535
- w || T(M);
1536
- }).catch((M) => {
1537
- process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", M);
1669
+ re(() => {
1670
+ if (r.initialRoles || !o) return;
1671
+ let v = !1;
1672
+ return d(!0), se.getRolesByApp(o).then(({ roles: $ }) => {
1673
+ v || S($);
1674
+ }).catch(($) => {
1675
+ process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", $);
1538
1676
  }).finally(() => {
1539
- w || d(!1);
1677
+ v || d(!1);
1540
1678
  }), () => {
1541
- w = !0;
1679
+ v = !0;
1542
1680
  };
1543
- }, [a, r.initialRoles, se]), re(() => {
1544
- let w = !1;
1681
+ }, [o, r.initialRoles, se]);
1682
+ const Qe = be({ completed: !1 });
1683
+ return re(() => {
1684
+ let v = !1;
1545
1685
  return (async () => {
1546
- var O;
1547
- if (!o.hasValidSession() && ((O = o.getTokens()) != null && O.refreshToken) && await o.waitForPendingRefresh(), w || !o.hasValidSession() && !o.getTokens() && r.enableCookieSession && (await o.attemptCookieSessionRestore(), w))
1548
- return;
1549
- const z = o.getUser();
1550
- z && o.hasValidSession() && P(z), x(!1);
1686
+ try {
1687
+ if (Qe.current.completed || !w.getTokens() && r.enableCookieSession && (await w.attemptCookieSessionRestore(), v))
1688
+ return;
1689
+ const $ = await w.ensureValidSession();
1690
+ if (v) return;
1691
+ if ($ === "authenticated") {
1692
+ const V = w.getUser();
1693
+ V && I(V);
1694
+ try {
1695
+ await D.current.loadUserData(!V);
1696
+ } catch {
1697
+ }
1698
+ if (v) return;
1699
+ }
1700
+ } finally {
1701
+ v || (Qe.current.completed = !0, A(!0));
1702
+ }
1551
1703
  })(), () => {
1552
- w = !0;
1704
+ v = !0;
1553
1705
  };
1554
- }, [o, r.enableCookieSession]), re(() => {
1555
- !A && !I && !E && o.hasValidSession() ? $.current.loadUserData().catch(() => {
1556
- }).finally(() => {
1557
- x(!1);
1558
- }) : x(!1);
1559
- }, [A, I, E, o]), /* @__PURE__ */ s(Ie.Provider, { value: bt, children: /* @__PURE__ */ s(Pe.Provider, { value: wt, children: e }) });
1706
+ }, [w, r.enableCookieSession]), re(() => {
1707
+ h && !w.hasValidSession() && x !== null && (I(null), m(null), b([]), De());
1708
+ }, [l, h, x, w]), /* @__PURE__ */ s(Le.Provider, { value: St, children: /* @__PURE__ */ s(Ie.Provider, { value: kt, children: e }) });
1560
1709
  }
1561
- function Ir() {
1562
- const r = ne(Pe);
1710
+ function Dr() {
1711
+ const r = ne(Ie);
1563
1712
  if (!r)
1564
1713
  throw new Error("useAuthState must be used within an AuthProvider");
1565
1714
  return r;
1566
1715
  }
1567
- function Lr() {
1568
- const r = ne(Ie);
1716
+ function Mr() {
1717
+ const r = ne(Le);
1569
1718
  if (!r)
1570
1719
  throw new Error("useAuthActions must be used within an AuthProvider");
1571
1720
  return r;
1572
1721
  }
1573
- function de() {
1574
- const r = ne(Pe), e = ne(Ie);
1722
+ function ue() {
1723
+ const r = ne(Ie), e = ne(Le);
1575
1724
  if (!r || !e)
1576
1725
  throw new Error("useAuth must be used within an AuthProvider");
1577
- return V(() => ({ ...r, ...e }), [r, e]);
1726
+ return O(() => ({ ...r, ...e }), [r, e]);
1578
1727
  }
1579
- function Oe() {
1580
- const r = ne(Pe), e = ne(Ie);
1581
- return V(() => !r || !e ? null : { ...r, ...e }, [r, e]);
1728
+ function qe() {
1729
+ const r = ne(Ie), e = ne(Le);
1730
+ return O(() => !r || !e ? null : { ...r, ...e }, [r, e]);
1582
1731
  }
1583
- class Vt {
1732
+ class Wt {
1584
1733
  constructor(e) {
1585
1734
  this.httpService = e;
1586
1735
  }
@@ -1592,7 +1741,7 @@ class Vt {
1592
1741
  }
1593
1742
  async getFeatureFlags(e) {
1594
1743
  const t = await this.httpService.get(
1595
- `/feature-flags/${ce(e)}`
1744
+ `/feature-flags/${le(e)}`
1596
1745
  );
1597
1746
  return { featureFlags: t.data, meta: t.meta };
1598
1747
  }
@@ -1611,7 +1760,7 @@ class Vt {
1611
1760
  async getTenantFeatureFlags(e, t) {
1612
1761
  if (!e || !t)
1613
1762
  throw new Error("Tenant ID and App ID are required");
1614
- const n = ce({ tenantId: e, appId: t });
1763
+ const n = le({ tenantId: e, appId: t });
1615
1764
  return (await this.httpService.get(
1616
1765
  `/tenant-feature-flags${n}`,
1617
1766
  { headers: { "X-Tenant-ID": e }, skipAuth: !0 }
@@ -1620,73 +1769,73 @@ class Vt {
1620
1769
  async getTenantFeatureFlag(e, t, n) {
1621
1770
  if (!e || !t || !n)
1622
1771
  throw new Error("Flag Key, Tenant ID and App ID are required");
1623
- const i = ce({ tenantId: t, appId: n });
1772
+ const i = le({ tenantId: t, appId: n });
1624
1773
  return (await this.httpService.get(
1625
1774
  `/tenant-feature-flags/${e}${i}`,
1626
1775
  { headers: { "X-Tenant-ID": t }, skipAuth: !0 }
1627
1776
  )).data;
1628
1777
  }
1629
1778
  }
1630
- const Ve = fe(null);
1631
- function Fr({ config: r = {}, children: e }) {
1632
- const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [h, S] = N([]), [k, T] = N(!1), [c, d] = N(null), [A, P] = N(!1), I = V(() => {
1779
+ const ze = fe(null);
1780
+ function $r({ config: r = {}, children: e }) {
1781
+ const t = _e(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, k] = C([]), [E, S] = C(!1), [c, d] = C(null), [x, I] = C(!1), L = O(() => {
1633
1782
  const m = new he(i);
1634
- return new Vt(m);
1635
- }, [i]), R = async () => {
1636
- if (!(l != null && l.id)) {
1637
- S([]);
1783
+ return new Wt(m);
1784
+ }, [i]), P = async () => {
1785
+ if (!(a != null && a.id)) {
1786
+ k([]);
1638
1787
  return;
1639
1788
  }
1640
- T(!0), d(null);
1789
+ S(!0), d(null);
1641
1790
  try {
1642
- const m = await I.getTenantFeatureFlags(l.id, a);
1643
- S(m);
1791
+ const m = await L.getTenantFeatureFlags(a.id, o);
1792
+ k(m);
1644
1793
  } catch (m) {
1645
1794
  const g = m instanceof Error ? m.message : "Failed to fetch feature flags";
1646
1795
  d(g), r.onError && r.onError(m instanceof Error ? m : new Error(g));
1647
1796
  } finally {
1648
- T(!1);
1797
+ S(!1);
1649
1798
  }
1650
1799
  };
1651
1800
  re(() => {
1652
- if (!i || !a) return;
1653
- R().finally(() => P(!0));
1654
- const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(R, m);
1801
+ if (!i || !o) return;
1802
+ P().finally(() => I(!0));
1803
+ const m = r.refreshInterval || 300 * 1e3, g = setInterval(P, m);
1655
1804
  return () => clearInterval(g);
1656
- }, [l == null ? void 0 : l.id, i, a, r.refreshInterval]);
1657
- const E = V(() => {
1658
- const m = (p) => {
1659
- const x = h.find((y) => y.key === p);
1660
- return (x == null ? void 0 : x.value) === !0;
1661
- }, g = (p) => h.find((x) => x.key === p), b = (p) => {
1662
- const x = h.find((y) => y.key === p);
1663
- return x ? x.value ? "enabled" : "disabled" : "not_found";
1664
- }, C = async () => {
1665
- await R();
1666
- }, o = !!(i && a) && (A || !(l != null && l.id));
1805
+ }, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
1806
+ const R = O(() => {
1807
+ const m = (h) => {
1808
+ const A = p.find((y) => y.key === h);
1809
+ return (A == null ? void 0 : A.value) === !0;
1810
+ }, g = (h) => p.find((A) => A.key === h), b = (h) => {
1811
+ const A = p.find((y) => y.key === h);
1812
+ return A ? A.value ? "enabled" : "disabled" : "not_found";
1813
+ }, w = async () => {
1814
+ await P();
1815
+ }, l = !!(i && o) && (x || !(a != null && a.id));
1667
1816
  return {
1668
- featureFlags: h,
1669
- loading: k,
1817
+ featureFlags: p,
1818
+ loading: E,
1670
1819
  error: c,
1671
- isReady: o,
1820
+ isReady: l,
1672
1821
  isEnabled: m,
1673
1822
  getFlag: g,
1674
1823
  getFlagState: b,
1675
- refresh: C
1824
+ refresh: w
1676
1825
  };
1677
- }, [h, k, c, i, a, l == null ? void 0 : l.id, A]);
1678
- return /* @__PURE__ */ s(Ve.Provider, { value: E, children: e });
1826
+ }, [p, E, c, i, o, a == null ? void 0 : a.id, x]);
1827
+ return /* @__PURE__ */ s(ze.Provider, { value: R, children: e });
1679
1828
  }
1680
- function qt() {
1681
- const r = ne(Ve);
1829
+ function Ht() {
1830
+ const r = ne(ze);
1682
1831
  if (!r)
1683
1832
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1684
1833
  return r;
1685
1834
  }
1686
- function at() {
1687
- return ne(Ve);
1835
+ function ut() {
1836
+ return ne(ze);
1688
1837
  }
1689
- class zt {
1838
+ class Qt {
1690
1839
  constructor(e) {
1691
1840
  this.httpService = e;
1692
1841
  }
@@ -1726,68 +1875,68 @@ class zt {
1726
1875
  )).data;
1727
1876
  }
1728
1877
  }
1729
- const qe = fe(void 0);
1730
- function Nr({ config: r = {}, children: e }) {
1731
- const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, h] = N(null), [S, k] = N(!1), [T, c] = N(null), [d, A] = N(!1), P = V(() => {
1732
- const E = new he(i);
1733
- return new zt(E);
1734
- }, [i]), I = async () => {
1735
- if (!(a != null && a.id)) {
1736
- h(null);
1878
+ const Ge = fe(void 0);
1879
+ function Ur({ config: r = {}, children: e }) {
1880
+ const t = _e(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = C(null), [k, E] = C(!1), [S, c] = C(null), [d, x] = C(!1), I = O(() => {
1881
+ const R = new he(i);
1882
+ return new Qt(R);
1883
+ }, [i]), L = async () => {
1884
+ if (!(o != null && o.id)) {
1885
+ p(null);
1737
1886
  return;
1738
1887
  }
1739
- k(!0), c(null);
1888
+ E(!0), c(null);
1740
1889
  try {
1741
- const E = await P.getTenantSubscriptionFeatures(a.id);
1742
- h(E);
1743
- } catch (E) {
1744
- const m = E instanceof Error ? E.message : "Failed to fetch subscription";
1745
- c(m), r.onError && r.onError(E instanceof Error ? E : new Error(m));
1890
+ const R = await I.getTenantSubscriptionFeatures(o.id);
1891
+ p(R);
1892
+ } catch (R) {
1893
+ const m = R instanceof Error ? R.message : "Failed to fetch subscription";
1894
+ c(m), r.onError && r.onError(R instanceof Error ? R : new Error(m));
1746
1895
  } finally {
1747
- k(!1);
1896
+ E(!1);
1748
1897
  }
1749
1898
  };
1750
1899
  re(() => {
1751
- if (!i || (I().finally(() => A(!0)), !r.refreshInterval)) return;
1752
- const E = r.refreshInterval || 10 * 60 * 1e3, m = setInterval(I, E);
1900
+ if (!i || (L().finally(() => x(!0)), !r.refreshInterval)) return;
1901
+ const R = r.refreshInterval || 600 * 1e3, m = setInterval(L, R);
1753
1902
  return () => clearInterval(m);
1754
- }, [a == null ? void 0 : a.id, i, r.refreshInterval]);
1755
- const R = V(() => {
1756
- const E = (l == null ? void 0 : l.features) || [], m = (x) => {
1757
- const y = E.find((u) => u.key === x);
1903
+ }, [o == null ? void 0 : o.id, i, r.refreshInterval]);
1904
+ const P = O(() => {
1905
+ const R = (a == null ? void 0 : a.features) || [], m = (A) => {
1906
+ const y = R.find((u) => u.key === A);
1758
1907
  return y ? y.type === "BOOLEAN" || y.type === "boolean" ? y.value === !0 : !!y.value : !1;
1759
- }, g = (x) => E.find((y) => y.key === x), b = (x, y) => {
1760
- const u = E.find((v) => v.key === x);
1908
+ }, g = (A) => R.find((y) => y.key === A), b = (A, y) => {
1909
+ const u = R.find((T) => T.key === A);
1761
1910
  return u ? u.value : y;
1762
- }, C = (x) => !l || !l.isActive ? !1 : x.includes(l.planId), o = async () => {
1763
- await I();
1764
- }, p = !!i && (d || !(a != null && a.id));
1911
+ }, w = (A) => !a || !a.isActive ? !1 : A.includes(a.planId), l = async () => {
1912
+ await L();
1913
+ }, h = !!i && (d || !(o != null && o.id));
1765
1914
  return {
1766
- subscription: l,
1767
- features: E,
1768
- loading: S,
1769
- error: T,
1770
- isReady: p,
1915
+ subscription: a,
1916
+ features: R,
1917
+ loading: k,
1918
+ error: S,
1919
+ isReady: h,
1771
1920
  isFeatureEnabled: m,
1772
1921
  getFeature: g,
1773
1922
  getFeatureValue: b,
1774
- hasAllowedPlan: C,
1775
- refresh: o
1923
+ hasAllowedPlan: w,
1924
+ refresh: l
1776
1925
  };
1777
- }, [l, S, T, i, a == null ? void 0 : a.id, d]);
1778
- return /* @__PURE__ */ s(qe.Provider, { value: R, children: e });
1926
+ }, [a, k, S, i, o == null ? void 0 : o.id, d]);
1927
+ return /* @__PURE__ */ s(Ge.Provider, { value: P, children: e });
1779
1928
  }
1780
- function jt() {
1781
- const r = ne(qe);
1929
+ function Jt() {
1930
+ const r = ne(Ge);
1782
1931
  if (r === void 0)
1783
1932
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1784
1933
  return r;
1785
1934
  }
1786
- function lt() {
1787
- return ne(qe) ?? null;
1935
+ function dt() {
1936
+ return ne(Ge) ?? null;
1788
1937
  }
1789
- var ae = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(ae || {});
1790
- const ze = {
1938
+ var oe = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(oe || {});
1939
+ const je = {
1791
1940
  publicGuest: "/",
1792
1941
  publicUser: "/account",
1793
1942
  publicAdmin: "/admin",
@@ -1795,7 +1944,7 @@ const ze = {
1795
1944
  tenantUser: "/dashboard",
1796
1945
  tenantAdmin: "/admin/dashboard",
1797
1946
  default: "/"
1798
- }, ct = {
1947
+ }, ht = {
1799
1948
  // Public/Landing zones
1800
1949
  landing: { tenant: "forbidden", auth: "optional" },
1801
1950
  publicOnly: { tenant: "forbidden", auth: "forbidden" },
@@ -1808,26 +1957,26 @@ const ze = {
1808
1957
  tenantOpen: { tenant: "required", auth: "optional" },
1809
1958
  tenantAuth: { tenant: "required", auth: "required" },
1810
1959
  // User type zones
1811
- user: { tenant: "required", auth: "required", userType: ae.USER },
1812
- admin: { tenant: "required", auth: "required", userType: ae.TENANT_ADMIN },
1960
+ user: { tenant: "required", auth: "required", userType: oe.USER },
1961
+ admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
1813
1962
  // Fully open
1814
1963
  open: { tenant: "optional", auth: "optional" }
1815
- }, je = fe(null), Wt = {
1816
- zoneRoots: ze,
1817
- presets: ct,
1964
+ }, We = fe(null), Kt = {
1965
+ zoneRoots: je,
1966
+ presets: ht,
1818
1967
  loadingFallback: null,
1819
1968
  accessDeniedFallback: null,
1820
1969
  onAccessDenied: void 0,
1821
1970
  returnToParam: "returnTo",
1822
1971
  returnToStorage: "url"
1823
1972
  };
1824
- function Cr({ config: r = {}, children: e }) {
1825
- const t = V(() => {
1973
+ function Br({ config: r = {}, children: e }) {
1974
+ const t = O(() => {
1826
1975
  const n = {
1827
- ...ze,
1976
+ ...je,
1828
1977
  ...r.zoneRoots
1829
1978
  }, i = {
1830
- ...ct,
1979
+ ...ht,
1831
1980
  ...r.presets
1832
1981
  };
1833
1982
  return {
@@ -1840,18 +1989,18 @@ function Cr({ config: r = {}, children: e }) {
1840
1989
  returnToStorage: r.returnToStorage ?? "url"
1841
1990
  };
1842
1991
  }, [r]);
1843
- return /* @__PURE__ */ s(je.Provider, { value: t, children: e });
1992
+ return /* @__PURE__ */ s(We.Provider, { value: t, children: e });
1844
1993
  }
1845
- function Dr() {
1846
- const r = ne(je);
1994
+ function _r() {
1995
+ const r = ne(We);
1847
1996
  if (!r)
1848
1997
  throw new Error("useRouting must be used within a RoutingProvider");
1849
1998
  return r;
1850
1999
  }
1851
- function Gt() {
1852
- return ne(je) ?? Wt;
2000
+ function Zt() {
2001
+ return ne(We) ?? Kt;
1853
2002
  }
1854
- const tt = () => /* @__PURE__ */ f(
2003
+ const st = () => /* @__PURE__ */ f(
1855
2004
  "div",
1856
2005
  {
1857
2006
  style: {
@@ -1888,7 +2037,7 @@ const tt = () => /* @__PURE__ */ f(
1888
2037
  )
1889
2038
  ]
1890
2039
  }
1891
- ), rt = ({
2040
+ ), it = ({
1892
2041
  userType: r,
1893
2042
  minUserType: e,
1894
2043
  missingPermissions: t
@@ -1929,36 +2078,36 @@ const tt = () => /* @__PURE__ */ f(
1929
2078
  ] })
1930
2079
  ]
1931
2080
  }
1932
- ), Ht = (r, e) => {
2081
+ ), Yt = (r, e) => {
1933
2082
  const t = {
1934
- [ae.USER]: 1,
1935
- [ae.TENANT_ADMIN]: 2,
1936
- [ae.SUPERUSER]: 3
2083
+ [oe.USER]: 1,
2084
+ [oe.TENANT_ADMIN]: 2,
2085
+ [oe.SUPERUSER]: 3
1937
2086
  };
1938
2087
  return t[r] >= t[e];
1939
2088
  };
1940
- function Mr({
2089
+ function Or({
1941
2090
  children: r,
1942
2091
  fallback: e,
1943
2092
  minUserType: t,
1944
2093
  requiredPermissions: n,
1945
2094
  requireAllPermissions: i = !1
1946
2095
  }) {
1947
- const { hasValidSession: a, sessionManager: l, hasPermission: h, hasAnyPermission: S, hasAllPermissions: k } = de();
1948
- if (!a())
1949
- return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(tt, {}) });
1950
- const T = l.getUser();
1951
- if (!T)
1952
- return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(tt, {}) });
1953
- if (t && !Ht(T.userType, t))
1954
- return /* @__PURE__ */ s(rt, { userType: T.userType, minUserType: t });
1955
- if (n && n.length > 0 && !(i ? k(n) : S(n))) {
1956
- const d = n.filter((A) => !h(A)).map((A) => typeof A == "string" ? A : A.name);
1957
- return /* @__PURE__ */ s(rt, { missingPermissions: d });
2096
+ const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: k, hasAllPermissions: E } = ue();
2097
+ if (!o())
2098
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(st, {}) });
2099
+ const S = a.getUser();
2100
+ if (!S)
2101
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(st, {}) });
2102
+ if (t && !Yt(S.userType, t))
2103
+ return /* @__PURE__ */ s(it, { userType: S.userType, minUserType: t });
2104
+ if (n && n.length > 0 && !(i ? E(n) : k(n))) {
2105
+ const d = n.filter((x) => !p(x)).map((x) => typeof x == "string" ? x : x.name);
2106
+ return /* @__PURE__ */ s(it, { missingPermissions: d });
1958
2107
  }
1959
2108
  return /* @__PURE__ */ s(U, { children: r });
1960
2109
  }
1961
- const Qt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2110
+ const Xt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1962
2111
  "div",
1963
2112
  {
1964
2113
  style: {
@@ -1994,7 +2143,7 @@ const Qt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1994
2143
  }
1995
2144
  )
1996
2145
  }
1997
- ), nt = ({
2146
+ ), ot = ({
1998
2147
  userType: r,
1999
2148
  requiredUserType: e,
2000
2149
  missingPermissions: t
@@ -2045,43 +2194,43 @@ const Qt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2045
2194
  }
2046
2195
  )
2047
2196
  }
2048
- ), Jt = (r, e) => r === e;
2049
- function $r({
2197
+ ), er = (r, e) => r === e;
2198
+ function Vr({
2050
2199
  children: r,
2051
2200
  redirectTo: e = "/login",
2052
2201
  requiredUserType: t,
2053
2202
  requiredPermissions: n,
2054
2203
  requireAllPermissions: i = !1,
2055
- fallback: a
2204
+ fallback: o
2056
2205
  }) {
2057
- const { hasValidSession: l, sessionManager: h, hasPermission: S, hasAnyPermission: k, hasAllPermissions: T } = de(), c = xe();
2206
+ const { hasValidSession: a, sessionManager: p, hasPermission: k, hasAnyPermission: E, hasAllPermissions: S } = ue(), c = Re();
2058
2207
  if (re(() => {
2059
2208
  process.env.NODE_ENV === "development" && console.warn(
2060
2209
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
2061
2210
  );
2062
- }, []), !l())
2063
- return a ? /* @__PURE__ */ s(U, { children: a }) : /* @__PURE__ */ f(U, { children: [
2064
- /* @__PURE__ */ s(Qt, { redirectPath: e }),
2065
- /* @__PURE__ */ s(we, { to: e, state: { from: c.pathname }, replace: !0 })
2211
+ }, []), !a())
2212
+ return o ? /* @__PURE__ */ s(U, { children: o }) : /* @__PURE__ */ f(U, { children: [
2213
+ /* @__PURE__ */ s(Xt, { redirectPath: e }),
2214
+ /* @__PURE__ */ s(ve, { to: e, state: { from: c.pathname }, replace: !0 })
2066
2215
  ] });
2067
- const d = h.getUser();
2216
+ const d = p.getUser();
2068
2217
  if (!d)
2069
- return /* @__PURE__ */ s(we, { to: e, state: { from: c.pathname }, replace: !0 });
2070
- if (t && !Jt(d.userType, t))
2218
+ return /* @__PURE__ */ s(ve, { to: e, state: { from: c.pathname }, replace: !0 });
2219
+ if (t && !er(d.userType, t))
2071
2220
  return /* @__PURE__ */ s(
2072
- nt,
2221
+ ot,
2073
2222
  {
2074
2223
  userType: d.userType,
2075
2224
  requiredUserType: t
2076
2225
  }
2077
2226
  );
2078
- if (n && n.length > 0 && !(i ? T(n) : k(n))) {
2079
- const P = n.filter((I) => !S(I)).map((I) => typeof I == "string" ? I : I.name);
2080
- return /* @__PURE__ */ s(nt, { missingPermissions: P });
2227
+ if (n && n.length > 0 && !(i ? S(n) : E(n))) {
2228
+ const I = n.filter((L) => !k(L)).map((L) => typeof L == "string" ? L : L.name);
2229
+ return /* @__PURE__ */ s(ot, { missingPermissions: I });
2081
2230
  }
2082
2231
  return /* @__PURE__ */ s(U, { children: r });
2083
2232
  }
2084
- const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2233
+ const tr = ({ redirectPath: r }) => /* @__PURE__ */ s(
2085
2234
  "div",
2086
2235
  {
2087
2236
  style: {
@@ -2118,18 +2267,18 @@ const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2118
2267
  )
2119
2268
  }
2120
2269
  );
2121
- function Ur({ children: r, redirectTo: e = "/", fallback: t }) {
2122
- const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
2270
+ function qr({ children: r, redirectTo: e = "/", fallback: t }) {
2271
+ const { tenant: n, isLoading: i, error: o } = ct(), a = Re();
2123
2272
  return re(() => {
2124
2273
  process.env.NODE_ENV === "development" && console.warn(
2125
2274
  "[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
2126
2275
  );
2127
- }, []), i || a ? null : n ? /* @__PURE__ */ s(U, { children: r }) : t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2128
- /* @__PURE__ */ s(Zt, { redirectPath: e }),
2129
- /* @__PURE__ */ s(we, { to: e, state: { from: l.pathname }, replace: !0 })
2276
+ }, []), i || o ? null : n ? /* @__PURE__ */ s(U, { children: r }) : t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2277
+ /* @__PURE__ */ s(tr, { redirectPath: e }),
2278
+ /* @__PURE__ */ s(ve, { to: e, state: { from: a.pathname }, replace: !0 })
2130
2279
  ] });
2131
2280
  }
2132
- const Kt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2281
+ const rr = ({ redirectPath: r }) => /* @__PURE__ */ s(
2133
2282
  "div",
2134
2283
  {
2135
2284
  style: {
@@ -2166,125 +2315,125 @@ const Kt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2166
2315
  )
2167
2316
  }
2168
2317
  );
2169
- function Br({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
2170
- const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
2318
+ function zr({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
2319
+ const { tenant: n, isLoading: i, error: o } = ct(), a = Re();
2171
2320
  return re(() => {
2172
2321
  process.env.NODE_ENV === "development" && console.warn(
2173
2322
  "[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
2174
2323
  );
2175
- }, []), i || a ? null : n ? t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2176
- /* @__PURE__ */ s(Kt, { redirectPath: e }),
2177
- /* @__PURE__ */ s(we, { to: e, state: { from: l.pathname }, replace: !0 })
2324
+ }, []), i || o ? null : n ? t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2325
+ /* @__PURE__ */ s(rr, { redirectPath: e }),
2326
+ /* @__PURE__ */ s(ve, { to: e, state: { from: a.pathname }, replace: !0 })
2178
2327
  ] }) : /* @__PURE__ */ s(U, { children: r });
2179
2328
  }
2180
- function Yt(r, e) {
2329
+ function nr(r, e) {
2181
2330
  return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
2182
2331
  }
2183
- function st(r, e) {
2332
+ function at(r, e) {
2184
2333
  return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
2185
2334
  }
2186
- function Xt(r, e) {
2187
- return st(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : st(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Yt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (a) => a.every((l) => e.permissions.includes(l)) : (a) => a.some((l) => e.permissions.includes(l)))(r.permissions) ? "missing_permissions" : null;
2335
+ function sr(r, e) {
2336
+ return at(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : at(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !nr(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
2188
2337
  }
2189
- function er(r, e) {
2190
- return r.hasTenant ? r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
2338
+ function ir(r, e) {
2339
+ return r.hasTenant ? r.isAuthenticated ? r.userType === oe.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === oe.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
2191
2340
  }
2192
- function tr(r, e, t, n, i) {
2341
+ function or(r, e, t, n, i) {
2193
2342
  if (!e || i !== "url")
2194
2343
  return r;
2195
- const a = typeof e == "string" ? e : t, l = r.includes("?") ? "&" : "?";
2196
- return `${r}${l}${n}=${encodeURIComponent(a)}`;
2344
+ const o = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
2345
+ return `${r}${a}${n}=${encodeURIComponent(o)}`;
2197
2346
  }
2198
- function rr(r, e, t) {
2347
+ function ar(r, e, t) {
2199
2348
  if (!r || t === "url") return;
2200
2349
  const n = typeof r == "string" ? r : e, i = "zone_return_to";
2201
2350
  t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
2202
2351
  }
2203
- const ue = ({
2352
+ const ce = ({
2204
2353
  children: r,
2205
2354
  preset: e,
2206
2355
  tenant: t,
2207
2356
  auth: n,
2208
2357
  userType: i,
2209
- requiredPermissions: a,
2210
- requireAllPermissions: l = !0,
2211
- returnTo: h,
2212
- onAccessDenied: S,
2213
- redirectTo: k,
2214
- loadingFallback: T,
2358
+ requiredPermissions: o,
2359
+ requireAllPermissions: a = !0,
2360
+ returnTo: p,
2361
+ onAccessDenied: k,
2362
+ redirectTo: E,
2363
+ loadingFallback: S,
2215
2364
  accessDeniedFallback: c
2216
2365
  }) => {
2217
- const d = xe(), { isAuthenticated: A, isAuthInitializing: P, currentUser: I, userPermissions: R } = de(), { tenant: E, isTenantLoading: m } = Te(), g = Gt(), b = V(() => {
2366
+ const d = Re(), { isAuthenticated: x, isAuthInitializing: I, currentUser: L, userPermissions: P } = ue(), { tenant: R, isTenantLoading: m } = Se(), g = Zt(), b = O(() => {
2218
2367
  if (e)
2219
2368
  return g.presets[e];
2220
- }, [e, g.presets]), C = V(
2369
+ }, [e, g.presets]), w = O(
2221
2370
  () => ({
2222
2371
  tenant: t ?? (b == null ? void 0 : b.tenant),
2223
2372
  auth: n ?? (b == null ? void 0 : b.auth),
2224
2373
  userType: i ?? (b == null ? void 0 : b.userType),
2225
- permissions: a ?? (b == null ? void 0 : b.requiredPermissions),
2226
- requireAllPermissions: l
2374
+ permissions: o ?? (b == null ? void 0 : b.requiredPermissions),
2375
+ requireAllPermissions: a
2227
2376
  }),
2228
- [t, n, i, a, b, l]
2229
- ), o = V(
2377
+ [t, n, i, o, b, a]
2378
+ ), l = O(
2230
2379
  () => ({
2231
- hasTenant: !!E,
2232
- isAuthenticated: A,
2233
- userType: I == null ? void 0 : I.userType,
2234
- permissions: R,
2235
- isLoading: P || m
2380
+ hasTenant: !!R,
2381
+ isAuthenticated: x,
2382
+ userType: L == null ? void 0 : L.userType,
2383
+ permissions: P,
2384
+ isLoading: I || m
2236
2385
  }),
2237
2386
  [
2238
- E,
2239
- A,
2240
- I == null ? void 0 : I.userType,
2241
2387
  R,
2388
+ x,
2389
+ L == null ? void 0 : L.userType,
2242
2390
  P,
2391
+ I,
2243
2392
  m
2244
2393
  ]
2245
- ), p = V(() => o.isLoading ? null : Xt(C, o), [C, o]), x = V(() => p ? k || er(o, g.zoneRoots) : null, [p, k, o, g.zoneRoots]), y = V(() => !p || !x ? null : {
2246
- type: p,
2394
+ ), h = O(() => l.isLoading ? null : sr(w, l), [w, l]), A = O(() => h ? E || ir(l, g.zoneRoots) : null, [h, E, l, g.zoneRoots]), y = O(() => !h || !A ? null : {
2395
+ type: h,
2247
2396
  required: {
2248
- tenant: C.tenant,
2249
- auth: C.auth,
2250
- userType: C.userType,
2251
- permissions: C.permissions
2397
+ tenant: w.tenant,
2398
+ auth: w.auth,
2399
+ userType: w.userType,
2400
+ permissions: w.permissions
2252
2401
  },
2253
2402
  current: {
2254
- hasTenant: o.hasTenant,
2255
- isAuthenticated: o.isAuthenticated,
2256
- userType: o.userType,
2257
- permissions: o.permissions
2403
+ hasTenant: l.hasTenant,
2404
+ isAuthenticated: l.isAuthenticated,
2405
+ userType: l.userType,
2406
+ permissions: l.permissions
2258
2407
  },
2259
- redirectTo: x
2260
- }, [p, x, C, o]);
2408
+ redirectTo: A
2409
+ }, [h, A, w, l]);
2261
2410
  if (re(() => {
2262
- y && (S ? S(y) : g.onAccessDenied && g.onAccessDenied(y));
2263
- }, [y, S, g]), re(() => {
2264
- y && h && rr(h, d.pathname + d.search, g.returnToStorage);
2411
+ y && (k ? k(y) : g.onAccessDenied && g.onAccessDenied(y));
2412
+ }, [y, k, g]), re(() => {
2413
+ y && p && ar(p, d.pathname + d.search, g.returnToStorage);
2265
2414
  }, [
2266
2415
  y,
2267
- h,
2416
+ p,
2268
2417
  d.pathname,
2269
2418
  d.search,
2270
2419
  g.returnToStorage
2271
- ]), o.isLoading)
2272
- return /* @__PURE__ */ s(U, { children: T ?? g.loadingFallback ?? null });
2273
- if (y && x) {
2420
+ ]), l.isLoading)
2421
+ return /* @__PURE__ */ s(U, { children: S ?? g.loadingFallback ?? null });
2422
+ if (y && A) {
2274
2423
  const u = c ?? g.accessDeniedFallback;
2275
2424
  if (u)
2276
2425
  return /* @__PURE__ */ s(U, { children: u });
2277
- const v = tr(
2278
- x,
2279
- h,
2426
+ const T = or(
2427
+ A,
2428
+ p,
2280
2429
  d.pathname + d.search,
2281
2430
  g.returnToParam,
2282
2431
  g.returnToStorage
2283
2432
  );
2284
- return /* @__PURE__ */ s(we, { to: v, replace: !0 });
2433
+ return /* @__PURE__ */ s(ve, { to: T, replace: !0 });
2285
2434
  }
2286
2435
  return /* @__PURE__ */ s(U, { children: r });
2287
- }, _r = (r) => /* @__PURE__ */ s(ue, { tenant: "required", ...r }), Or = (r) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...r }), Vr = (r) => /* @__PURE__ */ s(ue, { auth: "required", ...r }), qr = (r) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...r }), zr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...r }), jr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...r }), Wr = (r) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...r }), Gr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...r }), Hr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...r }), Qr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...r }), nr = () => /* @__PURE__ */ f(
2436
+ }, Gr = (r) => /* @__PURE__ */ s(ce, { tenant: "required", ...r }), jr = (r) => /* @__PURE__ */ s(ce, { tenant: "forbidden", ...r }), Wr = (r) => /* @__PURE__ */ s(ce, { auth: "required", ...r }), Hr = (r) => /* @__PURE__ */ s(ce, { auth: "forbidden", ...r }), Qr = (r) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.TENANT_ADMIN, ...r }), Jr = (r) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.USER, ...r }), Kr = (r) => /* @__PURE__ */ s(ce, { tenant: "optional", auth: "optional", ...r }), Zr = (r) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "required", ...r }), Yr = (r) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "optional", ...r }), Xr = (r) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "forbidden", ...r }), lr = () => /* @__PURE__ */ f(
2288
2437
  "div",
2289
2438
  {
2290
2439
  style: {
@@ -2301,14 +2450,14 @@ const ue = ({
2301
2450
  ]
2302
2451
  }
2303
2452
  );
2304
- function Jr({
2453
+ function en({
2305
2454
  children: r,
2306
- fallback: e = /* @__PURE__ */ s(nr, {}),
2455
+ fallback: e = /* @__PURE__ */ s(lr, {}),
2307
2456
  allowedPlans: t,
2308
2457
  requiredFeature: n
2309
2458
  }) {
2310
- const { subscription: i, hasAllowedPlan: a, isFeatureEnabled: l, loading: h } = jt();
2311
- return h ? /* @__PURE__ */ s(
2459
+ const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = Jt();
2460
+ return p ? /* @__PURE__ */ s(
2312
2461
  "div",
2313
2462
  {
2314
2463
  style: {
@@ -2318,9 +2467,9 @@ function Jr({
2318
2467
  },
2319
2468
  children: "Loading subscription..."
2320
2469
  }
2321
- ) : i ? i.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ s(U, { children: e }) : n && !l(n) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: r }) : /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: e });
2470
+ ) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(U, { children: e }) : n && !a(n) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: r }) : /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: e });
2322
2471
  }
2323
- const sr = ({ flagName: r }) => /* @__PURE__ */ f(
2472
+ const cr = ({ flagName: r }) => /* @__PURE__ */ f(
2324
2473
  "div",
2325
2474
  {
2326
2475
  style: {
@@ -2347,8 +2496,8 @@ const sr = ({ flagName: r }) => /* @__PURE__ */ f(
2347
2496
  ]
2348
2497
  }
2349
2498
  );
2350
- function Zr({ name: r, children: e, fallback: t }) {
2351
- const { isEnabled: n, loading: i } = qt();
2499
+ function tn({ name: r, children: e, fallback: t }) {
2500
+ const { isEnabled: n, loading: i } = Ht();
2352
2501
  return i ? /* @__PURE__ */ s(
2353
2502
  "div",
2354
2503
  {
@@ -2362,49 +2511,49 @@ function Zr({ name: r, children: e, fallback: t }) {
2362
2511
  },
2363
2512
  children: "Loading feature flags..."
2364
2513
  }
2365
- ) : n(r) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: t || /* @__PURE__ */ s(sr, { flagName: r }) });
2366
- }
2367
- function ve(r) {
2368
- const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, h] = N(!1), [S, k] = N(""), [T, c] = N({}), d = te((R, E) => {
2369
- c((m) => ({ ...m, [R]: E }));
2370
- }, []), A = te((R) => {
2371
- c((E) => {
2372
- if (!E[R]) return E;
2373
- const m = { ...E };
2374
- return delete m[R], m;
2514
+ ) : n(r) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: t || /* @__PURE__ */ s(cr, { flagName: r }) });
2515
+ }
2516
+ function Te(r) {
2517
+ const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: o } = r, [a, p] = C(!1), [k, E] = C(""), [S, c] = C({}), d = te((P, R) => {
2518
+ c((m) => ({ ...m, [P]: R }));
2519
+ }, []), x = te((P) => {
2520
+ c((R) => {
2521
+ if (!R[P]) return R;
2522
+ const m = { ...R };
2523
+ return delete m[P], m;
2375
2524
  });
2376
- }, []), P = te(() => {
2377
- k(""), c({});
2378
- }, []), I = te(
2379
- async (R) => {
2380
- if (R && R.preventDefault(), !(n && !n())) {
2381
- h(!0), k("");
2525
+ }, []), I = te(() => {
2526
+ E(""), c({});
2527
+ }, []), L = te(
2528
+ async (P) => {
2529
+ if (P && P.preventDefault(), !(n && !n())) {
2530
+ p(!0), E("");
2382
2531
  try {
2383
- const E = await e();
2384
- return i == null || i(E), E;
2385
- } catch (E) {
2386
- const m = E instanceof Error ? E.message : t;
2387
- k(m), a == null || a(m);
2532
+ const R = await e();
2533
+ return i == null || i(R), R;
2534
+ } catch (R) {
2535
+ const m = R instanceof Error ? R.message : t;
2536
+ E(m), o == null || o(m);
2388
2537
  return;
2389
2538
  } finally {
2390
- h(!1);
2539
+ p(!1);
2391
2540
  }
2392
2541
  }
2393
2542
  },
2394
- [e, n, t, i, a]
2543
+ [e, n, t, i, o]
2395
2544
  );
2396
2545
  return {
2397
- loading: l,
2398
- error: S,
2399
- setError: k,
2400
- fieldErrors: T,
2546
+ loading: a,
2547
+ error: k,
2548
+ setError: E,
2549
+ fieldErrors: S,
2401
2550
  setFieldError: d,
2402
- clearFieldError: A,
2403
- resetErrors: P,
2404
- handleSubmit: I
2551
+ clearFieldError: x,
2552
+ resetErrors: I,
2553
+ handleSubmit: L
2405
2554
  };
2406
2555
  }
2407
- const it = {
2556
+ const lt = {
2408
2557
  container: {
2409
2558
  maxWidth: "400px",
2410
2559
  width: "100%",
@@ -2568,18 +2717,18 @@ const it = {
2568
2717
  color: "#6b7280"
2569
2718
  }
2570
2719
  };
2571
- function Le(r, e) {
2720
+ function Fe(r, e) {
2572
2721
  return {
2573
- ...it,
2722
+ ...lt,
2574
2723
  ...e,
2575
2724
  button: {
2576
- ...it.button,
2725
+ ...lt.button,
2577
2726
  backgroundColor: r,
2578
2727
  ...(e == null ? void 0 : e.button) || {}
2579
2728
  }
2580
2729
  };
2581
2730
  }
2582
- const ir = () => me.createElement(
2731
+ const ur = () => me.createElement(
2583
2732
  "svg",
2584
2733
  {
2585
2734
  width: "16",
@@ -2594,7 +2743,7 @@ const ir = () => me.createElement(
2594
2743
  },
2595
2744
  me.createElement("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
2596
2745
  me.createElement("circle", { cx: "12", cy: "12", r: "3" })
2597
- ), or = () => me.createElement(
2746
+ ), dr = () => me.createElement(
2598
2747
  "svg",
2599
2748
  {
2600
2749
  width: "16",
@@ -2611,10 +2760,10 @@ const ir = () => me.createElement(
2611
2760
  d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"
2612
2761
  }),
2613
2762
  me.createElement("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
2614
- ), ar = {
2615
- showPassword: /* @__PURE__ */ s(ir, {}),
2616
- hidePassword: /* @__PURE__ */ s(or, {})
2617
- }, lr = {
2763
+ ), hr = {
2764
+ showPassword: /* @__PURE__ */ s(ur, {}),
2765
+ hidePassword: /* @__PURE__ */ s(dr, {})
2766
+ }, pr = {
2618
2767
  title: "Sign In",
2619
2768
  usernameLabel: "Email or Phone",
2620
2769
  usernamePlaceholder: "Enter your email or phone number",
@@ -2633,40 +2782,40 @@ const ir = () => me.createElement(
2633
2782
  showPasswordAriaLabel: "Show password",
2634
2783
  hidePasswordAriaLabel: "Hide password"
2635
2784
  };
2636
- function Kr({
2785
+ function rn({
2637
2786
  copy: r = {},
2638
2787
  styles: e = {},
2639
2788
  icons: t = {},
2640
2789
  onSuccess: n,
2641
2790
  onError: i,
2642
- onForgotPassword: a,
2643
- onSignupClick: l,
2644
- onMagicLinkClick: h,
2645
- showForgotPassword: S = !0,
2646
- showSignupLink: k = !0,
2647
- showMagicLinkOption: T = !0,
2791
+ onForgotPassword: o,
2792
+ onSignupClick: a,
2793
+ onMagicLinkClick: p,
2794
+ showForgotPassword: k = !0,
2795
+ showSignupLink: E = !0,
2796
+ showMagicLinkOption: S = !0,
2648
2797
  className: c
2649
2798
  }) {
2650
- const [d, A] = N(""), [P, I] = N(""), [R, E] = N(!1), { login: m } = de(), g = { ...lr, ...r }, b = Le("#3b82f6", e), C = { ...ar, ...t }, o = ve({
2799
+ const [d, x] = C(""), [I, L] = C(""), [P, R] = C(!1), { login: m } = ue(), g = { ...pr, ...r }, b = Fe("#3b82f6", e), w = { ...hr, ...t }, l = Te({
2651
2800
  defaultErrorMessage: g.errorMessage,
2652
2801
  validate: () => {
2653
2802
  const u = [];
2654
- return d.trim() || u.push("username"), P.trim() || u.push("password"), u.forEach((v) => o.setFieldError(v, !0)), u.length === 0;
2803
+ return d.trim() || u.push("username"), I.trim() || u.push("password"), u.forEach((T) => l.setFieldError(T, !0)), u.length === 0;
2655
2804
  },
2656
- submit: () => m({ username: d, password: P }),
2805
+ submit: () => m({ username: d, password: I }),
2657
2806
  onSuccess: n,
2658
2807
  onError: i
2659
- }), p = (u) => ({
2808
+ }), h = (u) => ({
2660
2809
  ...b.input,
2661
- ...o.fieldErrors[u] ? b.inputError : {}
2662
- }), x = !d || !P || o.loading, y = {
2810
+ ...l.fieldErrors[u] ? b.inputError : {}
2811
+ }), A = !d || !I || l.loading, y = {
2663
2812
  ...b.button,
2664
- ...o.loading ? b.buttonLoading : {},
2665
- ...x ? b.buttonDisabled : {}
2813
+ ...l.loading ? b.buttonLoading : {},
2814
+ ...A ? b.buttonDisabled : {}
2666
2815
  };
2667
2816
  return /* @__PURE__ */ f("div", { className: c, style: b.container, children: [
2668
2817
  /* @__PURE__ */ s("h2", { style: b.title, children: g.title }),
2669
- /* @__PURE__ */ f("form", { onSubmit: o.handleSubmit, style: b.form, children: [
2818
+ /* @__PURE__ */ f("form", { onSubmit: l.handleSubmit, style: b.form, children: [
2670
2819
  /* @__PURE__ */ f("div", { style: b.fieldGroup, children: [
2671
2820
  /* @__PURE__ */ s("label", { style: b.label, children: g.usernameLabel }),
2672
2821
  /* @__PURE__ */ s(
@@ -2677,11 +2826,11 @@ function Kr({
2677
2826
  type: "text",
2678
2827
  value: d,
2679
2828
  onChange: (u) => {
2680
- A(u.target.value), o.clearFieldError("username");
2829
+ x(u.target.value), l.clearFieldError("username");
2681
2830
  },
2682
2831
  placeholder: g.usernamePlaceholder,
2683
- style: p("username"),
2684
- disabled: o.loading
2832
+ style: h("username"),
2833
+ disabled: l.loading
2685
2834
  }
2686
2835
  )
2687
2836
  ] }),
@@ -2693,54 +2842,54 @@ function Kr({
2693
2842
  {
2694
2843
  id: "password",
2695
2844
  name: "password",
2696
- type: R ? "text" : "password",
2697
- value: P,
2845
+ type: P ? "text" : "password",
2846
+ value: I,
2698
2847
  onChange: (u) => {
2699
- I(u.target.value), o.clearFieldError("password");
2848
+ L(u.target.value), l.clearFieldError("password");
2700
2849
  },
2701
2850
  placeholder: g.passwordPlaceholder,
2702
- style: { ...p("password"), ...b.inputWithIcon },
2703
- disabled: o.loading
2851
+ style: { ...h("password"), ...b.inputWithIcon },
2852
+ disabled: l.loading
2704
2853
  }
2705
2854
  ),
2706
2855
  /* @__PURE__ */ s(
2707
2856
  "button",
2708
2857
  {
2709
2858
  type: "button",
2710
- onClick: () => E(!R),
2859
+ onClick: () => R(!P),
2711
2860
  style: b.passwordToggle,
2712
- disabled: o.loading,
2713
- "aria-label": R ? g.hidePasswordAriaLabel : g.showPasswordAriaLabel,
2714
- children: R ? C.hidePassword : C.showPassword
2861
+ disabled: l.loading,
2862
+ "aria-label": P ? g.hidePasswordAriaLabel : g.showPasswordAriaLabel,
2863
+ children: P ? w.hidePassword : w.showPassword
2715
2864
  }
2716
2865
  )
2717
2866
  ] })
2718
2867
  ] }),
2719
- /* @__PURE__ */ s("button", { type: "submit", disabled: x, style: y, children: o.loading ? g.loadingText : g.submitButton }),
2720
- o.error && /* @__PURE__ */ s("div", { style: b.errorText, children: o.error })
2868
+ /* @__PURE__ */ s("button", { type: "submit", disabled: A, style: y, children: l.loading ? g.loadingText : g.submitButton }),
2869
+ l.error && /* @__PURE__ */ s("div", { style: b.errorText, children: l.error })
2721
2870
  ] }),
2722
- (S || k || T) && /* @__PURE__ */ f("div", { style: b.linkContainer, children: [
2723
- T && /* @__PURE__ */ f("div", { children: [
2871
+ (k || E || S) && /* @__PURE__ */ f("div", { style: b.linkContainer, children: [
2872
+ S && /* @__PURE__ */ f("div", { children: [
2724
2873
  /* @__PURE__ */ f("span", { style: b.divider, children: [
2725
2874
  g.magicLinkText,
2726
2875
  " "
2727
2876
  ] }),
2728
- /* @__PURE__ */ s("a", { onClick: h, style: b.link, children: g.magicLinkLink })
2877
+ /* @__PURE__ */ s("a", { onClick: p, style: b.link, children: g.magicLinkLink })
2729
2878
  ] }),
2730
- T && (S || k) && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
2731
- S && /* @__PURE__ */ s("a", { onClick: a, style: b.link, children: g.forgotPasswordLink }),
2732
- S && k && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
2733
- k && /* @__PURE__ */ f("div", { children: [
2879
+ S && (k || E) && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
2880
+ k && /* @__PURE__ */ s("a", { onClick: o, style: b.link, children: g.forgotPasswordLink }),
2881
+ k && E && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
2882
+ E && /* @__PURE__ */ f("div", { children: [
2734
2883
  /* @__PURE__ */ f("span", { style: b.divider, children: [
2735
2884
  g.signupText,
2736
2885
  " "
2737
2886
  ] }),
2738
- /* @__PURE__ */ s("a", { onClick: l, style: b.link, children: g.signupLink })
2887
+ /* @__PURE__ */ s("a", { onClick: a, style: b.link, children: g.signupLink })
2739
2888
  ] })
2740
2889
  ] })
2741
2890
  ] });
2742
2891
  }
2743
- const cr = {
2892
+ const fr = {
2744
2893
  title: "Create Account",
2745
2894
  nameLabel: "First Name",
2746
2895
  namePlaceholder: "Enter your first name",
@@ -2770,75 +2919,75 @@ const cr = {
2770
2919
  tenantNotFoundError: "Tenant not found",
2771
2920
  dividerBullet: "•"
2772
2921
  };
2773
- function Yr({
2922
+ function nn({
2774
2923
  copy: r = {},
2775
2924
  styles: e = {},
2776
2925
  signupType: t = "user",
2777
2926
  onSuccess: n,
2778
2927
  onError: i,
2779
- onLoginClick: a,
2780
- onMagicLinkClick: l,
2781
- showLoginLink: h = !0,
2782
- showMagicLinkOption: S = !0,
2783
- className: k
2928
+ onLoginClick: o,
2929
+ onMagicLinkClick: a,
2930
+ showLoginLink: p = !0,
2931
+ showMagicLinkOption: k = !0,
2932
+ className: E
2784
2933
  }) {
2785
- var B;
2786
- const [T, c] = N(""), [d, A] = N(""), [P, I] = N(""), [R, E] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: x, signupTenantAdmin: y } = de(), u = ((B = pe()) == null ? void 0 : B.tenant) ?? null, v = { ...cr, ...r }, D = Le("#10b981", e), se = !!T && (!!P || !!R) && !!m && !!b && (t === "user" || !!o), F = ve({
2787
- defaultErrorMessage: v.errorMessage,
2934
+ var D;
2935
+ const [S, c] = C(""), [d, x] = C(""), [I, L] = C(""), [P, R] = C(""), [m, g] = C(""), [b, w] = C(""), [l, h] = C(""), { signup: A, signupTenantAdmin: y } = ue(), u = ((D = pe()) == null ? void 0 : D.tenant) ?? null, T = { ...fr, ...r }, M = Fe("#10b981", e), se = !!S && (!!I || !!P) && !!m && !!b && (t === "user" || !!l), N = Te({
2936
+ defaultErrorMessage: T.errorMessage,
2788
2937
  validate: () => {
2789
- const L = [];
2790
- return T.trim() || L.push("name"), !P.trim() && !R.trim() && (L.push("email"), L.push("phoneNumber")), m.trim() || L.push("password"), b.trim() || L.push("confirmPassword"), t === "tenant" && !o.trim() && L.push("tenantName"), L.forEach((q) => F.setFieldError(q, !0)), L.length > 0 ? !1 : m !== b ? (F.setError(v.passwordMismatchError), F.setFieldError("confirmPassword", !0), !1) : t === "user" && !(u != null && u.id) ? (F.setError(v.tenantNotFoundError), !1) : !0;
2938
+ const F = [];
2939
+ return S.trim() || F.push("name"), !I.trim() && !P.trim() && (F.push("email"), F.push("phoneNumber")), m.trim() || F.push("password"), b.trim() || F.push("confirmPassword"), t === "tenant" && !l.trim() && F.push("tenantName"), F.forEach((_) => N.setFieldError(_, !0)), F.length > 0 ? !1 : m !== b ? (N.setError(T.passwordMismatchError), N.setFieldError("confirmPassword", !0), !1) : t === "user" && !(u != null && u.id) ? (N.setError(T.tenantNotFoundError), !1) : !0;
2791
2940
  },
2792
2941
  submit: async () => t === "tenant" ? y({
2793
- email: P || void 0,
2794
- phoneNumber: R || void 0,
2795
- name: T,
2942
+ email: I || void 0,
2943
+ phoneNumber: P || void 0,
2944
+ name: S,
2796
2945
  password: m,
2797
- tenantName: o,
2946
+ tenantName: l,
2798
2947
  lastName: d || void 0
2799
- }) : x({
2800
- email: P || void 0,
2801
- phoneNumber: R || void 0,
2802
- name: T,
2948
+ }) : A({
2949
+ email: I || void 0,
2950
+ phoneNumber: P || void 0,
2951
+ name: S,
2803
2952
  password: m,
2804
2953
  tenantId: u.id,
2805
2954
  lastName: d || void 0
2806
2955
  }),
2807
2956
  onSuccess: n,
2808
2957
  onError: i
2809
- }), H = (L) => ({
2810
- ...D.input,
2811
- ...F.fieldErrors[L] ? D.inputError : {}
2812
- }), j = !se || F.loading, K = {
2813
- ...D.button,
2814
- ...F.loading ? D.buttonLoading : {},
2815
- ...j ? D.buttonDisabled : {}
2816
- }, $ = () => {
2817
- F.clearFieldError("email"), F.clearFieldError("phoneNumber");
2958
+ }), W = (F) => ({
2959
+ ...M.input,
2960
+ ...N.fieldErrors[F] ? M.inputError : {}
2961
+ }), z = !se || N.loading, Z = {
2962
+ ...M.button,
2963
+ ...N.loading ? M.buttonLoading : {},
2964
+ ...z ? M.buttonDisabled : {}
2965
+ }, K = () => {
2966
+ N.clearFieldError("email"), N.clearFieldError("phoneNumber");
2818
2967
  };
2819
- return /* @__PURE__ */ f("div", { className: k, style: D.container, children: [
2820
- /* @__PURE__ */ s("h2", { style: D.title, children: v.title }),
2821
- /* @__PURE__ */ f("form", { onSubmit: F.handleSubmit, style: D.form, children: [
2822
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2823
- /* @__PURE__ */ s("label", { style: D.label, children: v.nameLabel }),
2968
+ return /* @__PURE__ */ f("div", { className: E, style: M.container, children: [
2969
+ /* @__PURE__ */ s("h2", { style: M.title, children: T.title }),
2970
+ /* @__PURE__ */ f("form", { onSubmit: N.handleSubmit, style: M.form, children: [
2971
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
2972
+ /* @__PURE__ */ s("label", { style: M.label, children: T.nameLabel }),
2824
2973
  /* @__PURE__ */ s(
2825
2974
  "input",
2826
2975
  {
2827
2976
  id: "name",
2828
2977
  name: "name",
2829
2978
  type: "text",
2830
- value: T,
2831
- onChange: (L) => {
2832
- c(L.target.value), F.clearFieldError("name");
2979
+ value: S,
2980
+ onChange: (F) => {
2981
+ c(F.target.value), N.clearFieldError("name");
2833
2982
  },
2834
- placeholder: v.namePlaceholder,
2835
- style: H("name"),
2836
- disabled: F.loading
2983
+ placeholder: T.namePlaceholder,
2984
+ style: W("name"),
2985
+ disabled: N.loading
2837
2986
  }
2838
2987
  )
2839
2988
  ] }),
2840
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2841
- /* @__PURE__ */ s("label", { style: D.label, children: v.lastNameLabel }),
2989
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
2990
+ /* @__PURE__ */ s("label", { style: M.label, children: T.lastNameLabel }),
2842
2991
  /* @__PURE__ */ s(
2843
2992
  "input",
2844
2993
  {
@@ -2846,52 +2995,52 @@ function Yr({
2846
2995
  name: "lastName",
2847
2996
  type: "text",
2848
2997
  value: d,
2849
- onChange: (L) => A(L.target.value),
2850
- placeholder: v.lastNamePlaceholder,
2851
- style: D.input,
2852
- disabled: F.loading
2998
+ onChange: (F) => x(F.target.value),
2999
+ placeholder: T.lastNamePlaceholder,
3000
+ style: M.input,
3001
+ disabled: N.loading
2853
3002
  }
2854
3003
  )
2855
3004
  ] }),
2856
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2857
- /* @__PURE__ */ s("label", { style: D.label, children: v.emailLabel }),
3005
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
3006
+ /* @__PURE__ */ s("label", { style: M.label, children: T.emailLabel }),
2858
3007
  /* @__PURE__ */ s(
2859
3008
  "input",
2860
3009
  {
2861
3010
  id: "email",
2862
3011
  name: "email",
2863
3012
  type: "email",
2864
- value: P,
2865
- onChange: (L) => {
2866
- I(L.target.value), $();
3013
+ value: I,
3014
+ onChange: (F) => {
3015
+ L(F.target.value), K();
2867
3016
  },
2868
- placeholder: v.emailPlaceholder,
2869
- style: H("email"),
2870
- disabled: F.loading
3017
+ placeholder: T.emailPlaceholder,
3018
+ style: W("email"),
3019
+ disabled: N.loading
2871
3020
  }
2872
3021
  )
2873
3022
  ] }),
2874
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2875
- /* @__PURE__ */ s("label", { style: D.label, children: v.phoneNumberLabel }),
3023
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
3024
+ /* @__PURE__ */ s("label", { style: M.label, children: T.phoneNumberLabel }),
2876
3025
  /* @__PURE__ */ s(
2877
3026
  "input",
2878
3027
  {
2879
3028
  id: "phoneNumber",
2880
3029
  name: "phoneNumber",
2881
3030
  type: "tel",
2882
- value: R,
2883
- onChange: (L) => {
2884
- E(L.target.value), $();
3031
+ value: P,
3032
+ onChange: (F) => {
3033
+ R(F.target.value), K();
2885
3034
  },
2886
- placeholder: v.phoneNumberPlaceholder,
2887
- style: H("phoneNumber"),
2888
- disabled: F.loading
3035
+ placeholder: T.phoneNumberPlaceholder,
3036
+ style: W("phoneNumber"),
3037
+ disabled: N.loading
2889
3038
  }
2890
3039
  )
2891
3040
  ] }),
2892
- /* @__PURE__ */ s("div", { style: D.hintText, children: v.contactMethodHint }),
2893
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2894
- /* @__PURE__ */ s("label", { style: D.label, children: v.passwordLabel }),
3041
+ /* @__PURE__ */ s("div", { style: M.hintText, children: T.contactMethodHint }),
3042
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
3043
+ /* @__PURE__ */ s("label", { style: M.label, children: T.passwordLabel }),
2895
3044
  /* @__PURE__ */ s(
2896
3045
  "input",
2897
3046
  {
@@ -2899,17 +3048,17 @@ function Yr({
2899
3048
  name: "password",
2900
3049
  type: "password",
2901
3050
  value: m,
2902
- onChange: (L) => {
2903
- g(L.target.value), F.clearFieldError("password");
3051
+ onChange: (F) => {
3052
+ g(F.target.value), N.clearFieldError("password");
2904
3053
  },
2905
- placeholder: v.passwordPlaceholder,
2906
- style: H("password"),
2907
- disabled: F.loading
3054
+ placeholder: T.passwordPlaceholder,
3055
+ style: W("password"),
3056
+ disabled: N.loading
2908
3057
  }
2909
3058
  )
2910
3059
  ] }),
2911
- /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2912
- /* @__PURE__ */ s("label", { style: D.label, children: v.confirmPasswordLabel }),
3060
+ /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
3061
+ /* @__PURE__ */ s("label", { style: M.label, children: T.confirmPasswordLabel }),
2913
3062
  /* @__PURE__ */ s(
2914
3063
  "input",
2915
3064
  {
@@ -2917,56 +3066,56 @@ function Yr({
2917
3066
  name: "confirmPassword",
2918
3067
  type: "password",
2919
3068
  value: b,
2920
- onChange: (L) => {
2921
- C(L.target.value), F.clearFieldError("confirmPassword"), F.error === v.passwordMismatchError && F.setError("");
3069
+ onChange: (F) => {
3070
+ w(F.target.value), N.clearFieldError("confirmPassword"), N.error === T.passwordMismatchError && N.setError("");
2922
3071
  },
2923
- placeholder: v.confirmPasswordPlaceholder,
2924
- style: H("confirmPassword"),
2925
- disabled: F.loading
3072
+ placeholder: T.confirmPasswordPlaceholder,
3073
+ style: W("confirmPassword"),
3074
+ disabled: N.loading
2926
3075
  }
2927
3076
  )
2928
3077
  ] }),
2929
- t === "tenant" && /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
2930
- /* @__PURE__ */ s("label", { style: D.label, children: v.tenantNameLabel }),
3078
+ t === "tenant" && /* @__PURE__ */ f("div", { style: M.fieldGroup, children: [
3079
+ /* @__PURE__ */ s("label", { style: M.label, children: T.tenantNameLabel }),
2931
3080
  /* @__PURE__ */ s(
2932
3081
  "input",
2933
3082
  {
2934
3083
  id: "tenantName",
2935
3084
  name: "tenantName",
2936
3085
  type: "text",
2937
- value: o,
2938
- onChange: (L) => {
2939
- p(L.target.value), F.clearFieldError("tenantName");
3086
+ value: l,
3087
+ onChange: (F) => {
3088
+ h(F.target.value), N.clearFieldError("tenantName");
2940
3089
  },
2941
- placeholder: v.tenantNamePlaceholder,
2942
- style: H("tenantName"),
2943
- disabled: F.loading
3090
+ placeholder: T.tenantNamePlaceholder,
3091
+ style: W("tenantName"),
3092
+ disabled: N.loading
2944
3093
  }
2945
3094
  )
2946
3095
  ] }),
2947
- /* @__PURE__ */ s("button", { type: "submit", disabled: j, style: K, children: F.loading ? v.loadingText : v.submitButton }),
2948
- F.error && /* @__PURE__ */ s("div", { style: D.errorText, children: F.error })
3096
+ /* @__PURE__ */ s("button", { type: "submit", disabled: z, style: Z, children: N.loading ? T.loadingText : T.submitButton }),
3097
+ N.error && /* @__PURE__ */ s("div", { style: M.errorText, children: N.error })
2949
3098
  ] }),
2950
- (h || S) && /* @__PURE__ */ f("div", { style: D.linkContainer, children: [
2951
- S && /* @__PURE__ */ f("div", { children: [
2952
- /* @__PURE__ */ f("span", { style: D.divider, children: [
2953
- v.magicLinkText,
3099
+ (p || k) && /* @__PURE__ */ f("div", { style: M.linkContainer, children: [
3100
+ k && /* @__PURE__ */ f("div", { children: [
3101
+ /* @__PURE__ */ f("span", { style: M.divider, children: [
3102
+ T.magicLinkText,
2954
3103
  " "
2955
3104
  ] }),
2956
- /* @__PURE__ */ s("a", { onClick: l, style: D.link, children: v.magicLinkLink })
3105
+ /* @__PURE__ */ s("a", { onClick: a, style: M.link, children: T.magicLinkLink })
2957
3106
  ] }),
2958
- S && h && /* @__PURE__ */ s("div", { style: D.divider, children: v.dividerBullet }),
2959
- h && /* @__PURE__ */ f("div", { children: [
2960
- /* @__PURE__ */ f("span", { style: D.divider, children: [
2961
- v.loginText,
3107
+ k && p && /* @__PURE__ */ s("div", { style: M.divider, children: T.dividerBullet }),
3108
+ p && /* @__PURE__ */ f("div", { children: [
3109
+ /* @__PURE__ */ f("span", { style: M.divider, children: [
3110
+ T.loginText,
2962
3111
  " "
2963
3112
  ] }),
2964
- /* @__PURE__ */ s("a", { onClick: a, style: D.link, children: v.loginLink })
3113
+ /* @__PURE__ */ s("a", { onClick: o, style: M.link, children: T.loginLink })
2965
3114
  ] })
2966
3115
  ] })
2967
3116
  ] });
2968
3117
  }
2969
- const ur = {
3118
+ const mr = {
2970
3119
  title: "Sign In with Magic Link",
2971
3120
  emailLabel: "Email",
2972
3121
  emailPlaceholder: "Enter your email",
@@ -2991,73 +3140,73 @@ const ur = {
2991
3140
  missingTenantOrEmailError: "Missing tenant or email",
2992
3141
  dividerBullet: "•"
2993
3142
  };
2994
- function Xr({
3143
+ function sn({
2995
3144
  copy: r = {},
2996
3145
  styles: e = {},
2997
3146
  onSuccess: t,
2998
3147
  onError: n,
2999
3148
  onLoginClick: i,
3000
- onSignupClick: a,
3001
- showTraditionalLinks: l = !0,
3002
- className: h,
3003
- verifyToken: S,
3004
- frontendUrl: k
3149
+ onSignupClick: o,
3150
+ showTraditionalLinks: a = !0,
3151
+ className: p,
3152
+ verifyToken: k,
3153
+ frontendUrl: E
3005
3154
  }) {
3006
- var H;
3007
- const [T, c] = N(""), [d, A] = N(""), [P, I] = N(""), [R, E] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), x = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...ur, ...r }, u = Le("#3b82f6", e), v = ve({
3155
+ var W;
3156
+ const [S, c] = C(""), [d, x] = C(""), [I, L] = C(""), [P, R] = C(!1), [m, g] = C(""), [b, w] = C(!1), { sendMagicLink: l, verifyMagicLink: h } = ue(), A = ((W = pe()) == null ? void 0 : W.tenant) ?? null, y = { ...mr, ...r }, u = Fe("#3b82f6", e), T = Te({
3008
3157
  defaultErrorMessage: y.errorMessage,
3009
3158
  validate: () => {
3010
- const j = [];
3011
- return T.trim() || j.push("email"), b && !d.trim() && j.push("name"), j.forEach((K) => v.setFieldError(K, !0)), j.length > 0 ? !1 : x != null && x.id ? !0 : (v.setError(y.tenantNotFoundError), !1);
3159
+ const z = [];
3160
+ return S.trim() || z.push("email"), b && !d.trim() && z.push("name"), z.forEach((Z) => T.setFieldError(Z, !0)), z.length > 0 ? !1 : A != null && A.id ? !0 : (T.setError(y.tenantNotFoundError), !1);
3012
3161
  },
3013
3162
  submit: async () => {
3014
3163
  g("");
3015
- const j = k || (typeof window < "u" ? window.location.origin : ""), K = await o({
3016
- email: T,
3017
- tenantId: x.id,
3018
- frontendUrl: j,
3164
+ const z = E || (typeof window < "u" ? window.location.origin : ""), Z = await l({
3165
+ email: S,
3166
+ tenantId: A.id,
3167
+ frontendUrl: z,
3019
3168
  name: b ? d : void 0,
3020
- lastName: b ? P : void 0
3169
+ lastName: b ? I : void 0
3021
3170
  });
3022
- return g(y.successMessage), K;
3171
+ return g(y.successMessage), Z;
3023
3172
  },
3024
3173
  onSuccess: t,
3025
3174
  onError: n
3026
3175
  });
3027
3176
  re(() => {
3028
- if (!S) return;
3177
+ if (!k) return;
3029
3178
  (async () => {
3030
- if (!x || !T) {
3031
- v.setError(y.missingTenantOrEmailError);
3179
+ if (!A || !S) {
3180
+ T.setError(y.missingTenantOrEmailError);
3032
3181
  return;
3033
3182
  }
3034
- E(!0), v.setError("");
3183
+ R(!0), T.setError("");
3035
3184
  try {
3036
- const K = await p({ token: S, email: T });
3037
- t == null || t(K);
3038
- } catch (K) {
3039
- const $ = K instanceof Error ? K.message : "Failed to verify magic link";
3040
- v.setError($), n == null || n($);
3185
+ const Z = await h({ token: k, email: S });
3186
+ t == null || t(Z);
3187
+ } catch (Z) {
3188
+ const K = Z instanceof Error ? Z.message : "Failed to verify magic link";
3189
+ T.setError(K), n == null || n(K);
3041
3190
  } finally {
3042
- E(!1);
3191
+ R(!1);
3043
3192
  }
3044
3193
  })();
3045
- }, [S]);
3046
- const D = (j) => ({
3194
+ }, [k]);
3195
+ const M = (z) => ({
3047
3196
  ...u.input,
3048
- ...v.fieldErrors[j] ? u.inputError : {}
3049
- }), se = !T || v.loading || R, F = {
3197
+ ...T.fieldErrors[z] ? u.inputError : {}
3198
+ }), se = !S || T.loading || P, N = {
3050
3199
  ...u.button,
3051
- ...v.loading || R ? u.buttonLoading : {},
3200
+ ...T.loading || P ? u.buttonLoading : {},
3052
3201
  ...se ? u.buttonDisabled : {}
3053
3202
  };
3054
- return R ? /* @__PURE__ */ f("div", { className: h, style: u.container, children: [
3203
+ return P ? /* @__PURE__ */ f("div", { className: p, style: u.container, children: [
3055
3204
  /* @__PURE__ */ s("h2", { style: u.title, children: y.verifyingText }),
3056
3205
  /* @__PURE__ */ s("div", { style: u.verifyingContainer, children: /* @__PURE__ */ s("div", { style: u.verifyingText, children: y.verifyingDescription }) })
3057
- ] }) : /* @__PURE__ */ f("div", { className: h, style: u.container, children: [
3206
+ ] }) : /* @__PURE__ */ f("div", { className: p, style: u.container, children: [
3058
3207
  /* @__PURE__ */ s("h2", { style: u.title, children: y.title }),
3059
3208
  /* @__PURE__ */ s("p", { style: u.description, children: y.description }),
3060
- /* @__PURE__ */ f("form", { onSubmit: v.handleSubmit, style: u.form, children: [
3209
+ /* @__PURE__ */ f("form", { onSubmit: T.handleSubmit, style: u.form, children: [
3061
3210
  /* @__PURE__ */ f("div", { style: u.fieldGroup, children: [
3062
3211
  /* @__PURE__ */ s("label", { style: u.label, children: y.emailLabel }),
3063
3212
  /* @__PURE__ */ s(
@@ -3066,13 +3215,13 @@ function Xr({
3066
3215
  id: "email",
3067
3216
  name: "email",
3068
3217
  type: "email",
3069
- value: T,
3070
- onChange: (j) => {
3071
- c(j.target.value), v.clearFieldError("email");
3218
+ value: S,
3219
+ onChange: (z) => {
3220
+ c(z.target.value), T.clearFieldError("email");
3072
3221
  },
3073
3222
  placeholder: y.emailPlaceholder,
3074
- style: D("email"),
3075
- disabled: v.loading || R
3223
+ style: M("email"),
3224
+ disabled: T.loading || P
3076
3225
  }
3077
3226
  )
3078
3227
  ] }),
@@ -3080,7 +3229,7 @@ function Xr({
3080
3229
  "button",
3081
3230
  {
3082
3231
  type: "button",
3083
- onClick: () => C(!0),
3232
+ onClick: () => w(!0),
3084
3233
  style: u.toggleLink,
3085
3234
  children: y.showNameToggle
3086
3235
  }
@@ -3095,12 +3244,12 @@ function Xr({
3095
3244
  name: "name",
3096
3245
  type: "text",
3097
3246
  value: d,
3098
- onChange: (j) => {
3099
- A(j.target.value), v.clearFieldError("name");
3247
+ onChange: (z) => {
3248
+ x(z.target.value), T.clearFieldError("name");
3100
3249
  },
3101
3250
  placeholder: y.namePlaceholder,
3102
- style: D("name"),
3103
- disabled: v.loading || R
3251
+ style: M("name"),
3252
+ disabled: T.loading || P
3104
3253
  }
3105
3254
  )
3106
3255
  ] }),
@@ -3112,11 +3261,11 @@ function Xr({
3112
3261
  id: "lastName",
3113
3262
  name: "lastName",
3114
3263
  type: "text",
3115
- value: P,
3116
- onChange: (j) => I(j.target.value),
3264
+ value: I,
3265
+ onChange: (z) => L(z.target.value),
3117
3266
  placeholder: y.lastNamePlaceholder,
3118
3267
  style: u.input,
3119
- disabled: v.loading || R
3268
+ disabled: T.loading || P
3120
3269
  }
3121
3270
  )
3122
3271
  ] }),
@@ -3125,18 +3274,18 @@ function Xr({
3125
3274
  {
3126
3275
  type: "button",
3127
3276
  onClick: () => {
3128
- C(!1), A(""), I("");
3277
+ w(!1), x(""), L("");
3129
3278
  },
3130
3279
  style: u.toggleLink,
3131
3280
  children: y.hideNameToggle
3132
3281
  }
3133
3282
  ) })
3134
3283
  ] }),
3135
- /* @__PURE__ */ s("button", { type: "submit", disabled: se, style: F, children: v.loading ? y.loadingText : y.submitButton }),
3136
- v.error && /* @__PURE__ */ s("div", { style: u.errorText, children: v.error }),
3284
+ /* @__PURE__ */ s("button", { type: "submit", disabled: se, style: N, children: T.loading ? y.loadingText : y.submitButton }),
3285
+ T.error && /* @__PURE__ */ s("div", { style: u.errorText, children: T.error }),
3137
3286
  m && /* @__PURE__ */ s("div", { style: u.successText, children: m })
3138
3287
  ] }),
3139
- l && /* @__PURE__ */ f("div", { style: u.linkContainer, children: [
3288
+ a && /* @__PURE__ */ f("div", { style: u.linkContainer, children: [
3140
3289
  /* @__PURE__ */ f("div", { children: [
3141
3290
  /* @__PURE__ */ f("span", { style: u.divider, children: [
3142
3291
  y.loginText,
@@ -3150,12 +3299,12 @@ function Xr({
3150
3299
  y.signupText,
3151
3300
  " "
3152
3301
  ] }),
3153
- /* @__PURE__ */ s("a", { onClick: a, style: u.link, children: y.signupLink })
3302
+ /* @__PURE__ */ s("a", { onClick: o, style: u.link, children: y.signupLink })
3154
3303
  ] })
3155
3304
  ] })
3156
3305
  ] });
3157
3306
  }
3158
- const dr = {
3307
+ const gr = {
3159
3308
  title: "Verifying Magic Link",
3160
3309
  verifyingMessage: "Please wait while we verify your magic link...",
3161
3310
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -3164,7 +3313,7 @@ const dr = {
3164
3313
  retryButton: "Try Again",
3165
3314
  backToLoginButton: "Back to Login",
3166
3315
  missingParamsError: "Missing required parameters: token or email"
3167
- }, ut = {
3316
+ }, pt = {
3168
3317
  container: {
3169
3318
  maxWidth: "400px",
3170
3319
  width: "100%",
@@ -3257,7 +3406,7 @@ const dr = {
3257
3406
  backButtonHover: {
3258
3407
  backgroundColor: "#e5e7eb"
3259
3408
  }
3260
- }, hr = () => /* @__PURE__ */ s("div", { style: ut.spinner }), pr = () => /* @__PURE__ */ f(
3409
+ }, yr = () => /* @__PURE__ */ s("div", { style: pt.spinner }), br = () => /* @__PURE__ */ f(
3261
3410
  "svg",
3262
3411
  {
3263
3412
  width: "48",
@@ -3274,7 +3423,7 @@ const dr = {
3274
3423
  /* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
3275
3424
  ]
3276
3425
  }
3277
- ), fr = () => /* @__PURE__ */ f(
3426
+ ), wr = () => /* @__PURE__ */ f(
3278
3427
  "svg",
3279
3428
  {
3280
3429
  width: "48",
@@ -3292,63 +3441,63 @@ const dr = {
3292
3441
  /* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
3293
3442
  ]
3294
3443
  }
3295
- ), mr = {
3296
- loading: /* @__PURE__ */ s(hr, {}),
3297
- success: /* @__PURE__ */ s(pr, {}),
3298
- error: /* @__PURE__ */ s(fr, {})
3444
+ ), vr = {
3445
+ loading: /* @__PURE__ */ s(yr, {}),
3446
+ success: /* @__PURE__ */ s(br, {}),
3447
+ error: /* @__PURE__ */ s(wr, {})
3299
3448
  };
3300
- function en({
3449
+ function on({
3301
3450
  copy: r = {},
3302
3451
  styles: e = {},
3303
3452
  icons: t = {},
3304
3453
  onSuccess: n,
3305
3454
  onError: i,
3306
- onRetry: a,
3307
- onBackToLogin: l,
3308
- className: h,
3309
- token: S,
3310
- email: k,
3311
- appId: T,
3455
+ onRetry: o,
3456
+ onBackToLogin: a,
3457
+ className: p,
3458
+ token: k,
3459
+ email: E,
3460
+ appId: S,
3312
3461
  tenantSlug: c,
3313
3462
  autoRedirectDelay: d = 3e3
3314
3463
  }) {
3315
- const [A, P] = N("verifying"), [I, R] = N(""), { verifyMagicLink: E } = de(), m = { ...dr, ...r }, g = { ...ut, ...e }, b = { ...mr, ...t }, C = () => {
3464
+ const [x, I] = C("verifying"), [L, P] = C(""), { verifyMagicLink: R } = ue(), m = { ...gr, ...r }, g = { ...pt, ...e }, b = { ...vr, ...t }, w = () => {
3316
3465
  if (typeof window > "u") return {};
3317
3466
  const u = new URLSearchParams(window.location.search);
3318
3467
  return {
3319
- token: S || u.get("token") || "",
3320
- email: k || u.get("email") || "",
3321
- appId: T || u.get("appId") || "",
3468
+ token: k || u.get("token") || "",
3469
+ email: E || u.get("email") || "",
3470
+ appId: S || u.get("appId") || "",
3322
3471
  tenantSlug: c || u.get("tenantSlug") || void 0
3323
3472
  };
3324
- }, o = async () => {
3325
- P("verifying"), R("");
3473
+ }, l = async () => {
3474
+ I("verifying"), P("");
3326
3475
  try {
3327
- const u = C();
3476
+ const u = w();
3328
3477
  if (!u.token || !u.email)
3329
3478
  throw new Error(m.missingParamsError);
3330
- const v = await E({
3479
+ const T = await R({
3331
3480
  token: u.token,
3332
3481
  email: u.email,
3333
3482
  tenantSlug: u.tenantSlug
3334
3483
  });
3335
- P("success"), n == null || n(v), d > 0 && setTimeout(() => {
3336
- P("redirecting");
3484
+ I("success"), n == null || n(T), d > 0 && setTimeout(() => {
3485
+ I("redirecting");
3337
3486
  }, d);
3338
3487
  } catch (u) {
3339
- const v = u.message || m.errorMessage;
3340
- R(v), P("error"), i == null || i(v);
3488
+ const T = u.message || m.errorMessage;
3489
+ P(T), I("error"), i == null || i(T);
3341
3490
  }
3342
- }, p = () => {
3343
- a == null || a(), o();
3344
- }, x = () => {
3345
- l == null || l();
3491
+ }, h = () => {
3492
+ o == null || o(), l();
3493
+ }, A = () => {
3494
+ a == null || a();
3346
3495
  };
3347
3496
  re(() => {
3348
- o();
3497
+ l();
3349
3498
  }, []);
3350
3499
  const y = () => {
3351
- switch (A) {
3500
+ switch (x) {
3352
3501
  case "verifying":
3353
3502
  return /* @__PURE__ */ f("div", { style: g.message, children: [
3354
3503
  b.loading,
@@ -3367,20 +3516,20 @@ function en({
3367
3516
  case "error":
3368
3517
  return /* @__PURE__ */ f(U, { children: [
3369
3518
  b.error,
3370
- /* @__PURE__ */ s("div", { style: g.errorMessage, children: I || m.errorMessage }),
3519
+ /* @__PURE__ */ s("div", { style: g.errorMessage, children: L || m.errorMessage }),
3371
3520
  /* @__PURE__ */ f("div", { style: g.buttonContainer, children: [
3372
3521
  /* @__PURE__ */ s(
3373
3522
  "button",
3374
3523
  {
3375
- onClick: p,
3524
+ onClick: h,
3376
3525
  style: g.retryButton,
3377
3526
  onMouseOver: (u) => {
3378
3527
  Object.assign(u.currentTarget.style, g.retryButtonHover);
3379
3528
  },
3380
3529
  onMouseOut: (u) => {
3381
- const v = g.retryButton || {};
3382
- Object.keys(g.retryButtonHover || {}).forEach((D) => {
3383
- u.currentTarget.style[D] = v[D] ?? "";
3530
+ const T = g.retryButton || {};
3531
+ Object.keys(g.retryButtonHover || {}).forEach((M) => {
3532
+ u.currentTarget.style[M] = T[M] ?? "";
3384
3533
  });
3385
3534
  },
3386
3535
  children: m.retryButton
@@ -3389,15 +3538,15 @@ function en({
3389
3538
  /* @__PURE__ */ s(
3390
3539
  "button",
3391
3540
  {
3392
- onClick: x,
3541
+ onClick: A,
3393
3542
  style: g.backButton,
3394
3543
  onMouseOver: (u) => {
3395
3544
  Object.assign(u.currentTarget.style, g.backButtonHover);
3396
3545
  },
3397
3546
  onMouseOut: (u) => {
3398
- const v = g.backButton || {};
3399
- Object.keys(g.backButtonHover || {}).forEach((D) => {
3400
- u.currentTarget.style[D] = v[D] ?? "";
3547
+ const T = g.backButton || {};
3548
+ Object.keys(g.backButtonHover || {}).forEach((M) => {
3549
+ u.currentTarget.style[M] = T[M] ?? "";
3401
3550
  });
3402
3551
  },
3403
3552
  children: m.backToLoginButton
@@ -3409,7 +3558,7 @@ function en({
3409
3558
  return null;
3410
3559
  }
3411
3560
  };
3412
- return /* @__PURE__ */ f("div", { style: g.container, className: h, children: [
3561
+ return /* @__PURE__ */ f("div", { style: g.container, className: p, children: [
3413
3562
  /* @__PURE__ */ s("style", { children: `
3414
3563
  @keyframes spin {
3415
3564
  0% { transform: rotate(0deg); }
@@ -3420,7 +3569,7 @@ function en({
3420
3569
  y()
3421
3570
  ] });
3422
3571
  }
3423
- const gr = {
3572
+ const Tr = {
3424
3573
  title: "Reset Password",
3425
3574
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
3426
3575
  emailLabel: "Email",
@@ -3447,154 +3596,154 @@ const gr = {
3447
3596
  tenantNotFoundError: "Tenant not found",
3448
3597
  dividerBullet: "•"
3449
3598
  };
3450
- function tn({
3599
+ function an({
3451
3600
  copy: r = {},
3452
3601
  styles: e = {},
3453
3602
  mode: t = "request",
3454
3603
  token: n = "",
3455
3604
  onSuccess: i,
3456
- onError: a,
3457
- onBackToLogin: l,
3458
- onModeChange: h,
3459
- className: S
3605
+ onError: o,
3606
+ onBackToLogin: a,
3607
+ onModeChange: p,
3608
+ className: k
3460
3609
  }) {
3461
3610
  var se;
3462
- const [k, T] = N(""), [c, d] = N(n), [A, P] = N(""), [I, R] = N(""), [E, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...gr, ...r }, p = Le("#f59e0b", e), x = ve({
3463
- defaultErrorMessage: o.errorMessage,
3464
- validate: () => k.trim() ? C != null && C.id ? !0 : (x.setError(o.tenantNotFoundError), !1) : (x.setFieldError("email", !0), !1),
3611
+ const [E, S] = C(""), [c, d] = C(n), [x, I] = C(""), [L, P] = C(""), [R, m] = C(""), { requestPasswordReset: g, confirmPasswordReset: b } = ue(), w = ((se = pe()) == null ? void 0 : se.tenant) ?? null, l = { ...Tr, ...r }, h = Fe("#f59e0b", e), A = Te({
3612
+ defaultErrorMessage: l.errorMessage,
3613
+ validate: () => E.trim() ? w != null && w.id ? !0 : (A.setError(l.tenantNotFoundError), !1) : (A.setFieldError("email", !0), !1),
3465
3614
  submit: async () => {
3466
- m(""), await g({ email: k, tenantId: C.id }), m(o.successMessage);
3615
+ m(""), await g({ email: E, tenantId: w.id }), m(l.successMessage);
3467
3616
  },
3468
3617
  onSuccess: () => i == null ? void 0 : i(),
3469
- onError: a
3470
- }), y = ve({
3471
- defaultErrorMessage: o.errorMessage,
3618
+ onError: o
3619
+ }), y = Te({
3620
+ defaultErrorMessage: l.errorMessage,
3472
3621
  validate: () => {
3473
- const F = [];
3474
- return c.trim() || F.push("token"), A.trim() || F.push("newPassword"), I.trim() || F.push("confirmPassword"), F.forEach((H) => y.setFieldError(H, !0)), F.length > 0 ? !1 : A !== I ? (y.setError(o.passwordMismatchError), y.setFieldError("confirmPassword", !0), !1) : !0;
3622
+ const N = [];
3623
+ return c.trim() || N.push("token"), x.trim() || N.push("newPassword"), L.trim() || N.push("confirmPassword"), N.forEach((W) => y.setFieldError(W, !0)), N.length > 0 ? !1 : x !== L ? (y.setError(l.passwordMismatchError), y.setFieldError("confirmPassword", !0), !1) : !0;
3475
3624
  },
3476
3625
  submit: async () => {
3477
- m(""), await b({ token: c, newPassword: A }), m(o.resetSuccessMessage);
3626
+ m(""), await b({ token: c, newPassword: x }), m(l.resetSuccessMessage);
3478
3627
  },
3479
3628
  onSuccess: () => i == null ? void 0 : i(),
3480
- onError: a
3629
+ onError: o
3481
3630
  });
3482
3631
  if (t === "reset") {
3483
- const F = ($) => ({
3484
- ...p.input,
3485
- ...y.fieldErrors[$] ? p.inputError : {}
3486
- }), j = !(!!c && !!A && !!I) || y.loading, K = {
3487
- ...p.button,
3488
- ...y.loading ? p.buttonLoading : {},
3489
- ...j ? p.buttonDisabled : {}
3632
+ const N = (K) => ({
3633
+ ...h.input,
3634
+ ...y.fieldErrors[K] ? h.inputError : {}
3635
+ }), z = !(!!c && !!x && !!L) || y.loading, Z = {
3636
+ ...h.button,
3637
+ ...y.loading ? h.buttonLoading : {},
3638
+ ...z ? h.buttonDisabled : {}
3490
3639
  };
3491
- return /* @__PURE__ */ f("div", { className: S, style: p.container, children: [
3492
- /* @__PURE__ */ s("h2", { style: p.title, children: o.resetTitle }),
3493
- /* @__PURE__ */ s("p", { style: p.subtitle, children: o.resetSubtitle }),
3494
- /* @__PURE__ */ f("form", { onSubmit: y.handleSubmit, style: p.form, children: [
3495
- /* @__PURE__ */ f("div", { style: p.fieldGroup, children: [
3496
- /* @__PURE__ */ s("label", { style: p.label, children: o.tokenLabel }),
3640
+ return /* @__PURE__ */ f("div", { className: k, style: h.container, children: [
3641
+ /* @__PURE__ */ s("h2", { style: h.title, children: l.resetTitle }),
3642
+ /* @__PURE__ */ s("p", { style: h.subtitle, children: l.resetSubtitle }),
3643
+ /* @__PURE__ */ f("form", { onSubmit: y.handleSubmit, style: h.form, children: [
3644
+ /* @__PURE__ */ f("div", { style: h.fieldGroup, children: [
3645
+ /* @__PURE__ */ s("label", { style: h.label, children: l.tokenLabel }),
3497
3646
  /* @__PURE__ */ s(
3498
3647
  "input",
3499
3648
  {
3500
3649
  type: "text",
3501
3650
  value: c,
3502
- onChange: ($) => {
3503
- d($.target.value), y.clearFieldError("token");
3651
+ onChange: (K) => {
3652
+ d(K.target.value), y.clearFieldError("token");
3504
3653
  },
3505
- placeholder: o.tokenPlaceholder,
3506
- style: F("token"),
3654
+ placeholder: l.tokenPlaceholder,
3655
+ style: N("token"),
3507
3656
  disabled: y.loading
3508
3657
  }
3509
3658
  )
3510
3659
  ] }),
3511
- /* @__PURE__ */ f("div", { style: p.fieldGroup, children: [
3512
- /* @__PURE__ */ s("label", { style: p.label, children: o.newPasswordLabel }),
3660
+ /* @__PURE__ */ f("div", { style: h.fieldGroup, children: [
3661
+ /* @__PURE__ */ s("label", { style: h.label, children: l.newPasswordLabel }),
3513
3662
  /* @__PURE__ */ s(
3514
3663
  "input",
3515
3664
  {
3516
3665
  type: "password",
3517
- value: A,
3518
- onChange: ($) => {
3519
- P($.target.value), y.clearFieldError("newPassword");
3666
+ value: x,
3667
+ onChange: (K) => {
3668
+ I(K.target.value), y.clearFieldError("newPassword");
3520
3669
  },
3521
- placeholder: o.newPasswordPlaceholder,
3522
- style: F("newPassword"),
3670
+ placeholder: l.newPasswordPlaceholder,
3671
+ style: N("newPassword"),
3523
3672
  disabled: y.loading
3524
3673
  }
3525
3674
  )
3526
3675
  ] }),
3527
- /* @__PURE__ */ f("div", { style: p.fieldGroup, children: [
3528
- /* @__PURE__ */ s("label", { style: p.label, children: o.confirmPasswordLabel }),
3676
+ /* @__PURE__ */ f("div", { style: h.fieldGroup, children: [
3677
+ /* @__PURE__ */ s("label", { style: h.label, children: l.confirmPasswordLabel }),
3529
3678
  /* @__PURE__ */ s(
3530
3679
  "input",
3531
3680
  {
3532
3681
  type: "password",
3533
- value: I,
3534
- onChange: ($) => {
3535
- R($.target.value), y.clearFieldError("confirmPassword"), y.error === o.passwordMismatchError && y.setError("");
3682
+ value: L,
3683
+ onChange: (K) => {
3684
+ P(K.target.value), y.clearFieldError("confirmPassword"), y.error === l.passwordMismatchError && y.setError("");
3536
3685
  },
3537
- placeholder: o.confirmPasswordPlaceholder,
3538
- style: F("confirmPassword"),
3686
+ placeholder: l.confirmPasswordPlaceholder,
3687
+ style: N("confirmPassword"),
3539
3688
  disabled: y.loading
3540
3689
  }
3541
3690
  )
3542
3691
  ] }),
3543
- /* @__PURE__ */ s("button", { type: "submit", disabled: j, style: K, children: y.loading ? o.resetLoadingText : o.resetSubmitButton }),
3544
- y.error && /* @__PURE__ */ s("div", { style: p.errorText, children: y.error }),
3545
- E && /* @__PURE__ */ s("div", { style: p.successText, children: E })
3692
+ /* @__PURE__ */ s("button", { type: "submit", disabled: z, style: Z, children: y.loading ? l.resetLoadingText : l.resetSubmitButton }),
3693
+ y.error && /* @__PURE__ */ s("div", { style: h.errorText, children: y.error }),
3694
+ R && /* @__PURE__ */ s("div", { style: h.successText, children: R })
3546
3695
  ] }),
3547
- /* @__PURE__ */ f("div", { style: p.linkContainer, children: [
3548
- /* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
3549
- h && /* @__PURE__ */ f(U, { children: [
3550
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: o.dividerBullet }),
3551
- /* @__PURE__ */ s("a", { onClick: () => h("request"), style: p.link, children: o.requestNewLinkLink })
3696
+ /* @__PURE__ */ f("div", { style: h.linkContainer, children: [
3697
+ /* @__PURE__ */ s("a", { onClick: a, style: h.link, children: l.backToLoginLink }),
3698
+ p && /* @__PURE__ */ f(U, { children: [
3699
+ /* @__PURE__ */ s("span", { style: h.modeSwitchDivider, children: l.dividerBullet }),
3700
+ /* @__PURE__ */ s("a", { onClick: () => p("request"), style: h.link, children: l.requestNewLinkLink })
3552
3701
  ] })
3553
3702
  ] })
3554
3703
  ] });
3555
3704
  }
3556
- const u = (F) => ({
3557
- ...p.input,
3558
- ...x.fieldErrors[F] ? p.inputError : {}
3559
- }), v = !k || x.loading, D = {
3560
- ...p.button,
3561
- ...x.loading ? p.buttonLoading : {},
3562
- ...v ? p.buttonDisabled : {}
3705
+ const u = (N) => ({
3706
+ ...h.input,
3707
+ ...A.fieldErrors[N] ? h.inputError : {}
3708
+ }), T = !E || A.loading, M = {
3709
+ ...h.button,
3710
+ ...A.loading ? h.buttonLoading : {},
3711
+ ...T ? h.buttonDisabled : {}
3563
3712
  };
3564
- return /* @__PURE__ */ f("div", { className: S, style: p.container, children: [
3565
- /* @__PURE__ */ s("h2", { style: p.title, children: o.title }),
3566
- /* @__PURE__ */ s("p", { style: p.subtitle, children: o.subtitle }),
3567
- /* @__PURE__ */ f("form", { onSubmit: x.handleSubmit, style: p.form, children: [
3568
- /* @__PURE__ */ f("div", { style: p.fieldGroup, children: [
3569
- /* @__PURE__ */ s("label", { style: p.label, children: o.emailLabel }),
3713
+ return /* @__PURE__ */ f("div", { className: k, style: h.container, children: [
3714
+ /* @__PURE__ */ s("h2", { style: h.title, children: l.title }),
3715
+ /* @__PURE__ */ s("p", { style: h.subtitle, children: l.subtitle }),
3716
+ /* @__PURE__ */ f("form", { onSubmit: A.handleSubmit, style: h.form, children: [
3717
+ /* @__PURE__ */ f("div", { style: h.fieldGroup, children: [
3718
+ /* @__PURE__ */ s("label", { style: h.label, children: l.emailLabel }),
3570
3719
  /* @__PURE__ */ s(
3571
3720
  "input",
3572
3721
  {
3573
3722
  type: "email",
3574
- value: k,
3575
- onChange: (F) => {
3576
- T(F.target.value), x.clearFieldError("email");
3723
+ value: E,
3724
+ onChange: (N) => {
3725
+ S(N.target.value), A.clearFieldError("email");
3577
3726
  },
3578
- placeholder: o.emailPlaceholder,
3727
+ placeholder: l.emailPlaceholder,
3579
3728
  style: u("email"),
3580
- disabled: x.loading
3729
+ disabled: A.loading
3581
3730
  }
3582
3731
  )
3583
3732
  ] }),
3584
- /* @__PURE__ */ s("button", { type: "submit", disabled: v, style: D, children: x.loading ? o.loadingText : o.submitButton }),
3585
- x.error && /* @__PURE__ */ s("div", { style: p.errorText, children: x.error }),
3586
- E && /* @__PURE__ */ s("div", { style: p.successText, children: E })
3733
+ /* @__PURE__ */ s("button", { type: "submit", disabled: T, style: M, children: A.loading ? l.loadingText : l.submitButton }),
3734
+ A.error && /* @__PURE__ */ s("div", { style: h.errorText, children: A.error }),
3735
+ R && /* @__PURE__ */ s("div", { style: h.successText, children: R })
3587
3736
  ] }),
3588
- /* @__PURE__ */ f("div", { style: p.linkContainer, children: [
3589
- /* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
3590
- h && /* @__PURE__ */ f(U, { children: [
3591
- /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: o.dividerBullet }),
3592
- /* @__PURE__ */ s("a", { onClick: () => h("reset"), style: p.link, children: o.haveTokenLink })
3737
+ /* @__PURE__ */ f("div", { style: h.linkContainer, children: [
3738
+ /* @__PURE__ */ s("a", { onClick: a, style: h.link, children: l.backToLoginLink }),
3739
+ p && /* @__PURE__ */ f(U, { children: [
3740
+ /* @__PURE__ */ s("span", { style: h.modeSwitchDivider, children: l.dividerBullet }),
3741
+ /* @__PURE__ */ s("a", { onClick: () => p("reset"), style: h.link, children: l.haveTokenLink })
3593
3742
  ] })
3594
3743
  ] })
3595
3744
  ] });
3596
3745
  }
3597
- const yr = () => /* @__PURE__ */ s(
3746
+ const Sr = () => /* @__PURE__ */ s(
3598
3747
  "div",
3599
3748
  {
3600
3749
  style: {
@@ -3606,7 +3755,7 @@ const yr = () => /* @__PURE__ */ s(
3606
3755
  },
3607
3756
  children: /* @__PURE__ */ s("div", { children: "Loading..." })
3608
3757
  }
3609
- ), br = ({ error: r, retry: e }) => /* @__PURE__ */ f(
3758
+ ), kr = ({ error: r, retry: e }) => /* @__PURE__ */ f(
3610
3759
  "div",
3611
3760
  {
3612
3761
  style: {
@@ -3640,43 +3789,43 @@ const yr = () => /* @__PURE__ */ s(
3640
3789
  ]
3641
3790
  }
3642
3791
  );
3643
- function rn({
3792
+ function ln({
3644
3793
  children: r,
3645
3794
  loadingFallback: e,
3646
3795
  errorFallback: t,
3647
3796
  requireTenant: n = !0
3648
3797
  }) {
3649
- const { isAppLoading: i, appError: a, retryApp: l } = Ae(), h = pe(), S = Oe(), k = at(), T = lt(), c = (h == null ? void 0 : h.isTenantLoading) ?? !1, d = (h == null ? void 0 : h.tenantError) ?? null, A = (h == null ? void 0 : h.tenantSlug) ?? null, P = (h == null ? void 0 : h.retryTenant) ?? (() => {
3650
- }), I = (S == null ? void 0 : S.isAuthReady) ?? !0, R = (k == null ? void 0 : k.isReady) ?? !0, E = (T == null ? void 0 : T.isReady) ?? !0, m = n && h && A, o = i || m && c || S && !I || k && !R || T && !E, p = a || (m ? d : null), x = () => {
3651
- a && l(), d && h && P();
3798
+ const { isAppLoading: i, appError: o, retryApp: a } = Ae(), p = pe(), k = qe(), E = ut(), S = dt(), c = (p == null ? void 0 : p.isTenantLoading) ?? !1, d = (p == null ? void 0 : p.tenantError) ?? null, x = (p == null ? void 0 : p.tenantSlug) ?? null, I = (p == null ? void 0 : p.retryTenant) ?? (() => {
3799
+ }), L = (k == null ? void 0 : k.isAuthReady) ?? !0, P = (E == null ? void 0 : E.isReady) ?? !0, R = (S == null ? void 0 : S.isReady) ?? !0, m = n && p && x, l = i || m && c || k && !L || E && !P || S && !R, h = o || (m ? d : null), A = () => {
3800
+ o && a(), d && p && I();
3652
3801
  };
3653
- if (o)
3654
- return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(yr, {}) });
3655
- if (p) {
3656
- const y = typeof t == "function" ? t(p, x) : t || /* @__PURE__ */ s(br, { error: p, retry: x });
3802
+ if (l)
3803
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(Sr, {}) });
3804
+ if (h) {
3805
+ const y = typeof t == "function" ? t(h, A) : t || /* @__PURE__ */ s(kr, { error: h, retry: A });
3657
3806
  return /* @__PURE__ */ s(U, { children: y });
3658
3807
  }
3659
3808
  return /* @__PURE__ */ s(U, { children: r });
3660
3809
  }
3661
- function nn(r = !0) {
3662
- const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Ae(), a = pe(), l = Oe(), h = at(), S = lt(), k = (a == null ? void 0 : a.isTenantLoading) ?? !1, T = (a == null ? void 0 : a.tenantError) ?? null, c = (a == null ? void 0 : a.tenant) ?? null, d = (a == null ? void 0 : a.tenantSlug) ?? null, A = (a == null ? void 0 : a.retryTenant) ?? (() => {
3663
- }), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (h == null ? void 0 : h.isReady) ?? !0, R = (S == null ? void 0 : S.isReady) ?? !0, E = r && a && d, C = e || E && k || l && !P || h && !I || S && !R, o = t || (E ? T : null);
3810
+ function cn(r = !0) {
3811
+ const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Ae(), o = pe(), a = qe(), p = ut(), k = dt(), E = (o == null ? void 0 : o.isTenantLoading) ?? !1, S = (o == null ? void 0 : o.tenantError) ?? null, c = (o == null ? void 0 : o.tenant) ?? null, d = (o == null ? void 0 : o.tenantSlug) ?? null, x = (o == null ? void 0 : o.retryTenant) ?? (() => {
3812
+ }), I = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (p == null ? void 0 : p.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, R = r && o && d, w = e || R && E || a && !I || p && !L || k && !P, l = t || (R ? S : null);
3664
3813
  return {
3665
- isLoading: C,
3666
- error: o,
3667
- isReady: !C && !o && i !== null && (!E || c !== null),
3814
+ isLoading: w,
3815
+ error: l,
3816
+ isReady: !w && !l && i !== null && (!R || c !== null),
3668
3817
  retry: () => {
3669
- t && n(), T && a && A();
3818
+ t && n(), S && o && x();
3670
3819
  },
3671
3820
  // Individual states
3672
3821
  app: { isLoading: e, error: t, data: i },
3673
- tenant: a ? { isLoading: k, error: T, data: c } : null,
3674
- auth: l ? { isReady: P } : null,
3675
- featureFlags: h ? { isReady: I } : null,
3676
- subscription: S ? { isReady: R } : null
3822
+ tenant: o ? { isLoading: E, error: S, data: c } : null,
3823
+ auth: a ? { isReady: I } : null,
3824
+ featureFlags: p ? { isReady: L } : null,
3825
+ subscription: k ? { isReady: P } : null
3677
3826
  };
3678
3827
  }
3679
- const wr = {
3828
+ const Er = {
3680
3829
  wrapper: {
3681
3830
  position: "relative"
3682
3831
  },
@@ -3720,89 +3869,89 @@ const wr = {
3720
3869
  marginLeft: 8
3721
3870
  }
3722
3871
  };
3723
- function sn({
3872
+ function un({
3724
3873
  tenants: r,
3725
3874
  currentTenantId: e,
3726
3875
  onSelect: t,
3727
3876
  styles: n = {},
3728
3877
  className: i = "",
3729
- dropdownClassName: a = "",
3730
- itemClassName: l = "",
3731
- renderItem: h,
3732
- placeholder: S = "Select tenant",
3733
- disabled: k = !1,
3734
- showCurrentTenant: T = !0
3878
+ dropdownClassName: o = "",
3879
+ itemClassName: a = "",
3880
+ renderItem: p,
3881
+ placeholder: k = "Select tenant",
3882
+ disabled: E = !1,
3883
+ showCurrentTenant: S = !0
3735
3884
  }) {
3736
- var C;
3737
- const c = { ...wr, ...n }, d = Oe(), [A, P] = N(!1), I = ye(null), R = r ?? (d == null ? void 0 : d.userTenants) ?? [], E = e ?? ((C = d == null ? void 0 : d.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
3738
- P(!1), t ? t(o) : d != null && d.switchToTenant && await d.switchToTenant(o);
3885
+ var w;
3886
+ const c = { ...Er, ...n }, d = qe(), [x, I] = C(!1), L = be(null), P = r ?? (d == null ? void 0 : d.userTenants) ?? [], R = e ?? ((w = d == null ? void 0 : d.currentUser) == null ? void 0 : w.tenantId) ?? null, m = async (l) => {
3887
+ I(!1), t ? t(l) : d != null && d.switchToTenant && await d.switchToTenant(l);
3739
3888
  };
3740
3889
  re(() => {
3741
- const o = (p) => {
3742
- I.current && !I.current.contains(p.target) && P(!1);
3890
+ const l = (h) => {
3891
+ L.current && !L.current.contains(h.target) && I(!1);
3743
3892
  };
3744
- return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
3893
+ return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
3745
3894
  }, []);
3746
- const g = R.find((o) => o.id === E);
3747
- if (R.length === 0)
3895
+ const g = P.find((l) => l.id === R);
3896
+ if (P.length === 0)
3748
3897
  return null;
3749
- if (R.length === 1 && T)
3750
- return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: R[0].name }) });
3751
- const b = (o, p) => /* @__PURE__ */ f("span", { style: { fontWeight: p ? "bold" : "normal" }, children: [
3752
- o.name,
3753
- o.role && /* @__PURE__ */ f("span", { style: c.itemRole, children: [
3898
+ if (P.length === 1 && S)
3899
+ return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: P[0].name }) });
3900
+ const b = (l, h) => /* @__PURE__ */ f("span", { style: { fontWeight: h ? "bold" : "normal" }, children: [
3901
+ l.name,
3902
+ l.role && /* @__PURE__ */ f("span", { style: c.itemRole, children: [
3754
3903
  "(",
3755
- o.role,
3904
+ l.role,
3756
3905
  ")"
3757
3906
  ] })
3758
3907
  ] });
3759
- return /* @__PURE__ */ f("div", { ref: I, className: i, style: c.wrapper, children: [
3908
+ return /* @__PURE__ */ f("div", { ref: L, className: i, style: c.wrapper, children: [
3760
3909
  /* @__PURE__ */ f(
3761
3910
  "button",
3762
3911
  {
3763
3912
  type: "button",
3764
- onClick: () => !k && P(!A),
3765
- disabled: k,
3913
+ onClick: () => !E && I(!x),
3914
+ disabled: E,
3766
3915
  style: {
3767
3916
  ...c.button,
3768
- ...k ? c.buttonDisabled : {}
3917
+ ...E ? c.buttonDisabled : {}
3769
3918
  },
3770
3919
  children: [
3771
- g ? g.name : S,
3772
- /* @__PURE__ */ s("span", { style: c.arrow, children: A ? "▲" : "▼" })
3920
+ g ? g.name : k,
3921
+ /* @__PURE__ */ s("span", { style: c.arrow, children: x ? "▲" : "▼" })
3773
3922
  ]
3774
3923
  }
3775
3924
  ),
3776
- A && /* @__PURE__ */ s("div", { className: a, style: c.dropdown, children: R.map((o) => {
3777
- const p = o.id === E;
3925
+ x && /* @__PURE__ */ s("div", { className: o, style: c.dropdown, children: P.map((l) => {
3926
+ const h = l.id === R;
3778
3927
  return /* @__PURE__ */ s(
3779
3928
  "div",
3780
3929
  {
3781
- className: l,
3782
- onClick: () => m(o.id),
3930
+ className: a,
3931
+ onClick: () => m(l.id),
3783
3932
  style: {
3784
3933
  ...c.item,
3785
- ...p ? c.itemSelected : {}
3934
+ ...h ? c.itemSelected : {}
3786
3935
  },
3787
- onMouseEnter: (x) => {
3788
- p || Object.assign(x.currentTarget.style, c.itemHover);
3936
+ onMouseEnter: (A) => {
3937
+ h || Object.assign(A.currentTarget.style, c.itemHover);
3789
3938
  },
3790
- onMouseLeave: (x) => {
3791
- if (!p) {
3939
+ onMouseLeave: (A) => {
3940
+ if (!h) {
3792
3941
  const y = c.item || {};
3793
3942
  Object.keys(c.itemHover || {}).forEach((u) => {
3794
- x.currentTarget.style[u] = y[u] ?? "";
3943
+ A.currentTarget.style[u] = y[u] ?? "";
3795
3944
  });
3796
3945
  }
3797
3946
  },
3798
- children: h ? h(o, p) : b(o, p)
3947
+ children: p ? p(l, h) : b(l, h)
3799
3948
  },
3800
- o.id
3949
+ l.id
3801
3950
  );
3802
3951
  }) })
3803
3952
  ] });
3804
3953
  }
3805
- class on {
3954
+ class dn {
3806
3955
  constructor(e) {
3807
3956
  this.httpService = e;
3808
3957
  }
@@ -3811,7 +3960,7 @@ class on {
3811
3960
  }
3812
3961
  async getPermissions(e) {
3813
3962
  const t = await this.httpService.get(
3814
- `/permissions/${ce(e)}`
3963
+ `/permissions/${le(e)}`
3815
3964
  );
3816
3965
  return { permissions: t.data, meta: t.meta };
3817
3966
  }
@@ -3829,13 +3978,13 @@ class on {
3829
3978
  }
3830
3979
  async getAppPermissions(e, t) {
3831
3980
  const n = await this.httpService.get(
3832
- `/permissions/apps/${e}${ce(t)}`,
3981
+ `/permissions/apps/${e}${le(t)}`,
3833
3982
  { skipAuth: !0 }
3834
3983
  );
3835
3984
  return { permissions: n.data, meta: n.meta };
3836
3985
  }
3837
3986
  }
3838
- class an {
3987
+ class hn {
3839
3988
  constructor(e) {
3840
3989
  this.httpService = e;
3841
3990
  }
@@ -3847,7 +3996,7 @@ class an {
3847
3996
  }
3848
3997
  async getSubscriptionPlans(e) {
3849
3998
  const t = await this.httpService.get(
3850
- `/subscription-plans/${ce(e)}`
3999
+ `/subscription-plans/${le(e)}`
3851
4000
  );
3852
4001
  return { plans: t.data, meta: t.meta };
3853
4002
  }
@@ -3866,7 +4015,7 @@ class an {
3866
4015
  await this.httpService.delete(`/subscription-plans/${e}`);
3867
4016
  }
3868
4017
  }
3869
- class ln {
4018
+ class pn {
3870
4019
  constructor(e) {
3871
4020
  this.httpService = e;
3872
4021
  }
@@ -3875,142 +4024,142 @@ class ln {
3875
4024
  return await this.httpService.get("/health");
3876
4025
  }
3877
4026
  }
3878
- const dt = "returnTo", Ce = "zone_return_to", De = "zone_return_to";
3879
- function cn(r = {}) {
4027
+ const ft = "returnTo", Me = "zone_return_to", $e = "zone_return_to";
4028
+ function fn(r = {}) {
3880
4029
  const {
3881
4030
  zoneRoots: e = {},
3882
- returnToParam: t = dt,
4031
+ returnToParam: t = ft,
3883
4032
  returnToStorage: n = "url"
3884
- } = r, i = vt(), [a, l] = Tt(), { isAuthenticated: h, currentUser: S } = de(), { tenant: k } = Te(), T = V(() => ({ ...ze, ...e }), [e]), c = !!k, d = S == null ? void 0 : S.userType, A = V(() => {
4033
+ } = r, i = xt(), [o, a] = Rt(), { isAuthenticated: p, currentUser: k } = ue(), { tenant: E } = Se(), S = O(() => ({ ...je, ...e }), [e]), c = !!E, d = k == null ? void 0 : k.userType, x = O(() => {
3885
4034
  switch (n) {
3886
4035
  case "url":
3887
- return a.get(t);
4036
+ return o.get(t);
3888
4037
  case "session":
3889
- return sessionStorage.getItem(Ce);
4038
+ return sessionStorage.getItem(Me);
3890
4039
  case "local":
3891
- return localStorage.getItem(De);
4040
+ return localStorage.getItem($e);
3892
4041
  default:
3893
4042
  return null;
3894
4043
  }
3895
- }, [n, a, t]), P = te(() => {
4044
+ }, [n, o, t]), I = te(() => {
3896
4045
  switch (n) {
3897
4046
  case "url": {
3898
- const m = new URLSearchParams(a);
3899
- m.delete(t), l(m, { replace: !0 });
4047
+ const m = new URLSearchParams(o);
4048
+ m.delete(t), a(m, { replace: !0 });
3900
4049
  break;
3901
4050
  }
3902
4051
  case "session":
3903
- sessionStorage.removeItem(Ce);
4052
+ sessionStorage.removeItem(Me);
3904
4053
  break;
3905
4054
  case "local":
3906
- localStorage.removeItem(De);
4055
+ localStorage.removeItem($e);
3907
4056
  break;
3908
4057
  }
3909
- }, [n, a, t, l]), I = te(
4058
+ }, [n, o, t, a]), L = te(
3910
4059
  (m) => {
3911
4060
  switch (n) {
3912
4061
  case "url": {
3913
- const g = new URLSearchParams(a);
3914
- g.set(t, m), l(g, { replace: !0 });
4062
+ const g = new URLSearchParams(o);
4063
+ g.set(t, m), a(g, { replace: !0 });
3915
4064
  break;
3916
4065
  }
3917
4066
  case "session":
3918
- sessionStorage.setItem(Ce, m);
4067
+ sessionStorage.setItem(Me, m);
3919
4068
  break;
3920
4069
  case "local":
3921
- localStorage.setItem(De, m);
4070
+ localStorage.setItem($e, m);
3922
4071
  break;
3923
4072
  }
3924
4073
  },
3925
- [n, a, t, l]
3926
- ), R = te(
4074
+ [n, o, t, a]
4075
+ ), P = te(
3927
4076
  (m) => {
3928
- const g = T[m] || T.default;
4077
+ const g = S[m] || S.default;
3929
4078
  i(g);
3930
4079
  },
3931
- [i, T]
3932
- ), E = te(() => c ? h ? d === ae.TENANT_ADMIN ? T.tenantAdmin : T.tenantUser : T.tenantGuest : h ? d === ae.TENANT_ADMIN ? T.publicAdmin : T.publicUser : T.publicGuest, [c, h, d, T]);
4080
+ [i, S]
4081
+ ), R = te(() => c ? p ? d === oe.TENANT_ADMIN ? S.tenantAdmin : S.tenantUser : S.tenantGuest : p ? d === oe.TENANT_ADMIN ? S.publicAdmin : S.publicUser : S.publicGuest, [c, p, d, S]);
3933
4082
  return {
3934
- returnToUrl: A,
3935
- clearReturnTo: P,
3936
- setReturnTo: I,
3937
- navigateToZone: R,
3938
- getSmartRedirect: E
4083
+ returnToUrl: x,
4084
+ clearReturnTo: I,
4085
+ setReturnTo: L,
4086
+ navigateToZone: P,
4087
+ getSmartRedirect: R
3939
4088
  };
3940
4089
  }
3941
- function un(r, e, t = dt, n = "url") {
4090
+ function mn(r, e, t = ft, n = "url") {
3942
4091
  if (!e || n !== "url")
3943
4092
  return r;
3944
4093
  const i = new URL(r, window.location.origin);
3945
4094
  return i.searchParams.set(t, e), i.pathname + i.search;
3946
4095
  }
3947
4096
  export {
3948
- zr as AdminZone,
3949
- Je as AppApiService,
3950
- rn as AppLoader,
3951
- kr as AppProvider,
3952
- Ct as AuthApiService,
3953
- Pr as AuthProvider,
3954
- Vr as AuthenticatedZone,
3955
- oe as ConfigurationError,
3956
- ct as DEFAULT_ZONE_PRESETS,
3957
- ze as DEFAULT_ZONE_ROOTS,
3958
- Zr as FeatureFlag,
3959
- Vt as FeatureFlagApiService,
3960
- Fr as FeatureFlagProvider,
3961
- qr as GuestZone,
3962
- ln as HealthApiService,
4097
+ Qr as AdminZone,
4098
+ Ye as AppApiService,
4099
+ ln as AppLoader,
4100
+ Pr as AppProvider,
4101
+ Bt as AuthApiService,
4102
+ Cr as AuthProvider,
4103
+ Wr as AuthenticatedZone,
4104
+ ie as ConfigurationError,
4105
+ ht as DEFAULT_ZONE_PRESETS,
4106
+ je as DEFAULT_ZONE_ROOTS,
4107
+ tn as FeatureFlag,
4108
+ Wt as FeatureFlagApiService,
4109
+ $r as FeatureFlagProvider,
4110
+ Hr as GuestZone,
4111
+ pn as HealthApiService,
3963
4112
  he as HttpService,
3964
- Br as LandingRoute,
3965
- Kr as LoginForm,
3966
- Xr as MagicLinkForm,
3967
- en as MagicLinkVerify,
3968
- Wr as OpenZone,
3969
- tn as PasswordRecoveryForm,
3970
- on as PermissionApiService,
3971
- Mr as Protected,
3972
- $r as ProtectedRoute,
3973
- Or as PublicZone,
3974
- Dt as RoleApiService,
3975
- Cr as RoutingProvider,
3976
- Z as SessionExpiredError,
3977
- Me as SessionManager,
3978
- Yr as SignupForm,
3979
- zt as SubscriptionApiService,
3980
- Jr as SubscriptionGuard,
3981
- an as SubscriptionPlanApiService,
3982
- Nr as SubscriptionProvider,
3983
- be as TenantApiService,
3984
- Gr as TenantAuthenticatedZone,
3985
- Qr as TenantGuestZone,
3986
- Hr as TenantOpenZone,
3987
- xr as TenantProvider,
3988
- Ur as TenantRoute,
3989
- sn as TenantSelector,
3990
- _r as TenantZone,
3991
- Et as TokenRefreshError,
3992
- kt as TokenRefreshTimeoutError,
3993
- Mt as UserApiService,
3994
- ae as UserType,
3995
- jr as UserZone,
3996
- ue as ZoneRoute,
3997
- un as buildRedirectUrl,
3998
- Er as useApi,
4113
+ zr as LandingRoute,
4114
+ rn as LoginForm,
4115
+ sn as MagicLinkForm,
4116
+ on as MagicLinkVerify,
4117
+ Kr as OpenZone,
4118
+ an as PasswordRecoveryForm,
4119
+ dn as PermissionApiService,
4120
+ Or as Protected,
4121
+ Vr as ProtectedRoute,
4122
+ jr as PublicZone,
4123
+ _t as RoleApiService,
4124
+ Br as RoutingProvider,
4125
+ Q as SessionExpiredError,
4126
+ Ue as SessionManager,
4127
+ nn as SignupForm,
4128
+ Qt as SubscriptionApiService,
4129
+ en as SubscriptionGuard,
4130
+ hn as SubscriptionPlanApiService,
4131
+ Ur as SubscriptionProvider,
4132
+ we as TenantApiService,
4133
+ Zr as TenantAuthenticatedZone,
4134
+ Xr as TenantGuestZone,
4135
+ Yr as TenantOpenZone,
4136
+ Lr as TenantProvider,
4137
+ qr as TenantRoute,
4138
+ un as TenantSelector,
4139
+ Gr as TenantZone,
4140
+ It as TokenRefreshError,
4141
+ Pt as TokenRefreshTimeoutError,
4142
+ Ot as UserApiService,
4143
+ oe as UserType,
4144
+ Jr as UserZone,
4145
+ ce as ZoneRoute,
4146
+ mn as buildRedirectUrl,
4147
+ Ir as useApi,
3999
4148
  Ae as useApp,
4000
- nn as useAppLoaderState,
4001
- de as useAuth,
4002
- Lr as useAuthActions,
4003
- Oe as useAuthOptional,
4004
- Ir as useAuthState,
4005
- qt as useFeatureFlags,
4006
- Dr as useRouting,
4007
- Gt as useRoutingOptional,
4008
- Rr as useSettings,
4009
- jt as useSubscription,
4010
- Te as useTenant,
4011
- ot as useTenantInfo,
4149
+ cn as useAppLoaderState,
4150
+ ue as useAuth,
4151
+ Mr as useAuthActions,
4152
+ qe as useAuthOptional,
4153
+ Dr as useAuthState,
4154
+ Ht as useFeatureFlags,
4155
+ _r as useRouting,
4156
+ Zt as useRoutingOptional,
4157
+ Nr as useSettings,
4158
+ Jt as useSubscription,
4159
+ Se as useTenant,
4160
+ ct as useTenantInfo,
4012
4161
  pe as useTenantOptional,
4013
- Ar as useTenantSettings,
4014
- cn as useZoneNavigation
4162
+ Fr as useTenantSettings,
4163
+ fn as useZoneNavigation
4015
4164
  };
4016
4165
  //# sourceMappingURL=index.es.js.map