@skylabs-digital/react-identity-access 1.6.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as n, Fragment as D, jsxs as l } from "react/jsx-runtime";
2
- import { createContext as ae, useState as p, useMemo as _, useCallback as oe, useEffect as Z, useContext as le } from "react";
3
- import { useLocation as he, Navigate as de } from "react-router-dom";
4
- class te {
1
+ import { jsx as n, Fragment as N, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as de, useMemo as Q, useState as v, useCallback as ne, useEffect as te, useContext as ue } from "react";
3
+ import { useLocation as we, Navigate as pe } from "react-router-dom";
4
+ class re {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -16,40 +16,40 @@ class te {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
18
  async executeRequest(e, t, r, s, a = !1) {
19
- const b = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, E = (s == null ? void 0 : s.timeout) || this.timeout;
20
- let L = {
19
+ const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, I = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let A = {
21
21
  "Content-Type": "application/json",
22
22
  ...s == null ? void 0 : s.headers
23
23
  };
24
24
  if (!(s != null && s.skipAuth) && this.sessionManager)
25
25
  try {
26
- const m = await this.sessionManager.getAuthHeaders();
27
- L = { ...L, ...m };
28
- } catch (m) {
29
- console.warn("Failed to inject auth headers:", m);
26
+ const b = await this.sessionManager.getAuthHeaders();
27
+ A = { ...A, ...b };
28
+ } catch (b) {
29
+ console.warn("Failed to inject auth headers:", b);
30
30
  }
31
- const P = new AbortController(), f = setTimeout(() => P.abort(), E);
31
+ const x = new AbortController(), P = setTimeout(() => x.abort(), I);
32
32
  try {
33
- const m = await fetch(b, {
33
+ const b = await fetch(p, {
34
34
  method: e,
35
- headers: L,
35
+ headers: A,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: P.signal
37
+ signal: x.signal
38
38
  });
39
- if (clearTimeout(f), m.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
39
+ if (clearTimeout(P), b.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
- const w = this.sessionManager.getTokens();
42
- if (w != null && w.refreshToken)
41
+ const h = this.sessionManager.getTokens();
42
+ if (h != null && h.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${m.status}: ${m.statusText}`);
45
+ throw new Error(`HTTP ${b.status}: ${b.statusText}`);
46
46
  }
47
- if (!m.ok)
48
- throw new Error(`HTTP ${m.status}: ${m.statusText}`);
49
- const M = m.headers.get("content-type");
50
- return !M || !M.includes("application/json") ? {} : await m.json();
51
- } catch (m) {
52
- throw clearTimeout(f), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${E}ms`) : m;
47
+ if (!b.ok)
48
+ throw new Error(`HTTP ${b.status}: ${b.statusText}`);
49
+ const m = b.headers.get("content-type");
50
+ return !m || !m.includes("application/json") ? {} : await b.json();
51
+ } catch (b) {
52
+ throw clearTimeout(P), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,7 +65,7 @@ class te {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class Te {
68
+ class be {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -124,7 +124,7 @@ class Te {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const we = ae(null), Me = () => /* @__PURE__ */ n(
127
+ const Ae = de(null), De = () => /* @__PURE__ */ n(
128
128
  "div",
129
129
  {
130
130
  style: {
@@ -136,7 +136,7 @@ const we = ae(null), Me = () => /* @__PURE__ */ n(
136
136
  },
137
137
  children: /* @__PURE__ */ n("div", { children: "Loading application..." })
138
138
  }
139
- ), Ee = ({ error: i, retry: e }) => /* @__PURE__ */ l(
139
+ ), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
140
140
  "div",
141
141
  {
142
142
  style: {
@@ -170,55 +170,113 @@ const we = ae(null), Me = () => /* @__PURE__ */ n(
170
170
  ]
171
171
  }
172
172
  );
173
- function ht({ config: i, children: e }) {
174
- const [t, r] = p(null), [s, a] = p(!0), [b, E] = p(null), L = _(() => {
175
- const f = () => {
173
+ function St({ config: i, children: e }) {
174
+ const t = Q(
175
+ () => {
176
+ var m, h, S;
177
+ return {
178
+ enabled: ((m = i.cache) == null ? void 0 : m.enabled) ?? !0,
179
+ ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
180
+ // 5 minutes default
181
+ storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `app_cache_${i.appId}`
182
+ };
183
+ },
184
+ [i.cache, i.appId]
185
+ ), [r, s] = v(() => {
186
+ if (!t.enabled) return null;
187
+ try {
188
+ const m = localStorage.getItem(t.storageKey);
189
+ if (!m) return null;
190
+ const h = JSON.parse(m);
191
+ return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
192
+ } catch {
193
+ return null;
194
+ }
195
+ }), [a, p] = v(!r), [I, A] = v(null), x = Q(() => {
196
+ const m = () => {
176
197
  P();
177
198
  };
178
199
  return {
179
200
  appId: i.appId,
180
201
  baseUrl: i.baseUrl,
181
202
  // App info
182
- appInfo: t,
183
- isAppLoading: s,
184
- appError: b,
185
- retryApp: f
203
+ appInfo: r,
204
+ isAppLoading: a,
205
+ appError: I,
206
+ retryApp: m
186
207
  };
187
- }, [i, t, s, b]), P = oe(async () => {
188
- try {
189
- a(!0), E(null);
190
- const f = new te(i.baseUrl), M = await new Te(f, {}).getPublicAppInfo(i.appId);
191
- r(M);
192
- } catch (f) {
193
- const m = f instanceof Error ? f : new Error("Failed to load app information");
194
- E(m), r(null);
195
- } finally {
196
- a(!1);
197
- }
198
- }, [i.baseUrl, i.appId]);
199
- if (Z(() => {
200
- P();
201
- }, [P]), s)
202
- return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Me, {}) });
203
- if (b) {
204
- const f = typeof i.errorFallback == "function" ? i.errorFallback(b, () => P()) : i.errorFallback || /* @__PURE__ */ n(Ee, { error: b, retry: () => P() });
205
- return /* @__PURE__ */ n(D, { children: f });
206
- }
207
- return /* @__PURE__ */ n(we.Provider, { value: L, children: e });
208
+ }, [i, r, a, I]), P = ne(
209
+ async (m = !1) => {
210
+ if (!(!m && t.enabled && r))
211
+ try {
212
+ p(!0), A(null);
213
+ const h = new re(i.baseUrl), L = await new be(h, {}).getPublicAppInfo(i.appId);
214
+ if (s(L), t.enabled)
215
+ try {
216
+ const C = {
217
+ data: L,
218
+ timestamp: Date.now(),
219
+ appId: i.appId
220
+ };
221
+ localStorage.setItem(t.storageKey, JSON.stringify(C));
222
+ } catch (C) {
223
+ console.warn("Failed to cache app info:", C);
224
+ }
225
+ } catch (h) {
226
+ const S = h instanceof Error ? h : new Error("Failed to load app information");
227
+ A(S), s(null);
228
+ } finally {
229
+ p(!1);
230
+ }
231
+ },
232
+ [i.baseUrl, i.appId, t, r]
233
+ ), b = ne(async () => {
234
+ if (!(!t.enabled || !r))
235
+ try {
236
+ const m = localStorage.getItem(t.storageKey);
237
+ if (!m) return;
238
+ const h = JSON.parse(m);
239
+ if (Date.now() - h.timestamp > t.ttl * 0.5) {
240
+ const L = new re(i.baseUrl), q = await new be(L, {}).getPublicAppInfo(i.appId);
241
+ s(q);
242
+ const k = {
243
+ data: q,
244
+ timestamp: Date.now(),
245
+ appId: i.appId
246
+ };
247
+ localStorage.setItem(t.storageKey, JSON.stringify(k));
248
+ }
249
+ } catch (m) {
250
+ console.warn("Background app refresh failed:", m);
251
+ }
252
+ }, [i, t, r]);
253
+ if (te(() => {
254
+ r ? b() : P();
255
+ }, []), a)
256
+ return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
257
+ if (I) {
258
+ const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
259
+ return /* @__PURE__ */ n(N, { children: m });
260
+ }
261
+ return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
208
262
  }
209
- function ne() {
210
- const i = le(we);
263
+ function he() {
264
+ const i = ue(Ae);
211
265
  if (!i)
212
266
  throw new Error("useApp must be used within an AppProvider");
213
267
  return i;
214
268
  }
215
- const gt = ne;
216
- class Le {
269
+ const vt = he;
270
+ class ye {
217
271
  constructor(e = {}) {
218
- this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
272
+ this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
273
+ }
274
+ // Helper to create a TokenStorage for a specific key
275
+ createTokenStorage(e) {
276
+ return {
219
277
  get: () => {
220
278
  try {
221
- const t = localStorage.getItem(this.storageKey);
279
+ const t = localStorage.getItem(e);
222
280
  return t ? JSON.parse(t) : null;
223
281
  } catch {
224
282
  return null;
@@ -226,13 +284,13 @@ class Le {
226
284
  },
227
285
  set: (t) => {
228
286
  try {
229
- localStorage.setItem(this.storageKey, JSON.stringify(t));
287
+ localStorage.setItem(e, JSON.stringify(t));
230
288
  } catch {
231
289
  }
232
290
  },
233
291
  clear: () => {
234
292
  try {
235
- localStorage.removeItem(this.storageKey);
293
+ localStorage.removeItem(e);
236
294
  } catch {
237
295
  }
238
296
  }
@@ -325,12 +383,37 @@ class Le {
325
383
  clearSession() {
326
384
  this.clearTokens(), this.clearUser();
327
385
  }
386
+ /**
387
+ * Decode JWT token and extract payload
388
+ * Returns null if token is invalid or cannot be decoded
389
+ */
390
+ getTokenPayload() {
391
+ try {
392
+ const e = this.getTokens();
393
+ if (!(e != null && e.accessToken)) return null;
394
+ const t = e.accessToken.split(".");
395
+ if (t.length !== 3) return null;
396
+ const r = t[1], s = atob(r.replace(/-/g, "+").replace(/_/g, "/"));
397
+ return JSON.parse(s);
398
+ } catch {
399
+ return null;
400
+ }
401
+ }
402
+ /**
403
+ * Get userId from token (source of truth) or fallback to stored user
404
+ */
405
+ getUserId() {
406
+ const e = this.getTokenPayload();
407
+ if (e != null && e.userId) return e.userId;
408
+ const t = this.getUser();
409
+ return (t == null ? void 0 : t.id) || null;
410
+ }
328
411
  hasValidSession() {
329
412
  const e = this.getTokens();
330
413
  return e !== null && !this.isTokenExpired(e);
331
414
  }
332
415
  }
333
- class Re {
416
+ class Ne {
334
417
  constructor(e) {
335
418
  this.httpService = e;
336
419
  }
@@ -376,7 +459,7 @@ class Re {
376
459
  });
377
460
  }
378
461
  }
379
- class pe {
462
+ class Se {
380
463
  constructor(e, t) {
381
464
  this.httpService = e, this.sessionManager = t;
382
465
  }
@@ -443,16 +526,16 @@ class pe {
443
526
  throw new Error("SessionManager is required for private endpoints");
444
527
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
445
528
  t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
446
- const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, b = await this.httpService.get(a, {
529
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(a, {
447
530
  headers: r
448
531
  });
449
532
  return {
450
- roles: b.data,
451
- meta: b.meta
533
+ roles: p.data,
534
+ meta: p.meta
452
535
  };
453
536
  }
454
537
  }
455
- class Ce {
538
+ class Be {
456
539
  constructor(e, t) {
457
540
  this.httpService = e, this.sessionManager = t;
458
541
  }
@@ -492,7 +575,7 @@ class Ce {
492
575
  });
493
576
  }
494
577
  }
495
- class fe {
578
+ class ce {
496
579
  constructor(e, t, r) {
497
580
  this.httpService = e, this.appId = t, this.sessionManager = r;
498
581
  }
@@ -570,7 +653,7 @@ class fe {
570
653
  )).data;
571
654
  }
572
655
  }
573
- const ve = ae(null), Ie = () => /* @__PURE__ */ n(
656
+ const Pe = de(null), Ue = () => /* @__PURE__ */ n(
574
657
  "div",
575
658
  {
576
659
  style: {
@@ -582,7 +665,7 @@ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
582
665
  },
583
666
  children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
584
667
  }
585
- ), Fe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
668
+ ), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
586
669
  "div",
587
670
  {
588
671
  style: {
@@ -616,77 +699,134 @@ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
616
699
  ]
617
700
  }
618
701
  );
619
- function pt({ config: i, children: e }) {
620
- const { baseUrl: t, appInfo: r, appId: s } = ne(), [a, b] = p(i.initialTenant || null), [E, L] = p(!i.initialTenant), [P, f] = p(null), [m, M] = p(null), [w, v] = p(!1), [I, g] = p(null), U = oe(() => {
621
- const S = i.tenantMode || "selector", c = "tenant";
702
+ function xt({ config: i, children: e }) {
703
+ const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
704
+ const o = i.tenantMode || "selector", g = "tenant";
622
705
  if (typeof window > "u") return null;
623
- if (S === "subdomain") {
624
- const o = window.location.hostname.split(".");
625
- if (o.length >= 3) {
626
- const d = o[0];
627
- return localStorage.setItem(c, d), d;
706
+ if (o === "subdomain") {
707
+ const d = window.location.hostname.split(".");
708
+ if (d.length >= 3) {
709
+ const c = d[0];
710
+ return localStorage.setItem(g, c), c;
628
711
  }
629
- return localStorage.getItem(c);
630
- } else if (S === "selector") {
631
- const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
632
- return o ? (localStorage.setItem(c, o), o) : localStorage.getItem(c);
712
+ return localStorage.getItem(g);
713
+ } else if (o === "selector") {
714
+ const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
715
+ return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
633
716
  }
634
717
  return null;
635
- }, [i.tenantMode, i.selectorParam]), u = _(() => U(), [U]), y = (r == null ? void 0 : r.settingsSchema) || null, x = oe(
636
- async (S) => {
718
+ }, [i.tenantMode, i.selectorParam]), [p, I] = v(() => a()), A = Q(
719
+ () => {
720
+ var o, g, f;
721
+ return {
722
+ enabled: ((o = i.cache) == null ? void 0 : o.enabled) ?? !0,
723
+ ttl: ((g = i.cache) == null ? void 0 : g.ttl) ?? 5 * 60 * 1e3,
724
+ // 5 minutes default
725
+ storageKey: ((f = i.cache) == null ? void 0 : f.storageKey) ?? `tenant_cache_${p || "default"}`
726
+ };
727
+ },
728
+ [i.cache, p]
729
+ ), [x, P] = v(() => {
730
+ if (i.initialTenant) return i.initialTenant;
731
+ if (!A.enabled || !p) return null;
732
+ try {
733
+ const o = localStorage.getItem(A.storageKey);
734
+ if (!o) return null;
735
+ const g = JSON.parse(o);
736
+ return Date.now() - g.timestamp < A.ttl && g.tenantSlug === p ? g.data : (localStorage.removeItem(A.storageKey), null);
737
+ } catch {
738
+ return null;
739
+ }
740
+ }), [b, m] = v(!x && !i.initialTenant), [h, S] = v(null), [L, C] = v(null), [q, k] = v(!1), [u, T] = v(null);
741
+ te(() => {
742
+ const o = a();
743
+ I(o);
744
+ }, [a]);
745
+ const R = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
746
+ async (o, g = !1) => {
747
+ if (!(!g && A.enabled && x && x.domain === o))
748
+ try {
749
+ m(!0), S(null);
750
+ const f = new re(t), c = await new ce(f, s).getPublicTenantInfo(o);
751
+ if (P(c), A.enabled)
752
+ try {
753
+ const y = {
754
+ data: c,
755
+ timestamp: Date.now(),
756
+ tenantSlug: o
757
+ };
758
+ localStorage.setItem(A.storageKey, JSON.stringify(y));
759
+ } catch (y) {
760
+ console.warn("Failed to cache tenant info:", y);
761
+ }
762
+ } catch (f) {
763
+ const d = f instanceof Error ? f : new Error("Failed to load tenant information");
764
+ S(d), P(null);
765
+ } finally {
766
+ m(!1);
767
+ }
768
+ },
769
+ [t, s, A, x]
770
+ ), G = ne(async () => {
771
+ if (!(!A.enabled || !x || !p))
637
772
  try {
638
- L(!0), f(null);
639
- const c = new te(t), o = await new fe(c, s).getPublicTenantInfo(S);
640
- b(o);
641
- } catch (c) {
642
- const h = c instanceof Error ? c : new Error("Failed to load tenant information");
643
- f(h), b(null);
644
- } finally {
645
- L(!1);
773
+ const o = localStorage.getItem(A.storageKey);
774
+ if (!o) return;
775
+ const g = JSON.parse(o);
776
+ if (Date.now() - g.timestamp > A.ttl * 0.5) {
777
+ const d = new re(t), y = await new ce(d, s).getPublicTenantInfo(p);
778
+ P(y);
779
+ const W = {
780
+ data: y,
781
+ timestamp: Date.now(),
782
+ tenantSlug: p
783
+ };
784
+ localStorage.setItem(A.storageKey, JSON.stringify(W));
785
+ }
786
+ } catch (o) {
787
+ console.warn("Background tenant refresh failed:", o);
646
788
  }
647
- },
648
- [t, s]
649
- ), F = oe(async () => {
650
- if (a != null && a.id)
789
+ }, [t, s, A, x, p]), F = ne(async () => {
790
+ if (x != null && x.id)
651
791
  try {
652
- v(!0), g(null);
653
- const S = new te(t), h = await new fe(S, a.appId).getTenantSettings(a.id);
654
- M(h);
655
- } catch (S) {
656
- const c = S instanceof Error ? S : new Error("Failed to load tenant settings");
657
- g(c), M(null);
792
+ k(!0), T(null);
793
+ const o = new re(t), f = await new ce(o, x.appId).getTenantSettings(x.id);
794
+ C(f);
795
+ } catch (o) {
796
+ const g = o instanceof Error ? o : new Error("Failed to load tenant settings");
797
+ T(g), C(null);
658
798
  } finally {
659
- v(!1);
799
+ k(!1);
660
800
  }
661
- }, [t, a]), B = oe(() => {
801
+ }, [t, x]), V = ne(() => {
662
802
  F();
663
- }, [F]), z = oe(
664
- (S) => {
665
- if (!y)
803
+ }, [F]), w = ne(
804
+ (o) => {
805
+ if (!R)
666
806
  return { isValid: !0, errors: [] };
667
- const c = [];
807
+ const g = [];
668
808
  try {
669
- return y.properties && Object.entries(y.properties).forEach(([h, o]) => {
670
- var G;
671
- const d = S[h];
672
- if ((G = y.required) != null && G.includes(h) && d == null) {
673
- c.push(`Field '${h}' is required`);
809
+ return R.properties && Object.entries(R.properties).forEach(([f, d]) => {
810
+ var y;
811
+ const c = o[f];
812
+ if ((y = R.required) != null && y.includes(f) && c == null) {
813
+ g.push(`Field '${f}' is required`);
674
814
  return;
675
815
  }
676
- if (d != null) {
677
- if (o.type) {
678
- const Y = o.type, H = typeof d;
679
- Y === "string" && H !== "string" ? c.push(`Field '${h}' must be a string`) : (Y === "number" || Y === "integer") && H !== "number" ? c.push(`Field '${h}' must be a number`) : Y === "boolean" && H !== "boolean" ? c.push(`Field '${h}' must be a boolean`) : Y === "array" && !Array.isArray(d) && c.push(`Field '${h}' must be an array`);
816
+ if (c != null) {
817
+ if (d.type) {
818
+ const W = d.type, ee = typeof c;
819
+ W === "string" && ee !== "string" ? g.push(`Field '${f}' must be a string`) : (W === "number" || W === "integer") && ee !== "number" ? g.push(`Field '${f}' must be a number`) : W === "boolean" && ee !== "boolean" ? g.push(`Field '${f}' must be a boolean`) : W === "array" && !Array.isArray(c) && g.push(`Field '${f}' must be an array`);
680
820
  }
681
- o.minLength !== void 0 && typeof d == "string" && d.length < o.minLength && c.push(
682
- `Field '${h}' must be at least ${o.minLength} characters long`
683
- ), o.maxLength !== void 0 && typeof d == "string" && d.length > o.maxLength && c.push(
684
- `Field '${h}' must be no more than ${o.maxLength} characters long`
685
- ), o.minimum !== void 0 && typeof d == "number" && d < o.minimum && c.push(`Field '${h}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof d == "number" && d > o.maximum && c.push(`Field '${h}' must be no more than ${o.maximum}`), o.pattern && typeof d == "string" && (new RegExp(o.pattern).test(d) || c.push(`Field '${h}' does not match the required pattern`)), o.enum && !o.enum.includes(d) && c.push(`Field '${h}' must be one of: ${o.enum.join(", ")}`);
821
+ d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && g.push(
822
+ `Field '${f}' must be at least ${d.minLength} characters long`
823
+ ), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && g.push(
824
+ `Field '${f}' must be no more than ${d.maxLength} characters long`
825
+ ), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && g.push(`Field '${f}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && g.push(`Field '${f}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || g.push(`Field '${f}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && g.push(`Field '${f}' must be one of: ${d.enum.join(", ")}`);
686
826
  }
687
827
  }), {
688
- isValid: c.length === 0,
689
- errors: c
828
+ isValid: g.length === 0,
829
+ errors: g
690
830
  };
691
831
  } catch {
692
832
  return {
@@ -695,60 +835,93 @@ function pt({ config: i, children: e }) {
695
835
  };
696
836
  }
697
837
  },
698
- [y]
838
+ [R]
699
839
  );
700
- Z(() => {
701
- !i.initialTenant && u ? x(u) : !i.initialTenant && !u && (b(null), f(null), L(!1));
702
- }, [i.initialTenant, u, x]), Z(() => {
703
- a != null && a.id ? F() : (M(null), g(null), v(!1));
704
- }, [a == null ? void 0 : a.id, F]);
705
- const q = _(() => ({
840
+ te(() => {
841
+ !i.initialTenant && p ? x ? G() : H(p) : !i.initialTenant && !p && (P(null), S(null), m(!1));
842
+ }, [i.initialTenant, p, x, H, G]), te(() => {
843
+ x != null && x.id ? F() : (C(null), T(null), k(!1));
844
+ }, [x == null ? void 0 : x.id, F]);
845
+ const M = ne(
846
+ (o, g = "reload") => {
847
+ const f = i.tenantMode || "selector";
848
+ if (console.log("[TenantProvider] Switching tenant:", {
849
+ targetTenantSlug: o,
850
+ currentTenantSlug: p,
851
+ tenantMode: f,
852
+ mode: g
853
+ }), localStorage.setItem("tenant", o), f === "subdomain") {
854
+ const d = window.location.hostname, c = d.split(".");
855
+ if (c.length >= 2) {
856
+ c[0] = o;
857
+ const y = c.join("."), W = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
858
+ console.log("[TenantProvider] Redirecting to:", W), window.location.href = W;
859
+ } else
860
+ console.warn(
861
+ "[TenantProvider] Cannot switch subdomain, invalid hostname:",
862
+ d
863
+ );
864
+ } else if (f === "selector") {
865
+ const d = new URLSearchParams(window.location.search);
866
+ if (d.set(i.selectorParam || "tenant", o), g === "reload") {
867
+ const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
868
+ console.log("[TenantProvider] Reloading with new tenant:", c), window.location.href = c;
869
+ } else {
870
+ const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
871
+ console.log("[TenantProvider] Navigating without reload:", c), window.history.pushState({}, "", c), I(o), H(o);
872
+ }
873
+ }
874
+ },
875
+ [i.tenantMode, i.selectorParam, H, p]
876
+ ), E = Q(() => ({
706
877
  // Tenant info
707
- tenant: a,
708
- tenantSlug: u,
709
- isTenantLoading: E,
710
- tenantError: P,
878
+ tenant: x,
879
+ tenantSlug: p,
880
+ isTenantLoading: b,
881
+ tenantError: h,
711
882
  retryTenant: () => {
712
- u && x(u);
883
+ p && H(p);
713
884
  },
714
885
  // Settings
715
- settings: m,
716
- settingsSchema: y,
717
- isSettingsLoading: w,
718
- settingsError: I,
886
+ settings: L,
887
+ settingsSchema: R,
888
+ isSettingsLoading: q,
889
+ settingsError: u,
719
890
  // Actions
720
- refreshSettings: B,
891
+ refreshSettings: V,
892
+ switchTenant: M,
721
893
  // Validation
722
- validateSettings: z
894
+ validateSettings: w
723
895
  }), [
724
- a,
896
+ x,
897
+ p,
898
+ b,
899
+ h,
900
+ L,
901
+ R,
902
+ q,
725
903
  u,
726
- E,
727
- P,
728
- m,
729
- y,
730
- w,
731
- I,
732
- B,
733
- z
904
+ V,
905
+ M,
906
+ w
734
907
  ]);
735
- if (E)
736
- return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Ie, {}) });
737
- if (P) {
738
- const S = typeof i.errorFallback == "function" ? i.errorFallback(P, () => x(u || "")) : i.errorFallback || /* @__PURE__ */ n(Fe, { error: P, retry: () => x(u || "") });
739
- return /* @__PURE__ */ n(D, { children: S });
908
+ if (b)
909
+ return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
910
+ if (h) {
911
+ const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
912
+ return /* @__PURE__ */ n(N, { children: o });
740
913
  }
741
- return /* @__PURE__ */ n(ve.Provider, { value: q, children: e });
914
+ return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
742
915
  }
743
- function ge() {
744
- const i = le(ve);
916
+ function fe() {
917
+ const i = ue(Pe);
745
918
  if (!i)
746
919
  throw new Error("useTenant must be used within a TenantProvider");
747
920
  return i;
748
921
  }
749
- const ft = ge;
750
- function mt() {
751
- const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = ge();
922
+ const kt = fe;
923
+ function At() {
924
+ const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
752
925
  return {
753
926
  settings: i,
754
927
  settingsSchema: e,
@@ -757,8 +930,8 @@ function mt() {
757
930
  validateSettings: s
758
931
  };
759
932
  }
760
- function re() {
761
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ge();
933
+ function se() {
934
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = fe();
762
935
  return {
763
936
  tenant: i,
764
937
  tenantSlug: e,
@@ -767,249 +940,273 @@ function re() {
767
940
  retry: s
768
941
  };
769
942
  }
770
- const Se = ae(null);
771
- function yt({ config: i = {}, children: e }) {
772
- const { appId: t, baseUrl: r } = ne(), s = re(), a = (s == null ? void 0 : s.tenantSlug) || null, [b, E] = p(i.initialRoles || []), [L, P] = p(!i.initialRoles), [f, m] = p(null), [M, w] = p(!1), [v, I] = p(null), g = _(() => {
773
- const S = a ? `auth_tokens_${a}` : "auth_tokens", c = {
774
- get: () => {
775
- try {
776
- const h = localStorage.getItem(S);
777
- return h ? JSON.parse(h) : null;
778
- } catch {
779
- return null;
780
- }
781
- },
782
- set: (h) => {
783
- try {
784
- localStorage.setItem(S, JSON.stringify(h));
785
- } catch {
786
- }
787
- },
788
- clear: () => {
789
- try {
790
- localStorage.removeItem(S);
791
- } catch {
792
- }
793
- }
794
- };
795
- return new Le({
796
- onRefreshFailed: i.onRefreshFailed,
797
- tokenStorage: c,
798
- baseUrl: r
799
- });
800
- }, [a, r, i.onRefreshFailed]), U = _(() => {
801
- const S = new te(r);
802
- return S.setSessionManager(g), S;
803
- }, [r, g]), u = _(() => new Re(new te(r)), [r]), y = _(() => new Ce(U, g), [U, g]), x = _(() => new pe(new te(r)), [r]), F = _(() => f || g.getUser(), [f, g]), B = _(() => F != null && F.roleId && b.find((S) => S.id === F.roleId) || null, [F, b]), z = _(() => (B == null ? void 0 : B.permissions) || [], [B]);
804
- Z(() => {
805
- console.log("AuthProvider - userPermissions changed:", z);
806
- }, [z]);
807
- const q = _(() => {
808
- const S = async () => {
943
+ const Te = de(null);
944
+ function Pt({ config: i = {}, children: e }) {
945
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: a, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, P] = v(!i.initialRoles), [b, m] = v(null), [h, S] = v(!1), [L, C] = v(null), [q, k] = v(0), u = Q(() => new ye({
946
+ tenantSlug: a,
947
+ // SessionManager will generate storageKey internally
948
+ onRefreshFailed: i.onRefreshFailed,
949
+ baseUrl: r
950
+ }), [a, r, i.onRefreshFailed]), T = Q(() => {
951
+ const g = new re(r);
952
+ return g.setSessionManager(u), g;
953
+ }, [r, u]), R = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(T, u), [T, u]), G = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, o = Q(() => {
954
+ const g = async ($ = !1) => {
809
955
  try {
810
- w(!0), I(null);
811
- const A = g.getUser();
812
- if (!(A != null && A.id))
813
- throw new Error("No user ID available in session");
814
- const $ = await y.getUserById(A.id);
815
- m($), g.setUser($);
816
- } catch (A) {
817
- const $ = A instanceof Error ? A : new Error("Failed to load user data");
818
- I($), console.error("Failed to load user data:", $);
956
+ if (!u.hasValidSession())
957
+ return;
958
+ const U = Date.now();
959
+ if (!$ && U - q < E && b)
960
+ return;
961
+ const j = u.getUserId();
962
+ if (!j) {
963
+ console.warn("[AuthProvider] No userId available in token or storage");
964
+ return;
965
+ }
966
+ S(!0), C(null);
967
+ const X = await H.getUserById(j);
968
+ m(X), u.setUser(X), k(Date.now());
969
+ } catch (U) {
970
+ const K = U instanceof Error ? U : new Error("Failed to load user data");
971
+ C(K), console.error("[AuthProvider] Failed to load user data:", K);
819
972
  } finally {
820
- w(!1);
973
+ S(!1);
821
974
  }
822
- }, c = async () => {
823
- await S();
824
- }, h = async (A, $, Q, X) => {
825
- const W = await u.login({
826
- username: A,
827
- password: $,
828
- appId: Q,
975
+ }, f = async () => {
976
+ await g();
977
+ }, d = async ($) => {
978
+ const { username: U, password: K, tenantSlug: j } = $;
979
+ let X = s == null ? void 0 : s.id, Y = a, Z = u;
980
+ j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
981
+ const J = await R.login({
982
+ username: U,
983
+ password: K,
984
+ appId: t,
829
985
  tenantId: X
830
- });
831
- if (g.setTokens({
832
- accessToken: W.accessToken,
833
- refreshToken: W.refreshToken,
834
- expiresIn: W.expiresIn
835
- }), W.user) {
836
- g.setUser(W.user), m(W.user);
986
+ }), ae = j && j !== a;
987
+ if (ae && (Z = new ye({
988
+ tenantSlug: Y,
989
+ baseUrl: r
990
+ })), Z.setTokens({
991
+ accessToken: J.accessToken,
992
+ refreshToken: J.refreshToken,
993
+ expiresIn: J.expiresIn
994
+ }), J.user) {
995
+ Z.setUser(J.user), m(J.user);
837
996
  try {
838
- await S();
839
- } catch (ee) {
840
- console.warn("Failed to load complete user data after login:", ee);
997
+ await g();
998
+ } catch (le) {
999
+ console.warn("Failed to load complete user data after login:", le);
841
1000
  }
842
1001
  }
843
- return W;
844
- }, o = async (A, $, Q, X, W, ee, ce) => {
845
- if (!A && !$)
1002
+ return ae && Y && Y !== a && p(Y), J;
1003
+ }, c = async ($) => {
1004
+ const { email: U, phoneNumber: K, name: j, password: X, lastName: Y, tenantId: Z } = $;
1005
+ if (!U && !K)
846
1006
  throw new Error("Either email or phoneNumber is required");
847
- if (!Q || !X)
1007
+ if (!j || !X)
848
1008
  throw new Error("Name and password are required");
849
- return await u.signup({
850
- email: A,
851
- phoneNumber: $,
852
- name: Q,
1009
+ const J = Z ?? (s == null ? void 0 : s.id);
1010
+ return await R.signup({
1011
+ email: U,
1012
+ phoneNumber: K,
1013
+ name: j,
853
1014
  password: X,
854
- tenantId: W,
855
- lastName: ee,
856
- appId: ce
1015
+ tenantId: J,
1016
+ lastName: Y,
1017
+ appId: t
857
1018
  });
858
- }, d = async (A, $, Q, X, W, ee, ce) => {
859
- if (!A && !$)
1019
+ }, y = async ($) => {
1020
+ const { email: U, phoneNumber: K, name: j, password: X, tenantName: Y, lastName: Z } = $;
1021
+ if (!U && !K)
860
1022
  throw new Error("Either email or phoneNumber is required");
861
- if (!Q || !X || !W)
1023
+ if (!j || !X || !Y)
862
1024
  throw new Error("Name, password, and tenantName are required");
863
- return await u.signupTenantAdmin({
864
- email: A,
865
- phoneNumber: $,
866
- name: Q,
1025
+ return await R.signupTenantAdmin({
1026
+ email: U,
1027
+ phoneNumber: K,
1028
+ name: j,
867
1029
  password: X,
868
- tenantName: W,
869
- appId: ce,
870
- lastName: ee
1030
+ tenantName: Y,
1031
+ appId: t,
1032
+ lastName: Z
871
1033
  });
872
- }, G = async (A, $) => {
873
- const Q = await g.getAuthHeaders();
874
- await u.changePassword({ currentPassword: A, newPassword: $ }, Q);
875
- }, Y = async (A, $) => {
876
- await u.requestPasswordReset({ email: A, tenantId: $ });
877
- }, H = async (A, $) => {
878
- await u.confirmPasswordReset({ token: A, newPassword: $ });
879
- }, C = async (A, $, Q, X, W, ee) => await u.sendMagicLink({
880
- email: A,
881
- tenantId: $,
882
- frontendUrl: Q,
883
- name: X,
884
- lastName: W,
885
- appId: ee
886
- }), k = async (A, $, Q, X) => {
887
- const W = await u.verifyMagicLink({
888
- token: A,
889
- email: $,
890
- appId: Q,
891
- tenantId: X
1034
+ }, W = async ($) => {
1035
+ const { currentPassword: U, newPassword: K } = $, j = await u.getAuthHeaders();
1036
+ await R.changePassword({ currentPassword: U, newPassword: K }, j);
1037
+ }, ee = async ($) => {
1038
+ const { email: U, tenantId: K } = $, j = K ?? (s == null ? void 0 : s.id);
1039
+ if (!j)
1040
+ throw new Error("tenantId is required for password reset");
1041
+ await R.requestPasswordReset({ email: U, tenantId: j });
1042
+ }, z = async ($) => {
1043
+ const { token: U, newPassword: K } = $;
1044
+ await R.confirmPasswordReset({ token: U, newPassword: K });
1045
+ }, B = async ($) => {
1046
+ const { email: U, frontendUrl: K, name: j, lastName: X, tenantId: Y } = $, Z = Y ?? (s == null ? void 0 : s.id);
1047
+ if (!Z)
1048
+ throw new Error("tenantId is required for magic link authentication");
1049
+ return await R.sendMagicLink({
1050
+ email: U,
1051
+ tenantId: Z,
1052
+ frontendUrl: K,
1053
+ name: j,
1054
+ lastName: X,
1055
+ appId: t
892
1056
  });
893
- if (g.setTokens({
894
- accessToken: W.accessToken,
895
- refreshToken: W.refreshToken,
896
- expiresIn: W.expiresIn
897
- }), W.user) {
898
- g.setUser(W.user), m(W.user);
1057
+ }, O = async ($) => {
1058
+ const { token: U, email: K, tenantSlug: j } = $;
1059
+ let X = s == null ? void 0 : s.id, Y = a, Z = u;
1060
+ j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
1061
+ const J = await R.verifyMagicLink({
1062
+ token: U,
1063
+ email: K,
1064
+ appId: t,
1065
+ tenantId: X
1066
+ }), ae = j && j !== a;
1067
+ if (ae && (Z = new ye({
1068
+ tenantSlug: Y,
1069
+ baseUrl: r
1070
+ })), Z.setTokens({
1071
+ accessToken: J.accessToken,
1072
+ refreshToken: J.refreshToken,
1073
+ expiresIn: J.expiresIn
1074
+ }), J.user) {
1075
+ Z.setUser(J.user), m(J.user);
899
1076
  try {
900
- await S();
901
- } catch (ee) {
902
- console.warn("Failed to load complete user data after magic link login:", ee);
1077
+ await g();
1078
+ } catch (le) {
1079
+ console.warn("Failed to load complete user data after magic link login:", le);
903
1080
  }
904
1081
  }
905
- return W;
906
- }, T = async () => {
907
- const A = g.getTokens();
908
- if (!(A != null && A.refreshToken))
1082
+ return ae && Y && Y !== a && p(Y), J;
1083
+ }, D = async () => {
1084
+ const $ = u.getTokens();
1085
+ if (!($ != null && $.refreshToken))
909
1086
  throw new Error("No refresh token available");
910
- const $ = await u.refreshToken({
911
- refreshToken: A.refreshToken
1087
+ const U = await R.refreshToken({
1088
+ refreshToken: $.refreshToken
912
1089
  });
913
- g.setTokens({
914
- accessToken: $.accessToken,
915
- refreshToken: $.refreshToken || A.refreshToken,
916
- expiresIn: $.expiresIn
1090
+ u.setTokens({
1091
+ accessToken: U.accessToken,
1092
+ refreshToken: U.refreshToken || $.refreshToken,
1093
+ expiresIn: U.expiresIn
917
1094
  });
918
- }, J = () => {
919
- g.clearSession(), m(null), I(null);
920
- }, O = (A) => {
921
- g.setTokens(A);
922
- }, j = () => g.hasValidSession(), N = () => {
923
- g.clearSession(), m(null), I(null);
924
- }, K = async () => {
1095
+ }, _ = () => {
1096
+ u.clearSession(), m(null), C(null);
1097
+ }, ge = ($) => {
1098
+ u.setTokens($);
1099
+ }, Re = () => u.hasValidSession(), Ce = () => {
1100
+ u.clearSession(), m(null), C(null);
1101
+ }, Le = async () => {
925
1102
  if (t)
926
1103
  try {
927
1104
  P(!0);
928
- const { roles: A } = await x.getRolesByApp(t);
929
- E(A);
930
- } catch (A) {
931
- console.error("Failed to fetch roles:", A);
1105
+ const { roles: $ } = await G.getRolesByApp(t);
1106
+ A($);
1107
+ } catch ($) {
1108
+ console.error("Failed to fetch roles:", $);
932
1109
  } finally {
933
1110
  P(!1);
934
1111
  }
935
- }, R = async () => {
936
- await K();
937
- }, V = (A) => {
938
- if (!z || z.length === 0)
1112
+ }, Fe = async () => {
1113
+ await Le();
1114
+ }, me = ($) => {
1115
+ if (!w || w.length === 0)
939
1116
  return !1;
940
- if (typeof A == "string")
941
- return z.includes(A);
942
- const $ = `${A.resource}.${A.action}`;
943
- return z.includes($);
1117
+ if (typeof $ == "string")
1118
+ return w.includes($);
1119
+ const U = `${$.resource}.${$.action}`;
1120
+ return w.includes(U);
944
1121
  };
945
1122
  return {
946
- sessionManager: g,
947
- authenticatedHttpService: U,
948
- login: h,
949
- signup: o,
950
- signupTenantAdmin: d,
951
- sendMagicLink: C,
952
- verifyMagicLink: k,
953
- changePassword: G,
954
- requestPasswordReset: Y,
955
- confirmPasswordReset: H,
956
- refreshToken: T,
957
- logout: J,
958
- setTokens: O,
959
- hasValidSession: j,
960
- clearSession: N,
961
- currentUser: f,
962
- isUserLoading: M,
963
- userError: v,
964
- refreshUser: c,
965
- userRole: B,
966
- userPermissions: z,
967
- availableRoles: b,
968
- rolesLoading: L,
969
- hasPermission: V,
970
- hasAnyPermission: (A) => A.some(($) => V($)),
971
- hasAllPermissions: (A) => A.every(($) => V($)),
972
- getUserPermissionStrings: () => z || [],
973
- refreshRoles: R
1123
+ // RFC-003: Authentication state
1124
+ isAuthenticated: M,
1125
+ sessionManager: u,
1126
+ authenticatedHttpService: T,
1127
+ login: d,
1128
+ signup: c,
1129
+ signupTenantAdmin: y,
1130
+ sendMagicLink: B,
1131
+ verifyMagicLink: O,
1132
+ changePassword: W,
1133
+ requestPasswordReset: ee,
1134
+ confirmPasswordReset: z,
1135
+ refreshToken: D,
1136
+ logout: _,
1137
+ setTokens: ge,
1138
+ hasValidSession: Re,
1139
+ clearSession: Ce,
1140
+ currentUser: b,
1141
+ isUserLoading: h,
1142
+ userError: L,
1143
+ loadUserData: g,
1144
+ refreshUser: f,
1145
+ userRole: V,
1146
+ userPermissions: w,
1147
+ availableRoles: I,
1148
+ rolesLoading: x,
1149
+ hasPermission: me,
1150
+ hasAnyPermission: ($) => $.some((U) => me(U)),
1151
+ hasAllPermissions: ($) => $.every((U) => me(U)),
1152
+ getUserPermissionStrings: () => w || [],
1153
+ refreshRoles: Fe
974
1154
  };
975
1155
  }, [
976
- g,
977
- U,
1156
+ M,
978
1157
  u,
979
- y,
980
- x,
1158
+ T,
1159
+ R,
1160
+ H,
1161
+ G,
981
1162
  t,
1163
+ s,
1164
+ a,
1165
+ p,
1166
+ I,
982
1167
  b,
983
- f,
984
- M,
985
- v,
986
- B,
987
- z
1168
+ h,
1169
+ L,
1170
+ V,
1171
+ w,
1172
+ q,
1173
+ E
988
1174
  ]);
989
- return Z(() => {
1175
+ return te(() => {
990
1176
  !i.initialRoles && t && (async () => {
991
1177
  try {
992
1178
  P(!0);
993
- const c = new te(r), h = new pe(c), { roles: o } = await h.getRolesByApp(t);
994
- E(o);
995
- } catch (c) {
996
- console.error("Failed to fetch roles:", c);
1179
+ const f = new re(r), d = new Se(f), { roles: c } = await d.getRolesByApp(t);
1180
+ A(c);
1181
+ } catch (f) {
1182
+ console.error("Failed to fetch roles:", f);
997
1183
  } finally {
998
1184
  P(!1);
999
1185
  }
1000
1186
  })();
1001
- }, [t, r, i.initialRoles]), Z(() => {
1002
- const S = g.getUser();
1003
- S && g.hasValidSession() && m(S);
1004
- }, [g]), /* @__PURE__ */ n(Se.Provider, { value: q, children: e });
1187
+ }, [t, r, i.initialRoles]), te(() => {
1188
+ const g = u.getUser();
1189
+ g && u.hasValidSession() && m(g);
1190
+ }, [u]), te(() => {
1191
+ !b && !h && o.loadUserData().catch(() => {
1192
+ });
1193
+ }, [b, h, o]), te(() => {
1194
+ if (!u.hasValidSession() || !b)
1195
+ return;
1196
+ const g = setInterval(() => {
1197
+ o.loadUserData().catch(() => {
1198
+ });
1199
+ }, E);
1200
+ return () => clearInterval(g);
1201
+ }, [u, b, o, E]), /* @__PURE__ */ n(Te.Provider, { value: o, children: e });
1005
1202
  }
1006
- function ie() {
1007
- const i = le(Se);
1203
+ function oe() {
1204
+ const i = ue(Te);
1008
1205
  if (!i)
1009
1206
  throw new Error("useAuth must be used within an AuthProvider");
1010
1207
  return i;
1011
1208
  }
1012
- class He {
1209
+ class ze {
1013
1210
  constructor(e, t) {
1014
1211
  this.httpService = e, this.sessionManager = t;
1015
1212
  }
@@ -1089,58 +1286,58 @@ class He {
1089
1286
  })).data;
1090
1287
  }
1091
1288
  }
1092
- const xe = ae(null);
1093
- function bt({ config: i = {}, children: e }) {
1094
- const { baseUrl: t, appId: r } = ne(), { tenant: s } = re(), [a, b] = p([]), [E, L] = p(!1), [P, f] = p(null), m = _(() => {
1095
- const v = new te(t);
1096
- return new He(v);
1097
- }, [t]), M = async () => {
1289
+ const Me = de(null);
1290
+ function Tt({ config: i = {}, children: e }) {
1291
+ const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [a, p] = v([]), [I, A] = v(!1), [x, P] = v(null), b = Q(() => {
1292
+ const S = new re(t);
1293
+ return new ze(S);
1294
+ }, [t]), m = async () => {
1098
1295
  if (!(s != null && s.id)) {
1099
- b([]);
1296
+ p([]);
1100
1297
  return;
1101
1298
  }
1102
- L(!0), f(null);
1299
+ A(!0), P(null);
1103
1300
  try {
1104
- const v = await m.getTenantFeatureFlags(s.id, r);
1105
- b(v);
1106
- } catch (v) {
1107
- const I = v instanceof Error ? v.message : "Failed to fetch feature flags";
1108
- f(I), i.onError && i.onError(v instanceof Error ? v : new Error(I));
1301
+ const S = await b.getTenantFeatureFlags(s.id, r);
1302
+ p(S);
1303
+ } catch (S) {
1304
+ const L = S instanceof Error ? S.message : "Failed to fetch feature flags";
1305
+ P(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
1109
1306
  } finally {
1110
- L(!1);
1307
+ A(!1);
1111
1308
  }
1112
1309
  };
1113
- Z(() => {
1114
- M();
1115
- const v = i.refreshInterval || 5 * 60 * 1e3, I = setInterval(M, v);
1116
- return () => clearInterval(I);
1310
+ te(() => {
1311
+ m();
1312
+ const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(m, S);
1313
+ return () => clearInterval(L);
1117
1314
  }, [s == null ? void 0 : s.id, i.refreshInterval]);
1118
- const w = _(() => ({
1315
+ const h = Q(() => ({
1119
1316
  featureFlags: a,
1120
- loading: E,
1121
- error: P,
1122
- isEnabled: (u) => {
1123
- const y = a.find((x) => x.key === u);
1124
- return (y == null ? void 0 : y.value) === !0;
1317
+ loading: I,
1318
+ error: x,
1319
+ isEnabled: (k) => {
1320
+ const u = a.find((T) => T.key === k);
1321
+ return (u == null ? void 0 : u.value) === !0;
1125
1322
  },
1126
- getFlag: (u) => a.find((y) => y.key === u),
1127
- getFlagState: (u) => {
1128
- const y = a.find((x) => x.key === u);
1129
- return y ? y.value ? "enabled" : "disabled" : "not_found";
1323
+ getFlag: (k) => a.find((u) => u.key === k),
1324
+ getFlagState: (k) => {
1325
+ const u = a.find((T) => T.key === k);
1326
+ return u ? u.value ? "enabled" : "disabled" : "not_found";
1130
1327
  },
1131
1328
  refresh: async () => {
1132
- await M();
1329
+ await m();
1133
1330
  }
1134
- }), [a, E, P]);
1135
- return /* @__PURE__ */ n(xe.Provider, { value: w, children: e });
1331
+ }), [a, I, x]);
1332
+ return /* @__PURE__ */ n(Me.Provider, { value: h, children: e });
1136
1333
  }
1137
- function $e() {
1138
- const i = le(xe);
1334
+ function Oe() {
1335
+ const i = ue(Me);
1139
1336
  if (!i)
1140
1337
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1141
1338
  return i;
1142
1339
  }
1143
- class De {
1340
+ class je {
1144
1341
  constructor(e, t) {
1145
1342
  this.httpService = e, this.sessionManager = t;
1146
1343
  }
@@ -1206,64 +1403,64 @@ class De {
1206
1403
  )).data;
1207
1404
  }
1208
1405
  }
1209
- const ke = ae(void 0);
1210
- function wt({ config: i = {}, children: e }) {
1211
- const { baseUrl: t } = ne(), { tenant: r } = re(), [s, a] = p(null), [b, E] = p(!1), [L, P] = p(null), f = _(() => {
1212
- const w = new te(t);
1213
- return new De(w);
1214
- }, [t]), m = async () => {
1406
+ const Ie = de(void 0);
1407
+ function Mt({ config: i = {}, children: e }) {
1408
+ const { baseUrl: t } = he(), { tenant: r } = se(), [s, a] = v(null), [p, I] = v(!1), [A, x] = v(null), P = Q(() => {
1409
+ const h = new re(t);
1410
+ return new je(h);
1411
+ }, [t]), b = async () => {
1215
1412
  if (!(r != null && r.id)) {
1216
1413
  a(null);
1217
1414
  return;
1218
1415
  }
1219
- E(!0), P(null);
1416
+ I(!0), x(null);
1220
1417
  try {
1221
- const w = await f.getTenantSubscriptionFeatures(r.id);
1222
- a(w);
1223
- } catch (w) {
1224
- const v = w instanceof Error ? w.message : "Failed to fetch subscription";
1225
- P(v), i.onError && i.onError(w instanceof Error ? w : new Error(v));
1418
+ const h = await P.getTenantSubscriptionFeatures(r.id);
1419
+ a(h);
1420
+ } catch (h) {
1421
+ const S = h instanceof Error ? h.message : "Failed to fetch subscription";
1422
+ x(S), i.onError && i.onError(h instanceof Error ? h : new Error(S));
1226
1423
  } finally {
1227
- E(!1);
1424
+ I(!1);
1228
1425
  }
1229
1426
  };
1230
- Z(() => {
1231
- if (m(), !i.refreshInterval) return;
1232
- const w = i.refreshInterval || 10 * 60 * 1e3, v = setInterval(m, w);
1233
- return () => clearInterval(v);
1427
+ te(() => {
1428
+ if (b(), !i.refreshInterval) return;
1429
+ const h = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(b, h);
1430
+ return () => clearInterval(S);
1234
1431
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1235
- const M = _(() => {
1236
- const w = (s == null ? void 0 : s.features) || [];
1432
+ const m = Q(() => {
1433
+ const h = (s == null ? void 0 : s.features) || [];
1237
1434
  return {
1238
1435
  subscription: s,
1239
- features: w,
1240
- loading: b,
1241
- error: L,
1242
- isFeatureEnabled: (y) => {
1243
- const x = w.find((F) => F.key === y);
1244
- return x ? x.type === "BOOLEAN" || x.type === "boolean" ? x.value === !0 : !!x.value : !1;
1436
+ features: h,
1437
+ loading: p,
1438
+ error: A,
1439
+ isFeatureEnabled: (u) => {
1440
+ const T = h.find((R) => R.key === u);
1441
+ return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
1245
1442
  },
1246
- getFeature: (y) => w.find((x) => x.key === y),
1247
- getFeatureValue: (y, x) => {
1248
- const F = w.find((B) => B.key === y);
1249
- return F ? F.value : x;
1443
+ getFeature: (u) => h.find((T) => T.key === u),
1444
+ getFeatureValue: (u, T) => {
1445
+ const R = h.find((H) => H.key === u);
1446
+ return R ? R.value : T;
1250
1447
  },
1251
- hasAllowedPlan: (y) => !s || !s.isActive ? !1 : y.includes(s.planId),
1448
+ hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
1252
1449
  refresh: async () => {
1253
- await m();
1450
+ await b();
1254
1451
  }
1255
1452
  };
1256
- }, [s, b, L]);
1257
- return /* @__PURE__ */ n(ke.Provider, { value: M, children: e });
1453
+ }, [s, p, A]);
1454
+ return /* @__PURE__ */ n(Ie.Provider, { value: m, children: e });
1258
1455
  }
1259
- function Be() {
1260
- const i = le(ke);
1456
+ function Ve() {
1457
+ const i = ue(Ie);
1261
1458
  if (i === void 0)
1262
1459
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1263
1460
  return i;
1264
1461
  }
1265
- var se = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(se || {});
1266
- const me = () => /* @__PURE__ */ l(
1462
+ var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
1463
+ const ve = () => /* @__PURE__ */ l(
1267
1464
  "div",
1268
1465
  {
1269
1466
  style: {
@@ -1300,7 +1497,7 @@ const me = () => /* @__PURE__ */ l(
1300
1497
  )
1301
1498
  ]
1302
1499
  }
1303
- ), ye = ({
1500
+ ), xe = ({
1304
1501
  userType: i,
1305
1502
  minUserType: e,
1306
1503
  missingPermissions: t
@@ -1322,7 +1519,7 @@ const me = () => /* @__PURE__ */ l(
1322
1519
  children: [
1323
1520
  /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1324
1521
  /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1325
- e && i ? /* @__PURE__ */ l(D, { children: [
1522
+ e && i ? /* @__PURE__ */ l(N, { children: [
1326
1523
  /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1327
1524
  "This content requires ",
1328
1525
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1332,7 +1529,7 @@ const me = () => /* @__PURE__ */ l(
1332
1529
  "Your current access level: ",
1333
1530
  /* @__PURE__ */ n("strong", { children: i })
1334
1531
  ] })
1335
- ] }) : /* @__PURE__ */ l(D, { children: [
1532
+ ] }) : /* @__PURE__ */ l(N, { children: [
1336
1533
  /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1337
1534
  t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1338
1535
  "Required permissions: ",
@@ -1341,36 +1538,36 @@ const me = () => /* @__PURE__ */ l(
1341
1538
  ] })
1342
1539
  ]
1343
1540
  }
1344
- ), Ne = (i, e) => {
1541
+ ), We = (i, e) => {
1345
1542
  const t = {
1346
- [se.USER]: 1,
1347
- [se.TENANT_ADMIN]: 2,
1348
- [se.SUPERUSER]: 3
1543
+ [ie.USER]: 1,
1544
+ [ie.TENANT_ADMIN]: 2,
1545
+ [ie.SUPERUSER]: 3
1349
1546
  };
1350
1547
  return t[i] >= t[e];
1351
1548
  };
1352
- function vt({
1549
+ function It({
1353
1550
  children: i,
1354
1551
  fallback: e,
1355
1552
  minUserType: t,
1356
1553
  requiredPermissions: r,
1357
1554
  requireAllPermissions: s = !1
1358
1555
  }) {
1359
- const { hasValidSession: a, sessionManager: b, hasPermission: E, hasAnyPermission: L, hasAllPermissions: P } = ie();
1556
+ const { hasValidSession: a, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
1360
1557
  if (!a())
1361
- return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1362
- const f = b.getUser();
1363
- if (!f)
1364
- return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1365
- if (t && !Ne(f.userType, t))
1366
- return /* @__PURE__ */ n(ye, { userType: f.userType, minUserType: t });
1367
- if (r && r.length > 0 && !(s ? P(r) : L(r))) {
1368
- const M = r.filter((w) => !E(w)).map((w) => typeof w == "string" ? w : w.name);
1369
- return /* @__PURE__ */ n(ye, { missingPermissions: M });
1370
- }
1371
- return /* @__PURE__ */ n(D, { children: i });
1558
+ return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1559
+ const P = p.getUser();
1560
+ if (!P)
1561
+ return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1562
+ if (t && !We(P.userType, t))
1563
+ return /* @__PURE__ */ n(xe, { userType: P.userType, minUserType: t });
1564
+ if (r && r.length > 0 && !(s ? x(r) : A(r))) {
1565
+ const m = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
1566
+ return /* @__PURE__ */ n(xe, { missingPermissions: m });
1567
+ }
1568
+ return /* @__PURE__ */ n(N, { children: i });
1372
1569
  }
1373
- const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1570
+ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
1374
1571
  "div",
1375
1572
  {
1376
1573
  style: {
@@ -1406,7 +1603,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1406
1603
  }
1407
1604
  )
1408
1605
  }
1409
- ), be = ({
1606
+ ), ke = ({
1410
1607
  userType: i,
1411
1608
  minUserType: e,
1412
1609
  missingPermissions: t
@@ -1436,7 +1633,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1436
1633
  children: [
1437
1634
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1438
1635
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1439
- e && i ? /* @__PURE__ */ l(D, { children: [
1636
+ e && i ? /* @__PURE__ */ l(N, { children: [
1440
1637
  /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1441
1638
  "This page requires ",
1442
1639
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1446,7 +1643,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1446
1643
  "Your current access level: ",
1447
1644
  /* @__PURE__ */ n("strong", { children: i })
1448
1645
  ] })
1449
- ] }) : /* @__PURE__ */ l(D, { children: [
1646
+ ] }) : /* @__PURE__ */ l(N, { children: [
1450
1647
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1451
1648
  t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1452
1649
  "Required permissions: ",
@@ -1457,15 +1654,15 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1457
1654
  }
1458
1655
  )
1459
1656
  }
1460
- ), Ue = (i, e) => {
1657
+ ), Ke = (i, e) => {
1461
1658
  const t = {
1462
- [se.USER]: 1,
1463
- [se.TENANT_ADMIN]: 2,
1464
- [se.SUPERUSER]: 3
1659
+ [ie.USER]: 1,
1660
+ [ie.TENANT_ADMIN]: 2,
1661
+ [ie.SUPERUSER]: 3
1465
1662
  };
1466
1663
  return t[i] >= t[e];
1467
1664
  };
1468
- function St({
1665
+ function Et({
1469
1666
  children: i,
1470
1667
  redirectTo: e = "/login",
1471
1668
  minUserType: t,
@@ -1473,24 +1670,24 @@ function St({
1473
1670
  requireAllPermissions: s = !1,
1474
1671
  fallback: a
1475
1672
  }) {
1476
- const { hasValidSession: b, sessionManager: E, hasPermission: L, hasAnyPermission: P, hasAllPermissions: f } = ie(), m = he();
1477
- if (!b())
1478
- return a ? /* @__PURE__ */ n(D, { children: a }) : /* @__PURE__ */ l(D, { children: [
1479
- /* @__PURE__ */ n(qe, { redirectPath: e }),
1480
- /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 })
1673
+ const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: P } = oe(), b = we();
1674
+ if (!p())
1675
+ return a ? /* @__PURE__ */ n(N, { children: a }) : /* @__PURE__ */ l(N, { children: [
1676
+ /* @__PURE__ */ n(Ge, { redirectPath: e }),
1677
+ /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
1481
1678
  ] });
1482
- const M = E.getUser();
1483
- if (!M)
1484
- return /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 });
1485
- if (t && !Ue(M.userType, t))
1486
- return /* @__PURE__ */ n(be, { userType: M.userType, minUserType: t });
1487
- if (r && r.length > 0 && !(s ? f(r) : P(r))) {
1488
- const v = r.filter((I) => !L(I)).map((I) => typeof I == "string" ? I : I.name);
1489
- return /* @__PURE__ */ n(be, { missingPermissions: v });
1490
- }
1491
- return /* @__PURE__ */ n(D, { children: i });
1679
+ const m = I.getUser();
1680
+ if (!m)
1681
+ return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
1682
+ if (t && !Ke(m.userType, t))
1683
+ return /* @__PURE__ */ n(ke, { userType: m.userType, minUserType: t });
1684
+ if (r && r.length > 0 && !(s ? P(r) : x(r))) {
1685
+ const S = r.filter((L) => !A(L)).map((L) => typeof L == "string" ? L : L.name);
1686
+ return /* @__PURE__ */ n(ke, { missingPermissions: S });
1687
+ }
1688
+ return /* @__PURE__ */ n(N, { children: i });
1492
1689
  }
1493
- const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
1690
+ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1494
1691
  "div",
1495
1692
  {
1496
1693
  style: {
@@ -1527,14 +1724,14 @@ const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
1527
1724
  )
1528
1725
  }
1529
1726
  );
1530
- function xt({ children: i, redirectTo: e = "/", fallback: t }) {
1531
- const { tenant: r, isLoading: s, error: a } = re(), b = he();
1532
- return s || a ? null : r ? /* @__PURE__ */ n(D, { children: i }) : t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1533
- /* @__PURE__ */ n(ze, { redirectPath: e }),
1534
- /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1727
+ function Rt({ children: i, redirectTo: e = "/", fallback: t }) {
1728
+ const { tenant: r, isLoading: s, error: a } = se(), p = we();
1729
+ return s || a ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1730
+ /* @__PURE__ */ n(_e, { redirectPath: e }),
1731
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1535
1732
  ] });
1536
1733
  }
1537
- const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1734
+ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1538
1735
  "div",
1539
1736
  {
1540
1737
  style: {
@@ -1571,14 +1768,14 @@ const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1571
1768
  )
1572
1769
  }
1573
1770
  );
1574
- function kt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1575
- const { tenant: r, isLoading: s, error: a } = re(), b = he();
1576
- return s || a ? null : r ? t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1577
- /* @__PURE__ */ n(Oe, { redirectPath: e }),
1578
- /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1579
- ] }) : /* @__PURE__ */ n(D, { children: i });
1771
+ function Ct({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1772
+ const { tenant: r, isLoading: s, error: a } = se(), p = we();
1773
+ return s || a ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1774
+ /* @__PURE__ */ n(Je, { redirectPath: e }),
1775
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1776
+ ] }) : /* @__PURE__ */ n(N, { children: i });
1580
1777
  }
1581
- const je = () => /* @__PURE__ */ l(
1778
+ const Ye = () => /* @__PURE__ */ l(
1582
1779
  "div",
1583
1780
  {
1584
1781
  style: {
@@ -1595,14 +1792,14 @@ const je = () => /* @__PURE__ */ l(
1595
1792
  ]
1596
1793
  }
1597
1794
  );
1598
- function At({
1795
+ function Lt({
1599
1796
  children: i,
1600
- fallback: e = /* @__PURE__ */ n(je, {}),
1797
+ fallback: e = /* @__PURE__ */ n(Ye, {}),
1601
1798
  allowedPlans: t,
1602
1799
  requiredFeature: r
1603
1800
  }) {
1604
- const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: b, loading: E } = Be();
1605
- return E ? /* @__PURE__ */ n(
1801
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: p, loading: I } = Ve();
1802
+ return I ? /* @__PURE__ */ n(
1606
1803
  "div",
1607
1804
  {
1608
1805
  style: {
@@ -1612,9 +1809,9 @@ function At({
1612
1809
  },
1613
1810
  children: "Loading subscription..."
1614
1811
  }
1615
- ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(D, { children: e }) : r && !b(r) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: i }) : /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: e });
1812
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
1616
1813
  }
1617
- const We = ({ flagName: i }) => /* @__PURE__ */ l(
1814
+ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
1618
1815
  "div",
1619
1816
  {
1620
1817
  style: {
@@ -1641,8 +1838,8 @@ const We = ({ flagName: i }) => /* @__PURE__ */ l(
1641
1838
  ]
1642
1839
  }
1643
1840
  );
1644
- function Pt({ name: i, children: e, fallback: t }) {
1645
- const { isEnabled: r, loading: s } = $e();
1841
+ function Ft({ name: i, children: e, fallback: t }) {
1842
+ const { isEnabled: r, loading: s } = Oe();
1646
1843
  return s ? /* @__PURE__ */ n(
1647
1844
  "div",
1648
1845
  {
@@ -1656,9 +1853,9 @@ function Pt({ name: i, children: e, fallback: t }) {
1656
1853
  },
1657
1854
  children: "Loading feature flags..."
1658
1855
  }
1659
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: t || /* @__PURE__ */ n(We, { flagName: i }) }));
1856
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) }));
1660
1857
  }
1661
- const Ve = () => /* @__PURE__ */ l(
1858
+ const Xe = () => /* @__PURE__ */ l(
1662
1859
  "svg",
1663
1860
  {
1664
1861
  width: "16",
@@ -1675,7 +1872,7 @@ const Ve = () => /* @__PURE__ */ l(
1675
1872
  /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1676
1873
  ]
1677
1874
  }
1678
- ), Ge = () => /* @__PURE__ */ l(
1875
+ ), Ze = () => /* @__PURE__ */ l(
1679
1876
  "svg",
1680
1877
  {
1681
1878
  width: "16",
@@ -1692,10 +1889,10 @@ const Ve = () => /* @__PURE__ */ l(
1692
1889
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1693
1890
  ]
1694
1891
  }
1695
- ), Ye = {
1696
- showPassword: /* @__PURE__ */ n(Ve, {}),
1697
- hidePassword: /* @__PURE__ */ n(Ge, {})
1698
- }, _e = {
1892
+ ), et = {
1893
+ showPassword: /* @__PURE__ */ n(Xe, {}),
1894
+ hidePassword: /* @__PURE__ */ n(Ze, {})
1895
+ }, tt = {
1699
1896
  title: "Sign In",
1700
1897
  usernameLabel: "Email or Phone",
1701
1898
  usernamePlaceholder: "Enter your email or phone number",
@@ -1709,7 +1906,7 @@ const Ve = () => /* @__PURE__ */ l(
1709
1906
  magicLinkLink: "Use Magic Link",
1710
1907
  errorMessage: "Invalid credentials",
1711
1908
  loadingText: "Signing in..."
1712
- }, Ke = {
1909
+ }, rt = {
1713
1910
  container: {
1714
1911
  maxWidth: "400px",
1715
1912
  width: "100%",
@@ -1816,129 +2013,133 @@ const Ve = () => /* @__PURE__ */ l(
1816
2013
  fontSize: "0.875rem"
1817
2014
  }
1818
2015
  };
1819
- function Tt({
2016
+ function $t({
1820
2017
  copy: i = {},
1821
2018
  styles: e = {},
1822
2019
  icons: t = {},
1823
2020
  onSuccess: r,
1824
2021
  onError: s,
1825
2022
  onForgotPassword: a,
1826
- onSignupClick: b,
1827
- onMagicLinkClick: E,
1828
- showForgotPassword: L = !0,
1829
- showSignupLink: P = !0,
1830
- showMagicLinkOption: f = !0,
1831
- className: m
2023
+ onSignupClick: p,
2024
+ onMagicLinkClick: I,
2025
+ showForgotPassword: A = !0,
2026
+ showSignupLink: x = !0,
2027
+ showMagicLinkOption: P = !0,
2028
+ className: b
1832
2029
  }) {
1833
- const [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p({}), { login: q } = ie(), { tenant: S } = re(), { appId: c } = ne(), h = { ..._e, ...i }, o = { ...Ke, ...e }, d = { ...Ye, ...t }, G = () => {
1834
- const k = {};
1835
- return M.trim() || (k.username = !0), v.trim() || (k.password = !0), z(k), Object.keys(k).length === 0;
1836
- }, Y = async (k) => {
1837
- if (k.preventDefault(), !!G()) {
1838
- if (!(S != null && S.id)) {
1839
- F("Tenant not found");
2030
+ const [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, o = () => {
2031
+ const c = {};
2032
+ return m.trim() || (c.username = !0), S.trim() || (c.password = !0), G(c), Object.keys(c).length === 0;
2033
+ }, g = async (c) => {
2034
+ if (c.preventDefault(), !!o()) {
2035
+ if (!(V != null && V.id)) {
2036
+ R("Tenant not found");
1840
2037
  return;
1841
2038
  }
1842
- y(!0), F("");
2039
+ u(!0), R("");
1843
2040
  try {
1844
- const T = await q(M, v, c, S.id);
1845
- r == null || r(T);
1846
- } catch (T) {
1847
- const J = T.message || h.errorMessage;
1848
- F(J), s == null || s(J);
2041
+ const y = await F({
2042
+ username: m,
2043
+ password: S
2044
+ // tenantId inferred from context automatically
2045
+ });
2046
+ r == null || r(y);
2047
+ } catch (y) {
2048
+ const W = y.message || w.errorMessage;
2049
+ R(W), s == null || s(W);
1849
2050
  } finally {
1850
- y(!1);
2051
+ u(!1);
1851
2052
  }
1852
2053
  }
1853
- }, H = (k) => ({
1854
- ...o.input,
1855
- ...B[k] ? o.inputError : {}
1856
- }), C = () => ({
1857
- ...o.button,
1858
- ...u ? o.buttonLoading : {},
1859
- ...!M || !v || u ? o.buttonDisabled : {}
2054
+ }, f = (c) => ({
2055
+ ...M.input,
2056
+ ...H[c] ? M.inputError : {}
2057
+ }), d = () => ({
2058
+ ...M.button,
2059
+ ...k ? M.buttonLoading : {},
2060
+ ...!m || !S || k ? M.buttonDisabled : {}
1860
2061
  });
1861
- return /* @__PURE__ */ l("div", { className: m, style: o.container, children: [
1862
- /* @__PURE__ */ n("h2", { style: o.title, children: h.title }),
1863
- /* @__PURE__ */ l("form", { onSubmit: Y, style: o.form, children: [
1864
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1865
- /* @__PURE__ */ n("label", { style: o.label, children: h.usernameLabel }),
2062
+ return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
2063
+ /* @__PURE__ */ n("h2", { style: M.title, children: w.title }),
2064
+ /* @__PURE__ */ l("form", { onSubmit: g, style: M.form, children: [
2065
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2066
+ /* @__PURE__ */ n("label", { style: M.label, children: w.usernameLabel }),
1866
2067
  /* @__PURE__ */ n(
1867
2068
  "input",
1868
2069
  {
1869
2070
  id: "username",
1870
2071
  name: "username",
1871
2072
  type: "text",
1872
- value: M,
1873
- onChange: (k) => {
1874
- w(k.target.value), B.username && z((T) => ({ ...T, username: !1 }));
2073
+ value: m,
2074
+ onChange: (c) => {
2075
+ h(c.target.value), H.username && G((y) => ({ ...y, username: !1 }));
1875
2076
  },
1876
- placeholder: h.usernamePlaceholder,
1877
- style: H("username"),
1878
- disabled: u
2077
+ placeholder: w.usernamePlaceholder,
2078
+ style: f("username"),
2079
+ disabled: k
1879
2080
  }
1880
2081
  )
1881
2082
  ] }),
1882
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1883
- /* @__PURE__ */ n("label", { style: o.label, children: h.passwordLabel }),
1884
- /* @__PURE__ */ l("div", { style: o.inputContainer, children: [
2083
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2084
+ /* @__PURE__ */ n("label", { style: M.label, children: w.passwordLabel }),
2085
+ /* @__PURE__ */ l("div", { style: M.inputContainer, children: [
1885
2086
  /* @__PURE__ */ n(
1886
2087
  "input",
1887
2088
  {
1888
2089
  id: "password",
1889
2090
  name: "password",
1890
- type: g ? "text" : "password",
1891
- value: v,
1892
- onChange: (k) => {
1893
- I(k.target.value), B.password && z((T) => ({ ...T, password: !1 }));
2091
+ type: C ? "text" : "password",
2092
+ value: S,
2093
+ onChange: (c) => {
2094
+ L(c.target.value), H.password && G((y) => ({ ...y, password: !1 }));
1894
2095
  },
1895
- placeholder: h.passwordPlaceholder,
2096
+ placeholder: w.passwordPlaceholder,
1896
2097
  style: {
1897
- ...H("password"),
2098
+ ...f("password"),
1898
2099
  paddingRight: "2.5rem"
1899
2100
  // Make room for the icon
1900
2101
  },
1901
- disabled: u
2102
+ disabled: k
1902
2103
  }
1903
2104
  ),
1904
2105
  /* @__PURE__ */ n(
1905
2106
  "button",
1906
2107
  {
1907
2108
  type: "button",
1908
- onClick: () => U(!g),
1909
- style: o.passwordToggle,
1910
- disabled: u,
1911
- "aria-label": g ? "Hide password" : "Show password",
1912
- children: g ? d.hidePassword : d.showPassword
2109
+ onClick: () => q(!C),
2110
+ style: M.passwordToggle,
2111
+ disabled: k,
2112
+ "aria-label": C ? "Hide password" : "Show password",
2113
+ children: C ? E.hidePassword : E.showPassword
1913
2114
  }
1914
2115
  )
1915
2116
  ] })
1916
2117
  ] }),
1917
- /* @__PURE__ */ n("button", { type: "submit", disabled: !M || !v || u, style: C(), children: u ? h.loadingText : h.submitButton }),
1918
- x && /* @__PURE__ */ n("div", { style: o.errorText, children: x })
2118
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !m || !S || k, style: d(), children: k ? w.loadingText : w.submitButton }),
2119
+ T && /* @__PURE__ */ n("div", { style: M.errorText, children: T })
1919
2120
  ] }),
1920
- (L || P || f) && /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
1921
- f && /* @__PURE__ */ l("div", { children: [
1922
- /* @__PURE__ */ l("span", { style: o.divider, children: [
1923
- h.magicLinkText,
2121
+ (A || x || P) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2122
+ P && /* @__PURE__ */ l("div", { children: [
2123
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2124
+ w.magicLinkText,
1924
2125
  " "
1925
2126
  ] }),
1926
- /* @__PURE__ */ n("a", { onClick: E, style: o.link, children: h.magicLinkLink })
2127
+ /* @__PURE__ */ n("a", { onClick: I, style: M.link, children: w.magicLinkLink })
1927
2128
  ] }),
1928
- f && (L || P) && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1929
- L && /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: h.forgotPasswordLink }),
1930
- L && P && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1931
- P && /* @__PURE__ */ l("div", { children: [
1932
- /* @__PURE__ */ l("span", { style: o.divider, children: [
1933
- h.signupText,
2129
+ P && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2130
+ A && /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: w.forgotPasswordLink }),
2131
+ A && x && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2132
+ x && /* @__PURE__ */ l("div", { children: [
2133
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2134
+ w.signupText,
1934
2135
  " "
1935
2136
  ] }),
1936
- /* @__PURE__ */ n("a", { onClick: b, style: o.link, children: h.signupLink })
2137
+ /* @__PURE__ */ n("a", { onClick: p, style: M.link, children: w.signupLink })
1937
2138
  ] })
1938
2139
  ] })
1939
2140
  ] });
1940
2141
  }
1941
- const Qe = {
2142
+ const nt = {
1942
2143
  title: "Create Account",
1943
2144
  nameLabel: "First Name",
1944
2145
  namePlaceholder: "Enter your first name",
@@ -1964,7 +2165,7 @@ const Qe = {
1964
2165
  passwordMismatchError: "Passwords do not match",
1965
2166
  isAdminLabel: "Create new organization",
1966
2167
  isAdminDescription: "Check this if you want to create a new organization"
1967
- }, Je = {
2168
+ }, st = {
1968
2169
  container: {
1969
2170
  maxWidth: "400px",
1970
2171
  width: "100%",
@@ -2063,136 +2264,134 @@ const Qe = {
2063
2264
  fontSize: "0.875rem"
2064
2265
  }
2065
2266
  };
2066
- function Mt({
2267
+ function Dt({
2067
2268
  copy: i = {},
2068
2269
  styles: e = {},
2069
2270
  signupType: t = "user",
2070
2271
  onSuccess: r,
2071
2272
  onError: s,
2072
2273
  onLoginClick: a,
2073
- onMagicLinkClick: b,
2074
- showLoginLink: E = !0,
2075
- showMagicLinkOption: L = !0,
2076
- className: P
2274
+ onMagicLinkClick: p,
2275
+ showLoginLink: I = !0,
2276
+ showMagicLinkOption: A = !0,
2277
+ className: x
2077
2278
  }) {
2078
- const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(""), [u, y] = p(""), [x, F] = p(""), [B, z] = p(""), [q, S] = p(!1), [c, h] = p(""), [o, d] = p({}), { signup: G, signupTenantAdmin: Y } = ie(), { tenant: H } = re(), { appId: C } = ne(), k = { ...Qe, ...i }, T = { ...Je, ...e }, J = () => {
2079
- const R = {};
2080
- return f.trim() || (R.name = !0), !v.trim() && !g.trim() && (R.email = !0, R.phoneNumber = !0), u.trim() || (R.password = !0), x.trim() || (R.confirmPassword = !0), t === "tenant" && !B.trim() && (R.tenantName = !0), d(R), Object.keys(R).length === 0;
2081
- }, O = async (R) => {
2082
- if (R.preventDefault(), !!J()) {
2083
- if (u !== x) {
2084
- h(k.passwordMismatchError), d({ confirmPassword: !0 });
2279
+ const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(""), [k, u] = v(""), [T, R] = v(""), [H, G] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, o] = v({}), { signup: g, signupTenantAdmin: f } = oe(), { tenant: d } = se(), c = { ...nt, ...i }, y = { ...st, ...e }, W = () => {
2280
+ const D = {};
2281
+ return P.trim() || (D.name = !0), !S.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), T.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), o(D), Object.keys(D).length === 0;
2282
+ }, ee = async (D) => {
2283
+ if (D.preventDefault(), !!W()) {
2284
+ if (k !== T) {
2285
+ M(c.passwordMismatchError), o({ confirmPassword: !0 });
2085
2286
  return;
2086
2287
  }
2087
- if (t === "user" && !(H != null && H.id)) {
2088
- h("Tenant not found");
2288
+ if (t === "user" && !(d != null && d.id)) {
2289
+ M("Tenant not found");
2089
2290
  return;
2090
2291
  }
2091
- S(!0), h("");
2292
+ V(!0), M("");
2092
2293
  try {
2093
- let V;
2094
- t === "tenant" ? V = await Y(
2095
- v || void 0,
2096
- g || void 0,
2097
- f,
2098
- u,
2099
- B,
2100
- M || void 0,
2101
- C
2102
- ) : V = await G(
2103
- v || void 0,
2104
- g || void 0,
2105
- f,
2106
- u,
2107
- H.id,
2108
- M || void 0,
2109
- C
2110
- ), r == null || r(V);
2111
- } catch (V) {
2112
- const ue = V.message || k.errorMessage;
2113
- h(ue), s == null || s(ue);
2294
+ let _;
2295
+ t === "tenant" ? _ = await f({
2296
+ email: S || void 0,
2297
+ phoneNumber: C || void 0,
2298
+ name: P,
2299
+ password: k,
2300
+ tenantName: H,
2301
+ lastName: m || void 0
2302
+ }) : _ = await g({
2303
+ email: S || void 0,
2304
+ phoneNumber: C || void 0,
2305
+ name: P,
2306
+ password: k,
2307
+ tenantId: d.id,
2308
+ lastName: m || void 0
2309
+ }), r == null || r(_);
2310
+ } catch (_) {
2311
+ const ge = _.message || c.errorMessage;
2312
+ M(ge), s == null || s(ge);
2114
2313
  } finally {
2115
- S(!1);
2314
+ V(!1);
2116
2315
  }
2117
2316
  }
2118
- }, j = (R) => ({
2119
- ...T.input,
2120
- ...o[R] ? T.inputError : {}
2121
- }), N = () => ({
2122
- ...T.button,
2123
- ...q ? T.buttonLoading : {},
2124
- ...!f || !v && !g || !u || !x || q || t === "tenant" && !B ? T.buttonDisabled : {}
2125
- }), K = f && (v || g) && u && x && (t === "user" || B);
2126
- return /* @__PURE__ */ l("div", { className: P, style: T.container, children: [
2127
- /* @__PURE__ */ n("h2", { style: T.title, children: k.title }),
2128
- /* @__PURE__ */ l("form", { onSubmit: O, style: T.form, children: [
2129
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2130
- /* @__PURE__ */ n("label", { style: T.label, children: k.nameLabel }),
2317
+ }, z = (D) => ({
2318
+ ...y.input,
2319
+ ...E[D] ? y.inputError : {}
2320
+ }), B = () => ({
2321
+ ...y.button,
2322
+ ...F ? y.buttonLoading : {},
2323
+ ...!P || !S && !C || !k || !T || F || t === "tenant" && !H ? y.buttonDisabled : {}
2324
+ }), O = P && (S || C) && k && T && (t === "user" || H);
2325
+ return /* @__PURE__ */ l("div", { className: x, style: y.container, children: [
2326
+ /* @__PURE__ */ n("h2", { style: y.title, children: c.title }),
2327
+ /* @__PURE__ */ l("form", { onSubmit: ee, style: y.form, children: [
2328
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2329
+ /* @__PURE__ */ n("label", { style: y.label, children: c.nameLabel }),
2131
2330
  /* @__PURE__ */ n(
2132
2331
  "input",
2133
2332
  {
2134
2333
  id: "name",
2135
2334
  name: "name",
2136
2335
  type: "text",
2137
- value: f,
2138
- onChange: (R) => {
2139
- m(R.target.value), o.name && d((V) => ({ ...V, name: !1 }));
2336
+ value: P,
2337
+ onChange: (D) => {
2338
+ b(D.target.value), E.name && o((_) => ({ ..._, name: !1 }));
2140
2339
  },
2141
- placeholder: k.namePlaceholder,
2142
- style: j("name"),
2143
- disabled: q
2340
+ placeholder: c.namePlaceholder,
2341
+ style: z("name"),
2342
+ disabled: F
2144
2343
  }
2145
2344
  )
2146
2345
  ] }),
2147
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2148
- /* @__PURE__ */ n("label", { style: T.label, children: k.lastNameLabel }),
2346
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2347
+ /* @__PURE__ */ n("label", { style: y.label, children: c.lastNameLabel }),
2149
2348
  /* @__PURE__ */ n(
2150
2349
  "input",
2151
2350
  {
2152
2351
  id: "lastName",
2153
2352
  name: "lastName",
2154
2353
  type: "text",
2155
- value: M,
2156
- onChange: (R) => w(R.target.value),
2157
- placeholder: k.lastNamePlaceholder,
2158
- style: T.input,
2159
- disabled: q
2354
+ value: m,
2355
+ onChange: (D) => h(D.target.value),
2356
+ placeholder: c.lastNamePlaceholder,
2357
+ style: y.input,
2358
+ disabled: F
2160
2359
  }
2161
2360
  )
2162
2361
  ] }),
2163
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2164
- /* @__PURE__ */ n("label", { style: T.label, children: k.emailLabel }),
2362
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2363
+ /* @__PURE__ */ n("label", { style: y.label, children: c.emailLabel }),
2165
2364
  /* @__PURE__ */ n(
2166
2365
  "input",
2167
2366
  {
2168
2367
  id: "email",
2169
2368
  name: "email",
2170
2369
  type: "email",
2171
- value: v,
2172
- onChange: (R) => {
2173
- I(R.target.value), o.email && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2370
+ value: S,
2371
+ onChange: (D) => {
2372
+ L(D.target.value), E.email && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2174
2373
  },
2175
- placeholder: k.emailPlaceholder,
2176
- style: j("email"),
2177
- disabled: q
2374
+ placeholder: c.emailPlaceholder,
2375
+ style: z("email"),
2376
+ disabled: F
2178
2377
  }
2179
2378
  )
2180
2379
  ] }),
2181
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2182
- /* @__PURE__ */ n("label", { style: T.label, children: k.phoneNumberLabel }),
2380
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2381
+ /* @__PURE__ */ n("label", { style: y.label, children: c.phoneNumberLabel }),
2183
2382
  /* @__PURE__ */ n(
2184
2383
  "input",
2185
2384
  {
2186
2385
  id: "phoneNumber",
2187
2386
  name: "phoneNumber",
2188
2387
  type: "tel",
2189
- value: g,
2190
- onChange: (R) => {
2191
- U(R.target.value), o.phoneNumber && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2388
+ value: C,
2389
+ onChange: (D) => {
2390
+ q(D.target.value), E.phoneNumber && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2192
2391
  },
2193
- placeholder: k.phoneNumberPlaceholder,
2194
- style: j("phoneNumber"),
2195
- disabled: q
2392
+ placeholder: c.phoneNumberPlaceholder,
2393
+ style: z("phoneNumber"),
2394
+ disabled: F
2196
2395
  }
2197
2396
  )
2198
2397
  ] }),
@@ -2208,83 +2407,83 @@ function Mt({
2208
2407
  children: "At least one contact method (email or phone) is required"
2209
2408
  }
2210
2409
  ),
2211
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2212
- /* @__PURE__ */ n("label", { style: T.label, children: k.passwordLabel }),
2410
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2411
+ /* @__PURE__ */ n("label", { style: y.label, children: c.passwordLabel }),
2213
2412
  /* @__PURE__ */ n(
2214
2413
  "input",
2215
2414
  {
2216
2415
  id: "password",
2217
2416
  name: "password",
2218
2417
  type: "password",
2219
- value: u,
2220
- onChange: (R) => {
2221
- y(R.target.value), o.password && d((V) => ({ ...V, password: !1 }));
2418
+ value: k,
2419
+ onChange: (D) => {
2420
+ u(D.target.value), E.password && o((_) => ({ ..._, password: !1 }));
2222
2421
  },
2223
- placeholder: k.passwordPlaceholder,
2224
- style: j("password"),
2225
- disabled: q
2422
+ placeholder: c.passwordPlaceholder,
2423
+ style: z("password"),
2424
+ disabled: F
2226
2425
  }
2227
2426
  )
2228
2427
  ] }),
2229
- /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2230
- /* @__PURE__ */ n("label", { style: T.label, children: k.confirmPasswordLabel }),
2428
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2429
+ /* @__PURE__ */ n("label", { style: y.label, children: c.confirmPasswordLabel }),
2231
2430
  /* @__PURE__ */ n(
2232
2431
  "input",
2233
2432
  {
2234
2433
  id: "confirmPassword",
2235
2434
  name: "confirmPassword",
2236
2435
  type: "password",
2237
- value: x,
2238
- onChange: (R) => {
2239
- F(R.target.value), o.confirmPassword && d((V) => ({ ...V, confirmPassword: !1 })), c === k.passwordMismatchError && h("");
2436
+ value: T,
2437
+ onChange: (D) => {
2438
+ R(D.target.value), E.confirmPassword && o((_) => ({ ..._, confirmPassword: !1 })), w === c.passwordMismatchError && M("");
2240
2439
  },
2241
- placeholder: k.confirmPasswordPlaceholder,
2242
- style: j("confirmPassword"),
2243
- disabled: q
2440
+ placeholder: c.confirmPasswordPlaceholder,
2441
+ style: z("confirmPassword"),
2442
+ disabled: F
2244
2443
  }
2245
2444
  )
2246
2445
  ] }),
2247
- t === "tenant" && /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2248
- /* @__PURE__ */ n("label", { style: T.label, children: k.tenantNameLabel }),
2446
+ t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2447
+ /* @__PURE__ */ n("label", { style: y.label, children: c.tenantNameLabel }),
2249
2448
  /* @__PURE__ */ n(
2250
2449
  "input",
2251
2450
  {
2252
2451
  id: "tenantName",
2253
2452
  name: "tenantName",
2254
2453
  type: "text",
2255
- value: B,
2256
- onChange: (R) => {
2257
- z(R.target.value), o.tenantName && d((V) => ({ ...V, tenantName: !1 }));
2454
+ value: H,
2455
+ onChange: (D) => {
2456
+ G(D.target.value), E.tenantName && o((_) => ({ ..._, tenantName: !1 }));
2258
2457
  },
2259
- placeholder: k.tenantNamePlaceholder,
2260
- style: j("tenantName"),
2261
- disabled: q
2458
+ placeholder: c.tenantNamePlaceholder,
2459
+ style: z("tenantName"),
2460
+ disabled: F
2262
2461
  }
2263
2462
  )
2264
2463
  ] }),
2265
- /* @__PURE__ */ n("button", { type: "submit", disabled: !K || q, style: N(), children: q ? k.loadingText : k.submitButton }),
2266
- c && /* @__PURE__ */ n("div", { style: T.errorText, children: c })
2464
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? c.loadingText : c.submitButton }),
2465
+ w && /* @__PURE__ */ n("div", { style: y.errorText, children: w })
2267
2466
  ] }),
2268
- (E || L) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
2269
- L && /* @__PURE__ */ l("div", { children: [
2270
- /* @__PURE__ */ l("span", { style: T.divider, children: [
2271
- k.magicLinkText,
2467
+ (I || A) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
2468
+ A && /* @__PURE__ */ l("div", { children: [
2469
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2470
+ c.magicLinkText,
2272
2471
  " "
2273
2472
  ] }),
2274
- /* @__PURE__ */ n("a", { onClick: b, style: T.link, children: k.magicLinkLink })
2473
+ /* @__PURE__ */ n("a", { onClick: p, style: y.link, children: c.magicLinkLink })
2275
2474
  ] }),
2276
- L && E && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
2277
- E && /* @__PURE__ */ l("div", { children: [
2278
- /* @__PURE__ */ l("span", { style: T.divider, children: [
2279
- k.loginText,
2475
+ A && I && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
2476
+ I && /* @__PURE__ */ l("div", { children: [
2477
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2478
+ c.loginText,
2280
2479
  " "
2281
2480
  ] }),
2282
- /* @__PURE__ */ n("a", { onClick: a, style: T.link, children: k.loginLink })
2481
+ /* @__PURE__ */ n("a", { onClick: a, style: y.link, children: c.loginLink })
2283
2482
  ] })
2284
2483
  ] })
2285
2484
  ] });
2286
2485
  }
2287
- const Xe = {
2486
+ const it = {
2288
2487
  title: "Sign In with Magic Link",
2289
2488
  emailLabel: "Email",
2290
2489
  emailPlaceholder: "Enter your email",
@@ -2302,7 +2501,7 @@ const Xe = {
2302
2501
  loadingText: "Sending magic link...",
2303
2502
  verifyingText: "Verifying magic link...",
2304
2503
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2305
- }, Ze = {
2504
+ }, ot = {
2306
2505
  container: {
2307
2506
  maxWidth: "400px",
2308
2507
  width: "100%",
@@ -2405,100 +2604,105 @@ const Xe = {
2405
2604
  fontSize: "0.875rem"
2406
2605
  }
2407
2606
  };
2408
- function Et({
2607
+ function Ht({
2409
2608
  copy: i = {},
2410
2609
  styles: e = {},
2411
2610
  onSuccess: t,
2412
2611
  onError: r,
2413
2612
  onLoginClick: s,
2414
2613
  onSignupClick: a,
2415
- showTraditionalLinks: b = !0,
2416
- className: E,
2417
- verifyToken: L,
2418
- frontendUrl: P
2614
+ showTraditionalLinks: p = !0,
2615
+ className: I,
2616
+ verifyToken: A,
2617
+ frontendUrl: x
2419
2618
  }) {
2420
- const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p(""), [q, S] = p({}), [c, h] = p(!1), { sendMagicLink: o, verifyMagicLink: d } = ie(), { tenant: G } = re(), { appId: Y } = ne(), H = { ...Xe, ...i }, C = { ...Ze, ...e };
2421
- Z(() => {
2422
- L && k(L);
2423
- }, [L]);
2424
- const k = async (N) => {
2425
- y(!0), F("");
2619
+ const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: o } = oe(), { tenant: g } = se(), f = { ...it, ...i }, d = { ...ot, ...e };
2620
+ te(() => {
2621
+ A && c(A);
2622
+ }, [A]);
2623
+ const c = async (B) => {
2624
+ if (!g || !P) {
2625
+ R("Missing tenant or email");
2626
+ return;
2627
+ }
2628
+ u(!0), R("");
2426
2629
  try {
2427
- if (!f || !Y)
2428
- throw new Error("Email and App ID are required for magic link verification");
2429
- const K = await d(N, f, Y, G == null ? void 0 : G.id);
2430
- t == null || t(K);
2431
- } catch (K) {
2432
- const R = K.message || "Failed to verify magic link";
2433
- F(R), r == null || r(R);
2630
+ const O = await o({
2631
+ token: B,
2632
+ email: P
2633
+ // tenantId inferred from context automatically
2634
+ });
2635
+ t == null || t(O);
2636
+ } catch (O) {
2637
+ const D = O.message || "Failed to verify magic link";
2638
+ R(D), r == null || r(D);
2434
2639
  } finally {
2435
- y(!1);
2640
+ u(!1);
2436
2641
  }
2437
- }, T = () => {
2438
- const N = {};
2439
- return f.trim() || (N.email = !0), c && !M.trim() && (N.name = !0), S(N), Object.keys(N).length === 0;
2440
- }, J = async (N) => {
2441
- if (N.preventDefault(), !!T()) {
2442
- if (!(G != null && G.id)) {
2443
- F("Tenant not found");
2642
+ }, y = () => {
2643
+ const B = {};
2644
+ return P.trim() || (B.email = !0), w && !m.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
2645
+ }, W = async (B) => {
2646
+ if (B.preventDefault(), !!y()) {
2647
+ if (!(g != null && g.id)) {
2648
+ R("Tenant not found");
2444
2649
  return;
2445
2650
  }
2446
- U(!0), F(""), z("");
2651
+ q(!0), R(""), G("");
2447
2652
  try {
2448
- const K = P || (typeof window < "u" ? window.location.origin : ""), R = await o(
2449
- f,
2450
- G.id,
2451
- K,
2452
- c ? M : void 0,
2453
- c ? v : void 0,
2454
- Y
2455
- );
2456
- z(H.successMessage), t == null || t(R);
2457
- } catch (K) {
2458
- const R = K.message || H.errorMessage;
2459
- F(R), r == null || r(R);
2653
+ const O = x || (typeof window < "u" ? window.location.origin : ""), D = await E({
2654
+ email: P,
2655
+ tenantId: g.id,
2656
+ frontendUrl: O,
2657
+ name: w ? m : void 0,
2658
+ lastName: w ? S : void 0
2659
+ });
2660
+ G(f.successMessage), t == null || t(D);
2661
+ } catch (O) {
2662
+ const D = O.message || f.errorMessage;
2663
+ R(D), r == null || r(D);
2460
2664
  } finally {
2461
- U(!1);
2665
+ q(!1);
2462
2666
  }
2463
2667
  }
2464
- }, O = (N) => ({
2465
- ...C.input,
2466
- ...q[N] ? C.inputError : {}
2467
- }), j = () => ({
2468
- ...C.button,
2469
- ...g || u ? C.buttonLoading : {},
2470
- ...!f || g || u ? C.buttonDisabled : {}
2668
+ }, ee = (B) => ({
2669
+ ...d.input,
2670
+ ...F[B] ? d.inputError : {}
2671
+ }), z = () => ({
2672
+ ...d.button,
2673
+ ...C || k ? d.buttonLoading : {},
2674
+ ...!P || C || k ? d.buttonDisabled : {}
2471
2675
  });
2472
- return u ? /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2473
- /* @__PURE__ */ n("h2", { style: C.title, children: H.verifyingText }),
2676
+ return k ? /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2677
+ /* @__PURE__ */ n("h2", { style: d.title, children: f.verifyingText }),
2474
2678
  /* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
2475
- ] }) : /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2476
- /* @__PURE__ */ n("h2", { style: C.title, children: H.title }),
2477
- /* @__PURE__ */ n("p", { style: C.description, children: H.description }),
2478
- /* @__PURE__ */ l("form", { onSubmit: J, style: C.form, children: [
2479
- /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2480
- /* @__PURE__ */ n("label", { style: C.label, children: H.emailLabel }),
2679
+ ] }) : /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2680
+ /* @__PURE__ */ n("h2", { style: d.title, children: f.title }),
2681
+ /* @__PURE__ */ n("p", { style: d.description, children: f.description }),
2682
+ /* @__PURE__ */ l("form", { onSubmit: W, style: d.form, children: [
2683
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2684
+ /* @__PURE__ */ n("label", { style: d.label, children: f.emailLabel }),
2481
2685
  /* @__PURE__ */ n(
2482
2686
  "input",
2483
2687
  {
2484
2688
  id: "email",
2485
2689
  name: "email",
2486
2690
  type: "email",
2487
- value: f,
2488
- onChange: (N) => {
2489
- m(N.target.value), q.email && S((K) => ({ ...K, email: !1 }));
2691
+ value: P,
2692
+ onChange: (B) => {
2693
+ b(B.target.value), F.email && V((O) => ({ ...O, email: !1 }));
2490
2694
  },
2491
- placeholder: H.emailPlaceholder,
2492
- style: O("email"),
2493
- disabled: g || u
2695
+ placeholder: f.emailPlaceholder,
2696
+ style: ee("email"),
2697
+ disabled: C || k
2494
2698
  }
2495
2699
  )
2496
2700
  ] }),
2497
- !c && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2701
+ !w && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2498
2702
  "button",
2499
2703
  {
2500
2704
  type: "button",
2501
- onClick: () => h(!0),
2705
+ onClick: () => M(!0),
2502
2706
  style: {
2503
2707
  background: "none",
2504
2708
  border: "none",
@@ -2510,38 +2714,38 @@ function Et({
2510
2714
  children: "New user? Add your name"
2511
2715
  }
2512
2716
  ) }),
2513
- c && /* @__PURE__ */ l(D, { children: [
2514
- /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2515
- /* @__PURE__ */ n("label", { style: C.label, children: H.nameLabel }),
2717
+ w && /* @__PURE__ */ l(N, { children: [
2718
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2719
+ /* @__PURE__ */ n("label", { style: d.label, children: f.nameLabel }),
2516
2720
  /* @__PURE__ */ n(
2517
2721
  "input",
2518
2722
  {
2519
2723
  id: "name",
2520
2724
  name: "name",
2521
2725
  type: "text",
2522
- value: M,
2523
- onChange: (N) => {
2524
- w(N.target.value), q.name && S((K) => ({ ...K, name: !1 }));
2726
+ value: m,
2727
+ onChange: (B) => {
2728
+ h(B.target.value), F.name && V((O) => ({ ...O, name: !1 }));
2525
2729
  },
2526
- placeholder: H.namePlaceholder,
2527
- style: O("name"),
2528
- disabled: g || u
2730
+ placeholder: f.namePlaceholder,
2731
+ style: ee("name"),
2732
+ disabled: C || k
2529
2733
  }
2530
2734
  )
2531
2735
  ] }),
2532
- /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2533
- /* @__PURE__ */ n("label", { style: C.label, children: H.lastNameLabel }),
2736
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2737
+ /* @__PURE__ */ n("label", { style: d.label, children: f.lastNameLabel }),
2534
2738
  /* @__PURE__ */ n(
2535
2739
  "input",
2536
2740
  {
2537
2741
  id: "lastName",
2538
2742
  name: "lastName",
2539
2743
  type: "text",
2540
- value: v,
2541
- onChange: (N) => I(N.target.value),
2542
- placeholder: H.lastNamePlaceholder,
2543
- style: C.input,
2544
- disabled: g || u
2744
+ value: S,
2745
+ onChange: (B) => L(B.target.value),
2746
+ placeholder: f.lastNamePlaceholder,
2747
+ style: d.input,
2748
+ disabled: C || k
2545
2749
  }
2546
2750
  )
2547
2751
  ] }),
@@ -2550,7 +2754,7 @@ function Et({
2550
2754
  {
2551
2755
  type: "button",
2552
2756
  onClick: () => {
2553
- h(!1), w(""), I("");
2757
+ M(!1), h(""), L("");
2554
2758
  },
2555
2759
  style: {
2556
2760
  background: "none",
@@ -2564,30 +2768,30 @@ function Et({
2564
2768
  }
2565
2769
  ) })
2566
2770
  ] }),
2567
- /* @__PURE__ */ n("button", { type: "submit", disabled: !f || g || u, style: j(), children: g ? H.loadingText : H.submitButton }),
2568
- x && /* @__PURE__ */ n("div", { style: C.errorText, children: x }),
2569
- B && /* @__PURE__ */ n("div", { style: C.successText, children: B })
2771
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !P || C || k, style: z(), children: C ? f.loadingText : f.submitButton }),
2772
+ T && /* @__PURE__ */ n("div", { style: d.errorText, children: T }),
2773
+ H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
2570
2774
  ] }),
2571
- b && /* @__PURE__ */ l("div", { style: C.linkContainer, children: [
2775
+ p && /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
2572
2776
  /* @__PURE__ */ l("div", { children: [
2573
- /* @__PURE__ */ l("span", { style: C.divider, children: [
2574
- H.loginText,
2777
+ /* @__PURE__ */ l("span", { style: d.divider, children: [
2778
+ f.loginText,
2575
2779
  " "
2576
2780
  ] }),
2577
- /* @__PURE__ */ n("a", { onClick: s, style: C.link, children: H.loginLink })
2781
+ /* @__PURE__ */ n("a", { onClick: s, style: d.link, children: f.loginLink })
2578
2782
  ] }),
2579
- /* @__PURE__ */ n("div", { style: C.divider, children: "•" }),
2783
+ /* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
2580
2784
  /* @__PURE__ */ l("div", { children: [
2581
- /* @__PURE__ */ l("span", { style: C.divider, children: [
2582
- H.signupText,
2785
+ /* @__PURE__ */ l("span", { style: d.divider, children: [
2786
+ f.signupText,
2583
2787
  " "
2584
2788
  ] }),
2585
- /* @__PURE__ */ n("a", { onClick: a, style: C.link, children: H.signupLink })
2789
+ /* @__PURE__ */ n("a", { onClick: a, style: d.link, children: f.signupLink })
2586
2790
  ] })
2587
2791
  ] })
2588
2792
  ] });
2589
2793
  }
2590
- const et = {
2794
+ const at = {
2591
2795
  title: "Verifying Magic Link",
2592
2796
  verifyingMessage: "Please wait while we verify your magic link...",
2593
2797
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -2595,7 +2799,7 @@ const et = {
2595
2799
  redirectingMessage: "Redirecting you to the dashboard...",
2596
2800
  retryButton: "Try Again",
2597
2801
  backToLoginButton: "Back to Login"
2598
- }, Ae = {
2802
+ }, Ee = {
2599
2803
  container: {
2600
2804
  maxWidth: "400px",
2601
2805
  width: "100%",
@@ -2682,7 +2886,7 @@ const et = {
2682
2886
  cursor: "pointer",
2683
2887
  transition: "all 0.15s ease-in-out"
2684
2888
  }
2685
- }, tt = () => /* @__PURE__ */ n("div", { style: Ae.spinner }), rt = () => /* @__PURE__ */ l(
2889
+ }, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ l(
2686
2890
  "svg",
2687
2891
  {
2688
2892
  width: "48",
@@ -2699,7 +2903,7 @@ const et = {
2699
2903
  /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2700
2904
  ]
2701
2905
  }
2702
- ), nt = () => /* @__PURE__ */ l(
2906
+ ), dt = () => /* @__PURE__ */ l(
2703
2907
  "svg",
2704
2908
  {
2705
2909
  width: "48",
@@ -2717,110 +2921,109 @@ const et = {
2717
2921
  /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2718
2922
  ]
2719
2923
  }
2720
- ), st = {
2721
- loading: /* @__PURE__ */ n(tt, {}),
2722
- success: /* @__PURE__ */ n(rt, {}),
2723
- error: /* @__PURE__ */ n(nt, {})
2924
+ ), ut = {
2925
+ loading: /* @__PURE__ */ n(lt, {}),
2926
+ success: /* @__PURE__ */ n(ct, {}),
2927
+ error: /* @__PURE__ */ n(dt, {})
2724
2928
  };
2725
- function Lt({
2929
+ function Nt({
2726
2930
  copy: i = {},
2727
2931
  styles: e = {},
2728
2932
  icons: t = {},
2729
2933
  onSuccess: r,
2730
2934
  onError: s,
2731
2935
  onRetry: a,
2732
- onBackToLogin: b,
2733
- className: E,
2734
- token: L,
2735
- email: P,
2736
- appId: f,
2737
- tenantId: m,
2738
- autoRedirectDelay: M = 3e3
2936
+ onBackToLogin: p,
2937
+ className: I,
2938
+ token: A,
2939
+ email: x,
2940
+ appId: P,
2941
+ tenantSlug: b,
2942
+ autoRedirectDelay: m = 3e3
2739
2943
  }) {
2740
- const [w, v] = p("verifying"), [I, g] = p(""), { verifyMagicLink: U } = ie(), u = { ...et, ...i }, y = { ...Ae, ...e }, x = { ...st, ...t }, F = () => {
2944
+ const [h, S] = v("verifying"), [L, C] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, T = { ...ut, ...t }, R = () => {
2741
2945
  if (typeof window > "u") return {};
2742
- const c = new URLSearchParams(window.location.search);
2946
+ const w = new URLSearchParams(window.location.search);
2743
2947
  return {
2744
- token: L || c.get("token") || "",
2745
- email: P || c.get("email") || "",
2746
- appId: f || c.get("appId") || "",
2747
- tenantId: m || c.get("tenantId") || void 0
2948
+ token: A || w.get("token") || "",
2949
+ email: x || w.get("email") || "",
2950
+ appId: P || w.get("appId") || "",
2951
+ tenantSlug: b || w.get("tenantSlug") || void 0
2748
2952
  };
2749
- }, B = async () => {
2750
- v("verifying"), g("");
2953
+ }, H = async () => {
2954
+ S("verifying"), C("");
2751
2955
  try {
2752
- const c = F();
2753
- if (!c.token || !c.email || !c.appId)
2754
- throw new Error("Missing required parameters: token, email, or appId");
2755
- const h = await U(
2756
- c.token,
2757
- c.email,
2758
- c.appId,
2759
- c.tenantId
2760
- );
2761
- v("success"), r == null || r(h), M > 0 && setTimeout(() => {
2762
- v("redirecting");
2763
- }, M);
2764
- } catch (c) {
2765
- const h = c.message || u.errorMessage;
2766
- g(h), v("error"), s == null || s(h);
2956
+ const w = R();
2957
+ if (!w.token || !w.email)
2958
+ throw new Error("Missing required parameters: token or email");
2959
+ const M = await q({
2960
+ token: w.token,
2961
+ email: w.email,
2962
+ tenantSlug: w.tenantSlug
2963
+ });
2964
+ S("success"), r == null || r(M), m > 0 && setTimeout(() => {
2965
+ S("redirecting");
2966
+ }, m);
2967
+ } catch (w) {
2968
+ const M = w.message || k.errorMessage;
2969
+ C(M), S("error"), s == null || s(M);
2767
2970
  }
2768
- }, z = () => {
2769
- a == null || a(), B();
2770
- }, q = () => {
2771
- b == null || b();
2971
+ }, G = () => {
2972
+ a == null || a(), H();
2973
+ }, F = () => {
2974
+ p == null || p();
2772
2975
  };
2773
- Z(() => {
2774
- B();
2976
+ te(() => {
2977
+ H();
2775
2978
  }, []);
2776
- const S = () => {
2777
- switch (w) {
2979
+ const V = () => {
2980
+ switch (h) {
2778
2981
  case "verifying":
2779
- return /* @__PURE__ */ l("div", { style: y.message, children: [
2780
- x.loading,
2781
- u.verifyingMessage
2982
+ return /* @__PURE__ */ l("div", { style: u.message, children: [
2983
+ T.loading,
2984
+ k.verifyingMessage
2782
2985
  ] });
2783
2986
  case "success":
2784
- return /* @__PURE__ */ l(D, { children: [
2785
- x.success,
2786
- /* @__PURE__ */ n("div", { style: y.successMessage, children: u.successMessage })
2987
+ return /* @__PURE__ */ l(N, { children: [
2988
+ T.success,
2989
+ /* @__PURE__ */ n("div", { style: u.successMessage, children: k.successMessage })
2787
2990
  ] });
2788
2991
  case "redirecting":
2789
- return /* @__PURE__ */ l(D, { children: [
2790
- x.loading,
2791
- /* @__PURE__ */ n("div", { style: y.message, children: u.redirectingMessage })
2992
+ return /* @__PURE__ */ l(N, { children: [
2993
+ T.loading,
2994
+ /* @__PURE__ */ n("div", { style: u.message, children: k.redirectingMessage })
2792
2995
  ] });
2793
2996
  case "error":
2794
- return /* @__PURE__ */ l(D, { children: [
2795
- x.error,
2796
- /* @__PURE__ */ n("div", { style: y.errorMessage, children: I || u.errorMessage }),
2797
- /* @__PURE__ */ l("div", { style: y.buttonContainer, children: [
2997
+ return /* @__PURE__ */ l(N, { children: [
2998
+ T.error,
2999
+ /* @__PURE__ */ n("div", { style: u.errorMessage, children: L || k.errorMessage }),
3000
+ /* @__PURE__ */ l("div", { style: u.buttonContainer, children: [
2798
3001
  /* @__PURE__ */ n(
2799
3002
  "button",
2800
3003
  {
2801
- onClick: z,
2802
- style: y.retryButton,
2803
- onMouseOver: (c) => {
2804
- c.currentTarget.style.backgroundColor = "#2563eb";
3004
+ onClick: G,
3005
+ style: u.retryButton,
3006
+ onMouseOver: (w) => {
3007
+ w.currentTarget.style.backgroundColor = "#2563eb";
2805
3008
  },
2806
- onMouseOut: (c) => {
2807
- c.currentTarget.style.backgroundColor = "#3b82f6";
3009
+ onMouseOut: (w) => {
3010
+ w.currentTarget.style.backgroundColor = "#3b82f6";
2808
3011
  },
2809
- children: u.retryButton
3012
+ children: k.retryButton
2810
3013
  }
2811
3014
  ),
2812
3015
  /* @__PURE__ */ n(
2813
3016
  "button",
2814
3017
  {
2815
- onClick: q,
2816
- style: y.backButton,
2817
- onMouseOver: (c) => {
2818
- c.currentTarget.style.backgroundColor = "#e5e7eb";
3018
+ onClick: F,
3019
+ style: u.backButton,
3020
+ onMouseOver: (w) => {
3021
+ w.currentTarget.style.backgroundColor = "#e5e7eb";
2819
3022
  },
2820
- onMouseOut: (c) => {
2821
- c.currentTarget.style.backgroundColor = "#f3f4f6";
3023
+ onMouseOut: (w) => {
3024
+ w.currentTarget.style.backgroundColor = "#f3f4f6";
2822
3025
  },
2823
- children: u.backToLoginButton
3026
+ children: k.backToLoginButton
2824
3027
  }
2825
3028
  )
2826
3029
  ] })
@@ -2829,18 +3032,18 @@ function Lt({
2829
3032
  return null;
2830
3033
  }
2831
3034
  };
2832
- return /* @__PURE__ */ l("div", { style: y.container, className: E, children: [
3035
+ return /* @__PURE__ */ l("div", { style: u.container, className: I, children: [
2833
3036
  /* @__PURE__ */ n("style", { children: `
2834
3037
  @keyframes spin {
2835
3038
  0% { transform: rotate(0deg); }
2836
3039
  100% { transform: rotate(360deg); }
2837
3040
  }
2838
3041
  ` }),
2839
- /* @__PURE__ */ n("h1", { style: y.title, children: u.title }),
2840
- S()
3042
+ /* @__PURE__ */ n("h1", { style: u.title, children: k.title }),
3043
+ V()
2841
3044
  ] });
2842
3045
  }
2843
- const it = {
3046
+ const ht = {
2844
3047
  title: "Reset Password",
2845
3048
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2846
3049
  emailLabel: "Email",
@@ -2862,7 +3065,7 @@ const it = {
2862
3065
  resetLoadingText: "Resetting...",
2863
3066
  resetSuccessMessage: "Password reset successfully!",
2864
3067
  passwordMismatchError: "Passwords do not match"
2865
- }, ot = {
3068
+ }, gt = {
2866
3069
  container: {
2867
3070
  maxWidth: "400px",
2868
3071
  margin: "0 auto",
@@ -2954,113 +3157,113 @@ const it = {
2954
3157
  cursor: "pointer"
2955
3158
  }
2956
3159
  };
2957
- function Rt({
3160
+ function Bt({
2958
3161
  copy: i = {},
2959
3162
  styles: e = {},
2960
3163
  mode: t = "request",
2961
3164
  token: r = "",
2962
3165
  onSuccess: s,
2963
3166
  onError: a,
2964
- onBackToLogin: b,
2965
- onModeChange: E,
2966
- className: L
3167
+ onBackToLogin: p,
3168
+ onModeChange: I,
3169
+ className: A
2967
3170
  }) {
2968
- const [P, f] = p(""), [m, M] = p(r), [w, v] = p(""), [I, g] = p(""), [U, u] = p(!1), [y, x] = p(""), [F, B] = p(""), [z, q] = p({}), { requestPasswordReset: S, confirmPasswordReset: c } = ie(), { tenant: h } = re(), o = { ...it, ...i }, d = { ...ot, ...e }, G = () => {
2969
- const O = {};
2970
- return P.trim() || (O.email = !0), q(O), Object.keys(O).length === 0;
2971
- }, Y = () => {
2972
- const O = {};
2973
- return m.trim() || (O.token = !0), w.trim() || (O.newPassword = !0), I.trim() || (O.confirmPassword = !0), q(O), Object.keys(O).length === 0;
2974
- }, H = async (O) => {
2975
- if (O.preventDefault(), !!G()) {
2976
- if (!(h != null && h.id)) {
2977
- x("Tenant not found");
3171
+ const [x, P] = v(""), [b, m] = v(r), [h, S] = v(""), [L, C] = v(""), [q, k] = v(!1), [u, T] = v(""), [R, H] = v(""), [G, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, o = { ...gt, ...e }, g = () => {
3172
+ const z = {};
3173
+ return x.trim() || (z.email = !0), F(z), Object.keys(z).length === 0;
3174
+ }, f = () => {
3175
+ const z = {};
3176
+ return b.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), L.trim() || (z.confirmPassword = !0), F(z), Object.keys(z).length === 0;
3177
+ }, d = async (z) => {
3178
+ if (z.preventDefault(), !!g()) {
3179
+ if (!(M != null && M.id)) {
3180
+ T("Tenant not found");
2978
3181
  return;
2979
3182
  }
2980
- u(!0), x(""), B("");
3183
+ k(!0), T(""), H("");
2981
3184
  try {
2982
- await S(P, h.id), B(o.successMessage), s == null || s();
2983
- } catch (j) {
2984
- const N = j.message || o.errorMessage;
2985
- x(N), a == null || a(N);
3185
+ await V({ email: x, tenantId: M.id }), H(E.successMessage), s == null || s();
3186
+ } catch (B) {
3187
+ const O = B.message || E.errorMessage;
3188
+ T(O), a == null || a(O);
2986
3189
  } finally {
2987
- u(!1);
3190
+ k(!1);
2988
3191
  }
2989
3192
  }
2990
- }, C = async (O) => {
2991
- if (O.preventDefault(), !!Y()) {
2992
- if (w !== I) {
2993
- x(o.passwordMismatchError), q({ confirmPassword: !0 });
3193
+ }, c = async (z) => {
3194
+ if (z.preventDefault(), !!f()) {
3195
+ if (h !== L) {
3196
+ T(E.passwordMismatchError), F({ confirmPassword: !0 });
2994
3197
  return;
2995
3198
  }
2996
- u(!0), x(""), B("");
3199
+ k(!0), T(""), H("");
2997
3200
  try {
2998
- await c(m, w), B(o.resetSuccessMessage), s == null || s();
2999
- } catch (j) {
3000
- const N = j.message || o.errorMessage;
3001
- x(N), a == null || a(N);
3201
+ await w({ token: b, newPassword: h }), H(E.resetSuccessMessage), s == null || s();
3202
+ } catch (B) {
3203
+ const O = B.message || E.errorMessage;
3204
+ T(O), a == null || a(O);
3002
3205
  } finally {
3003
- u(!1);
3206
+ k(!1);
3004
3207
  }
3005
3208
  }
3006
- }, k = (O) => ({
3007
- ...d.input,
3008
- ...z[O] ? d.inputError : {}
3009
- }), T = () => ({
3010
- ...d.button,
3011
- ...U ? d.buttonLoading : {}
3209
+ }, y = (z) => ({
3210
+ ...o.input,
3211
+ ...G[z] ? o.inputError : {}
3212
+ }), W = () => ({
3213
+ ...o.button,
3214
+ ...q ? o.buttonLoading : {}
3012
3215
  });
3013
3216
  if (t === "reset") {
3014
- const O = m && w && I;
3015
- return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3016
- /* @__PURE__ */ n("h2", { style: d.title, children: o.resetTitle }),
3017
- /* @__PURE__ */ n("p", { style: d.subtitle, children: o.resetSubtitle }),
3018
- /* @__PURE__ */ l("form", { onSubmit: C, style: d.form, children: [
3019
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3020
- /* @__PURE__ */ n("label", { style: d.label, children: o.tokenLabel }),
3217
+ const z = b && h && L;
3218
+ return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3219
+ /* @__PURE__ */ n("h2", { style: o.title, children: E.resetTitle }),
3220
+ /* @__PURE__ */ n("p", { style: o.subtitle, children: E.resetSubtitle }),
3221
+ /* @__PURE__ */ l("form", { onSubmit: c, style: o.form, children: [
3222
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3223
+ /* @__PURE__ */ n("label", { style: o.label, children: E.tokenLabel }),
3021
3224
  /* @__PURE__ */ n(
3022
3225
  "input",
3023
3226
  {
3024
3227
  type: "text",
3025
- value: m,
3026
- onChange: (j) => {
3027
- M(j.target.value), z.token && q((N) => ({ ...N, token: !1 }));
3228
+ value: b,
3229
+ onChange: (B) => {
3230
+ m(B.target.value), G.token && F((O) => ({ ...O, token: !1 }));
3028
3231
  },
3029
- placeholder: o.tokenPlaceholder,
3030
- style: k("token"),
3031
- disabled: U
3232
+ placeholder: E.tokenPlaceholder,
3233
+ style: y("token"),
3234
+ disabled: q
3032
3235
  }
3033
3236
  )
3034
3237
  ] }),
3035
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3036
- /* @__PURE__ */ n("label", { style: d.label, children: o.newPasswordLabel }),
3238
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3239
+ /* @__PURE__ */ n("label", { style: o.label, children: E.newPasswordLabel }),
3037
3240
  /* @__PURE__ */ n(
3038
3241
  "input",
3039
3242
  {
3040
3243
  type: "password",
3041
- value: w,
3042
- onChange: (j) => {
3043
- v(j.target.value), z.newPassword && q((N) => ({ ...N, newPassword: !1 }));
3244
+ value: h,
3245
+ onChange: (B) => {
3246
+ S(B.target.value), G.newPassword && F((O) => ({ ...O, newPassword: !1 }));
3044
3247
  },
3045
- placeholder: o.newPasswordPlaceholder,
3046
- style: k("newPassword"),
3047
- disabled: U
3248
+ placeholder: E.newPasswordPlaceholder,
3249
+ style: y("newPassword"),
3250
+ disabled: q
3048
3251
  }
3049
3252
  )
3050
3253
  ] }),
3051
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3052
- /* @__PURE__ */ n("label", { style: d.label, children: o.confirmPasswordLabel }),
3254
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3255
+ /* @__PURE__ */ n("label", { style: o.label, children: E.confirmPasswordLabel }),
3053
3256
  /* @__PURE__ */ n(
3054
3257
  "input",
3055
3258
  {
3056
3259
  type: "password",
3057
- value: I,
3058
- onChange: (j) => {
3059
- g(j.target.value), z.confirmPassword && q((N) => ({ ...N, confirmPassword: !1 })), y === o.passwordMismatchError && x("");
3260
+ value: L,
3261
+ onChange: (B) => {
3262
+ C(B.target.value), G.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && T("");
3060
3263
  },
3061
- placeholder: o.confirmPasswordPlaceholder,
3062
- style: k("confirmPassword"),
3063
- disabled: U
3264
+ placeholder: E.confirmPasswordPlaceholder,
3265
+ style: y("confirmPassword"),
3266
+ disabled: q
3064
3267
  }
3065
3268
  )
3066
3269
  ] }),
@@ -3068,44 +3271,44 @@ function Rt({
3068
3271
  "button",
3069
3272
  {
3070
3273
  type: "submit",
3071
- disabled: !O || U,
3274
+ disabled: !z || q,
3072
3275
  style: {
3073
- ...T(),
3074
- ...!O || U ? d.buttonDisabled : {}
3276
+ ...W(),
3277
+ ...!z || q ? o.buttonDisabled : {}
3075
3278
  },
3076
- children: U ? o.resetLoadingText : o.resetSubmitButton
3279
+ children: q ? E.resetLoadingText : E.resetSubmitButton
3077
3280
  }
3078
3281
  ),
3079
- y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3080
- F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
3282
+ u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3283
+ R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
3081
3284
  ] }),
3082
- /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3083
- /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3084
- E && /* @__PURE__ */ l(D, { children: [
3285
+ /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3286
+ /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3287
+ I && /* @__PURE__ */ l(N, { children: [
3085
3288
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3086
- /* @__PURE__ */ n("a", { onClick: () => E("request"), style: d.link, children: "Request New Link" })
3289
+ /* @__PURE__ */ n("a", { onClick: () => I("request"), style: o.link, children: "Request New Link" })
3087
3290
  ] })
3088
3291
  ] })
3089
3292
  ] });
3090
3293
  }
3091
- const J = P;
3092
- return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3093
- /* @__PURE__ */ n("h2", { style: d.title, children: o.title }),
3094
- /* @__PURE__ */ n("p", { style: d.subtitle, children: o.subtitle }),
3095
- /* @__PURE__ */ l("form", { onSubmit: H, style: d.form, children: [
3096
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3097
- /* @__PURE__ */ n("label", { style: d.label, children: o.emailLabel }),
3294
+ const ee = x;
3295
+ return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3296
+ /* @__PURE__ */ n("h2", { style: o.title, children: E.title }),
3297
+ /* @__PURE__ */ n("p", { style: o.subtitle, children: E.subtitle }),
3298
+ /* @__PURE__ */ l("form", { onSubmit: d, style: o.form, children: [
3299
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3300
+ /* @__PURE__ */ n("label", { style: o.label, children: E.emailLabel }),
3098
3301
  /* @__PURE__ */ n(
3099
3302
  "input",
3100
3303
  {
3101
3304
  type: "email",
3102
- value: P,
3103
- onChange: (O) => {
3104
- f(O.target.value), z.email && q((j) => ({ ...j, email: !1 }));
3305
+ value: x,
3306
+ onChange: (z) => {
3307
+ P(z.target.value), G.email && F((B) => ({ ...B, email: !1 }));
3105
3308
  },
3106
- placeholder: o.emailPlaceholder,
3107
- style: k("email"),
3108
- disabled: U
3309
+ placeholder: E.emailPlaceholder,
3310
+ style: y("email"),
3311
+ disabled: q
3109
3312
  }
3110
3313
  )
3111
3314
  ] }),
@@ -3113,27 +3316,27 @@ function Rt({
3113
3316
  "button",
3114
3317
  {
3115
3318
  type: "submit",
3116
- disabled: !J || U,
3319
+ disabled: !ee || q,
3117
3320
  style: {
3118
- ...T(),
3119
- ...!J || U ? d.buttonDisabled : {}
3321
+ ...W(),
3322
+ ...!ee || q ? o.buttonDisabled : {}
3120
3323
  },
3121
- children: U ? o.loadingText : o.submitButton
3324
+ children: q ? E.loadingText : E.submitButton
3122
3325
  }
3123
3326
  ),
3124
- y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3125
- F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
3327
+ u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3328
+ R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
3126
3329
  ] }),
3127
- /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3128
- /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3129
- E && /* @__PURE__ */ l(D, { children: [
3330
+ /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3331
+ /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3332
+ I && /* @__PURE__ */ l(N, { children: [
3130
3333
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3131
- /* @__PURE__ */ n("a", { onClick: () => E("reset"), style: d.link, children: "I have a token" })
3334
+ /* @__PURE__ */ n("a", { onClick: () => I("reset"), style: o.link, children: "I have a token" })
3132
3335
  ] })
3133
3336
  ] })
3134
3337
  ] });
3135
3338
  }
3136
- class Ct {
3339
+ class Ut {
3137
3340
  constructor(e, t) {
3138
3341
  this.httpService = e, this.sessionManager = t;
3139
3342
  }
@@ -3201,7 +3404,7 @@ class Ct {
3201
3404
  };
3202
3405
  }
3203
3406
  }
3204
- class It {
3407
+ class qt {
3205
3408
  constructor(e, t) {
3206
3409
  this.httpService = e, this.sessionManager = t;
3207
3410
  }
@@ -3252,7 +3455,7 @@ class It {
3252
3455
  });
3253
3456
  }
3254
3457
  }
3255
- class Ft {
3458
+ class zt {
3256
3459
  constructor(e) {
3257
3460
  this.httpService = e;
3258
3461
  }
@@ -3261,7 +3464,7 @@ class Ft {
3261
3464
  return await this.httpService.get("/health");
3262
3465
  }
3263
3466
  }
3264
- class Ht {
3467
+ class Ot {
3265
3468
  // Date string to Date object
3266
3469
  static toDate(e) {
3267
3470
  return new Date(e);
@@ -3384,44 +3587,44 @@ class Ht {
3384
3587
  }
3385
3588
  }
3386
3589
  export {
3387
- Ht as ApiMappers,
3388
- Te as AppApiService,
3389
- ht as AppProvider,
3390
- Re as AuthApiService,
3391
- yt as AuthProvider,
3392
- Pt as FeatureFlag,
3393
- He as FeatureFlagApiService,
3394
- bt as FeatureFlagProvider,
3395
- Ft as HealthApiService,
3396
- te as HttpService,
3397
- kt as LandingRoute,
3398
- Tt as LoginForm,
3399
- Et as MagicLinkForm,
3400
- Lt as MagicLinkVerify,
3401
- Rt as PasswordRecoveryForm,
3402
- Ct as PermissionApiService,
3403
- vt as Protected,
3404
- St as ProtectedRoute,
3405
- pe as RoleApiService,
3406
- Le as SessionManager,
3407
- Mt as SignupForm,
3408
- De as SubscriptionApiService,
3409
- At as SubscriptionGuard,
3410
- It as SubscriptionPlanApiService,
3411
- wt as SubscriptionProvider,
3412
- fe as TenantApiService,
3413
- pt as TenantProvider,
3414
- xt as TenantRoute,
3415
- Ce as UserApiService,
3416
- se as UserType,
3417
- gt as useApi,
3418
- ne as useApp,
3419
- ie as useAuth,
3420
- $e as useFeatureFlags,
3421
- mt as useSettings,
3422
- Be as useSubscription,
3423
- ge as useTenant,
3424
- re as useTenantInfo,
3425
- ft as useTenantSettings
3590
+ Ot as ApiMappers,
3591
+ be as AppApiService,
3592
+ St as AppProvider,
3593
+ Ne as AuthApiService,
3594
+ Pt as AuthProvider,
3595
+ Ft as FeatureFlag,
3596
+ ze as FeatureFlagApiService,
3597
+ Tt as FeatureFlagProvider,
3598
+ zt as HealthApiService,
3599
+ re as HttpService,
3600
+ Ct as LandingRoute,
3601
+ $t as LoginForm,
3602
+ Ht as MagicLinkForm,
3603
+ Nt as MagicLinkVerify,
3604
+ Bt as PasswordRecoveryForm,
3605
+ Ut as PermissionApiService,
3606
+ It as Protected,
3607
+ Et as ProtectedRoute,
3608
+ Se as RoleApiService,
3609
+ ye as SessionManager,
3610
+ Dt as SignupForm,
3611
+ je as SubscriptionApiService,
3612
+ Lt as SubscriptionGuard,
3613
+ qt as SubscriptionPlanApiService,
3614
+ Mt as SubscriptionProvider,
3615
+ ce as TenantApiService,
3616
+ xt as TenantProvider,
3617
+ Rt as TenantRoute,
3618
+ Be as UserApiService,
3619
+ ie as UserType,
3620
+ vt as useApi,
3621
+ he as useApp,
3622
+ oe as useAuth,
3623
+ Oe as useFeatureFlags,
3624
+ At as useSettings,
3625
+ Ve as useSubscription,
3626
+ fe as useTenant,
3627
+ se as useTenantInfo,
3628
+ kt as useTenantSettings
3426
3629
  };
3427
3630
  //# sourceMappingURL=index.es.js.map