@skylabs-digital/react-identity-access 2.7.0 → 2.9.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
1
  import { jsx as n, Fragment as j, jsxs as l } from "react/jsx-runtime";
2
- import { createContext as ue, useMemo as X, useState as S, useCallback as se, useEffect as te, useContext as ne, useRef as Ge } from "react";
3
- import { useLocation as Se, Navigate as pe } from "react-router-dom";
4
- class re {
2
+ import { createContext as ue, useMemo as Q, useState as S, useCallback as ie, useEffect as re, useContext as se, useRef as Ge } from "react";
3
+ import { useLocation as ve, Navigate as pe } from "react-router-dom";
4
+ class ne {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -65,7 +65,7 @@ class re {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class Pe {
68
+ class Me {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -124,16 +124,16 @@ class Pe {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const ve = ue(null);
128
- function Bt({ config: i, children: e }) {
129
- const t = X(
127
+ const ke = ue(null);
128
+ function qt({ config: i, children: e }) {
129
+ const t = Q(
130
130
  () => {
131
- var f, A, L;
131
+ var f, A, E;
132
132
  return {
133
133
  enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
134
134
  ttl: ((A = i.cache) == null ? void 0 : A.ttl) ?? 3e5,
135
135
  // 5 minutes default
136
- storageKey: ((L = i.cache) == null ? void 0 : L.storageKey) ?? `app_cache_${i.appId}`
136
+ storageKey: ((E = i.cache) == null ? void 0 : E.storageKey) ?? `app_cache_${i.appId}`
137
137
  };
138
138
  },
139
139
  [i.cache, i.appId]
@@ -147,7 +147,7 @@ function Bt({ config: i, children: e }) {
147
147
  } catch {
148
148
  return null;
149
149
  }
150
- }), [o, a] = S(!r), [g, w] = S(null), m = X(() => {
150
+ }), [o, a] = S(!r), [g, w] = S(null), m = Q(() => {
151
151
  const f = () => {
152
152
  k();
153
153
  };
@@ -160,39 +160,39 @@ function Bt({ config: i, children: e }) {
160
160
  appError: g,
161
161
  retryApp: f
162
162
  };
163
- }, [i, r, o, g]), k = se(
163
+ }, [i, r, o, g]), k = ie(
164
164
  async (f = !1) => {
165
165
  if (!(!f && t.enabled && r))
166
166
  try {
167
167
  a(!0), w(null);
168
- const A = new re(i.baseUrl), D = await new Pe(A, {}).getPublicAppInfo(i.appId);
169
- if (s(D), t.enabled)
168
+ const A = new ne(i.baseUrl), $ = await new Me(A, {}).getPublicAppInfo(i.appId);
169
+ if (s($), t.enabled)
170
170
  try {
171
- const R = {
172
- data: D,
171
+ const L = {
172
+ data: $,
173
173
  timestamp: Date.now(),
174
174
  appId: i.appId
175
175
  };
176
- localStorage.setItem(t.storageKey, JSON.stringify(R));
177
- } catch (R) {
178
- console.warn("Failed to cache app info:", R);
176
+ localStorage.setItem(t.storageKey, JSON.stringify(L));
177
+ } catch (L) {
178
+ console.warn("Failed to cache app info:", L);
179
179
  }
180
180
  } catch (A) {
181
- const L = A instanceof Error ? A : new Error("Failed to load app information");
182
- w(L), s(null);
181
+ const E = A instanceof Error ? A : new Error("Failed to load app information");
182
+ w(E), s(null);
183
183
  } finally {
184
184
  a(!1);
185
185
  }
186
186
  },
187
187
  [i.baseUrl, i.appId, t, r]
188
- ), b = se(async () => {
188
+ ), b = ie(async () => {
189
189
  if (!(!t.enabled || !r))
190
190
  try {
191
191
  const f = localStorage.getItem(t.storageKey);
192
192
  if (!f) return;
193
193
  const A = JSON.parse(f);
194
194
  if (Date.now() - A.timestamp > t.ttl * 0.5) {
195
- const D = new re(i.baseUrl), P = await new Pe(D, {}).getPublicAppInfo(i.appId);
195
+ const $ = new ne(i.baseUrl), P = await new Me($, {}).getPublicAppInfo(i.appId);
196
196
  s(P);
197
197
  const u = {
198
198
  data: P,
@@ -205,21 +205,21 @@ function Bt({ config: i, children: e }) {
205
205
  console.warn("Background app refresh failed:", f);
206
206
  }
207
207
  }, [i, t, r]);
208
- return te(() => {
208
+ return re(() => {
209
209
  r ? b() : k();
210
- }, []), /* @__PURE__ */ n(ve.Provider, { value: m, children: e });
210
+ }, []), /* @__PURE__ */ n(ke.Provider, { value: m, children: e });
211
211
  }
212
212
  function he() {
213
- const i = ne(ve);
213
+ const i = se(ke);
214
214
  if (!i)
215
215
  throw new Error("useApp must be used within an AppProvider");
216
216
  return i;
217
217
  }
218
- function Ee() {
219
- return ne(ve);
218
+ function Fe() {
219
+ return se(ke);
220
220
  }
221
- const qt = he;
222
- class be {
221
+ const zt = he;
222
+ class Se {
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
  }
@@ -417,7 +417,7 @@ class Ke {
417
417
  });
418
418
  }
419
419
  }
420
- class Me {
420
+ class Ie {
421
421
  constructor(e, t) {
422
422
  this.httpService = e, this.sessionManager = t;
423
423
  }
@@ -682,9 +682,9 @@ function nt() {
682
682
  newUrl: i.toString()
683
683
  }), window.history.replaceState({}, "", i.toString());
684
684
  }
685
- const ke = ue(null);
686
- function zt({ config: i, children: e }) {
687
- const { baseUrl: t, appInfo: r, appId: s } = he(), o = se(() => typeof window > "u" ? null : Xe(
685
+ const xe = ue(null);
686
+ function Ot({ config: i, children: e }) {
687
+ const { baseUrl: t, appInfo: r, appId: s } = he(), o = ie(() => typeof window > "u" ? null : Xe(
688
688
  {
689
689
  tenantMode: i.tenantMode || "selector",
690
690
  baseDomain: i.baseDomain,
@@ -695,12 +695,12 @@ function zt({ config: i, children: e }) {
695
695
  search: window.location.search
696
696
  },
697
697
  window.localStorage
698
- ), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = X(
698
+ ), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = Q(
699
699
  () => {
700
- var c, I, T;
700
+ var c, R, T;
701
701
  return {
702
702
  enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
703
- ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
703
+ ttl: ((R = i.cache) == null ? void 0 : R.ttl) ?? 5 * 60 * 1e3,
704
704
  // 5 minutes default
705
705
  storageKey: ((T = i.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
706
706
  };
@@ -712,22 +712,22 @@ function zt({ config: i, children: e }) {
712
712
  try {
713
713
  const c = localStorage.getItem(w.storageKey);
714
714
  if (!c) return null;
715
- const I = JSON.parse(c);
716
- return Date.now() - I.timestamp < w.ttl && I.tenantSlug === a ? I.data : (localStorage.removeItem(w.storageKey), null);
715
+ const R = JSON.parse(c);
716
+ return Date.now() - R.timestamp < w.ttl && R.tenantSlug === a ? R.data : (localStorage.removeItem(w.storageKey), null);
717
717
  } catch {
718
718
  return null;
719
719
  }
720
- }), [b, f] = S(!m && !i.initialTenant), [A, L] = S(null), [D, R] = S(null), [P, u] = S(!1), [N, z] = S(null);
721
- te(() => {
720
+ }), [b, f] = S(!m && !i.initialTenant), [A, E] = S(null), [$, L] = S(null), [P, u] = S(!1), [M, z] = S(null);
721
+ re(() => {
722
722
  const c = o();
723
723
  g(c);
724
724
  }, [o]);
725
- const E = (r == null ? void 0 : r.settingsSchema) || null, p = se(
726
- async (c, I = !1) => {
727
- if (!(!I && w.enabled && m && m.domain === c))
725
+ const N = (r == null ? void 0 : r.settingsSchema) || null, p = ie(
726
+ async (c, R = !1) => {
727
+ if (!(!R && w.enabled && m && m.domain === c))
728
728
  try {
729
- f(!0), L(null);
730
- const T = new re(t), d = await new de(T, s).getPublicTenantInfo(c);
729
+ f(!0), E(null);
730
+ const T = new ne(t), d = await new de(T, s).getPublicTenantInfo(c);
731
731
  if (k(d), w.enabled)
732
732
  try {
733
733
  const y = {
@@ -741,20 +741,20 @@ function zt({ config: i, children: e }) {
741
741
  }
742
742
  } catch (T) {
743
743
  const h = T instanceof Error ? T : new Error("Failed to load tenant information");
744
- L(h), k(null);
744
+ E(h), k(null);
745
745
  } finally {
746
746
  f(!1);
747
747
  }
748
748
  },
749
749
  [t, s, w, m]
750
- ), O = se(async () => {
750
+ ), O = ie(async () => {
751
751
  if (!(!w.enabled || !m || !a))
752
752
  try {
753
753
  const c = localStorage.getItem(w.storageKey);
754
754
  if (!c) return;
755
- const I = JSON.parse(c);
756
- if (Date.now() - I.timestamp > w.ttl * 0.5) {
757
- const h = new re(t), y = await new de(h, s).getPublicTenantInfo(a);
755
+ const R = JSON.parse(c);
756
+ if (Date.now() - R.timestamp > w.ttl * 0.5) {
757
+ const h = new ne(t), y = await new de(h, s).getPublicTenantInfo(a);
758
758
  k(y);
759
759
  const G = {
760
760
  data: y,
@@ -766,47 +766,47 @@ function zt({ config: i, children: e }) {
766
766
  } catch (c) {
767
767
  console.warn("Background tenant refresh failed:", c);
768
768
  }
769
- }, [t, s, w, m, a]), v = se(async () => {
769
+ }, [t, s, w, m, a]), v = ie(async () => {
770
770
  if (m != null && m.id)
771
771
  try {
772
772
  u(!0), z(null);
773
- const c = new re(t), T = await new de(c, m.appId).getTenantSettings(m.id);
774
- R(T);
773
+ const c = new ne(t), T = await new de(c, m.appId).getTenantSettings(m.id);
774
+ L(T);
775
775
  } catch (c) {
776
- const I = c instanceof Error ? c : new Error("Failed to load tenant settings");
777
- z(I), R(null);
776
+ const R = c instanceof Error ? c : new Error("Failed to load tenant settings");
777
+ z(R), L(null);
778
778
  } finally {
779
779
  u(!1);
780
780
  }
781
- }, [t, m]), C = se(() => {
781
+ }, [t, m]), C = ie(() => {
782
782
  v();
783
- }, [v]), x = se(
783
+ }, [v]), x = ie(
784
784
  (c) => {
785
- if (!E)
785
+ if (!N)
786
786
  return { isValid: !0, errors: [] };
787
- const I = [];
787
+ const R = [];
788
788
  try {
789
- return E.properties && Object.entries(E.properties).forEach(([T, h]) => {
789
+ return N.properties && Object.entries(N.properties).forEach(([T, h]) => {
790
790
  var y;
791
791
  const d = c[T];
792
- if ((y = E.required) != null && y.includes(T) && d == null) {
793
- I.push(`Field '${T}' is required`);
792
+ if ((y = N.required) != null && y.includes(T) && d == null) {
793
+ R.push(`Field '${T}' is required`);
794
794
  return;
795
795
  }
796
796
  if (d != null) {
797
797
  if (h.type) {
798
- const G = h.type, $ = typeof d;
799
- G === "string" && $ !== "string" ? I.push(`Field '${T}' must be a string`) : (G === "number" || G === "integer") && $ !== "number" ? I.push(`Field '${T}' must be a number`) : G === "boolean" && $ !== "boolean" ? I.push(`Field '${T}' must be a boolean`) : G === "array" && !Array.isArray(d) && I.push(`Field '${T}' must be an array`);
798
+ const G = h.type, D = typeof d;
799
+ G === "string" && D !== "string" ? R.push(`Field '${T}' must be a string`) : (G === "number" || G === "integer") && D !== "number" ? R.push(`Field '${T}' must be a number`) : G === "boolean" && D !== "boolean" ? R.push(`Field '${T}' must be a boolean`) : G === "array" && !Array.isArray(d) && R.push(`Field '${T}' must be an array`);
800
800
  }
801
- h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength && I.push(
801
+ h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength && R.push(
802
802
  `Field '${T}' must be at least ${h.minLength} characters long`
803
- ), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength && I.push(
803
+ ), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength && R.push(
804
804
  `Field '${T}' must be no more than ${h.maxLength} characters long`
805
- ), h.minimum !== void 0 && typeof d == "number" && d < h.minimum && I.push(`Field '${T}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof d == "number" && d > h.maximum && I.push(`Field '${T}' must be no more than ${h.maximum}`), h.pattern && typeof d == "string" && (new RegExp(h.pattern).test(d) || I.push(`Field '${T}' does not match the required pattern`)), h.enum && !h.enum.includes(d) && I.push(`Field '${T}' must be one of: ${h.enum.join(", ")}`);
805
+ ), h.minimum !== void 0 && typeof d == "number" && d < h.minimum && R.push(`Field '${T}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof d == "number" && d > h.maximum && R.push(`Field '${T}' must be no more than ${h.maximum}`), h.pattern && typeof d == "string" && (new RegExp(h.pattern).test(d) || R.push(`Field '${T}' does not match the required pattern`)), h.enum && !h.enum.includes(d) && R.push(`Field '${T}' must be one of: ${h.enum.join(", ")}`);
806
806
  }
807
807
  }), {
808
- isValid: I.length === 0,
809
- errors: I
808
+ isValid: R.length === 0,
809
+ errors: R
810
810
  };
811
811
  } catch {
812
812
  return {
@@ -815,46 +815,46 @@ function zt({ config: i, children: e }) {
815
815
  };
816
816
  }
817
817
  },
818
- [E]
818
+ [N]
819
819
  );
820
- te(() => {
821
- !i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), L(null), f(!1));
822
- }, [i.initialTenant, a, m, p, O]), te(() => {
823
- m != null && m.id ? v() : (R(null), z(null), u(!1));
820
+ re(() => {
821
+ !i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), E(null), f(!1));
822
+ }, [i.initialTenant, a, m, p, O]), re(() => {
823
+ m != null && m.id ? v() : (L(null), z(null), u(!1));
824
824
  }, [m == null ? void 0 : m.id, v]);
825
- const M = se(
826
- (c, I) => {
827
- const { mode: T = "reload", tokens: h, redirectPath: d } = I || {}, y = i.tenantMode || "selector";
825
+ const I = ie(
826
+ (c, R) => {
827
+ const { mode: T = "reload", tokens: h, redirectPath: d } = R || {}, y = i.tenantMode || "selector";
828
828
  if (localStorage.setItem("tenant", c), y === "subdomain") {
829
- const G = window.location.hostname, $ = Ze(
829
+ const G = window.location.hostname, D = Ze(
830
830
  c,
831
831
  G,
832
832
  i.baseDomain
833
833
  );
834
- if (!$) {
834
+ if (!D) {
835
835
  console.warn(
836
836
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
837
837
  G
838
838
  );
839
839
  return;
840
840
  }
841
- const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${$}${H}`);
842
- new URLSearchParams(window.location.search).forEach((B, J) => {
843
- J !== fe && U.searchParams.set(J, B);
841
+ const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${D}${H}`);
842
+ new URLSearchParams(window.location.search).forEach((B, K) => {
843
+ K !== fe && U.searchParams.set(K, B);
844
844
  }), h && U.searchParams.set(fe, et(h)), window.location.href = U.toString();
845
845
  } else if (y === "selector") {
846
- const G = d || window.location.pathname, $ = new URLSearchParams(window.location.search);
847
- if ($.set(i.selectorParam || "tenant", c), T === "reload") {
848
- const H = `${G}?${$.toString()}${window.location.hash}`;
846
+ const G = d || window.location.pathname, D = new URLSearchParams(window.location.search);
847
+ if (D.set(i.selectorParam || "tenant", c), T === "reload") {
848
+ const H = `${G}?${D.toString()}${window.location.hash}`;
849
849
  window.location.href = H;
850
850
  } else {
851
- const H = `${G}?${$.toString()}${window.location.hash}`;
851
+ const H = `${G}?${D.toString()}${window.location.hash}`;
852
852
  window.history.pushState({}, "", H), g(c), p(c);
853
853
  }
854
854
  }
855
855
  },
856
856
  [i.tenantMode, i.selectorParam, i.baseDomain, p]
857
- ), F = X(() => ({
857
+ ), F = Q(() => ({
858
858
  // Tenant info
859
859
  tenant: m,
860
860
  tenantSlug: a,
@@ -864,13 +864,13 @@ function zt({ config: i, children: e }) {
864
864
  a && p(a);
865
865
  },
866
866
  // Settings
867
- settings: D,
868
- settingsSchema: E,
867
+ settings: $,
868
+ settingsSchema: N,
869
869
  isSettingsLoading: P,
870
- settingsError: N,
870
+ settingsError: M,
871
871
  // Actions
872
872
  refreshSettings: C,
873
- switchTenant: M,
873
+ switchTenant: I,
874
874
  // Validation
875
875
  validateSettings: x
876
876
  }), [
@@ -878,27 +878,27 @@ function zt({ config: i, children: e }) {
878
878
  a,
879
879
  b,
880
880
  A,
881
- D,
882
- E,
883
- P,
881
+ $,
884
882
  N,
885
- C,
883
+ P,
886
884
  M,
885
+ C,
886
+ I,
887
887
  x
888
888
  ]);
889
- return /* @__PURE__ */ n(ke.Provider, { value: F, children: e });
889
+ return /* @__PURE__ */ n(xe.Provider, { value: F, children: e });
890
890
  }
891
891
  function me() {
892
- const i = ne(ke);
892
+ const i = se(xe);
893
893
  if (!i)
894
894
  throw new Error("useTenant must be used within a TenantProvider");
895
895
  return i;
896
896
  }
897
897
  function ye() {
898
- return ne(ke);
898
+ return se(xe);
899
899
  }
900
- const Ot = me;
901
- function Wt() {
900
+ const Wt = me;
901
+ function jt() {
902
902
  const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
903
903
  return {
904
904
  settings: i,
@@ -918,26 +918,31 @@ function le() {
918
918
  retry: s
919
919
  };
920
920
  }
921
- const xe = ue(null);
922
- function jt({ config: i = {}, children: e }) {
923
- const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A, L] = S(!1), [D, R] = S(null), [P, u] = S(0), [N, z] = S(!1), E = Ge({ done: !1, urlTokens: null });
924
- E.current.done || (E.current.done = !0, E.current.urlTokens = rt(), E.current.urlTokens && console.log("[AuthProvider] SYNC: URL tokens found"));
925
- const p = X(() => {
926
- const $ = new be({
921
+ const Ae = ue(null);
922
+ function Vt({ config: i = {}, children: e }) {
923
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A, E] = S(!1), [$, L] = S(null), [P, u] = S(0), M = Ge({ done: !1, urlTokens: null });
924
+ M.current.done || (M.current.done = !0, M.current.urlTokens = rt(), M.current.urlTokens && console.log(
925
+ "[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
926
+ ));
927
+ const [z, N] = S(() => {
928
+ const D = M.current.urlTokens !== null;
929
+ return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", D), D;
930
+ }), p = Q(() => {
931
+ const D = new Se({
927
932
  tenantSlug: o,
928
933
  onRefreshFailed: i.onRefreshFailed,
929
934
  baseUrl: r
930
935
  });
931
- return E.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), $.setTokens({
932
- accessToken: E.current.urlTokens.accessToken,
933
- refreshToken: E.current.urlTokens.refreshToken,
934
- expiresIn: E.current.urlTokens.expiresIn
935
- }), console.log("[AuthProvider] SYNC: Session valid:", $.hasValidSession())), $;
936
- }, [o, r, i.onRefreshFailed]), O = E.current.done && !N, v = X(() => {
937
- const $ = new re(r);
938
- return $.setSessionManager(p), $;
939
- }, [r, p]), C = X(() => new Ke(new re(r)), [r]), x = X(() => new Je(v, p), [v, p]), M = X(() => new Me(new re(r)), [r]), F = X(() => b || p.getUser(), [b, p]), c = X(() => F != null && F.roleId && g.find(($) => $.id === F.roleId) || null, [F, g]), I = X(() => (c == null ? void 0 : c.permissions) || [], [c]), T = X(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = X(() => {
940
- const $ = async (q = !1) => {
936
+ return M.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), D.setTokens({
937
+ accessToken: M.current.urlTokens.accessToken,
938
+ refreshToken: M.current.urlTokens.refreshToken,
939
+ expiresIn: M.current.urlTokens.expiresIn
940
+ }), console.log("[AuthProvider] SYNC: Session valid:", D.hasValidSession())), D;
941
+ }, [o, r, i.onRefreshFailed]), O = M.current.done && !z, v = Q(() => {
942
+ const D = new ne(r);
943
+ return D.setSessionManager(p), D;
944
+ }, [r, p]), C = Q(() => new Ke(new ne(r)), [r]), x = Q(() => new Je(v, p), [v, p]), I = Q(() => new Ie(new ne(r)), [r]), F = Q(() => b || p.getUser(), [b, p]), c = Q(() => F != null && F.roleId && g.find((D) => D.id === F.roleId) || null, [F, g]), R = Q(() => (c == null ? void 0 : c.permissions) || [], [c]), T = Q(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = Q(() => {
945
+ const D = async (q = !1) => {
941
946
  try {
942
947
  if (!p.hasValidSession())
943
948
  return;
@@ -949,136 +954,137 @@ function jt({ config: i = {}, children: e }) {
949
954
  console.warn("[AuthProvider] No userId available in token or storage");
950
955
  return;
951
956
  }
952
- L(!0), R(null);
957
+ E(!0), L(null);
953
958
  const Z = await x.getUserById(_);
954
959
  f(Z), p.setUser(Z), u(Date.now());
955
960
  } catch (W) {
956
- const Y = W instanceof Error ? W : new Error("Failed to load user data");
957
- R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
961
+ const J = W instanceof Error ? W : new Error("Failed to load user data");
962
+ L(J), console.error("[AuthProvider] Failed to load user data:", J);
958
963
  } finally {
959
- L(!1);
964
+ E(!1);
960
965
  }
961
966
  }, H = async () => {
962
- await $();
967
+ await D();
963
968
  }, U = async (q) => {
964
- const { username: W, password: Y, tenantSlug: _ } = q;
965
- let Z = s == null ? void 0 : s.id, Q = o, ee = p;
966
- _ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
967
- const K = await C.login({
969
+ const { username: W, password: J, tenantSlug: _, redirectPath: Z } = q;
970
+ let ee = s == null ? void 0 : s.id, X = o, Y = p;
971
+ _ && (ee = (await new de(v, t).getPublicTenantInfo(_)).id, X = _);
972
+ const te = await C.login({
968
973
  username: W,
969
- password: Y,
974
+ password: J,
970
975
  appId: t,
971
- tenantId: Z
972
- }), ae = _ && _ !== o;
973
- if (ae && (ee = new be({
974
- tenantSlug: Q,
976
+ tenantId: ee
977
+ }), ce = _ && _ !== o;
978
+ if (ce && (Y = new Se({
979
+ tenantSlug: X,
975
980
  baseUrl: r
976
- })), ee.setTokens({
977
- accessToken: K.accessToken,
978
- refreshToken: K.refreshToken,
979
- expiresIn: K.expiresIn
980
- }), K.user) {
981
- ee.setUser(K.user), f(K.user);
981
+ })), Y.setTokens({
982
+ accessToken: te.accessToken,
983
+ refreshToken: te.refreshToken,
984
+ expiresIn: te.expiresIn
985
+ }), te.user) {
986
+ Y.setUser(te.user), f(te.user);
982
987
  try {
983
- await $();
984
- } catch (ce) {
985
- console.warn("Failed to load complete user data after login:", ce);
988
+ await D();
989
+ } catch (be) {
990
+ console.warn("Failed to load complete user data after login:", be);
986
991
  }
987
992
  }
988
- return ae && Q && Q !== o && a(Q, {
993
+ return ce && X && X !== o && a(X, {
989
994
  tokens: {
990
- accessToken: K.accessToken,
991
- refreshToken: K.refreshToken,
992
- expiresIn: K.expiresIn
993
- }
994
- }), K;
995
+ accessToken: te.accessToken,
996
+ refreshToken: te.refreshToken,
997
+ expiresIn: te.expiresIn
998
+ },
999
+ redirectPath: Z
1000
+ }), te;
995
1001
  }, V = async (q) => {
996
- const { email: W, phoneNumber: Y, name: _, password: Z, lastName: Q, tenantId: ee } = q;
997
- if (!W && !Y)
1002
+ const { email: W, phoneNumber: J, name: _, password: Z, lastName: ee, tenantId: X } = q;
1003
+ if (!W && !J)
998
1004
  throw new Error("Either email or phoneNumber is required");
999
1005
  if (!_ || !Z)
1000
1006
  throw new Error("Name and password are required");
1001
- const K = ee ?? (s == null ? void 0 : s.id);
1007
+ const Y = X ?? (s == null ? void 0 : s.id);
1002
1008
  return await C.signup({
1003
1009
  email: W,
1004
- phoneNumber: Y,
1010
+ phoneNumber: J,
1005
1011
  name: _,
1006
1012
  password: Z,
1007
- tenantId: K,
1008
- lastName: Q,
1013
+ tenantId: Y,
1014
+ lastName: ee,
1009
1015
  appId: t
1010
1016
  });
1011
1017
  }, B = async (q) => {
1012
- const { email: W, phoneNumber: Y, name: _, password: Z, tenantName: Q, lastName: ee } = q;
1013
- if (!W && !Y)
1018
+ const { email: W, phoneNumber: J, name: _, password: Z, tenantName: ee, lastName: X } = q;
1019
+ if (!W && !J)
1014
1020
  throw new Error("Either email or phoneNumber is required");
1015
- if (!_ || !Z || !Q)
1021
+ if (!_ || !Z || !ee)
1016
1022
  throw new Error("Name, password, and tenantName are required");
1017
1023
  return await C.signupTenantAdmin({
1018
1024
  email: W,
1019
- phoneNumber: Y,
1025
+ phoneNumber: J,
1020
1026
  name: _,
1021
1027
  password: Z,
1022
- tenantName: Q,
1028
+ tenantName: ee,
1023
1029
  appId: t,
1024
- lastName: ee
1030
+ lastName: X
1025
1031
  });
1026
- }, J = async (q) => {
1027
- const { currentPassword: W, newPassword: Y } = q, _ = await p.getAuthHeaders();
1028
- await C.changePassword({ currentPassword: W, newPassword: Y }, _);
1032
+ }, K = async (q) => {
1033
+ const { currentPassword: W, newPassword: J } = q, _ = await p.getAuthHeaders();
1034
+ await C.changePassword({ currentPassword: W, newPassword: J }, _);
1029
1035
  }, ge = async (q) => {
1030
- const { email: W, tenantId: Y } = q, _ = Y ?? (s == null ? void 0 : s.id);
1036
+ const { email: W, tenantId: J } = q, _ = J ?? (s == null ? void 0 : s.id);
1031
1037
  if (!_)
1032
1038
  throw new Error("tenantId is required for password reset");
1033
1039
  await C.requestPasswordReset({ email: W, tenantId: _ });
1034
- }, He = async (q) => {
1035
- const { token: W, newPassword: Y } = q;
1036
- await C.confirmPasswordReset({ token: W, newPassword: Y });
1037
1040
  }, Ne = async (q) => {
1038
- const { email: W, frontendUrl: Y, name: _, lastName: Z, tenantId: Q } = q, ee = Q ?? (s == null ? void 0 : s.id);
1039
- if (!ee)
1041
+ const { token: W, newPassword: J } = q;
1042
+ await C.confirmPasswordReset({ token: W, newPassword: J });
1043
+ }, Ue = async (q) => {
1044
+ const { email: W, frontendUrl: J, name: _, lastName: Z, tenantId: ee } = q, X = ee ?? (s == null ? void 0 : s.id);
1045
+ if (!X)
1040
1046
  throw new Error("tenantId is required for magic link authentication");
1041
1047
  return await C.sendMagicLink({
1042
1048
  email: W,
1043
- tenantId: ee,
1044
- frontendUrl: Y,
1049
+ tenantId: X,
1050
+ frontendUrl: J,
1045
1051
  name: _,
1046
1052
  lastName: Z,
1047
1053
  appId: t
1048
1054
  });
1049
- }, Ue = async (q) => {
1050
- const { token: W, email: Y, tenantSlug: _ } = q;
1051
- let Z = s == null ? void 0 : s.id, Q = o, ee = p;
1052
- _ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
1053
- const K = await C.verifyMagicLink({
1055
+ }, Be = async (q) => {
1056
+ const { token: W, email: J, tenantSlug: _ } = q;
1057
+ let Z = s == null ? void 0 : s.id, ee = o, X = p;
1058
+ _ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, ee = _);
1059
+ const Y = await C.verifyMagicLink({
1054
1060
  token: W,
1055
- email: Y,
1061
+ email: J,
1056
1062
  appId: t,
1057
1063
  tenantId: Z
1058
- }), ae = _ && _ !== o;
1059
- if (ae && (ee = new be({
1060
- tenantSlug: Q,
1064
+ }), te = _ && _ !== o;
1065
+ if (te && (X = new Se({
1066
+ tenantSlug: ee,
1061
1067
  baseUrl: r
1062
- })), ee.setTokens({
1063
- accessToken: K.accessToken,
1064
- refreshToken: K.refreshToken,
1065
- expiresIn: K.expiresIn
1066
- }), K.user) {
1067
- ee.setUser(K.user), f(K.user);
1068
+ })), X.setTokens({
1069
+ accessToken: Y.accessToken,
1070
+ refreshToken: Y.refreshToken,
1071
+ expiresIn: Y.expiresIn
1072
+ }), Y.user) {
1073
+ X.setUser(Y.user), f(Y.user);
1068
1074
  try {
1069
- await $();
1075
+ await D();
1070
1076
  } catch (ce) {
1071
1077
  console.warn("Failed to load complete user data after magic link login:", ce);
1072
1078
  }
1073
1079
  }
1074
- return ae && Q && Q !== o && a(Q, {
1080
+ return te && ee && ee !== o && a(ee, {
1075
1081
  tokens: {
1076
- accessToken: K.accessToken,
1077
- refreshToken: K.refreshToken,
1078
- expiresIn: K.expiresIn
1082
+ accessToken: Y.accessToken,
1083
+ refreshToken: Y.refreshToken,
1084
+ expiresIn: Y.expiresIn
1079
1085
  }
1080
- }), K;
1081
- }, Be = async () => {
1086
+ }), Y;
1087
+ }, qe = async () => {
1082
1088
  const q = p.getTokens();
1083
1089
  if (!(q != null && q.refreshToken))
1084
1090
  throw new Error("No refresh token available");
@@ -1090,32 +1096,32 @@ function jt({ config: i = {}, children: e }) {
1090
1096
  refreshToken: W.refreshToken || q.refreshToken,
1091
1097
  expiresIn: W.expiresIn
1092
1098
  });
1093
- }, qe = () => {
1094
- p.clearSession(), f(null), R(null);
1095
- }, ze = (q) => {
1099
+ }, ze = () => {
1100
+ p.clearSession(), f(null), L(null);
1101
+ }, Oe = (q) => {
1096
1102
  p.setTokens(q);
1097
- }, Oe = () => p.hasValidSession(), We = () => {
1098
- p.clearSession(), f(null), R(null);
1099
- }, je = async () => {
1103
+ }, We = () => p.hasValidSession(), je = () => {
1104
+ p.clearSession(), f(null), L(null);
1105
+ }, Ve = async () => {
1100
1106
  if (t)
1101
1107
  try {
1102
1108
  k(!0);
1103
- const { roles: q } = await M.getRolesByApp(t);
1109
+ const { roles: q } = await I.getRolesByApp(t);
1104
1110
  w(q);
1105
1111
  } catch (q) {
1106
1112
  console.error("Failed to fetch roles:", q);
1107
1113
  } finally {
1108
1114
  k(!1);
1109
1115
  }
1110
- }, Ve = async () => {
1111
- await je();
1116
+ }, _e = async () => {
1117
+ await Ve();
1112
1118
  }, we = (q) => {
1113
- if (!I || I.length === 0)
1119
+ if (!R || R.length === 0)
1114
1120
  return !1;
1115
1121
  if (typeof q == "string")
1116
- return I.includes(q);
1122
+ return R.includes(q);
1117
1123
  const W = `${q.resource}.${q.action}`;
1118
- return I.includes(W);
1124
+ return R.includes(W);
1119
1125
  };
1120
1126
  return {
1121
1127
  // RFC-003: Authentication state
@@ -1125,32 +1131,32 @@ function jt({ config: i = {}, children: e }) {
1125
1131
  login: U,
1126
1132
  signup: V,
1127
1133
  signupTenantAdmin: B,
1128
- sendMagicLink: Ne,
1129
- verifyMagicLink: Ue,
1130
- changePassword: J,
1134
+ sendMagicLink: Ue,
1135
+ verifyMagicLink: Be,
1136
+ changePassword: K,
1131
1137
  requestPasswordReset: ge,
1132
- confirmPasswordReset: He,
1133
- refreshToken: Be,
1134
- logout: qe,
1135
- setTokens: ze,
1136
- hasValidSession: Oe,
1137
- clearSession: We,
1138
+ confirmPasswordReset: Ne,
1139
+ refreshToken: qe,
1140
+ logout: ze,
1141
+ setTokens: Oe,
1142
+ hasValidSession: We,
1143
+ clearSession: je,
1138
1144
  currentUser: b,
1139
1145
  isUserLoading: A,
1140
- userError: D,
1141
- loadUserData: $,
1146
+ userError: $,
1147
+ loadUserData: D,
1142
1148
  refreshUser: H,
1143
1149
  isAuthInitializing: !O,
1144
1150
  isAuthReady: O,
1145
1151
  userRole: c,
1146
- userPermissions: I,
1152
+ userPermissions: R,
1147
1153
  availableRoles: g,
1148
1154
  rolesLoading: m,
1149
1155
  hasPermission: we,
1150
1156
  hasAnyPermission: (q) => q.some((W) => we(W)),
1151
1157
  hasAllPermissions: (q) => q.every((W) => we(W)),
1152
- getUserPermissionStrings: () => I || [],
1153
- refreshRoles: Ve
1158
+ getUserPermissionStrings: () => R || [],
1159
+ refreshRoles: _e
1154
1160
  };
1155
1161
  }, [
1156
1162
  T,
@@ -1158,7 +1164,7 @@ function jt({ config: i = {}, children: e }) {
1158
1164
  v,
1159
1165
  C,
1160
1166
  x,
1161
- M,
1167
+ I,
1162
1168
  t,
1163
1169
  s,
1164
1170
  o,
@@ -1166,18 +1172,18 @@ function jt({ config: i = {}, children: e }) {
1166
1172
  g,
1167
1173
  b,
1168
1174
  A,
1169
- D,
1175
+ $,
1170
1176
  O,
1171
1177
  c,
1172
- I,
1178
+ R,
1173
1179
  P,
1174
1180
  h
1175
1181
  ]);
1176
- te(() => {
1182
+ re(() => {
1177
1183
  !i.initialRoles && t && (async () => {
1178
1184
  try {
1179
1185
  k(!0);
1180
- const H = new re(r), U = new Me(H), { roles: V } = await U.getRolesByApp(t);
1186
+ const H = new ne(r), U = new Ie(H), { roles: V } = await U.getRolesByApp(t);
1181
1187
  w(V);
1182
1188
  } catch (H) {
1183
1189
  console.error("Failed to fetch roles:", H);
@@ -1187,36 +1193,36 @@ function jt({ config: i = {}, children: e }) {
1187
1193
  })();
1188
1194
  }, [t, r, i.initialRoles]);
1189
1195
  const [y, G] = S(!1);
1190
- return te(() => {
1191
- y || (G(!0), E.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), z(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch(($) => {
1192
- console.error("[AuthProvider] Failed to load user data:", $);
1196
+ return re(() => {
1197
+ y || (G(!0), M.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), N(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch((D) => {
1198
+ console.error("[AuthProvider] Failed to load user data:", D);
1193
1199
  }).finally(() => {
1194
- console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), z(!1);
1200
+ console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), N(!1);
1195
1201
  })));
1196
- }, [d, y]), te(() => {
1197
- const $ = p.getUser();
1198
- $ && p.hasValidSession() && f($);
1199
- }, [p]), te(() => {
1200
- y && (E.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
1202
+ }, [d, y]), re(() => {
1203
+ const D = p.getUser();
1204
+ D && p.hasValidSession() && f(D);
1205
+ }, [p]), re(() => {
1206
+ y && (M.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
1201
1207
  })));
1202
- }, [b, A, d, p, y]), te(() => {
1208
+ }, [b, A, d, p, y]), re(() => {
1203
1209
  if (!p.hasValidSession() || !b)
1204
1210
  return;
1205
- const $ = setInterval(() => {
1211
+ const D = setInterval(() => {
1206
1212
  d.loadUserData().catch(() => {
1207
1213
  });
1208
1214
  }, h);
1209
- return () => clearInterval($);
1210
- }, [p, b, d, h]), /* @__PURE__ */ n(xe.Provider, { value: d, children: e });
1215
+ return () => clearInterval(D);
1216
+ }, [p, b, d, h]), /* @__PURE__ */ n(Ae.Provider, { value: d, children: e });
1211
1217
  }
1212
- function oe() {
1213
- const i = ne(xe);
1218
+ function ae() {
1219
+ const i = se(Ae);
1214
1220
  if (!i)
1215
1221
  throw new Error("useAuth must be used within an AuthProvider");
1216
1222
  return i;
1217
1223
  }
1218
- function Fe() {
1219
- return ne(xe);
1224
+ function Ce() {
1225
+ return se(Ae);
1220
1226
  }
1221
1227
  class st {
1222
1228
  constructor(e, t) {
@@ -1298,42 +1304,42 @@ class st {
1298
1304
  })).data;
1299
1305
  }
1300
1306
  }
1301
- const Ae = ue(null);
1302
- function Vt({ config: i = {}, children: e }) {
1303
- const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A, L] = S(!1), D = X(() => {
1304
- const u = new re(s);
1307
+ const Te = ue(null);
1308
+ function _t({ config: i = {}, children: e }) {
1309
+ const t = Fe(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A, E] = S(!1), $ = Q(() => {
1310
+ const u = new ne(s);
1305
1311
  return new st(u);
1306
- }, [s]), R = async () => {
1312
+ }, [s]), L = async () => {
1307
1313
  if (!(a != null && a.id)) {
1308
1314
  w([]);
1309
1315
  return;
1310
1316
  }
1311
1317
  k(!0), f(null);
1312
1318
  try {
1313
- const u = await D.getTenantFeatureFlags(a.id, o);
1319
+ const u = await $.getTenantFeatureFlags(a.id, o);
1314
1320
  w(u);
1315
1321
  } catch (u) {
1316
- const N = u instanceof Error ? u.message : "Failed to fetch feature flags";
1317
- f(N), i.onError && i.onError(u instanceof Error ? u : new Error(N));
1322
+ const M = u instanceof Error ? u.message : "Failed to fetch feature flags";
1323
+ f(M), i.onError && i.onError(u instanceof Error ? u : new Error(M));
1318
1324
  } finally {
1319
1325
  k(!1);
1320
1326
  }
1321
1327
  };
1322
- te(() => {
1328
+ re(() => {
1323
1329
  if (!s || !o) return;
1324
- R().finally(() => L(!0));
1325
- const u = i.refreshInterval || 5 * 60 * 1e3, N = setInterval(R, u);
1326
- return () => clearInterval(N);
1330
+ L().finally(() => E(!0));
1331
+ const u = i.refreshInterval || 5 * 60 * 1e3, M = setInterval(L, u);
1332
+ return () => clearInterval(M);
1327
1333
  }, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
1328
- const P = X(() => {
1334
+ const P = Q(() => {
1329
1335
  const u = (O) => {
1330
1336
  const v = g.find((C) => C.key === O);
1331
1337
  return (v == null ? void 0 : v.value) === !0;
1332
- }, N = (O) => g.find((v) => v.key === O), z = (O) => {
1338
+ }, M = (O) => g.find((v) => v.key === O), z = (O) => {
1333
1339
  const v = g.find((C) => C.key === O);
1334
1340
  return v ? v.value ? "enabled" : "disabled" : "not_found";
1335
- }, E = async () => {
1336
- await R();
1341
+ }, N = async () => {
1342
+ await L();
1337
1343
  }, p = !!(s && o) && (A || !(a != null && a.id));
1338
1344
  return {
1339
1345
  featureFlags: g,
@@ -1341,21 +1347,21 @@ function Vt({ config: i = {}, children: e }) {
1341
1347
  error: b,
1342
1348
  isReady: p,
1343
1349
  isEnabled: u,
1344
- getFlag: N,
1350
+ getFlag: M,
1345
1351
  getFlagState: z,
1346
- refresh: E
1352
+ refresh: N
1347
1353
  };
1348
1354
  }, [g, m, b, s, o, a == null ? void 0 : a.id, A]);
1349
- return /* @__PURE__ */ n(Ae.Provider, { value: P, children: e });
1355
+ return /* @__PURE__ */ n(Te.Provider, { value: P, children: e });
1350
1356
  }
1351
1357
  function it() {
1352
- const i = ne(Ae);
1358
+ const i = se(Te);
1353
1359
  if (!i)
1354
1360
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1355
1361
  return i;
1356
1362
  }
1357
- function Ce() {
1358
- return ne(Ae);
1363
+ function De() {
1364
+ return se(Te);
1359
1365
  }
1360
1366
  class ot {
1361
1367
  constructor(e, t) {
@@ -1423,19 +1429,19 @@ class ot {
1423
1429
  )).data;
1424
1430
  }
1425
1431
  }
1426
- const Te = ue(void 0);
1427
- function _t({ config: i = {}, children: e }) {
1428
- const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1), L = X(() => {
1429
- const P = new re(s);
1432
+ const Pe = ue(void 0);
1433
+ function Gt({ config: i = {}, children: e }) {
1434
+ const t = Fe(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1), E = Q(() => {
1435
+ const P = new ne(s);
1430
1436
  return new ot(P);
1431
- }, [s]), D = async () => {
1437
+ }, [s]), $ = async () => {
1432
1438
  if (!(o != null && o.id)) {
1433
1439
  g(null);
1434
1440
  return;
1435
1441
  }
1436
1442
  m(!0), b(null);
1437
1443
  try {
1438
- const P = await L.getTenantSubscriptionFeatures(o.id);
1444
+ const P = await E.getTenantSubscriptionFeatures(o.id);
1439
1445
  g(P);
1440
1446
  } catch (P) {
1441
1447
  const u = P instanceof Error ? P.message : "Failed to fetch subscription";
@@ -1444,20 +1450,20 @@ function _t({ config: i = {}, children: e }) {
1444
1450
  m(!1);
1445
1451
  }
1446
1452
  };
1447
- te(() => {
1448
- if (!s || (D().finally(() => A(!0)), !i.refreshInterval)) return;
1449
- const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval(D, P);
1453
+ re(() => {
1454
+ if (!s || ($().finally(() => A(!0)), !i.refreshInterval)) return;
1455
+ const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval($, P);
1450
1456
  return () => clearInterval(u);
1451
1457
  }, [o == null ? void 0 : o.id, s, i.refreshInterval]);
1452
- const R = X(() => {
1458
+ const L = Q(() => {
1453
1459
  const P = (a == null ? void 0 : a.features) || [], u = (v) => {
1454
1460
  const C = P.find((x) => x.key === v);
1455
1461
  return C ? C.type === "BOOLEAN" || C.type === "boolean" ? C.value === !0 : !!C.value : !1;
1456
- }, N = (v) => P.find((C) => C.key === v), z = (v, C) => {
1457
- const x = P.find((M) => M.key === v);
1462
+ }, M = (v) => P.find((C) => C.key === v), z = (v, C) => {
1463
+ const x = P.find((I) => I.key === v);
1458
1464
  return x ? x.value : C;
1459
- }, E = (v) => !a || !a.isActive ? !1 : v.includes(a.planId), p = async () => {
1460
- await D();
1465
+ }, N = (v) => !a || !a.isActive ? !1 : v.includes(a.planId), p = async () => {
1466
+ await $();
1461
1467
  }, O = !!s && (f || !(o != null && o.id));
1462
1468
  return {
1463
1469
  subscription: a,
@@ -1466,25 +1472,25 @@ function _t({ config: i = {}, children: e }) {
1466
1472
  error: k,
1467
1473
  isReady: O,
1468
1474
  isFeatureEnabled: u,
1469
- getFeature: N,
1475
+ getFeature: M,
1470
1476
  getFeatureValue: z,
1471
- hasAllowedPlan: E,
1477
+ hasAllowedPlan: N,
1472
1478
  refresh: p
1473
1479
  };
1474
1480
  }, [a, w, k, s, o == null ? void 0 : o.id, f]);
1475
- return /* @__PURE__ */ n(Te.Provider, { value: R, children: e });
1481
+ return /* @__PURE__ */ n(Pe.Provider, { value: L, children: e });
1476
1482
  }
1477
1483
  function at() {
1478
- const i = ne(Te);
1484
+ const i = se(Pe);
1479
1485
  if (i === void 0)
1480
1486
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1481
1487
  return i;
1482
1488
  }
1483
- function De() {
1484
- return ne(Te) ?? null;
1489
+ function $e() {
1490
+ return se(Pe) ?? null;
1485
1491
  }
1486
- var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
1487
- const Ie = () => /* @__PURE__ */ l(
1492
+ var oe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(oe || {});
1493
+ const Re = () => /* @__PURE__ */ l(
1488
1494
  "div",
1489
1495
  {
1490
1496
  style: {
@@ -1521,7 +1527,7 @@ const Ie = () => /* @__PURE__ */ l(
1521
1527
  )
1522
1528
  ]
1523
1529
  }
1524
- ), Re = ({
1530
+ ), Le = ({
1525
1531
  userType: i,
1526
1532
  minUserType: e,
1527
1533
  missingPermissions: t
@@ -1564,30 +1570,30 @@ const Ie = () => /* @__PURE__ */ l(
1564
1570
  }
1565
1571
  ), lt = (i, e) => {
1566
1572
  const t = {
1567
- [ie.USER]: 1,
1568
- [ie.TENANT_ADMIN]: 2,
1569
- [ie.SUPERUSER]: 3
1573
+ [oe.USER]: 1,
1574
+ [oe.TENANT_ADMIN]: 2,
1575
+ [oe.SUPERUSER]: 3
1570
1576
  };
1571
1577
  return t[i] >= t[e];
1572
1578
  };
1573
- function Gt({
1579
+ function Kt({
1574
1580
  children: i,
1575
1581
  fallback: e,
1576
1582
  minUserType: t,
1577
1583
  requiredPermissions: r,
1578
1584
  requireAllPermissions: s = !1
1579
1585
  }) {
1580
- const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } = oe();
1586
+ const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } = ae();
1581
1587
  if (!o())
1582
- return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
1588
+ return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Re, {}) });
1583
1589
  const k = a.getUser();
1584
1590
  if (!k)
1585
- return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
1591
+ return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Re, {}) });
1586
1592
  if (t && !lt(k.userType, t))
1587
- return /* @__PURE__ */ n(Re, { userType: k.userType, minUserType: t });
1593
+ return /* @__PURE__ */ n(Le, { userType: k.userType, minUserType: t });
1588
1594
  if (r && r.length > 0 && !(s ? m(r) : w(r))) {
1589
1595
  const f = r.filter((A) => !g(A)).map((A) => typeof A == "string" ? A : A.name);
1590
- return /* @__PURE__ */ n(Re, { missingPermissions: f });
1596
+ return /* @__PURE__ */ n(Le, { missingPermissions: f });
1591
1597
  }
1592
1598
  return /* @__PURE__ */ n(j, { children: i });
1593
1599
  }
@@ -1627,7 +1633,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
1627
1633
  }
1628
1634
  )
1629
1635
  }
1630
- ), Le = ({
1636
+ ), Ee = ({
1631
1637
  userType: i,
1632
1638
  minUserType: e,
1633
1639
  missingPermissions: t
@@ -1680,13 +1686,13 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
1680
1686
  }
1681
1687
  ), dt = (i, e) => {
1682
1688
  const t = {
1683
- [ie.USER]: 1,
1684
- [ie.TENANT_ADMIN]: 2,
1685
- [ie.SUPERUSER]: 3
1689
+ [oe.USER]: 1,
1690
+ [oe.TENANT_ADMIN]: 2,
1691
+ [oe.SUPERUSER]: 3
1686
1692
  };
1687
1693
  return t[i] >= t[e];
1688
1694
  };
1689
- function Kt({
1695
+ function Jt({
1690
1696
  children: i,
1691
1697
  redirectTo: e = "/login",
1692
1698
  minUserType: t,
@@ -1694,7 +1700,7 @@ function Kt({
1694
1700
  requireAllPermissions: s = !1,
1695
1701
  fallback: o
1696
1702
  }) {
1697
- const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } = oe(), b = Se();
1703
+ const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } = ae(), b = ve();
1698
1704
  if (!a())
1699
1705
  return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ l(j, { children: [
1700
1706
  /* @__PURE__ */ n(ct, { redirectPath: e }),
@@ -1704,10 +1710,10 @@ function Kt({
1704
1710
  if (!f)
1705
1711
  return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
1706
1712
  if (t && !dt(f.userType, t))
1707
- return /* @__PURE__ */ n(Le, { userType: f.userType, minUserType: t });
1713
+ return /* @__PURE__ */ n(Ee, { userType: f.userType, minUserType: t });
1708
1714
  if (r && r.length > 0 && !(s ? k(r) : m(r))) {
1709
- const L = r.filter((D) => !w(D)).map((D) => typeof D == "string" ? D : D.name);
1710
- return /* @__PURE__ */ n(Le, { missingPermissions: L });
1715
+ const E = r.filter(($) => !w($)).map(($) => typeof $ == "string" ? $ : $.name);
1716
+ return /* @__PURE__ */ n(Ee, { missingPermissions: E });
1711
1717
  }
1712
1718
  return /* @__PURE__ */ n(j, { children: i });
1713
1719
  }
@@ -1748,8 +1754,8 @@ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
1748
1754
  )
1749
1755
  }
1750
1756
  );
1751
- function Jt({ children: i, redirectTo: e = "/", fallback: t }) {
1752
- const { tenant: r, isLoading: s, error: o } = le(), a = Se();
1757
+ function Yt({ children: i, redirectTo: e = "/", fallback: t }) {
1758
+ const { tenant: r, isLoading: s, error: o } = le(), a = ve();
1753
1759
  return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
1754
1760
  /* @__PURE__ */ n(ut, { redirectPath: e }),
1755
1761
  /* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
@@ -1792,8 +1798,8 @@ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
1792
1798
  )
1793
1799
  }
1794
1800
  );
1795
- function Yt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1796
- const { tenant: r, isLoading: s, error: o } = le(), a = Se();
1801
+ function Qt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1802
+ const { tenant: r, isLoading: s, error: o } = le(), a = ve();
1797
1803
  return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
1798
1804
  /* @__PURE__ */ n(ht, { redirectPath: e }),
1799
1805
  /* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
@@ -1816,7 +1822,7 @@ const gt = () => /* @__PURE__ */ l(
1816
1822
  ]
1817
1823
  }
1818
1824
  );
1819
- function Qt({
1825
+ function Xt({
1820
1826
  children: i,
1821
1827
  fallback: e = /* @__PURE__ */ n(gt, {}),
1822
1828
  allowedPlans: t,
@@ -1862,7 +1868,7 @@ const pt = ({ flagName: i }) => /* @__PURE__ */ l(
1862
1868
  ]
1863
1869
  }
1864
1870
  );
1865
- function Xt({ name: i, children: e, fallback: t }) {
1871
+ function Zt({ name: i, children: e, fallback: t }) {
1866
1872
  const { isEnabled: r, loading: s } = it();
1867
1873
  return s ? /* @__PURE__ */ n(
1868
1874
  "div",
@@ -2037,7 +2043,7 @@ const ft = () => /* @__PURE__ */ l(
2037
2043
  fontSize: "0.875rem"
2038
2044
  }
2039
2045
  };
2040
- function Zt({
2046
+ function er({
2041
2047
  copy: i = {},
2042
2048
  styles: e = {},
2043
2049
  icons: t = {},
@@ -2051,43 +2057,43 @@ function Zt({
2051
2057
  showMagicLinkOption: k = !0,
2052
2058
  className: b
2053
2059
  }) {
2054
- const [f, A] = S(""), [L, D] = S(""), [R, P] = S(!1), [u, N] = S(!1), [z, E] = S(""), [p, O] = S({}), { login: v } = oe(), { tenant: C } = le(), x = { ...wt, ...i }, M = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
2060
+ const [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S({}), { login: v } = ae(), { tenant: C } = le(), x = { ...wt, ...i }, I = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
2055
2061
  const d = {};
2056
- return f.trim() || (d.username = !0), L.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
2057
- }, I = async (d) => {
2062
+ return f.trim() || (d.username = !0), E.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
2063
+ }, R = async (d) => {
2058
2064
  if (d.preventDefault(), !!c()) {
2059
2065
  if (!(C != null && C.id)) {
2060
- E("Tenant not found");
2066
+ N("Tenant not found");
2061
2067
  return;
2062
2068
  }
2063
- N(!0), E("");
2069
+ M(!0), N("");
2064
2070
  try {
2065
2071
  const y = await v({
2066
2072
  username: f,
2067
- password: L
2073
+ password: E
2068
2074
  // tenantId inferred from context automatically
2069
2075
  });
2070
2076
  r == null || r(y);
2071
2077
  } catch (y) {
2072
2078
  const G = y.message || x.errorMessage;
2073
- E(G), s == null || s(G);
2079
+ N(G), s == null || s(G);
2074
2080
  } finally {
2075
- N(!1);
2081
+ M(!1);
2076
2082
  }
2077
2083
  }
2078
2084
  }, T = (d) => ({
2079
- ...M.input,
2080
- ...p[d] ? M.inputError : {}
2085
+ ...I.input,
2086
+ ...p[d] ? I.inputError : {}
2081
2087
  }), h = () => ({
2082
- ...M.button,
2083
- ...u ? M.buttonLoading : {},
2084
- ...!f || !L || u ? M.buttonDisabled : {}
2088
+ ...I.button,
2089
+ ...u ? I.buttonLoading : {},
2090
+ ...!f || !E || u ? I.buttonDisabled : {}
2085
2091
  });
2086
- return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
2087
- /* @__PURE__ */ n("h2", { style: M.title, children: x.title }),
2088
- /* @__PURE__ */ l("form", { onSubmit: I, style: M.form, children: [
2089
- /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2090
- /* @__PURE__ */ n("label", { style: M.label, children: x.usernameLabel }),
2092
+ return /* @__PURE__ */ l("div", { className: b, style: I.container, children: [
2093
+ /* @__PURE__ */ n("h2", { style: I.title, children: x.title }),
2094
+ /* @__PURE__ */ l("form", { onSubmit: R, style: I.form, children: [
2095
+ /* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
2096
+ /* @__PURE__ */ n("label", { style: I.label, children: x.usernameLabel }),
2091
2097
  /* @__PURE__ */ n(
2092
2098
  "input",
2093
2099
  {
@@ -2104,18 +2110,18 @@ function Zt({
2104
2110
  }
2105
2111
  )
2106
2112
  ] }),
2107
- /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2108
- /* @__PURE__ */ n("label", { style: M.label, children: x.passwordLabel }),
2109
- /* @__PURE__ */ l("div", { style: M.inputContainer, children: [
2113
+ /* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
2114
+ /* @__PURE__ */ n("label", { style: I.label, children: x.passwordLabel }),
2115
+ /* @__PURE__ */ l("div", { style: I.inputContainer, children: [
2110
2116
  /* @__PURE__ */ n(
2111
2117
  "input",
2112
2118
  {
2113
2119
  id: "password",
2114
2120
  name: "password",
2115
- type: R ? "text" : "password",
2116
- value: L,
2121
+ type: L ? "text" : "password",
2122
+ value: E,
2117
2123
  onChange: (d) => {
2118
- D(d.target.value), p.password && O((y) => ({ ...y, password: !1 }));
2124
+ $(d.target.value), p.password && O((y) => ({ ...y, password: !1 }));
2119
2125
  },
2120
2126
  placeholder: x.passwordPlaceholder,
2121
2127
  style: {
@@ -2130,35 +2136,35 @@ function Zt({
2130
2136
  "button",
2131
2137
  {
2132
2138
  type: "button",
2133
- onClick: () => P(!R),
2134
- style: M.passwordToggle,
2139
+ onClick: () => P(!L),
2140
+ style: I.passwordToggle,
2135
2141
  disabled: u,
2136
- "aria-label": R ? "Hide password" : "Show password",
2137
- children: R ? F.hidePassword : F.showPassword
2142
+ "aria-label": L ? "Hide password" : "Show password",
2143
+ children: L ? F.hidePassword : F.showPassword
2138
2144
  }
2139
2145
  )
2140
2146
  ] })
2141
2147
  ] }),
2142
- /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !L || u, style: h(), children: u ? x.loadingText : x.submitButton }),
2143
- z && /* @__PURE__ */ n("div", { style: M.errorText, children: z })
2148
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !E || u, style: h(), children: u ? x.loadingText : x.submitButton }),
2149
+ z && /* @__PURE__ */ n("div", { style: I.errorText, children: z })
2144
2150
  ] }),
2145
- (w || m || k) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2151
+ (w || m || k) && /* @__PURE__ */ l("div", { style: I.linkContainer, children: [
2146
2152
  k && /* @__PURE__ */ l("div", { children: [
2147
- /* @__PURE__ */ l("span", { style: M.divider, children: [
2153
+ /* @__PURE__ */ l("span", { style: I.divider, children: [
2148
2154
  x.magicLinkText,
2149
2155
  " "
2150
2156
  ] }),
2151
- /* @__PURE__ */ n("a", { onClick: g, style: M.link, children: x.magicLinkLink })
2157
+ /* @__PURE__ */ n("a", { onClick: g, style: I.link, children: x.magicLinkLink })
2152
2158
  ] }),
2153
- k && (w || m) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2154
- w && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: x.forgotPasswordLink }),
2155
- w && m && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2159
+ k && (w || m) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2160
+ w && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: x.forgotPasswordLink }),
2161
+ w && m && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2156
2162
  m && /* @__PURE__ */ l("div", { children: [
2157
- /* @__PURE__ */ l("span", { style: M.divider, children: [
2163
+ /* @__PURE__ */ l("span", { style: I.divider, children: [
2158
2164
  x.signupText,
2159
2165
  " "
2160
2166
  ] }),
2161
- /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: x.signupLink })
2167
+ /* @__PURE__ */ n("a", { onClick: a, style: I.link, children: x.signupLink })
2162
2168
  ] })
2163
2169
  ] })
2164
2170
  ] });
@@ -2288,7 +2294,7 @@ const St = {
2288
2294
  fontSize: "0.875rem"
2289
2295
  }
2290
2296
  };
2291
- function er({
2297
+ function tr({
2292
2298
  copy: i = {},
2293
2299
  styles: e = {},
2294
2300
  signupType: t = "user",
@@ -2300,40 +2306,40 @@ function er({
2300
2306
  showMagicLinkOption: w = !0,
2301
2307
  className: m
2302
2308
  }) {
2303
- const [k, b] = S(""), [f, A] = S(""), [L, D] = S(""), [R, P] = S(""), [u, N] = S(""), [z, E] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, M] = S(""), [F, c] = S({}), { signup: I, signupTenantAdmin: T } = oe(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
2309
+ const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(""), [u, M] = S(""), [z, N] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, I] = S(""), [F, c] = S({}), { signup: R, signupTenantAdmin: T } = ae(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
2304
2310
  const B = {};
2305
- return k.trim() || (B.name = !0), !L.trim() && !R.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), z.trim() || (B.confirmPassword = !0), t === "tenant" && !p.trim() && (B.tenantName = !0), c(B), Object.keys(B).length === 0;
2306
- }, $ = async (B) => {
2311
+ return k.trim() || (B.name = !0), !E.trim() && !L.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), z.trim() || (B.confirmPassword = !0), t === "tenant" && !p.trim() && (B.tenantName = !0), c(B), Object.keys(B).length === 0;
2312
+ }, D = async (B) => {
2307
2313
  if (B.preventDefault(), !!G()) {
2308
2314
  if (u !== z) {
2309
- M(d.passwordMismatchError), c({ confirmPassword: !0 });
2315
+ I(d.passwordMismatchError), c({ confirmPassword: !0 });
2310
2316
  return;
2311
2317
  }
2312
2318
  if (t === "user" && !(h != null && h.id)) {
2313
- M("Tenant not found");
2319
+ I("Tenant not found");
2314
2320
  return;
2315
2321
  }
2316
- C(!0), M("");
2322
+ C(!0), I("");
2317
2323
  try {
2318
- let J;
2319
- t === "tenant" ? J = await T({
2320
- email: L || void 0,
2321
- phoneNumber: R || void 0,
2324
+ let K;
2325
+ t === "tenant" ? K = await T({
2326
+ email: E || void 0,
2327
+ phoneNumber: L || void 0,
2322
2328
  name: k,
2323
2329
  password: u,
2324
2330
  tenantName: p,
2325
2331
  lastName: f || void 0
2326
- }) : J = await I({
2327
- email: L || void 0,
2328
- phoneNumber: R || void 0,
2332
+ }) : K = await R({
2333
+ email: E || void 0,
2334
+ phoneNumber: L || void 0,
2329
2335
  name: k,
2330
2336
  password: u,
2331
2337
  tenantId: h.id,
2332
2338
  lastName: f || void 0
2333
- }), r == null || r(J);
2334
- } catch (J) {
2335
- const ge = J.message || d.errorMessage;
2336
- M(ge), s == null || s(ge);
2339
+ }), r == null || r(K);
2340
+ } catch (K) {
2341
+ const ge = K.message || d.errorMessage;
2342
+ I(ge), s == null || s(ge);
2337
2343
  } finally {
2338
2344
  C(!1);
2339
2345
  }
@@ -2344,11 +2350,11 @@ function er({
2344
2350
  }), U = () => ({
2345
2351
  ...y.button,
2346
2352
  ...v ? y.buttonLoading : {},
2347
- ...!k || !L && !R || !u || !z || v || t === "tenant" && !p ? y.buttonDisabled : {}
2348
- }), V = k && (L || R) && u && z && (t === "user" || p);
2353
+ ...!k || !E && !L || !u || !z || v || t === "tenant" && !p ? y.buttonDisabled : {}
2354
+ }), V = k && (E || L) && u && z && (t === "user" || p);
2349
2355
  return /* @__PURE__ */ l("div", { className: m, style: y.container, children: [
2350
2356
  /* @__PURE__ */ n("h2", { style: y.title, children: d.title }),
2351
- /* @__PURE__ */ l("form", { onSubmit: $, style: y.form, children: [
2357
+ /* @__PURE__ */ l("form", { onSubmit: D, style: y.form, children: [
2352
2358
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2353
2359
  /* @__PURE__ */ n("label", { style: y.label, children: d.nameLabel }),
2354
2360
  /* @__PURE__ */ n(
@@ -2359,7 +2365,7 @@ function er({
2359
2365
  type: "text",
2360
2366
  value: k,
2361
2367
  onChange: (B) => {
2362
- b(B.target.value), F.name && c((J) => ({ ...J, name: !1 }));
2368
+ b(B.target.value), F.name && c((K) => ({ ...K, name: !1 }));
2363
2369
  },
2364
2370
  placeholder: d.namePlaceholder,
2365
2371
  style: H("name"),
@@ -2391,9 +2397,9 @@ function er({
2391
2397
  id: "email",
2392
2398
  name: "email",
2393
2399
  type: "email",
2394
- value: L,
2400
+ value: E,
2395
2401
  onChange: (B) => {
2396
- D(B.target.value), F.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2402
+ $(B.target.value), F.email && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2397
2403
  },
2398
2404
  placeholder: d.emailPlaceholder,
2399
2405
  style: H("email"),
@@ -2409,9 +2415,9 @@ function er({
2409
2415
  id: "phoneNumber",
2410
2416
  name: "phoneNumber",
2411
2417
  type: "tel",
2412
- value: R,
2418
+ value: L,
2413
2419
  onChange: (B) => {
2414
- P(B.target.value), F.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2420
+ P(B.target.value), F.phoneNumber && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2415
2421
  },
2416
2422
  placeholder: d.phoneNumberPlaceholder,
2417
2423
  style: H("phoneNumber"),
@@ -2441,7 +2447,7 @@ function er({
2441
2447
  type: "password",
2442
2448
  value: u,
2443
2449
  onChange: (B) => {
2444
- N(B.target.value), F.password && c((J) => ({ ...J, password: !1 }));
2450
+ M(B.target.value), F.password && c((K) => ({ ...K, password: !1 }));
2445
2451
  },
2446
2452
  placeholder: d.passwordPlaceholder,
2447
2453
  style: H("password"),
@@ -2459,7 +2465,7 @@ function er({
2459
2465
  type: "password",
2460
2466
  value: z,
2461
2467
  onChange: (B) => {
2462
- E(B.target.value), F.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === d.passwordMismatchError && M("");
2468
+ N(B.target.value), F.confirmPassword && c((K) => ({ ...K, confirmPassword: !1 })), x === d.passwordMismatchError && I("");
2463
2469
  },
2464
2470
  placeholder: d.confirmPasswordPlaceholder,
2465
2471
  style: H("confirmPassword"),
@@ -2477,7 +2483,7 @@ function er({
2477
2483
  type: "text",
2478
2484
  value: p,
2479
2485
  onChange: (B) => {
2480
- O(B.target.value), F.tenantName && c((J) => ({ ...J, tenantName: !1 }));
2486
+ O(B.target.value), F.tenantName && c((K) => ({ ...K, tenantName: !1 }));
2481
2487
  },
2482
2488
  placeholder: d.tenantNamePlaceholder,
2483
2489
  style: H("tenantName"),
@@ -2628,7 +2634,7 @@ const kt = {
2628
2634
  fontSize: "0.875rem"
2629
2635
  }
2630
2636
  };
2631
- function tr({
2637
+ function rr({
2632
2638
  copy: i = {},
2633
2639
  styles: e = {},
2634
2640
  onSuccess: t,
@@ -2640,16 +2646,16 @@ function tr({
2640
2646
  verifyToken: w,
2641
2647
  frontendUrl: m
2642
2648
  }) {
2643
- const [k, b] = S(""), [f, A] = S(""), [L, D] = S(""), [R, P] = S(!1), [u, N] = S(!1), [z, E] = S(""), [p, O] = S(""), [v, C] = S({}), [x, M] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = oe(), { tenant: I } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
2644
- te(() => {
2649
+ const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S(""), [v, C] = S({}), [x, I] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = ae(), { tenant: R } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
2650
+ re(() => {
2645
2651
  w && d(w);
2646
2652
  }, [w]);
2647
2653
  const d = async (U) => {
2648
- if (!I || !k) {
2649
- E("Missing tenant or email");
2654
+ if (!R || !k) {
2655
+ N("Missing tenant or email");
2650
2656
  return;
2651
2657
  }
2652
- N(!0), E("");
2658
+ M(!0), N("");
2653
2659
  try {
2654
2660
  const V = await c({
2655
2661
  token: U,
@@ -2659,43 +2665,43 @@ function tr({
2659
2665
  t == null || t(V);
2660
2666
  } catch (V) {
2661
2667
  const B = V.message || "Failed to verify magic link";
2662
- E(B), r == null || r(B);
2668
+ N(B), r == null || r(B);
2663
2669
  } finally {
2664
- N(!1);
2670
+ M(!1);
2665
2671
  }
2666
2672
  }, y = () => {
2667
2673
  const U = {};
2668
2674
  return k.trim() || (U.email = !0), x && !f.trim() && (U.name = !0), C(U), Object.keys(U).length === 0;
2669
2675
  }, G = async (U) => {
2670
2676
  if (U.preventDefault(), !!y()) {
2671
- if (!(I != null && I.id)) {
2672
- E("Tenant not found");
2677
+ if (!(R != null && R.id)) {
2678
+ N("Tenant not found");
2673
2679
  return;
2674
2680
  }
2675
- P(!0), E(""), O("");
2681
+ P(!0), N(""), O("");
2676
2682
  try {
2677
2683
  const V = m || (typeof window < "u" ? window.location.origin : ""), B = await F({
2678
2684
  email: k,
2679
- tenantId: I.id,
2685
+ tenantId: R.id,
2680
2686
  frontendUrl: V,
2681
2687
  name: x ? f : void 0,
2682
- lastName: x ? L : void 0
2688
+ lastName: x ? E : void 0
2683
2689
  });
2684
2690
  O(T.successMessage), t == null || t(B);
2685
2691
  } catch (V) {
2686
2692
  const B = V.message || T.errorMessage;
2687
- E(B), r == null || r(B);
2693
+ N(B), r == null || r(B);
2688
2694
  } finally {
2689
2695
  P(!1);
2690
2696
  }
2691
2697
  }
2692
- }, $ = (U) => ({
2698
+ }, D = (U) => ({
2693
2699
  ...h.input,
2694
2700
  ...v[U] ? h.inputError : {}
2695
2701
  }), H = () => ({
2696
2702
  ...h.button,
2697
- ...R || u ? h.buttonLoading : {},
2698
- ...!k || R || u ? h.buttonDisabled : {}
2703
+ ...L || u ? h.buttonLoading : {},
2704
+ ...!k || L || u ? h.buttonDisabled : {}
2699
2705
  });
2700
2706
  return u ? /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
2701
2707
  /* @__PURE__ */ n("h2", { style: h.title, children: T.verifyingText }),
@@ -2717,8 +2723,8 @@ function tr({
2717
2723
  b(U.target.value), v.email && C((V) => ({ ...V, email: !1 }));
2718
2724
  },
2719
2725
  placeholder: T.emailPlaceholder,
2720
- style: $("email"),
2721
- disabled: R || u
2726
+ style: D("email"),
2727
+ disabled: L || u
2722
2728
  }
2723
2729
  )
2724
2730
  ] }),
@@ -2726,7 +2732,7 @@ function tr({
2726
2732
  "button",
2727
2733
  {
2728
2734
  type: "button",
2729
- onClick: () => M(!0),
2735
+ onClick: () => I(!0),
2730
2736
  style: {
2731
2737
  background: "none",
2732
2738
  border: "none",
@@ -2752,8 +2758,8 @@ function tr({
2752
2758
  A(U.target.value), v.name && C((V) => ({ ...V, name: !1 }));
2753
2759
  },
2754
2760
  placeholder: T.namePlaceholder,
2755
- style: $("name"),
2756
- disabled: R || u
2761
+ style: D("name"),
2762
+ disabled: L || u
2757
2763
  }
2758
2764
  )
2759
2765
  ] }),
@@ -2765,11 +2771,11 @@ function tr({
2765
2771
  id: "lastName",
2766
2772
  name: "lastName",
2767
2773
  type: "text",
2768
- value: L,
2769
- onChange: (U) => D(U.target.value),
2774
+ value: E,
2775
+ onChange: (U) => $(U.target.value),
2770
2776
  placeholder: T.lastNamePlaceholder,
2771
2777
  style: h.input,
2772
- disabled: R || u
2778
+ disabled: L || u
2773
2779
  }
2774
2780
  )
2775
2781
  ] }),
@@ -2778,7 +2784,7 @@ function tr({
2778
2784
  {
2779
2785
  type: "button",
2780
2786
  onClick: () => {
2781
- M(!1), A(""), D("");
2787
+ I(!1), A(""), $("");
2782
2788
  },
2783
2789
  style: {
2784
2790
  background: "none",
@@ -2792,7 +2798,7 @@ function tr({
2792
2798
  }
2793
2799
  ) })
2794
2800
  ] }),
2795
- /* @__PURE__ */ n("button", { type: "submit", disabled: !k || R || u, style: H(), children: R ? T.loadingText : T.submitButton }),
2801
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !k || L || u, style: H(), children: L ? T.loadingText : T.submitButton }),
2796
2802
  z && /* @__PURE__ */ n("div", { style: h.errorText, children: z }),
2797
2803
  p && /* @__PURE__ */ n("div", { style: h.successText, children: p })
2798
2804
  ] }),
@@ -2823,7 +2829,7 @@ const At = {
2823
2829
  redirectingMessage: "Redirecting you to the dashboard...",
2824
2830
  retryButton: "Try Again",
2825
2831
  backToLoginButton: "Back to Login"
2826
- }, $e = {
2832
+ }, He = {
2827
2833
  container: {
2828
2834
  maxWidth: "400px",
2829
2835
  width: "100%",
@@ -2910,7 +2916,7 @@ const At = {
2910
2916
  cursor: "pointer",
2911
2917
  transition: "all 0.15s ease-in-out"
2912
2918
  }
2913
- }, Tt = () => /* @__PURE__ */ n("div", { style: $e.spinner }), Pt = () => /* @__PURE__ */ l(
2919
+ }, Tt = () => /* @__PURE__ */ n("div", { style: He.spinner }), Pt = () => /* @__PURE__ */ l(
2914
2920
  "svg",
2915
2921
  {
2916
2922
  width: "48",
@@ -2950,7 +2956,7 @@ const At = {
2950
2956
  success: /* @__PURE__ */ n(Pt, {}),
2951
2957
  error: /* @__PURE__ */ n(Mt, {})
2952
2958
  };
2953
- function rr({
2959
+ function nr({
2954
2960
  copy: i = {},
2955
2961
  styles: e = {},
2956
2962
  icons: t = {},
@@ -2965,7 +2971,7 @@ function rr({
2965
2971
  tenantSlug: b,
2966
2972
  autoRedirectDelay: f = 3e3
2967
2973
  }) {
2968
- const [A, L] = S("verifying"), [D, R] = S(""), { verifyMagicLink: P } = oe(), u = { ...At, ...i }, N = { ...$e, ...e }, z = { ...It, ...t }, E = () => {
2974
+ const [A, E] = S("verifying"), [$, L] = S(""), { verifyMagicLink: P } = ae(), u = { ...At, ...i }, M = { ...He, ...e }, z = { ...It, ...t }, N = () => {
2969
2975
  if (typeof window > "u") return {};
2970
2976
  const x = new URLSearchParams(window.location.search);
2971
2977
  return {
@@ -2975,58 +2981,58 @@ function rr({
2975
2981
  tenantSlug: b || x.get("tenantSlug") || void 0
2976
2982
  };
2977
2983
  }, p = async () => {
2978
- L("verifying"), R("");
2984
+ E("verifying"), L("");
2979
2985
  try {
2980
- const x = E();
2986
+ const x = N();
2981
2987
  if (!x.token || !x.email)
2982
2988
  throw new Error("Missing required parameters: token or email");
2983
- const M = await P({
2989
+ const I = await P({
2984
2990
  token: x.token,
2985
2991
  email: x.email,
2986
2992
  tenantSlug: x.tenantSlug
2987
2993
  });
2988
- L("success"), r == null || r(M), f > 0 && setTimeout(() => {
2989
- L("redirecting");
2994
+ E("success"), r == null || r(I), f > 0 && setTimeout(() => {
2995
+ E("redirecting");
2990
2996
  }, f);
2991
2997
  } catch (x) {
2992
- const M = x.message || u.errorMessage;
2993
- R(M), L("error"), s == null || s(M);
2998
+ const I = x.message || u.errorMessage;
2999
+ L(I), E("error"), s == null || s(I);
2994
3000
  }
2995
3001
  }, O = () => {
2996
3002
  o == null || o(), p();
2997
3003
  }, v = () => {
2998
3004
  a == null || a();
2999
3005
  };
3000
- te(() => {
3006
+ re(() => {
3001
3007
  p();
3002
3008
  }, []);
3003
3009
  const C = () => {
3004
3010
  switch (A) {
3005
3011
  case "verifying":
3006
- return /* @__PURE__ */ l("div", { style: N.message, children: [
3012
+ return /* @__PURE__ */ l("div", { style: M.message, children: [
3007
3013
  z.loading,
3008
3014
  u.verifyingMessage
3009
3015
  ] });
3010
3016
  case "success":
3011
3017
  return /* @__PURE__ */ l(j, { children: [
3012
3018
  z.success,
3013
- /* @__PURE__ */ n("div", { style: N.successMessage, children: u.successMessage })
3019
+ /* @__PURE__ */ n("div", { style: M.successMessage, children: u.successMessage })
3014
3020
  ] });
3015
3021
  case "redirecting":
3016
3022
  return /* @__PURE__ */ l(j, { children: [
3017
3023
  z.loading,
3018
- /* @__PURE__ */ n("div", { style: N.message, children: u.redirectingMessage })
3024
+ /* @__PURE__ */ n("div", { style: M.message, children: u.redirectingMessage })
3019
3025
  ] });
3020
3026
  case "error":
3021
3027
  return /* @__PURE__ */ l(j, { children: [
3022
3028
  z.error,
3023
- /* @__PURE__ */ n("div", { style: N.errorMessage, children: D || u.errorMessage }),
3024
- /* @__PURE__ */ l("div", { style: N.buttonContainer, children: [
3029
+ /* @__PURE__ */ n("div", { style: M.errorMessage, children: $ || u.errorMessage }),
3030
+ /* @__PURE__ */ l("div", { style: M.buttonContainer, children: [
3025
3031
  /* @__PURE__ */ n(
3026
3032
  "button",
3027
3033
  {
3028
3034
  onClick: O,
3029
- style: N.retryButton,
3035
+ style: M.retryButton,
3030
3036
  onMouseOver: (x) => {
3031
3037
  x.currentTarget.style.backgroundColor = "#2563eb";
3032
3038
  },
@@ -3040,7 +3046,7 @@ function rr({
3040
3046
  "button",
3041
3047
  {
3042
3048
  onClick: v,
3043
- style: N.backButton,
3049
+ style: M.backButton,
3044
3050
  onMouseOver: (x) => {
3045
3051
  x.currentTarget.style.backgroundColor = "#e5e7eb";
3046
3052
  },
@@ -3056,14 +3062,14 @@ function rr({
3056
3062
  return null;
3057
3063
  }
3058
3064
  };
3059
- return /* @__PURE__ */ l("div", { style: N.container, className: g, children: [
3065
+ return /* @__PURE__ */ l("div", { style: M.container, className: g, children: [
3060
3066
  /* @__PURE__ */ n("style", { children: `
3061
3067
  @keyframes spin {
3062
3068
  0% { transform: rotate(0deg); }
3063
3069
  100% { transform: rotate(360deg); }
3064
3070
  }
3065
3071
  ` }),
3066
- /* @__PURE__ */ n("h1", { style: N.title, children: u.title }),
3072
+ /* @__PURE__ */ n("h1", { style: M.title, children: u.title }),
3067
3073
  C()
3068
3074
  ] });
3069
3075
  }
@@ -3181,7 +3187,7 @@ const Rt = {
3181
3187
  cursor: "pointer"
3182
3188
  }
3183
3189
  };
3184
- function nr({
3190
+ function sr({
3185
3191
  copy: i = {},
3186
3192
  styles: e = {},
3187
3193
  mode: t = "request",
@@ -3192,21 +3198,21 @@ function nr({
3192
3198
  onModeChange: g,
3193
3199
  className: w
3194
3200
  }) {
3195
- const [m, k] = S(""), [b, f] = S(r), [A, L] = S(""), [D, R] = S(""), [P, u] = S(!1), [N, z] = S(""), [E, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = oe(), { tenant: M } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, I = () => {
3201
+ const [m, k] = S(""), [b, f] = S(r), [A, E] = S(""), [$, L] = S(""), [P, u] = S(!1), [M, z] = S(""), [N, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = ae(), { tenant: I } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, R = () => {
3196
3202
  const H = {};
3197
3203
  return m.trim() || (H.email = !0), v(H), Object.keys(H).length === 0;
3198
3204
  }, T = () => {
3199
3205
  const H = {};
3200
- return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0), D.trim() || (H.confirmPassword = !0), v(H), Object.keys(H).length === 0;
3206
+ return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0), $.trim() || (H.confirmPassword = !0), v(H), Object.keys(H).length === 0;
3201
3207
  }, h = async (H) => {
3202
- if (H.preventDefault(), !!I()) {
3203
- if (!(M != null && M.id)) {
3208
+ if (H.preventDefault(), !!R()) {
3209
+ if (!(I != null && I.id)) {
3204
3210
  z("Tenant not found");
3205
3211
  return;
3206
3212
  }
3207
3213
  u(!0), z(""), p("");
3208
3214
  try {
3209
- await C({ email: m, tenantId: M.id }), p(F.successMessage), s == null || s();
3215
+ await C({ email: m, tenantId: I.id }), p(F.successMessage), s == null || s();
3210
3216
  } catch (U) {
3211
3217
  const V = U.message || F.errorMessage;
3212
3218
  z(V), o == null || o(V);
@@ -3216,7 +3222,7 @@ function nr({
3216
3222
  }
3217
3223
  }, d = async (H) => {
3218
3224
  if (H.preventDefault(), !!T()) {
3219
- if (A !== D) {
3225
+ if (A !== $) {
3220
3226
  z(F.passwordMismatchError), v({ confirmPassword: !0 });
3221
3227
  return;
3222
3228
  }
@@ -3238,7 +3244,7 @@ function nr({
3238
3244
  ...P ? c.buttonLoading : {}
3239
3245
  });
3240
3246
  if (t === "reset") {
3241
- const H = b && A && D;
3247
+ const H = b && A && $;
3242
3248
  return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
3243
3249
  /* @__PURE__ */ n("h2", { style: c.title, children: F.resetTitle }),
3244
3250
  /* @__PURE__ */ n("p", { style: c.subtitle, children: F.resetSubtitle }),
@@ -3267,7 +3273,7 @@ function nr({
3267
3273
  type: "password",
3268
3274
  value: A,
3269
3275
  onChange: (U) => {
3270
- L(U.target.value), O.newPassword && v((V) => ({ ...V, newPassword: !1 }));
3276
+ E(U.target.value), O.newPassword && v((V) => ({ ...V, newPassword: !1 }));
3271
3277
  },
3272
3278
  placeholder: F.newPasswordPlaceholder,
3273
3279
  style: y("newPassword"),
@@ -3281,9 +3287,9 @@ function nr({
3281
3287
  "input",
3282
3288
  {
3283
3289
  type: "password",
3284
- value: D,
3290
+ value: $,
3285
3291
  onChange: (U) => {
3286
- R(U.target.value), O.confirmPassword && v((V) => ({ ...V, confirmPassword: !1 })), N === F.passwordMismatchError && z("");
3292
+ L(U.target.value), O.confirmPassword && v((V) => ({ ...V, confirmPassword: !1 })), M === F.passwordMismatchError && z("");
3287
3293
  },
3288
3294
  placeholder: F.confirmPasswordPlaceholder,
3289
3295
  style: y("confirmPassword"),
@@ -3303,8 +3309,8 @@ function nr({
3303
3309
  children: P ? F.resetLoadingText : F.resetSubmitButton
3304
3310
  }
3305
3311
  ),
3306
- N && /* @__PURE__ */ n("div", { style: c.errorText, children: N }),
3307
- E && /* @__PURE__ */ n("div", { style: c.successText, children: E })
3312
+ M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
3313
+ N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
3308
3314
  ] }),
3309
3315
  /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
3310
3316
  /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
@@ -3315,7 +3321,7 @@ function nr({
3315
3321
  ] })
3316
3322
  ] });
3317
3323
  }
3318
- const $ = m;
3324
+ const D = m;
3319
3325
  return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
3320
3326
  /* @__PURE__ */ n("h2", { style: c.title, children: F.title }),
3321
3327
  /* @__PURE__ */ n("p", { style: c.subtitle, children: F.subtitle }),
@@ -3340,16 +3346,16 @@ function nr({
3340
3346
  "button",
3341
3347
  {
3342
3348
  type: "submit",
3343
- disabled: !$ || P,
3349
+ disabled: !D || P,
3344
3350
  style: {
3345
3351
  ...G(),
3346
- ...!$ || P ? c.buttonDisabled : {}
3352
+ ...!D || P ? c.buttonDisabled : {}
3347
3353
  },
3348
3354
  children: P ? F.loadingText : F.submitButton
3349
3355
  }
3350
3356
  ),
3351
- N && /* @__PURE__ */ n("div", { style: c.errorText, children: N }),
3352
- E && /* @__PURE__ */ n("div", { style: c.successText, children: E })
3357
+ M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
3358
+ N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
3353
3359
  ] }),
3354
3360
  /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
3355
3361
  /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
@@ -3406,15 +3412,15 @@ const Et = () => /* @__PURE__ */ n(
3406
3412
  ]
3407
3413
  }
3408
3414
  );
3409
- function sr({
3415
+ function ir({
3410
3416
  children: i,
3411
3417
  loadingFallback: e,
3412
3418
  errorFallback: t,
3413
3419
  requireTenant: r = !0
3414
3420
  }) {
3415
- const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Fe(), m = Ce(), k = De(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, L = (g == null ? void 0 : g.retryTenant) ?? (() => {
3416
- }), D = (w == null ? void 0 : w.isAuthReady) ?? !0, R = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !D || m && !R || k && !P, O = o || (u ? f : null), v = () => {
3417
- o && a(), f && g && L();
3421
+ const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Ce(), m = De(), k = $e(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, E = (g == null ? void 0 : g.retryTenant) ?? (() => {
3422
+ }), $ = (w == null ? void 0 : w.isAuthReady) ?? !0, L = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !$ || m && !L || k && !P, O = o || (u ? f : null), v = () => {
3423
+ o && a(), f && g && E();
3418
3424
  };
3419
3425
  if (p)
3420
3426
  return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Et, {}) });
@@ -3424,25 +3430,25 @@ function sr({
3424
3430
  }
3425
3431
  return /* @__PURE__ */ n(j, { children: i });
3426
3432
  }
3427
- function ir(i = !0) {
3428
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(), g = Ce(), w = De(), m = (o == null ? void 0 : o.isTenantLoading) ?? !1, k = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
3429
- }), L = (a == null ? void 0 : a.isAuthReady) ?? !0, D = (g == null ? void 0 : g.isReady) ?? !0, R = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, E = e || P && m || a && !L || g && !D || w && !R, p = t || (P ? k : null);
3433
+ function or(i = !0) {
3434
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Ce(), g = De(), w = $e(), m = (o == null ? void 0 : o.isTenantLoading) ?? !1, k = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
3435
+ }), E = (a == null ? void 0 : a.isAuthReady) ?? !0, $ = (g == null ? void 0 : g.isReady) ?? !0, L = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, N = e || P && m || a && !E || g && !$ || w && !L, p = t || (P ? k : null);
3430
3436
  return {
3431
- isLoading: E,
3437
+ isLoading: N,
3432
3438
  error: p,
3433
- isReady: !E && !p && s !== null && (!P || b !== null),
3439
+ isReady: !N && !p && s !== null && (!P || b !== null),
3434
3440
  retry: () => {
3435
3441
  t && r(), k && o && A();
3436
3442
  },
3437
3443
  // Individual states
3438
3444
  app: { isLoading: e, error: t, data: s },
3439
3445
  tenant: o ? { isLoading: m, error: k, data: b } : null,
3440
- auth: a ? { isReady: L } : null,
3441
- featureFlags: g ? { isReady: D } : null,
3442
- subscription: w ? { isReady: R } : null
3446
+ auth: a ? { isReady: E } : null,
3447
+ featureFlags: g ? { isReady: $ } : null,
3448
+ subscription: w ? { isReady: L } : null
3443
3449
  };
3444
3450
  }
3445
- class or {
3451
+ class ar {
3446
3452
  constructor(e, t) {
3447
3453
  this.httpService = e, this.sessionManager = t;
3448
3454
  }
@@ -3510,7 +3516,7 @@ class or {
3510
3516
  };
3511
3517
  }
3512
3518
  }
3513
- class ar {
3519
+ class lr {
3514
3520
  constructor(e, t) {
3515
3521
  this.httpService = e, this.sessionManager = t;
3516
3522
  }
@@ -3561,7 +3567,7 @@ class ar {
3561
3567
  });
3562
3568
  }
3563
3569
  }
3564
- class lr {
3570
+ class cr {
3565
3571
  constructor(e) {
3566
3572
  this.httpService = e;
3567
3573
  }
@@ -3570,7 +3576,7 @@ class lr {
3570
3576
  return await this.httpService.get("/health");
3571
3577
  }
3572
3578
  }
3573
- class cr {
3579
+ class dr {
3574
3580
  // Date string to Date object
3575
3581
  static toDate(e) {
3576
3582
  return new Date(e);
@@ -3693,47 +3699,47 @@ class cr {
3693
3699
  }
3694
3700
  }
3695
3701
  export {
3696
- cr as ApiMappers,
3697
- Pe as AppApiService,
3698
- sr as AppLoader,
3699
- Bt as AppProvider,
3702
+ dr as ApiMappers,
3703
+ Me as AppApiService,
3704
+ ir as AppLoader,
3705
+ qt as AppProvider,
3700
3706
  Ke as AuthApiService,
3701
- jt as AuthProvider,
3702
- Xt as FeatureFlag,
3707
+ Vt as AuthProvider,
3708
+ Zt as FeatureFlag,
3703
3709
  st as FeatureFlagApiService,
3704
- Vt as FeatureFlagProvider,
3705
- lr as HealthApiService,
3706
- re as HttpService,
3707
- Yt as LandingRoute,
3708
- Zt as LoginForm,
3709
- tr as MagicLinkForm,
3710
- rr as MagicLinkVerify,
3711
- nr as PasswordRecoveryForm,
3712
- or as PermissionApiService,
3713
- Gt as Protected,
3714
- Kt as ProtectedRoute,
3715
- Me as RoleApiService,
3716
- be as SessionManager,
3717
- er as SignupForm,
3710
+ _t as FeatureFlagProvider,
3711
+ cr as HealthApiService,
3712
+ ne as HttpService,
3713
+ Qt as LandingRoute,
3714
+ er as LoginForm,
3715
+ rr as MagicLinkForm,
3716
+ nr as MagicLinkVerify,
3717
+ sr as PasswordRecoveryForm,
3718
+ ar as PermissionApiService,
3719
+ Kt as Protected,
3720
+ Jt as ProtectedRoute,
3721
+ Ie as RoleApiService,
3722
+ Se as SessionManager,
3723
+ tr as SignupForm,
3718
3724
  ot as SubscriptionApiService,
3719
- Qt as SubscriptionGuard,
3720
- ar as SubscriptionPlanApiService,
3721
- _t as SubscriptionProvider,
3725
+ Xt as SubscriptionGuard,
3726
+ lr as SubscriptionPlanApiService,
3727
+ Gt as SubscriptionProvider,
3722
3728
  de as TenantApiService,
3723
- zt as TenantProvider,
3724
- Jt as TenantRoute,
3729
+ Ot as TenantProvider,
3730
+ Yt as TenantRoute,
3725
3731
  Je as UserApiService,
3726
- ie as UserType,
3727
- qt as useApi,
3732
+ oe as UserType,
3733
+ zt as useApi,
3728
3734
  he as useApp,
3729
- ir as useAppLoaderState,
3730
- oe as useAuth,
3735
+ or as useAppLoaderState,
3736
+ ae as useAuth,
3731
3737
  it as useFeatureFlags,
3732
- Wt as useSettings,
3738
+ jt as useSettings,
3733
3739
  at as useSubscription,
3734
3740
  me as useTenant,
3735
3741
  le as useTenantInfo,
3736
3742
  ye as useTenantOptional,
3737
- Ot as useTenantSettings
3743
+ Wt as useTenantSettings
3738
3744
  };
3739
3745
  //# sourceMappingURL=index.es.js.map