@skylabs-digital/react-identity-access 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { jsx as n, Fragment as U, jsxs as l } from "react/jsx-runtime";
2
- import { createContext as he, useMemo as X, useState as x, useCallback as ne, useEffect as te, useContext as ce, useRef as Be } from "react";
1
+ import { jsx as n, Fragment as B, jsxs as c } from "react/jsx-runtime";
2
+ import { createContext as he, useMemo as X, useState as v, useCallback as ne, useEffect as te, useContext as ce, useRef as qe } from "react";
3
3
  import { useLocation as be, Navigate as pe } from "react-router-dom";
4
4
  class re {
5
5
  // SessionManager instance
@@ -16,27 +16,27 @@ class re {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
18
  async executeRequest(e, t, r, s, o = !1) {
19
- const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, b = (s == null ? void 0 : s.timeout) || this.timeout;
20
- let k = {
19
+ const g = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, w = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let x = {
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
26
  const m = await this.sessionManager.getAuthHeaders();
27
- k = { ...k, ...m };
27
+ x = { ...x, ...m };
28
28
  } catch (m) {
29
29
  console.warn("Failed to inject auth headers:", m);
30
30
  }
31
- const S = new AbortController(), T = setTimeout(() => S.abort(), b);
31
+ const b = new AbortController(), A = setTimeout(() => b.abort(), w);
32
32
  try {
33
- const m = await fetch(p, {
33
+ const m = await fetch(g, {
34
34
  method: e,
35
- headers: k,
35
+ headers: x,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: S.signal
37
+ signal: b.signal
38
38
  });
39
- if (clearTimeout(T), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(A), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
40
40
  try {
41
41
  const u = this.sessionManager.getTokens();
42
42
  if (u != null && u.refreshToken)
@@ -49,7 +49,7 @@ class re {
49
49
  const f = m.headers.get("content-type");
50
50
  return !f || !f.includes("application/json") ? {} : await m.json();
51
51
  } catch (m) {
52
- throw clearTimeout(T), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${b}ms`) : m;
52
+ throw clearTimeout(A), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${w}ms`) : m;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -125,7 +125,7 @@ class ve {
125
125
  }
126
126
  }
127
127
  const Pe = he(null);
128
- function Et({ config: i, children: e }) {
128
+ function Ct({ config: i, children: e }) {
129
129
  const t = X(
130
130
  () => {
131
131
  var f, u, y;
@@ -137,7 +137,7 @@ function Et({ config: i, children: e }) {
137
137
  };
138
138
  },
139
139
  [i.cache, i.appId]
140
- ), [r, s] = x(() => {
140
+ ), [r, s] = v(() => {
141
141
  if (!t.enabled) return null;
142
142
  try {
143
143
  const f = localStorage.getItem(t.storageKey);
@@ -147,9 +147,9 @@ function Et({ config: i, children: e }) {
147
147
  } catch {
148
148
  return null;
149
149
  }
150
- }), [o, p] = x(!r), [b, k] = x(null), S = X(() => {
150
+ }), [o, g] = v(!r), [w, x] = v(null), b = X(() => {
151
151
  const f = () => {
152
- T();
152
+ A();
153
153
  };
154
154
  return {
155
155
  appId: i.appId,
@@ -157,19 +157,19 @@ function Et({ config: i, children: e }) {
157
157
  // App info
158
158
  appInfo: r,
159
159
  isAppLoading: o,
160
- appError: b,
160
+ appError: w,
161
161
  retryApp: f
162
162
  };
163
- }, [i, r, o, b]), T = ne(
163
+ }, [i, r, o, w]), A = ne(
164
164
  async (f = !1) => {
165
165
  if (!(!f && t.enabled && r))
166
166
  try {
167
- p(!0), k(null);
168
- const u = new re(i.baseUrl), R = await new ve(u, {}).getPublicAppInfo(i.appId);
169
- if (s(R), t.enabled)
167
+ g(!0), x(null);
168
+ const u = new re(i.baseUrl), E = await new ve(u, {}).getPublicAppInfo(i.appId);
169
+ if (s(E), t.enabled)
170
170
  try {
171
171
  const C = {
172
- data: R,
172
+ data: E,
173
173
  timestamp: Date.now(),
174
174
  appId: i.appId
175
175
  };
@@ -179,9 +179,9 @@ function Et({ config: i, children: e }) {
179
179
  }
180
180
  } catch (u) {
181
181
  const y = u instanceof Error ? u : new Error("Failed to load app information");
182
- k(y), s(null);
182
+ x(y), s(null);
183
183
  } finally {
184
- p(!1);
184
+ g(!1);
185
185
  }
186
186
  },
187
187
  [i.baseUrl, i.appId, t, r]
@@ -192,22 +192,22 @@ function Et({ config: i, children: e }) {
192
192
  if (!f) return;
193
193
  const u = JSON.parse(f);
194
194
  if (Date.now() - u.timestamp > t.ttl * 0.5) {
195
- const R = new re(i.baseUrl), q = await new ve(R, {}).getPublicAppInfo(i.appId);
195
+ const E = new re(i.baseUrl), q = await new ve(E, {}).getPublicAppInfo(i.appId);
196
196
  s(q);
197
- const A = {
197
+ const T = {
198
198
  data: q,
199
199
  timestamp: Date.now(),
200
200
  appId: i.appId
201
201
  };
202
- localStorage.setItem(t.storageKey, JSON.stringify(A));
202
+ localStorage.setItem(t.storageKey, JSON.stringify(T));
203
203
  }
204
204
  } catch (f) {
205
205
  console.warn("Background app refresh failed:", f);
206
206
  }
207
207
  }, [i, t, r]);
208
208
  return te(() => {
209
- r ? m() : T();
210
- }, []), /* @__PURE__ */ n(Pe.Provider, { value: S, children: e });
209
+ r ? m() : A();
210
+ }, []), /* @__PURE__ */ n(Pe.Provider, { value: b, children: e });
211
211
  }
212
212
  function oe() {
213
213
  const i = ce(Pe);
@@ -215,7 +215,7 @@ function oe() {
215
215
  throw new Error("useApp must be used within an AppProvider");
216
216
  return i;
217
217
  }
218
- const Rt = oe;
218
+ const $t = oe;
219
219
  class we {
220
220
  constructor(e = {}) {
221
221
  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);
@@ -369,7 +369,7 @@ class we {
369
369
  return e !== null && !this.isTokenExpired(e);
370
370
  }
371
371
  }
372
- class Ue {
372
+ class ze {
373
373
  constructor(e) {
374
374
  this.httpService = e;
375
375
  }
@@ -481,16 +481,16 @@ class xe {
481
481
  throw new Error("SessionManager is required for private endpoints");
482
482
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
483
483
  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);
484
- const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(o, {
484
+ const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, g = await this.httpService.get(o, {
485
485
  headers: r
486
486
  });
487
487
  return {
488
- roles: p.data,
489
- meta: p.meta
488
+ roles: g.data,
489
+ meta: g.meta
490
490
  };
491
491
  }
492
492
  }
493
- class qe {
493
+ class Oe {
494
494
  constructor(e, t) {
495
495
  this.httpService = e, this.sessionManager = t;
496
496
  }
@@ -608,7 +608,7 @@ class ue {
608
608
  )).data;
609
609
  }
610
610
  }
611
- function ze(i, e) {
611
+ function We(i, e) {
612
612
  if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
613
613
  return null;
614
614
  if (e) {
@@ -616,34 +616,34 @@ function ze(i, e) {
616
616
  if (o === s || o === `www.${s}`)
617
617
  return null;
618
618
  if (o.endsWith(`.${s}`)) {
619
- const p = o.slice(0, -(s.length + 1));
620
- return p === "www" ? null : p;
619
+ const g = o.slice(0, -(s.length + 1));
620
+ return g === "www" ? null : g;
621
621
  }
622
622
  return null;
623
623
  }
624
624
  const r = i.split(".");
625
625
  return r.length >= 3 && r[0] !== "www" ? r[0] : null;
626
626
  }
627
- function Oe(i, e = "tenant", t) {
627
+ function Ve(i, e = "tenant", t) {
628
628
  const s = new URLSearchParams(i).get(e);
629
629
  return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
630
630
  }
631
- function We(i, e, t) {
631
+ function je(i, e, t) {
632
632
  const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
633
- return r === "subdomain" ? ze(e.hostname, s) : r === "selector" ? Oe(e.search, o, t) : null;
633
+ return r === "subdomain" ? We(e.hostname, s) : r === "selector" ? Ve(e.search, o, t) : null;
634
634
  }
635
- function je(i, e, t) {
635
+ function _e(i, e, t) {
636
636
  if (t)
637
637
  return `${i}.${t}`;
638
638
  const r = e.split(".");
639
639
  return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
640
640
  }
641
641
  const fe = "_auth";
642
- function Ve(i) {
642
+ function Ge(i) {
643
643
  const e = JSON.stringify(i);
644
644
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
645
645
  }
646
- function _e(i) {
646
+ function Ke(i) {
647
647
  try {
648
648
  let e = i.replace(/-/g, "+").replace(/_/g, "/");
649
649
  for (; e.length % 4; )
@@ -654,19 +654,34 @@ function _e(i) {
654
654
  return null;
655
655
  }
656
656
  }
657
- function Ge() {
658
- if (typeof window > "u") return null;
657
+ function Je() {
658
+ if (typeof window > "u")
659
+ return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
659
660
  const e = new URLSearchParams(window.location.search).get(fe);
660
- return e ? _e(e) : null;
661
+ if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
662
+ hasAuthParam: !!e,
663
+ searchParams: window.location.search,
664
+ encodedLength: e == null ? void 0 : e.length
665
+ }), !e) return null;
666
+ const t = Ke(e);
667
+ return console.log("[CrossDomainAuth] Token decode result:", {
668
+ success: !!t,
669
+ hasAccessToken: !!(t != null && t.accessToken),
670
+ hasRefreshToken: !!(t != null && t.refreshToken),
671
+ expiresIn: t == null ? void 0 : t.expiresIn
672
+ }), t;
661
673
  }
662
- function Ke() {
674
+ function Ye() {
663
675
  if (typeof window > "u") return;
664
676
  const i = new URL(window.location.href);
665
- i.searchParams.delete(fe), window.history.replaceState({}, "", i.toString());
677
+ i.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
678
+ oldUrl: window.location.href,
679
+ newUrl: i.toString()
680
+ }), window.history.replaceState({}, "", i.toString());
666
681
  }
667
682
  const Se = he(null);
668
- function Ct({ config: i, children: e }) {
669
- const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : We(
683
+ function Dt({ config: i, children: e }) {
684
+ const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : je(
670
685
  {
671
686
  tenantMode: i.tenantMode || "selector",
672
687
  baseDomain: i.baseDomain,
@@ -677,118 +692,118 @@ function Ct({ config: i, children: e }) {
677
692
  search: window.location.search
678
693
  },
679
694
  window.localStorage
680
- ), [i.tenantMode, i.baseDomain, i.selectorParam]), [p, b] = x(() => o()), k = X(
695
+ ), [i.tenantMode, i.baseDomain, i.selectorParam]), [g, w] = v(() => o()), x = X(
681
696
  () => {
682
- var a, L, c;
697
+ var l, I, k;
683
698
  return {
684
- enabled: ((a = i.cache) == null ? void 0 : a.enabled) ?? !0,
685
- ttl: ((L = i.cache) == null ? void 0 : L.ttl) ?? 5 * 60 * 1e3,
699
+ enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
700
+ ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
686
701
  // 5 minutes default
687
- storageKey: ((c = i.cache) == null ? void 0 : c.storageKey) ?? `tenant_cache_${p || "default"}`
702
+ storageKey: ((k = i.cache) == null ? void 0 : k.storageKey) ?? `tenant_cache_${g || "default"}`
688
703
  };
689
704
  },
690
- [i.cache, p]
691
- ), [S, T] = x(() => {
705
+ [i.cache, g]
706
+ ), [b, A] = v(() => {
692
707
  if (i.initialTenant) return i.initialTenant;
693
- if (!k.enabled || !p) return null;
708
+ if (!x.enabled || !g) return null;
694
709
  try {
695
- const a = localStorage.getItem(k.storageKey);
696
- if (!a) return null;
697
- const L = JSON.parse(a);
698
- return Date.now() - L.timestamp < k.ttl && L.tenantSlug === p ? L.data : (localStorage.removeItem(k.storageKey), null);
710
+ const l = localStorage.getItem(x.storageKey);
711
+ if (!l) return null;
712
+ const I = JSON.parse(l);
713
+ return Date.now() - I.timestamp < x.ttl && I.tenantSlug === g ? I.data : (localStorage.removeItem(x.storageKey), null);
699
714
  } catch {
700
715
  return null;
701
716
  }
702
- }), [m, f] = x(!S && !i.initialTenant), [u, y] = x(null), [R, C] = x(null), [q, A] = x(!1), [d, P] = x(null);
717
+ }), [m, f] = v(!b && !i.initialTenant), [u, y] = v(null), [E, C] = v(null), [q, T] = v(!1), [d, P] = v(null);
703
718
  te(() => {
704
- const a = o();
705
- b(a);
719
+ const l = o();
720
+ w(l);
706
721
  }, [o]);
707
- const E = (r == null ? void 0 : r.settingsSchema) || null, z = ne(
708
- async (a, L = !1) => {
709
- if (!(!L && k.enabled && S && S.domain === a))
722
+ const R = (r == null ? void 0 : r.settingsSchema) || null, z = ne(
723
+ async (l, I = !1) => {
724
+ if (!(!I && x.enabled && b && b.domain === l))
710
725
  try {
711
726
  f(!0), y(null);
712
- const c = new re(t), g = await new ue(c, s).getPublicTenantInfo(a);
713
- if (T(g), k.enabled)
727
+ const k = new re(t), a = await new ue(k, s).getPublicTenantInfo(l);
728
+ if (A(a), x.enabled)
714
729
  try {
715
- const w = {
716
- data: g,
730
+ const p = {
731
+ data: a,
717
732
  timestamp: Date.now(),
718
- tenantSlug: a
733
+ tenantSlug: l
719
734
  };
720
- localStorage.setItem(k.storageKey, JSON.stringify(w));
721
- } catch (w) {
722
- console.warn("Failed to cache tenant info:", w);
735
+ localStorage.setItem(x.storageKey, JSON.stringify(p));
736
+ } catch (p) {
737
+ console.warn("Failed to cache tenant info:", p);
723
738
  }
724
- } catch (c) {
725
- const h = c instanceof Error ? c : new Error("Failed to load tenant information");
726
- y(h), T(null);
739
+ } catch (k) {
740
+ const h = k instanceof Error ? k : new Error("Failed to load tenant information");
741
+ y(h), A(null);
727
742
  } finally {
728
743
  f(!1);
729
744
  }
730
745
  },
731
- [t, s, k, S]
746
+ [t, s, x, b]
732
747
  ), G = ne(async () => {
733
- if (!(!k.enabled || !S || !p))
748
+ if (!(!x.enabled || !b || !g))
734
749
  try {
735
- const a = localStorage.getItem(k.storageKey);
736
- if (!a) return;
737
- const L = JSON.parse(a);
738
- if (Date.now() - L.timestamp > k.ttl * 0.5) {
739
- const h = new re(t), w = await new ue(h, s).getPublicTenantInfo(p);
740
- T(w);
741
- const j = {
742
- data: w,
750
+ const l = localStorage.getItem(x.storageKey);
751
+ if (!l) return;
752
+ const I = JSON.parse(l);
753
+ if (Date.now() - I.timestamp > x.ttl * 0.5) {
754
+ const h = new re(t), p = await new ue(h, s).getPublicTenantInfo(g);
755
+ A(p);
756
+ const O = {
757
+ data: p,
743
758
  timestamp: Date.now(),
744
- tenantSlug: p
759
+ tenantSlug: g
745
760
  };
746
- localStorage.setItem(k.storageKey, JSON.stringify(j));
761
+ localStorage.setItem(x.storageKey, JSON.stringify(O));
747
762
  }
748
- } catch (a) {
749
- console.warn("Background tenant refresh failed:", a);
763
+ } catch (l) {
764
+ console.warn("Background tenant refresh failed:", l);
750
765
  }
751
- }, [t, s, k, S, p]), $ = ne(async () => {
752
- if (S != null && S.id)
766
+ }, [t, s, x, b, g]), $ = ne(async () => {
767
+ if (b != null && b.id)
753
768
  try {
754
- A(!0), P(null);
755
- const a = new re(t), c = await new ue(a, S.appId).getTenantSettings(S.id);
756
- C(c);
757
- } catch (a) {
758
- const L = a instanceof Error ? a : new Error("Failed to load tenant settings");
759
- P(L), C(null);
769
+ T(!0), P(null);
770
+ const l = new re(t), k = await new ue(l, b.appId).getTenantSettings(b.id);
771
+ C(k);
772
+ } catch (l) {
773
+ const I = l instanceof Error ? l : new Error("Failed to load tenant settings");
774
+ P(I), C(null);
760
775
  } finally {
761
- A(!1);
776
+ T(!1);
762
777
  }
763
- }, [t, S]), _ = ne(() => {
778
+ }, [t, b]), _ = ne(() => {
764
779
  $();
765
- }, [$]), v = ne(
766
- (a) => {
767
- if (!E)
780
+ }, [$]), S = ne(
781
+ (l) => {
782
+ if (!R)
768
783
  return { isValid: !0, errors: [] };
769
- const L = [];
784
+ const I = [];
770
785
  try {
771
- return E.properties && Object.entries(E.properties).forEach(([c, h]) => {
772
- var w;
773
- const g = a[c];
774
- if ((w = E.required) != null && w.includes(c) && g == null) {
775
- L.push(`Field '${c}' is required`);
786
+ return R.properties && Object.entries(R.properties).forEach(([k, h]) => {
787
+ var p;
788
+ const a = l[k];
789
+ if ((p = R.required) != null && p.includes(k) && a == null) {
790
+ I.push(`Field '${k}' is required`);
776
791
  return;
777
792
  }
778
- if (g != null) {
793
+ if (a != null) {
779
794
  if (h.type) {
780
- const j = h.type, Y = typeof g;
781
- j === "string" && Y !== "string" ? L.push(`Field '${c}' must be a string`) : (j === "number" || j === "integer") && Y !== "number" ? L.push(`Field '${c}' must be a number`) : j === "boolean" && Y !== "boolean" ? L.push(`Field '${c}' must be a boolean`) : j === "array" && !Array.isArray(g) && L.push(`Field '${c}' must be an array`);
795
+ const O = h.type, K = typeof a;
796
+ O === "string" && K !== "string" ? I.push(`Field '${k}' must be a string`) : (O === "number" || O === "integer") && K !== "number" ? I.push(`Field '${k}' must be a number`) : O === "boolean" && K !== "boolean" ? I.push(`Field '${k}' must be a boolean`) : O === "array" && !Array.isArray(a) && I.push(`Field '${k}' must be an array`);
782
797
  }
783
- h.minLength !== void 0 && typeof g == "string" && g.length < h.minLength && L.push(
784
- `Field '${c}' must be at least ${h.minLength} characters long`
785
- ), h.maxLength !== void 0 && typeof g == "string" && g.length > h.maxLength && L.push(
786
- `Field '${c}' must be no more than ${h.maxLength} characters long`
787
- ), h.minimum !== void 0 && typeof g == "number" && g < h.minimum && L.push(`Field '${c}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof g == "number" && g > h.maximum && L.push(`Field '${c}' must be no more than ${h.maximum}`), h.pattern && typeof g == "string" && (new RegExp(h.pattern).test(g) || L.push(`Field '${c}' does not match the required pattern`)), h.enum && !h.enum.includes(g) && L.push(`Field '${c}' must be one of: ${h.enum.join(", ")}`);
798
+ h.minLength !== void 0 && typeof a == "string" && a.length < h.minLength && I.push(
799
+ `Field '${k}' must be at least ${h.minLength} characters long`
800
+ ), h.maxLength !== void 0 && typeof a == "string" && a.length > h.maxLength && I.push(
801
+ `Field '${k}' must be no more than ${h.maxLength} characters long`
802
+ ), h.minimum !== void 0 && typeof a == "number" && a < h.minimum && I.push(`Field '${k}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof a == "number" && a > h.maximum && I.push(`Field '${k}' must be no more than ${h.maximum}`), h.pattern && typeof a == "string" && (new RegExp(h.pattern).test(a) || I.push(`Field '${k}' does not match the required pattern`)), h.enum && !h.enum.includes(a) && I.push(`Field '${k}' must be one of: ${h.enum.join(", ")}`);
788
803
  }
789
804
  }), {
790
- isValid: L.length === 0,
791
- errors: L
805
+ isValid: I.length === 0,
806
+ errors: I
792
807
  };
793
808
  } catch {
794
809
  return {
@@ -797,78 +812,78 @@ function Ct({ config: i, children: e }) {
797
812
  };
798
813
  }
799
814
  },
800
- [E]
815
+ [R]
801
816
  );
802
817
  te(() => {
803
- !i.initialTenant && p ? S ? G() : z(p) : !i.initialTenant && !p && (T(null), y(null), f(!1));
804
- }, [i.initialTenant, p, S, z, G]), te(() => {
805
- S != null && S.id ? $() : (C(null), P(null), A(!1));
806
- }, [S == null ? void 0 : S.id, $]);
818
+ !i.initialTenant && g ? b ? G() : z(g) : !i.initialTenant && !g && (A(null), y(null), f(!1));
819
+ }, [i.initialTenant, g, b, z, G]), te(() => {
820
+ b != null && b.id ? $() : (C(null), P(null), T(!1));
821
+ }, [b == null ? void 0 : b.id, $]);
807
822
  const M = ne(
808
- (a, L) => {
809
- const { mode: c = "reload", tokens: h, redirectPath: g } = L || {}, w = i.tenantMode || "selector";
810
- if (localStorage.setItem("tenant", a), w === "subdomain") {
811
- const j = window.location.hostname, Y = je(
812
- a,
813
- j,
823
+ (l, I) => {
824
+ const { mode: k = "reload", tokens: h, redirectPath: a } = I || {}, p = i.tenantMode || "selector";
825
+ if (localStorage.setItem("tenant", l), p === "subdomain") {
826
+ const O = window.location.hostname, K = _e(
827
+ l,
828
+ O,
814
829
  i.baseDomain
815
830
  );
816
- if (!Y) {
831
+ if (!K) {
817
832
  console.warn(
818
833
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
819
- j
834
+ O
820
835
  );
821
836
  return;
822
837
  }
823
- const H = g || window.location.pathname, N = new URL(`${window.location.protocol}//${Y}${H}`);
824
- new URLSearchParams(window.location.search).forEach((F, K) => {
825
- K !== fe && N.searchParams.set(K, F);
826
- }), h && N.searchParams.set(fe, Ve(h)), window.location.href = N.toString();
827
- } else if (w === "selector") {
828
- const j = g || window.location.pathname, Y = new URLSearchParams(window.location.search);
829
- if (Y.set(i.selectorParam || "tenant", a), c === "reload") {
830
- const H = `${j}?${Y.toString()}${window.location.hash}`;
838
+ const H = a || window.location.pathname, N = new URL(`${window.location.protocol}//${K}${H}`);
839
+ new URLSearchParams(window.location.search).forEach((D, J) => {
840
+ J !== fe && N.searchParams.set(J, D);
841
+ }), h && N.searchParams.set(fe, Ge(h)), window.location.href = N.toString();
842
+ } else if (p === "selector") {
843
+ const O = a || window.location.pathname, K = new URLSearchParams(window.location.search);
844
+ if (K.set(i.selectorParam || "tenant", l), k === "reload") {
845
+ const H = `${O}?${K.toString()}${window.location.hash}`;
831
846
  window.location.href = H;
832
847
  } else {
833
- const H = `${j}?${Y.toString()}${window.location.hash}`;
834
- window.history.pushState({}, "", H), b(a), z(a);
848
+ const H = `${O}?${K.toString()}${window.location.hash}`;
849
+ window.history.pushState({}, "", H), w(l), z(l);
835
850
  }
836
851
  }
837
852
  },
838
853
  [i.tenantMode, i.selectorParam, i.baseDomain, z]
839
- ), I = X(() => ({
854
+ ), L = X(() => ({
840
855
  // Tenant info
841
- tenant: S,
842
- tenantSlug: p,
856
+ tenant: b,
857
+ tenantSlug: g,
843
858
  isTenantLoading: m,
844
859
  tenantError: u,
845
860
  retryTenant: () => {
846
- p && z(p);
861
+ g && z(g);
847
862
  },
848
863
  // Settings
849
- settings: R,
850
- settingsSchema: E,
864
+ settings: E,
865
+ settingsSchema: R,
851
866
  isSettingsLoading: q,
852
867
  settingsError: d,
853
868
  // Actions
854
869
  refreshSettings: _,
855
870
  switchTenant: M,
856
871
  // Validation
857
- validateSettings: v
872
+ validateSettings: S
858
873
  }), [
859
- S,
860
- p,
874
+ b,
875
+ g,
861
876
  m,
862
877
  u,
863
- R,
864
878
  E,
879
+ R,
865
880
  q,
866
881
  d,
867
882
  _,
868
883
  M,
869
- v
884
+ S
870
885
  ]);
871
- return /* @__PURE__ */ n(Se.Provider, { value: I, children: e });
886
+ return /* @__PURE__ */ n(Se.Provider, { value: L, children: e });
872
887
  }
873
888
  function me() {
874
889
  const i = ce(Se);
@@ -879,8 +894,8 @@ function me() {
879
894
  function Me() {
880
895
  return ce(Se);
881
896
  }
882
- const $t = me;
883
- function Ft() {
897
+ const Ft = me;
898
+ function Ht() {
884
899
  const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
885
900
  return {
886
901
  settings: i,
@@ -901,287 +916,314 @@ function se() {
901
916
  };
902
917
  }
903
918
  const Ie = he(null);
904
- function Dt({ config: i = {}, children: e }) {
905
- const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: p } = me(), [b, k] = x(i.initialRoles || []), [S, T] = x(!i.initialRoles), [m, f] = x(null), [u, y] = x(!1), [R, C] = x(null), [q, A] = x(0), d = X(() => new we({
919
+ function Nt({ config: i = {}, children: e }) {
920
+ const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: g } = me(), [w, x] = v(i.initialRoles || []), [b, A] = v(!i.initialRoles), [m, f] = v(null), [u, y] = v(!1), [E, C] = v(null), [q, T] = v(0), d = X(() => new we({
906
921
  tenantSlug: o,
907
922
  // SessionManager will generate storageKey internally
908
923
  onRefreshFailed: i.onRefreshFailed,
909
924
  baseUrl: r
910
925
  }), [o, r, i.onRefreshFailed]), P = X(() => {
911
- const c = new re(r);
912
- return c.setSessionManager(d), c;
913
- }, [r, d]), E = X(() => new Ue(new re(r)), [r]), z = X(() => new qe(P, d), [P, d]), G = X(() => new xe(new re(r)), [r]), $ = X(() => m || d.getUser(), [m, d]), _ = X(() => $ != null && $.roleId && b.find((c) => c.id === $.roleId) || null, [$, b]), v = X(() => (_ == null ? void 0 : _.permissions) || [], [_]), M = X(() => d.hasValidSession() && m !== null, [d, m]), I = 5 * 60 * 1e3, a = X(() => {
914
- const c = async (D = !1) => {
926
+ const a = new re(r);
927
+ return a.setSessionManager(d), a;
928
+ }, [r, d]), R = X(() => new ze(new re(r)), [r]), z = X(() => new Oe(P, d), [P, d]), G = X(() => new xe(new re(r)), [r]), $ = X(() => m || d.getUser(), [m, d]), _ = X(() => $ != null && $.roleId && w.find((a) => a.id === $.roleId) || null, [$, w]), S = X(() => (_ == null ? void 0 : _.permissions) || [], [_]), M = X(() => d.hasValidSession() && m !== null, [d, m]), L = 5 * 60 * 1e3, l = X(() => {
929
+ const a = async (F = !1) => {
915
930
  try {
916
931
  if (!d.hasValidSession())
917
932
  return;
918
- const B = Date.now();
919
- if (!D && B - q < I && m)
933
+ const U = Date.now();
934
+ if (!F && U - q < L && m)
920
935
  return;
921
- const W = d.getUserId();
922
- if (!W) {
936
+ const V = d.getUserId();
937
+ if (!V) {
923
938
  console.warn("[AuthProvider] No userId available in token or storage");
924
939
  return;
925
940
  }
926
941
  y(!0), C(null);
927
- const Z = await z.getUserById(W);
928
- f(Z), d.setUser(Z), A(Date.now());
929
- } catch (B) {
930
- const J = B instanceof Error ? B : new Error("Failed to load user data");
931
- C(J), console.error("[AuthProvider] Failed to load user data:", J);
942
+ const Z = await z.getUserById(V);
943
+ f(Z), d.setUser(Z), T(Date.now());
944
+ } catch (U) {
945
+ const Y = U instanceof Error ? U : new Error("Failed to load user data");
946
+ C(Y), console.error("[AuthProvider] Failed to load user data:", Y);
932
947
  } finally {
933
948
  y(!1);
934
949
  }
935
- }, h = async () => {
936
- await c();
937
- }, g = async (D) => {
938
- const { username: B, password: J, tenantSlug: W } = D;
950
+ }, p = async () => {
951
+ await a();
952
+ }, O = async (F) => {
953
+ const { username: U, password: Y, tenantSlug: V } = F;
939
954
  let Z = s == null ? void 0 : s.id, Q = o, ee = d;
940
- W && (Z = (await new ue(P, t).getPublicTenantInfo(W)).id, Q = W);
941
- const V = await E.login({
942
- username: B,
943
- password: J,
955
+ V && (Z = (await new ue(P, t).getPublicTenantInfo(V)).id, Q = V);
956
+ const j = await R.login({
957
+ username: U,
958
+ password: Y,
944
959
  appId: t,
945
960
  tenantId: Z
946
- }), le = W && W !== o;
961
+ }), le = V && V !== o;
947
962
  if (le && (ee = new we({
948
963
  tenantSlug: Q,
949
964
  baseUrl: r
950
965
  })), ee.setTokens({
951
- accessToken: V.accessToken,
952
- refreshToken: V.refreshToken,
953
- expiresIn: V.expiresIn
954
- }), V.user) {
955
- ee.setUser(V.user), f(V.user);
966
+ accessToken: j.accessToken,
967
+ refreshToken: j.refreshToken,
968
+ expiresIn: j.expiresIn
969
+ }), j.user) {
970
+ ee.setUser(j.user), f(j.user);
956
971
  try {
957
- await c();
972
+ await a();
958
973
  } catch (de) {
959
974
  console.warn("Failed to load complete user data after login:", de);
960
975
  }
961
976
  }
962
- return le && Q && Q !== o && p(Q, {
977
+ return le && Q && Q !== o && g(Q, {
963
978
  tokens: {
964
- accessToken: V.accessToken,
965
- refreshToken: V.refreshToken,
966
- expiresIn: V.expiresIn
979
+ accessToken: j.accessToken,
980
+ refreshToken: j.refreshToken,
981
+ expiresIn: j.expiresIn
967
982
  }
968
- }), V;
969
- }, w = async (D) => {
970
- const { email: B, phoneNumber: J, name: W, password: Z, lastName: Q, tenantId: ee } = D;
971
- if (!B && !J)
983
+ }), j;
984
+ }, K = async (F) => {
985
+ const { email: U, phoneNumber: Y, name: V, password: Z, lastName: Q, tenantId: ee } = F;
986
+ if (!U && !Y)
972
987
  throw new Error("Either email or phoneNumber is required");
973
- if (!W || !Z)
988
+ if (!V || !Z)
974
989
  throw new Error("Name and password are required");
975
- const V = ee ?? (s == null ? void 0 : s.id);
976
- return await E.signup({
977
- email: B,
978
- phoneNumber: J,
979
- name: W,
990
+ const j = ee ?? (s == null ? void 0 : s.id);
991
+ return await R.signup({
992
+ email: U,
993
+ phoneNumber: Y,
994
+ name: V,
980
995
  password: Z,
981
- tenantId: V,
996
+ tenantId: j,
982
997
  lastName: Q,
983
998
  appId: t
984
999
  });
985
- }, j = async (D) => {
986
- const { email: B, phoneNumber: J, name: W, password: Z, tenantName: Q, lastName: ee } = D;
987
- if (!B && !J)
1000
+ }, H = async (F) => {
1001
+ const { email: U, phoneNumber: Y, name: V, password: Z, tenantName: Q, lastName: ee } = F;
1002
+ if (!U && !Y)
988
1003
  throw new Error("Either email or phoneNumber is required");
989
- if (!W || !Z || !Q)
1004
+ if (!V || !Z || !Q)
990
1005
  throw new Error("Name, password, and tenantName are required");
991
- return await E.signupTenantAdmin({
992
- email: B,
993
- phoneNumber: J,
994
- name: W,
1006
+ return await R.signupTenantAdmin({
1007
+ email: U,
1008
+ phoneNumber: Y,
1009
+ name: V,
995
1010
  password: Z,
996
1011
  tenantName: Q,
997
1012
  appId: t,
998
1013
  lastName: ee
999
1014
  });
1000
- }, Y = async (D) => {
1001
- const { currentPassword: B, newPassword: J } = D, W = await d.getAuthHeaders();
1002
- await E.changePassword({ currentPassword: B, newPassword: J }, W);
1003
- }, H = async (D) => {
1004
- const { email: B, tenantId: J } = D, W = J ?? (s == null ? void 0 : s.id);
1005
- if (!W)
1015
+ }, N = async (F) => {
1016
+ const { currentPassword: U, newPassword: Y } = F, V = await d.getAuthHeaders();
1017
+ await R.changePassword({ currentPassword: U, newPassword: Y }, V);
1018
+ }, W = async (F) => {
1019
+ const { email: U, tenantId: Y } = F, V = Y ?? (s == null ? void 0 : s.id);
1020
+ if (!V)
1006
1021
  throw new Error("tenantId is required for password reset");
1007
- await E.requestPasswordReset({ email: B, tenantId: W });
1008
- }, N = async (D) => {
1009
- const { token: B, newPassword: J } = D;
1010
- await E.confirmPasswordReset({ token: B, newPassword: J });
1011
- }, O = async (D) => {
1012
- const { email: B, frontendUrl: J, name: W, lastName: Z, tenantId: Q } = D, ee = Q ?? (s == null ? void 0 : s.id);
1022
+ await R.requestPasswordReset({ email: U, tenantId: V });
1023
+ }, D = async (F) => {
1024
+ const { token: U, newPassword: Y } = F;
1025
+ await R.confirmPasswordReset({ token: U, newPassword: Y });
1026
+ }, J = async (F) => {
1027
+ const { email: U, frontendUrl: Y, name: V, lastName: Z, tenantId: Q } = F, ee = Q ?? (s == null ? void 0 : s.id);
1013
1028
  if (!ee)
1014
1029
  throw new Error("tenantId is required for magic link authentication");
1015
- return await E.sendMagicLink({
1016
- email: B,
1030
+ return await R.sendMagicLink({
1031
+ email: U,
1017
1032
  tenantId: ee,
1018
- frontendUrl: J,
1019
- name: W,
1033
+ frontendUrl: Y,
1034
+ name: V,
1020
1035
  lastName: Z,
1021
1036
  appId: t
1022
1037
  });
1023
- }, F = async (D) => {
1024
- const { token: B, email: J, tenantSlug: W } = D;
1038
+ }, ge = async (F) => {
1039
+ const { token: U, email: Y, tenantSlug: V } = F;
1025
1040
  let Z = s == null ? void 0 : s.id, Q = o, ee = d;
1026
- W && (Z = (await new ue(P, t).getPublicTenantInfo(W)).id, Q = W);
1027
- const V = await E.verifyMagicLink({
1028
- token: B,
1029
- email: J,
1041
+ V && (Z = (await new ue(P, t).getPublicTenantInfo(V)).id, Q = V);
1042
+ const j = await R.verifyMagicLink({
1043
+ token: U,
1044
+ email: Y,
1030
1045
  appId: t,
1031
1046
  tenantId: Z
1032
- }), le = W && W !== o;
1047
+ }), le = V && V !== o;
1033
1048
  if (le && (ee = new we({
1034
1049
  tenantSlug: Q,
1035
1050
  baseUrl: r
1036
1051
  })), ee.setTokens({
1037
- accessToken: V.accessToken,
1038
- refreshToken: V.refreshToken,
1039
- expiresIn: V.expiresIn
1040
- }), V.user) {
1041
- ee.setUser(V.user), f(V.user);
1052
+ accessToken: j.accessToken,
1053
+ refreshToken: j.refreshToken,
1054
+ expiresIn: j.expiresIn
1055
+ }), j.user) {
1056
+ ee.setUser(j.user), f(j.user);
1042
1057
  try {
1043
- await c();
1058
+ await a();
1044
1059
  } catch (de) {
1045
1060
  console.warn("Failed to load complete user data after magic link login:", de);
1046
1061
  }
1047
1062
  }
1048
- return le && Q && Q !== o && p(Q, {
1063
+ return le && Q && Q !== o && g(Q, {
1049
1064
  tokens: {
1050
- accessToken: V.accessToken,
1051
- refreshToken: V.refreshToken,
1052
- expiresIn: V.expiresIn
1065
+ accessToken: j.accessToken,
1066
+ refreshToken: j.refreshToken,
1067
+ expiresIn: j.expiresIn
1053
1068
  }
1054
- }), V;
1055
- }, K = async () => {
1056
- const D = d.getTokens();
1057
- if (!(D != null && D.refreshToken))
1069
+ }), j;
1070
+ }, Ce = async () => {
1071
+ const F = d.getTokens();
1072
+ if (!(F != null && F.refreshToken))
1058
1073
  throw new Error("No refresh token available");
1059
- const B = await E.refreshToken({
1060
- refreshToken: D.refreshToken
1074
+ const U = await R.refreshToken({
1075
+ refreshToken: F.refreshToken
1061
1076
  });
1062
1077
  d.setTokens({
1063
- accessToken: B.accessToken,
1064
- refreshToken: B.refreshToken || D.refreshToken,
1065
- expiresIn: B.expiresIn
1078
+ accessToken: U.accessToken,
1079
+ refreshToken: U.refreshToken || F.refreshToken,
1080
+ expiresIn: U.expiresIn
1066
1081
  });
1067
- }, ge = () => {
1082
+ }, $e = () => {
1068
1083
  d.clearSession(), f(null), C(null);
1069
- }, Ce = (D) => {
1070
- d.setTokens(D);
1071
- }, $e = () => d.hasValidSession(), Fe = () => {
1084
+ }, De = (F) => {
1085
+ d.setTokens(F);
1086
+ }, Fe = () => d.hasValidSession(), He = () => {
1072
1087
  d.clearSession(), f(null), C(null);
1073
- }, De = async () => {
1088
+ }, Ne = async () => {
1074
1089
  if (t)
1075
1090
  try {
1076
- T(!0);
1077
- const { roles: D } = await G.getRolesByApp(t);
1078
- k(D);
1079
- } catch (D) {
1080
- console.error("Failed to fetch roles:", D);
1091
+ A(!0);
1092
+ const { roles: F } = await G.getRolesByApp(t);
1093
+ x(F);
1094
+ } catch (F) {
1095
+ console.error("Failed to fetch roles:", F);
1081
1096
  } finally {
1082
- T(!1);
1097
+ A(!1);
1083
1098
  }
1084
- }, He = async () => {
1085
- await De();
1086
- }, ye = (D) => {
1087
- if (!v || v.length === 0)
1099
+ }, Ue = async () => {
1100
+ await Ne();
1101
+ }, ye = (F) => {
1102
+ if (!S || S.length === 0)
1088
1103
  return !1;
1089
- if (typeof D == "string")
1090
- return v.includes(D);
1091
- const B = `${D.resource}.${D.action}`;
1092
- return v.includes(B);
1104
+ if (typeof F == "string")
1105
+ return S.includes(F);
1106
+ const U = `${F.resource}.${F.action}`;
1107
+ return S.includes(U);
1093
1108
  };
1094
1109
  return {
1095
1110
  // RFC-003: Authentication state
1096
1111
  isAuthenticated: M,
1097
1112
  sessionManager: d,
1098
1113
  authenticatedHttpService: P,
1099
- login: g,
1100
- signup: w,
1101
- signupTenantAdmin: j,
1102
- sendMagicLink: O,
1103
- verifyMagicLink: F,
1104
- changePassword: Y,
1105
- requestPasswordReset: H,
1106
- confirmPasswordReset: N,
1107
- refreshToken: K,
1108
- logout: ge,
1109
- setTokens: Ce,
1110
- hasValidSession: $e,
1111
- clearSession: Fe,
1114
+ login: O,
1115
+ signup: K,
1116
+ signupTenantAdmin: H,
1117
+ sendMagicLink: J,
1118
+ verifyMagicLink: ge,
1119
+ changePassword: N,
1120
+ requestPasswordReset: W,
1121
+ confirmPasswordReset: D,
1122
+ refreshToken: Ce,
1123
+ logout: $e,
1124
+ setTokens: De,
1125
+ hasValidSession: Fe,
1126
+ clearSession: He,
1112
1127
  currentUser: m,
1113
1128
  isUserLoading: u,
1114
- userError: R,
1115
- loadUserData: c,
1116
- refreshUser: h,
1129
+ userError: E,
1130
+ loadUserData: a,
1131
+ refreshUser: p,
1117
1132
  userRole: _,
1118
- userPermissions: v,
1119
- availableRoles: b,
1120
- rolesLoading: S,
1133
+ userPermissions: S,
1134
+ availableRoles: w,
1135
+ rolesLoading: b,
1121
1136
  hasPermission: ye,
1122
- hasAnyPermission: (D) => D.some((B) => ye(B)),
1123
- hasAllPermissions: (D) => D.every((B) => ye(B)),
1124
- getUserPermissionStrings: () => v || [],
1125
- refreshRoles: He
1137
+ hasAnyPermission: (F) => F.some((U) => ye(U)),
1138
+ hasAllPermissions: (F) => F.every((U) => ye(U)),
1139
+ getUserPermissionStrings: () => S || [],
1140
+ refreshRoles: Ue
1126
1141
  };
1127
1142
  }, [
1128
1143
  M,
1129
1144
  d,
1130
1145
  P,
1131
- E,
1146
+ R,
1132
1147
  z,
1133
1148
  G,
1134
1149
  t,
1135
1150
  s,
1136
1151
  o,
1137
- p,
1138
- b,
1152
+ g,
1153
+ w,
1139
1154
  m,
1140
1155
  u,
1141
- R,
1156
+ E,
1142
1157
  _,
1143
- v,
1158
+ S,
1144
1159
  q,
1145
- I
1160
+ L
1146
1161
  ]);
1147
1162
  te(() => {
1148
1163
  !i.initialRoles && t && (async () => {
1149
1164
  try {
1150
- T(!0);
1151
- const h = new re(r), g = new xe(h), { roles: w } = await g.getRolesByApp(t);
1152
- k(w);
1153
- } catch (h) {
1154
- console.error("Failed to fetch roles:", h);
1165
+ A(!0);
1166
+ const p = new re(r), O = new xe(p), { roles: K } = await O.getRolesByApp(t);
1167
+ x(K);
1168
+ } catch (p) {
1169
+ console.error("Failed to fetch roles:", p);
1155
1170
  } finally {
1156
- T(!1);
1171
+ A(!1);
1157
1172
  }
1158
1173
  })();
1159
1174
  }, [t, r, i.initialRoles]);
1160
- const L = Be(!1);
1175
+ const [I, k] = v(!1), h = qe(!1);
1161
1176
  return te(() => {
1162
- if (L.current) return;
1163
- const c = Ge();
1164
- c && (L.current = !0, d.setTokens({
1165
- accessToken: c.accessToken,
1166
- refreshToken: c.refreshToken,
1167
- expiresIn: c.expiresIn
1168
- }), Ke(), a.loadUserData().catch(() => {
1177
+ if (console.log("[AuthProvider] Cross-subdomain auth effect running", {
1178
+ alreadyChecked: I,
1179
+ alreadyProcessed: h.current,
1180
+ currentUrl: typeof window < "u" ? window.location.href : "SSR"
1181
+ }), I) {
1182
+ console.log("[AuthProvider] URL tokens already checked, skipping");
1183
+ return;
1184
+ }
1185
+ k(!0);
1186
+ const a = Je();
1187
+ console.log("[AuthProvider] URL tokens extraction result:", {
1188
+ found: !!a,
1189
+ hasAccessToken: !!(a != null && a.accessToken)
1190
+ }), a && (h.current = !0, console.log("[AuthProvider] Saving URL tokens to session..."), d.setTokens({
1191
+ accessToken: a.accessToken,
1192
+ refreshToken: a.refreshToken,
1193
+ expiresIn: a.expiresIn
1194
+ }), console.log("[AuthProvider] Tokens saved, verifying session validity:", {
1195
+ hasValidSession: d.hasValidSession()
1196
+ }), Ye(), console.log("[AuthProvider] Loading user data after URL token consumption..."), l.loadUserData().catch((p) => {
1197
+ console.error(
1198
+ "[AuthProvider] Failed to load user data after URL token consumption:",
1199
+ p
1200
+ );
1169
1201
  }));
1170
- }, [d, a]), te(() => {
1171
- const c = d.getUser();
1172
- c && d.hasValidSession() && f(c);
1202
+ }, [d, l, I]), te(() => {
1203
+ const a = d.getUser();
1204
+ a && d.hasValidSession() && f(a);
1173
1205
  }, [d]), te(() => {
1174
- !m && !u && a.loadUserData().catch(() => {
1175
- });
1176
- }, [m, u, a]), te(() => {
1206
+ if (console.log("[AuthProvider] Auto-load effect running", {
1207
+ hasCurrentUser: !!m,
1208
+ isUserLoading: u,
1209
+ hasValidSession: d.hasValidSession(),
1210
+ urlTokensChecked: I,
1211
+ urlTokensProcessed: h.current
1212
+ }), !I) {
1213
+ console.log("[AuthProvider] Waiting for URL tokens check before auto-load");
1214
+ return;
1215
+ }
1216
+ !m && !u && (console.log("[AuthProvider] Auto-loading user data..."), l.loadUserData().catch(() => {
1217
+ }));
1218
+ }, [m, u, l, d, I]), te(() => {
1177
1219
  if (!d.hasValidSession() || !m)
1178
1220
  return;
1179
- const c = setInterval(() => {
1180
- a.loadUserData().catch(() => {
1221
+ const a = setInterval(() => {
1222
+ l.loadUserData().catch(() => {
1181
1223
  });
1182
- }, I);
1183
- return () => clearInterval(c);
1184
- }, [d, m, a, I]), /* @__PURE__ */ n(Ie.Provider, { value: a, children: e });
1224
+ }, L);
1225
+ return () => clearInterval(a);
1226
+ }, [d, m, l, L]), /* @__PURE__ */ n(Ie.Provider, { value: l, children: e });
1185
1227
  }
1186
1228
  function ae() {
1187
1229
  const i = ce(Ie);
@@ -1189,7 +1231,7 @@ function ae() {
1189
1231
  throw new Error("useAuth must be used within an AuthProvider");
1190
1232
  return i;
1191
1233
  }
1192
- class Je {
1234
+ class Qe {
1193
1235
  constructor(e, t) {
1194
1236
  this.httpService = e, this.sessionManager = t;
1195
1237
  }
@@ -1270,57 +1312,57 @@ class Je {
1270
1312
  }
1271
1313
  }
1272
1314
  const Le = he(null);
1273
- function Ht({ config: i = {}, children: e }) {
1274
- const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, p] = x([]), [b, k] = x(!1), [S, T] = x(null), m = X(() => {
1315
+ function Ut({ config: i = {}, children: e }) {
1316
+ const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = v([]), [w, x] = v(!1), [b, A] = v(null), m = X(() => {
1275
1317
  const y = new re(t);
1276
- return new Je(y);
1318
+ return new Qe(y);
1277
1319
  }, [t]), f = async () => {
1278
1320
  if (!(s != null && s.id)) {
1279
- p([]);
1321
+ g([]);
1280
1322
  return;
1281
1323
  }
1282
- k(!0), T(null);
1324
+ x(!0), A(null);
1283
1325
  try {
1284
1326
  const y = await m.getTenantFeatureFlags(s.id, r);
1285
- p(y);
1327
+ g(y);
1286
1328
  } catch (y) {
1287
- const R = y instanceof Error ? y.message : "Failed to fetch feature flags";
1288
- T(R), i.onError && i.onError(y instanceof Error ? y : new Error(R));
1329
+ const E = y instanceof Error ? y.message : "Failed to fetch feature flags";
1330
+ A(E), i.onError && i.onError(y instanceof Error ? y : new Error(E));
1289
1331
  } finally {
1290
- k(!1);
1332
+ x(!1);
1291
1333
  }
1292
1334
  };
1293
1335
  te(() => {
1294
1336
  f();
1295
- const y = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(f, y);
1296
- return () => clearInterval(R);
1337
+ const y = i.refreshInterval || 5 * 60 * 1e3, E = setInterval(f, y);
1338
+ return () => clearInterval(E);
1297
1339
  }, [s == null ? void 0 : s.id, i.refreshInterval]);
1298
1340
  const u = X(() => ({
1299
1341
  featureFlags: o,
1300
- loading: b,
1301
- error: S,
1302
- isEnabled: (A) => {
1303
- const d = o.find((P) => P.key === A);
1342
+ loading: w,
1343
+ error: b,
1344
+ isEnabled: (T) => {
1345
+ const d = o.find((P) => P.key === T);
1304
1346
  return (d == null ? void 0 : d.value) === !0;
1305
1347
  },
1306
- getFlag: (A) => o.find((d) => d.key === A),
1307
- getFlagState: (A) => {
1308
- const d = o.find((P) => P.key === A);
1348
+ getFlag: (T) => o.find((d) => d.key === T),
1349
+ getFlagState: (T) => {
1350
+ const d = o.find((P) => P.key === T);
1309
1351
  return d ? d.value ? "enabled" : "disabled" : "not_found";
1310
1352
  },
1311
1353
  refresh: async () => {
1312
1354
  await f();
1313
1355
  }
1314
- }), [o, b, S]);
1356
+ }), [o, w, b]);
1315
1357
  return /* @__PURE__ */ n(Le.Provider, { value: u, children: e });
1316
1358
  }
1317
- function Ye() {
1359
+ function Xe() {
1318
1360
  const i = ce(Le);
1319
1361
  if (!i)
1320
1362
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1321
1363
  return i;
1322
1364
  }
1323
- class Qe {
1365
+ class Ze {
1324
1366
  constructor(e, t) {
1325
1367
  this.httpService = e, this.sessionManager = t;
1326
1368
  }
@@ -1386,25 +1428,25 @@ class Qe {
1386
1428
  )).data;
1387
1429
  }
1388
1430
  }
1389
- const Ee = he(void 0);
1390
- function Nt({ config: i = {}, children: e }) {
1391
- const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = x(null), [p, b] = x(!1), [k, S] = x(null), T = X(() => {
1431
+ const Re = he(void 0);
1432
+ function Bt({ config: i = {}, children: e }) {
1433
+ const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = v(null), [g, w] = v(!1), [x, b] = v(null), A = X(() => {
1392
1434
  const u = new re(t);
1393
- return new Qe(u);
1435
+ return new Ze(u);
1394
1436
  }, [t]), m = async () => {
1395
1437
  if (!(r != null && r.id)) {
1396
1438
  o(null);
1397
1439
  return;
1398
1440
  }
1399
- b(!0), S(null);
1441
+ w(!0), b(null);
1400
1442
  try {
1401
- const u = await T.getTenantSubscriptionFeatures(r.id);
1443
+ const u = await A.getTenantSubscriptionFeatures(r.id);
1402
1444
  o(u);
1403
1445
  } catch (u) {
1404
1446
  const y = u instanceof Error ? u.message : "Failed to fetch subscription";
1405
- S(y), i.onError && i.onError(u instanceof Error ? u : new Error(y));
1447
+ b(y), i.onError && i.onError(u instanceof Error ? u : new Error(y));
1406
1448
  } finally {
1407
- b(!1);
1449
+ w(!1);
1408
1450
  }
1409
1451
  };
1410
1452
  te(() => {
@@ -1417,33 +1459,33 @@ function Nt({ config: i = {}, children: e }) {
1417
1459
  return {
1418
1460
  subscription: s,
1419
1461
  features: u,
1420
- loading: p,
1421
- error: k,
1462
+ loading: g,
1463
+ error: x,
1422
1464
  isFeatureEnabled: (d) => {
1423
- const P = u.find((E) => E.key === d);
1465
+ const P = u.find((R) => R.key === d);
1424
1466
  return P ? P.type === "BOOLEAN" || P.type === "boolean" ? P.value === !0 : !!P.value : !1;
1425
1467
  },
1426
1468
  getFeature: (d) => u.find((P) => P.key === d),
1427
1469
  getFeatureValue: (d, P) => {
1428
- const E = u.find((z) => z.key === d);
1429
- return E ? E.value : P;
1470
+ const R = u.find((z) => z.key === d);
1471
+ return R ? R.value : P;
1430
1472
  },
1431
1473
  hasAllowedPlan: (d) => !s || !s.isActive ? !1 : d.includes(s.planId),
1432
1474
  refresh: async () => {
1433
1475
  await m();
1434
1476
  }
1435
1477
  };
1436
- }, [s, p, k]);
1437
- return /* @__PURE__ */ n(Ee.Provider, { value: f, children: e });
1478
+ }, [s, g, x]);
1479
+ return /* @__PURE__ */ n(Re.Provider, { value: f, children: e });
1438
1480
  }
1439
- function Xe() {
1440
- const i = ce(Ee);
1481
+ function et() {
1482
+ const i = ce(Re);
1441
1483
  if (i === void 0)
1442
1484
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1443
1485
  return i;
1444
1486
  }
1445
1487
  var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
1446
- const ke = () => /* @__PURE__ */ l(
1488
+ const ke = () => /* @__PURE__ */ c(
1447
1489
  "div",
1448
1490
  {
1449
1491
  style: {
@@ -1480,11 +1522,11 @@ const ke = () => /* @__PURE__ */ l(
1480
1522
  )
1481
1523
  ]
1482
1524
  }
1483
- ), Te = ({
1525
+ ), Ae = ({
1484
1526
  userType: i,
1485
1527
  minUserType: e,
1486
1528
  missingPermissions: t
1487
- }) => /* @__PURE__ */ l(
1529
+ }) => /* @__PURE__ */ c(
1488
1530
  "div",
1489
1531
  {
1490
1532
  style: {
@@ -1502,26 +1544,26 @@ const ke = () => /* @__PURE__ */ l(
1502
1544
  children: [
1503
1545
  /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1504
1546
  /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1505
- e && i ? /* @__PURE__ */ l(U, { children: [
1506
- /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1547
+ e && i ? /* @__PURE__ */ c(B, { children: [
1548
+ /* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1507
1549
  "This content requires ",
1508
1550
  /* @__PURE__ */ n("strong", { children: e }),
1509
1551
  " access level or higher."
1510
1552
  ] }),
1511
- /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1553
+ /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1512
1554
  "Your current access level: ",
1513
1555
  /* @__PURE__ */ n("strong", { children: i })
1514
1556
  ] })
1515
- ] }) : /* @__PURE__ */ l(U, { children: [
1557
+ ] }) : /* @__PURE__ */ c(B, { children: [
1516
1558
  /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1517
- t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1559
+ t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1518
1560
  "Required permissions: ",
1519
1561
  /* @__PURE__ */ n("strong", { children: t.join(", ") })
1520
1562
  ] })
1521
1563
  ] })
1522
1564
  ]
1523
1565
  }
1524
- ), Ze = (i, e) => {
1566
+ ), tt = (i, e) => {
1525
1567
  const t = {
1526
1568
  [ie.USER]: 1,
1527
1569
  [ie.TENANT_ADMIN]: 2,
@@ -1529,28 +1571,28 @@ const ke = () => /* @__PURE__ */ l(
1529
1571
  };
1530
1572
  return t[i] >= t[e];
1531
1573
  };
1532
- function Bt({
1574
+ function qt({
1533
1575
  children: i,
1534
1576
  fallback: e,
1535
1577
  minUserType: t,
1536
1578
  requiredPermissions: r,
1537
1579
  requireAllPermissions: s = !1
1538
1580
  }) {
1539
- const { hasValidSession: o, sessionManager: p, hasPermission: b, hasAnyPermission: k, hasAllPermissions: S } = ae();
1581
+ const { hasValidSession: o, sessionManager: g, hasPermission: w, hasAnyPermission: x, hasAllPermissions: b } = ae();
1540
1582
  if (!o())
1541
- return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(ke, {}) });
1542
- const T = p.getUser();
1543
- if (!T)
1544
- return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(ke, {}) });
1545
- if (t && !Ze(T.userType, t))
1546
- return /* @__PURE__ */ n(Te, { userType: T.userType, minUserType: t });
1547
- if (r && r.length > 0 && !(s ? S(r) : k(r))) {
1548
- const f = r.filter((u) => !b(u)).map((u) => typeof u == "string" ? u : u.name);
1549
- return /* @__PURE__ */ n(Te, { missingPermissions: f });
1550
- }
1551
- return /* @__PURE__ */ n(U, { children: i });
1583
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ke, {}) });
1584
+ const A = g.getUser();
1585
+ if (!A)
1586
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ke, {}) });
1587
+ if (t && !tt(A.userType, t))
1588
+ return /* @__PURE__ */ n(Ae, { userType: A.userType, minUserType: t });
1589
+ if (r && r.length > 0 && !(s ? b(r) : x(r))) {
1590
+ const f = r.filter((u) => !w(u)).map((u) => typeof u == "string" ? u : u.name);
1591
+ return /* @__PURE__ */ n(Ae, { missingPermissions: f });
1592
+ }
1593
+ return /* @__PURE__ */ n(B, { children: i });
1552
1594
  }
1553
- const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1595
+ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1554
1596
  "div",
1555
1597
  {
1556
1598
  style: {
@@ -1563,7 +1605,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1563
1605
  backgroundColor: "#f9fafb",
1564
1606
  textAlign: "center"
1565
1607
  },
1566
- children: /* @__PURE__ */ l(
1608
+ children: /* @__PURE__ */ c(
1567
1609
  "div",
1568
1610
  {
1569
1611
  style: {
@@ -1577,7 +1619,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1577
1619
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1578
1620
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1579
1621
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1580
- /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1622
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1581
1623
  "Redirecting to ",
1582
1624
  i,
1583
1625
  "..."
@@ -1586,7 +1628,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1586
1628
  }
1587
1629
  )
1588
1630
  }
1589
- ), Ae = ({
1631
+ ), Te = ({
1590
1632
  userType: i,
1591
1633
  minUserType: e,
1592
1634
  missingPermissions: t
@@ -1603,7 +1645,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1603
1645
  backgroundColor: "#f9fafb",
1604
1646
  textAlign: "center"
1605
1647
  },
1606
- children: /* @__PURE__ */ l(
1648
+ children: /* @__PURE__ */ c(
1607
1649
  "div",
1608
1650
  {
1609
1651
  style: {
@@ -1616,19 +1658,19 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1616
1658
  children: [
1617
1659
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1618
1660
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1619
- e && i ? /* @__PURE__ */ l(U, { children: [
1620
- /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1661
+ e && i ? /* @__PURE__ */ c(B, { children: [
1662
+ /* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1621
1663
  "This page requires ",
1622
1664
  /* @__PURE__ */ n("strong", { children: e }),
1623
1665
  " access level or higher."
1624
1666
  ] }),
1625
- /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1667
+ /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1626
1668
  "Your current access level: ",
1627
1669
  /* @__PURE__ */ n("strong", { children: i })
1628
1670
  ] })
1629
- ] }) : /* @__PURE__ */ l(U, { children: [
1671
+ ] }) : /* @__PURE__ */ c(B, { children: [
1630
1672
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1631
- t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1673
+ t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1632
1674
  "Required permissions: ",
1633
1675
  /* @__PURE__ */ n("strong", { children: t.join(", ") })
1634
1676
  ] })
@@ -1637,7 +1679,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1637
1679
  }
1638
1680
  )
1639
1681
  }
1640
- ), tt = (i, e) => {
1682
+ ), nt = (i, e) => {
1641
1683
  const t = {
1642
1684
  [ie.USER]: 1,
1643
1685
  [ie.TENANT_ADMIN]: 2,
@@ -1645,7 +1687,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1645
1687
  };
1646
1688
  return t[i] >= t[e];
1647
1689
  };
1648
- function Ut({
1690
+ function zt({
1649
1691
  children: i,
1650
1692
  redirectTo: e = "/login",
1651
1693
  minUserType: t,
@@ -1653,24 +1695,24 @@ function Ut({
1653
1695
  requireAllPermissions: s = !1,
1654
1696
  fallback: o
1655
1697
  }) {
1656
- const { hasValidSession: p, sessionManager: b, hasPermission: k, hasAnyPermission: S, hasAllPermissions: T } = ae(), m = be();
1657
- if (!p())
1658
- return o ? /* @__PURE__ */ n(U, { children: o }) : /* @__PURE__ */ l(U, { children: [
1659
- /* @__PURE__ */ n(et, { redirectPath: e }),
1698
+ const { hasValidSession: g, sessionManager: w, hasPermission: x, hasAnyPermission: b, hasAllPermissions: A } = ae(), m = be();
1699
+ if (!g())
1700
+ return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ c(B, { children: [
1701
+ /* @__PURE__ */ n(rt, { redirectPath: e }),
1660
1702
  /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 })
1661
1703
  ] });
1662
- const f = b.getUser();
1704
+ const f = w.getUser();
1663
1705
  if (!f)
1664
1706
  return /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 });
1665
- if (t && !tt(f.userType, t))
1666
- return /* @__PURE__ */ n(Ae, { userType: f.userType, minUserType: t });
1667
- if (r && r.length > 0 && !(s ? T(r) : S(r))) {
1668
- const y = r.filter((R) => !k(R)).map((R) => typeof R == "string" ? R : R.name);
1669
- return /* @__PURE__ */ n(Ae, { missingPermissions: y });
1707
+ if (t && !nt(f.userType, t))
1708
+ return /* @__PURE__ */ n(Te, { userType: f.userType, minUserType: t });
1709
+ if (r && r.length > 0 && !(s ? A(r) : b(r))) {
1710
+ const y = r.filter((E) => !x(E)).map((E) => typeof E == "string" ? E : E.name);
1711
+ return /* @__PURE__ */ n(Te, { missingPermissions: y });
1670
1712
  }
1671
- return /* @__PURE__ */ n(U, { children: i });
1713
+ return /* @__PURE__ */ n(B, { children: i });
1672
1714
  }
1673
- const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1715
+ const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
1674
1716
  "div",
1675
1717
  {
1676
1718
  style: {
@@ -1683,7 +1725,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1683
1725
  backgroundColor: "#f9fafb",
1684
1726
  textAlign: "center"
1685
1727
  },
1686
- children: /* @__PURE__ */ l(
1728
+ children: /* @__PURE__ */ c(
1687
1729
  "div",
1688
1730
  {
1689
1731
  style: {
@@ -1697,7 +1739,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1697
1739
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1698
1740
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1699
1741
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1700
- /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1742
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1701
1743
  "Redirecting to ",
1702
1744
  i,
1703
1745
  "..."
@@ -1707,14 +1749,14 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1707
1749
  )
1708
1750
  }
1709
1751
  );
1710
- function qt({ children: i, redirectTo: e = "/", fallback: t }) {
1711
- const { tenant: r, isLoading: s, error: o } = se(), p = be();
1712
- return s || o ? null : r ? /* @__PURE__ */ n(U, { children: i }) : t ? /* @__PURE__ */ n(U, { children: t }) : /* @__PURE__ */ l(U, { children: [
1713
- /* @__PURE__ */ n(rt, { redirectPath: e }),
1714
- /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1752
+ function Ot({ children: i, redirectTo: e = "/", fallback: t }) {
1753
+ const { tenant: r, isLoading: s, error: o } = se(), g = be();
1754
+ return s || o ? null : r ? /* @__PURE__ */ n(B, { children: i }) : t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ c(B, { children: [
1755
+ /* @__PURE__ */ n(st, { redirectPath: e }),
1756
+ /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1715
1757
  ] });
1716
1758
  }
1717
- const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1759
+ const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
1718
1760
  "div",
1719
1761
  {
1720
1762
  style: {
@@ -1727,7 +1769,7 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1727
1769
  backgroundColor: "#f9fafb",
1728
1770
  textAlign: "center"
1729
1771
  },
1730
- children: /* @__PURE__ */ l(
1772
+ children: /* @__PURE__ */ c(
1731
1773
  "div",
1732
1774
  {
1733
1775
  style: {
@@ -1741,7 +1783,7 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1741
1783
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1742
1784
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1743
1785
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1744
- /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1786
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1745
1787
  "Redirecting to ",
1746
1788
  i,
1747
1789
  "..."
@@ -1751,14 +1793,14 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1751
1793
  )
1752
1794
  }
1753
1795
  );
1754
- function zt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1755
- const { tenant: r, isLoading: s, error: o } = se(), p = be();
1756
- return s || o ? null : r ? t ? /* @__PURE__ */ n(U, { children: t }) : /* @__PURE__ */ l(U, { children: [
1757
- /* @__PURE__ */ n(nt, { redirectPath: e }),
1758
- /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1759
- ] }) : /* @__PURE__ */ n(U, { children: i });
1796
+ function Wt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1797
+ const { tenant: r, isLoading: s, error: o } = se(), g = be();
1798
+ return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ c(B, { children: [
1799
+ /* @__PURE__ */ n(it, { redirectPath: e }),
1800
+ /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1801
+ ] }) : /* @__PURE__ */ n(B, { children: i });
1760
1802
  }
1761
- const st = () => /* @__PURE__ */ l(
1803
+ const ot = () => /* @__PURE__ */ c(
1762
1804
  "div",
1763
1805
  {
1764
1806
  style: {
@@ -1775,14 +1817,14 @@ const st = () => /* @__PURE__ */ l(
1775
1817
  ]
1776
1818
  }
1777
1819
  );
1778
- function Ot({
1820
+ function Vt({
1779
1821
  children: i,
1780
- fallback: e = /* @__PURE__ */ n(st, {}),
1822
+ fallback: e = /* @__PURE__ */ n(ot, {}),
1781
1823
  allowedPlans: t,
1782
1824
  requiredFeature: r
1783
1825
  }) {
1784
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: p, loading: b } = Xe();
1785
- return b ? /* @__PURE__ */ n(
1826
+ const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: w } = et();
1827
+ return w ? /* @__PURE__ */ n(
1786
1828
  "div",
1787
1829
  {
1788
1830
  style: {
@@ -1792,9 +1834,9 @@ function Ot({
1792
1834
  },
1793
1835
  children: "Loading subscription..."
1794
1836
  }
1795
- ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(U, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: i }) : /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: e });
1837
+ ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !g(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
1796
1838
  }
1797
- const it = ({ flagName: i }) => /* @__PURE__ */ l(
1839
+ const at = ({ flagName: i }) => /* @__PURE__ */ c(
1798
1840
  "div",
1799
1841
  {
1800
1842
  style: {
@@ -1813,7 +1855,7 @@ const it = ({ flagName: i }) => /* @__PURE__ */ l(
1813
1855
  children: [
1814
1856
  /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1815
1857
  /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1816
- /* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1858
+ /* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1817
1859
  'Feature flag "',
1818
1860
  i,
1819
1861
  '" is disabled'
@@ -1821,8 +1863,8 @@ const it = ({ flagName: i }) => /* @__PURE__ */ l(
1821
1863
  ]
1822
1864
  }
1823
1865
  );
1824
- function Wt({ name: i, children: e, fallback: t }) {
1825
- const { isEnabled: r, loading: s } = Ye();
1866
+ function jt({ name: i, children: e, fallback: t }) {
1867
+ const { isEnabled: r, loading: s } = Xe();
1826
1868
  return s ? /* @__PURE__ */ n(
1827
1869
  "div",
1828
1870
  {
@@ -1836,9 +1878,9 @@ function Wt({ name: i, children: e, fallback: t }) {
1836
1878
  },
1837
1879
  children: "Loading feature flags..."
1838
1880
  }
1839
- ) : r(i) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: t || /* @__PURE__ */ n(it, { flagName: i }) });
1881
+ ) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(at, { flagName: i }) });
1840
1882
  }
1841
- const ot = () => /* @__PURE__ */ l(
1883
+ const lt = () => /* @__PURE__ */ c(
1842
1884
  "svg",
1843
1885
  {
1844
1886
  width: "16",
@@ -1855,7 +1897,7 @@ const ot = () => /* @__PURE__ */ l(
1855
1897
  /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1856
1898
  ]
1857
1899
  }
1858
- ), at = () => /* @__PURE__ */ l(
1900
+ ), ct = () => /* @__PURE__ */ c(
1859
1901
  "svg",
1860
1902
  {
1861
1903
  width: "16",
@@ -1872,10 +1914,10 @@ const ot = () => /* @__PURE__ */ l(
1872
1914
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1873
1915
  ]
1874
1916
  }
1875
- ), lt = {
1876
- showPassword: /* @__PURE__ */ n(ot, {}),
1877
- hidePassword: /* @__PURE__ */ n(at, {})
1878
- }, ct = {
1917
+ ), dt = {
1918
+ showPassword: /* @__PURE__ */ n(lt, {}),
1919
+ hidePassword: /* @__PURE__ */ n(ct, {})
1920
+ }, ut = {
1879
1921
  title: "Sign In",
1880
1922
  usernameLabel: "Email or Phone",
1881
1923
  usernamePlaceholder: "Enter your email or phone number",
@@ -1889,7 +1931,7 @@ const ot = () => /* @__PURE__ */ l(
1889
1931
  magicLinkLink: "Use Magic Link",
1890
1932
  errorMessage: "Invalid credentials",
1891
1933
  loadingText: "Signing in..."
1892
- }, dt = {
1934
+ }, ht = {
1893
1935
  container: {
1894
1936
  maxWidth: "400px",
1895
1937
  width: "100%",
@@ -1996,57 +2038,57 @@ const ot = () => /* @__PURE__ */ l(
1996
2038
  fontSize: "0.875rem"
1997
2039
  }
1998
2040
  };
1999
- function jt({
2041
+ function _t({
2000
2042
  copy: i = {},
2001
2043
  styles: e = {},
2002
2044
  icons: t = {},
2003
2045
  onSuccess: r,
2004
2046
  onError: s,
2005
2047
  onForgotPassword: o,
2006
- onSignupClick: p,
2007
- onMagicLinkClick: b,
2008
- showForgotPassword: k = !0,
2009
- showSignupLink: S = !0,
2010
- showMagicLinkOption: T = !0,
2048
+ onSignupClick: g,
2049
+ onMagicLinkClick: w,
2050
+ showForgotPassword: x = !0,
2051
+ showSignupLink: b = !0,
2052
+ showMagicLinkOption: A = !0,
2011
2053
  className: m
2012
2054
  }) {
2013
- const [f, u] = x(""), [y, R] = x(""), [C, q] = x(!1), [A, d] = x(!1), [P, E] = x(""), [z, G] = x({}), { login: $ } = ae(), { tenant: _ } = se(), v = { ...ct, ...i }, M = { ...dt, ...e }, I = { ...lt, ...t }, a = () => {
2014
- const g = {};
2015
- return f.trim() || (g.username = !0), y.trim() || (g.password = !0), G(g), Object.keys(g).length === 0;
2016
- }, L = async (g) => {
2017
- if (g.preventDefault(), !!a()) {
2055
+ const [f, u] = v(""), [y, E] = v(""), [C, q] = v(!1), [T, d] = v(!1), [P, R] = v(""), [z, G] = v({}), { login: $ } = ae(), { tenant: _ } = se(), S = { ...ut, ...i }, M = { ...ht, ...e }, L = { ...dt, ...t }, l = () => {
2056
+ const a = {};
2057
+ return f.trim() || (a.username = !0), y.trim() || (a.password = !0), G(a), Object.keys(a).length === 0;
2058
+ }, I = async (a) => {
2059
+ if (a.preventDefault(), !!l()) {
2018
2060
  if (!(_ != null && _.id)) {
2019
- E("Tenant not found");
2061
+ R("Tenant not found");
2020
2062
  return;
2021
2063
  }
2022
- d(!0), E("");
2064
+ d(!0), R("");
2023
2065
  try {
2024
- const w = await $({
2066
+ const p = await $({
2025
2067
  username: f,
2026
2068
  password: y
2027
2069
  // tenantId inferred from context automatically
2028
2070
  });
2029
- r == null || r(w);
2030
- } catch (w) {
2031
- const j = w.message || v.errorMessage;
2032
- E(j), s == null || s(j);
2071
+ r == null || r(p);
2072
+ } catch (p) {
2073
+ const O = p.message || S.errorMessage;
2074
+ R(O), s == null || s(O);
2033
2075
  } finally {
2034
2076
  d(!1);
2035
2077
  }
2036
2078
  }
2037
- }, c = (g) => ({
2079
+ }, k = (a) => ({
2038
2080
  ...M.input,
2039
- ...z[g] ? M.inputError : {}
2081
+ ...z[a] ? M.inputError : {}
2040
2082
  }), h = () => ({
2041
2083
  ...M.button,
2042
- ...A ? M.buttonLoading : {},
2043
- ...!f || !y || A ? M.buttonDisabled : {}
2084
+ ...T ? M.buttonLoading : {},
2085
+ ...!f || !y || T ? M.buttonDisabled : {}
2044
2086
  });
2045
- return /* @__PURE__ */ l("div", { className: m, style: M.container, children: [
2046
- /* @__PURE__ */ n("h2", { style: M.title, children: v.title }),
2047
- /* @__PURE__ */ l("form", { onSubmit: L, style: M.form, children: [
2048
- /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2049
- /* @__PURE__ */ n("label", { style: M.label, children: v.usernameLabel }),
2087
+ return /* @__PURE__ */ c("div", { className: m, style: M.container, children: [
2088
+ /* @__PURE__ */ n("h2", { style: M.title, children: S.title }),
2089
+ /* @__PURE__ */ c("form", { onSubmit: I, style: M.form, children: [
2090
+ /* @__PURE__ */ c("div", { style: M.fieldGroup, children: [
2091
+ /* @__PURE__ */ n("label", { style: M.label, children: S.usernameLabel }),
2050
2092
  /* @__PURE__ */ n(
2051
2093
  "input",
2052
2094
  {
@@ -2054,18 +2096,18 @@ function jt({
2054
2096
  name: "username",
2055
2097
  type: "text",
2056
2098
  value: f,
2057
- onChange: (g) => {
2058
- u(g.target.value), z.username && G((w) => ({ ...w, username: !1 }));
2099
+ onChange: (a) => {
2100
+ u(a.target.value), z.username && G((p) => ({ ...p, username: !1 }));
2059
2101
  },
2060
- placeholder: v.usernamePlaceholder,
2061
- style: c("username"),
2062
- disabled: A
2102
+ placeholder: S.usernamePlaceholder,
2103
+ style: k("username"),
2104
+ disabled: T
2063
2105
  }
2064
2106
  )
2065
2107
  ] }),
2066
- /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2067
- /* @__PURE__ */ n("label", { style: M.label, children: v.passwordLabel }),
2068
- /* @__PURE__ */ l("div", { style: M.inputContainer, children: [
2108
+ /* @__PURE__ */ c("div", { style: M.fieldGroup, children: [
2109
+ /* @__PURE__ */ n("label", { style: M.label, children: S.passwordLabel }),
2110
+ /* @__PURE__ */ c("div", { style: M.inputContainer, children: [
2069
2111
  /* @__PURE__ */ n(
2070
2112
  "input",
2071
2113
  {
@@ -2073,16 +2115,16 @@ function jt({
2073
2115
  name: "password",
2074
2116
  type: C ? "text" : "password",
2075
2117
  value: y,
2076
- onChange: (g) => {
2077
- R(g.target.value), z.password && G((w) => ({ ...w, password: !1 }));
2118
+ onChange: (a) => {
2119
+ E(a.target.value), z.password && G((p) => ({ ...p, password: !1 }));
2078
2120
  },
2079
- placeholder: v.passwordPlaceholder,
2121
+ placeholder: S.passwordPlaceholder,
2080
2122
  style: {
2081
- ...c("password"),
2123
+ ...k("password"),
2082
2124
  paddingRight: "2.5rem"
2083
2125
  // Make room for the icon
2084
2126
  },
2085
- disabled: A
2127
+ disabled: T
2086
2128
  }
2087
2129
  ),
2088
2130
  /* @__PURE__ */ n(
@@ -2091,38 +2133,38 @@ function jt({
2091
2133
  type: "button",
2092
2134
  onClick: () => q(!C),
2093
2135
  style: M.passwordToggle,
2094
- disabled: A,
2136
+ disabled: T,
2095
2137
  "aria-label": C ? "Hide password" : "Show password",
2096
- children: C ? I.hidePassword : I.showPassword
2138
+ children: C ? L.hidePassword : L.showPassword
2097
2139
  }
2098
2140
  )
2099
2141
  ] })
2100
2142
  ] }),
2101
- /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !y || A, style: h(), children: A ? v.loadingText : v.submitButton }),
2143
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !y || T, style: h(), children: T ? S.loadingText : S.submitButton }),
2102
2144
  P && /* @__PURE__ */ n("div", { style: M.errorText, children: P })
2103
2145
  ] }),
2104
- (k || S || T) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2105
- T && /* @__PURE__ */ l("div", { children: [
2106
- /* @__PURE__ */ l("span", { style: M.divider, children: [
2107
- v.magicLinkText,
2146
+ (x || b || A) && /* @__PURE__ */ c("div", { style: M.linkContainer, children: [
2147
+ A && /* @__PURE__ */ c("div", { children: [
2148
+ /* @__PURE__ */ c("span", { style: M.divider, children: [
2149
+ S.magicLinkText,
2108
2150
  " "
2109
2151
  ] }),
2110
- /* @__PURE__ */ n("a", { onClick: b, style: M.link, children: v.magicLinkLink })
2152
+ /* @__PURE__ */ n("a", { onClick: w, style: M.link, children: S.magicLinkLink })
2111
2153
  ] }),
2112
- T && (k || S) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2113
- k && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: v.forgotPasswordLink }),
2114
- k && S && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2115
- S && /* @__PURE__ */ l("div", { children: [
2116
- /* @__PURE__ */ l("span", { style: M.divider, children: [
2117
- v.signupText,
2154
+ A && (x || b) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2155
+ x && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: S.forgotPasswordLink }),
2156
+ x && b && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2157
+ b && /* @__PURE__ */ c("div", { children: [
2158
+ /* @__PURE__ */ c("span", { style: M.divider, children: [
2159
+ S.signupText,
2118
2160
  " "
2119
2161
  ] }),
2120
- /* @__PURE__ */ n("a", { onClick: p, style: M.link, children: v.signupLink })
2162
+ /* @__PURE__ */ n("a", { onClick: g, style: M.link, children: S.signupLink })
2121
2163
  ] })
2122
2164
  ] })
2123
2165
  ] });
2124
2166
  }
2125
- const ut = {
2167
+ const gt = {
2126
2168
  title: "Create Account",
2127
2169
  nameLabel: "First Name",
2128
2170
  namePlaceholder: "Enter your first name",
@@ -2148,7 +2190,7 @@ const ut = {
2148
2190
  passwordMismatchError: "Passwords do not match",
2149
2191
  isAdminLabel: "Create new organization",
2150
2192
  isAdminDescription: "Check this if you want to create a new organization"
2151
- }, ht = {
2193
+ }, pt = {
2152
2194
  container: {
2153
2195
  maxWidth: "400px",
2154
2196
  width: "100%",
@@ -2247,25 +2289,25 @@ const ut = {
2247
2289
  fontSize: "0.875rem"
2248
2290
  }
2249
2291
  };
2250
- function Vt({
2292
+ function Gt({
2251
2293
  copy: i = {},
2252
2294
  styles: e = {},
2253
2295
  signupType: t = "user",
2254
2296
  onSuccess: r,
2255
2297
  onError: s,
2256
2298
  onLoginClick: o,
2257
- onMagicLinkClick: p,
2258
- showLoginLink: b = !0,
2259
- showMagicLinkOption: k = !0,
2260
- className: S
2299
+ onMagicLinkClick: g,
2300
+ showLoginLink: w = !0,
2301
+ showMagicLinkOption: x = !0,
2302
+ className: b
2261
2303
  }) {
2262
- const [T, m] = x(""), [f, u] = x(""), [y, R] = x(""), [C, q] = x(""), [A, d] = x(""), [P, E] = x(""), [z, G] = x(""), [$, _] = x(!1), [v, M] = x(""), [I, a] = x({}), { signup: L, signupTenantAdmin: c } = ae(), { tenant: h } = se(), g = { ...ut, ...i }, w = { ...ht, ...e }, j = () => {
2263
- const F = {};
2264
- return T.trim() || (F.name = !0), !y.trim() && !C.trim() && (F.email = !0, F.phoneNumber = !0), A.trim() || (F.password = !0), P.trim() || (F.confirmPassword = !0), t === "tenant" && !z.trim() && (F.tenantName = !0), a(F), Object.keys(F).length === 0;
2265
- }, Y = async (F) => {
2266
- if (F.preventDefault(), !!j()) {
2267
- if (A !== P) {
2268
- M(g.passwordMismatchError), a({ confirmPassword: !0 });
2304
+ const [A, m] = v(""), [f, u] = v(""), [y, E] = v(""), [C, q] = v(""), [T, d] = v(""), [P, R] = v(""), [z, G] = v(""), [$, _] = v(!1), [S, M] = v(""), [L, l] = v({}), { signup: I, signupTenantAdmin: k } = ae(), { tenant: h } = se(), a = { ...gt, ...i }, p = { ...pt, ...e }, O = () => {
2305
+ const D = {};
2306
+ return A.trim() || (D.name = !0), !y.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), T.trim() || (D.password = !0), P.trim() || (D.confirmPassword = !0), t === "tenant" && !z.trim() && (D.tenantName = !0), l(D), Object.keys(D).length === 0;
2307
+ }, K = async (D) => {
2308
+ if (D.preventDefault(), !!O()) {
2309
+ if (T !== P) {
2310
+ M(a.passwordMismatchError), l({ confirmPassword: !0 });
2269
2311
  return;
2270
2312
  }
2271
2313
  if (t === "user" && !(h != null && h.id)) {
@@ -2274,60 +2316,60 @@ function Vt({
2274
2316
  }
2275
2317
  _(!0), M("");
2276
2318
  try {
2277
- let K;
2278
- t === "tenant" ? K = await c({
2319
+ let J;
2320
+ t === "tenant" ? J = await k({
2279
2321
  email: y || void 0,
2280
2322
  phoneNumber: C || void 0,
2281
- name: T,
2282
- password: A,
2323
+ name: A,
2324
+ password: T,
2283
2325
  tenantName: z,
2284
2326
  lastName: f || void 0
2285
- }) : K = await L({
2327
+ }) : J = await I({
2286
2328
  email: y || void 0,
2287
2329
  phoneNumber: C || void 0,
2288
- name: T,
2289
- password: A,
2330
+ name: A,
2331
+ password: T,
2290
2332
  tenantId: h.id,
2291
2333
  lastName: f || void 0
2292
- }), r == null || r(K);
2293
- } catch (K) {
2294
- const ge = K.message || g.errorMessage;
2334
+ }), r == null || r(J);
2335
+ } catch (J) {
2336
+ const ge = J.message || a.errorMessage;
2295
2337
  M(ge), s == null || s(ge);
2296
2338
  } finally {
2297
2339
  _(!1);
2298
2340
  }
2299
2341
  }
2300
- }, H = (F) => ({
2301
- ...w.input,
2302
- ...I[F] ? w.inputError : {}
2342
+ }, H = (D) => ({
2343
+ ...p.input,
2344
+ ...L[D] ? p.inputError : {}
2303
2345
  }), N = () => ({
2304
- ...w.button,
2305
- ...$ ? w.buttonLoading : {},
2306
- ...!T || !y && !C || !A || !P || $ || t === "tenant" && !z ? w.buttonDisabled : {}
2307
- }), O = T && (y || C) && A && P && (t === "user" || z);
2308
- return /* @__PURE__ */ l("div", { className: S, style: w.container, children: [
2309
- /* @__PURE__ */ n("h2", { style: w.title, children: g.title }),
2310
- /* @__PURE__ */ l("form", { onSubmit: Y, style: w.form, children: [
2311
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2312
- /* @__PURE__ */ n("label", { style: w.label, children: g.nameLabel }),
2346
+ ...p.button,
2347
+ ...$ ? p.buttonLoading : {},
2348
+ ...!A || !y && !C || !T || !P || $ || t === "tenant" && !z ? p.buttonDisabled : {}
2349
+ }), W = A && (y || C) && T && P && (t === "user" || z);
2350
+ return /* @__PURE__ */ c("div", { className: b, style: p.container, children: [
2351
+ /* @__PURE__ */ n("h2", { style: p.title, children: a.title }),
2352
+ /* @__PURE__ */ c("form", { onSubmit: K, style: p.form, children: [
2353
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2354
+ /* @__PURE__ */ n("label", { style: p.label, children: a.nameLabel }),
2313
2355
  /* @__PURE__ */ n(
2314
2356
  "input",
2315
2357
  {
2316
2358
  id: "name",
2317
2359
  name: "name",
2318
2360
  type: "text",
2319
- value: T,
2320
- onChange: (F) => {
2321
- m(F.target.value), I.name && a((K) => ({ ...K, name: !1 }));
2361
+ value: A,
2362
+ onChange: (D) => {
2363
+ m(D.target.value), L.name && l((J) => ({ ...J, name: !1 }));
2322
2364
  },
2323
- placeholder: g.namePlaceholder,
2365
+ placeholder: a.namePlaceholder,
2324
2366
  style: H("name"),
2325
2367
  disabled: $
2326
2368
  }
2327
2369
  )
2328
2370
  ] }),
2329
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2330
- /* @__PURE__ */ n("label", { style: w.label, children: g.lastNameLabel }),
2371
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2372
+ /* @__PURE__ */ n("label", { style: p.label, children: a.lastNameLabel }),
2331
2373
  /* @__PURE__ */ n(
2332
2374
  "input",
2333
2375
  {
@@ -2335,15 +2377,15 @@ function Vt({
2335
2377
  name: "lastName",
2336
2378
  type: "text",
2337
2379
  value: f,
2338
- onChange: (F) => u(F.target.value),
2339
- placeholder: g.lastNamePlaceholder,
2340
- style: w.input,
2380
+ onChange: (D) => u(D.target.value),
2381
+ placeholder: a.lastNamePlaceholder,
2382
+ style: p.input,
2341
2383
  disabled: $
2342
2384
  }
2343
2385
  )
2344
2386
  ] }),
2345
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2346
- /* @__PURE__ */ n("label", { style: w.label, children: g.emailLabel }),
2387
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2388
+ /* @__PURE__ */ n("label", { style: p.label, children: a.emailLabel }),
2347
2389
  /* @__PURE__ */ n(
2348
2390
  "input",
2349
2391
  {
@@ -2351,17 +2393,17 @@ function Vt({
2351
2393
  name: "email",
2352
2394
  type: "email",
2353
2395
  value: y,
2354
- onChange: (F) => {
2355
- R(F.target.value), I.email && a((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2396
+ onChange: (D) => {
2397
+ E(D.target.value), L.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2356
2398
  },
2357
- placeholder: g.emailPlaceholder,
2399
+ placeholder: a.emailPlaceholder,
2358
2400
  style: H("email"),
2359
2401
  disabled: $
2360
2402
  }
2361
2403
  )
2362
2404
  ] }),
2363
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2364
- /* @__PURE__ */ n("label", { style: w.label, children: g.phoneNumberLabel }),
2405
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2406
+ /* @__PURE__ */ n("label", { style: p.label, children: a.phoneNumberLabel }),
2365
2407
  /* @__PURE__ */ n(
2366
2408
  "input",
2367
2409
  {
@@ -2369,10 +2411,10 @@ function Vt({
2369
2411
  name: "phoneNumber",
2370
2412
  type: "tel",
2371
2413
  value: C,
2372
- onChange: (F) => {
2373
- q(F.target.value), I.phoneNumber && a((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2414
+ onChange: (D) => {
2415
+ q(D.target.value), L.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2374
2416
  },
2375
- placeholder: g.phoneNumberPlaceholder,
2417
+ placeholder: a.phoneNumberPlaceholder,
2376
2418
  style: H("phoneNumber"),
2377
2419
  disabled: $
2378
2420
  }
@@ -2390,26 +2432,26 @@ function Vt({
2390
2432
  children: "At least one contact method (email or phone) is required"
2391
2433
  }
2392
2434
  ),
2393
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2394
- /* @__PURE__ */ n("label", { style: w.label, children: g.passwordLabel }),
2435
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2436
+ /* @__PURE__ */ n("label", { style: p.label, children: a.passwordLabel }),
2395
2437
  /* @__PURE__ */ n(
2396
2438
  "input",
2397
2439
  {
2398
2440
  id: "password",
2399
2441
  name: "password",
2400
2442
  type: "password",
2401
- value: A,
2402
- onChange: (F) => {
2403
- d(F.target.value), I.password && a((K) => ({ ...K, password: !1 }));
2443
+ value: T,
2444
+ onChange: (D) => {
2445
+ d(D.target.value), L.password && l((J) => ({ ...J, password: !1 }));
2404
2446
  },
2405
- placeholder: g.passwordPlaceholder,
2447
+ placeholder: a.passwordPlaceholder,
2406
2448
  style: H("password"),
2407
2449
  disabled: $
2408
2450
  }
2409
2451
  )
2410
2452
  ] }),
2411
- /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2412
- /* @__PURE__ */ n("label", { style: w.label, children: g.confirmPasswordLabel }),
2453
+ /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2454
+ /* @__PURE__ */ n("label", { style: p.label, children: a.confirmPasswordLabel }),
2413
2455
  /* @__PURE__ */ n(
2414
2456
  "input",
2415
2457
  {
@@ -2417,17 +2459,17 @@ function Vt({
2417
2459
  name: "confirmPassword",
2418
2460
  type: "password",
2419
2461
  value: P,
2420
- onChange: (F) => {
2421
- E(F.target.value), I.confirmPassword && a((K) => ({ ...K, confirmPassword: !1 })), v === g.passwordMismatchError && M("");
2462
+ onChange: (D) => {
2463
+ R(D.target.value), L.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), S === a.passwordMismatchError && M("");
2422
2464
  },
2423
- placeholder: g.confirmPasswordPlaceholder,
2465
+ placeholder: a.confirmPasswordPlaceholder,
2424
2466
  style: H("confirmPassword"),
2425
2467
  disabled: $
2426
2468
  }
2427
2469
  )
2428
2470
  ] }),
2429
- t === "tenant" && /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2430
- /* @__PURE__ */ n("label", { style: w.label, children: g.tenantNameLabel }),
2471
+ t === "tenant" && /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
2472
+ /* @__PURE__ */ n("label", { style: p.label, children: a.tenantNameLabel }),
2431
2473
  /* @__PURE__ */ n(
2432
2474
  "input",
2433
2475
  {
@@ -2435,38 +2477,38 @@ function Vt({
2435
2477
  name: "tenantName",
2436
2478
  type: "text",
2437
2479
  value: z,
2438
- onChange: (F) => {
2439
- G(F.target.value), I.tenantName && a((K) => ({ ...K, tenantName: !1 }));
2480
+ onChange: (D) => {
2481
+ G(D.target.value), L.tenantName && l((J) => ({ ...J, tenantName: !1 }));
2440
2482
  },
2441
- placeholder: g.tenantNamePlaceholder,
2483
+ placeholder: a.tenantNamePlaceholder,
2442
2484
  style: H("tenantName"),
2443
2485
  disabled: $
2444
2486
  }
2445
2487
  )
2446
2488
  ] }),
2447
- /* @__PURE__ */ n("button", { type: "submit", disabled: !O || $, style: N(), children: $ ? g.loadingText : g.submitButton }),
2448
- v && /* @__PURE__ */ n("div", { style: w.errorText, children: v })
2489
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !W || $, style: N(), children: $ ? a.loadingText : a.submitButton }),
2490
+ S && /* @__PURE__ */ n("div", { style: p.errorText, children: S })
2449
2491
  ] }),
2450
- (b || k) && /* @__PURE__ */ l("div", { style: w.linkContainer, children: [
2451
- k && /* @__PURE__ */ l("div", { children: [
2452
- /* @__PURE__ */ l("span", { style: w.divider, children: [
2453
- g.magicLinkText,
2492
+ (w || x) && /* @__PURE__ */ c("div", { style: p.linkContainer, children: [
2493
+ x && /* @__PURE__ */ c("div", { children: [
2494
+ /* @__PURE__ */ c("span", { style: p.divider, children: [
2495
+ a.magicLinkText,
2454
2496
  " "
2455
2497
  ] }),
2456
- /* @__PURE__ */ n("a", { onClick: p, style: w.link, children: g.magicLinkLink })
2498
+ /* @__PURE__ */ n("a", { onClick: g, style: p.link, children: a.magicLinkLink })
2457
2499
  ] }),
2458
- k && b && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
2459
- b && /* @__PURE__ */ l("div", { children: [
2460
- /* @__PURE__ */ l("span", { style: w.divider, children: [
2461
- g.loginText,
2500
+ x && w && /* @__PURE__ */ n("div", { style: p.divider, children: "•" }),
2501
+ w && /* @__PURE__ */ c("div", { children: [
2502
+ /* @__PURE__ */ c("span", { style: p.divider, children: [
2503
+ a.loginText,
2462
2504
  " "
2463
2505
  ] }),
2464
- /* @__PURE__ */ n("a", { onClick: o, style: w.link, children: g.loginLink })
2506
+ /* @__PURE__ */ n("a", { onClick: o, style: p.link, children: a.loginLink })
2465
2507
  ] })
2466
2508
  ] })
2467
2509
  ] });
2468
2510
  }
2469
- const gt = {
2511
+ const ft = {
2470
2512
  title: "Sign In with Magic Link",
2471
2513
  emailLabel: "Email",
2472
2514
  emailPlaceholder: "Enter your email",
@@ -2484,7 +2526,7 @@ const gt = {
2484
2526
  loadingText: "Sending magic link...",
2485
2527
  verifyingText: "Verifying magic link...",
2486
2528
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2487
- }, pt = {
2529
+ }, mt = {
2488
2530
  container: {
2489
2531
  maxWidth: "400px",
2490
2532
  width: "100%",
@@ -2587,101 +2629,101 @@ const gt = {
2587
2629
  fontSize: "0.875rem"
2588
2630
  }
2589
2631
  };
2590
- function _t({
2632
+ function Kt({
2591
2633
  copy: i = {},
2592
2634
  styles: e = {},
2593
2635
  onSuccess: t,
2594
2636
  onError: r,
2595
2637
  onLoginClick: s,
2596
2638
  onSignupClick: o,
2597
- showTraditionalLinks: p = !0,
2598
- className: b,
2599
- verifyToken: k,
2600
- frontendUrl: S
2639
+ showTraditionalLinks: g = !0,
2640
+ className: w,
2641
+ verifyToken: x,
2642
+ frontendUrl: b
2601
2643
  }) {
2602
- const [T, m] = x(""), [f, u] = x(""), [y, R] = x(""), [C, q] = x(!1), [A, d] = x(!1), [P, E] = x(""), [z, G] = x(""), [$, _] = x({}), [v, M] = x(!1), { sendMagicLink: I, verifyMagicLink: a } = ae(), { tenant: L } = se(), c = { ...gt, ...i }, h = { ...pt, ...e };
2644
+ const [A, m] = v(""), [f, u] = v(""), [y, E] = v(""), [C, q] = v(!1), [T, d] = v(!1), [P, R] = v(""), [z, G] = v(""), [$, _] = v({}), [S, M] = v(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: I } = se(), k = { ...ft, ...i }, h = { ...mt, ...e };
2603
2645
  te(() => {
2604
- k && g(k);
2605
- }, [k]);
2606
- const g = async (N) => {
2607
- if (!L || !T) {
2608
- E("Missing tenant or email");
2646
+ x && a(x);
2647
+ }, [x]);
2648
+ const a = async (N) => {
2649
+ if (!I || !A) {
2650
+ R("Missing tenant or email");
2609
2651
  return;
2610
2652
  }
2611
- d(!0), E("");
2653
+ d(!0), R("");
2612
2654
  try {
2613
- const O = await a({
2655
+ const W = await l({
2614
2656
  token: N,
2615
- email: T
2657
+ email: A
2616
2658
  // tenantId inferred from context automatically
2617
2659
  });
2618
- t == null || t(O);
2619
- } catch (O) {
2620
- const F = O.message || "Failed to verify magic link";
2621
- E(F), r == null || r(F);
2660
+ t == null || t(W);
2661
+ } catch (W) {
2662
+ const D = W.message || "Failed to verify magic link";
2663
+ R(D), r == null || r(D);
2622
2664
  } finally {
2623
2665
  d(!1);
2624
2666
  }
2625
- }, w = () => {
2667
+ }, p = () => {
2626
2668
  const N = {};
2627
- return T.trim() || (N.email = !0), v && !f.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
2628
- }, j = async (N) => {
2629
- if (N.preventDefault(), !!w()) {
2630
- if (!(L != null && L.id)) {
2631
- E("Tenant not found");
2669
+ return A.trim() || (N.email = !0), S && !f.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
2670
+ }, O = async (N) => {
2671
+ if (N.preventDefault(), !!p()) {
2672
+ if (!(I != null && I.id)) {
2673
+ R("Tenant not found");
2632
2674
  return;
2633
2675
  }
2634
- q(!0), E(""), G("");
2676
+ q(!0), R(""), G("");
2635
2677
  try {
2636
- const O = S || (typeof window < "u" ? window.location.origin : ""), F = await I({
2637
- email: T,
2638
- tenantId: L.id,
2639
- frontendUrl: O,
2640
- name: v ? f : void 0,
2641
- lastName: v ? y : void 0
2678
+ const W = b || (typeof window < "u" ? window.location.origin : ""), D = await L({
2679
+ email: A,
2680
+ tenantId: I.id,
2681
+ frontendUrl: W,
2682
+ name: S ? f : void 0,
2683
+ lastName: S ? y : void 0
2642
2684
  });
2643
- G(c.successMessage), t == null || t(F);
2644
- } catch (O) {
2645
- const F = O.message || c.errorMessage;
2646
- E(F), r == null || r(F);
2685
+ G(k.successMessage), t == null || t(D);
2686
+ } catch (W) {
2687
+ const D = W.message || k.errorMessage;
2688
+ R(D), r == null || r(D);
2647
2689
  } finally {
2648
2690
  q(!1);
2649
2691
  }
2650
2692
  }
2651
- }, Y = (N) => ({
2693
+ }, K = (N) => ({
2652
2694
  ...h.input,
2653
2695
  ...$[N] ? h.inputError : {}
2654
2696
  }), H = () => ({
2655
2697
  ...h.button,
2656
- ...C || A ? h.buttonLoading : {},
2657
- ...!T || C || A ? h.buttonDisabled : {}
2698
+ ...C || T ? h.buttonLoading : {},
2699
+ ...!A || C || T ? h.buttonDisabled : {}
2658
2700
  });
2659
- return A ? /* @__PURE__ */ l("div", { className: b, style: h.container, children: [
2660
- /* @__PURE__ */ n("h2", { style: h.title, children: c.verifyingText }),
2701
+ return T ? /* @__PURE__ */ c("div", { className: w, style: h.container, children: [
2702
+ /* @__PURE__ */ n("h2", { style: h.title, children: k.verifyingText }),
2661
2703
  /* @__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..." }) })
2662
- ] }) : /* @__PURE__ */ l("div", { className: b, style: h.container, children: [
2663
- /* @__PURE__ */ n("h2", { style: h.title, children: c.title }),
2664
- /* @__PURE__ */ n("p", { style: h.description, children: c.description }),
2665
- /* @__PURE__ */ l("form", { onSubmit: j, style: h.form, children: [
2666
- /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2667
- /* @__PURE__ */ n("label", { style: h.label, children: c.emailLabel }),
2704
+ ] }) : /* @__PURE__ */ c("div", { className: w, style: h.container, children: [
2705
+ /* @__PURE__ */ n("h2", { style: h.title, children: k.title }),
2706
+ /* @__PURE__ */ n("p", { style: h.description, children: k.description }),
2707
+ /* @__PURE__ */ c("form", { onSubmit: O, style: h.form, children: [
2708
+ /* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
2709
+ /* @__PURE__ */ n("label", { style: h.label, children: k.emailLabel }),
2668
2710
  /* @__PURE__ */ n(
2669
2711
  "input",
2670
2712
  {
2671
2713
  id: "email",
2672
2714
  name: "email",
2673
2715
  type: "email",
2674
- value: T,
2716
+ value: A,
2675
2717
  onChange: (N) => {
2676
- m(N.target.value), $.email && _((O) => ({ ...O, email: !1 }));
2718
+ m(N.target.value), $.email && _((W) => ({ ...W, email: !1 }));
2677
2719
  },
2678
- placeholder: c.emailPlaceholder,
2679
- style: Y("email"),
2680
- disabled: C || A
2720
+ placeholder: k.emailPlaceholder,
2721
+ style: K("email"),
2722
+ disabled: C || T
2681
2723
  }
2682
2724
  )
2683
2725
  ] }),
2684
- !v && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2726
+ !S && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2685
2727
  "button",
2686
2728
  {
2687
2729
  type: "button",
@@ -2697,9 +2739,9 @@ function _t({
2697
2739
  children: "New user? Add your name"
2698
2740
  }
2699
2741
  ) }),
2700
- v && /* @__PURE__ */ l(U, { children: [
2701
- /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2702
- /* @__PURE__ */ n("label", { style: h.label, children: c.nameLabel }),
2742
+ S && /* @__PURE__ */ c(B, { children: [
2743
+ /* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
2744
+ /* @__PURE__ */ n("label", { style: h.label, children: k.nameLabel }),
2703
2745
  /* @__PURE__ */ n(
2704
2746
  "input",
2705
2747
  {
@@ -2708,16 +2750,16 @@ function _t({
2708
2750
  type: "text",
2709
2751
  value: f,
2710
2752
  onChange: (N) => {
2711
- u(N.target.value), $.name && _((O) => ({ ...O, name: !1 }));
2753
+ u(N.target.value), $.name && _((W) => ({ ...W, name: !1 }));
2712
2754
  },
2713
- placeholder: c.namePlaceholder,
2714
- style: Y("name"),
2715
- disabled: C || A
2755
+ placeholder: k.namePlaceholder,
2756
+ style: K("name"),
2757
+ disabled: C || T
2716
2758
  }
2717
2759
  )
2718
2760
  ] }),
2719
- /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2720
- /* @__PURE__ */ n("label", { style: h.label, children: c.lastNameLabel }),
2761
+ /* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
2762
+ /* @__PURE__ */ n("label", { style: h.label, children: k.lastNameLabel }),
2721
2763
  /* @__PURE__ */ n(
2722
2764
  "input",
2723
2765
  {
@@ -2725,10 +2767,10 @@ function _t({
2725
2767
  name: "lastName",
2726
2768
  type: "text",
2727
2769
  value: y,
2728
- onChange: (N) => R(N.target.value),
2729
- placeholder: c.lastNamePlaceholder,
2770
+ onChange: (N) => E(N.target.value),
2771
+ placeholder: k.lastNamePlaceholder,
2730
2772
  style: h.input,
2731
- disabled: C || A
2773
+ disabled: C || T
2732
2774
  }
2733
2775
  )
2734
2776
  ] }),
@@ -2737,7 +2779,7 @@ function _t({
2737
2779
  {
2738
2780
  type: "button",
2739
2781
  onClick: () => {
2740
- M(!1), u(""), R("");
2782
+ M(!1), u(""), E("");
2741
2783
  },
2742
2784
  style: {
2743
2785
  background: "none",
@@ -2751,30 +2793,30 @@ function _t({
2751
2793
  }
2752
2794
  ) })
2753
2795
  ] }),
2754
- /* @__PURE__ */ n("button", { type: "submit", disabled: !T || C || A, style: H(), children: C ? c.loadingText : c.submitButton }),
2796
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !A || C || T, style: H(), children: C ? k.loadingText : k.submitButton }),
2755
2797
  P && /* @__PURE__ */ n("div", { style: h.errorText, children: P }),
2756
2798
  z && /* @__PURE__ */ n("div", { style: h.successText, children: z })
2757
2799
  ] }),
2758
- p && /* @__PURE__ */ l("div", { style: h.linkContainer, children: [
2759
- /* @__PURE__ */ l("div", { children: [
2760
- /* @__PURE__ */ l("span", { style: h.divider, children: [
2761
- c.loginText,
2800
+ g && /* @__PURE__ */ c("div", { style: h.linkContainer, children: [
2801
+ /* @__PURE__ */ c("div", { children: [
2802
+ /* @__PURE__ */ c("span", { style: h.divider, children: [
2803
+ k.loginText,
2762
2804
  " "
2763
2805
  ] }),
2764
- /* @__PURE__ */ n("a", { onClick: s, style: h.link, children: c.loginLink })
2806
+ /* @__PURE__ */ n("a", { onClick: s, style: h.link, children: k.loginLink })
2765
2807
  ] }),
2766
2808
  /* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
2767
- /* @__PURE__ */ l("div", { children: [
2768
- /* @__PURE__ */ l("span", { style: h.divider, children: [
2769
- c.signupText,
2809
+ /* @__PURE__ */ c("div", { children: [
2810
+ /* @__PURE__ */ c("span", { style: h.divider, children: [
2811
+ k.signupText,
2770
2812
  " "
2771
2813
  ] }),
2772
- /* @__PURE__ */ n("a", { onClick: o, style: h.link, children: c.signupLink })
2814
+ /* @__PURE__ */ n("a", { onClick: o, style: h.link, children: k.signupLink })
2773
2815
  ] })
2774
2816
  ] })
2775
2817
  ] });
2776
2818
  }
2777
- const ft = {
2819
+ const yt = {
2778
2820
  title: "Verifying Magic Link",
2779
2821
  verifyingMessage: "Please wait while we verify your magic link...",
2780
2822
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -2782,7 +2824,7 @@ const ft = {
2782
2824
  redirectingMessage: "Redirecting you to the dashboard...",
2783
2825
  retryButton: "Try Again",
2784
2826
  backToLoginButton: "Back to Login"
2785
- }, Re = {
2827
+ }, Ee = {
2786
2828
  container: {
2787
2829
  maxWidth: "400px",
2788
2830
  width: "100%",
@@ -2869,7 +2911,7 @@ const ft = {
2869
2911
  cursor: "pointer",
2870
2912
  transition: "all 0.15s ease-in-out"
2871
2913
  }
2872
- }, mt = () => /* @__PURE__ */ n("div", { style: Re.spinner }), yt = () => /* @__PURE__ */ l(
2914
+ }, wt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), bt = () => /* @__PURE__ */ c(
2873
2915
  "svg",
2874
2916
  {
2875
2917
  width: "48",
@@ -2886,7 +2928,7 @@ const ft = {
2886
2928
  /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2887
2929
  ]
2888
2930
  }
2889
- ), wt = () => /* @__PURE__ */ l(
2931
+ ), St = () => /* @__PURE__ */ c(
2890
2932
  "svg",
2891
2933
  {
2892
2934
  width: "48",
@@ -2904,57 +2946,57 @@ const ft = {
2904
2946
  /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2905
2947
  ]
2906
2948
  }
2907
- ), bt = {
2908
- loading: /* @__PURE__ */ n(mt, {}),
2909
- success: /* @__PURE__ */ n(yt, {}),
2910
- error: /* @__PURE__ */ n(wt, {})
2949
+ ), vt = {
2950
+ loading: /* @__PURE__ */ n(wt, {}),
2951
+ success: /* @__PURE__ */ n(bt, {}),
2952
+ error: /* @__PURE__ */ n(St, {})
2911
2953
  };
2912
- function Gt({
2954
+ function Jt({
2913
2955
  copy: i = {},
2914
2956
  styles: e = {},
2915
2957
  icons: t = {},
2916
2958
  onSuccess: r,
2917
2959
  onError: s,
2918
2960
  onRetry: o,
2919
- onBackToLogin: p,
2920
- className: b,
2921
- token: k,
2922
- email: S,
2923
- appId: T,
2961
+ onBackToLogin: g,
2962
+ className: w,
2963
+ token: x,
2964
+ email: b,
2965
+ appId: A,
2924
2966
  tenantSlug: m,
2925
2967
  autoRedirectDelay: f = 3e3
2926
2968
  }) {
2927
- const [u, y] = x("verifying"), [R, C] = x(""), { verifyMagicLink: q } = ae(), A = { ...ft, ...i }, d = { ...Re, ...e }, P = { ...bt, ...t }, E = () => {
2969
+ const [u, y] = v("verifying"), [E, C] = v(""), { verifyMagicLink: q } = ae(), T = { ...yt, ...i }, d = { ...Ee, ...e }, P = { ...vt, ...t }, R = () => {
2928
2970
  if (typeof window > "u") return {};
2929
- const v = new URLSearchParams(window.location.search);
2971
+ const S = new URLSearchParams(window.location.search);
2930
2972
  return {
2931
- token: k || v.get("token") || "",
2932
- email: S || v.get("email") || "",
2933
- appId: T || v.get("appId") || "",
2934
- tenantSlug: m || v.get("tenantSlug") || void 0
2973
+ token: x || S.get("token") || "",
2974
+ email: b || S.get("email") || "",
2975
+ appId: A || S.get("appId") || "",
2976
+ tenantSlug: m || S.get("tenantSlug") || void 0
2935
2977
  };
2936
2978
  }, z = async () => {
2937
2979
  y("verifying"), C("");
2938
2980
  try {
2939
- const v = E();
2940
- if (!v.token || !v.email)
2981
+ const S = R();
2982
+ if (!S.token || !S.email)
2941
2983
  throw new Error("Missing required parameters: token or email");
2942
2984
  const M = await q({
2943
- token: v.token,
2944
- email: v.email,
2945
- tenantSlug: v.tenantSlug
2985
+ token: S.token,
2986
+ email: S.email,
2987
+ tenantSlug: S.tenantSlug
2946
2988
  });
2947
2989
  y("success"), r == null || r(M), f > 0 && setTimeout(() => {
2948
2990
  y("redirecting");
2949
2991
  }, f);
2950
- } catch (v) {
2951
- const M = v.message || A.errorMessage;
2992
+ } catch (S) {
2993
+ const M = S.message || T.errorMessage;
2952
2994
  C(M), y("error"), s == null || s(M);
2953
2995
  }
2954
2996
  }, G = () => {
2955
2997
  o == null || o(), z();
2956
2998
  }, $ = () => {
2957
- p == null || p();
2999
+ g == null || g();
2958
3000
  };
2959
3001
  te(() => {
2960
3002
  z();
@@ -2962,37 +3004,37 @@ function Gt({
2962
3004
  const _ = () => {
2963
3005
  switch (u) {
2964
3006
  case "verifying":
2965
- return /* @__PURE__ */ l("div", { style: d.message, children: [
3007
+ return /* @__PURE__ */ c("div", { style: d.message, children: [
2966
3008
  P.loading,
2967
- A.verifyingMessage
3009
+ T.verifyingMessage
2968
3010
  ] });
2969
3011
  case "success":
2970
- return /* @__PURE__ */ l(U, { children: [
3012
+ return /* @__PURE__ */ c(B, { children: [
2971
3013
  P.success,
2972
- /* @__PURE__ */ n("div", { style: d.successMessage, children: A.successMessage })
3014
+ /* @__PURE__ */ n("div", { style: d.successMessage, children: T.successMessage })
2973
3015
  ] });
2974
3016
  case "redirecting":
2975
- return /* @__PURE__ */ l(U, { children: [
3017
+ return /* @__PURE__ */ c(B, { children: [
2976
3018
  P.loading,
2977
- /* @__PURE__ */ n("div", { style: d.message, children: A.redirectingMessage })
3019
+ /* @__PURE__ */ n("div", { style: d.message, children: T.redirectingMessage })
2978
3020
  ] });
2979
3021
  case "error":
2980
- return /* @__PURE__ */ l(U, { children: [
3022
+ return /* @__PURE__ */ c(B, { children: [
2981
3023
  P.error,
2982
- /* @__PURE__ */ n("div", { style: d.errorMessage, children: R || A.errorMessage }),
2983
- /* @__PURE__ */ l("div", { style: d.buttonContainer, children: [
3024
+ /* @__PURE__ */ n("div", { style: d.errorMessage, children: E || T.errorMessage }),
3025
+ /* @__PURE__ */ c("div", { style: d.buttonContainer, children: [
2984
3026
  /* @__PURE__ */ n(
2985
3027
  "button",
2986
3028
  {
2987
3029
  onClick: G,
2988
3030
  style: d.retryButton,
2989
- onMouseOver: (v) => {
2990
- v.currentTarget.style.backgroundColor = "#2563eb";
3031
+ onMouseOver: (S) => {
3032
+ S.currentTarget.style.backgroundColor = "#2563eb";
2991
3033
  },
2992
- onMouseOut: (v) => {
2993
- v.currentTarget.style.backgroundColor = "#3b82f6";
3034
+ onMouseOut: (S) => {
3035
+ S.currentTarget.style.backgroundColor = "#3b82f6";
2994
3036
  },
2995
- children: A.retryButton
3037
+ children: T.retryButton
2996
3038
  }
2997
3039
  ),
2998
3040
  /* @__PURE__ */ n(
@@ -3000,13 +3042,13 @@ function Gt({
3000
3042
  {
3001
3043
  onClick: $,
3002
3044
  style: d.backButton,
3003
- onMouseOver: (v) => {
3004
- v.currentTarget.style.backgroundColor = "#e5e7eb";
3045
+ onMouseOver: (S) => {
3046
+ S.currentTarget.style.backgroundColor = "#e5e7eb";
3005
3047
  },
3006
- onMouseOut: (v) => {
3007
- v.currentTarget.style.backgroundColor = "#f3f4f6";
3048
+ onMouseOut: (S) => {
3049
+ S.currentTarget.style.backgroundColor = "#f3f4f6";
3008
3050
  },
3009
- children: A.backToLoginButton
3051
+ children: T.backToLoginButton
3010
3052
  }
3011
3053
  )
3012
3054
  ] })
@@ -3015,18 +3057,18 @@ function Gt({
3015
3057
  return null;
3016
3058
  }
3017
3059
  };
3018
- return /* @__PURE__ */ l("div", { style: d.container, className: b, children: [
3060
+ return /* @__PURE__ */ c("div", { style: d.container, className: w, children: [
3019
3061
  /* @__PURE__ */ n("style", { children: `
3020
3062
  @keyframes spin {
3021
3063
  0% { transform: rotate(0deg); }
3022
3064
  100% { transform: rotate(360deg); }
3023
3065
  }
3024
3066
  ` }),
3025
- /* @__PURE__ */ n("h1", { style: d.title, children: A.title }),
3067
+ /* @__PURE__ */ n("h1", { style: d.title, children: T.title }),
3026
3068
  _()
3027
3069
  ] });
3028
3070
  }
3029
- const St = {
3071
+ const xt = {
3030
3072
  title: "Reset Password",
3031
3073
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
3032
3074
  emailLabel: "Email",
@@ -3048,7 +3090,7 @@ const St = {
3048
3090
  resetLoadingText: "Resetting...",
3049
3091
  resetSuccessMessage: "Password reset successfully!",
3050
3092
  passwordMismatchError: "Passwords do not match"
3051
- }, vt = {
3093
+ }, kt = {
3052
3094
  container: {
3053
3095
  maxWidth: "400px",
3054
3096
  margin: "0 auto",
@@ -3140,112 +3182,112 @@ const St = {
3140
3182
  cursor: "pointer"
3141
3183
  }
3142
3184
  };
3143
- function Kt({
3185
+ function Yt({
3144
3186
  copy: i = {},
3145
3187
  styles: e = {},
3146
3188
  mode: t = "request",
3147
3189
  token: r = "",
3148
3190
  onSuccess: s,
3149
3191
  onError: o,
3150
- onBackToLogin: p,
3151
- onModeChange: b,
3152
- className: k
3192
+ onBackToLogin: g,
3193
+ onModeChange: w,
3194
+ className: x
3153
3195
  }) {
3154
- const [S, T] = x(""), [m, f] = x(r), [u, y] = x(""), [R, C] = x(""), [q, A] = x(!1), [d, P] = x(""), [E, z] = x(""), [G, $] = x({}), { requestPasswordReset: _, confirmPasswordReset: v } = ae(), { tenant: M } = se(), I = { ...St, ...i }, a = { ...vt, ...e }, L = () => {
3196
+ const [b, A] = v(""), [m, f] = v(r), [u, y] = v(""), [E, C] = v(""), [q, T] = v(!1), [d, P] = v(""), [R, z] = v(""), [G, $] = v({}), { requestPasswordReset: _, confirmPasswordReset: S } = ae(), { tenant: M } = se(), L = { ...xt, ...i }, l = { ...kt, ...e }, I = () => {
3155
3197
  const H = {};
3156
- return S.trim() || (H.email = !0), $(H), Object.keys(H).length === 0;
3157
- }, c = () => {
3198
+ return b.trim() || (H.email = !0), $(H), Object.keys(H).length === 0;
3199
+ }, k = () => {
3158
3200
  const H = {};
3159
- return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), R.trim() || (H.confirmPassword = !0), $(H), Object.keys(H).length === 0;
3201
+ return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), E.trim() || (H.confirmPassword = !0), $(H), Object.keys(H).length === 0;
3160
3202
  }, h = async (H) => {
3161
- if (H.preventDefault(), !!L()) {
3203
+ if (H.preventDefault(), !!I()) {
3162
3204
  if (!(M != null && M.id)) {
3163
3205
  P("Tenant not found");
3164
3206
  return;
3165
3207
  }
3166
- A(!0), P(""), z("");
3208
+ T(!0), P(""), z("");
3167
3209
  try {
3168
- await _({ email: S, tenantId: M.id }), z(I.successMessage), s == null || s();
3210
+ await _({ email: b, tenantId: M.id }), z(L.successMessage), s == null || s();
3169
3211
  } catch (N) {
3170
- const O = N.message || I.errorMessage;
3171
- P(O), o == null || o(O);
3212
+ const W = N.message || L.errorMessage;
3213
+ P(W), o == null || o(W);
3172
3214
  } finally {
3173
- A(!1);
3215
+ T(!1);
3174
3216
  }
3175
3217
  }
3176
- }, g = async (H) => {
3177
- if (H.preventDefault(), !!c()) {
3178
- if (u !== R) {
3179
- P(I.passwordMismatchError), $({ confirmPassword: !0 });
3218
+ }, a = async (H) => {
3219
+ if (H.preventDefault(), !!k()) {
3220
+ if (u !== E) {
3221
+ P(L.passwordMismatchError), $({ confirmPassword: !0 });
3180
3222
  return;
3181
3223
  }
3182
- A(!0), P(""), z("");
3224
+ T(!0), P(""), z("");
3183
3225
  try {
3184
- await v({ token: m, newPassword: u }), z(I.resetSuccessMessage), s == null || s();
3226
+ await S({ token: m, newPassword: u }), z(L.resetSuccessMessage), s == null || s();
3185
3227
  } catch (N) {
3186
- const O = N.message || I.errorMessage;
3187
- P(O), o == null || o(O);
3228
+ const W = N.message || L.errorMessage;
3229
+ P(W), o == null || o(W);
3188
3230
  } finally {
3189
- A(!1);
3231
+ T(!1);
3190
3232
  }
3191
3233
  }
3192
- }, w = (H) => ({
3193
- ...a.input,
3194
- ...G[H] ? a.inputError : {}
3195
- }), j = () => ({
3196
- ...a.button,
3197
- ...q ? a.buttonLoading : {}
3234
+ }, p = (H) => ({
3235
+ ...l.input,
3236
+ ...G[H] ? l.inputError : {}
3237
+ }), O = () => ({
3238
+ ...l.button,
3239
+ ...q ? l.buttonLoading : {}
3198
3240
  });
3199
3241
  if (t === "reset") {
3200
- const H = m && u && R;
3201
- return /* @__PURE__ */ l("div", { className: k, style: a.container, children: [
3202
- /* @__PURE__ */ n("h2", { style: a.title, children: I.resetTitle }),
3203
- /* @__PURE__ */ n("p", { style: a.subtitle, children: I.resetSubtitle }),
3204
- /* @__PURE__ */ l("form", { onSubmit: g, style: a.form, children: [
3205
- /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3206
- /* @__PURE__ */ n("label", { style: a.label, children: I.tokenLabel }),
3242
+ const H = m && u && E;
3243
+ return /* @__PURE__ */ c("div", { className: x, style: l.container, children: [
3244
+ /* @__PURE__ */ n("h2", { style: l.title, children: L.resetTitle }),
3245
+ /* @__PURE__ */ n("p", { style: l.subtitle, children: L.resetSubtitle }),
3246
+ /* @__PURE__ */ c("form", { onSubmit: a, style: l.form, children: [
3247
+ /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
3248
+ /* @__PURE__ */ n("label", { style: l.label, children: L.tokenLabel }),
3207
3249
  /* @__PURE__ */ n(
3208
3250
  "input",
3209
3251
  {
3210
3252
  type: "text",
3211
3253
  value: m,
3212
3254
  onChange: (N) => {
3213
- f(N.target.value), G.token && $((O) => ({ ...O, token: !1 }));
3255
+ f(N.target.value), G.token && $((W) => ({ ...W, token: !1 }));
3214
3256
  },
3215
- placeholder: I.tokenPlaceholder,
3216
- style: w("token"),
3257
+ placeholder: L.tokenPlaceholder,
3258
+ style: p("token"),
3217
3259
  disabled: q
3218
3260
  }
3219
3261
  )
3220
3262
  ] }),
3221
- /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3222
- /* @__PURE__ */ n("label", { style: a.label, children: I.newPasswordLabel }),
3263
+ /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
3264
+ /* @__PURE__ */ n("label", { style: l.label, children: L.newPasswordLabel }),
3223
3265
  /* @__PURE__ */ n(
3224
3266
  "input",
3225
3267
  {
3226
3268
  type: "password",
3227
3269
  value: u,
3228
3270
  onChange: (N) => {
3229
- y(N.target.value), G.newPassword && $((O) => ({ ...O, newPassword: !1 }));
3271
+ y(N.target.value), G.newPassword && $((W) => ({ ...W, newPassword: !1 }));
3230
3272
  },
3231
- placeholder: I.newPasswordPlaceholder,
3232
- style: w("newPassword"),
3273
+ placeholder: L.newPasswordPlaceholder,
3274
+ style: p("newPassword"),
3233
3275
  disabled: q
3234
3276
  }
3235
3277
  )
3236
3278
  ] }),
3237
- /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3238
- /* @__PURE__ */ n("label", { style: a.label, children: I.confirmPasswordLabel }),
3279
+ /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
3280
+ /* @__PURE__ */ n("label", { style: l.label, children: L.confirmPasswordLabel }),
3239
3281
  /* @__PURE__ */ n(
3240
3282
  "input",
3241
3283
  {
3242
3284
  type: "password",
3243
- value: R,
3285
+ value: E,
3244
3286
  onChange: (N) => {
3245
- C(N.target.value), G.confirmPassword && $((O) => ({ ...O, confirmPassword: !1 })), d === I.passwordMismatchError && P("");
3287
+ C(N.target.value), G.confirmPassword && $((W) => ({ ...W, confirmPassword: !1 })), d === L.passwordMismatchError && P("");
3246
3288
  },
3247
- placeholder: I.confirmPasswordPlaceholder,
3248
- style: w("confirmPassword"),
3289
+ placeholder: L.confirmPasswordPlaceholder,
3290
+ style: p("confirmPassword"),
3249
3291
  disabled: q
3250
3292
  }
3251
3293
  )
@@ -3256,41 +3298,41 @@ function Kt({
3256
3298
  type: "submit",
3257
3299
  disabled: !H || q,
3258
3300
  style: {
3259
- ...j(),
3260
- ...!H || q ? a.buttonDisabled : {}
3301
+ ...O(),
3302
+ ...!H || q ? l.buttonDisabled : {}
3261
3303
  },
3262
- children: q ? I.resetLoadingText : I.resetSubmitButton
3304
+ children: q ? L.resetLoadingText : L.resetSubmitButton
3263
3305
  }
3264
3306
  ),
3265
- d && /* @__PURE__ */ n("div", { style: a.errorText, children: d }),
3266
- E && /* @__PURE__ */ n("div", { style: a.successText, children: E })
3307
+ d && /* @__PURE__ */ n("div", { style: l.errorText, children: d }),
3308
+ R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
3267
3309
  ] }),
3268
- /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3269
- /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: I.backToLoginLink }),
3270
- b && /* @__PURE__ */ l(U, { children: [
3310
+ /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
3311
+ /* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
3312
+ w && /* @__PURE__ */ c(B, { children: [
3271
3313
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3272
- /* @__PURE__ */ n("a", { onClick: () => b("request"), style: a.link, children: "Request New Link" })
3314
+ /* @__PURE__ */ n("a", { onClick: () => w("request"), style: l.link, children: "Request New Link" })
3273
3315
  ] })
3274
3316
  ] })
3275
3317
  ] });
3276
3318
  }
3277
- const Y = S;
3278
- return /* @__PURE__ */ l("div", { className: k, style: a.container, children: [
3279
- /* @__PURE__ */ n("h2", { style: a.title, children: I.title }),
3280
- /* @__PURE__ */ n("p", { style: a.subtitle, children: I.subtitle }),
3281
- /* @__PURE__ */ l("form", { onSubmit: h, style: a.form, children: [
3282
- /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3283
- /* @__PURE__ */ n("label", { style: a.label, children: I.emailLabel }),
3319
+ const K = b;
3320
+ return /* @__PURE__ */ c("div", { className: x, style: l.container, children: [
3321
+ /* @__PURE__ */ n("h2", { style: l.title, children: L.title }),
3322
+ /* @__PURE__ */ n("p", { style: l.subtitle, children: L.subtitle }),
3323
+ /* @__PURE__ */ c("form", { onSubmit: h, style: l.form, children: [
3324
+ /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
3325
+ /* @__PURE__ */ n("label", { style: l.label, children: L.emailLabel }),
3284
3326
  /* @__PURE__ */ n(
3285
3327
  "input",
3286
3328
  {
3287
3329
  type: "email",
3288
- value: S,
3330
+ value: b,
3289
3331
  onChange: (H) => {
3290
- T(H.target.value), G.email && $((N) => ({ ...N, email: !1 }));
3332
+ A(H.target.value), G.email && $((N) => ({ ...N, email: !1 }));
3291
3333
  },
3292
- placeholder: I.emailPlaceholder,
3293
- style: w("email"),
3334
+ placeholder: L.emailPlaceholder,
3335
+ style: p("email"),
3294
3336
  disabled: q
3295
3337
  }
3296
3338
  )
@@ -3299,27 +3341,27 @@ function Kt({
3299
3341
  "button",
3300
3342
  {
3301
3343
  type: "submit",
3302
- disabled: !Y || q,
3344
+ disabled: !K || q,
3303
3345
  style: {
3304
- ...j(),
3305
- ...!Y || q ? a.buttonDisabled : {}
3346
+ ...O(),
3347
+ ...!K || q ? l.buttonDisabled : {}
3306
3348
  },
3307
- children: q ? I.loadingText : I.submitButton
3349
+ children: q ? L.loadingText : L.submitButton
3308
3350
  }
3309
3351
  ),
3310
- d && /* @__PURE__ */ n("div", { style: a.errorText, children: d }),
3311
- E && /* @__PURE__ */ n("div", { style: a.successText, children: E })
3352
+ d && /* @__PURE__ */ n("div", { style: l.errorText, children: d }),
3353
+ R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
3312
3354
  ] }),
3313
- /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3314
- /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: I.backToLoginLink }),
3315
- b && /* @__PURE__ */ l(U, { children: [
3355
+ /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
3356
+ /* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
3357
+ w && /* @__PURE__ */ c(B, { children: [
3316
3358
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3317
- /* @__PURE__ */ n("a", { onClick: () => b("reset"), style: a.link, children: "I have a token" })
3359
+ /* @__PURE__ */ n("a", { onClick: () => w("reset"), style: l.link, children: "I have a token" })
3318
3360
  ] })
3319
3361
  ] })
3320
3362
  ] });
3321
3363
  }
3322
- const xt = () => /* @__PURE__ */ n(
3364
+ const At = () => /* @__PURE__ */ n(
3323
3365
  "div",
3324
3366
  {
3325
3367
  style: {
@@ -3331,7 +3373,7 @@ const xt = () => /* @__PURE__ */ n(
3331
3373
  },
3332
3374
  children: /* @__PURE__ */ n("div", { children: "Loading..." })
3333
3375
  }
3334
- ), kt = ({ error: i, retry: e }) => /* @__PURE__ */ l(
3376
+ ), Tt = ({ error: i, retry: e }) => /* @__PURE__ */ c(
3335
3377
  "div",
3336
3378
  {
3337
3379
  style: {
@@ -3365,40 +3407,40 @@ const xt = () => /* @__PURE__ */ n(
3365
3407
  ]
3366
3408
  }
3367
3409
  );
3368
- function Jt({
3410
+ function Qt({
3369
3411
  children: i,
3370
3412
  loadingFallback: e,
3371
3413
  errorFallback: t,
3372
3414
  requireTenant: r = !0
3373
3415
  }) {
3374
- const { isAppLoading: s, appError: o, retryApp: p } = oe(), b = Me(), k = (b == null ? void 0 : b.isTenantLoading) ?? !1, S = (b == null ? void 0 : b.tenantError) ?? null, T = (b == null ? void 0 : b.tenantSlug) ?? null, m = (b == null ? void 0 : b.retryTenant) ?? (() => {
3375
- }), f = r && b && T, u = s || f && k, y = o || (f ? S : null), R = () => {
3376
- o && p(), S && b && m();
3416
+ const { isAppLoading: s, appError: o, retryApp: g } = oe(), w = Me(), x = (w == null ? void 0 : w.isTenantLoading) ?? !1, b = (w == null ? void 0 : w.tenantError) ?? null, A = (w == null ? void 0 : w.tenantSlug) ?? null, m = (w == null ? void 0 : w.retryTenant) ?? (() => {
3417
+ }), f = r && w && A, u = s || f && x, y = o || (f ? b : null), E = () => {
3418
+ o && g(), b && w && m();
3377
3419
  };
3378
3420
  if (u)
3379
- return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(xt, {}) });
3421
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(At, {}) });
3380
3422
  if (y) {
3381
- const C = typeof t == "function" ? t(y, R) : t || /* @__PURE__ */ n(kt, { error: y, retry: R });
3382
- return /* @__PURE__ */ n(U, { children: C });
3423
+ const C = typeof t == "function" ? t(y, E) : t || /* @__PURE__ */ n(Tt, { error: y, retry: E });
3424
+ return /* @__PURE__ */ n(B, { children: C });
3383
3425
  }
3384
- return /* @__PURE__ */ n(U, { children: i });
3426
+ return /* @__PURE__ */ n(B, { children: i });
3385
3427
  }
3386
- function Yt(i = !0) {
3387
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), p = (o == null ? void 0 : o.isTenantLoading) ?? !1, b = (o == null ? void 0 : o.tenantError) ?? null, k = (o == null ? void 0 : o.tenant) ?? null, S = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3388
- }), m = i && o && S, f = e || m && p, u = t || (m ? b : null);
3428
+ function Xt(i = !0) {
3429
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), g = (o == null ? void 0 : o.isTenantLoading) ?? !1, w = (o == null ? void 0 : o.tenantError) ?? null, x = (o == null ? void 0 : o.tenant) ?? null, b = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
3430
+ }), m = i && o && b, f = e || m && g, u = t || (m ? w : null);
3389
3431
  return {
3390
3432
  isLoading: f,
3391
3433
  error: u,
3392
- isReady: !f && !u && s !== null && (!m || k !== null),
3434
+ isReady: !f && !u && s !== null && (!m || x !== null),
3393
3435
  retry: () => {
3394
- t && r(), b && o && T();
3436
+ t && r(), w && o && A();
3395
3437
  },
3396
3438
  // Individual states
3397
3439
  app: { isLoading: e, error: t, data: s },
3398
- tenant: o ? { isLoading: p, error: b, data: k } : null
3440
+ tenant: o ? { isLoading: g, error: w, data: x } : null
3399
3441
  };
3400
3442
  }
3401
- class Qt {
3443
+ class Zt {
3402
3444
  constructor(e, t) {
3403
3445
  this.httpService = e, this.sessionManager = t;
3404
3446
  }
@@ -3466,7 +3508,7 @@ class Qt {
3466
3508
  };
3467
3509
  }
3468
3510
  }
3469
- class Xt {
3511
+ class er {
3470
3512
  constructor(e, t) {
3471
3513
  this.httpService = e, this.sessionManager = t;
3472
3514
  }
@@ -3517,7 +3559,7 @@ class Xt {
3517
3559
  });
3518
3560
  }
3519
3561
  }
3520
- class Zt {
3562
+ class tr {
3521
3563
  constructor(e) {
3522
3564
  this.httpService = e;
3523
3565
  }
@@ -3526,7 +3568,7 @@ class Zt {
3526
3568
  return await this.httpService.get("/health");
3527
3569
  }
3528
3570
  }
3529
- class er {
3571
+ class rr {
3530
3572
  // Date string to Date object
3531
3573
  static toDate(e) {
3532
3574
  return new Date(e);
@@ -3649,47 +3691,47 @@ class er {
3649
3691
  }
3650
3692
  }
3651
3693
  export {
3652
- er as ApiMappers,
3694
+ rr as ApiMappers,
3653
3695
  ve as AppApiService,
3654
- Jt as AppLoader,
3655
- Et as AppProvider,
3656
- Ue as AuthApiService,
3657
- Dt as AuthProvider,
3658
- Wt as FeatureFlag,
3659
- Je as FeatureFlagApiService,
3660
- Ht as FeatureFlagProvider,
3661
- Zt as HealthApiService,
3696
+ Qt as AppLoader,
3697
+ Ct as AppProvider,
3698
+ ze as AuthApiService,
3699
+ Nt as AuthProvider,
3700
+ jt as FeatureFlag,
3701
+ Qe as FeatureFlagApiService,
3702
+ Ut as FeatureFlagProvider,
3703
+ tr as HealthApiService,
3662
3704
  re as HttpService,
3663
- zt as LandingRoute,
3664
- jt as LoginForm,
3665
- _t as MagicLinkForm,
3666
- Gt as MagicLinkVerify,
3667
- Kt as PasswordRecoveryForm,
3668
- Qt as PermissionApiService,
3669
- Bt as Protected,
3670
- Ut as ProtectedRoute,
3705
+ Wt as LandingRoute,
3706
+ _t as LoginForm,
3707
+ Kt as MagicLinkForm,
3708
+ Jt as MagicLinkVerify,
3709
+ Yt as PasswordRecoveryForm,
3710
+ Zt as PermissionApiService,
3711
+ qt as Protected,
3712
+ zt as ProtectedRoute,
3671
3713
  xe as RoleApiService,
3672
3714
  we as SessionManager,
3673
- Vt as SignupForm,
3674
- Qe as SubscriptionApiService,
3675
- Ot as SubscriptionGuard,
3676
- Xt as SubscriptionPlanApiService,
3677
- Nt as SubscriptionProvider,
3715
+ Gt as SignupForm,
3716
+ Ze as SubscriptionApiService,
3717
+ Vt as SubscriptionGuard,
3718
+ er as SubscriptionPlanApiService,
3719
+ Bt as SubscriptionProvider,
3678
3720
  ue as TenantApiService,
3679
- Ct as TenantProvider,
3680
- qt as TenantRoute,
3681
- qe as UserApiService,
3721
+ Dt as TenantProvider,
3722
+ Ot as TenantRoute,
3723
+ Oe as UserApiService,
3682
3724
  ie as UserType,
3683
- Rt as useApi,
3725
+ $t as useApi,
3684
3726
  oe as useApp,
3685
- Yt as useAppLoaderState,
3727
+ Xt as useAppLoaderState,
3686
3728
  ae as useAuth,
3687
- Ye as useFeatureFlags,
3688
- Ft as useSettings,
3689
- Xe as useSubscription,
3729
+ Xe as useFeatureFlags,
3730
+ Ht as useSettings,
3731
+ et as useSubscription,
3690
3732
  me as useTenant,
3691
3733
  se as useTenantInfo,
3692
3734
  Me as useTenantOptional,
3693
- $t as useTenantSettings
3735
+ Ft as useTenantSettings
3694
3736
  };
3695
3737
  //# sourceMappingURL=index.es.js.map