@skylabs-digital/react-identity-access 2.16.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
2
- import { createContext as ue, useMemo as Z, useState as x, useCallback as re, useEffect as X, useContext as ie, useRef as Ve } from "react";
3
- import { useLocation as be, Navigate as me, useNavigate as ut, useSearchParams as ht } from "react-router-dom";
4
- class oe {
1
+ import { jsx as s, Fragment as _, jsxs as c } from "react/jsx-runtime";
2
+ import { createContext as ue, useMemo as J, useState as x, useCallback as se, useEffect as ee, useContext as oe, useRef as Ge } from "react";
3
+ import { useLocation as Se, Navigate as ye, useNavigate as gt, useSearchParams as pt } from "react-router-dom";
4
+ class ae {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -23,33 +23,33 @@ class oe {
23
23
  };
24
24
  if (!(i != null && i.skipAuth) && this.sessionManager)
25
25
  try {
26
- const b = await this.sessionManager.getAuthHeaders();
27
- f = { ...f, ...b };
28
- } catch (b) {
29
- console.warn("Failed to inject auth headers:", b);
26
+ const m = await this.sessionManager.getAuthHeaders();
27
+ f = { ...f, ...m };
28
+ } catch (m) {
29
+ console.warn("Failed to inject auth headers:", m);
30
30
  }
31
- const w = new AbortController(), u = setTimeout(() => w.abort(), p);
31
+ const w = new AbortController(), d = setTimeout(() => w.abort(), p);
32
32
  try {
33
- const b = await fetch(a, {
33
+ const m = await fetch(a, {
34
34
  method: e,
35
35
  headers: f,
36
36
  body: n ? JSON.stringify(n) : void 0,
37
37
  signal: w.signal
38
38
  });
39
- if (clearTimeout(u), b.status === 401 && !(i != null && i.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(d), m.status === 401 && !(i != null && i.skipRetry) && !o && this.sessionManager)
40
40
  try {
41
- const T = this.sessionManager.getTokens();
42
- if (T != null && T.refreshToken)
41
+ const v = this.sessionManager.getTokens();
42
+ if (v != null && v.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, n, i, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${b.status}: ${b.statusText}`);
45
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
46
46
  }
47
- if (!b.ok)
48
- throw new Error(`HTTP ${b.status}: ${b.statusText}`);
49
- const g = b.headers.get("content-type");
50
- return !g || !g.includes("application/json") ? {} : await b.json();
51
- } catch (b) {
52
- throw clearTimeout(u), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : b;
47
+ if (!m.ok)
48
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
49
+ const h = m.headers.get("content-type");
50
+ return !h || !h.includes("application/json") ? {} : await m.json();
51
+ } catch (m) {
52
+ throw clearTimeout(d), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : m;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,7 +65,7 @@ class oe {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class He {
68
+ class qe {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -124,14 +124,14 @@ class He {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const Ie = ue(null);
128
- function hn({ config: r, children: e }) {
129
- const t = Z(
127
+ const Le = ue(null);
128
+ function pn({ config: r, children: e }) {
129
+ const t = J(
130
130
  () => {
131
- var g, T, I;
131
+ var h, v, I;
132
132
  return {
133
- enabled: ((g = r.cache) == null ? void 0 : g.enabled) ?? !0,
134
- ttl: ((T = r.cache) == null ? void 0 : T.ttl) ?? 3e5,
133
+ enabled: ((h = r.cache) == null ? void 0 : h.enabled) ?? !0,
134
+ ttl: ((v = r.cache) == null ? void 0 : v.ttl) ?? 3e5,
135
135
  // 5 minutes default
136
136
  storageKey: ((I = r.cache) == null ? void 0 : I.storageKey) ?? `app_cache_${r.appId}`
137
137
  };
@@ -140,16 +140,16 @@ function hn({ config: r, children: e }) {
140
140
  ), [n, i] = x(() => {
141
141
  if (!t.enabled) return null;
142
142
  try {
143
- const g = localStorage.getItem(t.storageKey);
144
- if (!g) return null;
145
- const T = JSON.parse(g);
146
- return Date.now() - T.timestamp < t.ttl && T.appId === r.appId ? T.data : (localStorage.removeItem(t.storageKey), null);
143
+ const h = localStorage.getItem(t.storageKey);
144
+ if (!h) return null;
145
+ const v = JSON.parse(h);
146
+ return Date.now() - v.timestamp < t.ttl && v.appId === r.appId ? v.data : (localStorage.removeItem(t.storageKey), null);
147
147
  } catch {
148
148
  return null;
149
149
  }
150
- }), [o, a] = x(!n), [p, f] = x(null), w = Z(() => {
151
- const g = () => {
152
- u();
150
+ }), [o, a] = x(!n), [p, f] = x(null), w = J(() => {
151
+ const h = () => {
152
+ d();
153
153
  };
154
154
  return {
155
155
  appId: r.appId,
@@ -158,18 +158,18 @@ function hn({ config: r, children: e }) {
158
158
  appInfo: n,
159
159
  isAppLoading: o,
160
160
  appError: p,
161
- retryApp: g
161
+ retryApp: h
162
162
  };
163
- }, [r, n, o, p]), u = re(
164
- async (g = !1) => {
165
- if (!(!g && t.enabled && n))
163
+ }, [r, n, o, p]), d = se(
164
+ async (h = !1) => {
165
+ if (!(!h && t.enabled && n))
166
166
  try {
167
167
  a(!0), f(null);
168
- const T = new oe(r.baseUrl), N = await new He(T, {}).getPublicAppInfo(r.appId);
169
- if (i(N), t.enabled)
168
+ const v = new ae(r.baseUrl), F = await new qe(v, {}).getPublicAppInfo(r.appId);
169
+ if (i(F), t.enabled)
170
170
  try {
171
171
  const M = {
172
- data: N,
172
+ data: F,
173
173
  timestamp: Date.now(),
174
174
  appId: r.appId
175
175
  };
@@ -177,49 +177,49 @@ function hn({ config: r, children: e }) {
177
177
  } catch (M) {
178
178
  console.warn("Failed to cache app info:", M);
179
179
  }
180
- } catch (T) {
181
- const I = T instanceof Error ? T : new Error("Failed to load app information");
180
+ } catch (v) {
181
+ const I = v instanceof Error ? v : new Error("Failed to load app information");
182
182
  f(I), i(null);
183
183
  } finally {
184
184
  a(!1);
185
185
  }
186
186
  },
187
187
  [r.baseUrl, r.appId, t, n]
188
- ), b = re(async () => {
188
+ ), m = se(async () => {
189
189
  if (!(!t.enabled || !n))
190
190
  try {
191
- const g = localStorage.getItem(t.storageKey);
192
- if (!g) return;
193
- const T = JSON.parse(g);
194
- if (Date.now() - T.timestamp > t.ttl * 0.5) {
195
- const N = new oe(r.baseUrl), P = await new He(N, {}).getPublicAppInfo(r.appId);
191
+ const h = localStorage.getItem(t.storageKey);
192
+ if (!h) return;
193
+ const v = JSON.parse(h);
194
+ if (Date.now() - v.timestamp > t.ttl * 0.5) {
195
+ const F = new ae(r.baseUrl), P = await new qe(F, {}).getPublicAppInfo(r.appId);
196
196
  i(P);
197
- const h = {
197
+ const u = {
198
198
  data: P,
199
199
  timestamp: Date.now(),
200
200
  appId: r.appId
201
201
  };
202
- localStorage.setItem(t.storageKey, JSON.stringify(h));
202
+ localStorage.setItem(t.storageKey, JSON.stringify(u));
203
203
  }
204
- } catch (g) {
205
- console.warn("Background app refresh failed:", g);
204
+ } catch (h) {
205
+ console.warn("Background app refresh failed:", h);
206
206
  }
207
207
  }, [r, t, n]);
208
- return X(() => {
209
- n ? b() : u();
210
- }, []), /* @__PURE__ */ s(Ie.Provider, { value: w, children: e });
208
+ return ee(() => {
209
+ n ? m() : d();
210
+ }, []), /* @__PURE__ */ s(Le.Provider, { value: w, children: e });
211
211
  }
212
- function ye() {
213
- const r = ie(Ie);
212
+ function we() {
213
+ const r = oe(Le);
214
214
  if (!r)
215
215
  throw new Error("useApp must be used within an AppProvider");
216
216
  return r;
217
217
  }
218
- function je() {
219
- return ie(Ie);
218
+ function Ze() {
219
+ return oe(Le);
220
220
  }
221
- const gn = ye;
222
- class Ae {
221
+ const fn = we;
222
+ class Re {
223
223
  constructor(e = {}) {
224
224
  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);
225
225
  }
@@ -372,7 +372,7 @@ class Ae {
372
372
  return e !== null && !this.isTokenExpired(e);
373
373
  }
374
374
  }
375
- class gt {
375
+ class ft {
376
376
  constructor(e) {
377
377
  this.httpService = e;
378
378
  }
@@ -428,7 +428,7 @@ class gt {
428
428
  });
429
429
  }
430
430
  }
431
- class Be {
431
+ class Oe {
432
432
  constructor(e, t) {
433
433
  this.httpService = e, this.sessionManager = t;
434
434
  }
@@ -504,7 +504,7 @@ class Be {
504
504
  };
505
505
  }
506
506
  }
507
- class pt {
507
+ class mt {
508
508
  constructor(e, t) {
509
509
  this.httpService = e, this.sessionManager = t;
510
510
  }
@@ -544,7 +544,7 @@ class pt {
544
544
  });
545
545
  }
546
546
  }
547
- class fe {
547
+ class me {
548
548
  constructor(e, t, n) {
549
549
  this.httpService = e, this.appId = t, this.sessionManager = n;
550
550
  }
@@ -622,7 +622,7 @@ class fe {
622
622
  )).data;
623
623
  }
624
624
  }
625
- function ft(r, e) {
625
+ function yt(r, e) {
626
626
  if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
627
627
  return null;
628
628
  if (e) {
@@ -638,26 +638,26 @@ function ft(r, e) {
638
638
  const n = r.split(".");
639
639
  return n.length >= 3 && n[0] !== "www" ? n[0] : null;
640
640
  }
641
- function mt(r, e = "tenant", t) {
641
+ function wt(r, e = "tenant", t) {
642
642
  const i = new URLSearchParams(r).get(e);
643
643
  return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
644
644
  }
645
- function yt(r, e, t) {
645
+ function bt(r, e, t) {
646
646
  const { tenantMode: n, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = r;
647
- return n === "fixed" ? a || null : n === "subdomain" ? ft(e.hostname, i) : n === "selector" ? mt(e.search, o, t) : null;
647
+ return n === "fixed" ? a || null : n === "subdomain" ? yt(e.hostname, i) : n === "selector" ? wt(e.search, o, t) : null;
648
648
  }
649
- function wt(r, e, t) {
649
+ function St(r, e, t) {
650
650
  if (t)
651
651
  return `${r}.${t}`;
652
652
  const n = e.split(".");
653
653
  return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
654
654
  }
655
655
  const de = "_auth";
656
- function qe(r) {
656
+ function ze(r) {
657
657
  const e = JSON.stringify(r);
658
658
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
659
659
  }
660
- function bt(r) {
660
+ function vt(r) {
661
661
  try {
662
662
  let e = r.replace(/-/g, "+").replace(/_/g, "/");
663
663
  for (; e.length % 4; )
@@ -668,7 +668,7 @@ function bt(r) {
668
668
  return null;
669
669
  }
670
670
  }
671
- function St() {
671
+ function Tt() {
672
672
  if (typeof window > "u")
673
673
  return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
674
674
  const e = new URLSearchParams(window.location.search).get(de);
@@ -677,7 +677,7 @@ function St() {
677
677
  searchParams: window.location.search,
678
678
  encodedLength: e == null ? void 0 : e.length
679
679
  }), !e) return null;
680
- const t = bt(e);
680
+ const t = vt(e);
681
681
  return console.log("[CrossDomainAuth] Token decode result:", {
682
682
  success: !!t,
683
683
  hasAccessToken: !!(t != null && t.accessToken),
@@ -685,7 +685,7 @@ function St() {
685
685
  expiresIn: t == null ? void 0 : t.expiresIn
686
686
  }), t;
687
687
  }
688
- function vt() {
688
+ function kt() {
689
689
  if (typeof window > "u") return;
690
690
  const r = new URL(window.location.href);
691
691
  r.searchParams.delete(de), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
@@ -693,9 +693,9 @@ function vt() {
693
693
  newUrl: r.toString()
694
694
  }), window.history.replaceState({}, "", r.toString());
695
695
  }
696
- const Me = ue(null);
697
- function pn({ config: r, children: e }) {
698
- const { baseUrl: t, appInfo: n, appId: i } = ye(), o = re(() => typeof window > "u" ? null : yt(
696
+ const Ee = ue(null);
697
+ function mn({ config: r, children: e }) {
698
+ const { baseUrl: t, appInfo: n, appId: i } = we(), o = se(() => typeof window > "u" ? null : bt(
699
699
  {
700
700
  tenantMode: r.tenantMode || "selector",
701
701
  baseDomain: r.baseDomain,
@@ -707,119 +707,119 @@ function pn({ config: r, children: e }) {
707
707
  search: window.location.search
708
708
  },
709
709
  window.localStorage
710
- ), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f = Z(
710
+ ), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f = J(
711
711
  () => {
712
- var c, H, F;
712
+ var g, C, T;
713
713
  return {
714
- enabled: ((c = r.cache) == null ? void 0 : c.enabled) ?? !0,
715
- ttl: ((H = r.cache) == null ? void 0 : H.ttl) ?? 5 * 60 * 1e3,
714
+ enabled: ((g = r.cache) == null ? void 0 : g.enabled) ?? !0,
715
+ ttl: ((C = r.cache) == null ? void 0 : C.ttl) ?? 5 * 60 * 1e3,
716
716
  // 5 minutes default
717
- storageKey: ((F = r.cache) == null ? void 0 : F.storageKey) ?? `tenant_cache_${a || "default"}`
717
+ storageKey: ((T = r.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
718
718
  };
719
719
  },
720
720
  [r.cache, a]
721
- ), [w, u] = x(() => {
721
+ ), [w, d] = x(() => {
722
722
  if (r.initialTenant) return r.initialTenant;
723
723
  if (!f.enabled || !a) return null;
724
724
  try {
725
- const c = localStorage.getItem(f.storageKey);
726
- if (!c) return null;
727
- const H = JSON.parse(c);
728
- return Date.now() - H.timestamp < f.ttl && H.tenantSlug === a ? H.data : (localStorage.removeItem(f.storageKey), null);
725
+ const g = localStorage.getItem(f.storageKey);
726
+ if (!g) return null;
727
+ const C = JSON.parse(g);
728
+ return Date.now() - C.timestamp < f.ttl && C.tenantSlug === a ? C.data : (localStorage.removeItem(f.storageKey), null);
729
729
  } catch {
730
730
  return null;
731
731
  }
732
- }), [b, g] = x(!w && !r.initialTenant), [T, I] = x(null), [N, M] = x(null), [P, h] = x(!1), [A, S] = x(null);
733
- X(() => {
732
+ }), [m, h] = x(!w && !r.initialTenant), [v, I] = x(null), [F, M] = x(null), [P, u] = x(!1), [A, b] = x(null);
733
+ ee(() => {
734
734
  if (r.tenantMode === "fixed") return;
735
- const c = o();
736
- p(c);
735
+ const g = o();
736
+ p(g);
737
737
  }, [o, r.tenantMode]);
738
- const L = (n == null ? void 0 : n.settingsSchema) || null, E = re(
739
- async (c, H = !1) => {
740
- if (!(!H && f.enabled && w && w.domain === c))
738
+ const L = (n == null ? void 0 : n.settingsSchema) || null, E = se(
739
+ async (g, C = !1) => {
740
+ if (!(!C && f.enabled && w && w.domain === g))
741
741
  try {
742
- g(!0), I(null);
743
- const F = new oe(t), m = await new fe(F, i).getPublicTenantInfo(c);
744
- if (u(m), f.enabled)
742
+ h(!0), I(null);
743
+ const T = new ae(t), y = await new me(T, i).getPublicTenantInfo(g);
744
+ if (d(y), f.enabled)
745
745
  try {
746
- const v = {
747
- data: m,
746
+ const k = {
747
+ data: y,
748
748
  timestamp: Date.now(),
749
- tenantSlug: c
749
+ tenantSlug: g
750
750
  };
751
- localStorage.setItem(f.storageKey, JSON.stringify(v));
752
- } catch (v) {
753
- console.warn("Failed to cache tenant info:", v);
751
+ localStorage.setItem(f.storageKey, JSON.stringify(k));
752
+ } catch (k) {
753
+ console.warn("Failed to cache tenant info:", k);
754
754
  }
755
- } catch (F) {
756
- const y = F instanceof Error ? F : new Error("Failed to load tenant information");
757
- I(y), u(null);
755
+ } catch (T) {
756
+ const S = T instanceof Error ? T : new Error("Failed to load tenant information");
757
+ I(S), d(null);
758
758
  } finally {
759
- g(!1);
759
+ h(!1);
760
760
  }
761
761
  },
762
762
  [t, i, f, w]
763
- ), C = re(async () => {
763
+ ), N = se(async () => {
764
764
  if (!(!f.enabled || !w || !a))
765
765
  try {
766
- const c = localStorage.getItem(f.storageKey);
767
- if (!c) return;
768
- const H = JSON.parse(c);
769
- if (Date.now() - H.timestamp > f.ttl * 0.5) {
770
- const y = new oe(t), v = await new fe(y, i).getPublicTenantInfo(a);
771
- u(v);
772
- const G = {
773
- data: v,
766
+ const g = localStorage.getItem(f.storageKey);
767
+ if (!g) return;
768
+ const C = JSON.parse(g);
769
+ if (Date.now() - C.timestamp > f.ttl * 0.5) {
770
+ const S = new ae(t), k = await new me(S, i).getPublicTenantInfo(a);
771
+ d(k);
772
+ const j = {
773
+ data: k,
774
774
  timestamp: Date.now(),
775
775
  tenantSlug: a
776
776
  };
777
- localStorage.setItem(f.storageKey, JSON.stringify(G));
777
+ localStorage.setItem(f.storageKey, JSON.stringify(j));
778
778
  }
779
- } catch (c) {
780
- console.warn("Background tenant refresh failed:", c);
779
+ } catch (g) {
780
+ console.warn("Background tenant refresh failed:", g);
781
781
  }
782
- }, [t, i, f, w, a]), R = re(async () => {
782
+ }, [t, i, f, w, a]), R = se(async () => {
783
783
  if (w != null && w.id)
784
784
  try {
785
- h(!0), S(null);
786
- const c = new oe(t), F = await new fe(c, w.appId).getTenantSettings(w.id);
787
- M(F);
788
- } catch (c) {
789
- const H = c instanceof Error ? c : new Error("Failed to load tenant settings");
790
- S(H), M(null);
785
+ u(!0), b(null);
786
+ const g = new ae(t), T = await new me(g, w.appId).getTenantSettings(w.id);
787
+ M(T);
788
+ } catch (g) {
789
+ const C = g instanceof Error ? g : new Error("Failed to load tenant settings");
790
+ b(C), M(null);
791
791
  } finally {
792
- h(!1);
792
+ u(!1);
793
793
  }
794
- }, [t, w]), $ = re(() => {
794
+ }, [t, w]), U = se(() => {
795
795
  R();
796
- }, [R]), l = re(
797
- (c) => {
796
+ }, [R]), l = se(
797
+ (g) => {
798
798
  if (!L)
799
799
  return { isValid: !0, errors: [] };
800
- const H = [];
800
+ const C = [];
801
801
  try {
802
- return L.properties && Object.entries(L.properties).forEach(([F, y]) => {
803
- var v;
804
- const m = c[F];
805
- if ((v = L.required) != null && v.includes(F) && m == null) {
806
- H.push(`Field '${F}' is required`);
802
+ return L.properties && Object.entries(L.properties).forEach(([T, S]) => {
803
+ var k;
804
+ const y = g[T];
805
+ if ((k = L.required) != null && k.includes(T) && y == null) {
806
+ C.push(`Field '${T}' is required`);
807
807
  return;
808
808
  }
809
- if (m != null) {
810
- if (y.type) {
811
- const G = y.type, Y = typeof m;
812
- G === "string" && Y !== "string" ? H.push(`Field '${F}' must be a string`) : (G === "number" || G === "integer") && Y !== "number" ? H.push(`Field '${F}' must be a number`) : G === "boolean" && Y !== "boolean" ? H.push(`Field '${F}' must be a boolean`) : G === "array" && !Array.isArray(m) && H.push(`Field '${F}' must be an array`);
809
+ if (y != null) {
810
+ if (S.type) {
811
+ const j = S.type, Z = typeof y;
812
+ j === "string" && Z !== "string" ? C.push(`Field '${T}' must be a string`) : (j === "number" || j === "integer") && Z !== "number" ? C.push(`Field '${T}' must be a number`) : j === "boolean" && Z !== "boolean" ? C.push(`Field '${T}' must be a boolean`) : j === "array" && !Array.isArray(y) && C.push(`Field '${T}' must be an array`);
813
813
  }
814
- y.minLength !== void 0 && typeof m == "string" && m.length < y.minLength && H.push(
815
- `Field '${F}' must be at least ${y.minLength} characters long`
816
- ), y.maxLength !== void 0 && typeof m == "string" && m.length > y.maxLength && H.push(
817
- `Field '${F}' must be no more than ${y.maxLength} characters long`
818
- ), y.minimum !== void 0 && typeof m == "number" && m < y.minimum && H.push(`Field '${F}' must be at least ${y.minimum}`), y.maximum !== void 0 && typeof m == "number" && m > y.maximum && H.push(`Field '${F}' must be no more than ${y.maximum}`), y.pattern && typeof m == "string" && (new RegExp(y.pattern).test(m) || H.push(`Field '${F}' does not match the required pattern`)), y.enum && !y.enum.includes(m) && H.push(`Field '${F}' must be one of: ${y.enum.join(", ")}`);
814
+ S.minLength !== void 0 && typeof y == "string" && y.length < S.minLength && C.push(
815
+ `Field '${T}' must be at least ${S.minLength} characters long`
816
+ ), S.maxLength !== void 0 && typeof y == "string" && y.length > S.maxLength && C.push(
817
+ `Field '${T}' must be no more than ${S.maxLength} characters long`
818
+ ), S.minimum !== void 0 && typeof y == "number" && y < S.minimum && C.push(`Field '${T}' must be at least ${S.minimum}`), S.maximum !== void 0 && typeof y == "number" && y > S.maximum && C.push(`Field '${T}' must be no more than ${S.maximum}`), S.pattern && typeof y == "string" && (new RegExp(S.pattern).test(y) || C.push(`Field '${T}' does not match the required pattern`)), S.enum && !S.enum.includes(y) && C.push(`Field '${T}' must be one of: ${S.enum.join(", ")}`);
819
819
  }
820
820
  }), {
821
- isValid: H.length === 0,
822
- errors: H
821
+ isValid: C.length === 0,
822
+ errors: C
823
823
  };
824
824
  } catch {
825
825
  return {
@@ -830,95 +830,95 @@ function pn({ config: r, children: e }) {
830
830
  },
831
831
  [L]
832
832
  );
833
- X(() => {
834
- !r.initialTenant && a ? w ? C() : E(a) : !r.initialTenant && !a && (u(null), I(null), g(!1));
835
- }, [r.initialTenant, a, w, E, C]), X(() => {
836
- w != null && w.id ? R() : (M(null), S(null), h(!1));
833
+ ee(() => {
834
+ !r.initialTenant && a ? w ? N() : E(a) : !r.initialTenant && !a && (d(null), I(null), h(!1));
835
+ }, [r.initialTenant, a, w, E, N]), ee(() => {
836
+ w != null && w.id ? R() : (M(null), b(null), u(!1));
837
837
  }, [w == null ? void 0 : w.id, R]);
838
- const D = re(
839
- (c, H) => {
840
- const { mode: F = "reload", tokens: y, redirectPath: m } = H || {}, v = r.tenantMode || "selector";
841
- if (v === "fixed") {
838
+ const D = se(
839
+ (g, C) => {
840
+ const { mode: T = "reload", tokens: S, redirectPath: y } = C || {}, k = r.tenantMode || "selector";
841
+ if (k === "fixed") {
842
842
  console.warn(
843
843
  "[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
844
844
  r.fixedTenantSlug
845
- ), m && (window.location.href = m);
845
+ ), y && (window.location.href = y);
846
846
  return;
847
847
  }
848
- if (localStorage.setItem("tenant", c), v === "subdomain") {
849
- const G = window.location.hostname, Y = wt(
850
- c,
851
- G,
848
+ if (localStorage.setItem("tenant", g), k === "subdomain") {
849
+ const j = window.location.hostname, Z = St(
850
+ g,
851
+ j,
852
852
  r.baseDomain
853
853
  );
854
- if (!Y) {
854
+ if (!Z) {
855
855
  console.warn(
856
856
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
857
- G
857
+ j
858
858
  );
859
859
  return;
860
860
  }
861
- const q = m || window.location.pathname, O = new URL(`${window.location.protocol}//${Y}${q}`);
862
- new URLSearchParams(window.location.search).forEach((k, K) => {
863
- K !== de && O.searchParams.set(K, k);
864
- }), y && O.searchParams.set(de, qe(y)), window.location.href = O.toString();
865
- } else if (v === "selector") {
866
- const G = m || window.location.pathname, Y = new URLSearchParams(window.location.search);
867
- if (Y.set(r.selectorParam || "tenant", c), Y.delete(de), y && Y.set(de, qe(y)), F === "reload") {
868
- const q = `${G}?${Y.toString()}${window.location.hash}`;
869
- window.location.href = q;
861
+ const O = y || window.location.pathname, q = new URL(`${window.location.protocol}//${Z}${O}`);
862
+ new URLSearchParams(window.location.search).forEach((B, X) => {
863
+ X !== de && q.searchParams.set(X, B);
864
+ }), S && q.searchParams.set(de, ze(S)), window.location.href = q.toString();
865
+ } else if (k === "selector") {
866
+ const j = y || window.location.pathname, Z = new URLSearchParams(window.location.search);
867
+ if (Z.set(r.selectorParam || "tenant", g), Z.delete(de), S && Z.set(de, ze(S)), T === "reload") {
868
+ const O = `${j}?${Z.toString()}${window.location.hash}`;
869
+ window.location.href = O;
870
870
  } else {
871
- const q = `${G}?${Y.toString()}${window.location.hash}`;
872
- window.history.pushState({}, "", q), p(c), E(c);
871
+ const O = `${j}?${Z.toString()}${window.location.hash}`;
872
+ window.history.pushState({}, "", O), p(g), E(g);
873
873
  }
874
874
  }
875
875
  },
876
876
  [r.tenantMode, r.selectorParam, r.baseDomain, E]
877
- ), U = Z(() => ({
877
+ ), $ = J(() => ({
878
878
  // Tenant info
879
879
  tenant: w,
880
880
  tenantSlug: a,
881
- isTenantLoading: b,
882
- tenantError: T,
881
+ isTenantLoading: m,
882
+ tenantError: v,
883
883
  retryTenant: () => {
884
884
  a && E(a);
885
885
  },
886
886
  // Settings
887
- settings: N,
887
+ settings: F,
888
888
  settingsSchema: L,
889
889
  isSettingsLoading: P,
890
890
  settingsError: A,
891
891
  // Actions
892
- refreshSettings: $,
892
+ refreshSettings: U,
893
893
  switchTenant: D,
894
894
  // Validation
895
895
  validateSettings: l
896
896
  }), [
897
897
  w,
898
898
  a,
899
- b,
900
- T,
901
- N,
899
+ m,
900
+ v,
901
+ F,
902
902
  L,
903
903
  P,
904
904
  A,
905
- $,
905
+ U,
906
906
  D,
907
907
  l
908
908
  ]);
909
- return /* @__PURE__ */ s(Me.Provider, { value: U, children: e });
909
+ return /* @__PURE__ */ s(Ee.Provider, { value: $, children: e });
910
910
  }
911
911
  function he() {
912
- const r = ie(Me);
912
+ const r = oe(Ee);
913
913
  if (!r)
914
914
  throw new Error("useTenant must be used within a TenantProvider");
915
915
  return r;
916
916
  }
917
- function Se() {
918
- return ie(Me);
917
+ function ve() {
918
+ return oe(Ee);
919
919
  }
920
- const fn = he;
921
- function mn() {
920
+ const yn = he;
921
+ function wn() {
922
922
  const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = he();
923
923
  return {
924
924
  settings: r,
@@ -938,305 +938,305 @@ function ge() {
938
938
  retry: i
939
939
  };
940
940
  }
941
- const Le = ue(null);
942
- function yn({ config: r = {}, children: e }) {
943
- const { appId: t, baseUrl: n } = ye(), { tenant: i, tenantSlug: o, switchTenant: a } = he(), [p, f] = x(r.initialRoles || []), [w, u] = x(!r.initialRoles), [b, g] = x(null), [T, I] = x(!1), [N, M] = x(null), [P, h] = x(0), [A, S] = x(() => {
941
+ const Fe = ue(null);
942
+ function bn({ config: r = {}, children: e }) {
943
+ const { appId: t, baseUrl: n } = we(), { tenant: i, tenantSlug: o, switchTenant: a } = he(), [p, f] = x(r.initialRoles || []), [w, d] = x(!r.initialRoles), [m, h] = x(null), [v, I] = x(!1), [F, M] = x(null), [P, u] = x(0), [A, b] = x(() => {
944
944
  try {
945
- const k = localStorage.getItem("userTenants");
946
- return k ? JSON.parse(k) : [];
945
+ const G = localStorage.getItem("userTenants");
946
+ return G ? JSON.parse(G) : [];
947
947
  } catch {
948
948
  return [];
949
949
  }
950
- }), [L, E] = x(!1), C = Ve({ done: !1, urlTokens: null });
951
- C.current.done || (C.current.done = !0, C.current.urlTokens = St(), C.current.urlTokens && console.log(
950
+ }), [L, E] = x(!1), N = Ge({ done: !1, urlTokens: null });
951
+ N.current.done || (N.current.done = !0, N.current.urlTokens = Tt(), N.current.urlTokens && console.log(
952
952
  "[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
953
953
  ));
954
- const [R, $] = x(() => {
955
- const k = C.current.urlTokens !== null;
956
- return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", k), k;
957
- }), l = Z(() => {
958
- const k = new Ae({
954
+ const [R, U] = x(() => {
955
+ const G = N.current.urlTokens !== null;
956
+ return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", G), G;
957
+ }), l = J(() => {
958
+ const G = new Re({
959
959
  tenantSlug: o,
960
960
  onRefreshFailed: r.onRefreshFailed,
961
961
  baseUrl: n
962
962
  });
963
- return C.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), k.setTokens({
964
- accessToken: C.current.urlTokens.accessToken,
965
- refreshToken: C.current.urlTokens.refreshToken,
966
- expiresIn: C.current.urlTokens.expiresIn
967
- }), console.log("[AuthProvider] SYNC: Session valid:", k.hasValidSession())), k;
968
- }, [o, n, r.onRefreshFailed]), D = C.current.done && !R, U = Z(() => {
969
- const k = new oe(n);
970
- return k.setSessionManager(l), k;
971
- }, [n, l]), c = Z(() => new gt(new oe(n)), [n]), H = Z(() => new pt(U, l), [U, l]), F = Z(() => new Be(new oe(n)), [n]), y = Z(() => b || l.getUser(), [b, l]), m = Z(() => y != null && y.roleId && p.find((k) => k.id === y.roleId) || null, [y, p]), v = Z(() => (m == null ? void 0 : m.permissions) || [], [m]), G = Z(() => l.hasValidSession() && b !== null, [l, b]), Y = 5 * 60 * 1e3, q = Z(() => {
972
- const k = async (B = !1) => {
963
+ return N.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), G.setTokens({
964
+ accessToken: N.current.urlTokens.accessToken,
965
+ refreshToken: N.current.urlTokens.refreshToken,
966
+ expiresIn: N.current.urlTokens.expiresIn
967
+ }), console.log("[AuthProvider] SYNC: Session valid:", G.hasValidSession())), G;
968
+ }, [o, n, r.onRefreshFailed]), [D, $] = x(() => N.current.urlTokens ? !1 : l.hasValidSession()), g = N.current.done && !R && !D, C = J(() => {
969
+ const G = new ae(n);
970
+ return G.setSessionManager(l), G;
971
+ }, [n, l]), T = J(() => new ft(new ae(n)), [n]), S = J(() => new mt(C, l), [C, l]), y = J(() => new Oe(new ae(n)), [n]), k = J(() => m || l.getUser(), [m, l]), j = J(() => k != null && k.roleId && p.find((G) => G.id === k.roleId) || null, [k, p]), Z = J(() => (j == null ? void 0 : j.permissions) || [], [j]), O = J(() => l.hasValidSession() && m !== null, [l, m]), q = 5 * 60 * 1e3, W = J(() => {
972
+ const G = async (H = !1) => {
973
973
  try {
974
974
  if (!l.hasValidSession())
975
975
  return;
976
976
  const z = Date.now();
977
- if (!B && z - P < Y && b)
977
+ if (!H && z - P < q && m)
978
978
  return;
979
- const W = l.getUserId();
980
- if (!W) {
979
+ const V = l.getUserId();
980
+ if (!V) {
981
981
  console.warn("[AuthProvider] No userId available in token or storage");
982
982
  return;
983
983
  }
984
984
  I(!0), M(null);
985
- const J = await H.getUserById(W);
986
- g(J), l.setUser(J), h(Date.now());
985
+ const Y = await S.getUserById(V);
986
+ h(Y), l.setUser(Y), u(Date.now());
987
987
  } catch (z) {
988
988
  const Q = z instanceof Error ? z : new Error("Failed to load user data");
989
989
  M(Q), console.error("[AuthProvider] Failed to load user data:", Q);
990
990
  } finally {
991
991
  I(!1);
992
992
  }
993
- }, K = async () => {
994
- await k();
995
- }, ce = async (B) => {
996
- var Ue;
997
- const { username: z, password: Q, tenantSlug: W, redirectPath: J } = B;
998
- let ee = i == null ? void 0 : i.id, te = o, ne = l;
999
- W && (ee = (await new fe(U, t).getPublicTenantInfo(W)).id, te = W);
1000
- const j = await c.login({
993
+ }, pe = async () => {
994
+ await G();
995
+ }, Te = async (H) => {
996
+ var He;
997
+ const { username: z, password: Q, tenantSlug: V, redirectPath: Y } = H;
998
+ let te = i == null ? void 0 : i.id, ne = o, re = l;
999
+ V && (te = (await new me(C, t).getPublicTenantInfo(V)).id, ne = V);
1000
+ const K = await T.login({
1001
1001
  username: z,
1002
1002
  password: Q,
1003
1003
  appId: t,
1004
- tenantId: ee
1005
- }), pe = W && W !== o;
1006
- if (pe && (ne = new Ae({
1007
- tenantSlug: te,
1004
+ tenantId: te
1005
+ }), fe = V && V !== o;
1006
+ if (fe && (re = new Re({
1007
+ tenantSlug: ne,
1008
1008
  baseUrl: n
1009
- })), ne.setTokens({
1010
- accessToken: j.accessToken,
1011
- refreshToken: j.refreshToken,
1012
- expiresIn: j.expiresIn
1013
- }), j.user) {
1014
- ne.setUser(j.user), g(j.user);
1009
+ })), re.setTokens({
1010
+ accessToken: K.accessToken,
1011
+ refreshToken: K.refreshToken,
1012
+ expiresIn: K.expiresIn
1013
+ }), K.user) {
1014
+ re.setUser(K.user), h(K.user);
1015
1015
  try {
1016
- await k();
1017
- } catch (we) {
1018
- console.warn("Failed to load complete user data after login:", we);
1016
+ await G();
1017
+ } catch (be) {
1018
+ console.warn("Failed to load complete user data after login:", be);
1019
1019
  }
1020
1020
  }
1021
- if (j.tenants && j.tenants.length > 0) {
1022
- S(j.tenants);
1021
+ if (K.tenants && K.tenants.length > 0) {
1022
+ b(K.tenants);
1023
1023
  try {
1024
- localStorage.setItem("userTenants", JSON.stringify(j.tenants));
1024
+ localStorage.setItem("userTenants", JSON.stringify(K.tenants));
1025
1025
  } catch {
1026
1026
  }
1027
1027
  }
1028
- const ke = ((Ue = j.user) == null ? void 0 : Ue.tenantId) !== null;
1029
- E(ke);
1030
- const xe = {
1031
- accessToken: j.accessToken,
1032
- refreshToken: j.refreshToken,
1033
- expiresIn: j.expiresIn
1028
+ const Ae = ((He = K.user) == null ? void 0 : He.tenantId) !== null;
1029
+ E(Ae);
1030
+ const Pe = {
1031
+ accessToken: K.accessToken,
1032
+ refreshToken: K.refreshToken,
1033
+ expiresIn: K.expiresIn
1034
1034
  };
1035
- if (pe && te)
1036
- return a(te, { tokens: xe, redirectPath: J }), j;
1037
- if (J && J !== window.location.pathname)
1038
- return a(te || o || "", { tokens: xe, redirectPath: J }), j;
1039
- if (!ke && j.tenants && j.tenants.length > 0) {
1040
- const we = B.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1041
- if (j.tenants.length === 1 && we) {
1042
- const $e = j.tenants[0];
1043
- return a($e.subdomain, { tokens: xe, redirectPath: J }), j;
1044
- } else j.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(j.tenants);
1035
+ if (fe && ne)
1036
+ return a(ne, { tokens: Pe, redirectPath: Y }), K;
1037
+ if (Y && Y !== window.location.pathname)
1038
+ return a(ne || o || "", { tokens: Pe, redirectPath: Y }), K;
1039
+ if (!Ae && K.tenants && K.tenants.length > 0) {
1040
+ const be = H.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1041
+ if (K.tenants.length === 1 && be) {
1042
+ const Be = K.tenants[0];
1043
+ return a(Be.subdomain, { tokens: Pe, redirectPath: Y }), K;
1044
+ } else K.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(K.tenants);
1045
1045
  }
1046
- return j;
1047
- }, ve = async (B) => {
1048
- const { email: z, phoneNumber: Q, name: W, password: J, lastName: ee, tenantId: te } = B;
1046
+ return K;
1047
+ }, ke = async (H) => {
1048
+ const { email: z, phoneNumber: Q, name: V, password: Y, lastName: te, tenantId: ne } = H;
1049
1049
  if (!z && !Q)
1050
1050
  throw new Error("Either email or phoneNumber is required");
1051
- if (!W || !J)
1051
+ if (!V || !Y)
1052
1052
  throw new Error("Name and password are required");
1053
- const ne = te ?? (i == null ? void 0 : i.id);
1054
- return await c.signup({
1053
+ const re = ne ?? (i == null ? void 0 : i.id);
1054
+ return await T.signup({
1055
1055
  email: z,
1056
1056
  phoneNumber: Q,
1057
- name: W,
1058
- password: J,
1059
- tenantId: ne,
1060
- lastName: ee,
1057
+ name: V,
1058
+ password: Y,
1059
+ tenantId: re,
1060
+ lastName: te,
1061
1061
  appId: t
1062
1062
  });
1063
- }, Qe = async (B) => {
1064
- const { email: z, phoneNumber: Q, name: W, password: J, tenantName: ee, lastName: te } = B;
1063
+ }, et = async (H) => {
1064
+ const { email: z, phoneNumber: Q, name: V, password: Y, tenantName: te, lastName: ne } = H;
1065
1065
  if (!z && !Q)
1066
1066
  throw new Error("Either email or phoneNumber is required");
1067
- if (!W || !J || !ee)
1067
+ if (!V || !Y || !te)
1068
1068
  throw new Error("Name, password, and tenantName are required");
1069
- return await c.signupTenantAdmin({
1069
+ return await T.signupTenantAdmin({
1070
1070
  email: z,
1071
1071
  phoneNumber: Q,
1072
- name: W,
1073
- password: J,
1074
- tenantName: ee,
1072
+ name: V,
1073
+ password: Y,
1074
+ tenantName: te,
1075
1075
  appId: t,
1076
- lastName: te
1076
+ lastName: ne
1077
1077
  });
1078
- }, Xe = async (B) => {
1079
- const { currentPassword: z, newPassword: Q } = B, W = await l.getAuthHeaders();
1080
- await c.changePassword({ currentPassword: z, newPassword: Q }, W);
1081
- }, et = async (B) => {
1082
- const { email: z, tenantId: Q } = B, W = Q ?? (i == null ? void 0 : i.id);
1083
- if (!W)
1078
+ }, tt = async (H) => {
1079
+ const { currentPassword: z, newPassword: Q } = H, V = await l.getAuthHeaders();
1080
+ await T.changePassword({ currentPassword: z, newPassword: Q }, V);
1081
+ }, nt = async (H) => {
1082
+ const { email: z, tenantId: Q } = H, V = Q ?? (i == null ? void 0 : i.id);
1083
+ if (!V)
1084
1084
  throw new Error("tenantId is required for password reset");
1085
- await c.requestPasswordReset({ email: z, tenantId: W });
1086
- }, tt = async (B) => {
1087
- const { token: z, newPassword: Q } = B;
1088
- await c.confirmPasswordReset({ token: z, newPassword: Q });
1089
- }, nt = async (B) => {
1090
- const { email: z, frontendUrl: Q, name: W, lastName: J, tenantId: ee } = B, te = ee ?? (i == null ? void 0 : i.id);
1091
- if (!te)
1085
+ await T.requestPasswordReset({ email: z, tenantId: V });
1086
+ }, rt = async (H) => {
1087
+ const { token: z, newPassword: Q } = H;
1088
+ await T.confirmPasswordReset({ token: z, newPassword: Q });
1089
+ }, st = async (H) => {
1090
+ const { email: z, frontendUrl: Q, name: V, lastName: Y, tenantId: te } = H, ne = te ?? (i == null ? void 0 : i.id);
1091
+ if (!ne)
1092
1092
  throw new Error("tenantId is required for magic link authentication");
1093
- return await c.sendMagicLink({
1093
+ return await T.sendMagicLink({
1094
1094
  email: z,
1095
- tenantId: te,
1095
+ tenantId: ne,
1096
1096
  frontendUrl: Q,
1097
- name: W,
1098
- lastName: J,
1097
+ name: V,
1098
+ lastName: Y,
1099
1099
  appId: t
1100
1100
  });
1101
- }, rt = async (B) => {
1102
- const { token: z, email: Q, tenantSlug: W } = B;
1103
- let J = i == null ? void 0 : i.id, ee = o, te = l;
1104
- W && (J = (await new fe(U, t).getPublicTenantInfo(W)).id, ee = W);
1105
- const ne = await c.verifyMagicLink({
1101
+ }, it = async (H) => {
1102
+ const { token: z, email: Q, tenantSlug: V } = H;
1103
+ let Y = i == null ? void 0 : i.id, te = o, ne = l;
1104
+ V && (Y = (await new me(C, t).getPublicTenantInfo(V)).id, te = V);
1105
+ const re = await T.verifyMagicLink({
1106
1106
  token: z,
1107
1107
  email: Q,
1108
1108
  appId: t,
1109
- tenantId: J
1110
- }), j = W && W !== o;
1111
- if (j && (te = new Ae({
1112
- tenantSlug: ee,
1109
+ tenantId: Y
1110
+ }), K = V && V !== o;
1111
+ if (K && (ne = new Re({
1112
+ tenantSlug: te,
1113
1113
  baseUrl: n
1114
- })), te.setTokens({
1115
- accessToken: ne.accessToken,
1116
- refreshToken: ne.refreshToken,
1117
- expiresIn: ne.expiresIn
1118
- }), ne.user) {
1119
- te.setUser(ne.user), g(ne.user);
1114
+ })), ne.setTokens({
1115
+ accessToken: re.accessToken,
1116
+ refreshToken: re.refreshToken,
1117
+ expiresIn: re.expiresIn
1118
+ }), re.user) {
1119
+ ne.setUser(re.user), h(re.user);
1120
1120
  try {
1121
- await k();
1122
- } catch (pe) {
1123
- console.warn("Failed to load complete user data after magic link login:", pe);
1121
+ await G();
1122
+ } catch (fe) {
1123
+ console.warn("Failed to load complete user data after magic link login:", fe);
1124
1124
  }
1125
1125
  }
1126
- return j && ee && ee !== o && a(ee, {
1126
+ return K && te && te !== o && a(te, {
1127
1127
  tokens: {
1128
- accessToken: ne.accessToken,
1129
- refreshToken: ne.refreshToken,
1130
- expiresIn: ne.expiresIn
1128
+ accessToken: re.accessToken,
1129
+ refreshToken: re.refreshToken,
1130
+ expiresIn: re.expiresIn
1131
1131
  }
1132
- }), ne;
1133
- }, st = async () => {
1134
- const B = l.getTokens();
1135
- if (!(B != null && B.refreshToken))
1132
+ }), re;
1133
+ }, ot = async () => {
1134
+ const H = l.getTokens();
1135
+ if (!(H != null && H.refreshToken))
1136
1136
  throw new Error("No refresh token available");
1137
- const z = await c.refreshToken({
1138
- refreshToken: B.refreshToken
1137
+ const z = await T.refreshToken({
1138
+ refreshToken: H.refreshToken
1139
1139
  });
1140
1140
  l.setTokens({
1141
1141
  accessToken: z.accessToken,
1142
- refreshToken: z.refreshToken || B.refreshToken,
1142
+ refreshToken: z.refreshToken || H.refreshToken,
1143
1143
  expiresIn: z.expiresIn
1144
1144
  });
1145
- }, it = () => {
1146
- l.clearSession(), g(null), M(null), S([]), E(!1);
1145
+ }, at = () => {
1146
+ l.clearSession(), h(null), M(null), b([]), E(!1);
1147
1147
  try {
1148
1148
  localStorage.removeItem("userTenants");
1149
1149
  } catch {
1150
1150
  }
1151
- }, ot = (B) => {
1152
- l.setTokens(B);
1153
- }, at = () => l.hasValidSession(), lt = () => {
1154
- l.clearSession(), g(null), M(null);
1155
- }, ct = async () => {
1151
+ }, lt = (H) => {
1152
+ l.setTokens(H);
1153
+ }, ct = () => l.hasValidSession(), dt = () => {
1154
+ l.clearSession(), h(null), M(null);
1155
+ }, ut = async () => {
1156
1156
  if (t)
1157
1157
  try {
1158
- u(!0);
1159
- const { roles: B } = await F.getRolesByApp(t);
1160
- f(B);
1161
- } catch (B) {
1162
- console.error("Failed to fetch roles:", B);
1158
+ d(!0);
1159
+ const { roles: H } = await y.getRolesByApp(t);
1160
+ f(H);
1161
+ } catch (H) {
1162
+ console.error("Failed to fetch roles:", H);
1163
1163
  } finally {
1164
- u(!1);
1164
+ d(!1);
1165
1165
  }
1166
- }, dt = async () => {
1167
- await ct();
1168
- }, Te = (B) => {
1169
- if (!v || v.length === 0)
1166
+ }, ht = async () => {
1167
+ await ut();
1168
+ }, xe = (H) => {
1169
+ if (!Z || Z.length === 0)
1170
1170
  return !1;
1171
- if (typeof B == "string")
1172
- return v.includes(B);
1173
- const z = `${B.resource}.${B.action}`;
1174
- return v.includes(z);
1171
+ if (typeof H == "string")
1172
+ return Z.includes(H);
1173
+ const z = `${H.resource}.${H.action}`;
1174
+ return Z.includes(z);
1175
1175
  };
1176
1176
  return {
1177
1177
  // RFC-003: Authentication state
1178
- isAuthenticated: G,
1178
+ isAuthenticated: O,
1179
1179
  sessionManager: l,
1180
- authenticatedHttpService: U,
1181
- login: ce,
1182
- signup: ve,
1183
- signupTenantAdmin: Qe,
1184
- sendMagicLink: nt,
1185
- verifyMagicLink: rt,
1186
- changePassword: Xe,
1187
- requestPasswordReset: et,
1188
- confirmPasswordReset: tt,
1189
- refreshToken: st,
1190
- logout: it,
1191
- setTokens: ot,
1192
- hasValidSession: at,
1193
- clearSession: lt,
1194
- currentUser: b,
1195
- isUserLoading: T,
1196
- userError: N,
1197
- loadUserData: k,
1198
- refreshUser: K,
1199
- isAuthInitializing: !D,
1200
- isAuthReady: D,
1201
- userRole: m,
1202
- userPermissions: v,
1180
+ authenticatedHttpService: C,
1181
+ login: Te,
1182
+ signup: ke,
1183
+ signupTenantAdmin: et,
1184
+ sendMagicLink: st,
1185
+ verifyMagicLink: it,
1186
+ changePassword: tt,
1187
+ requestPasswordReset: nt,
1188
+ confirmPasswordReset: rt,
1189
+ refreshToken: ot,
1190
+ logout: at,
1191
+ setTokens: lt,
1192
+ hasValidSession: ct,
1193
+ clearSession: dt,
1194
+ currentUser: m,
1195
+ isUserLoading: v,
1196
+ userError: F,
1197
+ loadUserData: G,
1198
+ refreshUser: pe,
1199
+ isAuthInitializing: !g,
1200
+ isAuthReady: g,
1201
+ userRole: j,
1202
+ userPermissions: Z,
1203
1203
  availableRoles: p,
1204
1204
  rolesLoading: w,
1205
- hasPermission: Te,
1206
- hasAnyPermission: (B) => B.some((z) => Te(z)),
1207
- hasAllPermissions: (B) => B.every((z) => Te(z)),
1208
- getUserPermissionStrings: () => v || [],
1209
- refreshRoles: dt,
1205
+ hasPermission: xe,
1206
+ hasAnyPermission: (H) => H.some((z) => xe(z)),
1207
+ hasAllPermissions: (H) => H.every((z) => xe(z)),
1208
+ getUserPermissionStrings: () => Z || [],
1209
+ refreshRoles: ht,
1210
1210
  // RFC-004: Multi-tenant user membership
1211
1211
  userTenants: A,
1212
1212
  hasTenantContext: L,
1213
- switchToTenant: async (B, z) => {
1214
- const { redirectPath: Q } = z || {}, W = l.getTokens();
1215
- if (!(W != null && W.refreshToken))
1213
+ switchToTenant: async (H, z) => {
1214
+ const { redirectPath: Q } = z || {}, V = l.getTokens();
1215
+ if (!(V != null && V.refreshToken))
1216
1216
  throw new Error("No refresh token available for tenant switch");
1217
- const J = await c.switchTenant({
1218
- refreshToken: W.refreshToken,
1219
- tenantId: B
1217
+ const Y = await T.switchTenant({
1218
+ refreshToken: V.refreshToken,
1219
+ tenantId: H
1220
1220
  });
1221
1221
  l.setTokens({
1222
- accessToken: J.accessToken,
1223
- refreshToken: W.refreshToken,
1222
+ accessToken: Y.accessToken,
1223
+ refreshToken: V.refreshToken,
1224
1224
  // Keep the same refresh token
1225
- expiresIn: J.expiresIn
1226
- }), g(J.user), l.setUser(J.user), E(!0);
1227
- const ee = A.find((te) => te.id === B);
1228
- ee && a(ee.subdomain, {
1225
+ expiresIn: Y.expiresIn
1226
+ }), h(Y.user), l.setUser(Y.user), E(!0);
1227
+ const te = A.find((ne) => ne.id === H);
1228
+ te && a(te.subdomain, {
1229
1229
  tokens: {
1230
- accessToken: J.accessToken,
1231
- refreshToken: W.refreshToken,
1232
- expiresIn: J.expiresIn
1230
+ accessToken: Y.accessToken,
1231
+ refreshToken: V.refreshToken,
1232
+ expiresIn: Y.expiresIn
1233
1233
  },
1234
1234
  redirectPath: Q
1235
1235
  });
1236
1236
  },
1237
1237
  refreshUserTenants: async () => {
1238
- const B = await l.getAuthHeaders(), z = await c.getUserTenants(B);
1239
- S(z);
1238
+ const H = await l.getAuthHeaders(), z = await T.getUserTenants(H);
1239
+ b(z);
1240
1240
  try {
1241
1241
  localStorage.setItem("userTenants", JSON.stringify(z));
1242
1242
  } catch {
@@ -1245,74 +1245,76 @@ function yn({ config: r = {}, children: e }) {
1245
1245
  }
1246
1246
  };
1247
1247
  }, [
1248
- G,
1248
+ O,
1249
1249
  l,
1250
- U,
1251
- c,
1252
- H,
1253
- F,
1250
+ C,
1251
+ T,
1252
+ S,
1253
+ y,
1254
1254
  t,
1255
1255
  i,
1256
1256
  o,
1257
1257
  a,
1258
1258
  p,
1259
- b,
1260
- T,
1261
- N,
1262
- A,
1263
- L,
1264
- D,
1265
1259
  m,
1266
1260
  v,
1261
+ F,
1262
+ A,
1263
+ L,
1264
+ g,
1265
+ j,
1266
+ Z,
1267
1267
  P,
1268
- Y
1268
+ q
1269
1269
  ]);
1270
- X(() => {
1270
+ ee(() => {
1271
1271
  !r.initialRoles && t && (async () => {
1272
1272
  try {
1273
- u(!0);
1274
- const K = new oe(n), ce = new Be(K), { roles: ve } = await ce.getRolesByApp(t);
1275
- f(ve);
1276
- } catch (K) {
1277
- console.error("Failed to fetch roles:", K);
1273
+ d(!0);
1274
+ const pe = new ae(n), Te = new Oe(pe), { roles: ke } = await Te.getRolesByApp(t);
1275
+ f(ke);
1276
+ } catch (pe) {
1277
+ console.error("Failed to fetch roles:", pe);
1278
1278
  } finally {
1279
- u(!1);
1279
+ d(!1);
1280
1280
  }
1281
1281
  })();
1282
1282
  }, [t, n, r.initialRoles]);
1283
- const [O, V] = x(!1);
1284
- return X(() => {
1285
- O || (V(!0), C.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), vt(), $(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), q.loadUserData().catch((k) => {
1286
- console.error("[AuthProvider] Failed to load user data:", k);
1283
+ const [B, X] = x(!1);
1284
+ return ee(() => {
1285
+ B || (X(!0), N.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), kt(), U(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), W.loadUserData().catch((G) => {
1286
+ console.error("[AuthProvider] Failed to load user data:", G);
1287
1287
  }).finally(() => {
1288
- console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), $(!1);
1288
+ console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), U(!1);
1289
1289
  })));
1290
- }, [q, O]), X(() => {
1291
- const k = l.getUser();
1292
- k && l.hasValidSession() && g(k);
1293
- }, [l]), X(() => {
1294
- O && (C.current.urlTokens || !b && !T && l.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), q.loadUserData().catch(() => {
1295
- })));
1296
- }, [b, T, q, l, O]), X(() => {
1297
- if (!l.hasValidSession() || !b)
1290
+ }, [W, B]), ee(() => {
1291
+ const G = l.getUser();
1292
+ G && l.hasValidSession() ? (h(G), $(!1)) : l.hasValidSession() || $(!1);
1293
+ }, [l]), ee(() => {
1294
+ B && (N.current.urlTokens || (!m && !v && l.hasValidSession() ? (console.log("[AuthProvider] Auto-loading user data..."), W.loadUserData().catch(() => {
1295
+ }).finally(() => {
1296
+ $(!1);
1297
+ })) : m && $(!1)));
1298
+ }, [m, v, W, l, B]), ee(() => {
1299
+ if (!l.hasValidSession() || !m)
1298
1300
  return;
1299
- const k = setInterval(() => {
1300
- q.loadUserData().catch(() => {
1301
+ const G = setInterval(() => {
1302
+ W.loadUserData().catch(() => {
1301
1303
  });
1302
- }, Y);
1303
- return () => clearInterval(k);
1304
- }, [l, b, q, Y]), /* @__PURE__ */ s(Le.Provider, { value: q, children: e });
1304
+ }, q);
1305
+ return () => clearInterval(G);
1306
+ }, [l, m, W, q]), /* @__PURE__ */ s(Fe.Provider, { value: W, children: e });
1305
1307
  }
1306
- function le() {
1307
- const r = ie(Le);
1308
+ function ce() {
1309
+ const r = oe(Fe);
1308
1310
  if (!r)
1309
1311
  throw new Error("useAuth must be used within an AuthProvider");
1310
1312
  return r;
1311
1313
  }
1312
- function Ee() {
1313
- return ie(Le);
1314
+ function Ne() {
1315
+ return oe(Fe);
1314
1316
  }
1315
- class Tt {
1317
+ class xt {
1316
1318
  constructor(e, t) {
1317
1319
  this.httpService = e, this.sessionManager = t;
1318
1320
  }
@@ -1392,66 +1394,66 @@ class Tt {
1392
1394
  })).data;
1393
1395
  }
1394
1396
  }
1395
- const Fe = ue(null);
1396
- function wn({ config: r = {}, children: e }) {
1397
- const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = x([]), [w, u] = x(!1), [b, g] = x(null), [T, I] = x(!1), N = Z(() => {
1398
- const h = new oe(i);
1399
- return new Tt(h);
1397
+ const De = ue(null);
1398
+ function Sn({ config: r = {}, children: e }) {
1399
+ const t = Ze(), n = ve(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = x([]), [w, d] = x(!1), [m, h] = x(null), [v, I] = x(!1), F = J(() => {
1400
+ const u = new ae(i);
1401
+ return new xt(u);
1400
1402
  }, [i]), M = async () => {
1401
1403
  if (!(a != null && a.id)) {
1402
1404
  f([]);
1403
1405
  return;
1404
1406
  }
1405
- u(!0), g(null);
1407
+ d(!0), h(null);
1406
1408
  try {
1407
- const h = await N.getTenantFeatureFlags(a.id, o);
1408
- f(h);
1409
- } catch (h) {
1410
- const A = h instanceof Error ? h.message : "Failed to fetch feature flags";
1411
- g(A), r.onError && r.onError(h instanceof Error ? h : new Error(A));
1409
+ const u = await F.getTenantFeatureFlags(a.id, o);
1410
+ f(u);
1411
+ } catch (u) {
1412
+ const A = u instanceof Error ? u.message : "Failed to fetch feature flags";
1413
+ h(A), r.onError && r.onError(u instanceof Error ? u : new Error(A));
1412
1414
  } finally {
1413
- u(!1);
1415
+ d(!1);
1414
1416
  }
1415
1417
  };
1416
- X(() => {
1418
+ ee(() => {
1417
1419
  if (!i || !o) return;
1418
1420
  M().finally(() => I(!0));
1419
- const h = r.refreshInterval || 5 * 60 * 1e3, A = setInterval(M, h);
1421
+ const u = r.refreshInterval || 5 * 60 * 1e3, A = setInterval(M, u);
1420
1422
  return () => clearInterval(A);
1421
1423
  }, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
1422
- const P = Z(() => {
1423
- const h = (C) => {
1424
- const R = p.find(($) => $.key === C);
1424
+ const P = J(() => {
1425
+ const u = (N) => {
1426
+ const R = p.find((U) => U.key === N);
1425
1427
  return (R == null ? void 0 : R.value) === !0;
1426
- }, A = (C) => p.find((R) => R.key === C), S = (C) => {
1427
- const R = p.find(($) => $.key === C);
1428
+ }, A = (N) => p.find((R) => R.key === N), b = (N) => {
1429
+ const R = p.find((U) => U.key === N);
1428
1430
  return R ? R.value ? "enabled" : "disabled" : "not_found";
1429
1431
  }, L = async () => {
1430
1432
  await M();
1431
- }, E = !!(i && o) && (T || !(a != null && a.id));
1433
+ }, E = !!(i && o) && (v || !(a != null && a.id));
1432
1434
  return {
1433
1435
  featureFlags: p,
1434
1436
  loading: w,
1435
- error: b,
1437
+ error: m,
1436
1438
  isReady: E,
1437
- isEnabled: h,
1439
+ isEnabled: u,
1438
1440
  getFlag: A,
1439
- getFlagState: S,
1441
+ getFlagState: b,
1440
1442
  refresh: L
1441
1443
  };
1442
- }, [p, w, b, i, o, a == null ? void 0 : a.id, T]);
1443
- return /* @__PURE__ */ s(Fe.Provider, { value: P, children: e });
1444
+ }, [p, w, m, i, o, a == null ? void 0 : a.id, v]);
1445
+ return /* @__PURE__ */ s(De.Provider, { value: P, children: e });
1444
1446
  }
1445
- function kt() {
1446
- const r = ie(Fe);
1447
+ function At() {
1448
+ const r = oe(De);
1447
1449
  if (!r)
1448
1450
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1449
1451
  return r;
1450
1452
  }
1451
- function Ge() {
1452
- return ie(Fe);
1453
+ function Ke() {
1454
+ return oe(De);
1453
1455
  }
1454
- class xt {
1456
+ class Pt {
1455
1457
  constructor(e, t) {
1456
1458
  this.httpService = e, this.sessionManager = t;
1457
1459
  }
@@ -1517,68 +1519,68 @@ class xt {
1517
1519
  )).data;
1518
1520
  }
1519
1521
  }
1520
- const Ne = ue(void 0);
1521
- function bn({ config: r = {}, children: e }) {
1522
- const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = x(null), [f, w] = x(!1), [u, b] = x(null), [g, T] = x(!1), I = Z(() => {
1523
- const P = new oe(i);
1524
- return new xt(P);
1525
- }, [i]), N = async () => {
1522
+ const Ce = ue(void 0);
1523
+ function vn({ config: r = {}, children: e }) {
1524
+ const t = Ze(), n = ve(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = x(null), [f, w] = x(!1), [d, m] = x(null), [h, v] = x(!1), I = J(() => {
1525
+ const P = new ae(i);
1526
+ return new Pt(P);
1527
+ }, [i]), F = async () => {
1526
1528
  if (!(o != null && o.id)) {
1527
1529
  p(null);
1528
1530
  return;
1529
1531
  }
1530
- w(!0), b(null);
1532
+ w(!0), m(null);
1531
1533
  try {
1532
1534
  const P = await I.getTenantSubscriptionFeatures(o.id);
1533
1535
  p(P);
1534
1536
  } catch (P) {
1535
- const h = P instanceof Error ? P.message : "Failed to fetch subscription";
1536
- b(h), r.onError && r.onError(P instanceof Error ? P : new Error(h));
1537
+ const u = P instanceof Error ? P.message : "Failed to fetch subscription";
1538
+ m(u), r.onError && r.onError(P instanceof Error ? P : new Error(u));
1537
1539
  } finally {
1538
1540
  w(!1);
1539
1541
  }
1540
1542
  };
1541
- X(() => {
1542
- if (!i || (N().finally(() => T(!0)), !r.refreshInterval)) return;
1543
- const P = r.refreshInterval || 10 * 60 * 1e3, h = setInterval(N, P);
1544
- return () => clearInterval(h);
1543
+ ee(() => {
1544
+ if (!i || (F().finally(() => v(!0)), !r.refreshInterval)) return;
1545
+ const P = r.refreshInterval || 10 * 60 * 1e3, u = setInterval(F, P);
1546
+ return () => clearInterval(u);
1545
1547
  }, [o == null ? void 0 : o.id, i, r.refreshInterval]);
1546
- const M = Z(() => {
1547
- const P = (a == null ? void 0 : a.features) || [], h = (R) => {
1548
- const $ = P.find((l) => l.key === R);
1549
- return $ ? $.type === "BOOLEAN" || $.type === "boolean" ? $.value === !0 : !!$.value : !1;
1550
- }, A = (R) => P.find(($) => $.key === R), S = (R, $) => {
1548
+ const M = J(() => {
1549
+ const P = (a == null ? void 0 : a.features) || [], u = (R) => {
1550
+ const U = P.find((l) => l.key === R);
1551
+ return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
1552
+ }, A = (R) => P.find((U) => U.key === R), b = (R, U) => {
1551
1553
  const l = P.find((D) => D.key === R);
1552
- return l ? l.value : $;
1554
+ return l ? l.value : U;
1553
1555
  }, L = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), E = async () => {
1554
- await N();
1555
- }, C = !!i && (g || !(o != null && o.id));
1556
+ await F();
1557
+ }, N = !!i && (h || !(o != null && o.id));
1556
1558
  return {
1557
1559
  subscription: a,
1558
1560
  features: P,
1559
1561
  loading: f,
1560
- error: u,
1561
- isReady: C,
1562
- isFeatureEnabled: h,
1562
+ error: d,
1563
+ isReady: N,
1564
+ isFeatureEnabled: u,
1563
1565
  getFeature: A,
1564
- getFeatureValue: S,
1566
+ getFeatureValue: b,
1565
1567
  hasAllowedPlan: L,
1566
1568
  refresh: E
1567
1569
  };
1568
- }, [a, f, u, i, o == null ? void 0 : o.id, g]);
1569
- return /* @__PURE__ */ s(Ne.Provider, { value: M, children: e });
1570
+ }, [a, f, d, i, o == null ? void 0 : o.id, h]);
1571
+ return /* @__PURE__ */ s(Ce.Provider, { value: M, children: e });
1570
1572
  }
1571
- function At() {
1572
- const r = ie(Ne);
1573
+ function Rt() {
1574
+ const r = oe(Ce);
1573
1575
  if (r === void 0)
1574
1576
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1575
1577
  return r;
1576
1578
  }
1577
- function Ze() {
1578
- return ie(Ne) ?? null;
1579
+ function Je() {
1580
+ return oe(Ce) ?? null;
1579
1581
  }
1580
- var se = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(se || {});
1581
- const De = {
1582
+ var ie = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(ie || {});
1583
+ const Ue = {
1582
1584
  publicGuest: "/",
1583
1585
  publicUser: "/account",
1584
1586
  publicAdmin: "/admin",
@@ -1586,7 +1588,7 @@ const De = {
1586
1588
  tenantUser: "/dashboard",
1587
1589
  tenantAdmin: "/admin/dashboard",
1588
1590
  default: "/"
1589
- }, Ke = {
1591
+ }, Ye = {
1590
1592
  // Public/Landing zones
1591
1593
  landing: { tenant: "forbidden", auth: "optional" },
1592
1594
  publicOnly: { tenant: "forbidden", auth: "forbidden" },
@@ -1599,18 +1601,18 @@ const De = {
1599
1601
  tenantOpen: { tenant: "required", auth: "optional" },
1600
1602
  tenantAuth: { tenant: "required", auth: "required" },
1601
1603
  // User type zones
1602
- user: { tenant: "required", auth: "required", userType: se.USER },
1603
- admin: { tenant: "required", auth: "required", userType: se.TENANT_ADMIN },
1604
+ user: { tenant: "required", auth: "required", userType: ie.USER },
1605
+ admin: { tenant: "required", auth: "required", userType: ie.TENANT_ADMIN },
1604
1606
  // Fully open
1605
1607
  open: { tenant: "optional", auth: "optional" }
1606
- }, Ce = ue(null);
1607
- function Sn({ config: r = {}, children: e }) {
1608
- const t = Z(() => {
1608
+ }, $e = ue(null);
1609
+ function Tn({ config: r = {}, children: e }) {
1610
+ const t = J(() => {
1609
1611
  const n = {
1610
- ...De,
1612
+ ...Ue,
1611
1613
  ...r.zoneRoots
1612
1614
  }, i = {
1613
- ...Ke,
1615
+ ...Ye,
1614
1616
  ...r.presets
1615
1617
  };
1616
1618
  return {
@@ -1623,19 +1625,19 @@ function Sn({ config: r = {}, children: e }) {
1623
1625
  returnToStorage: r.returnToStorage ?? "url"
1624
1626
  };
1625
1627
  }, [r]);
1626
- return /* @__PURE__ */ s(Ce.Provider, { value: t, children: e });
1628
+ return /* @__PURE__ */ s($e.Provider, { value: t, children: e });
1627
1629
  }
1628
- function vn() {
1629
- const r = ie(Ce);
1630
+ function kn() {
1631
+ const r = oe($e);
1630
1632
  if (!r)
1631
1633
  throw new Error("useRouting must be used within a RoutingProvider");
1632
1634
  return r;
1633
1635
  }
1634
- function Pt() {
1635
- const r = ie(Ce);
1636
+ function It() {
1637
+ const r = oe($e);
1636
1638
  return r || {
1637
- zoneRoots: De,
1638
- presets: Ke,
1639
+ zoneRoots: Ue,
1640
+ presets: Ye,
1639
1641
  loadingFallback: null,
1640
1642
  accessDeniedFallback: null,
1641
1643
  onAccessDenied: void 0,
@@ -1643,7 +1645,7 @@ function Pt() {
1643
1645
  returnToStorage: "url"
1644
1646
  };
1645
1647
  }
1646
- const Oe = () => /* @__PURE__ */ d(
1648
+ const _e = () => /* @__PURE__ */ c(
1647
1649
  "div",
1648
1650
  {
1649
1651
  style: {
@@ -1680,11 +1682,11 @@ const Oe = () => /* @__PURE__ */ d(
1680
1682
  )
1681
1683
  ]
1682
1684
  }
1683
- ), ze = ({
1685
+ ), We = ({
1684
1686
  userType: r,
1685
1687
  minUserType: e,
1686
1688
  missingPermissions: t
1687
- }) => /* @__PURE__ */ d(
1689
+ }) => /* @__PURE__ */ c(
1688
1690
  "div",
1689
1691
  {
1690
1692
  style: {
@@ -1702,55 +1704,55 @@ const Oe = () => /* @__PURE__ */ d(
1702
1704
  children: [
1703
1705
  /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1704
1706
  /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1705
- e && r ? /* @__PURE__ */ d(_, { children: [
1706
- /* @__PURE__ */ d("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1707
+ e && r ? /* @__PURE__ */ c(_, { children: [
1708
+ /* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1707
1709
  "This content requires ",
1708
1710
  /* @__PURE__ */ s("strong", { children: e }),
1709
1711
  " access level or higher."
1710
1712
  ] }),
1711
- /* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1713
+ /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1712
1714
  "Your current access level: ",
1713
1715
  /* @__PURE__ */ s("strong", { children: r })
1714
1716
  ] })
1715
- ] }) : /* @__PURE__ */ d(_, { children: [
1717
+ ] }) : /* @__PURE__ */ c(_, { children: [
1716
1718
  /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1717
- t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1719
+ t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1718
1720
  "Required permissions: ",
1719
1721
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
1720
1722
  ] })
1721
1723
  ] })
1722
1724
  ]
1723
1725
  }
1724
- ), Rt = (r, e) => {
1726
+ ), Mt = (r, e) => {
1725
1727
  const t = {
1726
- [se.USER]: 1,
1727
- [se.TENANT_ADMIN]: 2,
1728
- [se.SUPERUSER]: 3
1728
+ [ie.USER]: 1,
1729
+ [ie.TENANT_ADMIN]: 2,
1730
+ [ie.SUPERUSER]: 3
1729
1731
  };
1730
1732
  return t[r] >= t[e];
1731
1733
  };
1732
- function Tn({
1734
+ function xn({
1733
1735
  children: r,
1734
1736
  fallback: e,
1735
1737
  minUserType: t,
1736
1738
  requiredPermissions: n,
1737
1739
  requireAllPermissions: i = !1
1738
1740
  }) {
1739
- const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } = le();
1741
+ const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } = ce();
1740
1742
  if (!o())
1741
- return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Oe, {}) });
1742
- const u = a.getUser();
1743
- if (!u)
1744
- return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Oe, {}) });
1745
- if (t && !Rt(u.userType, t))
1746
- return /* @__PURE__ */ s(ze, { userType: u.userType, minUserType: t });
1743
+ return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(_e, {}) });
1744
+ const d = a.getUser();
1745
+ if (!d)
1746
+ return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(_e, {}) });
1747
+ if (t && !Mt(d.userType, t))
1748
+ return /* @__PURE__ */ s(We, { userType: d.userType, minUserType: t });
1747
1749
  if (n && n.length > 0 && !(i ? w(n) : f(n))) {
1748
- const g = n.filter((T) => !p(T)).map((T) => typeof T == "string" ? T : T.name);
1749
- return /* @__PURE__ */ s(ze, { missingPermissions: g });
1750
+ const h = n.filter((v) => !p(v)).map((v) => typeof v == "string" ? v : v.name);
1751
+ return /* @__PURE__ */ s(We, { missingPermissions: h });
1750
1752
  }
1751
1753
  return /* @__PURE__ */ s(_, { children: r });
1752
1754
  }
1753
- const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1755
+ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1754
1756
  "div",
1755
1757
  {
1756
1758
  style: {
@@ -1763,7 +1765,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1763
1765
  backgroundColor: "#f9fafb",
1764
1766
  textAlign: "center"
1765
1767
  },
1766
- children: /* @__PURE__ */ d(
1768
+ children: /* @__PURE__ */ c(
1767
1769
  "div",
1768
1770
  {
1769
1771
  style: {
@@ -1777,7 +1779,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1777
1779
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1778
1780
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1779
1781
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1780
- /* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1782
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1781
1783
  "Redirecting to ",
1782
1784
  r,
1783
1785
  "..."
@@ -1786,7 +1788,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1786
1788
  }
1787
1789
  )
1788
1790
  }
1789
- ), _e = ({
1791
+ ), Ve = ({
1790
1792
  userType: r,
1791
1793
  requiredUserType: e,
1792
1794
  missingPermissions: t
@@ -1803,7 +1805,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1803
1805
  backgroundColor: "#f9fafb",
1804
1806
  textAlign: "center"
1805
1807
  },
1806
- children: /* @__PURE__ */ d(
1808
+ children: /* @__PURE__ */ c(
1807
1809
  "div",
1808
1810
  {
1809
1811
  style: {
@@ -1816,19 +1818,19 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1816
1818
  children: [
1817
1819
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1818
1820
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1819
- e && r ? /* @__PURE__ */ d(_, { children: [
1820
- /* @__PURE__ */ d("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1821
+ e && r ? /* @__PURE__ */ c(_, { children: [
1822
+ /* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1821
1823
  "This page requires ",
1822
1824
  /* @__PURE__ */ s("strong", { children: e }),
1823
1825
  " access."
1824
1826
  ] }),
1825
- /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1827
+ /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1826
1828
  "Your current user type: ",
1827
1829
  /* @__PURE__ */ s("strong", { children: r })
1828
1830
  ] })
1829
- ] }) : /* @__PURE__ */ d(_, { children: [
1831
+ ] }) : /* @__PURE__ */ c(_, { children: [
1830
1832
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1831
- t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1833
+ t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1832
1834
  "Required permissions: ",
1833
1835
  /* @__PURE__ */ s("strong", { children: t.join(", ") })
1834
1836
  ] })
@@ -1837,8 +1839,8 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
1837
1839
  }
1838
1840
  )
1839
1841
  }
1840
- ), Mt = (r, e) => r === e;
1841
- function kn({
1842
+ ), Et = (r, e) => r === e;
1843
+ function An({
1842
1844
  children: r,
1843
1845
  redirectTo: e = "/login",
1844
1846
  requiredUserType: t,
@@ -1846,34 +1848,34 @@ function kn({
1846
1848
  requireAllPermissions: i = !1,
1847
1849
  fallback: o
1848
1850
  }) {
1849
- const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions: u } = le(), b = be();
1850
- if (X(() => {
1851
+ const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions: d } = ce(), m = Se();
1852
+ if (ee(() => {
1851
1853
  process.env.NODE_ENV === "development" && console.warn(
1852
1854
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
1853
1855
  );
1854
1856
  }, []), !a())
1855
- return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
1856
- /* @__PURE__ */ s(It, { redirectPath: e }),
1857
- /* @__PURE__ */ s(me, { to: e, state: { from: b.pathname }, replace: !0 })
1857
+ return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ c(_, { children: [
1858
+ /* @__PURE__ */ s(Lt, { redirectPath: e }),
1859
+ /* @__PURE__ */ s(ye, { to: e, state: { from: m.pathname }, replace: !0 })
1858
1860
  ] });
1859
- const g = p.getUser();
1860
- if (!g)
1861
- return /* @__PURE__ */ s(me, { to: e, state: { from: b.pathname }, replace: !0 });
1862
- if (t && !Mt(g.userType, t))
1861
+ const h = p.getUser();
1862
+ if (!h)
1863
+ return /* @__PURE__ */ s(ye, { to: e, state: { from: m.pathname }, replace: !0 });
1864
+ if (t && !Et(h.userType, t))
1863
1865
  return /* @__PURE__ */ s(
1864
- _e,
1866
+ Ve,
1865
1867
  {
1866
- userType: g.userType,
1868
+ userType: h.userType,
1867
1869
  requiredUserType: t
1868
1870
  }
1869
1871
  );
1870
- if (n && n.length > 0 && !(i ? u(n) : w(n))) {
1871
- const I = n.filter((N) => !f(N)).map((N) => typeof N == "string" ? N : N.name);
1872
- return /* @__PURE__ */ s(_e, { missingPermissions: I });
1872
+ if (n && n.length > 0 && !(i ? d(n) : w(n))) {
1873
+ const I = n.filter((F) => !f(F)).map((F) => typeof F == "string" ? F : F.name);
1874
+ return /* @__PURE__ */ s(Ve, { missingPermissions: I });
1873
1875
  }
1874
1876
  return /* @__PURE__ */ s(_, { children: r });
1875
1877
  }
1876
- const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1878
+ const Ft = ({ redirectPath: r }) => /* @__PURE__ */ s(
1877
1879
  "div",
1878
1880
  {
1879
1881
  style: {
@@ -1886,7 +1888,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1886
1888
  backgroundColor: "#f9fafb",
1887
1889
  textAlign: "center"
1888
1890
  },
1889
- children: /* @__PURE__ */ d(
1891
+ children: /* @__PURE__ */ c(
1890
1892
  "div",
1891
1893
  {
1892
1894
  style: {
@@ -1900,7 +1902,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1900
1902
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1901
1903
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1902
1904
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1903
- /* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1905
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1904
1906
  "Redirecting to ",
1905
1907
  r,
1906
1908
  "..."
@@ -1910,18 +1912,18 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1910
1912
  )
1911
1913
  }
1912
1914
  );
1913
- function xn({ children: r, redirectTo: e = "/", fallback: t }) {
1914
- const { tenant: n, isLoading: i, error: o } = ge(), a = be();
1915
- return X(() => {
1915
+ function Pn({ children: r, redirectTo: e = "/", fallback: t }) {
1916
+ const { tenant: n, isLoading: i, error: o } = ge(), a = Se();
1917
+ return ee(() => {
1916
1918
  process.env.NODE_ENV === "development" && console.warn(
1917
1919
  "[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
1918
1920
  );
1919
- }, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
1920
- /* @__PURE__ */ s(Lt, { redirectPath: e }),
1921
- /* @__PURE__ */ s(me, { to: e, state: { from: a.pathname }, replace: !0 })
1921
+ }, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ c(_, { children: [
1922
+ /* @__PURE__ */ s(Ft, { redirectPath: e }),
1923
+ /* @__PURE__ */ s(ye, { to: e, state: { from: a.pathname }, replace: !0 })
1922
1924
  ] });
1923
1925
  }
1924
- const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
1926
+ const Nt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1925
1927
  "div",
1926
1928
  {
1927
1929
  style: {
@@ -1934,7 +1936,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
1934
1936
  backgroundColor: "#f9fafb",
1935
1937
  textAlign: "center"
1936
1938
  },
1937
- children: /* @__PURE__ */ d(
1939
+ children: /* @__PURE__ */ c(
1938
1940
  "div",
1939
1941
  {
1940
1942
  style: {
@@ -1948,7 +1950,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
1948
1950
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1949
1951
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1950
1952
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1951
- /* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1953
+ /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1952
1954
  "Redirecting to ",
1953
1955
  r,
1954
1956
  "..."
@@ -1958,41 +1960,41 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
1958
1960
  )
1959
1961
  }
1960
1962
  );
1961
- function An({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
1962
- const { tenant: n, isLoading: i, error: o } = ge(), a = be();
1963
- return X(() => {
1963
+ function Rn({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
1964
+ const { tenant: n, isLoading: i, error: o } = ge(), a = Se();
1965
+ return ee(() => {
1964
1966
  process.env.NODE_ENV === "development" && console.warn(
1965
1967
  "[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
1966
1968
  );
1967
- }, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
1968
- /* @__PURE__ */ s(Et, { redirectPath: e }),
1969
- /* @__PURE__ */ s(me, { to: e, state: { from: a.pathname }, replace: !0 })
1969
+ }, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ c(_, { children: [
1970
+ /* @__PURE__ */ s(Nt, { redirectPath: e }),
1971
+ /* @__PURE__ */ s(ye, { to: e, state: { from: a.pathname }, replace: !0 })
1970
1972
  ] }) : /* @__PURE__ */ s(_, { children: r });
1971
1973
  }
1972
- function Ft(r, e) {
1974
+ function Dt(r, e) {
1973
1975
  return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
1974
1976
  }
1975
- function We(r, e) {
1977
+ function je(r, e) {
1976
1978
  return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
1977
1979
  }
1978
- function Nt(r, e) {
1979
- return We(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : We(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Ft(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
1980
+ function Ct(r, e) {
1981
+ return je(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : je(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Dt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
1980
1982
  }
1981
- function Dt(r, e) {
1982
- return r.hasTenant ? r.isAuthenticated ? r.userType === se.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === se.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
1983
+ function Ut(r, e) {
1984
+ return r.hasTenant ? r.isAuthenticated ? r.userType === ie.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === ie.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
1983
1985
  }
1984
- function Ct(r, e, t, n, i) {
1986
+ function $t(r, e, t, n, i) {
1985
1987
  if (!e || i !== "url")
1986
1988
  return r;
1987
1989
  const o = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
1988
1990
  return `${r}${a}${n}=${encodeURIComponent(o)}`;
1989
1991
  }
1990
- function Ut(r, e, t) {
1992
+ function Ht(r, e, t) {
1991
1993
  if (!r || t === "url") return;
1992
1994
  const n = typeof r == "string" ? r : e, i = "zone_return_to";
1993
1995
  t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
1994
1996
  }
1995
- const ae = ({
1997
+ const le = ({
1996
1998
  children: r,
1997
1999
  preset: e,
1998
2000
  tenant: t,
@@ -2003,39 +2005,39 @@ const ae = ({
2003
2005
  returnTo: p,
2004
2006
  onAccessDenied: f,
2005
2007
  redirectTo: w,
2006
- loadingFallback: u,
2007
- accessDeniedFallback: b
2008
+ loadingFallback: d,
2009
+ accessDeniedFallback: m
2008
2010
  }) => {
2009
- const g = be(), { isAuthenticated: T, isAuthInitializing: I, currentUser: N, userPermissions: M } = le(), { tenant: P, isTenantLoading: h } = he(), A = Pt(), S = Z(() => {
2011
+ const h = Se(), { isAuthenticated: v, isAuthInitializing: I, currentUser: F, userPermissions: M } = ce(), { tenant: P, isTenantLoading: u } = he(), A = It(), b = J(() => {
2010
2012
  if (e)
2011
2013
  return A.presets[e];
2012
- }, [e, A.presets]), L = Z(
2014
+ }, [e, A.presets]), L = J(
2013
2015
  () => ({
2014
- tenant: t ?? (S == null ? void 0 : S.tenant),
2015
- auth: n ?? (S == null ? void 0 : S.auth),
2016
- userType: i ?? (S == null ? void 0 : S.userType),
2017
- permissions: o ?? (S == null ? void 0 : S.requiredPermissions),
2016
+ tenant: t ?? (b == null ? void 0 : b.tenant),
2017
+ auth: n ?? (b == null ? void 0 : b.auth),
2018
+ userType: i ?? (b == null ? void 0 : b.userType),
2019
+ permissions: o ?? (b == null ? void 0 : b.requiredPermissions),
2018
2020
  requireAllPermissions: a
2019
2021
  }),
2020
- [t, n, i, o, S, a]
2021
- ), E = Z(
2022
+ [t, n, i, o, b, a]
2023
+ ), E = J(
2022
2024
  () => ({
2023
2025
  hasTenant: !!P,
2024
- isAuthenticated: T,
2025
- userType: N == null ? void 0 : N.userType,
2026
+ isAuthenticated: v,
2027
+ userType: F == null ? void 0 : F.userType,
2026
2028
  permissions: M,
2027
- isLoading: I || h
2029
+ isLoading: I || u
2028
2030
  }),
2029
2031
  [
2030
2032
  P,
2031
- T,
2032
- N == null ? void 0 : N.userType,
2033
+ v,
2034
+ F == null ? void 0 : F.userType,
2033
2035
  M,
2034
2036
  I,
2035
- h
2037
+ u
2036
2038
  ]
2037
- ), C = Z(() => E.isLoading ? null : Nt(L, E), [L, E]), R = Z(() => C ? w || Dt(E, A.zoneRoots) : null, [C, w, E, A.zoneRoots]), $ = Z(() => !C || !R ? null : {
2038
- type: C,
2039
+ ), N = J(() => E.isLoading ? null : Ct(L, E), [L, E]), R = J(() => N ? w || Ut(E, A.zoneRoots) : null, [N, w, E, A.zoneRoots]), U = J(() => !N || !R ? null : {
2040
+ type: N,
2039
2041
  required: {
2040
2042
  tenant: L.tenant,
2041
2043
  auth: L.auth,
@@ -2049,34 +2051,34 @@ const ae = ({
2049
2051
  permissions: E.permissions
2050
2052
  },
2051
2053
  redirectTo: R
2052
- }, [C, R, L, E]);
2053
- if (X(() => {
2054
- $ && (f ? f($) : A.onAccessDenied && A.onAccessDenied($));
2055
- }, [$, f, A]), X(() => {
2056
- $ && p && Ut(p, g.pathname + g.search, A.returnToStorage);
2054
+ }, [N, R, L, E]);
2055
+ if (ee(() => {
2056
+ U && (f ? f(U) : A.onAccessDenied && A.onAccessDenied(U));
2057
+ }, [U, f, A]), ee(() => {
2058
+ U && p && Ht(p, h.pathname + h.search, A.returnToStorage);
2057
2059
  }, [
2058
- $,
2060
+ U,
2059
2061
  p,
2060
- g.pathname,
2061
- g.search,
2062
+ h.pathname,
2063
+ h.search,
2062
2064
  A.returnToStorage
2063
2065
  ]), E.isLoading)
2064
- return /* @__PURE__ */ s(_, { children: u ?? A.loadingFallback ?? null });
2065
- if ($ && R) {
2066
- const l = b ?? A.accessDeniedFallback;
2066
+ return /* @__PURE__ */ s(_, { children: d ?? A.loadingFallback ?? null });
2067
+ if (U && R) {
2068
+ const l = m ?? A.accessDeniedFallback;
2067
2069
  if (l)
2068
2070
  return /* @__PURE__ */ s(_, { children: l });
2069
- const D = Ct(
2071
+ const D = $t(
2070
2072
  R,
2071
2073
  p,
2072
- g.pathname + g.search,
2074
+ h.pathname + h.search,
2073
2075
  A.returnToParam,
2074
2076
  A.returnToStorage
2075
2077
  );
2076
- return /* @__PURE__ */ s(me, { to: D, replace: !0 });
2078
+ return /* @__PURE__ */ s(ye, { to: D, replace: !0 });
2077
2079
  }
2078
2080
  return /* @__PURE__ */ s(_, { children: r });
2079
- }, Pn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", ...r }), Rn = (r) => /* @__PURE__ */ s(ae, { tenant: "forbidden", ...r }), In = (r) => /* @__PURE__ */ s(ae, { auth: "required", ...r }), Mn = (r) => /* @__PURE__ */ s(ae, { auth: "forbidden", ...r }), Ln = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.TENANT_ADMIN, ...r }), En = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.USER, ...r }), Fn = (r) => /* @__PURE__ */ s(ae, { tenant: "optional", auth: "optional", ...r }), Nn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "required", ...r }), Dn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "optional", ...r }), Cn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "forbidden", ...r }), $t = () => /* @__PURE__ */ d(
2081
+ }, In = (r) => /* @__PURE__ */ s(le, { tenant: "required", ...r }), Mn = (r) => /* @__PURE__ */ s(le, { tenant: "forbidden", ...r }), Ln = (r) => /* @__PURE__ */ s(le, { auth: "required", ...r }), En = (r) => /* @__PURE__ */ s(le, { auth: "forbidden", ...r }), Fn = (r) => /* @__PURE__ */ s(le, { auth: "required", userType: ie.TENANT_ADMIN, ...r }), Nn = (r) => /* @__PURE__ */ s(le, { auth: "required", userType: ie.USER, ...r }), Dn = (r) => /* @__PURE__ */ s(le, { tenant: "optional", auth: "optional", ...r }), Cn = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "required", ...r }), Un = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "optional", ...r }), $n = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "forbidden", ...r }), Bt = () => /* @__PURE__ */ c(
2080
2082
  "div",
2081
2083
  {
2082
2084
  style: {
@@ -2093,13 +2095,13 @@ const ae = ({
2093
2095
  ]
2094
2096
  }
2095
2097
  );
2096
- function Un({
2098
+ function Hn({
2097
2099
  children: r,
2098
- fallback: e = /* @__PURE__ */ s($t, {}),
2100
+ fallback: e = /* @__PURE__ */ s(Bt, {}),
2099
2101
  allowedPlans: t,
2100
2102
  requiredFeature: n
2101
2103
  }) {
2102
- const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = At();
2104
+ const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = Rt();
2103
2105
  return p ? /* @__PURE__ */ s(
2104
2106
  "div",
2105
2107
  {
@@ -2112,7 +2114,7 @@ function Un({
2112
2114
  }
2113
2115
  ) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : n && !a(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: r }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
2114
2116
  }
2115
- const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
2117
+ const qt = ({ flagName: r }) => /* @__PURE__ */ c(
2116
2118
  "div",
2117
2119
  {
2118
2120
  style: {
@@ -2131,7 +2133,7 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
2131
2133
  children: [
2132
2134
  /* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
2133
2135
  /* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
2134
- /* @__PURE__ */ d("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2136
+ /* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
2135
2137
  'Feature flag "',
2136
2138
  r,
2137
2139
  '" is disabled'
@@ -2139,8 +2141,8 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
2139
2141
  ]
2140
2142
  }
2141
2143
  );
2142
- function $n({ name: r, children: e, fallback: t }) {
2143
- const { isEnabled: n, loading: i } = kt();
2144
+ function Bn({ name: r, children: e, fallback: t }) {
2145
+ const { isEnabled: n, loading: i } = At();
2144
2146
  return i ? /* @__PURE__ */ s(
2145
2147
  "div",
2146
2148
  {
@@ -2154,9 +2156,9 @@ function $n({ name: r, children: e, fallback: t }) {
2154
2156
  },
2155
2157
  children: "Loading feature flags..."
2156
2158
  }
2157
- ) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Ht, { flagName: r }) });
2159
+ ) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(qt, { flagName: r }) });
2158
2160
  }
2159
- const Bt = () => /* @__PURE__ */ d(
2161
+ const Ot = () => /* @__PURE__ */ c(
2160
2162
  "svg",
2161
2163
  {
2162
2164
  width: "16",
@@ -2173,7 +2175,7 @@ const Bt = () => /* @__PURE__ */ d(
2173
2175
  /* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
2174
2176
  ]
2175
2177
  }
2176
- ), qt = () => /* @__PURE__ */ d(
2178
+ ), zt = () => /* @__PURE__ */ c(
2177
2179
  "svg",
2178
2180
  {
2179
2181
  width: "16",
@@ -2190,10 +2192,10 @@ const Bt = () => /* @__PURE__ */ d(
2190
2192
  /* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
2191
2193
  ]
2192
2194
  }
2193
- ), Ot = {
2194
- showPassword: /* @__PURE__ */ s(Bt, {}),
2195
- hidePassword: /* @__PURE__ */ s(qt, {})
2196
- }, zt = {
2195
+ ), _t = {
2196
+ showPassword: /* @__PURE__ */ s(Ot, {}),
2197
+ hidePassword: /* @__PURE__ */ s(zt, {})
2198
+ }, Wt = {
2197
2199
  title: "Sign In",
2198
2200
  usernameLabel: "Email or Phone",
2199
2201
  usernamePlaceholder: "Enter your email or phone number",
@@ -2207,7 +2209,7 @@ const Bt = () => /* @__PURE__ */ d(
2207
2209
  magicLinkLink: "Use Magic Link",
2208
2210
  errorMessage: "Invalid credentials",
2209
2211
  loadingText: "Signing in..."
2210
- }, _t = {
2212
+ }, Vt = {
2211
2213
  container: {
2212
2214
  maxWidth: "400px",
2213
2215
  width: "100%",
@@ -2314,7 +2316,7 @@ const Bt = () => /* @__PURE__ */ d(
2314
2316
  fontSize: "0.875rem"
2315
2317
  }
2316
2318
  };
2317
- function Hn({
2319
+ function qn({
2318
2320
  copy: r = {},
2319
2321
  styles: e = {},
2320
2322
  icons: t = {},
@@ -2325,45 +2327,45 @@ function Hn({
2325
2327
  onMagicLinkClick: p,
2326
2328
  showForgotPassword: f = !0,
2327
2329
  showSignupLink: w = !0,
2328
- showMagicLinkOption: u = !0,
2329
- className: b
2330
+ showMagicLinkOption: d = !0,
2331
+ className: m
2330
2332
  }) {
2331
- const [g, T] = x(""), [I, N] = x(""), [M, P] = x(!1), [h, A] = x(!1), [S, L] = x(""), [E, C] = x({}), { login: R } = le(), { tenant: $ } = ge(), l = { ...zt, ...r }, D = { ..._t, ...e }, U = { ...Ot, ...t }, c = () => {
2332
- const m = {};
2333
- return g.trim() || (m.username = !0), I.trim() || (m.password = !0), C(m), Object.keys(m).length === 0;
2334
- }, H = async (m) => {
2335
- if (m.preventDefault(), !!c()) {
2336
- if (!($ != null && $.id)) {
2333
+ const [h, v] = x(""), [I, F] = x(""), [M, P] = x(!1), [u, A] = x(!1), [b, L] = x(""), [E, N] = x({}), { login: R } = ce(), { tenant: U } = ge(), l = { ...Wt, ...r }, D = { ...Vt, ...e }, $ = { ..._t, ...t }, g = () => {
2334
+ const y = {};
2335
+ return h.trim() || (y.username = !0), I.trim() || (y.password = !0), N(y), Object.keys(y).length === 0;
2336
+ }, C = async (y) => {
2337
+ if (y.preventDefault(), !!g()) {
2338
+ if (!(U != null && U.id)) {
2337
2339
  L("Tenant not found");
2338
2340
  return;
2339
2341
  }
2340
2342
  A(!0), L("");
2341
2343
  try {
2342
- const v = await R({
2343
- username: g,
2344
+ const k = await R({
2345
+ username: h,
2344
2346
  password: I
2345
2347
  // tenantId inferred from context automatically
2346
2348
  });
2347
- n == null || n(v);
2348
- } catch (v) {
2349
- const G = v.message || l.errorMessage;
2350
- L(G), i == null || i(G);
2349
+ n == null || n(k);
2350
+ } catch (k) {
2351
+ const j = k.message || l.errorMessage;
2352
+ L(j), i == null || i(j);
2351
2353
  } finally {
2352
2354
  A(!1);
2353
2355
  }
2354
2356
  }
2355
- }, F = (m) => ({
2357
+ }, T = (y) => ({
2356
2358
  ...D.input,
2357
- ...E[m] ? D.inputError : {}
2358
- }), y = () => ({
2359
+ ...E[y] ? D.inputError : {}
2360
+ }), S = () => ({
2359
2361
  ...D.button,
2360
- ...h ? D.buttonLoading : {},
2361
- ...!g || !I || h ? D.buttonDisabled : {}
2362
+ ...u ? D.buttonLoading : {},
2363
+ ...!h || !I || u ? D.buttonDisabled : {}
2362
2364
  });
2363
- return /* @__PURE__ */ d("div", { className: b, style: D.container, children: [
2365
+ return /* @__PURE__ */ c("div", { className: m, style: D.container, children: [
2364
2366
  /* @__PURE__ */ s("h2", { style: D.title, children: l.title }),
2365
- /* @__PURE__ */ d("form", { onSubmit: H, style: D.form, children: [
2366
- /* @__PURE__ */ d("div", { style: D.fieldGroup, children: [
2367
+ /* @__PURE__ */ c("form", { onSubmit: C, style: D.form, children: [
2368
+ /* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
2367
2369
  /* @__PURE__ */ s("label", { style: D.label, children: l.usernameLabel }),
2368
2370
  /* @__PURE__ */ s(
2369
2371
  "input",
@@ -2371,19 +2373,19 @@ function Hn({
2371
2373
  id: "username",
2372
2374
  name: "username",
2373
2375
  type: "text",
2374
- value: g,
2375
- onChange: (m) => {
2376
- T(m.target.value), E.username && C((v) => ({ ...v, username: !1 }));
2376
+ value: h,
2377
+ onChange: (y) => {
2378
+ v(y.target.value), E.username && N((k) => ({ ...k, username: !1 }));
2377
2379
  },
2378
2380
  placeholder: l.usernamePlaceholder,
2379
- style: F("username"),
2380
- disabled: h
2381
+ style: T("username"),
2382
+ disabled: u
2381
2383
  }
2382
2384
  )
2383
2385
  ] }),
2384
- /* @__PURE__ */ d("div", { style: D.fieldGroup, children: [
2386
+ /* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
2385
2387
  /* @__PURE__ */ s("label", { style: D.label, children: l.passwordLabel }),
2386
- /* @__PURE__ */ d("div", { style: D.inputContainer, children: [
2388
+ /* @__PURE__ */ c("div", { style: D.inputContainer, children: [
2387
2389
  /* @__PURE__ */ s(
2388
2390
  "input",
2389
2391
  {
@@ -2391,16 +2393,16 @@ function Hn({
2391
2393
  name: "password",
2392
2394
  type: M ? "text" : "password",
2393
2395
  value: I,
2394
- onChange: (m) => {
2395
- N(m.target.value), E.password && C((v) => ({ ...v, password: !1 }));
2396
+ onChange: (y) => {
2397
+ F(y.target.value), E.password && N((k) => ({ ...k, password: !1 }));
2396
2398
  },
2397
2399
  placeholder: l.passwordPlaceholder,
2398
2400
  style: {
2399
- ...F("password"),
2401
+ ...T("password"),
2400
2402
  paddingRight: "2.5rem"
2401
2403
  // Make room for the icon
2402
2404
  },
2403
- disabled: h
2405
+ disabled: u
2404
2406
  }
2405
2407
  ),
2406
2408
  /* @__PURE__ */ s(
@@ -2409,29 +2411,29 @@ function Hn({
2409
2411
  type: "button",
2410
2412
  onClick: () => P(!M),
2411
2413
  style: D.passwordToggle,
2412
- disabled: h,
2414
+ disabled: u,
2413
2415
  "aria-label": M ? "Hide password" : "Show password",
2414
- children: M ? U.hidePassword : U.showPassword
2416
+ children: M ? $.hidePassword : $.showPassword
2415
2417
  }
2416
2418
  )
2417
2419
  ] })
2418
2420
  ] }),
2419
- /* @__PURE__ */ s("button", { type: "submit", disabled: !g || !I || h, style: y(), children: h ? l.loadingText : l.submitButton }),
2420
- S && /* @__PURE__ */ s("div", { style: D.errorText, children: S })
2421
+ /* @__PURE__ */ s("button", { type: "submit", disabled: !h || !I || u, style: S(), children: u ? l.loadingText : l.submitButton }),
2422
+ b && /* @__PURE__ */ s("div", { style: D.errorText, children: b })
2421
2423
  ] }),
2422
- (f || w || u) && /* @__PURE__ */ d("div", { style: D.linkContainer, children: [
2423
- u && /* @__PURE__ */ d("div", { children: [
2424
- /* @__PURE__ */ d("span", { style: D.divider, children: [
2424
+ (f || w || d) && /* @__PURE__ */ c("div", { style: D.linkContainer, children: [
2425
+ d && /* @__PURE__ */ c("div", { children: [
2426
+ /* @__PURE__ */ c("span", { style: D.divider, children: [
2425
2427
  l.magicLinkText,
2426
2428
  " "
2427
2429
  ] }),
2428
2430
  /* @__PURE__ */ s("a", { onClick: p, style: D.link, children: l.magicLinkLink })
2429
2431
  ] }),
2430
- u && (f || w) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
2432
+ d && (f || w) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
2431
2433
  f && /* @__PURE__ */ s("a", { onClick: o, style: D.link, children: l.forgotPasswordLink }),
2432
2434
  f && w && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
2433
- w && /* @__PURE__ */ d("div", { children: [
2434
- /* @__PURE__ */ d("span", { style: D.divider, children: [
2435
+ w && /* @__PURE__ */ c("div", { children: [
2436
+ /* @__PURE__ */ c("span", { style: D.divider, children: [
2435
2437
  l.signupText,
2436
2438
  " "
2437
2439
  ] }),
@@ -2440,7 +2442,7 @@ function Hn({
2440
2442
  ] })
2441
2443
  ] });
2442
2444
  }
2443
- const Wt = {
2445
+ const jt = {
2444
2446
  title: "Create Account",
2445
2447
  nameLabel: "First Name",
2446
2448
  namePlaceholder: "Enter your first name",
@@ -2466,7 +2468,7 @@ const Wt = {
2466
2468
  passwordMismatchError: "Passwords do not match",
2467
2469
  isAdminLabel: "Create new organization",
2468
2470
  isAdminDescription: "Check this if you want to create a new organization"
2469
- }, Vt = {
2471
+ }, Gt = {
2470
2472
  container: {
2471
2473
  maxWidth: "400px",
2472
2474
  width: "100%",
@@ -2565,7 +2567,7 @@ const Wt = {
2565
2567
  fontSize: "0.875rem"
2566
2568
  }
2567
2569
  };
2568
- function Bn({
2570
+ function On({
2569
2571
  copy: r = {},
2570
2572
  styles: e = {},
2571
2573
  signupType: t = "user",
@@ -2577,91 +2579,91 @@ function Bn({
2577
2579
  showMagicLinkOption: f = !0,
2578
2580
  className: w
2579
2581
  }) {
2580
- const [u, b] = x(""), [g, T] = x(""), [I, N] = x(""), [M, P] = x(""), [h, A] = x(""), [S, L] = x(""), [E, C] = x(""), [R, $] = x(!1), [l, D] = x(""), [U, c] = x({}), { signup: H, signupTenantAdmin: F } = le(), { tenant: y } = ge(), m = { ...Wt, ...r }, v = { ...Vt, ...e }, G = () => {
2581
- const k = {};
2582
- return u.trim() || (k.name = !0), !I.trim() && !M.trim() && (k.email = !0, k.phoneNumber = !0), h.trim() || (k.password = !0), S.trim() || (k.confirmPassword = !0), t === "tenant" && !E.trim() && (k.tenantName = !0), c(k), Object.keys(k).length === 0;
2583
- }, Y = async (k) => {
2584
- if (k.preventDefault(), !!G()) {
2585
- if (h !== S) {
2586
- D(m.passwordMismatchError), c({ confirmPassword: !0 });
2582
+ const [d, m] = x(""), [h, v] = x(""), [I, F] = x(""), [M, P] = x(""), [u, A] = x(""), [b, L] = x(""), [E, N] = x(""), [R, U] = x(!1), [l, D] = x(""), [$, g] = x({}), { signup: C, signupTenantAdmin: T } = ce(), { tenant: S } = ge(), y = { ...jt, ...r }, k = { ...Gt, ...e }, j = () => {
2583
+ const B = {};
2584
+ return d.trim() || (B.name = !0), !I.trim() && !M.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), b.trim() || (B.confirmPassword = !0), t === "tenant" && !E.trim() && (B.tenantName = !0), g(B), Object.keys(B).length === 0;
2585
+ }, Z = async (B) => {
2586
+ if (B.preventDefault(), !!j()) {
2587
+ if (u !== b) {
2588
+ D(y.passwordMismatchError), g({ confirmPassword: !0 });
2587
2589
  return;
2588
2590
  }
2589
- if (t === "user" && !(y != null && y.id)) {
2591
+ if (t === "user" && !(S != null && S.id)) {
2590
2592
  D("Tenant not found");
2591
2593
  return;
2592
2594
  }
2593
- $(!0), D("");
2595
+ U(!0), D("");
2594
2596
  try {
2595
- let K;
2596
- t === "tenant" ? K = await F({
2597
+ let X;
2598
+ t === "tenant" ? X = await T({
2597
2599
  email: I || void 0,
2598
2600
  phoneNumber: M || void 0,
2599
- name: u,
2600
- password: h,
2601
+ name: d,
2602
+ password: u,
2601
2603
  tenantName: E,
2602
- lastName: g || void 0
2603
- }) : K = await H({
2604
+ lastName: h || void 0
2605
+ }) : X = await C({
2604
2606
  email: I || void 0,
2605
2607
  phoneNumber: M || void 0,
2606
- name: u,
2607
- password: h,
2608
- tenantId: y.id,
2609
- lastName: g || void 0
2610
- }), n == null || n(K);
2611
- } catch (K) {
2612
- const ce = K.message || m.errorMessage;
2613
- D(ce), i == null || i(ce);
2608
+ name: d,
2609
+ password: u,
2610
+ tenantId: S.id,
2611
+ lastName: h || void 0
2612
+ }), n == null || n(X);
2613
+ } catch (X) {
2614
+ const G = X.message || y.errorMessage;
2615
+ D(G), i == null || i(G);
2614
2616
  } finally {
2615
- $(!1);
2617
+ U(!1);
2616
2618
  }
2617
2619
  }
2618
- }, q = (k) => ({
2619
- ...v.input,
2620
- ...U[k] ? v.inputError : {}
2621
- }), O = () => ({
2622
- ...v.button,
2623
- ...R ? v.buttonLoading : {},
2624
- ...!u || !I && !M || !h || !S || R || t === "tenant" && !E ? v.buttonDisabled : {}
2625
- }), V = u && (I || M) && h && S && (t === "user" || E);
2626
- return /* @__PURE__ */ d("div", { className: w, style: v.container, children: [
2627
- /* @__PURE__ */ s("h2", { style: v.title, children: m.title }),
2628
- /* @__PURE__ */ d("form", { onSubmit: Y, style: v.form, children: [
2629
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2630
- /* @__PURE__ */ s("label", { style: v.label, children: m.nameLabel }),
2620
+ }, O = (B) => ({
2621
+ ...k.input,
2622
+ ...$[B] ? k.inputError : {}
2623
+ }), q = () => ({
2624
+ ...k.button,
2625
+ ...R ? k.buttonLoading : {},
2626
+ ...!d || !I && !M || !u || !b || R || t === "tenant" && !E ? k.buttonDisabled : {}
2627
+ }), W = d && (I || M) && u && b && (t === "user" || E);
2628
+ return /* @__PURE__ */ c("div", { className: w, style: k.container, children: [
2629
+ /* @__PURE__ */ s("h2", { style: k.title, children: y.title }),
2630
+ /* @__PURE__ */ c("form", { onSubmit: Z, style: k.form, children: [
2631
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2632
+ /* @__PURE__ */ s("label", { style: k.label, children: y.nameLabel }),
2631
2633
  /* @__PURE__ */ s(
2632
2634
  "input",
2633
2635
  {
2634
2636
  id: "name",
2635
2637
  name: "name",
2636
2638
  type: "text",
2637
- value: u,
2638
- onChange: (k) => {
2639
- b(k.target.value), U.name && c((K) => ({ ...K, name: !1 }));
2639
+ value: d,
2640
+ onChange: (B) => {
2641
+ m(B.target.value), $.name && g((X) => ({ ...X, name: !1 }));
2640
2642
  },
2641
- placeholder: m.namePlaceholder,
2642
- style: q("name"),
2643
+ placeholder: y.namePlaceholder,
2644
+ style: O("name"),
2643
2645
  disabled: R
2644
2646
  }
2645
2647
  )
2646
2648
  ] }),
2647
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2648
- /* @__PURE__ */ s("label", { style: v.label, children: m.lastNameLabel }),
2649
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2650
+ /* @__PURE__ */ s("label", { style: k.label, children: y.lastNameLabel }),
2649
2651
  /* @__PURE__ */ s(
2650
2652
  "input",
2651
2653
  {
2652
2654
  id: "lastName",
2653
2655
  name: "lastName",
2654
2656
  type: "text",
2655
- value: g,
2656
- onChange: (k) => T(k.target.value),
2657
- placeholder: m.lastNamePlaceholder,
2658
- style: v.input,
2657
+ value: h,
2658
+ onChange: (B) => v(B.target.value),
2659
+ placeholder: y.lastNamePlaceholder,
2660
+ style: k.input,
2659
2661
  disabled: R
2660
2662
  }
2661
2663
  )
2662
2664
  ] }),
2663
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2664
- /* @__PURE__ */ s("label", { style: v.label, children: m.emailLabel }),
2665
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2666
+ /* @__PURE__ */ s("label", { style: k.label, children: y.emailLabel }),
2665
2667
  /* @__PURE__ */ s(
2666
2668
  "input",
2667
2669
  {
@@ -2669,17 +2671,17 @@ function Bn({
2669
2671
  name: "email",
2670
2672
  type: "email",
2671
2673
  value: I,
2672
- onChange: (k) => {
2673
- N(k.target.value), U.email && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2674
+ onChange: (B) => {
2675
+ F(B.target.value), $.email && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2674
2676
  },
2675
- placeholder: m.emailPlaceholder,
2676
- style: q("email"),
2677
+ placeholder: y.emailPlaceholder,
2678
+ style: O("email"),
2677
2679
  disabled: R
2678
2680
  }
2679
2681
  )
2680
2682
  ] }),
2681
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2682
- /* @__PURE__ */ s("label", { style: v.label, children: m.phoneNumberLabel }),
2683
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2684
+ /* @__PURE__ */ s("label", { style: k.label, children: y.phoneNumberLabel }),
2683
2685
  /* @__PURE__ */ s(
2684
2686
  "input",
2685
2687
  {
@@ -2687,11 +2689,11 @@ function Bn({
2687
2689
  name: "phoneNumber",
2688
2690
  type: "tel",
2689
2691
  value: M,
2690
- onChange: (k) => {
2691
- P(k.target.value), U.phoneNumber && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2692
+ onChange: (B) => {
2693
+ P(B.target.value), $.phoneNumber && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2692
2694
  },
2693
- placeholder: m.phoneNumberPlaceholder,
2694
- style: q("phoneNumber"),
2695
+ placeholder: y.phoneNumberPlaceholder,
2696
+ style: O("phoneNumber"),
2695
2697
  disabled: R
2696
2698
  }
2697
2699
  )
@@ -2708,44 +2710,44 @@ function Bn({
2708
2710
  children: "At least one contact method (email or phone) is required"
2709
2711
  }
2710
2712
  ),
2711
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2712
- /* @__PURE__ */ s("label", { style: v.label, children: m.passwordLabel }),
2713
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2714
+ /* @__PURE__ */ s("label", { style: k.label, children: y.passwordLabel }),
2713
2715
  /* @__PURE__ */ s(
2714
2716
  "input",
2715
2717
  {
2716
2718
  id: "password",
2717
2719
  name: "password",
2718
2720
  type: "password",
2719
- value: h,
2720
- onChange: (k) => {
2721
- A(k.target.value), U.password && c((K) => ({ ...K, password: !1 }));
2721
+ value: u,
2722
+ onChange: (B) => {
2723
+ A(B.target.value), $.password && g((X) => ({ ...X, password: !1 }));
2722
2724
  },
2723
- placeholder: m.passwordPlaceholder,
2724
- style: q("password"),
2725
+ placeholder: y.passwordPlaceholder,
2726
+ style: O("password"),
2725
2727
  disabled: R
2726
2728
  }
2727
2729
  )
2728
2730
  ] }),
2729
- /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2730
- /* @__PURE__ */ s("label", { style: v.label, children: m.confirmPasswordLabel }),
2731
+ /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2732
+ /* @__PURE__ */ s("label", { style: k.label, children: y.confirmPasswordLabel }),
2731
2733
  /* @__PURE__ */ s(
2732
2734
  "input",
2733
2735
  {
2734
2736
  id: "confirmPassword",
2735
2737
  name: "confirmPassword",
2736
2738
  type: "password",
2737
- value: S,
2738
- onChange: (k) => {
2739
- L(k.target.value), U.confirmPassword && c((K) => ({ ...K, confirmPassword: !1 })), l === m.passwordMismatchError && D("");
2739
+ value: b,
2740
+ onChange: (B) => {
2741
+ L(B.target.value), $.confirmPassword && g((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && D("");
2740
2742
  },
2741
- placeholder: m.confirmPasswordPlaceholder,
2742
- style: q("confirmPassword"),
2743
+ placeholder: y.confirmPasswordPlaceholder,
2744
+ style: O("confirmPassword"),
2743
2745
  disabled: R
2744
2746
  }
2745
2747
  )
2746
2748
  ] }),
2747
- t === "tenant" && /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
2748
- /* @__PURE__ */ s("label", { style: v.label, children: m.tenantNameLabel }),
2749
+ t === "tenant" && /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
2750
+ /* @__PURE__ */ s("label", { style: k.label, children: y.tenantNameLabel }),
2749
2751
  /* @__PURE__ */ s(
2750
2752
  "input",
2751
2753
  {
@@ -2753,38 +2755,38 @@ function Bn({
2753
2755
  name: "tenantName",
2754
2756
  type: "text",
2755
2757
  value: E,
2756
- onChange: (k) => {
2757
- C(k.target.value), U.tenantName && c((K) => ({ ...K, tenantName: !1 }));
2758
+ onChange: (B) => {
2759
+ N(B.target.value), $.tenantName && g((X) => ({ ...X, tenantName: !1 }));
2758
2760
  },
2759
- placeholder: m.tenantNamePlaceholder,
2760
- style: q("tenantName"),
2761
+ placeholder: y.tenantNamePlaceholder,
2762
+ style: O("tenantName"),
2761
2763
  disabled: R
2762
2764
  }
2763
2765
  )
2764
2766
  ] }),
2765
- /* @__PURE__ */ s("button", { type: "submit", disabled: !V || R, style: O(), children: R ? m.loadingText : m.submitButton }),
2766
- l && /* @__PURE__ */ s("div", { style: v.errorText, children: l })
2767
+ /* @__PURE__ */ s("button", { type: "submit", disabled: !W || R, style: q(), children: R ? y.loadingText : y.submitButton }),
2768
+ l && /* @__PURE__ */ s("div", { style: k.errorText, children: l })
2767
2769
  ] }),
2768
- (p || f) && /* @__PURE__ */ d("div", { style: v.linkContainer, children: [
2769
- f && /* @__PURE__ */ d("div", { children: [
2770
- /* @__PURE__ */ d("span", { style: v.divider, children: [
2771
- m.magicLinkText,
2770
+ (p || f) && /* @__PURE__ */ c("div", { style: k.linkContainer, children: [
2771
+ f && /* @__PURE__ */ c("div", { children: [
2772
+ /* @__PURE__ */ c("span", { style: k.divider, children: [
2773
+ y.magicLinkText,
2772
2774
  " "
2773
2775
  ] }),
2774
- /* @__PURE__ */ s("a", { onClick: a, style: v.link, children: m.magicLinkLink })
2776
+ /* @__PURE__ */ s("a", { onClick: a, style: k.link, children: y.magicLinkLink })
2775
2777
  ] }),
2776
- f && p && /* @__PURE__ */ s("div", { style: v.divider, children: "•" }),
2777
- p && /* @__PURE__ */ d("div", { children: [
2778
- /* @__PURE__ */ d("span", { style: v.divider, children: [
2779
- m.loginText,
2778
+ f && p && /* @__PURE__ */ s("div", { style: k.divider, children: "•" }),
2779
+ p && /* @__PURE__ */ c("div", { children: [
2780
+ /* @__PURE__ */ c("span", { style: k.divider, children: [
2781
+ y.loginText,
2780
2782
  " "
2781
2783
  ] }),
2782
- /* @__PURE__ */ s("a", { onClick: o, style: v.link, children: m.loginLink })
2784
+ /* @__PURE__ */ s("a", { onClick: o, style: k.link, children: y.loginLink })
2783
2785
  ] })
2784
2786
  ] })
2785
2787
  ] });
2786
2788
  }
2787
- const jt = {
2789
+ const Zt = {
2788
2790
  title: "Sign In with Magic Link",
2789
2791
  emailLabel: "Email",
2790
2792
  emailPlaceholder: "Enter your email",
@@ -2802,7 +2804,7 @@ const jt = {
2802
2804
  loadingText: "Sending magic link...",
2803
2805
  verifyingText: "Verifying magic link...",
2804
2806
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2805
- }, Gt = {
2807
+ }, Kt = {
2806
2808
  container: {
2807
2809
  maxWidth: "400px",
2808
2810
  width: "100%",
@@ -2905,7 +2907,7 @@ const jt = {
2905
2907
  fontSize: "0.875rem"
2906
2908
  }
2907
2909
  };
2908
- function qn({
2910
+ function zn({
2909
2911
  copy: r = {},
2910
2912
  styles: e = {},
2911
2913
  onSuccess: t,
@@ -2917,85 +2919,85 @@ function qn({
2917
2919
  verifyToken: f,
2918
2920
  frontendUrl: w
2919
2921
  }) {
2920
- const [u, b] = x(""), [g, T] = x(""), [I, N] = x(""), [M, P] = x(!1), [h, A] = x(!1), [S, L] = x(""), [E, C] = x(""), [R, $] = x({}), [l, D] = x(!1), { sendMagicLink: U, verifyMagicLink: c } = le(), { tenant: H } = ge(), F = { ...jt, ...r }, y = { ...Gt, ...e };
2921
- X(() => {
2922
- f && m(f);
2922
+ const [d, m] = x(""), [h, v] = x(""), [I, F] = x(""), [M, P] = x(!1), [u, A] = x(!1), [b, L] = x(""), [E, N] = x(""), [R, U] = x({}), [l, D] = x(!1), { sendMagicLink: $, verifyMagicLink: g } = ce(), { tenant: C } = ge(), T = { ...Zt, ...r }, S = { ...Kt, ...e };
2923
+ ee(() => {
2924
+ f && y(f);
2923
2925
  }, [f]);
2924
- const m = async (O) => {
2925
- if (!H || !u) {
2926
+ const y = async (q) => {
2927
+ if (!C || !d) {
2926
2928
  L("Missing tenant or email");
2927
2929
  return;
2928
2930
  }
2929
2931
  A(!0), L("");
2930
2932
  try {
2931
- const V = await c({
2932
- token: O,
2933
- email: u
2933
+ const W = await g({
2934
+ token: q,
2935
+ email: d
2934
2936
  // tenantId inferred from context automatically
2935
2937
  });
2936
- t == null || t(V);
2937
- } catch (V) {
2938
- const k = V.message || "Failed to verify magic link";
2939
- L(k), n == null || n(k);
2938
+ t == null || t(W);
2939
+ } catch (W) {
2940
+ const B = W.message || "Failed to verify magic link";
2941
+ L(B), n == null || n(B);
2940
2942
  } finally {
2941
2943
  A(!1);
2942
2944
  }
2943
- }, v = () => {
2944
- const O = {};
2945
- return u.trim() || (O.email = !0), l && !g.trim() && (O.name = !0), $(O), Object.keys(O).length === 0;
2946
- }, G = async (O) => {
2947
- if (O.preventDefault(), !!v()) {
2948
- if (!(H != null && H.id)) {
2945
+ }, k = () => {
2946
+ const q = {};
2947
+ return d.trim() || (q.email = !0), l && !h.trim() && (q.name = !0), U(q), Object.keys(q).length === 0;
2948
+ }, j = async (q) => {
2949
+ if (q.preventDefault(), !!k()) {
2950
+ if (!(C != null && C.id)) {
2949
2951
  L("Tenant not found");
2950
2952
  return;
2951
2953
  }
2952
- P(!0), L(""), C("");
2954
+ P(!0), L(""), N("");
2953
2955
  try {
2954
- const V = w || (typeof window < "u" ? window.location.origin : ""), k = await U({
2955
- email: u,
2956
- tenantId: H.id,
2957
- frontendUrl: V,
2958
- name: l ? g : void 0,
2956
+ const W = w || (typeof window < "u" ? window.location.origin : ""), B = await $({
2957
+ email: d,
2958
+ tenantId: C.id,
2959
+ frontendUrl: W,
2960
+ name: l ? h : void 0,
2959
2961
  lastName: l ? I : void 0
2960
2962
  });
2961
- C(F.successMessage), t == null || t(k);
2962
- } catch (V) {
2963
- const k = V.message || F.errorMessage;
2964
- L(k), n == null || n(k);
2963
+ N(T.successMessage), t == null || t(B);
2964
+ } catch (W) {
2965
+ const B = W.message || T.errorMessage;
2966
+ L(B), n == null || n(B);
2965
2967
  } finally {
2966
2968
  P(!1);
2967
2969
  }
2968
2970
  }
2969
- }, Y = (O) => ({
2970
- ...y.input,
2971
- ...R[O] ? y.inputError : {}
2972
- }), q = () => ({
2973
- ...y.button,
2974
- ...M || h ? y.buttonLoading : {},
2975
- ...!u || M || h ? y.buttonDisabled : {}
2971
+ }, Z = (q) => ({
2972
+ ...S.input,
2973
+ ...R[q] ? S.inputError : {}
2974
+ }), O = () => ({
2975
+ ...S.button,
2976
+ ...M || u ? S.buttonLoading : {},
2977
+ ...!d || M || u ? S.buttonDisabled : {}
2976
2978
  });
2977
- return h ? /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
2978
- /* @__PURE__ */ s("h2", { style: y.title, children: F.verifyingText }),
2979
+ return u ? /* @__PURE__ */ c("div", { className: p, style: S.container, children: [
2980
+ /* @__PURE__ */ s("h2", { style: S.title, children: T.verifyingText }),
2979
2981
  /* @__PURE__ */ s("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ s("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
2980
- ] }) : /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
2981
- /* @__PURE__ */ s("h2", { style: y.title, children: F.title }),
2982
- /* @__PURE__ */ s("p", { style: y.description, children: F.description }),
2983
- /* @__PURE__ */ d("form", { onSubmit: G, style: y.form, children: [
2984
- /* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
2985
- /* @__PURE__ */ s("label", { style: y.label, children: F.emailLabel }),
2982
+ ] }) : /* @__PURE__ */ c("div", { className: p, style: S.container, children: [
2983
+ /* @__PURE__ */ s("h2", { style: S.title, children: T.title }),
2984
+ /* @__PURE__ */ s("p", { style: S.description, children: T.description }),
2985
+ /* @__PURE__ */ c("form", { onSubmit: j, style: S.form, children: [
2986
+ /* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
2987
+ /* @__PURE__ */ s("label", { style: S.label, children: T.emailLabel }),
2986
2988
  /* @__PURE__ */ s(
2987
2989
  "input",
2988
2990
  {
2989
2991
  id: "email",
2990
2992
  name: "email",
2991
2993
  type: "email",
2992
- value: u,
2993
- onChange: (O) => {
2994
- b(O.target.value), R.email && $((V) => ({ ...V, email: !1 }));
2994
+ value: d,
2995
+ onChange: (q) => {
2996
+ m(q.target.value), R.email && U((W) => ({ ...W, email: !1 }));
2995
2997
  },
2996
- placeholder: F.emailPlaceholder,
2997
- style: Y("email"),
2998
- disabled: M || h
2998
+ placeholder: T.emailPlaceholder,
2999
+ style: Z("email"),
3000
+ disabled: M || u
2999
3001
  }
3000
3002
  )
3001
3003
  ] }),
@@ -3015,27 +3017,27 @@ function qn({
3015
3017
  children: "New user? Add your name"
3016
3018
  }
3017
3019
  ) }),
3018
- l && /* @__PURE__ */ d(_, { children: [
3019
- /* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
3020
- /* @__PURE__ */ s("label", { style: y.label, children: F.nameLabel }),
3020
+ l && /* @__PURE__ */ c(_, { children: [
3021
+ /* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
3022
+ /* @__PURE__ */ s("label", { style: S.label, children: T.nameLabel }),
3021
3023
  /* @__PURE__ */ s(
3022
3024
  "input",
3023
3025
  {
3024
3026
  id: "name",
3025
3027
  name: "name",
3026
3028
  type: "text",
3027
- value: g,
3028
- onChange: (O) => {
3029
- T(O.target.value), R.name && $((V) => ({ ...V, name: !1 }));
3029
+ value: h,
3030
+ onChange: (q) => {
3031
+ v(q.target.value), R.name && U((W) => ({ ...W, name: !1 }));
3030
3032
  },
3031
- placeholder: F.namePlaceholder,
3032
- style: Y("name"),
3033
- disabled: M || h
3033
+ placeholder: T.namePlaceholder,
3034
+ style: Z("name"),
3035
+ disabled: M || u
3034
3036
  }
3035
3037
  )
3036
3038
  ] }),
3037
- /* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
3038
- /* @__PURE__ */ s("label", { style: y.label, children: F.lastNameLabel }),
3039
+ /* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
3040
+ /* @__PURE__ */ s("label", { style: S.label, children: T.lastNameLabel }),
3039
3041
  /* @__PURE__ */ s(
3040
3042
  "input",
3041
3043
  {
@@ -3043,10 +3045,10 @@ function qn({
3043
3045
  name: "lastName",
3044
3046
  type: "text",
3045
3047
  value: I,
3046
- onChange: (O) => N(O.target.value),
3047
- placeholder: F.lastNamePlaceholder,
3048
- style: y.input,
3049
- disabled: M || h
3048
+ onChange: (q) => F(q.target.value),
3049
+ placeholder: T.lastNamePlaceholder,
3050
+ style: S.input,
3051
+ disabled: M || u
3050
3052
  }
3051
3053
  )
3052
3054
  ] }),
@@ -3055,7 +3057,7 @@ function qn({
3055
3057
  {
3056
3058
  type: "button",
3057
3059
  onClick: () => {
3058
- D(!1), T(""), N("");
3060
+ D(!1), v(""), F("");
3059
3061
  },
3060
3062
  style: {
3061
3063
  background: "none",
@@ -3069,30 +3071,30 @@ function qn({
3069
3071
  }
3070
3072
  ) })
3071
3073
  ] }),
3072
- /* @__PURE__ */ s("button", { type: "submit", disabled: !u || M || h, style: q(), children: M ? F.loadingText : F.submitButton }),
3073
- S && /* @__PURE__ */ s("div", { style: y.errorText, children: S }),
3074
- E && /* @__PURE__ */ s("div", { style: y.successText, children: E })
3074
+ /* @__PURE__ */ s("button", { type: "submit", disabled: !d || M || u, style: O(), children: M ? T.loadingText : T.submitButton }),
3075
+ b && /* @__PURE__ */ s("div", { style: S.errorText, children: b }),
3076
+ E && /* @__PURE__ */ s("div", { style: S.successText, children: E })
3075
3077
  ] }),
3076
- a && /* @__PURE__ */ d("div", { style: y.linkContainer, children: [
3077
- /* @__PURE__ */ d("div", { children: [
3078
- /* @__PURE__ */ d("span", { style: y.divider, children: [
3079
- F.loginText,
3078
+ a && /* @__PURE__ */ c("div", { style: S.linkContainer, children: [
3079
+ /* @__PURE__ */ c("div", { children: [
3080
+ /* @__PURE__ */ c("span", { style: S.divider, children: [
3081
+ T.loginText,
3080
3082
  " "
3081
3083
  ] }),
3082
- /* @__PURE__ */ s("a", { onClick: i, style: y.link, children: F.loginLink })
3084
+ /* @__PURE__ */ s("a", { onClick: i, style: S.link, children: T.loginLink })
3083
3085
  ] }),
3084
- /* @__PURE__ */ s("div", { style: y.divider, children: "•" }),
3085
- /* @__PURE__ */ d("div", { children: [
3086
- /* @__PURE__ */ d("span", { style: y.divider, children: [
3087
- F.signupText,
3086
+ /* @__PURE__ */ s("div", { style: S.divider, children: "•" }),
3087
+ /* @__PURE__ */ c("div", { children: [
3088
+ /* @__PURE__ */ c("span", { style: S.divider, children: [
3089
+ T.signupText,
3088
3090
  " "
3089
3091
  ] }),
3090
- /* @__PURE__ */ s("a", { onClick: o, style: y.link, children: F.signupLink })
3092
+ /* @__PURE__ */ s("a", { onClick: o, style: S.link, children: T.signupLink })
3091
3093
  ] })
3092
3094
  ] })
3093
3095
  ] });
3094
3096
  }
3095
- const Zt = {
3097
+ const Jt = {
3096
3098
  title: "Verifying Magic Link",
3097
3099
  verifyingMessage: "Please wait while we verify your magic link...",
3098
3100
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -3100,7 +3102,7 @@ const Zt = {
3100
3102
  redirectingMessage: "Redirecting you to the dashboard...",
3101
3103
  retryButton: "Try Again",
3102
3104
  backToLoginButton: "Back to Login"
3103
- }, Je = {
3105
+ }, Qe = {
3104
3106
  container: {
3105
3107
  maxWidth: "400px",
3106
3108
  width: "100%",
@@ -3187,7 +3189,7 @@ const Zt = {
3187
3189
  cursor: "pointer",
3188
3190
  transition: "all 0.15s ease-in-out"
3189
3191
  }
3190
- }, Kt = () => /* @__PURE__ */ s("div", { style: Je.spinner }), Jt = () => /* @__PURE__ */ d(
3192
+ }, Yt = () => /* @__PURE__ */ s("div", { style: Qe.spinner }), Qt = () => /* @__PURE__ */ c(
3191
3193
  "svg",
3192
3194
  {
3193
3195
  width: "48",
@@ -3204,7 +3206,7 @@ const Zt = {
3204
3206
  /* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
3205
3207
  ]
3206
3208
  }
3207
- ), Yt = () => /* @__PURE__ */ d(
3209
+ ), Xt = () => /* @__PURE__ */ c(
3208
3210
  "svg",
3209
3211
  {
3210
3212
  width: "48",
@@ -3222,12 +3224,12 @@ const Zt = {
3222
3224
  /* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
3223
3225
  ]
3224
3226
  }
3225
- ), Qt = {
3226
- loading: /* @__PURE__ */ s(Kt, {}),
3227
- success: /* @__PURE__ */ s(Jt, {}),
3228
- error: /* @__PURE__ */ s(Yt, {})
3227
+ ), en = {
3228
+ loading: /* @__PURE__ */ s(Yt, {}),
3229
+ success: /* @__PURE__ */ s(Qt, {}),
3230
+ error: /* @__PURE__ */ s(Xt, {})
3229
3231
  };
3230
- function On({
3232
+ function _n({
3231
3233
  copy: r = {},
3232
3234
  styles: e = {},
3233
3235
  icons: t = {},
@@ -3238,18 +3240,18 @@ function On({
3238
3240
  className: p,
3239
3241
  token: f,
3240
3242
  email: w,
3241
- appId: u,
3242
- tenantSlug: b,
3243
- autoRedirectDelay: g = 3e3
3243
+ appId: d,
3244
+ tenantSlug: m,
3245
+ autoRedirectDelay: h = 3e3
3244
3246
  }) {
3245
- const [T, I] = x("verifying"), [N, M] = x(""), { verifyMagicLink: P } = le(), h = { ...Zt, ...r }, A = { ...Je, ...e }, S = { ...Qt, ...t }, L = () => {
3247
+ const [v, I] = x("verifying"), [F, M] = x(""), { verifyMagicLink: P } = ce(), u = { ...Jt, ...r }, A = { ...Qe, ...e }, b = { ...en, ...t }, L = () => {
3246
3248
  if (typeof window > "u") return {};
3247
3249
  const l = new URLSearchParams(window.location.search);
3248
3250
  return {
3249
3251
  token: f || l.get("token") || "",
3250
3252
  email: w || l.get("email") || "",
3251
- appId: u || l.get("appId") || "",
3252
- tenantSlug: b || l.get("tenantSlug") || void 0
3253
+ appId: d || l.get("appId") || "",
3254
+ tenantSlug: m || l.get("tenantSlug") || void 0
3253
3255
  };
3254
3256
  }, E = async () => {
3255
3257
  I("verifying"), M("");
@@ -3262,47 +3264,47 @@ function On({
3262
3264
  email: l.email,
3263
3265
  tenantSlug: l.tenantSlug
3264
3266
  });
3265
- I("success"), n == null || n(D), g > 0 && setTimeout(() => {
3267
+ I("success"), n == null || n(D), h > 0 && setTimeout(() => {
3266
3268
  I("redirecting");
3267
- }, g);
3269
+ }, h);
3268
3270
  } catch (l) {
3269
- const D = l.message || h.errorMessage;
3271
+ const D = l.message || u.errorMessage;
3270
3272
  M(D), I("error"), i == null || i(D);
3271
3273
  }
3272
- }, C = () => {
3274
+ }, N = () => {
3273
3275
  o == null || o(), E();
3274
3276
  }, R = () => {
3275
3277
  a == null || a();
3276
3278
  };
3277
- X(() => {
3279
+ ee(() => {
3278
3280
  E();
3279
3281
  }, []);
3280
- const $ = () => {
3281
- switch (T) {
3282
+ const U = () => {
3283
+ switch (v) {
3282
3284
  case "verifying":
3283
- return /* @__PURE__ */ d("div", { style: A.message, children: [
3284
- S.loading,
3285
- h.verifyingMessage
3285
+ return /* @__PURE__ */ c("div", { style: A.message, children: [
3286
+ b.loading,
3287
+ u.verifyingMessage
3286
3288
  ] });
3287
3289
  case "success":
3288
- return /* @__PURE__ */ d(_, { children: [
3289
- S.success,
3290
- /* @__PURE__ */ s("div", { style: A.successMessage, children: h.successMessage })
3290
+ return /* @__PURE__ */ c(_, { children: [
3291
+ b.success,
3292
+ /* @__PURE__ */ s("div", { style: A.successMessage, children: u.successMessage })
3291
3293
  ] });
3292
3294
  case "redirecting":
3293
- return /* @__PURE__ */ d(_, { children: [
3294
- S.loading,
3295
- /* @__PURE__ */ s("div", { style: A.message, children: h.redirectingMessage })
3295
+ return /* @__PURE__ */ c(_, { children: [
3296
+ b.loading,
3297
+ /* @__PURE__ */ s("div", { style: A.message, children: u.redirectingMessage })
3296
3298
  ] });
3297
3299
  case "error":
3298
- return /* @__PURE__ */ d(_, { children: [
3299
- S.error,
3300
- /* @__PURE__ */ s("div", { style: A.errorMessage, children: N || h.errorMessage }),
3301
- /* @__PURE__ */ d("div", { style: A.buttonContainer, children: [
3300
+ return /* @__PURE__ */ c(_, { children: [
3301
+ b.error,
3302
+ /* @__PURE__ */ s("div", { style: A.errorMessage, children: F || u.errorMessage }),
3303
+ /* @__PURE__ */ c("div", { style: A.buttonContainer, children: [
3302
3304
  /* @__PURE__ */ s(
3303
3305
  "button",
3304
3306
  {
3305
- onClick: C,
3307
+ onClick: N,
3306
3308
  style: A.retryButton,
3307
3309
  onMouseOver: (l) => {
3308
3310
  l.currentTarget.style.backgroundColor = "#2563eb";
@@ -3310,7 +3312,7 @@ function On({
3310
3312
  onMouseOut: (l) => {
3311
3313
  l.currentTarget.style.backgroundColor = "#3b82f6";
3312
3314
  },
3313
- children: h.retryButton
3315
+ children: u.retryButton
3314
3316
  }
3315
3317
  ),
3316
3318
  /* @__PURE__ */ s(
@@ -3324,7 +3326,7 @@ function On({
3324
3326
  onMouseOut: (l) => {
3325
3327
  l.currentTarget.style.backgroundColor = "#f3f4f6";
3326
3328
  },
3327
- children: h.backToLoginButton
3329
+ children: u.backToLoginButton
3328
3330
  }
3329
3331
  )
3330
3332
  ] })
@@ -3333,18 +3335,18 @@ function On({
3333
3335
  return null;
3334
3336
  }
3335
3337
  };
3336
- return /* @__PURE__ */ d("div", { style: A.container, className: p, children: [
3338
+ return /* @__PURE__ */ c("div", { style: A.container, className: p, children: [
3337
3339
  /* @__PURE__ */ s("style", { children: `
3338
3340
  @keyframes spin {
3339
3341
  0% { transform: rotate(0deg); }
3340
3342
  100% { transform: rotate(360deg); }
3341
3343
  }
3342
3344
  ` }),
3343
- /* @__PURE__ */ s("h1", { style: A.title, children: h.title }),
3344
- $()
3345
+ /* @__PURE__ */ s("h1", { style: A.title, children: u.title }),
3346
+ U()
3345
3347
  ] });
3346
3348
  }
3347
- const Xt = {
3349
+ const tn = {
3348
3350
  title: "Reset Password",
3349
3351
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
3350
3352
  emailLabel: "Email",
@@ -3366,7 +3368,7 @@ const Xt = {
3366
3368
  resetLoadingText: "Resetting...",
3367
3369
  resetSuccessMessage: "Password reset successfully!",
3368
3370
  passwordMismatchError: "Passwords do not match"
3369
- }, en = {
3371
+ }, nn = {
3370
3372
  container: {
3371
3373
  maxWidth: "400px",
3372
3374
  margin: "0 auto",
@@ -3458,7 +3460,7 @@ const Xt = {
3458
3460
  cursor: "pointer"
3459
3461
  }
3460
3462
  };
3461
- function zn({
3463
+ function Wn({
3462
3464
  copy: r = {},
3463
3465
  styles: e = {},
3464
3466
  mode: t = "request",
@@ -3469,101 +3471,101 @@ function zn({
3469
3471
  onModeChange: p,
3470
3472
  className: f
3471
3473
  }) {
3472
- const [w, u] = x(""), [b, g] = x(n), [T, I] = x(""), [N, M] = x(""), [P, h] = x(!1), [A, S] = x(""), [L, E] = x(""), [C, R] = x({}), { requestPasswordReset: $, confirmPasswordReset: l } = le(), { tenant: D } = ge(), U = { ...Xt, ...r }, c = { ...en, ...e }, H = () => {
3473
- const q = {};
3474
- return w.trim() || (q.email = !0), R(q), Object.keys(q).length === 0;
3475
- }, F = () => {
3476
- const q = {};
3477
- return b.trim() || (q.token = !0), T.trim() || (q.newPassword = !0), N.trim() || (q.confirmPassword = !0), R(q), Object.keys(q).length === 0;
3478
- }, y = async (q) => {
3479
- if (q.preventDefault(), !!H()) {
3474
+ const [w, d] = x(""), [m, h] = x(n), [v, I] = x(""), [F, M] = x(""), [P, u] = x(!1), [A, b] = x(""), [L, E] = x(""), [N, R] = x({}), { requestPasswordReset: U, confirmPasswordReset: l } = ce(), { tenant: D } = ge(), $ = { ...tn, ...r }, g = { ...nn, ...e }, C = () => {
3475
+ const O = {};
3476
+ return w.trim() || (O.email = !0), R(O), Object.keys(O).length === 0;
3477
+ }, T = () => {
3478
+ const O = {};
3479
+ return m.trim() || (O.token = !0), v.trim() || (O.newPassword = !0), F.trim() || (O.confirmPassword = !0), R(O), Object.keys(O).length === 0;
3480
+ }, S = async (O) => {
3481
+ if (O.preventDefault(), !!C()) {
3480
3482
  if (!(D != null && D.id)) {
3481
- S("Tenant not found");
3483
+ b("Tenant not found");
3482
3484
  return;
3483
3485
  }
3484
- h(!0), S(""), E("");
3486
+ u(!0), b(""), E("");
3485
3487
  try {
3486
- await $({ email: w, tenantId: D.id }), E(U.successMessage), i == null || i();
3487
- } catch (O) {
3488
- const V = O.message || U.errorMessage;
3489
- S(V), o == null || o(V);
3488
+ await U({ email: w, tenantId: D.id }), E($.successMessage), i == null || i();
3489
+ } catch (q) {
3490
+ const W = q.message || $.errorMessage;
3491
+ b(W), o == null || o(W);
3490
3492
  } finally {
3491
- h(!1);
3493
+ u(!1);
3492
3494
  }
3493
3495
  }
3494
- }, m = async (q) => {
3495
- if (q.preventDefault(), !!F()) {
3496
- if (T !== N) {
3497
- S(U.passwordMismatchError), R({ confirmPassword: !0 });
3496
+ }, y = async (O) => {
3497
+ if (O.preventDefault(), !!T()) {
3498
+ if (v !== F) {
3499
+ b($.passwordMismatchError), R({ confirmPassword: !0 });
3498
3500
  return;
3499
3501
  }
3500
- h(!0), S(""), E("");
3502
+ u(!0), b(""), E("");
3501
3503
  try {
3502
- await l({ token: b, newPassword: T }), E(U.resetSuccessMessage), i == null || i();
3503
- } catch (O) {
3504
- const V = O.message || U.errorMessage;
3505
- S(V), o == null || o(V);
3504
+ await l({ token: m, newPassword: v }), E($.resetSuccessMessage), i == null || i();
3505
+ } catch (q) {
3506
+ const W = q.message || $.errorMessage;
3507
+ b(W), o == null || o(W);
3506
3508
  } finally {
3507
- h(!1);
3509
+ u(!1);
3508
3510
  }
3509
3511
  }
3510
- }, v = (q) => ({
3511
- ...c.input,
3512
- ...C[q] ? c.inputError : {}
3513
- }), G = () => ({
3514
- ...c.button,
3515
- ...P ? c.buttonLoading : {}
3512
+ }, k = (O) => ({
3513
+ ...g.input,
3514
+ ...N[O] ? g.inputError : {}
3515
+ }), j = () => ({
3516
+ ...g.button,
3517
+ ...P ? g.buttonLoading : {}
3516
3518
  });
3517
3519
  if (t === "reset") {
3518
- const q = b && T && N;
3519
- return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
3520
- /* @__PURE__ */ s("h2", { style: c.title, children: U.resetTitle }),
3521
- /* @__PURE__ */ s("p", { style: c.subtitle, children: U.resetSubtitle }),
3522
- /* @__PURE__ */ d("form", { onSubmit: m, style: c.form, children: [
3523
- /* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
3524
- /* @__PURE__ */ s("label", { style: c.label, children: U.tokenLabel }),
3520
+ const O = m && v && F;
3521
+ return /* @__PURE__ */ c("div", { className: f, style: g.container, children: [
3522
+ /* @__PURE__ */ s("h2", { style: g.title, children: $.resetTitle }),
3523
+ /* @__PURE__ */ s("p", { style: g.subtitle, children: $.resetSubtitle }),
3524
+ /* @__PURE__ */ c("form", { onSubmit: y, style: g.form, children: [
3525
+ /* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
3526
+ /* @__PURE__ */ s("label", { style: g.label, children: $.tokenLabel }),
3525
3527
  /* @__PURE__ */ s(
3526
3528
  "input",
3527
3529
  {
3528
3530
  type: "text",
3529
- value: b,
3530
- onChange: (O) => {
3531
- g(O.target.value), C.token && R((V) => ({ ...V, token: !1 }));
3531
+ value: m,
3532
+ onChange: (q) => {
3533
+ h(q.target.value), N.token && R((W) => ({ ...W, token: !1 }));
3532
3534
  },
3533
- placeholder: U.tokenPlaceholder,
3534
- style: v("token"),
3535
+ placeholder: $.tokenPlaceholder,
3536
+ style: k("token"),
3535
3537
  disabled: P
3536
3538
  }
3537
3539
  )
3538
3540
  ] }),
3539
- /* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
3540
- /* @__PURE__ */ s("label", { style: c.label, children: U.newPasswordLabel }),
3541
+ /* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
3542
+ /* @__PURE__ */ s("label", { style: g.label, children: $.newPasswordLabel }),
3541
3543
  /* @__PURE__ */ s(
3542
3544
  "input",
3543
3545
  {
3544
3546
  type: "password",
3545
- value: T,
3546
- onChange: (O) => {
3547
- I(O.target.value), C.newPassword && R((V) => ({ ...V, newPassword: !1 }));
3547
+ value: v,
3548
+ onChange: (q) => {
3549
+ I(q.target.value), N.newPassword && R((W) => ({ ...W, newPassword: !1 }));
3548
3550
  },
3549
- placeholder: U.newPasswordPlaceholder,
3550
- style: v("newPassword"),
3551
+ placeholder: $.newPasswordPlaceholder,
3552
+ style: k("newPassword"),
3551
3553
  disabled: P
3552
3554
  }
3553
3555
  )
3554
3556
  ] }),
3555
- /* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
3556
- /* @__PURE__ */ s("label", { style: c.label, children: U.confirmPasswordLabel }),
3557
+ /* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
3558
+ /* @__PURE__ */ s("label", { style: g.label, children: $.confirmPasswordLabel }),
3557
3559
  /* @__PURE__ */ s(
3558
3560
  "input",
3559
3561
  {
3560
3562
  type: "password",
3561
- value: N,
3562
- onChange: (O) => {
3563
- M(O.target.value), C.confirmPassword && R((V) => ({ ...V, confirmPassword: !1 })), A === U.passwordMismatchError && S("");
3563
+ value: F,
3564
+ onChange: (q) => {
3565
+ M(q.target.value), N.confirmPassword && R((W) => ({ ...W, confirmPassword: !1 })), A === $.passwordMismatchError && b("");
3564
3566
  },
3565
- placeholder: U.confirmPasswordPlaceholder,
3566
- style: v("confirmPassword"),
3567
+ placeholder: $.confirmPasswordPlaceholder,
3568
+ style: k("confirmPassword"),
3567
3569
  disabled: P
3568
3570
  }
3569
3571
  )
@@ -3572,43 +3574,43 @@ function zn({
3572
3574
  "button",
3573
3575
  {
3574
3576
  type: "submit",
3575
- disabled: !q || P,
3577
+ disabled: !O || P,
3576
3578
  style: {
3577
- ...G(),
3578
- ...!q || P ? c.buttonDisabled : {}
3579
+ ...j(),
3580
+ ...!O || P ? g.buttonDisabled : {}
3579
3581
  },
3580
- children: P ? U.resetLoadingText : U.resetSubmitButton
3582
+ children: P ? $.resetLoadingText : $.resetSubmitButton
3581
3583
  }
3582
3584
  ),
3583
- A && /* @__PURE__ */ s("div", { style: c.errorText, children: A }),
3584
- L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
3585
+ A && /* @__PURE__ */ s("div", { style: g.errorText, children: A }),
3586
+ L && /* @__PURE__ */ s("div", { style: g.successText, children: L })
3585
3587
  ] }),
3586
- /* @__PURE__ */ d("div", { style: c.linkContainer, children: [
3587
- /* @__PURE__ */ s("a", { onClick: a, style: c.link, children: U.backToLoginLink }),
3588
- p && /* @__PURE__ */ d(_, { children: [
3588
+ /* @__PURE__ */ c("div", { style: g.linkContainer, children: [
3589
+ /* @__PURE__ */ s("a", { onClick: a, style: g.link, children: $.backToLoginLink }),
3590
+ p && /* @__PURE__ */ c(_, { children: [
3589
3591
  /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3590
- /* @__PURE__ */ s("a", { onClick: () => p("request"), style: c.link, children: "Request New Link" })
3592
+ /* @__PURE__ */ s("a", { onClick: () => p("request"), style: g.link, children: "Request New Link" })
3591
3593
  ] })
3592
3594
  ] })
3593
3595
  ] });
3594
3596
  }
3595
- const Y = w;
3596
- return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
3597
- /* @__PURE__ */ s("h2", { style: c.title, children: U.title }),
3598
- /* @__PURE__ */ s("p", { style: c.subtitle, children: U.subtitle }),
3599
- /* @__PURE__ */ d("form", { onSubmit: y, style: c.form, children: [
3600
- /* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
3601
- /* @__PURE__ */ s("label", { style: c.label, children: U.emailLabel }),
3597
+ const Z = w;
3598
+ return /* @__PURE__ */ c("div", { className: f, style: g.container, children: [
3599
+ /* @__PURE__ */ s("h2", { style: g.title, children: $.title }),
3600
+ /* @__PURE__ */ s("p", { style: g.subtitle, children: $.subtitle }),
3601
+ /* @__PURE__ */ c("form", { onSubmit: S, style: g.form, children: [
3602
+ /* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
3603
+ /* @__PURE__ */ s("label", { style: g.label, children: $.emailLabel }),
3602
3604
  /* @__PURE__ */ s(
3603
3605
  "input",
3604
3606
  {
3605
3607
  type: "email",
3606
3608
  value: w,
3607
- onChange: (q) => {
3608
- u(q.target.value), C.email && R((O) => ({ ...O, email: !1 }));
3609
+ onChange: (O) => {
3610
+ d(O.target.value), N.email && R((q) => ({ ...q, email: !1 }));
3609
3611
  },
3610
- placeholder: U.emailPlaceholder,
3611
- style: v("email"),
3612
+ placeholder: $.emailPlaceholder,
3613
+ style: k("email"),
3612
3614
  disabled: P
3613
3615
  }
3614
3616
  )
@@ -3617,27 +3619,27 @@ function zn({
3617
3619
  "button",
3618
3620
  {
3619
3621
  type: "submit",
3620
- disabled: !Y || P,
3622
+ disabled: !Z || P,
3621
3623
  style: {
3622
- ...G(),
3623
- ...!Y || P ? c.buttonDisabled : {}
3624
+ ...j(),
3625
+ ...!Z || P ? g.buttonDisabled : {}
3624
3626
  },
3625
- children: P ? U.loadingText : U.submitButton
3627
+ children: P ? $.loadingText : $.submitButton
3626
3628
  }
3627
3629
  ),
3628
- A && /* @__PURE__ */ s("div", { style: c.errorText, children: A }),
3629
- L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
3630
+ A && /* @__PURE__ */ s("div", { style: g.errorText, children: A }),
3631
+ L && /* @__PURE__ */ s("div", { style: g.successText, children: L })
3630
3632
  ] }),
3631
- /* @__PURE__ */ d("div", { style: c.linkContainer, children: [
3632
- /* @__PURE__ */ s("a", { onClick: a, style: c.link, children: U.backToLoginLink }),
3633
- p && /* @__PURE__ */ d(_, { children: [
3633
+ /* @__PURE__ */ c("div", { style: g.linkContainer, children: [
3634
+ /* @__PURE__ */ s("a", { onClick: a, style: g.link, children: $.backToLoginLink }),
3635
+ p && /* @__PURE__ */ c(_, { children: [
3634
3636
  /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3635
- /* @__PURE__ */ s("a", { onClick: () => p("reset"), style: c.link, children: "I have a token" })
3637
+ /* @__PURE__ */ s("a", { onClick: () => p("reset"), style: g.link, children: "I have a token" })
3636
3638
  ] })
3637
3639
  ] })
3638
3640
  ] });
3639
3641
  }
3640
- const tn = () => /* @__PURE__ */ s(
3642
+ const rn = () => /* @__PURE__ */ s(
3641
3643
  "div",
3642
3644
  {
3643
3645
  style: {
@@ -3649,7 +3651,7 @@ const tn = () => /* @__PURE__ */ s(
3649
3651
  },
3650
3652
  children: /* @__PURE__ */ s("div", { children: "Loading..." })
3651
3653
  }
3652
- ), nn = ({ error: r, retry: e }) => /* @__PURE__ */ d(
3654
+ ), sn = ({ error: r, retry: e }) => /* @__PURE__ */ c(
3653
3655
  "div",
3654
3656
  {
3655
3657
  style: {
@@ -3683,43 +3685,43 @@ const tn = () => /* @__PURE__ */ s(
3683
3685
  ]
3684
3686
  }
3685
3687
  );
3686
- function _n({
3688
+ function Vn({
3687
3689
  children: r,
3688
3690
  loadingFallback: e,
3689
3691
  errorFallback: t,
3690
3692
  requireTenant: n = !0
3691
3693
  }) {
3692
- const { isAppLoading: i, appError: o, retryApp: a } = ye(), p = Se(), f = Ee(), w = Ge(), u = Ze(), b = (p == null ? void 0 : p.isTenantLoading) ?? !1, g = (p == null ? void 0 : p.tenantError) ?? null, T = (p == null ? void 0 : p.tenantSlug) ?? null, I = (p == null ? void 0 : p.retryTenant) ?? (() => {
3693
- }), N = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (w == null ? void 0 : w.isReady) ?? !0, P = (u == null ? void 0 : u.isReady) ?? !0, h = n && p && T, E = i || h && b || f && !N || w && !M || u && !P, C = o || (h ? g : null), R = () => {
3694
- o && a(), g && p && I();
3694
+ const { isAppLoading: i, appError: o, retryApp: a } = we(), p = ve(), f = Ne(), w = Ke(), d = Je(), m = (p == null ? void 0 : p.isTenantLoading) ?? !1, h = (p == null ? void 0 : p.tenantError) ?? null, v = (p == null ? void 0 : p.tenantSlug) ?? null, I = (p == null ? void 0 : p.retryTenant) ?? (() => {
3695
+ }), F = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (w == null ? void 0 : w.isReady) ?? !0, P = (d == null ? void 0 : d.isReady) ?? !0, u = n && p && v, E = i || u && m || f && !F || w && !M || d && !P, N = o || (u ? h : null), R = () => {
3696
+ o && a(), h && p && I();
3695
3697
  };
3696
3698
  if (E)
3697
- return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(tn, {}) });
3698
- if (C) {
3699
- const $ = typeof t == "function" ? t(C, R) : t || /* @__PURE__ */ s(nn, { error: C, retry: R });
3700
- return /* @__PURE__ */ s(_, { children: $ });
3699
+ return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(rn, {}) });
3700
+ if (N) {
3701
+ const U = typeof t == "function" ? t(N, R) : t || /* @__PURE__ */ s(sn, { error: N, retry: R });
3702
+ return /* @__PURE__ */ s(_, { children: U });
3701
3703
  }
3702
3704
  return /* @__PURE__ */ s(_, { children: r });
3703
3705
  }
3704
- function Wn(r = !0) {
3705
- const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = ye(), o = Se(), a = Ee(), p = Ge(), f = Ze(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, u = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3706
- }), I = (a == null ? void 0 : a.isAuthReady) ?? !0, N = (p == null ? void 0 : p.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = r && o && g, L = e || P && w || a && !I || p && !N || f && !M, E = t || (P ? u : null);
3706
+ function jn(r = !0) {
3707
+ const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = we(), o = ve(), a = Ne(), p = Ke(), f = Je(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, d = (o == null ? void 0 : o.tenantError) ?? null, m = (o == null ? void 0 : o.tenant) ?? null, h = (o == null ? void 0 : o.tenantSlug) ?? null, v = (o == null ? void 0 : o.retryTenant) ?? (() => {
3708
+ }), I = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (p == null ? void 0 : p.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = r && o && h, L = e || P && w || a && !I || p && !F || f && !M, E = t || (P ? d : null);
3707
3709
  return {
3708
3710
  isLoading: L,
3709
3711
  error: E,
3710
- isReady: !L && !E && i !== null && (!P || b !== null),
3712
+ isReady: !L && !E && i !== null && (!P || m !== null),
3711
3713
  retry: () => {
3712
- t && n(), u && o && T();
3714
+ t && n(), d && o && v();
3713
3715
  },
3714
3716
  // Individual states
3715
3717
  app: { isLoading: e, error: t, data: i },
3716
- tenant: o ? { isLoading: w, error: u, data: b } : null,
3718
+ tenant: o ? { isLoading: w, error: d, data: m } : null,
3717
3719
  auth: a ? { isReady: I } : null,
3718
- featureFlags: p ? { isReady: N } : null,
3720
+ featureFlags: p ? { isReady: F } : null,
3719
3721
  subscription: f ? { isReady: M } : null
3720
3722
  };
3721
3723
  }
3722
- function Vn({
3724
+ function Gn({
3723
3725
  tenants: r,
3724
3726
  currentTenantId: e,
3725
3727
  onSelect: t,
@@ -3732,34 +3734,34 @@ function Vn({
3732
3734
  showCurrentTenant: w = !0
3733
3735
  }) {
3734
3736
  var A;
3735
- const u = Ee(), [b, g] = x(!1), T = Ve(null), I = r ?? (u == null ? void 0 : u.userTenants) ?? [], N = e ?? ((A = u == null ? void 0 : u.currentUser) == null ? void 0 : A.tenantId) ?? null, M = async (S) => {
3736
- g(!1), t ? t(S) : u != null && u.switchToTenant && await u.switchToTenant(S);
3737
+ const d = Ne(), [m, h] = x(!1), v = Ge(null), I = r ?? (d == null ? void 0 : d.userTenants) ?? [], F = e ?? ((A = d == null ? void 0 : d.currentUser) == null ? void 0 : A.tenantId) ?? null, M = async (b) => {
3738
+ h(!1), t ? t(b) : d != null && d.switchToTenant && await d.switchToTenant(b);
3737
3739
  };
3738
- X(() => {
3739
- const S = (L) => {
3740
- T.current && !T.current.contains(L.target) && g(!1);
3740
+ ee(() => {
3741
+ const b = (L) => {
3742
+ v.current && !v.current.contains(L.target) && h(!1);
3741
3743
  };
3742
- return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
3744
+ return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
3743
3745
  }, []);
3744
- const P = I.find((S) => S.id === N);
3746
+ const P = I.find((b) => b.id === F);
3745
3747
  if (I.length === 0)
3746
3748
  return null;
3747
3749
  if (I.length === 1 && w)
3748
3750
  return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children: I[0].name }) });
3749
- const h = (S, L) => /* @__PURE__ */ d("span", { style: { fontWeight: L ? "bold" : "normal" }, children: [
3750
- S.name,
3751
- S.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
3751
+ const u = (b, L) => /* @__PURE__ */ c("span", { style: { fontWeight: L ? "bold" : "normal" }, children: [
3752
+ b.name,
3753
+ b.role && /* @__PURE__ */ c("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
3752
3754
  "(",
3753
- S.role,
3755
+ b.role,
3754
3756
  ")"
3755
3757
  ] })
3756
3758
  ] });
3757
- return /* @__PURE__ */ d("div", { ref: T, className: n, style: { position: "relative" }, children: [
3758
- /* @__PURE__ */ d(
3759
+ return /* @__PURE__ */ c("div", { ref: v, className: n, style: { position: "relative" }, children: [
3760
+ /* @__PURE__ */ c(
3759
3761
  "button",
3760
3762
  {
3761
3763
  type: "button",
3762
- onClick: () => !f && g(!b),
3764
+ onClick: () => !f && h(!m),
3763
3765
  disabled: f,
3764
3766
  style: {
3765
3767
  cursor: f ? "not-allowed" : "pointer",
@@ -3767,11 +3769,11 @@ function Vn({
3767
3769
  },
3768
3770
  children: [
3769
3771
  P ? P.name : p,
3770
- /* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: b ? "▲" : "▼" })
3772
+ /* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: m ? "▲" : "▼" })
3771
3773
  ]
3772
3774
  }
3773
3775
  ),
3774
- b && /* @__PURE__ */ s(
3776
+ m && /* @__PURE__ */ s(
3775
3777
  "div",
3776
3778
  {
3777
3779
  className: i,
@@ -3788,13 +3790,13 @@ function Vn({
3788
3790
  maxHeight: 300,
3789
3791
  overflowY: "auto"
3790
3792
  },
3791
- children: I.map((S) => {
3792
- const L = S.id === N;
3793
+ children: I.map((b) => {
3794
+ const L = b.id === F;
3793
3795
  return /* @__PURE__ */ s(
3794
3796
  "div",
3795
3797
  {
3796
3798
  className: o,
3797
- onClick: () => M(S.id),
3799
+ onClick: () => M(b.id),
3798
3800
  style: {
3799
3801
  padding: "8px 12px",
3800
3802
  cursor: "pointer",
@@ -3806,16 +3808,16 @@ function Vn({
3806
3808
  onMouseLeave: (E) => {
3807
3809
  L || (E.target.style.backgroundColor = "transparent");
3808
3810
  },
3809
- children: a ? a(S, L) : h(S, L)
3811
+ children: a ? a(b, L) : u(b, L)
3810
3812
  },
3811
- S.id
3813
+ b.id
3812
3814
  );
3813
3815
  })
3814
3816
  }
3815
3817
  )
3816
3818
  ] });
3817
3819
  }
3818
- class jn {
3820
+ class Zn {
3819
3821
  constructor(e, t) {
3820
3822
  this.httpService = e, this.sessionManager = t;
3821
3823
  }
@@ -3883,7 +3885,7 @@ class jn {
3883
3885
  };
3884
3886
  }
3885
3887
  }
3886
- class Gn {
3888
+ class Kn {
3887
3889
  constructor(e, t) {
3888
3890
  this.httpService = e, this.sessionManager = t;
3889
3891
  }
@@ -3934,7 +3936,7 @@ class Gn {
3934
3936
  });
3935
3937
  }
3936
3938
  }
3937
- class Zn {
3939
+ class Jn {
3938
3940
  constructor(e) {
3939
3941
  this.httpService = e;
3940
3942
  }
@@ -3943,7 +3945,7 @@ class Zn {
3943
3945
  return await this.httpService.get("/health");
3944
3946
  }
3945
3947
  }
3946
- class Kn {
3948
+ class Yn {
3947
3949
  // Date string to Date object
3948
3950
  static toDate(e) {
3949
3951
  return new Date(e);
@@ -4065,136 +4067,136 @@ class Kn {
4065
4067
  }), t;
4066
4068
  }
4067
4069
  }
4068
- const Ye = "returnTo", Pe = "zone_return_to", Re = "zone_return_to";
4069
- function Jn(r = {}) {
4070
+ const Xe = "returnTo", Ie = "zone_return_to", Me = "zone_return_to";
4071
+ function Qn(r = {}) {
4070
4072
  const {
4071
4073
  zoneRoots: e = {},
4072
- returnToParam: t = Ye,
4074
+ returnToParam: t = Xe,
4073
4075
  returnToStorage: n = "url"
4074
- } = r, i = ut(), [o, a] = ht(), { isAuthenticated: p, currentUser: f } = le(), { tenant: w } = he(), u = Z(() => ({ ...De, ...e }), [e]), b = !!w, g = f == null ? void 0 : f.userType, T = Z(() => {
4076
+ } = r, i = gt(), [o, a] = pt(), { isAuthenticated: p, currentUser: f } = ce(), { tenant: w } = he(), d = J(() => ({ ...Ue, ...e }), [e]), m = !!w, h = f == null ? void 0 : f.userType, v = J(() => {
4075
4077
  switch (n) {
4076
4078
  case "url":
4077
4079
  return o.get(t);
4078
4080
  case "session":
4079
- return sessionStorage.getItem(Pe);
4081
+ return sessionStorage.getItem(Ie);
4080
4082
  case "local":
4081
- return localStorage.getItem(Re);
4083
+ return localStorage.getItem(Me);
4082
4084
  default:
4083
4085
  return null;
4084
4086
  }
4085
- }, [n, o, t]), I = re(() => {
4087
+ }, [n, o, t]), I = se(() => {
4086
4088
  switch (n) {
4087
4089
  case "url": {
4088
- const h = new URLSearchParams(o);
4089
- h.delete(t), a(h, { replace: !0 });
4090
+ const u = new URLSearchParams(o);
4091
+ u.delete(t), a(u, { replace: !0 });
4090
4092
  break;
4091
4093
  }
4092
4094
  case "session":
4093
- sessionStorage.removeItem(Pe);
4095
+ sessionStorage.removeItem(Ie);
4094
4096
  break;
4095
4097
  case "local":
4096
- localStorage.removeItem(Re);
4098
+ localStorage.removeItem(Me);
4097
4099
  break;
4098
4100
  }
4099
- }, [n, o, t, a]), N = re(
4100
- (h) => {
4101
+ }, [n, o, t, a]), F = se(
4102
+ (u) => {
4101
4103
  switch (n) {
4102
4104
  case "url": {
4103
4105
  const A = new URLSearchParams(o);
4104
- A.set(t, h), a(A, { replace: !0 });
4106
+ A.set(t, u), a(A, { replace: !0 });
4105
4107
  break;
4106
4108
  }
4107
4109
  case "session":
4108
- sessionStorage.setItem(Pe, h);
4110
+ sessionStorage.setItem(Ie, u);
4109
4111
  break;
4110
4112
  case "local":
4111
- localStorage.setItem(Re, h);
4113
+ localStorage.setItem(Me, u);
4112
4114
  break;
4113
4115
  }
4114
4116
  },
4115
4117
  [n, o, t, a]
4116
- ), M = re(
4117
- (h) => {
4118
- const A = u[h] || u.default;
4118
+ ), M = se(
4119
+ (u) => {
4120
+ const A = d[u] || d.default;
4119
4121
  i(A);
4120
4122
  },
4121
- [i, u]
4122
- ), P = re(() => b ? p ? g === se.TENANT_ADMIN ? u.tenantAdmin : u.tenantUser : u.tenantGuest : p ? g === se.TENANT_ADMIN ? u.publicAdmin : u.publicUser : u.publicGuest, [b, p, g, u]);
4123
+ [i, d]
4124
+ ), P = se(() => m ? p ? h === ie.TENANT_ADMIN ? d.tenantAdmin : d.tenantUser : d.tenantGuest : p ? h === ie.TENANT_ADMIN ? d.publicAdmin : d.publicUser : d.publicGuest, [m, p, h, d]);
4123
4125
  return {
4124
- returnToUrl: T,
4126
+ returnToUrl: v,
4125
4127
  clearReturnTo: I,
4126
- setReturnTo: N,
4128
+ setReturnTo: F,
4127
4129
  navigateToZone: M,
4128
4130
  getSmartRedirect: P
4129
4131
  };
4130
4132
  }
4131
- function Yn(r, e, t = Ye, n = "url") {
4133
+ function Xn(r, e, t = Xe, n = "url") {
4132
4134
  if (!e || n !== "url")
4133
4135
  return r;
4134
4136
  const i = new URL(r, window.location.origin);
4135
4137
  return i.searchParams.set(t, e), i.pathname + i.search;
4136
4138
  }
4137
4139
  export {
4138
- Ln as AdminZone,
4139
- Kn as ApiMappers,
4140
- He as AppApiService,
4141
- _n as AppLoader,
4142
- hn as AppProvider,
4143
- gt as AuthApiService,
4144
- yn as AuthProvider,
4145
- In as AuthenticatedZone,
4146
- Ke as DEFAULT_ZONE_PRESETS,
4147
- De as DEFAULT_ZONE_ROOTS,
4148
- $n as FeatureFlag,
4149
- Tt as FeatureFlagApiService,
4150
- wn as FeatureFlagProvider,
4151
- Mn as GuestZone,
4152
- Zn as HealthApiService,
4153
- oe as HttpService,
4154
- An as LandingRoute,
4155
- Hn as LoginForm,
4156
- qn as MagicLinkForm,
4157
- On as MagicLinkVerify,
4158
- Fn as OpenZone,
4159
- zn as PasswordRecoveryForm,
4160
- jn as PermissionApiService,
4161
- Tn as Protected,
4162
- kn as ProtectedRoute,
4163
- Rn as PublicZone,
4164
- Be as RoleApiService,
4165
- Sn as RoutingProvider,
4166
- Ae as SessionManager,
4167
- Bn as SignupForm,
4168
- xt as SubscriptionApiService,
4169
- Un as SubscriptionGuard,
4170
- Gn as SubscriptionPlanApiService,
4171
- bn as SubscriptionProvider,
4172
- fe as TenantApiService,
4173
- Nn as TenantAuthenticatedZone,
4174
- Cn as TenantGuestZone,
4175
- Dn as TenantOpenZone,
4176
- pn as TenantProvider,
4177
- xn as TenantRoute,
4178
- Vn as TenantSelector,
4179
- Pn as TenantZone,
4180
- pt as UserApiService,
4181
- se as UserType,
4182
- En as UserZone,
4183
- ae as ZoneRoute,
4184
- Yn as buildRedirectUrl,
4185
- gn as useApi,
4186
- ye as useApp,
4187
- Wn as useAppLoaderState,
4188
- le as useAuth,
4189
- kt as useFeatureFlags,
4190
- vn as useRouting,
4191
- Pt as useRoutingOptional,
4192
- mn as useSettings,
4193
- At as useSubscription,
4140
+ Fn as AdminZone,
4141
+ Yn as ApiMappers,
4142
+ qe as AppApiService,
4143
+ Vn as AppLoader,
4144
+ pn as AppProvider,
4145
+ ft as AuthApiService,
4146
+ bn as AuthProvider,
4147
+ Ln as AuthenticatedZone,
4148
+ Ye as DEFAULT_ZONE_PRESETS,
4149
+ Ue as DEFAULT_ZONE_ROOTS,
4150
+ Bn as FeatureFlag,
4151
+ xt as FeatureFlagApiService,
4152
+ Sn as FeatureFlagProvider,
4153
+ En as GuestZone,
4154
+ Jn as HealthApiService,
4155
+ ae as HttpService,
4156
+ Rn as LandingRoute,
4157
+ qn as LoginForm,
4158
+ zn as MagicLinkForm,
4159
+ _n as MagicLinkVerify,
4160
+ Dn as OpenZone,
4161
+ Wn as PasswordRecoveryForm,
4162
+ Zn as PermissionApiService,
4163
+ xn as Protected,
4164
+ An as ProtectedRoute,
4165
+ Mn as PublicZone,
4166
+ Oe as RoleApiService,
4167
+ Tn as RoutingProvider,
4168
+ Re as SessionManager,
4169
+ On as SignupForm,
4170
+ Pt as SubscriptionApiService,
4171
+ Hn as SubscriptionGuard,
4172
+ Kn as SubscriptionPlanApiService,
4173
+ vn as SubscriptionProvider,
4174
+ me as TenantApiService,
4175
+ Cn as TenantAuthenticatedZone,
4176
+ $n as TenantGuestZone,
4177
+ Un as TenantOpenZone,
4178
+ mn as TenantProvider,
4179
+ Pn as TenantRoute,
4180
+ Gn as TenantSelector,
4181
+ In as TenantZone,
4182
+ mt as UserApiService,
4183
+ ie as UserType,
4184
+ Nn as UserZone,
4185
+ le as ZoneRoute,
4186
+ Xn as buildRedirectUrl,
4187
+ fn as useApi,
4188
+ we as useApp,
4189
+ jn as useAppLoaderState,
4190
+ ce as useAuth,
4191
+ At as useFeatureFlags,
4192
+ kn as useRouting,
4193
+ It as useRoutingOptional,
4194
+ wn as useSettings,
4195
+ Rt as useSubscription,
4194
4196
  he as useTenant,
4195
4197
  ge as useTenantInfo,
4196
- Se as useTenantOptional,
4197
- fn as useTenantSettings,
4198
- Jn as useZoneNavigation
4198
+ ve as useTenantOptional,
4199
+ yn as useTenantSettings,
4200
+ Qn as useZoneNavigation
4199
4201
  };
4200
4202
  //# sourceMappingURL=index.es.js.map