@skylabs-digital/react-identity-access 2.4.0 → 2.5.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 +761 -758
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
1
|
+
import { jsx as n, Fragment as q, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as he, useMemo as X, useState as v, useCallback as ne, useEffect as te, useContext as ce, useRef as qe } from "react";
|
|
3
3
|
import { useLocation as be, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
@@ -16,27 +16,27 @@ class re {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
-
const
|
|
20
|
-
let
|
|
19
|
+
const h = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, w = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let k = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
26
|
const m = await this.sessionManager.getAuthHeaders();
|
|
27
|
-
|
|
27
|
+
k = { ...k, ...m };
|
|
28
28
|
} catch (m) {
|
|
29
29
|
console.warn("Failed to inject auth headers:", m);
|
|
30
30
|
}
|
|
31
|
-
const b = new AbortController(),
|
|
31
|
+
const b = new AbortController(), P = setTimeout(() => b.abort(), w);
|
|
32
32
|
try {
|
|
33
|
-
const m = await fetch(
|
|
33
|
+
const m = await fetch(h, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: k,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(P), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const u = this.sessionManager.getTokens();
|
|
42
42
|
if (u != null && u.refreshToken)
|
|
@@ -46,10 +46,10 @@ class re {
|
|
|
46
46
|
}
|
|
47
47
|
if (!m.ok)
|
|
48
48
|
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
49
|
+
const p = m.headers.get("content-type");
|
|
50
|
+
return !p || !p.includes("application/json") ? {} : await m.json();
|
|
51
51
|
} catch (m) {
|
|
52
|
-
throw clearTimeout(
|
|
52
|
+
throw clearTimeout(P), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${w}ms`) : m;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -128,9 +128,9 @@ const Pe = he(null);
|
|
|
128
128
|
function Ct({ config: i, children: e }) {
|
|
129
129
|
const t = X(
|
|
130
130
|
() => {
|
|
131
|
-
var
|
|
131
|
+
var p, u, y;
|
|
132
132
|
return {
|
|
133
|
-
enabled: ((
|
|
133
|
+
enabled: ((p = i.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
134
134
|
ttl: ((u = i.cache) == null ? void 0 : u.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
136
|
storageKey: ((y = i.cache) == null ? void 0 : y.storageKey) ?? `app_cache_${i.appId}`
|
|
@@ -140,16 +140,16 @@ function Ct({ config: i, children: e }) {
|
|
|
140
140
|
), [r, s] = v(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
const u = JSON.parse(
|
|
143
|
+
const p = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!p) return null;
|
|
145
|
+
const u = JSON.parse(p);
|
|
146
146
|
return Date.now() - u.timestamp < t.ttl && u.appId === i.appId ? u.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o,
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
}), [o, h] = v(!r), [w, k] = v(null), b = X(() => {
|
|
151
|
+
const p = () => {
|
|
152
|
+
P();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -158,55 +158,55 @@ function Ct({ config: i, children: e }) {
|
|
|
158
158
|
appInfo: r,
|
|
159
159
|
isAppLoading: o,
|
|
160
160
|
appError: w,
|
|
161
|
-
retryApp:
|
|
161
|
+
retryApp: p
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o, w]),
|
|
164
|
-
async (
|
|
165
|
-
if (!(!
|
|
163
|
+
}, [i, r, o, w]), P = ne(
|
|
164
|
+
async (p = !1) => {
|
|
165
|
+
if (!(!p && t.enabled && r))
|
|
166
166
|
try {
|
|
167
|
-
|
|
168
|
-
const u = new re(i.baseUrl),
|
|
169
|
-
if (s(
|
|
167
|
+
h(!0), k(null);
|
|
168
|
+
const u = new re(i.baseUrl), L = await new ve(u, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(L), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const R = {
|
|
172
|
+
data: L,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(R));
|
|
177
|
+
} catch (R) {
|
|
178
|
+
console.warn("Failed to cache app info:", R);
|
|
179
179
|
}
|
|
180
180
|
} catch (u) {
|
|
181
181
|
const y = u instanceof Error ? u : new Error("Failed to load app information");
|
|
182
|
-
|
|
182
|
+
k(y), s(null);
|
|
183
183
|
} finally {
|
|
184
|
-
|
|
184
|
+
h(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[i.baseUrl, i.appId, t, r]
|
|
188
188
|
), m = ne(async () => {
|
|
189
189
|
if (!(!t.enabled || !r))
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const u = JSON.parse(
|
|
191
|
+
const p = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!p) return;
|
|
193
|
+
const u = JSON.parse(p);
|
|
194
194
|
if (Date.now() - u.timestamp > t.ttl * 0.5) {
|
|
195
|
-
const
|
|
196
|
-
s(
|
|
197
|
-
const
|
|
198
|
-
data:
|
|
195
|
+
const L = new re(i.baseUrl), z = await new ve(L, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(z);
|
|
197
|
+
const M = {
|
|
198
|
+
data: z,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(M));
|
|
203
203
|
}
|
|
204
|
-
} catch (
|
|
205
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (p) {
|
|
205
|
+
console.warn("Background app refresh failed:", p);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
208
|
return te(() => {
|
|
209
|
-
r ? m() :
|
|
209
|
+
r ? m() : P();
|
|
210
210
|
}, []), /* @__PURE__ */ n(Pe.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
212
|
function oe() {
|
|
@@ -215,7 +215,7 @@ function oe() {
|
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
const
|
|
218
|
+
const Ft = oe;
|
|
219
219
|
class we {
|
|
220
220
|
constructor(e = {}) {
|
|
221
221
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
@@ -414,7 +414,7 @@ class ze {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class ke {
|
|
418
418
|
constructor(e, t) {
|
|
419
419
|
this.httpService = e, this.sessionManager = t;
|
|
420
420
|
}
|
|
@@ -481,12 +481,12 @@ class xe {
|
|
|
481
481
|
throw new Error("SessionManager is required for private endpoints");
|
|
482
482
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
483
483
|
t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
|
|
484
|
-
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
484
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, h = await this.httpService.get(o, {
|
|
485
485
|
headers: r
|
|
486
486
|
});
|
|
487
487
|
return {
|
|
488
|
-
roles:
|
|
489
|
-
meta:
|
|
488
|
+
roles: h.data,
|
|
489
|
+
meta: h.meta
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
}
|
|
@@ -616,8 +616,8 @@ function We(i, e) {
|
|
|
616
616
|
if (o === s || o === `www.${s}`)
|
|
617
617
|
return null;
|
|
618
618
|
if (o.endsWith(`.${s}`)) {
|
|
619
|
-
const
|
|
620
|
-
return
|
|
619
|
+
const h = o.slice(0, -(s.length + 1));
|
|
620
|
+
return h === "www" ? null : h;
|
|
621
621
|
}
|
|
622
622
|
return null;
|
|
623
623
|
}
|
|
@@ -680,7 +680,7 @@ function Ye() {
|
|
|
680
680
|
}), window.history.replaceState({}, "", i.toString());
|
|
681
681
|
}
|
|
682
682
|
const Se = he(null);
|
|
683
|
-
function
|
|
683
|
+
function $t({ config: i, children: e }) {
|
|
684
684
|
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : je(
|
|
685
685
|
{
|
|
686
686
|
tenantMode: i.tenantMode || "selector",
|
|
@@ -692,114 +692,114 @@ function Dt({ config: i, children: e }) {
|
|
|
692
692
|
search: window.location.search
|
|
693
693
|
},
|
|
694
694
|
window.localStorage
|
|
695
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [
|
|
695
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [h, w] = v(() => o()), k = X(
|
|
696
696
|
() => {
|
|
697
|
-
var
|
|
697
|
+
var c, I, S;
|
|
698
698
|
return {
|
|
699
|
-
enabled: ((
|
|
699
|
+
enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
700
700
|
ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
|
|
701
701
|
// 5 minutes default
|
|
702
|
-
storageKey: ((
|
|
702
|
+
storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `tenant_cache_${h || "default"}`
|
|
703
703
|
};
|
|
704
704
|
},
|
|
705
|
-
[i.cache,
|
|
706
|
-
), [b,
|
|
705
|
+
[i.cache, h]
|
|
706
|
+
), [b, P] = v(() => {
|
|
707
707
|
if (i.initialTenant) return i.initialTenant;
|
|
708
|
-
if (!
|
|
708
|
+
if (!k.enabled || !h) return null;
|
|
709
709
|
try {
|
|
710
|
-
const
|
|
711
|
-
if (!
|
|
712
|
-
const I = JSON.parse(
|
|
713
|
-
return Date.now() - I.timestamp <
|
|
710
|
+
const c = localStorage.getItem(k.storageKey);
|
|
711
|
+
if (!c) return null;
|
|
712
|
+
const I = JSON.parse(c);
|
|
713
|
+
return Date.now() - I.timestamp < k.ttl && I.tenantSlug === h ? I.data : (localStorage.removeItem(k.storageKey), null);
|
|
714
714
|
} catch {
|
|
715
715
|
return null;
|
|
716
716
|
}
|
|
717
|
-
}), [m,
|
|
717
|
+
}), [m, p] = v(!b && !i.initialTenant), [u, y] = v(null), [L, R] = v(null), [z, M] = v(!1), [A, d] = v(null);
|
|
718
718
|
te(() => {
|
|
719
|
-
const
|
|
720
|
-
w(
|
|
719
|
+
const c = o();
|
|
720
|
+
w(c);
|
|
721
721
|
}, [o]);
|
|
722
|
-
const
|
|
723
|
-
async (
|
|
724
|
-
if (!(!I &&
|
|
722
|
+
const C = (r == null ? void 0 : r.settingsSchema) || null, F = ne(
|
|
723
|
+
async (c, I = !1) => {
|
|
724
|
+
if (!(!I && k.enabled && b && b.domain === c))
|
|
725
725
|
try {
|
|
726
|
-
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
726
|
+
p(!0), y(null);
|
|
727
|
+
const S = new re(t), a = await new ue(S, s).getPublicTenantInfo(c);
|
|
728
|
+
if (P(a), k.enabled)
|
|
729
729
|
try {
|
|
730
|
-
const
|
|
730
|
+
const f = {
|
|
731
731
|
data: a,
|
|
732
732
|
timestamp: Date.now(),
|
|
733
|
-
tenantSlug:
|
|
733
|
+
tenantSlug: c
|
|
734
734
|
};
|
|
735
|
-
localStorage.setItem(
|
|
736
|
-
} catch (
|
|
737
|
-
console.warn("Failed to cache tenant info:",
|
|
735
|
+
localStorage.setItem(k.storageKey, JSON.stringify(f));
|
|
736
|
+
} catch (f) {
|
|
737
|
+
console.warn("Failed to cache tenant info:", f);
|
|
738
738
|
}
|
|
739
|
-
} catch (
|
|
740
|
-
const
|
|
741
|
-
y(
|
|
739
|
+
} catch (S) {
|
|
740
|
+
const g = S instanceof Error ? S : new Error("Failed to load tenant information");
|
|
741
|
+
y(g), P(null);
|
|
742
742
|
} finally {
|
|
743
|
-
|
|
743
|
+
p(!1);
|
|
744
744
|
}
|
|
745
745
|
},
|
|
746
|
-
[t, s,
|
|
746
|
+
[t, s, k, b]
|
|
747
747
|
), G = ne(async () => {
|
|
748
|
-
if (!(!
|
|
748
|
+
if (!(!k.enabled || !b || !h))
|
|
749
749
|
try {
|
|
750
|
-
const
|
|
751
|
-
if (!
|
|
752
|
-
const I = JSON.parse(
|
|
753
|
-
if (Date.now() - I.timestamp >
|
|
754
|
-
const
|
|
755
|
-
|
|
750
|
+
const c = localStorage.getItem(k.storageKey);
|
|
751
|
+
if (!c) return;
|
|
752
|
+
const I = JSON.parse(c);
|
|
753
|
+
if (Date.now() - I.timestamp > k.ttl * 0.5) {
|
|
754
|
+
const g = new re(t), f = await new ue(g, s).getPublicTenantInfo(h);
|
|
755
|
+
P(f);
|
|
756
756
|
const O = {
|
|
757
|
-
data:
|
|
757
|
+
data: f,
|
|
758
758
|
timestamp: Date.now(),
|
|
759
|
-
tenantSlug:
|
|
759
|
+
tenantSlug: h
|
|
760
760
|
};
|
|
761
|
-
localStorage.setItem(
|
|
761
|
+
localStorage.setItem(k.storageKey, JSON.stringify(O));
|
|
762
762
|
}
|
|
763
|
-
} catch (
|
|
764
|
-
console.warn("Background tenant refresh failed:",
|
|
763
|
+
} catch (c) {
|
|
764
|
+
console.warn("Background tenant refresh failed:", c);
|
|
765
765
|
}
|
|
766
|
-
}, [t, s,
|
|
766
|
+
}, [t, s, k, b, h]), U = ne(async () => {
|
|
767
767
|
if (b != null && b.id)
|
|
768
768
|
try {
|
|
769
|
-
|
|
770
|
-
const
|
|
771
|
-
|
|
772
|
-
} catch (
|
|
773
|
-
const I =
|
|
774
|
-
|
|
769
|
+
M(!0), d(null);
|
|
770
|
+
const c = new re(t), S = await new ue(c, b.appId).getTenantSettings(b.id);
|
|
771
|
+
R(S);
|
|
772
|
+
} catch (c) {
|
|
773
|
+
const I = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
774
|
+
d(I), R(null);
|
|
775
775
|
} finally {
|
|
776
|
-
|
|
776
|
+
M(!1);
|
|
777
777
|
}
|
|
778
778
|
}, [t, b]), _ = ne(() => {
|
|
779
|
-
|
|
780
|
-
}, [
|
|
781
|
-
(
|
|
782
|
-
if (!
|
|
779
|
+
U();
|
|
780
|
+
}, [U]), x = ne(
|
|
781
|
+
(c) => {
|
|
782
|
+
if (!C)
|
|
783
783
|
return { isValid: !0, errors: [] };
|
|
784
784
|
const I = [];
|
|
785
785
|
try {
|
|
786
|
-
return
|
|
787
|
-
var
|
|
788
|
-
const a =
|
|
789
|
-
if ((
|
|
790
|
-
I.push(`Field '${
|
|
786
|
+
return C.properties && Object.entries(C.properties).forEach(([S, g]) => {
|
|
787
|
+
var f;
|
|
788
|
+
const a = c[S];
|
|
789
|
+
if ((f = C.required) != null && f.includes(S) && a == null) {
|
|
790
|
+
I.push(`Field '${S}' is required`);
|
|
791
791
|
return;
|
|
792
792
|
}
|
|
793
793
|
if (a != null) {
|
|
794
|
-
if (
|
|
795
|
-
const O =
|
|
796
|
-
O === "string" && K !== "string" ? I.push(`Field '${
|
|
794
|
+
if (g.type) {
|
|
795
|
+
const O = g.type, K = typeof a;
|
|
796
|
+
O === "string" && K !== "string" ? I.push(`Field '${S}' must be a string`) : (O === "number" || O === "integer") && K !== "number" ? I.push(`Field '${S}' must be a number`) : O === "boolean" && K !== "boolean" ? I.push(`Field '${S}' must be a boolean`) : O === "array" && !Array.isArray(a) && I.push(`Field '${S}' must be an array`);
|
|
797
797
|
}
|
|
798
|
-
|
|
799
|
-
`Field '${
|
|
800
|
-
),
|
|
801
|
-
`Field '${
|
|
802
|
-
),
|
|
798
|
+
g.minLength !== void 0 && typeof a == "string" && a.length < g.minLength && I.push(
|
|
799
|
+
`Field '${S}' must be at least ${g.minLength} characters long`
|
|
800
|
+
), g.maxLength !== void 0 && typeof a == "string" && a.length > g.maxLength && I.push(
|
|
801
|
+
`Field '${S}' must be no more than ${g.maxLength} characters long`
|
|
802
|
+
), g.minimum !== void 0 && typeof a == "number" && a < g.minimum && I.push(`Field '${S}' must be at least ${g.minimum}`), g.maximum !== void 0 && typeof a == "number" && a > g.maximum && I.push(`Field '${S}' must be no more than ${g.maximum}`), g.pattern && typeof a == "string" && (new RegExp(g.pattern).test(a) || I.push(`Field '${S}' does not match the required pattern`)), g.enum && !g.enum.includes(a) && I.push(`Field '${S}' must be one of: ${g.enum.join(", ")}`);
|
|
803
803
|
}
|
|
804
804
|
}), {
|
|
805
805
|
isValid: I.length === 0,
|
|
@@ -812,19 +812,19 @@ function Dt({ config: i, children: e }) {
|
|
|
812
812
|
};
|
|
813
813
|
}
|
|
814
814
|
},
|
|
815
|
-
[
|
|
815
|
+
[C]
|
|
816
816
|
);
|
|
817
817
|
te(() => {
|
|
818
|
-
!i.initialTenant &&
|
|
819
|
-
}, [i.initialTenant,
|
|
820
|
-
b != null && b.id ?
|
|
821
|
-
}, [b == null ? void 0 : b.id,
|
|
822
|
-
const
|
|
823
|
-
(
|
|
824
|
-
const { mode:
|
|
825
|
-
if (localStorage.setItem("tenant",
|
|
818
|
+
!i.initialTenant && h ? b ? G() : F(h) : !i.initialTenant && !h && (P(null), y(null), p(!1));
|
|
819
|
+
}, [i.initialTenant, h, b, F, G]), te(() => {
|
|
820
|
+
b != null && b.id ? U() : (R(null), d(null), M(!1));
|
|
821
|
+
}, [b == null ? void 0 : b.id, U]);
|
|
822
|
+
const T = ne(
|
|
823
|
+
(c, I) => {
|
|
824
|
+
const { mode: S = "reload", tokens: g, redirectPath: a } = I || {}, f = i.tenantMode || "selector";
|
|
825
|
+
if (localStorage.setItem("tenant", c), f === "subdomain") {
|
|
826
826
|
const O = window.location.hostname, K = _e(
|
|
827
|
-
|
|
827
|
+
c,
|
|
828
828
|
O,
|
|
829
829
|
i.baseDomain
|
|
830
830
|
);
|
|
@@ -836,54 +836,54 @@ function Dt({ config: i, children: e }) {
|
|
|
836
836
|
return;
|
|
837
837
|
}
|
|
838
838
|
const H = a || window.location.pathname, N = new URL(`${window.location.protocol}//${K}${H}`);
|
|
839
|
-
new URLSearchParams(window.location.search).forEach((
|
|
840
|
-
J !== fe && N.searchParams.set(J,
|
|
841
|
-
}),
|
|
842
|
-
} else if (
|
|
839
|
+
new URLSearchParams(window.location.search).forEach(($, J) => {
|
|
840
|
+
J !== fe && N.searchParams.set(J, $);
|
|
841
|
+
}), g && N.searchParams.set(fe, Ge(g)), window.location.href = N.toString();
|
|
842
|
+
} else if (f === "selector") {
|
|
843
843
|
const O = a || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
844
|
-
if (K.set(i.selectorParam || "tenant",
|
|
844
|
+
if (K.set(i.selectorParam || "tenant", c), S === "reload") {
|
|
845
845
|
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
846
846
|
window.location.href = H;
|
|
847
847
|
} else {
|
|
848
848
|
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
849
|
-
window.history.pushState({}, "", H), w(
|
|
849
|
+
window.history.pushState({}, "", H), w(c), F(c);
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
},
|
|
853
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
854
|
-
),
|
|
853
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, F]
|
|
854
|
+
), E = X(() => ({
|
|
855
855
|
// Tenant info
|
|
856
856
|
tenant: b,
|
|
857
|
-
tenantSlug:
|
|
857
|
+
tenantSlug: h,
|
|
858
858
|
isTenantLoading: m,
|
|
859
859
|
tenantError: u,
|
|
860
860
|
retryTenant: () => {
|
|
861
|
-
|
|
861
|
+
h && F(h);
|
|
862
862
|
},
|
|
863
863
|
// Settings
|
|
864
|
-
settings:
|
|
865
|
-
settingsSchema:
|
|
866
|
-
isSettingsLoading:
|
|
867
|
-
settingsError:
|
|
864
|
+
settings: L,
|
|
865
|
+
settingsSchema: C,
|
|
866
|
+
isSettingsLoading: z,
|
|
867
|
+
settingsError: A,
|
|
868
868
|
// Actions
|
|
869
869
|
refreshSettings: _,
|
|
870
|
-
switchTenant:
|
|
870
|
+
switchTenant: T,
|
|
871
871
|
// Validation
|
|
872
|
-
validateSettings:
|
|
872
|
+
validateSettings: x
|
|
873
873
|
}), [
|
|
874
874
|
b,
|
|
875
|
-
|
|
875
|
+
h,
|
|
876
876
|
m,
|
|
877
877
|
u,
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
878
|
+
L,
|
|
879
|
+
C,
|
|
880
|
+
z,
|
|
881
|
+
A,
|
|
882
882
|
_,
|
|
883
|
-
|
|
884
|
-
|
|
883
|
+
T,
|
|
884
|
+
x
|
|
885
885
|
]);
|
|
886
|
-
return /* @__PURE__ */ n(Se.Provider, { value:
|
|
886
|
+
return /* @__PURE__ */ n(Se.Provider, { value: E, children: e });
|
|
887
887
|
}
|
|
888
888
|
function me() {
|
|
889
889
|
const i = ce(Se);
|
|
@@ -894,7 +894,7 @@ function me() {
|
|
|
894
894
|
function Me() {
|
|
895
895
|
return ce(Se);
|
|
896
896
|
}
|
|
897
|
-
const
|
|
897
|
+
const Dt = me;
|
|
898
898
|
function Ht() {
|
|
899
899
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
|
|
900
900
|
return {
|
|
@@ -917,44 +917,62 @@ function se() {
|
|
|
917
917
|
}
|
|
918
918
|
const Ie = he(null);
|
|
919
919
|
function Nt({ config: i = {}, children: e }) {
|
|
920
|
-
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant:
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
920
|
+
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: h } = me(), [w, k] = v(i.initialRoles || []), [b, P] = v(!i.initialRoles), [m, p] = v(null), [u, y] = v(!1), [L, R] = v(null), [z, M] = v(0), A = qe({
|
|
921
|
+
processed: !1,
|
|
922
|
+
tokens: null
|
|
923
|
+
});
|
|
924
|
+
A.current.processed || (A.current.processed = !0, A.current.tokens = Je(), console.log("[AuthProvider] SYNC: URL tokens extracted on init", {
|
|
925
|
+
found: !!A.current.tokens,
|
|
926
|
+
url: typeof window < "u" ? window.location.href : "SSR"
|
|
927
|
+
}));
|
|
928
|
+
const d = X(() => {
|
|
929
|
+
const a = new we({
|
|
930
|
+
tenantSlug: o,
|
|
931
|
+
// SessionManager will generate storageKey internally
|
|
932
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
933
|
+
baseUrl: r
|
|
934
|
+
});
|
|
935
|
+
return A.current.tokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), a.setTokens({
|
|
936
|
+
accessToken: A.current.tokens.accessToken,
|
|
937
|
+
refreshToken: A.current.tokens.refreshToken,
|
|
938
|
+
expiresIn: A.current.tokens.expiresIn
|
|
939
|
+
}), console.log(
|
|
940
|
+
"[AuthProvider] SYNC: Session valid after saving tokens:",
|
|
941
|
+
a.hasValidSession()
|
|
942
|
+
)), a;
|
|
943
|
+
}, [o, r, i.onRefreshFailed]), C = X(() => {
|
|
926
944
|
const a = new re(r);
|
|
927
945
|
return a.setSessionManager(d), a;
|
|
928
|
-
}, [r, d]),
|
|
929
|
-
const a = async (
|
|
946
|
+
}, [r, d]), F = X(() => new ze(new re(r)), [r]), G = X(() => new Oe(C, d), [C, d]), U = X(() => new ke(new re(r)), [r]), _ = X(() => m || d.getUser(), [m, d]), x = X(() => _ != null && _.roleId && w.find((a) => a.id === _.roleId) || null, [_, w]), T = X(() => (x == null ? void 0 : x.permissions) || [], [x]), E = X(() => d.hasValidSession() && m !== null, [d, m]), c = 5 * 60 * 1e3, I = X(() => {
|
|
947
|
+
const a = async (D = !1) => {
|
|
930
948
|
try {
|
|
931
949
|
if (!d.hasValidSession())
|
|
932
950
|
return;
|
|
933
|
-
const
|
|
934
|
-
if (!
|
|
951
|
+
const B = Date.now();
|
|
952
|
+
if (!D && B - z < c && m)
|
|
935
953
|
return;
|
|
936
954
|
const V = d.getUserId();
|
|
937
955
|
if (!V) {
|
|
938
956
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
939
957
|
return;
|
|
940
958
|
}
|
|
941
|
-
y(!0),
|
|
942
|
-
const Z = await
|
|
943
|
-
|
|
944
|
-
} catch (
|
|
945
|
-
const Y =
|
|
946
|
-
|
|
959
|
+
y(!0), R(null);
|
|
960
|
+
const Z = await G.getUserById(V);
|
|
961
|
+
p(Z), d.setUser(Z), M(Date.now());
|
|
962
|
+
} catch (B) {
|
|
963
|
+
const Y = B instanceof Error ? B : new Error("Failed to load user data");
|
|
964
|
+
R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
947
965
|
} finally {
|
|
948
966
|
y(!1);
|
|
949
967
|
}
|
|
950
|
-
},
|
|
968
|
+
}, f = async () => {
|
|
951
969
|
await a();
|
|
952
|
-
}, O = async (
|
|
953
|
-
const { username:
|
|
970
|
+
}, O = async (D) => {
|
|
971
|
+
const { username: B, password: Y, tenantSlug: V } = D;
|
|
954
972
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
955
|
-
V && (Z = (await new ue(
|
|
956
|
-
const j = await
|
|
957
|
-
username:
|
|
973
|
+
V && (Z = (await new ue(C, t).getPublicTenantInfo(V)).id, Q = V);
|
|
974
|
+
const j = await F.login({
|
|
975
|
+
username: B,
|
|
958
976
|
password: Y,
|
|
959
977
|
appId: t,
|
|
960
978
|
tenantId: Z
|
|
@@ -967,29 +985,29 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
967
985
|
refreshToken: j.refreshToken,
|
|
968
986
|
expiresIn: j.expiresIn
|
|
969
987
|
}), j.user) {
|
|
970
|
-
ee.setUser(j.user),
|
|
988
|
+
ee.setUser(j.user), p(j.user);
|
|
971
989
|
try {
|
|
972
990
|
await a();
|
|
973
991
|
} catch (de) {
|
|
974
992
|
console.warn("Failed to load complete user data after login:", de);
|
|
975
993
|
}
|
|
976
994
|
}
|
|
977
|
-
return le && Q && Q !== o &&
|
|
995
|
+
return le && Q && Q !== o && h(Q, {
|
|
978
996
|
tokens: {
|
|
979
997
|
accessToken: j.accessToken,
|
|
980
998
|
refreshToken: j.refreshToken,
|
|
981
999
|
expiresIn: j.expiresIn
|
|
982
1000
|
}
|
|
983
1001
|
}), j;
|
|
984
|
-
}, K = async (
|
|
985
|
-
const { email:
|
|
986
|
-
if (!
|
|
1002
|
+
}, K = async (D) => {
|
|
1003
|
+
const { email: B, phoneNumber: Y, name: V, password: Z, lastName: Q, tenantId: ee } = D;
|
|
1004
|
+
if (!B && !Y)
|
|
987
1005
|
throw new Error("Either email or phoneNumber is required");
|
|
988
1006
|
if (!V || !Z)
|
|
989
1007
|
throw new Error("Name and password are required");
|
|
990
1008
|
const j = ee ?? (s == null ? void 0 : s.id);
|
|
991
|
-
return await
|
|
992
|
-
email:
|
|
1009
|
+
return await F.signup({
|
|
1010
|
+
email: B,
|
|
993
1011
|
phoneNumber: Y,
|
|
994
1012
|
name: V,
|
|
995
1013
|
password: Z,
|
|
@@ -997,14 +1015,14 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
997
1015
|
lastName: Q,
|
|
998
1016
|
appId: t
|
|
999
1017
|
});
|
|
1000
|
-
}, H = async (
|
|
1001
|
-
const { email:
|
|
1002
|
-
if (!
|
|
1018
|
+
}, H = async (D) => {
|
|
1019
|
+
const { email: B, phoneNumber: Y, name: V, password: Z, tenantName: Q, lastName: ee } = D;
|
|
1020
|
+
if (!B && !Y)
|
|
1003
1021
|
throw new Error("Either email or phoneNumber is required");
|
|
1004
1022
|
if (!V || !Z || !Q)
|
|
1005
1023
|
throw new Error("Name, password, and tenantName are required");
|
|
1006
|
-
return await
|
|
1007
|
-
email:
|
|
1024
|
+
return await F.signupTenantAdmin({
|
|
1025
|
+
email: B,
|
|
1008
1026
|
phoneNumber: Y,
|
|
1009
1027
|
name: V,
|
|
1010
1028
|
password: Z,
|
|
@@ -1012,35 +1030,35 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1012
1030
|
appId: t,
|
|
1013
1031
|
lastName: ee
|
|
1014
1032
|
});
|
|
1015
|
-
}, N = async (
|
|
1016
|
-
const { currentPassword:
|
|
1017
|
-
await
|
|
1018
|
-
}, W = async (
|
|
1019
|
-
const { email:
|
|
1033
|
+
}, N = async (D) => {
|
|
1034
|
+
const { currentPassword: B, newPassword: Y } = D, V = await d.getAuthHeaders();
|
|
1035
|
+
await F.changePassword({ currentPassword: B, newPassword: Y }, V);
|
|
1036
|
+
}, W = async (D) => {
|
|
1037
|
+
const { email: B, tenantId: Y } = D, V = Y ?? (s == null ? void 0 : s.id);
|
|
1020
1038
|
if (!V)
|
|
1021
1039
|
throw new Error("tenantId is required for password reset");
|
|
1022
|
-
await
|
|
1023
|
-
},
|
|
1024
|
-
const { token:
|
|
1025
|
-
await
|
|
1026
|
-
}, J = async (
|
|
1027
|
-
const { email:
|
|
1040
|
+
await F.requestPasswordReset({ email: B, tenantId: V });
|
|
1041
|
+
}, $ = async (D) => {
|
|
1042
|
+
const { token: B, newPassword: Y } = D;
|
|
1043
|
+
await F.confirmPasswordReset({ token: B, newPassword: Y });
|
|
1044
|
+
}, J = async (D) => {
|
|
1045
|
+
const { email: B, frontendUrl: Y, name: V, lastName: Z, tenantId: Q } = D, ee = Q ?? (s == null ? void 0 : s.id);
|
|
1028
1046
|
if (!ee)
|
|
1029
1047
|
throw new Error("tenantId is required for magic link authentication");
|
|
1030
|
-
return await
|
|
1031
|
-
email:
|
|
1048
|
+
return await F.sendMagicLink({
|
|
1049
|
+
email: B,
|
|
1032
1050
|
tenantId: ee,
|
|
1033
1051
|
frontendUrl: Y,
|
|
1034
1052
|
name: V,
|
|
1035
1053
|
lastName: Z,
|
|
1036
1054
|
appId: t
|
|
1037
1055
|
});
|
|
1038
|
-
}, ge = async (
|
|
1039
|
-
const { token:
|
|
1056
|
+
}, ge = async (D) => {
|
|
1057
|
+
const { token: B, email: Y, tenantSlug: V } = D;
|
|
1040
1058
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
1041
|
-
V && (Z = (await new ue(
|
|
1042
|
-
const j = await
|
|
1043
|
-
token:
|
|
1059
|
+
V && (Z = (await new ue(C, t).getPublicTenantInfo(V)).id, Q = V);
|
|
1060
|
+
const j = await F.verifyMagicLink({
|
|
1061
|
+
token: B,
|
|
1044
1062
|
email: Y,
|
|
1045
1063
|
appId: t,
|
|
1046
1064
|
tenantId: Z
|
|
@@ -1053,14 +1071,14 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1053
1071
|
refreshToken: j.refreshToken,
|
|
1054
1072
|
expiresIn: j.expiresIn
|
|
1055
1073
|
}), j.user) {
|
|
1056
|
-
ee.setUser(j.user),
|
|
1074
|
+
ee.setUser(j.user), p(j.user);
|
|
1057
1075
|
try {
|
|
1058
1076
|
await a();
|
|
1059
1077
|
} catch (de) {
|
|
1060
1078
|
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1061
1079
|
}
|
|
1062
1080
|
}
|
|
1063
|
-
return le && Q && Q !== o &&
|
|
1081
|
+
return le && Q && Q !== o && h(Q, {
|
|
1064
1082
|
tokens: {
|
|
1065
1083
|
accessToken: j.accessToken,
|
|
1066
1084
|
refreshToken: j.refreshToken,
|
|
@@ -1068,49 +1086,49 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1068
1086
|
}
|
|
1069
1087
|
}), j;
|
|
1070
1088
|
}, Ce = async () => {
|
|
1071
|
-
const
|
|
1072
|
-
if (!(
|
|
1089
|
+
const D = d.getTokens();
|
|
1090
|
+
if (!(D != null && D.refreshToken))
|
|
1073
1091
|
throw new Error("No refresh token available");
|
|
1074
|
-
const
|
|
1075
|
-
refreshToken:
|
|
1092
|
+
const B = await F.refreshToken({
|
|
1093
|
+
refreshToken: D.refreshToken
|
|
1076
1094
|
});
|
|
1077
1095
|
d.setTokens({
|
|
1078
|
-
accessToken:
|
|
1079
|
-
refreshToken:
|
|
1080
|
-
expiresIn:
|
|
1096
|
+
accessToken: B.accessToken,
|
|
1097
|
+
refreshToken: B.refreshToken || D.refreshToken,
|
|
1098
|
+
expiresIn: B.expiresIn
|
|
1081
1099
|
});
|
|
1082
|
-
},
|
|
1083
|
-
d.clearSession(),
|
|
1084
|
-
},
|
|
1085
|
-
d.setTokens(
|
|
1086
|
-
},
|
|
1087
|
-
d.clearSession(),
|
|
1100
|
+
}, Fe = () => {
|
|
1101
|
+
d.clearSession(), p(null), R(null);
|
|
1102
|
+
}, $e = (D) => {
|
|
1103
|
+
d.setTokens(D);
|
|
1104
|
+
}, De = () => d.hasValidSession(), He = () => {
|
|
1105
|
+
d.clearSession(), p(null), R(null);
|
|
1088
1106
|
}, Ne = async () => {
|
|
1089
1107
|
if (t)
|
|
1090
1108
|
try {
|
|
1091
|
-
|
|
1092
|
-
const { roles:
|
|
1093
|
-
|
|
1094
|
-
} catch (
|
|
1095
|
-
console.error("Failed to fetch roles:",
|
|
1109
|
+
P(!0);
|
|
1110
|
+
const { roles: D } = await U.getRolesByApp(t);
|
|
1111
|
+
k(D);
|
|
1112
|
+
} catch (D) {
|
|
1113
|
+
console.error("Failed to fetch roles:", D);
|
|
1096
1114
|
} finally {
|
|
1097
|
-
|
|
1115
|
+
P(!1);
|
|
1098
1116
|
}
|
|
1099
1117
|
}, Ue = async () => {
|
|
1100
1118
|
await Ne();
|
|
1101
|
-
}, ye = (
|
|
1102
|
-
if (!
|
|
1119
|
+
}, ye = (D) => {
|
|
1120
|
+
if (!T || T.length === 0)
|
|
1103
1121
|
return !1;
|
|
1104
|
-
if (typeof
|
|
1105
|
-
return
|
|
1106
|
-
const
|
|
1107
|
-
return
|
|
1122
|
+
if (typeof D == "string")
|
|
1123
|
+
return T.includes(D);
|
|
1124
|
+
const B = `${D.resource}.${D.action}`;
|
|
1125
|
+
return T.includes(B);
|
|
1108
1126
|
};
|
|
1109
1127
|
return {
|
|
1110
1128
|
// RFC-003: Authentication state
|
|
1111
|
-
isAuthenticated:
|
|
1129
|
+
isAuthenticated: E,
|
|
1112
1130
|
sessionManager: d,
|
|
1113
|
-
authenticatedHttpService:
|
|
1131
|
+
authenticatedHttpService: C,
|
|
1114
1132
|
login: O,
|
|
1115
1133
|
signup: K,
|
|
1116
1134
|
signupTenantAdmin: H,
|
|
@@ -1118,112 +1136,97 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1118
1136
|
verifyMagicLink: ge,
|
|
1119
1137
|
changePassword: N,
|
|
1120
1138
|
requestPasswordReset: W,
|
|
1121
|
-
confirmPasswordReset:
|
|
1139
|
+
confirmPasswordReset: $,
|
|
1122
1140
|
refreshToken: Ce,
|
|
1123
|
-
logout:
|
|
1124
|
-
setTokens:
|
|
1125
|
-
hasValidSession:
|
|
1141
|
+
logout: Fe,
|
|
1142
|
+
setTokens: $e,
|
|
1143
|
+
hasValidSession: De,
|
|
1126
1144
|
clearSession: He,
|
|
1127
1145
|
currentUser: m,
|
|
1128
1146
|
isUserLoading: u,
|
|
1129
|
-
userError:
|
|
1147
|
+
userError: L,
|
|
1130
1148
|
loadUserData: a,
|
|
1131
|
-
refreshUser:
|
|
1132
|
-
userRole:
|
|
1133
|
-
userPermissions:
|
|
1149
|
+
refreshUser: f,
|
|
1150
|
+
userRole: x,
|
|
1151
|
+
userPermissions: T,
|
|
1134
1152
|
availableRoles: w,
|
|
1135
1153
|
rolesLoading: b,
|
|
1136
1154
|
hasPermission: ye,
|
|
1137
|
-
hasAnyPermission: (
|
|
1138
|
-
hasAllPermissions: (
|
|
1139
|
-
getUserPermissionStrings: () =>
|
|
1155
|
+
hasAnyPermission: (D) => D.some((B) => ye(B)),
|
|
1156
|
+
hasAllPermissions: (D) => D.every((B) => ye(B)),
|
|
1157
|
+
getUserPermissionStrings: () => T || [],
|
|
1140
1158
|
refreshRoles: Ue
|
|
1141
1159
|
};
|
|
1142
1160
|
}, [
|
|
1143
|
-
|
|
1161
|
+
E,
|
|
1144
1162
|
d,
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
z,
|
|
1163
|
+
C,
|
|
1164
|
+
F,
|
|
1148
1165
|
G,
|
|
1166
|
+
U,
|
|
1149
1167
|
t,
|
|
1150
1168
|
s,
|
|
1151
1169
|
o,
|
|
1152
|
-
|
|
1170
|
+
h,
|
|
1153
1171
|
w,
|
|
1154
1172
|
m,
|
|
1155
1173
|
u,
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1174
|
+
L,
|
|
1175
|
+
x,
|
|
1176
|
+
T,
|
|
1177
|
+
z,
|
|
1178
|
+
c
|
|
1161
1179
|
]);
|
|
1162
1180
|
te(() => {
|
|
1163
1181
|
!i.initialRoles && t && (async () => {
|
|
1164
1182
|
try {
|
|
1165
|
-
|
|
1166
|
-
const
|
|
1167
|
-
|
|
1168
|
-
} catch (
|
|
1169
|
-
console.error("Failed to fetch roles:",
|
|
1183
|
+
P(!0);
|
|
1184
|
+
const f = new re(r), O = new ke(f), { roles: K } = await O.getRolesByApp(t);
|
|
1185
|
+
k(K);
|
|
1186
|
+
} catch (f) {
|
|
1187
|
+
console.error("Failed to fetch roles:", f);
|
|
1170
1188
|
} finally {
|
|
1171
|
-
|
|
1189
|
+
P(!1);
|
|
1172
1190
|
}
|
|
1173
1191
|
})();
|
|
1174
1192
|
}, [t, r, i.initialRoles]);
|
|
1175
|
-
const [
|
|
1193
|
+
const [S, g] = v(!1);
|
|
1176
1194
|
return te(() => {
|
|
1177
|
-
|
|
1178
|
-
alreadyChecked: I,
|
|
1179
|
-
alreadyProcessed: h.current,
|
|
1180
|
-
currentUrl: typeof window < "u" ? window.location.href : "SSR"
|
|
1181
|
-
}), I) {
|
|
1182
|
-
console.log("[AuthProvider] URL tokens already checked, skipping");
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
k(!0);
|
|
1186
|
-
const a = Je();
|
|
1187
|
-
console.log("[AuthProvider] URL tokens extraction result:", {
|
|
1188
|
-
found: !!a,
|
|
1189
|
-
hasAccessToken: !!(a != null && a.accessToken)
|
|
1190
|
-
}), a && (h.current = !0, console.log("[AuthProvider] Saving URL tokens to session..."), d.setTokens({
|
|
1191
|
-
accessToken: a.accessToken,
|
|
1192
|
-
refreshToken: a.refreshToken,
|
|
1193
|
-
expiresIn: a.expiresIn
|
|
1194
|
-
}), console.log("[AuthProvider] Tokens saved, verifying session validity:", {
|
|
1195
|
-
hasValidSession: d.hasValidSession()
|
|
1196
|
-
}), Ye(), console.log("[AuthProvider] Loading user data after URL token consumption..."), l.loadUserData().catch((p) => {
|
|
1195
|
+
S || (g(!0), A.current.tokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), Ye(), console.log("[AuthProvider] EFFECT: Loading user data after URL token consumption..."), I.loadUserData().catch((a) => {
|
|
1197
1196
|
console.error(
|
|
1198
1197
|
"[AuthProvider] Failed to load user data after URL token consumption:",
|
|
1199
|
-
|
|
1198
|
+
a
|
|
1200
1199
|
);
|
|
1201
|
-
}));
|
|
1202
|
-
}, [
|
|
1200
|
+
})));
|
|
1201
|
+
}, [I, S]), te(() => {
|
|
1203
1202
|
const a = d.getUser();
|
|
1204
|
-
a && d.hasValidSession() &&
|
|
1203
|
+
a && d.hasValidSession() && p(a);
|
|
1205
1204
|
}, [d]), te(() => {
|
|
1206
1205
|
if (console.log("[AuthProvider] Auto-load effect running", {
|
|
1207
1206
|
hasCurrentUser: !!m,
|
|
1208
1207
|
isUserLoading: u,
|
|
1209
1208
|
hasValidSession: d.hasValidSession(),
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}), !
|
|
1213
|
-
console.log("[AuthProvider] Waiting for URL tokens
|
|
1209
|
+
urlTokensCleanedUp: S,
|
|
1210
|
+
hadUrlTokens: !!A.current.tokens
|
|
1211
|
+
}), !S) {
|
|
1212
|
+
console.log("[AuthProvider] Waiting for URL tokens cleanup before auto-load");
|
|
1214
1213
|
return;
|
|
1215
1214
|
}
|
|
1216
|
-
|
|
1215
|
+
if (A.current.tokens) {
|
|
1216
|
+
console.log("[AuthProvider] URL tokens present, skipping auto-load (already handled)");
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
!m && !u && (console.log("[AuthProvider] Auto-loading user data..."), I.loadUserData().catch(() => {
|
|
1217
1220
|
}));
|
|
1218
|
-
}, [m, u,
|
|
1221
|
+
}, [m, u, I, d, S]), te(() => {
|
|
1219
1222
|
if (!d.hasValidSession() || !m)
|
|
1220
1223
|
return;
|
|
1221
1224
|
const a = setInterval(() => {
|
|
1222
|
-
|
|
1225
|
+
I.loadUserData().catch(() => {
|
|
1223
1226
|
});
|
|
1224
|
-
},
|
|
1227
|
+
}, c);
|
|
1225
1228
|
return () => clearInterval(a);
|
|
1226
|
-
}, [d, m,
|
|
1229
|
+
}, [d, m, I, c]), /* @__PURE__ */ n(Ie.Provider, { value: I, children: e });
|
|
1227
1230
|
}
|
|
1228
1231
|
function ae() {
|
|
1229
1232
|
const i = ce(Ie);
|
|
@@ -1313,45 +1316,45 @@ class Qe {
|
|
|
1313
1316
|
}
|
|
1314
1317
|
const Le = he(null);
|
|
1315
1318
|
function Ut({ config: i = {}, children: e }) {
|
|
1316
|
-
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o,
|
|
1319
|
+
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, h] = v([]), [w, k] = v(!1), [b, P] = v(null), m = X(() => {
|
|
1317
1320
|
const y = new re(t);
|
|
1318
1321
|
return new Qe(y);
|
|
1319
|
-
}, [t]),
|
|
1322
|
+
}, [t]), p = async () => {
|
|
1320
1323
|
if (!(s != null && s.id)) {
|
|
1321
|
-
|
|
1324
|
+
h([]);
|
|
1322
1325
|
return;
|
|
1323
1326
|
}
|
|
1324
|
-
|
|
1327
|
+
k(!0), P(null);
|
|
1325
1328
|
try {
|
|
1326
1329
|
const y = await m.getTenantFeatureFlags(s.id, r);
|
|
1327
|
-
|
|
1330
|
+
h(y);
|
|
1328
1331
|
} catch (y) {
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1332
|
+
const L = y instanceof Error ? y.message : "Failed to fetch feature flags";
|
|
1333
|
+
P(L), i.onError && i.onError(y instanceof Error ? y : new Error(L));
|
|
1331
1334
|
} finally {
|
|
1332
|
-
|
|
1335
|
+
k(!1);
|
|
1333
1336
|
}
|
|
1334
1337
|
};
|
|
1335
1338
|
te(() => {
|
|
1336
|
-
|
|
1337
|
-
const y = i.refreshInterval || 5 * 60 * 1e3,
|
|
1338
|
-
return () => clearInterval(
|
|
1339
|
+
p();
|
|
1340
|
+
const y = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(p, y);
|
|
1341
|
+
return () => clearInterval(L);
|
|
1339
1342
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1340
1343
|
const u = X(() => ({
|
|
1341
1344
|
featureFlags: o,
|
|
1342
1345
|
loading: w,
|
|
1343
1346
|
error: b,
|
|
1344
|
-
isEnabled: (
|
|
1345
|
-
const
|
|
1346
|
-
return (
|
|
1347
|
+
isEnabled: (M) => {
|
|
1348
|
+
const A = o.find((d) => d.key === M);
|
|
1349
|
+
return (A == null ? void 0 : A.value) === !0;
|
|
1347
1350
|
},
|
|
1348
|
-
getFlag: (
|
|
1349
|
-
getFlagState: (
|
|
1350
|
-
const
|
|
1351
|
-
return
|
|
1351
|
+
getFlag: (M) => o.find((A) => A.key === M),
|
|
1352
|
+
getFlagState: (M) => {
|
|
1353
|
+
const A = o.find((d) => d.key === M);
|
|
1354
|
+
return A ? A.value ? "enabled" : "disabled" : "not_found";
|
|
1352
1355
|
},
|
|
1353
1356
|
refresh: async () => {
|
|
1354
|
-
await
|
|
1357
|
+
await p();
|
|
1355
1358
|
}
|
|
1356
1359
|
}), [o, w, b]);
|
|
1357
1360
|
return /* @__PURE__ */ n(Le.Provider, { value: u, children: e });
|
|
@@ -1430,7 +1433,7 @@ class Ze {
|
|
|
1430
1433
|
}
|
|
1431
1434
|
const Re = he(void 0);
|
|
1432
1435
|
function Bt({ config: i = {}, children: e }) {
|
|
1433
|
-
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = v(null), [
|
|
1436
|
+
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = v(null), [h, w] = v(!1), [k, b] = v(null), P = X(() => {
|
|
1434
1437
|
const u = new re(t);
|
|
1435
1438
|
return new Ze(u);
|
|
1436
1439
|
}, [t]), m = async () => {
|
|
@@ -1440,7 +1443,7 @@ function Bt({ config: i = {}, children: e }) {
|
|
|
1440
1443
|
}
|
|
1441
1444
|
w(!0), b(null);
|
|
1442
1445
|
try {
|
|
1443
|
-
const u = await
|
|
1446
|
+
const u = await P.getTenantSubscriptionFeatures(r.id);
|
|
1444
1447
|
o(u);
|
|
1445
1448
|
} catch (u) {
|
|
1446
1449
|
const y = u instanceof Error ? u.message : "Failed to fetch subscription";
|
|
@@ -1454,29 +1457,29 @@ function Bt({ config: i = {}, children: e }) {
|
|
|
1454
1457
|
const u = i.refreshInterval || 10 * 60 * 1e3, y = setInterval(m, u);
|
|
1455
1458
|
return () => clearInterval(y);
|
|
1456
1459
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1457
|
-
const
|
|
1460
|
+
const p = X(() => {
|
|
1458
1461
|
const u = (s == null ? void 0 : s.features) || [];
|
|
1459
1462
|
return {
|
|
1460
1463
|
subscription: s,
|
|
1461
1464
|
features: u,
|
|
1462
|
-
loading:
|
|
1463
|
-
error:
|
|
1464
|
-
isFeatureEnabled: (
|
|
1465
|
-
const
|
|
1466
|
-
return
|
|
1465
|
+
loading: h,
|
|
1466
|
+
error: k,
|
|
1467
|
+
isFeatureEnabled: (A) => {
|
|
1468
|
+
const d = u.find((C) => C.key === A);
|
|
1469
|
+
return d ? d.type === "BOOLEAN" || d.type === "boolean" ? d.value === !0 : !!d.value : !1;
|
|
1467
1470
|
},
|
|
1468
|
-
getFeature: (
|
|
1469
|
-
getFeatureValue: (
|
|
1470
|
-
const
|
|
1471
|
-
return
|
|
1471
|
+
getFeature: (A) => u.find((d) => d.key === A),
|
|
1472
|
+
getFeatureValue: (A, d) => {
|
|
1473
|
+
const C = u.find((F) => F.key === A);
|
|
1474
|
+
return C ? C.value : d;
|
|
1472
1475
|
},
|
|
1473
|
-
hasAllowedPlan: (
|
|
1476
|
+
hasAllowedPlan: (A) => !s || !s.isActive ? !1 : A.includes(s.planId),
|
|
1474
1477
|
refresh: async () => {
|
|
1475
1478
|
await m();
|
|
1476
1479
|
}
|
|
1477
1480
|
};
|
|
1478
|
-
}, [s,
|
|
1479
|
-
return /* @__PURE__ */ n(Re.Provider, { value:
|
|
1481
|
+
}, [s, h, k]);
|
|
1482
|
+
return /* @__PURE__ */ n(Re.Provider, { value: p, children: e });
|
|
1480
1483
|
}
|
|
1481
1484
|
function et() {
|
|
1482
1485
|
const i = ce(Re);
|
|
@@ -1485,7 +1488,7 @@ function et() {
|
|
|
1485
1488
|
return i;
|
|
1486
1489
|
}
|
|
1487
1490
|
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1488
|
-
const
|
|
1491
|
+
const xe = () => /* @__PURE__ */ l(
|
|
1489
1492
|
"div",
|
|
1490
1493
|
{
|
|
1491
1494
|
style: {
|
|
@@ -1526,7 +1529,7 @@ const ke = () => /* @__PURE__ */ c(
|
|
|
1526
1529
|
userType: i,
|
|
1527
1530
|
minUserType: e,
|
|
1528
1531
|
missingPermissions: t
|
|
1529
|
-
}) => /* @__PURE__ */
|
|
1532
|
+
}) => /* @__PURE__ */ l(
|
|
1530
1533
|
"div",
|
|
1531
1534
|
{
|
|
1532
1535
|
style: {
|
|
@@ -1544,19 +1547,19 @@ const ke = () => /* @__PURE__ */ c(
|
|
|
1544
1547
|
children: [
|
|
1545
1548
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1546
1549
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1547
|
-
e && i ? /* @__PURE__ */
|
|
1548
|
-
/* @__PURE__ */
|
|
1550
|
+
e && i ? /* @__PURE__ */ l(q, { children: [
|
|
1551
|
+
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1549
1552
|
"This content requires ",
|
|
1550
1553
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1551
1554
|
" access level or higher."
|
|
1552
1555
|
] }),
|
|
1553
|
-
/* @__PURE__ */
|
|
1556
|
+
/* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1554
1557
|
"Your current access level: ",
|
|
1555
1558
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1556
1559
|
] })
|
|
1557
|
-
] }) : /* @__PURE__ */
|
|
1560
|
+
] }) : /* @__PURE__ */ l(q, { children: [
|
|
1558
1561
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1559
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1562
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1560
1563
|
"Required permissions: ",
|
|
1561
1564
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1562
1565
|
] })
|
|
@@ -1578,19 +1581,19 @@ function qt({
|
|
|
1578
1581
|
requiredPermissions: r,
|
|
1579
1582
|
requireAllPermissions: s = !1
|
|
1580
1583
|
}) {
|
|
1581
|
-
const { hasValidSession: o, sessionManager:
|
|
1584
|
+
const { hasValidSession: o, sessionManager: h, hasPermission: w, hasAnyPermission: k, hasAllPermissions: b } = ae();
|
|
1582
1585
|
if (!o())
|
|
1583
|
-
return /* @__PURE__ */ n(
|
|
1584
|
-
const
|
|
1585
|
-
if (!
|
|
1586
|
-
return /* @__PURE__ */ n(
|
|
1587
|
-
if (t && !tt(
|
|
1588
|
-
return /* @__PURE__ */ n(Ae, { userType:
|
|
1589
|
-
if (r && r.length > 0 && !(s ? b(r) :
|
|
1590
|
-
const
|
|
1591
|
-
return /* @__PURE__ */ n(Ae, { missingPermissions:
|
|
1592
|
-
}
|
|
1593
|
-
return /* @__PURE__ */ n(
|
|
1586
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1587
|
+
const P = h.getUser();
|
|
1588
|
+
if (!P)
|
|
1589
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1590
|
+
if (t && !tt(P.userType, t))
|
|
1591
|
+
return /* @__PURE__ */ n(Ae, { userType: P.userType, minUserType: t });
|
|
1592
|
+
if (r && r.length > 0 && !(s ? b(r) : k(r))) {
|
|
1593
|
+
const p = r.filter((u) => !w(u)).map((u) => typeof u == "string" ? u : u.name);
|
|
1594
|
+
return /* @__PURE__ */ n(Ae, { missingPermissions: p });
|
|
1595
|
+
}
|
|
1596
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
1594
1597
|
}
|
|
1595
1598
|
const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1596
1599
|
"div",
|
|
@@ -1605,7 +1608,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1605
1608
|
backgroundColor: "#f9fafb",
|
|
1606
1609
|
textAlign: "center"
|
|
1607
1610
|
},
|
|
1608
|
-
children: /* @__PURE__ */
|
|
1611
|
+
children: /* @__PURE__ */ l(
|
|
1609
1612
|
"div",
|
|
1610
1613
|
{
|
|
1611
1614
|
style: {
|
|
@@ -1619,7 +1622,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1619
1622
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1620
1623
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1621
1624
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1622
|
-
/* @__PURE__ */
|
|
1625
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1623
1626
|
"Redirecting to ",
|
|
1624
1627
|
i,
|
|
1625
1628
|
"..."
|
|
@@ -1645,7 +1648,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1645
1648
|
backgroundColor: "#f9fafb",
|
|
1646
1649
|
textAlign: "center"
|
|
1647
1650
|
},
|
|
1648
|
-
children: /* @__PURE__ */
|
|
1651
|
+
children: /* @__PURE__ */ l(
|
|
1649
1652
|
"div",
|
|
1650
1653
|
{
|
|
1651
1654
|
style: {
|
|
@@ -1658,19 +1661,19 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1658
1661
|
children: [
|
|
1659
1662
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1660
1663
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1661
|
-
e && i ? /* @__PURE__ */
|
|
1662
|
-
/* @__PURE__ */
|
|
1664
|
+
e && i ? /* @__PURE__ */ l(q, { children: [
|
|
1665
|
+
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1663
1666
|
"This page requires ",
|
|
1664
1667
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1665
1668
|
" access level or higher."
|
|
1666
1669
|
] }),
|
|
1667
|
-
/* @__PURE__ */
|
|
1670
|
+
/* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1668
1671
|
"Your current access level: ",
|
|
1669
1672
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1670
1673
|
] })
|
|
1671
|
-
] }) : /* @__PURE__ */
|
|
1674
|
+
] }) : /* @__PURE__ */ l(q, { children: [
|
|
1672
1675
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1673
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1676
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1674
1677
|
"Required permissions: ",
|
|
1675
1678
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1676
1679
|
] })
|
|
@@ -1695,22 +1698,22 @@ function zt({
|
|
|
1695
1698
|
requireAllPermissions: s = !1,
|
|
1696
1699
|
fallback: o
|
|
1697
1700
|
}) {
|
|
1698
|
-
const { hasValidSession:
|
|
1699
|
-
if (!
|
|
1700
|
-
return o ? /* @__PURE__ */ n(
|
|
1701
|
+
const { hasValidSession: h, sessionManager: w, hasPermission: k, hasAnyPermission: b, hasAllPermissions: P } = ae(), m = be();
|
|
1702
|
+
if (!h())
|
|
1703
|
+
return o ? /* @__PURE__ */ n(q, { children: o }) : /* @__PURE__ */ l(q, { children: [
|
|
1701
1704
|
/* @__PURE__ */ n(rt, { redirectPath: e }),
|
|
1702
1705
|
/* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1703
1706
|
] });
|
|
1704
|
-
const
|
|
1705
|
-
if (!
|
|
1707
|
+
const p = w.getUser();
|
|
1708
|
+
if (!p)
|
|
1706
1709
|
return /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 });
|
|
1707
|
-
if (t && !nt(
|
|
1708
|
-
return /* @__PURE__ */ n(Te, { userType:
|
|
1709
|
-
if (r && r.length > 0 && !(s ?
|
|
1710
|
-
const y = r.filter((
|
|
1710
|
+
if (t && !nt(p.userType, t))
|
|
1711
|
+
return /* @__PURE__ */ n(Te, { userType: p.userType, minUserType: t });
|
|
1712
|
+
if (r && r.length > 0 && !(s ? P(r) : b(r))) {
|
|
1713
|
+
const y = r.filter((L) => !k(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
1711
1714
|
return /* @__PURE__ */ n(Te, { missingPermissions: y });
|
|
1712
1715
|
}
|
|
1713
|
-
return /* @__PURE__ */ n(
|
|
1716
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
1714
1717
|
}
|
|
1715
1718
|
const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1716
1719
|
"div",
|
|
@@ -1725,7 +1728,7 @@ const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1725
1728
|
backgroundColor: "#f9fafb",
|
|
1726
1729
|
textAlign: "center"
|
|
1727
1730
|
},
|
|
1728
|
-
children: /* @__PURE__ */
|
|
1731
|
+
children: /* @__PURE__ */ l(
|
|
1729
1732
|
"div",
|
|
1730
1733
|
{
|
|
1731
1734
|
style: {
|
|
@@ -1739,7 +1742,7 @@ const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1739
1742
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1740
1743
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1741
1744
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1742
|
-
/* @__PURE__ */
|
|
1745
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1743
1746
|
"Redirecting to ",
|
|
1744
1747
|
i,
|
|
1745
1748
|
"..."
|
|
@@ -1750,10 +1753,10 @@ const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1750
1753
|
}
|
|
1751
1754
|
);
|
|
1752
1755
|
function Ot({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1753
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1754
|
-
return s || o ? null : r ? /* @__PURE__ */ n(
|
|
1756
|
+
const { tenant: r, isLoading: s, error: o } = se(), h = be();
|
|
1757
|
+
return s || o ? null : r ? /* @__PURE__ */ n(q, { children: i }) : t ? /* @__PURE__ */ n(q, { children: t }) : /* @__PURE__ */ l(q, { children: [
|
|
1755
1758
|
/* @__PURE__ */ n(st, { redirectPath: e }),
|
|
1756
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1759
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1757
1760
|
] });
|
|
1758
1761
|
}
|
|
1759
1762
|
const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
@@ -1769,7 +1772,7 @@ const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1769
1772
|
backgroundColor: "#f9fafb",
|
|
1770
1773
|
textAlign: "center"
|
|
1771
1774
|
},
|
|
1772
|
-
children: /* @__PURE__ */
|
|
1775
|
+
children: /* @__PURE__ */ l(
|
|
1773
1776
|
"div",
|
|
1774
1777
|
{
|
|
1775
1778
|
style: {
|
|
@@ -1783,7 +1786,7 @@ const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1783
1786
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1784
1787
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1785
1788
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1786
|
-
/* @__PURE__ */
|
|
1789
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1787
1790
|
"Redirecting to ",
|
|
1788
1791
|
i,
|
|
1789
1792
|
"..."
|
|
@@ -1794,13 +1797,13 @@ const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1794
1797
|
}
|
|
1795
1798
|
);
|
|
1796
1799
|
function Wt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1797
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1798
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(
|
|
1800
|
+
const { tenant: r, isLoading: s, error: o } = se(), h = be();
|
|
1801
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(q, { children: t }) : /* @__PURE__ */ l(q, { children: [
|
|
1799
1802
|
/* @__PURE__ */ n(it, { redirectPath: e }),
|
|
1800
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1801
|
-
] }) : /* @__PURE__ */ n(
|
|
1803
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1804
|
+
] }) : /* @__PURE__ */ n(q, { children: i });
|
|
1802
1805
|
}
|
|
1803
|
-
const ot = () => /* @__PURE__ */
|
|
1806
|
+
const ot = () => /* @__PURE__ */ l(
|
|
1804
1807
|
"div",
|
|
1805
1808
|
{
|
|
1806
1809
|
style: {
|
|
@@ -1823,7 +1826,7 @@ function Vt({
|
|
|
1823
1826
|
allowedPlans: t,
|
|
1824
1827
|
requiredFeature: r
|
|
1825
1828
|
}) {
|
|
1826
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled:
|
|
1829
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: h, loading: w } = et();
|
|
1827
1830
|
return w ? /* @__PURE__ */ n(
|
|
1828
1831
|
"div",
|
|
1829
1832
|
{
|
|
@@ -1834,9 +1837,9 @@ function Vt({
|
|
|
1834
1837
|
},
|
|
1835
1838
|
children: "Loading subscription..."
|
|
1836
1839
|
}
|
|
1837
|
-
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(
|
|
1840
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(q, { children: e }) : r && !h(r) ? /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: i }) : /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: e });
|
|
1838
1841
|
}
|
|
1839
|
-
const at = ({ flagName: i }) => /* @__PURE__ */
|
|
1842
|
+
const at = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1840
1843
|
"div",
|
|
1841
1844
|
{
|
|
1842
1845
|
style: {
|
|
@@ -1855,7 +1858,7 @@ const at = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
|
1855
1858
|
children: [
|
|
1856
1859
|
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1857
1860
|
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1858
|
-
/* @__PURE__ */
|
|
1861
|
+
/* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1859
1862
|
'Feature flag "',
|
|
1860
1863
|
i,
|
|
1861
1864
|
'" is disabled'
|
|
@@ -1878,9 +1881,9 @@ function jt({ name: i, children: e, fallback: t }) {
|
|
|
1878
1881
|
},
|
|
1879
1882
|
children: "Loading feature flags..."
|
|
1880
1883
|
}
|
|
1881
|
-
) : r(i) ? /* @__PURE__ */ n(
|
|
1884
|
+
) : r(i) ? /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: t || /* @__PURE__ */ n(at, { flagName: i }) });
|
|
1882
1885
|
}
|
|
1883
|
-
const lt = () => /* @__PURE__ */
|
|
1886
|
+
const lt = () => /* @__PURE__ */ l(
|
|
1884
1887
|
"svg",
|
|
1885
1888
|
{
|
|
1886
1889
|
width: "16",
|
|
@@ -1897,7 +1900,7 @@ const lt = () => /* @__PURE__ */ c(
|
|
|
1897
1900
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1898
1901
|
]
|
|
1899
1902
|
}
|
|
1900
|
-
), ct = () => /* @__PURE__ */
|
|
1903
|
+
), ct = () => /* @__PURE__ */ l(
|
|
1901
1904
|
"svg",
|
|
1902
1905
|
{
|
|
1903
1906
|
width: "16",
|
|
@@ -2045,121 +2048,121 @@ function _t({
|
|
|
2045
2048
|
onSuccess: r,
|
|
2046
2049
|
onError: s,
|
|
2047
2050
|
onForgotPassword: o,
|
|
2048
|
-
onSignupClick:
|
|
2051
|
+
onSignupClick: h,
|
|
2049
2052
|
onMagicLinkClick: w,
|
|
2050
|
-
showForgotPassword:
|
|
2053
|
+
showForgotPassword: k = !0,
|
|
2051
2054
|
showSignupLink: b = !0,
|
|
2052
|
-
showMagicLinkOption:
|
|
2055
|
+
showMagicLinkOption: P = !0,
|
|
2053
2056
|
className: m
|
|
2054
2057
|
}) {
|
|
2055
|
-
const [
|
|
2058
|
+
const [p, u] = v(""), [y, L] = v(""), [R, z] = v(!1), [M, A] = v(!1), [d, C] = v(""), [F, G] = v({}), { login: U } = ae(), { tenant: _ } = se(), x = { ...ut, ...i }, T = { ...ht, ...e }, E = { ...dt, ...t }, c = () => {
|
|
2056
2059
|
const a = {};
|
|
2057
|
-
return
|
|
2060
|
+
return p.trim() || (a.username = !0), y.trim() || (a.password = !0), G(a), Object.keys(a).length === 0;
|
|
2058
2061
|
}, I = async (a) => {
|
|
2059
|
-
if (a.preventDefault(), !!
|
|
2062
|
+
if (a.preventDefault(), !!c()) {
|
|
2060
2063
|
if (!(_ != null && _.id)) {
|
|
2061
|
-
|
|
2064
|
+
C("Tenant not found");
|
|
2062
2065
|
return;
|
|
2063
2066
|
}
|
|
2064
|
-
|
|
2067
|
+
A(!0), C("");
|
|
2065
2068
|
try {
|
|
2066
|
-
const
|
|
2067
|
-
username:
|
|
2069
|
+
const f = await U({
|
|
2070
|
+
username: p,
|
|
2068
2071
|
password: y
|
|
2069
2072
|
// tenantId inferred from context automatically
|
|
2070
2073
|
});
|
|
2071
|
-
r == null || r(
|
|
2072
|
-
} catch (
|
|
2073
|
-
const O =
|
|
2074
|
-
|
|
2074
|
+
r == null || r(f);
|
|
2075
|
+
} catch (f) {
|
|
2076
|
+
const O = f.message || x.errorMessage;
|
|
2077
|
+
C(O), s == null || s(O);
|
|
2075
2078
|
} finally {
|
|
2076
|
-
|
|
2079
|
+
A(!1);
|
|
2077
2080
|
}
|
|
2078
2081
|
}
|
|
2079
|
-
},
|
|
2080
|
-
...
|
|
2081
|
-
...
|
|
2082
|
-
}),
|
|
2083
|
-
...
|
|
2084
|
-
...
|
|
2085
|
-
...!
|
|
2082
|
+
}, S = (a) => ({
|
|
2083
|
+
...T.input,
|
|
2084
|
+
...F[a] ? T.inputError : {}
|
|
2085
|
+
}), g = () => ({
|
|
2086
|
+
...T.button,
|
|
2087
|
+
...M ? T.buttonLoading : {},
|
|
2088
|
+
...!p || !y || M ? T.buttonDisabled : {}
|
|
2086
2089
|
});
|
|
2087
|
-
return /* @__PURE__ */
|
|
2088
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2089
|
-
/* @__PURE__ */
|
|
2090
|
-
/* @__PURE__ */
|
|
2091
|
-
/* @__PURE__ */ n("label", { style:
|
|
2090
|
+
return /* @__PURE__ */ l("div", { className: m, style: T.container, children: [
|
|
2091
|
+
/* @__PURE__ */ n("h2", { style: T.title, children: x.title }),
|
|
2092
|
+
/* @__PURE__ */ l("form", { onSubmit: I, style: T.form, children: [
|
|
2093
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2094
|
+
/* @__PURE__ */ n("label", { style: T.label, children: x.usernameLabel }),
|
|
2092
2095
|
/* @__PURE__ */ n(
|
|
2093
2096
|
"input",
|
|
2094
2097
|
{
|
|
2095
2098
|
id: "username",
|
|
2096
2099
|
name: "username",
|
|
2097
2100
|
type: "text",
|
|
2098
|
-
value:
|
|
2101
|
+
value: p,
|
|
2099
2102
|
onChange: (a) => {
|
|
2100
|
-
u(a.target.value),
|
|
2103
|
+
u(a.target.value), F.username && G((f) => ({ ...f, username: !1 }));
|
|
2101
2104
|
},
|
|
2102
|
-
placeholder:
|
|
2103
|
-
style:
|
|
2104
|
-
disabled:
|
|
2105
|
+
placeholder: x.usernamePlaceholder,
|
|
2106
|
+
style: S("username"),
|
|
2107
|
+
disabled: M
|
|
2105
2108
|
}
|
|
2106
2109
|
)
|
|
2107
2110
|
] }),
|
|
2108
|
-
/* @__PURE__ */
|
|
2109
|
-
/* @__PURE__ */ n("label", { style:
|
|
2110
|
-
/* @__PURE__ */
|
|
2111
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2112
|
+
/* @__PURE__ */ n("label", { style: T.label, children: x.passwordLabel }),
|
|
2113
|
+
/* @__PURE__ */ l("div", { style: T.inputContainer, children: [
|
|
2111
2114
|
/* @__PURE__ */ n(
|
|
2112
2115
|
"input",
|
|
2113
2116
|
{
|
|
2114
2117
|
id: "password",
|
|
2115
2118
|
name: "password",
|
|
2116
|
-
type:
|
|
2119
|
+
type: R ? "text" : "password",
|
|
2117
2120
|
value: y,
|
|
2118
2121
|
onChange: (a) => {
|
|
2119
|
-
|
|
2122
|
+
L(a.target.value), F.password && G((f) => ({ ...f, password: !1 }));
|
|
2120
2123
|
},
|
|
2121
|
-
placeholder:
|
|
2124
|
+
placeholder: x.passwordPlaceholder,
|
|
2122
2125
|
style: {
|
|
2123
|
-
...
|
|
2126
|
+
...S("password"),
|
|
2124
2127
|
paddingRight: "2.5rem"
|
|
2125
2128
|
// Make room for the icon
|
|
2126
2129
|
},
|
|
2127
|
-
disabled:
|
|
2130
|
+
disabled: M
|
|
2128
2131
|
}
|
|
2129
2132
|
),
|
|
2130
2133
|
/* @__PURE__ */ n(
|
|
2131
2134
|
"button",
|
|
2132
2135
|
{
|
|
2133
2136
|
type: "button",
|
|
2134
|
-
onClick: () =>
|
|
2135
|
-
style:
|
|
2136
|
-
disabled:
|
|
2137
|
-
"aria-label":
|
|
2138
|
-
children:
|
|
2137
|
+
onClick: () => z(!R),
|
|
2138
|
+
style: T.passwordToggle,
|
|
2139
|
+
disabled: M,
|
|
2140
|
+
"aria-label": R ? "Hide password" : "Show password",
|
|
2141
|
+
children: R ? E.hidePassword : E.showPassword
|
|
2139
2142
|
}
|
|
2140
2143
|
)
|
|
2141
2144
|
] })
|
|
2142
2145
|
] }),
|
|
2143
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2144
|
-
|
|
2146
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !p || !y || M, style: g(), children: M ? x.loadingText : x.submitButton }),
|
|
2147
|
+
d && /* @__PURE__ */ n("div", { style: T.errorText, children: d })
|
|
2145
2148
|
] }),
|
|
2146
|
-
(
|
|
2147
|
-
|
|
2148
|
-
/* @__PURE__ */
|
|
2149
|
-
|
|
2149
|
+
(k || b || P) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
|
|
2150
|
+
P && /* @__PURE__ */ l("div", { children: [
|
|
2151
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2152
|
+
x.magicLinkText,
|
|
2150
2153
|
" "
|
|
2151
2154
|
] }),
|
|
2152
|
-
/* @__PURE__ */ n("a", { onClick: w, style:
|
|
2155
|
+
/* @__PURE__ */ n("a", { onClick: w, style: T.link, children: x.magicLinkLink })
|
|
2153
2156
|
] }),
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
b && /* @__PURE__ */
|
|
2158
|
-
/* @__PURE__ */
|
|
2159
|
-
|
|
2157
|
+
P && (k || b) && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
|
|
2158
|
+
k && /* @__PURE__ */ n("a", { onClick: o, style: T.link, children: x.forgotPasswordLink }),
|
|
2159
|
+
k && b && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
|
|
2160
|
+
b && /* @__PURE__ */ l("div", { children: [
|
|
2161
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2162
|
+
x.signupText,
|
|
2160
2163
|
" "
|
|
2161
2164
|
] }),
|
|
2162
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2165
|
+
/* @__PURE__ */ n("a", { onClick: h, style: T.link, children: x.signupLink })
|
|
2163
2166
|
] })
|
|
2164
2167
|
] })
|
|
2165
2168
|
] });
|
|
@@ -2296,96 +2299,96 @@ function Gt({
|
|
|
2296
2299
|
onSuccess: r,
|
|
2297
2300
|
onError: s,
|
|
2298
2301
|
onLoginClick: o,
|
|
2299
|
-
onMagicLinkClick:
|
|
2302
|
+
onMagicLinkClick: h,
|
|
2300
2303
|
showLoginLink: w = !0,
|
|
2301
|
-
showMagicLinkOption:
|
|
2304
|
+
showMagicLinkOption: k = !0,
|
|
2302
2305
|
className: b
|
|
2303
2306
|
}) {
|
|
2304
|
-
const [
|
|
2305
|
-
const
|
|
2306
|
-
return
|
|
2307
|
-
}, K = async (
|
|
2308
|
-
if (
|
|
2309
|
-
if (
|
|
2310
|
-
|
|
2307
|
+
const [P, m] = v(""), [p, u] = v(""), [y, L] = v(""), [R, z] = v(""), [M, A] = v(""), [d, C] = v(""), [F, G] = v(""), [U, _] = v(!1), [x, T] = v(""), [E, c] = v({}), { signup: I, signupTenantAdmin: S } = ae(), { tenant: g } = se(), a = { ...gt, ...i }, f = { ...pt, ...e }, O = () => {
|
|
2308
|
+
const $ = {};
|
|
2309
|
+
return P.trim() || ($.name = !0), !y.trim() && !R.trim() && ($.email = !0, $.phoneNumber = !0), M.trim() || ($.password = !0), d.trim() || ($.confirmPassword = !0), t === "tenant" && !F.trim() && ($.tenantName = !0), c($), Object.keys($).length === 0;
|
|
2310
|
+
}, K = async ($) => {
|
|
2311
|
+
if ($.preventDefault(), !!O()) {
|
|
2312
|
+
if (M !== d) {
|
|
2313
|
+
T(a.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2311
2314
|
return;
|
|
2312
2315
|
}
|
|
2313
|
-
if (t === "user" && !(
|
|
2314
|
-
|
|
2316
|
+
if (t === "user" && !(g != null && g.id)) {
|
|
2317
|
+
T("Tenant not found");
|
|
2315
2318
|
return;
|
|
2316
2319
|
}
|
|
2317
|
-
_(!0),
|
|
2320
|
+
_(!0), T("");
|
|
2318
2321
|
try {
|
|
2319
2322
|
let J;
|
|
2320
|
-
t === "tenant" ? J = await
|
|
2323
|
+
t === "tenant" ? J = await S({
|
|
2321
2324
|
email: y || void 0,
|
|
2322
|
-
phoneNumber:
|
|
2323
|
-
name:
|
|
2324
|
-
password:
|
|
2325
|
-
tenantName:
|
|
2326
|
-
lastName:
|
|
2325
|
+
phoneNumber: R || void 0,
|
|
2326
|
+
name: P,
|
|
2327
|
+
password: M,
|
|
2328
|
+
tenantName: F,
|
|
2329
|
+
lastName: p || void 0
|
|
2327
2330
|
}) : J = await I({
|
|
2328
2331
|
email: y || void 0,
|
|
2329
|
-
phoneNumber:
|
|
2330
|
-
name:
|
|
2331
|
-
password:
|
|
2332
|
-
tenantId:
|
|
2333
|
-
lastName:
|
|
2332
|
+
phoneNumber: R || void 0,
|
|
2333
|
+
name: P,
|
|
2334
|
+
password: M,
|
|
2335
|
+
tenantId: g.id,
|
|
2336
|
+
lastName: p || void 0
|
|
2334
2337
|
}), r == null || r(J);
|
|
2335
2338
|
} catch (J) {
|
|
2336
2339
|
const ge = J.message || a.errorMessage;
|
|
2337
|
-
|
|
2340
|
+
T(ge), s == null || s(ge);
|
|
2338
2341
|
} finally {
|
|
2339
2342
|
_(!1);
|
|
2340
2343
|
}
|
|
2341
2344
|
}
|
|
2342
|
-
}, H = (
|
|
2343
|
-
...
|
|
2344
|
-
...
|
|
2345
|
+
}, H = ($) => ({
|
|
2346
|
+
...f.input,
|
|
2347
|
+
...E[$] ? f.inputError : {}
|
|
2345
2348
|
}), N = () => ({
|
|
2346
|
-
...
|
|
2347
|
-
|
|
2348
|
-
...!
|
|
2349
|
-
}), W =
|
|
2350
|
-
return /* @__PURE__ */
|
|
2351
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2352
|
-
/* @__PURE__ */
|
|
2353
|
-
/* @__PURE__ */
|
|
2354
|
-
/* @__PURE__ */ n("label", { style:
|
|
2349
|
+
...f.button,
|
|
2350
|
+
...U ? f.buttonLoading : {},
|
|
2351
|
+
...!P || !y && !R || !M || !d || U || t === "tenant" && !F ? f.buttonDisabled : {}
|
|
2352
|
+
}), W = P && (y || R) && M && d && (t === "user" || F);
|
|
2353
|
+
return /* @__PURE__ */ l("div", { className: b, style: f.container, children: [
|
|
2354
|
+
/* @__PURE__ */ n("h2", { style: f.title, children: a.title }),
|
|
2355
|
+
/* @__PURE__ */ l("form", { onSubmit: K, style: f.form, children: [
|
|
2356
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2357
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.nameLabel }),
|
|
2355
2358
|
/* @__PURE__ */ n(
|
|
2356
2359
|
"input",
|
|
2357
2360
|
{
|
|
2358
2361
|
id: "name",
|
|
2359
2362
|
name: "name",
|
|
2360
2363
|
type: "text",
|
|
2361
|
-
value:
|
|
2362
|
-
onChange: (
|
|
2363
|
-
m(
|
|
2364
|
+
value: P,
|
|
2365
|
+
onChange: ($) => {
|
|
2366
|
+
m($.target.value), E.name && c((J) => ({ ...J, name: !1 }));
|
|
2364
2367
|
},
|
|
2365
2368
|
placeholder: a.namePlaceholder,
|
|
2366
2369
|
style: H("name"),
|
|
2367
|
-
disabled:
|
|
2370
|
+
disabled: U
|
|
2368
2371
|
}
|
|
2369
2372
|
)
|
|
2370
2373
|
] }),
|
|
2371
|
-
/* @__PURE__ */
|
|
2372
|
-
/* @__PURE__ */ n("label", { style:
|
|
2374
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2375
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.lastNameLabel }),
|
|
2373
2376
|
/* @__PURE__ */ n(
|
|
2374
2377
|
"input",
|
|
2375
2378
|
{
|
|
2376
2379
|
id: "lastName",
|
|
2377
2380
|
name: "lastName",
|
|
2378
2381
|
type: "text",
|
|
2379
|
-
value:
|
|
2380
|
-
onChange: (
|
|
2382
|
+
value: p,
|
|
2383
|
+
onChange: ($) => u($.target.value),
|
|
2381
2384
|
placeholder: a.lastNamePlaceholder,
|
|
2382
|
-
style:
|
|
2383
|
-
disabled:
|
|
2385
|
+
style: f.input,
|
|
2386
|
+
disabled: U
|
|
2384
2387
|
}
|
|
2385
2388
|
)
|
|
2386
2389
|
] }),
|
|
2387
|
-
/* @__PURE__ */
|
|
2388
|
-
/* @__PURE__ */ n("label", { style:
|
|
2390
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2391
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.emailLabel }),
|
|
2389
2392
|
/* @__PURE__ */ n(
|
|
2390
2393
|
"input",
|
|
2391
2394
|
{
|
|
@@ -2393,30 +2396,30 @@ function Gt({
|
|
|
2393
2396
|
name: "email",
|
|
2394
2397
|
type: "email",
|
|
2395
2398
|
value: y,
|
|
2396
|
-
onChange: (
|
|
2397
|
-
|
|
2399
|
+
onChange: ($) => {
|
|
2400
|
+
L($.target.value), E.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2398
2401
|
},
|
|
2399
2402
|
placeholder: a.emailPlaceholder,
|
|
2400
2403
|
style: H("email"),
|
|
2401
|
-
disabled:
|
|
2404
|
+
disabled: U
|
|
2402
2405
|
}
|
|
2403
2406
|
)
|
|
2404
2407
|
] }),
|
|
2405
|
-
/* @__PURE__ */
|
|
2406
|
-
/* @__PURE__ */ n("label", { style:
|
|
2408
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2409
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.phoneNumberLabel }),
|
|
2407
2410
|
/* @__PURE__ */ n(
|
|
2408
2411
|
"input",
|
|
2409
2412
|
{
|
|
2410
2413
|
id: "phoneNumber",
|
|
2411
2414
|
name: "phoneNumber",
|
|
2412
2415
|
type: "tel",
|
|
2413
|
-
value:
|
|
2414
|
-
onChange: (
|
|
2415
|
-
|
|
2416
|
+
value: R,
|
|
2417
|
+
onChange: ($) => {
|
|
2418
|
+
z($.target.value), E.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2416
2419
|
},
|
|
2417
2420
|
placeholder: a.phoneNumberPlaceholder,
|
|
2418
2421
|
style: H("phoneNumber"),
|
|
2419
|
-
disabled:
|
|
2422
|
+
disabled: U
|
|
2420
2423
|
}
|
|
2421
2424
|
)
|
|
2422
2425
|
] }),
|
|
@@ -2432,78 +2435,78 @@ function Gt({
|
|
|
2432
2435
|
children: "At least one contact method (email or phone) is required"
|
|
2433
2436
|
}
|
|
2434
2437
|
),
|
|
2435
|
-
/* @__PURE__ */
|
|
2436
|
-
/* @__PURE__ */ n("label", { style:
|
|
2438
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2439
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.passwordLabel }),
|
|
2437
2440
|
/* @__PURE__ */ n(
|
|
2438
2441
|
"input",
|
|
2439
2442
|
{
|
|
2440
2443
|
id: "password",
|
|
2441
2444
|
name: "password",
|
|
2442
2445
|
type: "password",
|
|
2443
|
-
value:
|
|
2444
|
-
onChange: (
|
|
2445
|
-
|
|
2446
|
+
value: M,
|
|
2447
|
+
onChange: ($) => {
|
|
2448
|
+
A($.target.value), E.password && c((J) => ({ ...J, password: !1 }));
|
|
2446
2449
|
},
|
|
2447
2450
|
placeholder: a.passwordPlaceholder,
|
|
2448
2451
|
style: H("password"),
|
|
2449
|
-
disabled:
|
|
2452
|
+
disabled: U
|
|
2450
2453
|
}
|
|
2451
2454
|
)
|
|
2452
2455
|
] }),
|
|
2453
|
-
/* @__PURE__ */
|
|
2454
|
-
/* @__PURE__ */ n("label", { style:
|
|
2456
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2457
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.confirmPasswordLabel }),
|
|
2455
2458
|
/* @__PURE__ */ n(
|
|
2456
2459
|
"input",
|
|
2457
2460
|
{
|
|
2458
2461
|
id: "confirmPassword",
|
|
2459
2462
|
name: "confirmPassword",
|
|
2460
2463
|
type: "password",
|
|
2461
|
-
value:
|
|
2462
|
-
onChange: (
|
|
2463
|
-
|
|
2464
|
+
value: d,
|
|
2465
|
+
onChange: ($) => {
|
|
2466
|
+
C($.target.value), E.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === a.passwordMismatchError && T("");
|
|
2464
2467
|
},
|
|
2465
2468
|
placeholder: a.confirmPasswordPlaceholder,
|
|
2466
2469
|
style: H("confirmPassword"),
|
|
2467
|
-
disabled:
|
|
2470
|
+
disabled: U
|
|
2468
2471
|
}
|
|
2469
2472
|
)
|
|
2470
2473
|
] }),
|
|
2471
|
-
t === "tenant" && /* @__PURE__ */
|
|
2472
|
-
/* @__PURE__ */ n("label", { style:
|
|
2474
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2475
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.tenantNameLabel }),
|
|
2473
2476
|
/* @__PURE__ */ n(
|
|
2474
2477
|
"input",
|
|
2475
2478
|
{
|
|
2476
2479
|
id: "tenantName",
|
|
2477
2480
|
name: "tenantName",
|
|
2478
2481
|
type: "text",
|
|
2479
|
-
value:
|
|
2480
|
-
onChange: (
|
|
2481
|
-
G(
|
|
2482
|
+
value: F,
|
|
2483
|
+
onChange: ($) => {
|
|
2484
|
+
G($.target.value), E.tenantName && c((J) => ({ ...J, tenantName: !1 }));
|
|
2482
2485
|
},
|
|
2483
2486
|
placeholder: a.tenantNamePlaceholder,
|
|
2484
2487
|
style: H("tenantName"),
|
|
2485
|
-
disabled:
|
|
2488
|
+
disabled: U
|
|
2486
2489
|
}
|
|
2487
2490
|
)
|
|
2488
2491
|
] }),
|
|
2489
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !W ||
|
|
2490
|
-
|
|
2492
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !W || U, style: N(), children: U ? a.loadingText : a.submitButton }),
|
|
2493
|
+
x && /* @__PURE__ */ n("div", { style: f.errorText, children: x })
|
|
2491
2494
|
] }),
|
|
2492
|
-
(w ||
|
|
2493
|
-
|
|
2494
|
-
/* @__PURE__ */
|
|
2495
|
+
(w || k) && /* @__PURE__ */ l("div", { style: f.linkContainer, children: [
|
|
2496
|
+
k && /* @__PURE__ */ l("div", { children: [
|
|
2497
|
+
/* @__PURE__ */ l("span", { style: f.divider, children: [
|
|
2495
2498
|
a.magicLinkText,
|
|
2496
2499
|
" "
|
|
2497
2500
|
] }),
|
|
2498
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2501
|
+
/* @__PURE__ */ n("a", { onClick: h, style: f.link, children: a.magicLinkLink })
|
|
2499
2502
|
] }),
|
|
2500
|
-
|
|
2501
|
-
w && /* @__PURE__ */
|
|
2502
|
-
/* @__PURE__ */
|
|
2503
|
+
k && w && /* @__PURE__ */ n("div", { style: f.divider, children: "•" }),
|
|
2504
|
+
w && /* @__PURE__ */ l("div", { children: [
|
|
2505
|
+
/* @__PURE__ */ l("span", { style: f.divider, children: [
|
|
2503
2506
|
a.loginText,
|
|
2504
2507
|
" "
|
|
2505
2508
|
] }),
|
|
2506
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2509
|
+
/* @__PURE__ */ n("a", { onClick: o, style: f.link, children: a.loginLink })
|
|
2507
2510
|
] })
|
|
2508
2511
|
] })
|
|
2509
2512
|
] });
|
|
@@ -2636,98 +2639,98 @@ function Kt({
|
|
|
2636
2639
|
onError: r,
|
|
2637
2640
|
onLoginClick: s,
|
|
2638
2641
|
onSignupClick: o,
|
|
2639
|
-
showTraditionalLinks:
|
|
2642
|
+
showTraditionalLinks: h = !0,
|
|
2640
2643
|
className: w,
|
|
2641
|
-
verifyToken:
|
|
2644
|
+
verifyToken: k,
|
|
2642
2645
|
frontendUrl: b
|
|
2643
2646
|
}) {
|
|
2644
|
-
const [
|
|
2647
|
+
const [P, m] = v(""), [p, u] = v(""), [y, L] = v(""), [R, z] = v(!1), [M, A] = v(!1), [d, C] = v(""), [F, G] = v(""), [U, _] = v({}), [x, T] = v(!1), { sendMagicLink: E, verifyMagicLink: c } = ae(), { tenant: I } = se(), S = { ...ft, ...i }, g = { ...mt, ...e };
|
|
2645
2648
|
te(() => {
|
|
2646
|
-
|
|
2647
|
-
}, [
|
|
2649
|
+
k && a(k);
|
|
2650
|
+
}, [k]);
|
|
2648
2651
|
const a = async (N) => {
|
|
2649
|
-
if (!I || !
|
|
2650
|
-
|
|
2652
|
+
if (!I || !P) {
|
|
2653
|
+
C("Missing tenant or email");
|
|
2651
2654
|
return;
|
|
2652
2655
|
}
|
|
2653
|
-
|
|
2656
|
+
A(!0), C("");
|
|
2654
2657
|
try {
|
|
2655
|
-
const W = await
|
|
2658
|
+
const W = await c({
|
|
2656
2659
|
token: N,
|
|
2657
|
-
email:
|
|
2660
|
+
email: P
|
|
2658
2661
|
// tenantId inferred from context automatically
|
|
2659
2662
|
});
|
|
2660
2663
|
t == null || t(W);
|
|
2661
2664
|
} catch (W) {
|
|
2662
|
-
const
|
|
2663
|
-
|
|
2665
|
+
const $ = W.message || "Failed to verify magic link";
|
|
2666
|
+
C($), r == null || r($);
|
|
2664
2667
|
} finally {
|
|
2665
|
-
|
|
2668
|
+
A(!1);
|
|
2666
2669
|
}
|
|
2667
|
-
},
|
|
2670
|
+
}, f = () => {
|
|
2668
2671
|
const N = {};
|
|
2669
|
-
return
|
|
2672
|
+
return P.trim() || (N.email = !0), x && !p.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
|
|
2670
2673
|
}, O = async (N) => {
|
|
2671
|
-
if (N.preventDefault(), !!
|
|
2674
|
+
if (N.preventDefault(), !!f()) {
|
|
2672
2675
|
if (!(I != null && I.id)) {
|
|
2673
|
-
|
|
2676
|
+
C("Tenant not found");
|
|
2674
2677
|
return;
|
|
2675
2678
|
}
|
|
2676
|
-
|
|
2679
|
+
z(!0), C(""), G("");
|
|
2677
2680
|
try {
|
|
2678
|
-
const W = b || (typeof window < "u" ? window.location.origin : ""),
|
|
2679
|
-
email:
|
|
2681
|
+
const W = b || (typeof window < "u" ? window.location.origin : ""), $ = await E({
|
|
2682
|
+
email: P,
|
|
2680
2683
|
tenantId: I.id,
|
|
2681
2684
|
frontendUrl: W,
|
|
2682
|
-
name:
|
|
2683
|
-
lastName:
|
|
2685
|
+
name: x ? p : void 0,
|
|
2686
|
+
lastName: x ? y : void 0
|
|
2684
2687
|
});
|
|
2685
|
-
G(
|
|
2688
|
+
G(S.successMessage), t == null || t($);
|
|
2686
2689
|
} catch (W) {
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2690
|
+
const $ = W.message || S.errorMessage;
|
|
2691
|
+
C($), r == null || r($);
|
|
2689
2692
|
} finally {
|
|
2690
|
-
|
|
2693
|
+
z(!1);
|
|
2691
2694
|
}
|
|
2692
2695
|
}
|
|
2693
2696
|
}, K = (N) => ({
|
|
2694
|
-
...
|
|
2695
|
-
|
|
2697
|
+
...g.input,
|
|
2698
|
+
...U[N] ? g.inputError : {}
|
|
2696
2699
|
}), H = () => ({
|
|
2697
|
-
...
|
|
2698
|
-
...
|
|
2699
|
-
...!
|
|
2700
|
+
...g.button,
|
|
2701
|
+
...R || M ? g.buttonLoading : {},
|
|
2702
|
+
...!P || R || M ? g.buttonDisabled : {}
|
|
2700
2703
|
});
|
|
2701
|
-
return
|
|
2702
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2704
|
+
return M ? /* @__PURE__ */ l("div", { className: w, style: g.container, children: [
|
|
2705
|
+
/* @__PURE__ */ n("h2", { style: g.title, children: S.verifyingText }),
|
|
2703
2706
|
/* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2704
|
-
] }) : /* @__PURE__ */
|
|
2705
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2706
|
-
/* @__PURE__ */ n("p", { style:
|
|
2707
|
-
/* @__PURE__ */
|
|
2708
|
-
/* @__PURE__ */
|
|
2709
|
-
/* @__PURE__ */ n("label", { style:
|
|
2707
|
+
] }) : /* @__PURE__ */ l("div", { className: w, style: g.container, children: [
|
|
2708
|
+
/* @__PURE__ */ n("h2", { style: g.title, children: S.title }),
|
|
2709
|
+
/* @__PURE__ */ n("p", { style: g.description, children: S.description }),
|
|
2710
|
+
/* @__PURE__ */ l("form", { onSubmit: O, style: g.form, children: [
|
|
2711
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2712
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.emailLabel }),
|
|
2710
2713
|
/* @__PURE__ */ n(
|
|
2711
2714
|
"input",
|
|
2712
2715
|
{
|
|
2713
2716
|
id: "email",
|
|
2714
2717
|
name: "email",
|
|
2715
2718
|
type: "email",
|
|
2716
|
-
value:
|
|
2719
|
+
value: P,
|
|
2717
2720
|
onChange: (N) => {
|
|
2718
|
-
m(N.target.value),
|
|
2721
|
+
m(N.target.value), U.email && _((W) => ({ ...W, email: !1 }));
|
|
2719
2722
|
},
|
|
2720
|
-
placeholder:
|
|
2723
|
+
placeholder: S.emailPlaceholder,
|
|
2721
2724
|
style: K("email"),
|
|
2722
|
-
disabled:
|
|
2725
|
+
disabled: R || M
|
|
2723
2726
|
}
|
|
2724
2727
|
)
|
|
2725
2728
|
] }),
|
|
2726
|
-
!
|
|
2729
|
+
!x && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2727
2730
|
"button",
|
|
2728
2731
|
{
|
|
2729
2732
|
type: "button",
|
|
2730
|
-
onClick: () =>
|
|
2733
|
+
onClick: () => T(!0),
|
|
2731
2734
|
style: {
|
|
2732
2735
|
background: "none",
|
|
2733
2736
|
border: "none",
|
|
@@ -2739,27 +2742,27 @@ function Kt({
|
|
|
2739
2742
|
children: "New user? Add your name"
|
|
2740
2743
|
}
|
|
2741
2744
|
) }),
|
|
2742
|
-
|
|
2743
|
-
/* @__PURE__ */
|
|
2744
|
-
/* @__PURE__ */ n("label", { style:
|
|
2745
|
+
x && /* @__PURE__ */ l(q, { children: [
|
|
2746
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2747
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.nameLabel }),
|
|
2745
2748
|
/* @__PURE__ */ n(
|
|
2746
2749
|
"input",
|
|
2747
2750
|
{
|
|
2748
2751
|
id: "name",
|
|
2749
2752
|
name: "name",
|
|
2750
2753
|
type: "text",
|
|
2751
|
-
value:
|
|
2754
|
+
value: p,
|
|
2752
2755
|
onChange: (N) => {
|
|
2753
|
-
u(N.target.value),
|
|
2756
|
+
u(N.target.value), U.name && _((W) => ({ ...W, name: !1 }));
|
|
2754
2757
|
},
|
|
2755
|
-
placeholder:
|
|
2758
|
+
placeholder: S.namePlaceholder,
|
|
2756
2759
|
style: K("name"),
|
|
2757
|
-
disabled:
|
|
2760
|
+
disabled: R || M
|
|
2758
2761
|
}
|
|
2759
2762
|
)
|
|
2760
2763
|
] }),
|
|
2761
|
-
/* @__PURE__ */
|
|
2762
|
-
/* @__PURE__ */ n("label", { style:
|
|
2764
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2765
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.lastNameLabel }),
|
|
2763
2766
|
/* @__PURE__ */ n(
|
|
2764
2767
|
"input",
|
|
2765
2768
|
{
|
|
@@ -2767,10 +2770,10 @@ function Kt({
|
|
|
2767
2770
|
name: "lastName",
|
|
2768
2771
|
type: "text",
|
|
2769
2772
|
value: y,
|
|
2770
|
-
onChange: (N) =>
|
|
2771
|
-
placeholder:
|
|
2772
|
-
style:
|
|
2773
|
-
disabled:
|
|
2773
|
+
onChange: (N) => L(N.target.value),
|
|
2774
|
+
placeholder: S.lastNamePlaceholder,
|
|
2775
|
+
style: g.input,
|
|
2776
|
+
disabled: R || M
|
|
2774
2777
|
}
|
|
2775
2778
|
)
|
|
2776
2779
|
] }),
|
|
@@ -2779,7 +2782,7 @@ function Kt({
|
|
|
2779
2782
|
{
|
|
2780
2783
|
type: "button",
|
|
2781
2784
|
onClick: () => {
|
|
2782
|
-
|
|
2785
|
+
T(!1), u(""), L("");
|
|
2783
2786
|
},
|
|
2784
2787
|
style: {
|
|
2785
2788
|
background: "none",
|
|
@@ -2793,25 +2796,25 @@ function Kt({
|
|
|
2793
2796
|
}
|
|
2794
2797
|
) })
|
|
2795
2798
|
] }),
|
|
2796
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !P || R || M, style: H(), children: R ? S.loadingText : S.submitButton }),
|
|
2800
|
+
d && /* @__PURE__ */ n("div", { style: g.errorText, children: d }),
|
|
2801
|
+
F && /* @__PURE__ */ n("div", { style: g.successText, children: F })
|
|
2799
2802
|
] }),
|
|
2800
|
-
|
|
2801
|
-
/* @__PURE__ */
|
|
2802
|
-
/* @__PURE__ */
|
|
2803
|
-
|
|
2803
|
+
h && /* @__PURE__ */ l("div", { style: g.linkContainer, children: [
|
|
2804
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2805
|
+
/* @__PURE__ */ l("span", { style: g.divider, children: [
|
|
2806
|
+
S.loginText,
|
|
2804
2807
|
" "
|
|
2805
2808
|
] }),
|
|
2806
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2809
|
+
/* @__PURE__ */ n("a", { onClick: s, style: g.link, children: S.loginLink })
|
|
2807
2810
|
] }),
|
|
2808
|
-
/* @__PURE__ */ n("div", { style:
|
|
2809
|
-
/* @__PURE__ */
|
|
2810
|
-
/* @__PURE__ */
|
|
2811
|
-
|
|
2811
|
+
/* @__PURE__ */ n("div", { style: g.divider, children: "•" }),
|
|
2812
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2813
|
+
/* @__PURE__ */ l("span", { style: g.divider, children: [
|
|
2814
|
+
S.signupText,
|
|
2812
2815
|
" "
|
|
2813
2816
|
] }),
|
|
2814
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2817
|
+
/* @__PURE__ */ n("a", { onClick: o, style: g.link, children: S.signupLink })
|
|
2815
2818
|
] })
|
|
2816
2819
|
] })
|
|
2817
2820
|
] });
|
|
@@ -2911,7 +2914,7 @@ const yt = {
|
|
|
2911
2914
|
cursor: "pointer",
|
|
2912
2915
|
transition: "all 0.15s ease-in-out"
|
|
2913
2916
|
}
|
|
2914
|
-
}, wt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), bt = () => /* @__PURE__ */
|
|
2917
|
+
}, wt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), bt = () => /* @__PURE__ */ l(
|
|
2915
2918
|
"svg",
|
|
2916
2919
|
{
|
|
2917
2920
|
width: "48",
|
|
@@ -2928,7 +2931,7 @@ const yt = {
|
|
|
2928
2931
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2929
2932
|
]
|
|
2930
2933
|
}
|
|
2931
|
-
), St = () => /* @__PURE__ */
|
|
2934
|
+
), St = () => /* @__PURE__ */ l(
|
|
2932
2935
|
"svg",
|
|
2933
2936
|
{
|
|
2934
2937
|
width: "48",
|
|
@@ -2958,97 +2961,97 @@ function Jt({
|
|
|
2958
2961
|
onSuccess: r,
|
|
2959
2962
|
onError: s,
|
|
2960
2963
|
onRetry: o,
|
|
2961
|
-
onBackToLogin:
|
|
2964
|
+
onBackToLogin: h,
|
|
2962
2965
|
className: w,
|
|
2963
|
-
token:
|
|
2966
|
+
token: k,
|
|
2964
2967
|
email: b,
|
|
2965
|
-
appId:
|
|
2968
|
+
appId: P,
|
|
2966
2969
|
tenantSlug: m,
|
|
2967
|
-
autoRedirectDelay:
|
|
2970
|
+
autoRedirectDelay: p = 3e3
|
|
2968
2971
|
}) {
|
|
2969
|
-
const [u, y] = v("verifying"), [
|
|
2972
|
+
const [u, y] = v("verifying"), [L, R] = v(""), { verifyMagicLink: z } = ae(), M = { ...yt, ...i }, A = { ...Ee, ...e }, d = { ...vt, ...t }, C = () => {
|
|
2970
2973
|
if (typeof window > "u") return {};
|
|
2971
|
-
const
|
|
2974
|
+
const x = new URLSearchParams(window.location.search);
|
|
2972
2975
|
return {
|
|
2973
|
-
token:
|
|
2974
|
-
email: b ||
|
|
2975
|
-
appId:
|
|
2976
|
-
tenantSlug: m ||
|
|
2976
|
+
token: k || x.get("token") || "",
|
|
2977
|
+
email: b || x.get("email") || "",
|
|
2978
|
+
appId: P || x.get("appId") || "",
|
|
2979
|
+
tenantSlug: m || x.get("tenantSlug") || void 0
|
|
2977
2980
|
};
|
|
2978
|
-
},
|
|
2979
|
-
y("verifying"),
|
|
2981
|
+
}, F = async () => {
|
|
2982
|
+
y("verifying"), R("");
|
|
2980
2983
|
try {
|
|
2981
|
-
const
|
|
2982
|
-
if (!
|
|
2984
|
+
const x = C();
|
|
2985
|
+
if (!x.token || !x.email)
|
|
2983
2986
|
throw new Error("Missing required parameters: token or email");
|
|
2984
|
-
const
|
|
2985
|
-
token:
|
|
2986
|
-
email:
|
|
2987
|
-
tenantSlug:
|
|
2987
|
+
const T = await z({
|
|
2988
|
+
token: x.token,
|
|
2989
|
+
email: x.email,
|
|
2990
|
+
tenantSlug: x.tenantSlug
|
|
2988
2991
|
});
|
|
2989
|
-
y("success"), r == null || r(
|
|
2992
|
+
y("success"), r == null || r(T), p > 0 && setTimeout(() => {
|
|
2990
2993
|
y("redirecting");
|
|
2991
|
-
},
|
|
2992
|
-
} catch (
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2994
|
+
}, p);
|
|
2995
|
+
} catch (x) {
|
|
2996
|
+
const T = x.message || M.errorMessage;
|
|
2997
|
+
R(T), y("error"), s == null || s(T);
|
|
2995
2998
|
}
|
|
2996
2999
|
}, G = () => {
|
|
2997
|
-
o == null || o(),
|
|
2998
|
-
},
|
|
2999
|
-
|
|
3000
|
+
o == null || o(), F();
|
|
3001
|
+
}, U = () => {
|
|
3002
|
+
h == null || h();
|
|
3000
3003
|
};
|
|
3001
3004
|
te(() => {
|
|
3002
|
-
|
|
3005
|
+
F();
|
|
3003
3006
|
}, []);
|
|
3004
3007
|
const _ = () => {
|
|
3005
3008
|
switch (u) {
|
|
3006
3009
|
case "verifying":
|
|
3007
|
-
return /* @__PURE__ */
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
+
return /* @__PURE__ */ l("div", { style: A.message, children: [
|
|
3011
|
+
d.loading,
|
|
3012
|
+
M.verifyingMessage
|
|
3010
3013
|
] });
|
|
3011
3014
|
case "success":
|
|
3012
|
-
return /* @__PURE__ */
|
|
3013
|
-
|
|
3014
|
-
/* @__PURE__ */ n("div", { style:
|
|
3015
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3016
|
+
d.success,
|
|
3017
|
+
/* @__PURE__ */ n("div", { style: A.successMessage, children: M.successMessage })
|
|
3015
3018
|
] });
|
|
3016
3019
|
case "redirecting":
|
|
3017
|
-
return /* @__PURE__ */
|
|
3018
|
-
|
|
3019
|
-
/* @__PURE__ */ n("div", { style:
|
|
3020
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3021
|
+
d.loading,
|
|
3022
|
+
/* @__PURE__ */ n("div", { style: A.message, children: M.redirectingMessage })
|
|
3020
3023
|
] });
|
|
3021
3024
|
case "error":
|
|
3022
|
-
return /* @__PURE__ */
|
|
3023
|
-
|
|
3024
|
-
/* @__PURE__ */ n("div", { style:
|
|
3025
|
-
/* @__PURE__ */
|
|
3025
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3026
|
+
d.error,
|
|
3027
|
+
/* @__PURE__ */ n("div", { style: A.errorMessage, children: L || M.errorMessage }),
|
|
3028
|
+
/* @__PURE__ */ l("div", { style: A.buttonContainer, children: [
|
|
3026
3029
|
/* @__PURE__ */ n(
|
|
3027
3030
|
"button",
|
|
3028
3031
|
{
|
|
3029
3032
|
onClick: G,
|
|
3030
|
-
style:
|
|
3031
|
-
onMouseOver: (
|
|
3032
|
-
|
|
3033
|
+
style: A.retryButton,
|
|
3034
|
+
onMouseOver: (x) => {
|
|
3035
|
+
x.currentTarget.style.backgroundColor = "#2563eb";
|
|
3033
3036
|
},
|
|
3034
|
-
onMouseOut: (
|
|
3035
|
-
|
|
3037
|
+
onMouseOut: (x) => {
|
|
3038
|
+
x.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3036
3039
|
},
|
|
3037
|
-
children:
|
|
3040
|
+
children: M.retryButton
|
|
3038
3041
|
}
|
|
3039
3042
|
),
|
|
3040
3043
|
/* @__PURE__ */ n(
|
|
3041
3044
|
"button",
|
|
3042
3045
|
{
|
|
3043
|
-
onClick:
|
|
3044
|
-
style:
|
|
3045
|
-
onMouseOver: (
|
|
3046
|
-
|
|
3046
|
+
onClick: U,
|
|
3047
|
+
style: A.backButton,
|
|
3048
|
+
onMouseOver: (x) => {
|
|
3049
|
+
x.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3047
3050
|
},
|
|
3048
|
-
onMouseOut: (
|
|
3049
|
-
|
|
3051
|
+
onMouseOut: (x) => {
|
|
3052
|
+
x.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3050
3053
|
},
|
|
3051
|
-
children:
|
|
3054
|
+
children: M.backToLoginButton
|
|
3052
3055
|
}
|
|
3053
3056
|
)
|
|
3054
3057
|
] })
|
|
@@ -3057,18 +3060,18 @@ function Jt({
|
|
|
3057
3060
|
return null;
|
|
3058
3061
|
}
|
|
3059
3062
|
};
|
|
3060
|
-
return /* @__PURE__ */
|
|
3063
|
+
return /* @__PURE__ */ l("div", { style: A.container, className: w, children: [
|
|
3061
3064
|
/* @__PURE__ */ n("style", { children: `
|
|
3062
3065
|
@keyframes spin {
|
|
3063
3066
|
0% { transform: rotate(0deg); }
|
|
3064
3067
|
100% { transform: rotate(360deg); }
|
|
3065
3068
|
}
|
|
3066
3069
|
` }),
|
|
3067
|
-
/* @__PURE__ */ n("h1", { style:
|
|
3070
|
+
/* @__PURE__ */ n("h1", { style: A.title, children: M.title }),
|
|
3068
3071
|
_()
|
|
3069
3072
|
] });
|
|
3070
3073
|
}
|
|
3071
|
-
const
|
|
3074
|
+
const kt = {
|
|
3072
3075
|
title: "Reset Password",
|
|
3073
3076
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3074
3077
|
emailLabel: "Email",
|
|
@@ -3090,7 +3093,7 @@ const xt = {
|
|
|
3090
3093
|
resetLoadingText: "Resetting...",
|
|
3091
3094
|
resetSuccessMessage: "Password reset successfully!",
|
|
3092
3095
|
passwordMismatchError: "Passwords do not match"
|
|
3093
|
-
},
|
|
3096
|
+
}, xt = {
|
|
3094
3097
|
container: {
|
|
3095
3098
|
maxWidth: "400px",
|
|
3096
3099
|
margin: "0 auto",
|
|
@@ -3189,106 +3192,106 @@ function Yt({
|
|
|
3189
3192
|
token: r = "",
|
|
3190
3193
|
onSuccess: s,
|
|
3191
3194
|
onError: o,
|
|
3192
|
-
onBackToLogin:
|
|
3195
|
+
onBackToLogin: h,
|
|
3193
3196
|
onModeChange: w,
|
|
3194
|
-
className:
|
|
3197
|
+
className: k
|
|
3195
3198
|
}) {
|
|
3196
|
-
const [b,
|
|
3199
|
+
const [b, P] = v(""), [m, p] = v(r), [u, y] = v(""), [L, R] = v(""), [z, M] = v(!1), [A, d] = v(""), [C, F] = v(""), [G, U] = v({}), { requestPasswordReset: _, confirmPasswordReset: x } = ae(), { tenant: T } = se(), E = { ...kt, ...i }, c = { ...xt, ...e }, I = () => {
|
|
3197
3200
|
const H = {};
|
|
3198
|
-
return b.trim() || (H.email = !0),
|
|
3199
|
-
},
|
|
3201
|
+
return b.trim() || (H.email = !0), U(H), Object.keys(H).length === 0;
|
|
3202
|
+
}, S = () => {
|
|
3200
3203
|
const H = {};
|
|
3201
|
-
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0),
|
|
3202
|
-
},
|
|
3204
|
+
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), L.trim() || (H.confirmPassword = !0), U(H), Object.keys(H).length === 0;
|
|
3205
|
+
}, g = async (H) => {
|
|
3203
3206
|
if (H.preventDefault(), !!I()) {
|
|
3204
|
-
if (!(
|
|
3205
|
-
|
|
3207
|
+
if (!(T != null && T.id)) {
|
|
3208
|
+
d("Tenant not found");
|
|
3206
3209
|
return;
|
|
3207
3210
|
}
|
|
3208
|
-
|
|
3211
|
+
M(!0), d(""), F("");
|
|
3209
3212
|
try {
|
|
3210
|
-
await _({ email: b, tenantId:
|
|
3213
|
+
await _({ email: b, tenantId: T.id }), F(E.successMessage), s == null || s();
|
|
3211
3214
|
} catch (N) {
|
|
3212
|
-
const W = N.message ||
|
|
3213
|
-
|
|
3215
|
+
const W = N.message || E.errorMessage;
|
|
3216
|
+
d(W), o == null || o(W);
|
|
3214
3217
|
} finally {
|
|
3215
|
-
|
|
3218
|
+
M(!1);
|
|
3216
3219
|
}
|
|
3217
3220
|
}
|
|
3218
3221
|
}, a = async (H) => {
|
|
3219
|
-
if (H.preventDefault(), !!
|
|
3220
|
-
if (u !==
|
|
3221
|
-
|
|
3222
|
+
if (H.preventDefault(), !!S()) {
|
|
3223
|
+
if (u !== L) {
|
|
3224
|
+
d(E.passwordMismatchError), U({ confirmPassword: !0 });
|
|
3222
3225
|
return;
|
|
3223
3226
|
}
|
|
3224
|
-
|
|
3227
|
+
M(!0), d(""), F("");
|
|
3225
3228
|
try {
|
|
3226
|
-
await
|
|
3229
|
+
await x({ token: m, newPassword: u }), F(E.resetSuccessMessage), s == null || s();
|
|
3227
3230
|
} catch (N) {
|
|
3228
|
-
const W = N.message ||
|
|
3229
|
-
|
|
3231
|
+
const W = N.message || E.errorMessage;
|
|
3232
|
+
d(W), o == null || o(W);
|
|
3230
3233
|
} finally {
|
|
3231
|
-
|
|
3234
|
+
M(!1);
|
|
3232
3235
|
}
|
|
3233
3236
|
}
|
|
3234
|
-
},
|
|
3235
|
-
...
|
|
3236
|
-
...G[H] ?
|
|
3237
|
+
}, f = (H) => ({
|
|
3238
|
+
...c.input,
|
|
3239
|
+
...G[H] ? c.inputError : {}
|
|
3237
3240
|
}), O = () => ({
|
|
3238
|
-
...
|
|
3239
|
-
...
|
|
3241
|
+
...c.button,
|
|
3242
|
+
...z ? c.buttonLoading : {}
|
|
3240
3243
|
});
|
|
3241
3244
|
if (t === "reset") {
|
|
3242
|
-
const H = m && u &&
|
|
3243
|
-
return /* @__PURE__ */
|
|
3244
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3245
|
-
/* @__PURE__ */ n("p", { style:
|
|
3246
|
-
/* @__PURE__ */
|
|
3247
|
-
/* @__PURE__ */
|
|
3248
|
-
/* @__PURE__ */ n("label", { style:
|
|
3245
|
+
const H = m && u && L;
|
|
3246
|
+
return /* @__PURE__ */ l("div", { className: k, style: c.container, children: [
|
|
3247
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: E.resetTitle }),
|
|
3248
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: E.resetSubtitle }),
|
|
3249
|
+
/* @__PURE__ */ l("form", { onSubmit: a, style: c.form, children: [
|
|
3250
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3251
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.tokenLabel }),
|
|
3249
3252
|
/* @__PURE__ */ n(
|
|
3250
3253
|
"input",
|
|
3251
3254
|
{
|
|
3252
3255
|
type: "text",
|
|
3253
3256
|
value: m,
|
|
3254
3257
|
onChange: (N) => {
|
|
3255
|
-
|
|
3258
|
+
p(N.target.value), G.token && U((W) => ({ ...W, token: !1 }));
|
|
3256
3259
|
},
|
|
3257
|
-
placeholder:
|
|
3258
|
-
style:
|
|
3259
|
-
disabled:
|
|
3260
|
+
placeholder: E.tokenPlaceholder,
|
|
3261
|
+
style: f("token"),
|
|
3262
|
+
disabled: z
|
|
3260
3263
|
}
|
|
3261
3264
|
)
|
|
3262
3265
|
] }),
|
|
3263
|
-
/* @__PURE__ */
|
|
3264
|
-
/* @__PURE__ */ n("label", { style:
|
|
3266
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3267
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.newPasswordLabel }),
|
|
3265
3268
|
/* @__PURE__ */ n(
|
|
3266
3269
|
"input",
|
|
3267
3270
|
{
|
|
3268
3271
|
type: "password",
|
|
3269
3272
|
value: u,
|
|
3270
3273
|
onChange: (N) => {
|
|
3271
|
-
y(N.target.value), G.newPassword &&
|
|
3274
|
+
y(N.target.value), G.newPassword && U((W) => ({ ...W, newPassword: !1 }));
|
|
3272
3275
|
},
|
|
3273
|
-
placeholder:
|
|
3274
|
-
style:
|
|
3275
|
-
disabled:
|
|
3276
|
+
placeholder: E.newPasswordPlaceholder,
|
|
3277
|
+
style: f("newPassword"),
|
|
3278
|
+
disabled: z
|
|
3276
3279
|
}
|
|
3277
3280
|
)
|
|
3278
3281
|
] }),
|
|
3279
|
-
/* @__PURE__ */
|
|
3280
|
-
/* @__PURE__ */ n("label", { style:
|
|
3282
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3283
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.confirmPasswordLabel }),
|
|
3281
3284
|
/* @__PURE__ */ n(
|
|
3282
3285
|
"input",
|
|
3283
3286
|
{
|
|
3284
3287
|
type: "password",
|
|
3285
|
-
value:
|
|
3288
|
+
value: L,
|
|
3286
3289
|
onChange: (N) => {
|
|
3287
|
-
|
|
3290
|
+
R(N.target.value), G.confirmPassword && U((W) => ({ ...W, confirmPassword: !1 })), A === E.passwordMismatchError && d("");
|
|
3288
3291
|
},
|
|
3289
|
-
placeholder:
|
|
3290
|
-
style:
|
|
3291
|
-
disabled:
|
|
3292
|
+
placeholder: E.confirmPasswordPlaceholder,
|
|
3293
|
+
style: f("confirmPassword"),
|
|
3294
|
+
disabled: z
|
|
3292
3295
|
}
|
|
3293
3296
|
)
|
|
3294
3297
|
] }),
|
|
@@ -3296,44 +3299,44 @@ function Yt({
|
|
|
3296
3299
|
"button",
|
|
3297
3300
|
{
|
|
3298
3301
|
type: "submit",
|
|
3299
|
-
disabled: !H ||
|
|
3302
|
+
disabled: !H || z,
|
|
3300
3303
|
style: {
|
|
3301
3304
|
...O(),
|
|
3302
|
-
...!H ||
|
|
3305
|
+
...!H || z ? c.buttonDisabled : {}
|
|
3303
3306
|
},
|
|
3304
|
-
children:
|
|
3307
|
+
children: z ? E.resetLoadingText : E.resetSubmitButton
|
|
3305
3308
|
}
|
|
3306
3309
|
),
|
|
3307
|
-
|
|
3308
|
-
|
|
3310
|
+
A && /* @__PURE__ */ n("div", { style: c.errorText, children: A }),
|
|
3311
|
+
C && /* @__PURE__ */ n("div", { style: c.successText, children: C })
|
|
3309
3312
|
] }),
|
|
3310
|
-
/* @__PURE__ */
|
|
3311
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3312
|
-
w && /* @__PURE__ */
|
|
3313
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3314
|
+
/* @__PURE__ */ n("a", { onClick: h, style: c.link, children: E.backToLoginLink }),
|
|
3315
|
+
w && /* @__PURE__ */ l(q, { children: [
|
|
3313
3316
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3314
|
-
/* @__PURE__ */ n("a", { onClick: () => w("request"), style:
|
|
3317
|
+
/* @__PURE__ */ n("a", { onClick: () => w("request"), style: c.link, children: "Request New Link" })
|
|
3315
3318
|
] })
|
|
3316
3319
|
] })
|
|
3317
3320
|
] });
|
|
3318
3321
|
}
|
|
3319
3322
|
const K = b;
|
|
3320
|
-
return /* @__PURE__ */
|
|
3321
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3322
|
-
/* @__PURE__ */ n("p", { style:
|
|
3323
|
-
/* @__PURE__ */
|
|
3324
|
-
/* @__PURE__ */
|
|
3325
|
-
/* @__PURE__ */ n("label", { style:
|
|
3323
|
+
return /* @__PURE__ */ l("div", { className: k, style: c.container, children: [
|
|
3324
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: E.title }),
|
|
3325
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: E.subtitle }),
|
|
3326
|
+
/* @__PURE__ */ l("form", { onSubmit: g, style: c.form, children: [
|
|
3327
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3328
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.emailLabel }),
|
|
3326
3329
|
/* @__PURE__ */ n(
|
|
3327
3330
|
"input",
|
|
3328
3331
|
{
|
|
3329
3332
|
type: "email",
|
|
3330
3333
|
value: b,
|
|
3331
3334
|
onChange: (H) => {
|
|
3332
|
-
|
|
3335
|
+
P(H.target.value), G.email && U((N) => ({ ...N, email: !1 }));
|
|
3333
3336
|
},
|
|
3334
|
-
placeholder:
|
|
3335
|
-
style:
|
|
3336
|
-
disabled:
|
|
3337
|
+
placeholder: E.emailPlaceholder,
|
|
3338
|
+
style: f("email"),
|
|
3339
|
+
disabled: z
|
|
3337
3340
|
}
|
|
3338
3341
|
)
|
|
3339
3342
|
] }),
|
|
@@ -3341,22 +3344,22 @@ function Yt({
|
|
|
3341
3344
|
"button",
|
|
3342
3345
|
{
|
|
3343
3346
|
type: "submit",
|
|
3344
|
-
disabled: !K ||
|
|
3347
|
+
disabled: !K || z,
|
|
3345
3348
|
style: {
|
|
3346
3349
|
...O(),
|
|
3347
|
-
...!K ||
|
|
3350
|
+
...!K || z ? c.buttonDisabled : {}
|
|
3348
3351
|
},
|
|
3349
|
-
children:
|
|
3352
|
+
children: z ? E.loadingText : E.submitButton
|
|
3350
3353
|
}
|
|
3351
3354
|
),
|
|
3352
|
-
|
|
3353
|
-
|
|
3355
|
+
A && /* @__PURE__ */ n("div", { style: c.errorText, children: A }),
|
|
3356
|
+
C && /* @__PURE__ */ n("div", { style: c.successText, children: C })
|
|
3354
3357
|
] }),
|
|
3355
|
-
/* @__PURE__ */
|
|
3356
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3357
|
-
w && /* @__PURE__ */
|
|
3358
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3359
|
+
/* @__PURE__ */ n("a", { onClick: h, style: c.link, children: E.backToLoginLink }),
|
|
3360
|
+
w && /* @__PURE__ */ l(q, { children: [
|
|
3358
3361
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3359
|
-
/* @__PURE__ */ n("a", { onClick: () => w("reset"), style:
|
|
3362
|
+
/* @__PURE__ */ n("a", { onClick: () => w("reset"), style: c.link, children: "I have a token" })
|
|
3360
3363
|
] })
|
|
3361
3364
|
] })
|
|
3362
3365
|
] });
|
|
@@ -3373,7 +3376,7 @@ const At = () => /* @__PURE__ */ n(
|
|
|
3373
3376
|
},
|
|
3374
3377
|
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3375
3378
|
}
|
|
3376
|
-
), Tt = ({ error: i, retry: e }) => /* @__PURE__ */
|
|
3379
|
+
), Tt = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
3377
3380
|
"div",
|
|
3378
3381
|
{
|
|
3379
3382
|
style: {
|
|
@@ -3413,31 +3416,31 @@ function Qt({
|
|
|
3413
3416
|
errorFallback: t,
|
|
3414
3417
|
requireTenant: r = !0
|
|
3415
3418
|
}) {
|
|
3416
|
-
const { isAppLoading: s, appError: o, retryApp:
|
|
3417
|
-
}),
|
|
3418
|
-
o &&
|
|
3419
|
+
const { isAppLoading: s, appError: o, retryApp: h } = oe(), w = Me(), k = (w == null ? void 0 : w.isTenantLoading) ?? !1, b = (w == null ? void 0 : w.tenantError) ?? null, P = (w == null ? void 0 : w.tenantSlug) ?? null, m = (w == null ? void 0 : w.retryTenant) ?? (() => {
|
|
3420
|
+
}), p = r && w && P, u = s || p && k, y = o || (p ? b : null), L = () => {
|
|
3421
|
+
o && h(), b && w && m();
|
|
3419
3422
|
};
|
|
3420
3423
|
if (u)
|
|
3421
|
-
return /* @__PURE__ */ n(
|
|
3424
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(At, {}) });
|
|
3422
3425
|
if (y) {
|
|
3423
|
-
const
|
|
3424
|
-
return /* @__PURE__ */ n(
|
|
3426
|
+
const R = typeof t == "function" ? t(y, L) : t || /* @__PURE__ */ n(Tt, { error: y, retry: L });
|
|
3427
|
+
return /* @__PURE__ */ n(q, { children: R });
|
|
3425
3428
|
}
|
|
3426
|
-
return /* @__PURE__ */ n(
|
|
3429
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
3427
3430
|
}
|
|
3428
3431
|
function Xt(i = !0) {
|
|
3429
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(),
|
|
3430
|
-
}), m = i && o && b,
|
|
3432
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), h = (o == null ? void 0 : o.isTenantLoading) ?? !1, w = (o == null ? void 0 : o.tenantError) ?? null, k = (o == null ? void 0 : o.tenant) ?? null, b = (o == null ? void 0 : o.tenantSlug) ?? null, P = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3433
|
+
}), m = i && o && b, p = e || m && h, u = t || (m ? w : null);
|
|
3431
3434
|
return {
|
|
3432
|
-
isLoading:
|
|
3435
|
+
isLoading: p,
|
|
3433
3436
|
error: u,
|
|
3434
|
-
isReady: !
|
|
3437
|
+
isReady: !p && !u && s !== null && (!m || k !== null),
|
|
3435
3438
|
retry: () => {
|
|
3436
|
-
t && r(), w && o &&
|
|
3439
|
+
t && r(), w && o && P();
|
|
3437
3440
|
},
|
|
3438
3441
|
// Individual states
|
|
3439
3442
|
app: { isLoading: e, error: t, data: s },
|
|
3440
|
-
tenant: o ? { isLoading:
|
|
3443
|
+
tenant: o ? { isLoading: h, error: w, data: k } : null
|
|
3441
3444
|
};
|
|
3442
3445
|
}
|
|
3443
3446
|
class Zt {
|
|
@@ -3710,7 +3713,7 @@ export {
|
|
|
3710
3713
|
Zt as PermissionApiService,
|
|
3711
3714
|
qt as Protected,
|
|
3712
3715
|
zt as ProtectedRoute,
|
|
3713
|
-
|
|
3716
|
+
ke as RoleApiService,
|
|
3714
3717
|
we as SessionManager,
|
|
3715
3718
|
Gt as SignupForm,
|
|
3716
3719
|
Ze as SubscriptionApiService,
|
|
@@ -3718,11 +3721,11 @@ export {
|
|
|
3718
3721
|
er as SubscriptionPlanApiService,
|
|
3719
3722
|
Bt as SubscriptionProvider,
|
|
3720
3723
|
ue as TenantApiService,
|
|
3721
|
-
|
|
3724
|
+
$t as TenantProvider,
|
|
3722
3725
|
Ot as TenantRoute,
|
|
3723
3726
|
Oe as UserApiService,
|
|
3724
3727
|
ie as UserType,
|
|
3725
|
-
|
|
3728
|
+
Ft as useApi,
|
|
3726
3729
|
oe as useApp,
|
|
3727
3730
|
Xt as useAppLoaderState,
|
|
3728
3731
|
ae as useAuth,
|
|
@@ -3732,6 +3735,6 @@ export {
|
|
|
3732
3735
|
me as useTenant,
|
|
3733
3736
|
se as useTenantInfo,
|
|
3734
3737
|
Me as useTenantOptional,
|
|
3735
|
-
|
|
3738
|
+
Dt as useTenantSettings
|
|
3736
3739
|
};
|
|
3737
3740
|
//# sourceMappingURL=index.es.js.map
|