@skylabs-digital/react-identity-access 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -0
- package/dist/components/FeatureFlag.d.ts +9 -0
- package/dist/components/FeatureFlag.d.ts.map +1 -0
- package/dist/components/LoginForm.d.ts +50 -0
- package/dist/components/LoginForm.d.ts.map +1 -0
- package/dist/components/PasswordRecoveryForm.d.ts +54 -0
- package/dist/components/PasswordRecoveryForm.d.ts.map +1 -0
- package/dist/components/Protected.d.ts +11 -0
- package/dist/components/Protected.d.ts.map +1 -0
- package/dist/components/ProtectedRoute.d.ts +12 -0
- package/dist/components/ProtectedRoute.d.ts.map +1 -0
- package/dist/components/SignupForm.d.ts +54 -0
- package/dist/components/SignupForm.d.ts.map +1 -0
- package/dist/components/SubscriptionGuard.d.ts +9 -0
- package/dist/components/SubscriptionGuard.d.ts.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +2609 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/AppProvider.d.ts +41 -0
- package/dist/providers/AppProvider.d.ts.map +1 -0
- package/dist/providers/AuthProvider.d.ts +48 -0
- package/dist/providers/AuthProvider.d.ts.map +1 -0
- package/dist/providers/FeatureFlagProvider.d.ts +22 -0
- package/dist/providers/FeatureFlagProvider.d.ts.map +1 -0
- package/dist/providers/SubscriptionProvider.d.ts +24 -0
- package/dist/providers/SubscriptionProvider.d.ts.map +1 -0
- package/dist/providers/TenantProvider.d.ts +32 -0
- package/dist/providers/TenantProvider.d.ts.map +1 -0
- package/dist/services/AppApiService.d.ts +20 -0
- package/dist/services/AppApiService.d.ts.map +1 -0
- package/dist/services/AuthApiService.d.ts +29 -0
- package/dist/services/AuthApiService.d.ts.map +1 -0
- package/dist/services/FeatureFlagApiService.d.ts +19 -0
- package/dist/services/FeatureFlagApiService.d.ts.map +1 -0
- package/dist/services/HealthApiService.d.ts +9 -0
- package/dist/services/HealthApiService.d.ts.map +1 -0
- package/dist/services/HttpService.d.ts +21 -0
- package/dist/services/HttpService.d.ts.map +1 -0
- package/dist/services/PermissionApiService.d.ts +21 -0
- package/dist/services/PermissionApiService.d.ts.map +1 -0
- package/dist/services/RoleApiService.d.ts +23 -0
- package/dist/services/RoleApiService.d.ts.map +1 -0
- package/dist/services/SessionManager.d.ts +45 -0
- package/dist/services/SessionManager.d.ts.map +1 -0
- package/dist/services/SubscriptionApiService.d.ts +15 -0
- package/dist/services/SubscriptionApiService.d.ts.map +1 -0
- package/dist/services/SubscriptionPlanApiService.d.ts +19 -0
- package/dist/services/SubscriptionPlanApiService.d.ts.map +1 -0
- package/dist/services/TenantApiService.d.ts +21 -0
- package/dist/services/TenantApiService.d.ts.map +1 -0
- package/dist/services/UserApiService.d.ts +17 -0
- package/dist/services/UserApiService.d.ts.map +1 -0
- package/dist/types/api.d.ts +281 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/utils/mappers.d.ts +29 -0
- package/dist/utils/mappers.d.ts.map +1 -0
- package/package.json +135 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,2609 @@
|
|
|
1
|
+
import { jsx as i, Fragment as B, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as te, useState as b, useCallback as X, useMemo as N, useEffect as K, useContext as re } from "react";
|
|
3
|
+
import { useLocation as we, Navigate as ie } from "react-router";
|
|
4
|
+
class W {
|
|
5
|
+
// SessionManager instance
|
|
6
|
+
constructor(e, t = 1e4) {
|
|
7
|
+
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
8
|
+
}
|
|
9
|
+
setSessionManager(e) {
|
|
10
|
+
this.sessionManager = e;
|
|
11
|
+
}
|
|
12
|
+
getBaseUrl() {
|
|
13
|
+
return this.baseUrl;
|
|
14
|
+
}
|
|
15
|
+
async request(e, t, r, s) {
|
|
16
|
+
return this.executeRequest(e, t, r, s, !1);
|
|
17
|
+
}
|
|
18
|
+
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
+
const T = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, M = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let S = {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
...s == null ? void 0 : s.headers
|
|
23
|
+
};
|
|
24
|
+
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
|
+
try {
|
|
26
|
+
const p = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
S = { ...S, ...p };
|
|
28
|
+
} catch (p) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", p);
|
|
30
|
+
}
|
|
31
|
+
const E = new AbortController(), w = setTimeout(() => E.abort(), M);
|
|
32
|
+
try {
|
|
33
|
+
const p = await fetch(T, {
|
|
34
|
+
method: e,
|
|
35
|
+
headers: S,
|
|
36
|
+
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
+
signal: E.signal
|
|
38
|
+
});
|
|
39
|
+
if (clearTimeout(w), p.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
|
+
try {
|
|
41
|
+
const f = this.sessionManager.getTokens();
|
|
42
|
+
if (f != null && f.refreshToken)
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
|
+
} catch {
|
|
45
|
+
throw new Error(`HTTP ${p.status}: ${p.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
if (!p.ok)
|
|
48
|
+
throw new Error(`HTTP ${p.status}: ${p.statusText}`);
|
|
49
|
+
const v = p.headers.get("content-type");
|
|
50
|
+
return !v || !v.includes("application/json") ? {} : await p.json();
|
|
51
|
+
} catch (p) {
|
|
52
|
+
throw clearTimeout(w), p instanceof Error && p.name === "AbortError" ? new Error(`Request timeout after ${M}ms`) : p;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async get(e, t) {
|
|
56
|
+
return this.request("GET", e, void 0, t);
|
|
57
|
+
}
|
|
58
|
+
async post(e, t, r) {
|
|
59
|
+
return this.request("POST", e, t, r);
|
|
60
|
+
}
|
|
61
|
+
async put(e, t, r) {
|
|
62
|
+
return this.request("PUT", e, t, r);
|
|
63
|
+
}
|
|
64
|
+
async delete(e, t) {
|
|
65
|
+
return this.request("DELETE", e, void 0, t);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class ne {
|
|
69
|
+
constructor(e, t, r) {
|
|
70
|
+
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
71
|
+
}
|
|
72
|
+
async createTenant(e) {
|
|
73
|
+
if (!this.sessionManager)
|
|
74
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
75
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
76
|
+
return (await this.httpService.post("/tenants/", e, {
|
|
77
|
+
headers: t
|
|
78
|
+
})).data;
|
|
79
|
+
}
|
|
80
|
+
async getTenants(e) {
|
|
81
|
+
if (!this.sessionManager)
|
|
82
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
83
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
84
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
85
|
+
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
86
|
+
headers: t
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
tenants: o.data,
|
|
90
|
+
meta: o.meta
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async getTenantById(e) {
|
|
94
|
+
if (!this.sessionManager)
|
|
95
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
96
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
97
|
+
return (await this.httpService.get(`/tenants/${e}`, {
|
|
98
|
+
headers: t
|
|
99
|
+
})).data;
|
|
100
|
+
}
|
|
101
|
+
async updateTenant(e, t) {
|
|
102
|
+
if (!this.sessionManager)
|
|
103
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
104
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
105
|
+
return (await this.httpService.put(`/tenants/${e}`, t, {
|
|
106
|
+
headers: r
|
|
107
|
+
})).data;
|
|
108
|
+
}
|
|
109
|
+
async adminUpdateTenant(e, t) {
|
|
110
|
+
if (!this.sessionManager)
|
|
111
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
112
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
113
|
+
return (await this.httpService.put(
|
|
114
|
+
`/tenants/${e}/admin-update`,
|
|
115
|
+
t,
|
|
116
|
+
{
|
|
117
|
+
headers: r
|
|
118
|
+
}
|
|
119
|
+
)).data;
|
|
120
|
+
}
|
|
121
|
+
// Public endpoint - no auth required
|
|
122
|
+
async getPublicTenantInfo(e) {
|
|
123
|
+
return (await this.httpService.get(
|
|
124
|
+
`/tenants/${this.appId}/${e}/public`
|
|
125
|
+
)).data;
|
|
126
|
+
}
|
|
127
|
+
// Settings endpoints
|
|
128
|
+
async getTenantSettings(e) {
|
|
129
|
+
return (await this.httpService.get(
|
|
130
|
+
`/tenants/${e}/settings`
|
|
131
|
+
)).data;
|
|
132
|
+
}
|
|
133
|
+
async updateTenantSettings(e, t) {
|
|
134
|
+
if (!this.sessionManager)
|
|
135
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
136
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
137
|
+
return (await this.httpService.put(
|
|
138
|
+
`/tenants/${e}/settings`,
|
|
139
|
+
t,
|
|
140
|
+
{
|
|
141
|
+
headers: r
|
|
142
|
+
}
|
|
143
|
+
)).data;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
class ye {
|
|
147
|
+
constructor(e, t) {
|
|
148
|
+
this.httpService = e, this.sessionManager = t;
|
|
149
|
+
}
|
|
150
|
+
async createApp(e) {
|
|
151
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
152
|
+
return (await this.httpService.post("/apps/", e, {
|
|
153
|
+
headers: t
|
|
154
|
+
})).data;
|
|
155
|
+
}
|
|
156
|
+
async getApps(e) {
|
|
157
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
158
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
159
|
+
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
160
|
+
headers: t
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
apps: o.data,
|
|
164
|
+
meta: o.meta
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async getAppById(e) {
|
|
168
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
169
|
+
return (await this.httpService.get(`/apps/${e}`, {
|
|
170
|
+
headers: t
|
|
171
|
+
})).data;
|
|
172
|
+
}
|
|
173
|
+
async updateApp(e, t) {
|
|
174
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
175
|
+
return (await this.httpService.put(`/apps/${e}`, t, {
|
|
176
|
+
headers: r
|
|
177
|
+
})).data;
|
|
178
|
+
}
|
|
179
|
+
async getPublicAppInfo(e) {
|
|
180
|
+
return (await this.httpService.get(`/apps/${e}/public`)).data;
|
|
181
|
+
}
|
|
182
|
+
async setDefaultSubscriptionPlan(e, t) {
|
|
183
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
184
|
+
return (await this.httpService.put(
|
|
185
|
+
`/apps/${e}/default-subscription-plan`,
|
|
186
|
+
{ planId: t },
|
|
187
|
+
{ headers: r }
|
|
188
|
+
)).data;
|
|
189
|
+
}
|
|
190
|
+
async updateSettingsSchema(e, t, r) {
|
|
191
|
+
const s = await this.sessionManager.getAuthHeaders();
|
|
192
|
+
return (await this.httpService.put(
|
|
193
|
+
`/apps/${e}/settings-schema`,
|
|
194
|
+
{ schema: t, defaultSettings: r },
|
|
195
|
+
{ headers: s }
|
|
196
|
+
)).data;
|
|
197
|
+
}
|
|
198
|
+
async exportConfig(e) {
|
|
199
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
200
|
+
return (await this.httpService.get(`/apps/${e}/export-config`, {
|
|
201
|
+
headers: t
|
|
202
|
+
})).data;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const ue = te(null), me = () => /* @__PURE__ */ i(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
style: {
|
|
209
|
+
display: "flex",
|
|
210
|
+
justifyContent: "center",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
height: "100vh",
|
|
213
|
+
fontFamily: "system-ui, sans-serif"
|
|
214
|
+
},
|
|
215
|
+
children: /* @__PURE__ */ i("div", { children: "Loading application..." })
|
|
216
|
+
}
|
|
217
|
+
), oe = ({ error: n, retry: e }) => /* @__PURE__ */ g(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
style: {
|
|
221
|
+
display: "flex",
|
|
222
|
+
flexDirection: "column",
|
|
223
|
+
justifyContent: "center",
|
|
224
|
+
alignItems: "center",
|
|
225
|
+
height: "100vh",
|
|
226
|
+
fontFamily: "system-ui, sans-serif",
|
|
227
|
+
textAlign: "center",
|
|
228
|
+
padding: "20px"
|
|
229
|
+
},
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ i("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
232
|
+
/* @__PURE__ */ i("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: n.message || "Unable to load application" }),
|
|
233
|
+
/* @__PURE__ */ i(
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
onClick: e,
|
|
237
|
+
style: {
|
|
238
|
+
padding: "8px 16px",
|
|
239
|
+
backgroundColor: "#007bff",
|
|
240
|
+
color: "white",
|
|
241
|
+
border: "none",
|
|
242
|
+
borderRadius: "4px",
|
|
243
|
+
cursor: "pointer"
|
|
244
|
+
},
|
|
245
|
+
children: "Retry"
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
function _e({ config: n, children: e }) {
|
|
252
|
+
const [t, r] = b(n.initialTenant || null), [s, o] = b(!n.initialTenant), [T, M] = b(null), [S, E] = b(null), [w, p] = b(!0), [v, f] = b(null), y = X(() => {
|
|
253
|
+
const l = n.tenantMode || "fixed", a = "tenant";
|
|
254
|
+
if (l === "fixed")
|
|
255
|
+
return n.fixedTenantSlug || null;
|
|
256
|
+
if (typeof window > "u") return null;
|
|
257
|
+
if (l === "subdomain") {
|
|
258
|
+
const k = window.location.hostname.split(".");
|
|
259
|
+
if (k.length >= 3) {
|
|
260
|
+
const F = k[0];
|
|
261
|
+
return localStorage.setItem(a, F), F;
|
|
262
|
+
}
|
|
263
|
+
return localStorage.getItem(a);
|
|
264
|
+
} else {
|
|
265
|
+
const k = new URLSearchParams(window.location.search).get(n.selectorParam || "tenant");
|
|
266
|
+
return k ? (localStorage.setItem(a, k), k) : localStorage.getItem(a);
|
|
267
|
+
}
|
|
268
|
+
}, [n.tenantMode, n.fixedTenantSlug, n.selectorParam]), c = N(() => y(), [y]), C = N(() => {
|
|
269
|
+
const l = () => {
|
|
270
|
+
c && d(c);
|
|
271
|
+
}, a = () => {
|
|
272
|
+
x();
|
|
273
|
+
};
|
|
274
|
+
return {
|
|
275
|
+
appId: n.appId,
|
|
276
|
+
baseUrl: n.baseUrl,
|
|
277
|
+
// Tenant info
|
|
278
|
+
tenant: t,
|
|
279
|
+
tenantSlug: c,
|
|
280
|
+
isTenantLoading: s,
|
|
281
|
+
tenantError: T,
|
|
282
|
+
retryTenant: l,
|
|
283
|
+
// App info
|
|
284
|
+
appInfo: S,
|
|
285
|
+
isAppLoading: w,
|
|
286
|
+
appError: v,
|
|
287
|
+
retryApp: a
|
|
288
|
+
};
|
|
289
|
+
}, [n, t, c, s, T, S, w, v]), x = X(async () => {
|
|
290
|
+
try {
|
|
291
|
+
p(!0), f(null);
|
|
292
|
+
const l = new W(n.baseUrl), u = await new ye(l, {}).getPublicAppInfo(n.appId);
|
|
293
|
+
E(u);
|
|
294
|
+
} catch (l) {
|
|
295
|
+
const a = l instanceof Error ? l : new Error("Failed to load app information");
|
|
296
|
+
f(a), E(null);
|
|
297
|
+
} finally {
|
|
298
|
+
p(!1);
|
|
299
|
+
}
|
|
300
|
+
}, [n.baseUrl, n.appId]), d = X(
|
|
301
|
+
async (l) => {
|
|
302
|
+
try {
|
|
303
|
+
o(!0), M(null);
|
|
304
|
+
const a = new W(n.baseUrl), k = await new ne(a, n.appId).getPublicTenantInfo(l);
|
|
305
|
+
r(k);
|
|
306
|
+
} catch (a) {
|
|
307
|
+
const u = a instanceof Error ? a : new Error("Failed to load tenant information");
|
|
308
|
+
M(u), r(null);
|
|
309
|
+
} finally {
|
|
310
|
+
o(!1);
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
[n.baseUrl, n.appId]
|
|
314
|
+
);
|
|
315
|
+
if (K(() => {
|
|
316
|
+
x();
|
|
317
|
+
}, [x]), K(() => {
|
|
318
|
+
if (!n.initialTenant && c)
|
|
319
|
+
d(c);
|
|
320
|
+
else if (!n.initialTenant && !c && n.tenantMode !== "fixed") {
|
|
321
|
+
const l = n.tenantMode || "fixed";
|
|
322
|
+
M(
|
|
323
|
+
new Error(`No tenant ${l === "subdomain" ? "subdomain" : "parameter"} found`)
|
|
324
|
+
), o(!1);
|
|
325
|
+
} else n.tenantMode === "fixed" && !n.fixedTenantSlug && (M(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), o(!1));
|
|
326
|
+
}, [n.initialTenant, c, d, n.tenantMode, n.fixedTenantSlug]), s)
|
|
327
|
+
return /* @__PURE__ */ i(B, { children: n.loadingFallback || /* @__PURE__ */ i(me, {}) });
|
|
328
|
+
if (T) {
|
|
329
|
+
const l = typeof n.errorFallback == "function" ? n.errorFallback(T, () => d(c || "")) : n.errorFallback || /* @__PURE__ */ i(oe, { error: T, retry: () => d(c || "") });
|
|
330
|
+
return /* @__PURE__ */ i(B, { children: l });
|
|
331
|
+
}
|
|
332
|
+
return !t && n.tenantMode !== "fixed" ? /* @__PURE__ */ i(
|
|
333
|
+
oe,
|
|
334
|
+
{
|
|
335
|
+
error: new Error("No tenant information available"),
|
|
336
|
+
retry: () => d(c || "")
|
|
337
|
+
}
|
|
338
|
+
) : /* @__PURE__ */ i(ue.Provider, { value: C, children: e });
|
|
339
|
+
}
|
|
340
|
+
function G() {
|
|
341
|
+
const n = re(ue);
|
|
342
|
+
if (!n)
|
|
343
|
+
throw new Error("useApp must be used within an AppProvider");
|
|
344
|
+
return n;
|
|
345
|
+
}
|
|
346
|
+
const Ke = G;
|
|
347
|
+
function Ye() {
|
|
348
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = G();
|
|
349
|
+
return {
|
|
350
|
+
tenant: n,
|
|
351
|
+
tenantSlug: e,
|
|
352
|
+
isLoading: t,
|
|
353
|
+
error: r,
|
|
354
|
+
retry: s
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
class be {
|
|
358
|
+
constructor(e = {}) {
|
|
359
|
+
this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
|
|
360
|
+
get: () => {
|
|
361
|
+
try {
|
|
362
|
+
const t = localStorage.getItem(this.storageKey);
|
|
363
|
+
return t ? JSON.parse(t) : null;
|
|
364
|
+
} catch {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
set: (t) => {
|
|
369
|
+
try {
|
|
370
|
+
localStorage.setItem(this.storageKey, JSON.stringify(t));
|
|
371
|
+
} catch {
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
clear: () => {
|
|
375
|
+
try {
|
|
376
|
+
localStorage.removeItem(this.storageKey);
|
|
377
|
+
} catch {
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
setTokens(e) {
|
|
383
|
+
const t = {
|
|
384
|
+
...e,
|
|
385
|
+
expiresAt: e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0)
|
|
386
|
+
};
|
|
387
|
+
this.tokenStorage.set(t);
|
|
388
|
+
}
|
|
389
|
+
getTokens() {
|
|
390
|
+
return this.tokenStorage.get();
|
|
391
|
+
}
|
|
392
|
+
clearTokens() {
|
|
393
|
+
this.tokenStorage.clear();
|
|
394
|
+
}
|
|
395
|
+
isTokenExpired(e) {
|
|
396
|
+
const t = e || this.getTokens();
|
|
397
|
+
return t != null && t.expiresAt ? Date.now() >= t.expiresAt : !1;
|
|
398
|
+
}
|
|
399
|
+
shouldRefreshToken(e) {
|
|
400
|
+
const t = e || this.getTokens();
|
|
401
|
+
return !(t != null && t.expiresAt) || !this.autoRefresh ? !1 : Date.now() >= t.expiresAt - this.refreshThreshold;
|
|
402
|
+
}
|
|
403
|
+
getAccessToken() {
|
|
404
|
+
const e = this.getTokens();
|
|
405
|
+
return (e == null ? void 0 : e.accessToken) || null;
|
|
406
|
+
}
|
|
407
|
+
async getAuthHeaders() {
|
|
408
|
+
const e = this.getTokens();
|
|
409
|
+
if (!(e != null && e.accessToken))
|
|
410
|
+
return {};
|
|
411
|
+
if (!this.shouldRefreshToken(e))
|
|
412
|
+
return {
|
|
413
|
+
Authorization: `Bearer ${e.accessToken}`
|
|
414
|
+
};
|
|
415
|
+
if (!e.refreshToken)
|
|
416
|
+
return this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
417
|
+
if (this.refreshPromise)
|
|
418
|
+
return new Promise((t, r) => {
|
|
419
|
+
this.refreshQueue.push({ resolve: t, reject: r });
|
|
420
|
+
});
|
|
421
|
+
this.refreshPromise = this.performTokenRefresh(e.refreshToken);
|
|
422
|
+
try {
|
|
423
|
+
await this.refreshPromise;
|
|
424
|
+
const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
425
|
+
return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
|
|
426
|
+
} catch (t) {
|
|
427
|
+
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
428
|
+
return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
429
|
+
} finally {
|
|
430
|
+
this.refreshPromise = null;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async performTokenRefresh(e) {
|
|
434
|
+
if (!this.baseUrl)
|
|
435
|
+
throw new Error("Base URL not configured for token refresh");
|
|
436
|
+
const t = `${this.baseUrl}/auth/refresh`, r = await fetch(t, {
|
|
437
|
+
method: "POST",
|
|
438
|
+
headers: {
|
|
439
|
+
"Content-Type": "application/json"
|
|
440
|
+
},
|
|
441
|
+
body: JSON.stringify({
|
|
442
|
+
refreshToken: e
|
|
443
|
+
})
|
|
444
|
+
});
|
|
445
|
+
if (!r.ok)
|
|
446
|
+
throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
|
|
447
|
+
const s = await r.json();
|
|
448
|
+
this.setTokens({
|
|
449
|
+
accessToken: s.accessToken,
|
|
450
|
+
refreshToken: s.refreshToken || e,
|
|
451
|
+
expiresIn: s.expiresIn
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
setUser(e) {
|
|
455
|
+
const t = this.tokenStorage.get() || {};
|
|
456
|
+
this.tokenStorage.set({ ...t, user: e });
|
|
457
|
+
}
|
|
458
|
+
getUser() {
|
|
459
|
+
const e = this.tokenStorage.get();
|
|
460
|
+
return (e == null ? void 0 : e.user) || null;
|
|
461
|
+
}
|
|
462
|
+
clearUser() {
|
|
463
|
+
const e = this.tokenStorage.get() || {};
|
|
464
|
+
delete e.user, this.tokenStorage.set(e);
|
|
465
|
+
}
|
|
466
|
+
clearSession() {
|
|
467
|
+
this.clearTokens(), this.clearUser();
|
|
468
|
+
}
|
|
469
|
+
hasValidSession() {
|
|
470
|
+
const e = this.getTokens();
|
|
471
|
+
return e !== null && !this.isTokenExpired(e);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
class Se {
|
|
475
|
+
constructor(e) {
|
|
476
|
+
this.httpService = e;
|
|
477
|
+
}
|
|
478
|
+
// Public endpoints - no auth required
|
|
479
|
+
async login(e) {
|
|
480
|
+
const t = await this.httpService.post("/auth/login", e);
|
|
481
|
+
return console.log(t), t;
|
|
482
|
+
}
|
|
483
|
+
async signup(e) {
|
|
484
|
+
return await this.httpService.post("/auth/signup", e);
|
|
485
|
+
}
|
|
486
|
+
async signupTenantAdmin(e) {
|
|
487
|
+
return await this.httpService.post(
|
|
488
|
+
"/auth/signup/tenant-admin",
|
|
489
|
+
e
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
async refreshToken(e) {
|
|
493
|
+
return await this.httpService.post("/auth/refresh", e);
|
|
494
|
+
}
|
|
495
|
+
async requestPasswordReset(e) {
|
|
496
|
+
await this.httpService.post("/auth/password-reset/request", e);
|
|
497
|
+
}
|
|
498
|
+
async confirmPasswordReset(e) {
|
|
499
|
+
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
500
|
+
}
|
|
501
|
+
// Protected endpoints - auth required
|
|
502
|
+
async changePassword(e, t) {
|
|
503
|
+
await this.httpService.post("/auth/change-password", e, {
|
|
504
|
+
headers: t
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
class ae {
|
|
509
|
+
constructor(e, t) {
|
|
510
|
+
this.httpService = e, this.sessionManager = t;
|
|
511
|
+
}
|
|
512
|
+
async createRole(e) {
|
|
513
|
+
if (!this.sessionManager)
|
|
514
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
515
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
516
|
+
return (await this.httpService.post("/roles/", e, {
|
|
517
|
+
headers: t
|
|
518
|
+
})).data;
|
|
519
|
+
}
|
|
520
|
+
async getRoleById(e) {
|
|
521
|
+
if (!this.sessionManager)
|
|
522
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
523
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
524
|
+
return (await this.httpService.get(`/roles/${e}`, {
|
|
525
|
+
headers: t
|
|
526
|
+
})).data;
|
|
527
|
+
}
|
|
528
|
+
async updateRole(e, t) {
|
|
529
|
+
if (!this.sessionManager)
|
|
530
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
531
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
532
|
+
return (await this.httpService.put(`/roles/${e}`, t, {
|
|
533
|
+
headers: r
|
|
534
|
+
})).data;
|
|
535
|
+
}
|
|
536
|
+
async deleteRole(e) {
|
|
537
|
+
if (!this.sessionManager)
|
|
538
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
539
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
540
|
+
await this.httpService.delete(`/roles/${e}`, {
|
|
541
|
+
headers: t
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
// Public endpoint - no auth required
|
|
545
|
+
async getRolesByApp(e, t) {
|
|
546
|
+
const r = new URLSearchParams();
|
|
547
|
+
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
548
|
+
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
|
|
549
|
+
return {
|
|
550
|
+
roles: o.data,
|
|
551
|
+
meta: o.meta
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
async assignRole(e, t) {
|
|
555
|
+
if (!this.sessionManager)
|
|
556
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
557
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
558
|
+
await this.httpService.post(`/roles/${e}/assign`, t, {
|
|
559
|
+
headers: r
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
async revokeRole(e, t) {
|
|
563
|
+
if (!this.sessionManager)
|
|
564
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
565
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
566
|
+
await this.httpService.post(`/roles/${e}/revoke`, t, {
|
|
567
|
+
headers: r
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
async getUserRoles(e, t) {
|
|
571
|
+
if (!this.sessionManager)
|
|
572
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
573
|
+
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
574
|
+
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);
|
|
575
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, T = await this.httpService.get(o, {
|
|
576
|
+
headers: r
|
|
577
|
+
});
|
|
578
|
+
return {
|
|
579
|
+
roles: T.data,
|
|
580
|
+
meta: T.meta
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
class ve {
|
|
585
|
+
constructor(e, t) {
|
|
586
|
+
this.httpService = e, this.sessionManager = t;
|
|
587
|
+
}
|
|
588
|
+
async createUser(e) {
|
|
589
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
590
|
+
return (await this.httpService.post("/users/", e, {
|
|
591
|
+
headers: t
|
|
592
|
+
})).data;
|
|
593
|
+
}
|
|
594
|
+
async getUsers(e) {
|
|
595
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
596
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
597
|
+
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
598
|
+
headers: t
|
|
599
|
+
});
|
|
600
|
+
return {
|
|
601
|
+
users: o.data,
|
|
602
|
+
meta: o.meta
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
async getUserById(e) {
|
|
606
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
607
|
+
return (await this.httpService.get(`/users/${e}`, {
|
|
608
|
+
headers: t
|
|
609
|
+
})).data;
|
|
610
|
+
}
|
|
611
|
+
async updateUser(e, t) {
|
|
612
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
613
|
+
return (await this.httpService.put(`/users/${e}`, t, {
|
|
614
|
+
headers: r
|
|
615
|
+
})).data;
|
|
616
|
+
}
|
|
617
|
+
async deleteUser(e) {
|
|
618
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
619
|
+
await this.httpService.delete(`/users/${e}`, {
|
|
620
|
+
headers: t
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const he = te(null);
|
|
625
|
+
function Qe({ config: n = {}, children: e }) {
|
|
626
|
+
const { appId: t, tenantSlug: r, baseUrl: s } = G(), [o, T] = b(n.initialRoles || []), [M, S] = b(!n.initialRoles), [E, w] = b(null), [p, v] = b(!1), [f, y] = b(null), c = N(() => {
|
|
627
|
+
const m = r ? `auth_tokens_${r}` : "auth_tokens", R = {
|
|
628
|
+
get: () => {
|
|
629
|
+
try {
|
|
630
|
+
const U = localStorage.getItem(m);
|
|
631
|
+
return U ? JSON.parse(U) : null;
|
|
632
|
+
} catch {
|
|
633
|
+
return null;
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
set: (U) => {
|
|
637
|
+
try {
|
|
638
|
+
localStorage.setItem(m, JSON.stringify(U));
|
|
639
|
+
} catch {
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
clear: () => {
|
|
643
|
+
try {
|
|
644
|
+
localStorage.removeItem(m);
|
|
645
|
+
} catch {
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
return new be({
|
|
650
|
+
onRefreshFailed: n.onRefreshFailed,
|
|
651
|
+
tokenStorage: R,
|
|
652
|
+
baseUrl: s
|
|
653
|
+
});
|
|
654
|
+
}, [r, s, n.onRefreshFailed]), C = N(() => {
|
|
655
|
+
const m = new W(s);
|
|
656
|
+
return m.setSessionManager(c), m;
|
|
657
|
+
}, [s, c]), x = N(() => new Se(new W(s)), [s]), d = N(() => new ve(C, c), [C, c]), l = N(() => new ae(new W(s)), [s]), a = N(() => E || c.getUser(), [E, c]), u = N(() => a != null && a.roleId && o.find((m) => m.id === a.roleId) || null, [a, o]), k = N(() => (u == null ? void 0 : u.permissions) || [], [u]);
|
|
658
|
+
K(() => {
|
|
659
|
+
console.log("AuthProvider - userPermissions changed:", k);
|
|
660
|
+
}, [k]);
|
|
661
|
+
const F = N(() => {
|
|
662
|
+
const m = async () => {
|
|
663
|
+
try {
|
|
664
|
+
v(!0), y(null);
|
|
665
|
+
const A = c.getUser();
|
|
666
|
+
if (!(A != null && A.id))
|
|
667
|
+
throw new Error("No user ID available in session");
|
|
668
|
+
const $ = await d.getUserById(A.id);
|
|
669
|
+
w($), c.setUser($);
|
|
670
|
+
} catch (A) {
|
|
671
|
+
const $ = A instanceof Error ? A : new Error("Failed to load user data");
|
|
672
|
+
y($), console.error("Failed to load user data:", $);
|
|
673
|
+
} finally {
|
|
674
|
+
v(!1);
|
|
675
|
+
}
|
|
676
|
+
}, R = async () => {
|
|
677
|
+
await m();
|
|
678
|
+
}, U = async (A, $, J) => {
|
|
679
|
+
const V = await x.login({
|
|
680
|
+
email: A,
|
|
681
|
+
password: $,
|
|
682
|
+
tenantId: J
|
|
683
|
+
});
|
|
684
|
+
if (c.setTokens({
|
|
685
|
+
accessToken: V.accessToken,
|
|
686
|
+
refreshToken: V.refreshToken,
|
|
687
|
+
expiresIn: V.expiresIn
|
|
688
|
+
}), V.user) {
|
|
689
|
+
c.setUser(V.user), w(V.user);
|
|
690
|
+
try {
|
|
691
|
+
await m();
|
|
692
|
+
} catch (se) {
|
|
693
|
+
console.warn("Failed to load complete user data after login:", se);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return V;
|
|
697
|
+
}, I = async (A, $, J, V) => await x.signup({ email: A, name: $, password: J, tenantId: V }), h = async (A, $, J, V) => await x.signupTenantAdmin({
|
|
698
|
+
email: A,
|
|
699
|
+
name: $,
|
|
700
|
+
password: J,
|
|
701
|
+
tenantName: V,
|
|
702
|
+
appId: t
|
|
703
|
+
}), P = async (A, $) => {
|
|
704
|
+
const J = await c.getAuthHeaders();
|
|
705
|
+
await x.changePassword({ currentPassword: A, newPassword: $ }, J);
|
|
706
|
+
}, Y = async (A, $) => {
|
|
707
|
+
await x.requestPasswordReset({ email: A, tenantId: $ });
|
|
708
|
+
}, L = async (A, $) => {
|
|
709
|
+
await x.confirmPasswordReset({ token: A, newPassword: $ });
|
|
710
|
+
}, z = async () => {
|
|
711
|
+
const A = c.getTokens();
|
|
712
|
+
if (!(A != null && A.refreshToken))
|
|
713
|
+
throw new Error("No refresh token available");
|
|
714
|
+
const $ = await x.refreshToken({
|
|
715
|
+
refreshToken: A.refreshToken
|
|
716
|
+
});
|
|
717
|
+
c.setTokens({
|
|
718
|
+
accessToken: $.accessToken,
|
|
719
|
+
refreshToken: $.refreshToken || A.refreshToken,
|
|
720
|
+
expiresIn: $.expiresIn
|
|
721
|
+
});
|
|
722
|
+
}, _ = () => {
|
|
723
|
+
c.clearSession(), w(null), y(null);
|
|
724
|
+
}, H = (A) => {
|
|
725
|
+
c.setTokens(A);
|
|
726
|
+
}, q = () => c.hasValidSession(), Q = () => {
|
|
727
|
+
c.clearSession(), w(null), y(null);
|
|
728
|
+
}, D = async () => {
|
|
729
|
+
if (t)
|
|
730
|
+
try {
|
|
731
|
+
S(!0);
|
|
732
|
+
const { roles: A } = await l.getRolesByApp(t);
|
|
733
|
+
T(A);
|
|
734
|
+
} catch (A) {
|
|
735
|
+
console.error("Failed to fetch roles:", A);
|
|
736
|
+
} finally {
|
|
737
|
+
S(!1);
|
|
738
|
+
}
|
|
739
|
+
}, j = async () => {
|
|
740
|
+
await D();
|
|
741
|
+
}, O = (A) => {
|
|
742
|
+
if (!k || k.length === 0)
|
|
743
|
+
return !1;
|
|
744
|
+
if (typeof A == "string")
|
|
745
|
+
return k.includes(A);
|
|
746
|
+
const $ = `${A.resource}.${A.action}`;
|
|
747
|
+
return k.includes($);
|
|
748
|
+
};
|
|
749
|
+
return {
|
|
750
|
+
sessionManager: c,
|
|
751
|
+
authenticatedHttpService: C,
|
|
752
|
+
login: U,
|
|
753
|
+
signup: I,
|
|
754
|
+
signupTenantAdmin: h,
|
|
755
|
+
changePassword: P,
|
|
756
|
+
requestPasswordReset: Y,
|
|
757
|
+
confirmPasswordReset: L,
|
|
758
|
+
refreshToken: z,
|
|
759
|
+
logout: _,
|
|
760
|
+
setTokens: H,
|
|
761
|
+
hasValidSession: q,
|
|
762
|
+
clearSession: Q,
|
|
763
|
+
currentUser: E,
|
|
764
|
+
isUserLoading: p,
|
|
765
|
+
userError: f,
|
|
766
|
+
refreshUser: R,
|
|
767
|
+
userRole: u,
|
|
768
|
+
userPermissions: k,
|
|
769
|
+
availableRoles: o,
|
|
770
|
+
rolesLoading: M,
|
|
771
|
+
hasPermission: O,
|
|
772
|
+
hasAnyPermission: (A) => A.some(($) => O($)),
|
|
773
|
+
hasAllPermissions: (A) => A.every(($) => O($)),
|
|
774
|
+
getUserPermissionStrings: () => k || [],
|
|
775
|
+
refreshRoles: j
|
|
776
|
+
};
|
|
777
|
+
}, [
|
|
778
|
+
c,
|
|
779
|
+
C,
|
|
780
|
+
x,
|
|
781
|
+
d,
|
|
782
|
+
l,
|
|
783
|
+
t,
|
|
784
|
+
o,
|
|
785
|
+
E,
|
|
786
|
+
p,
|
|
787
|
+
f,
|
|
788
|
+
u,
|
|
789
|
+
k
|
|
790
|
+
]);
|
|
791
|
+
return K(() => {
|
|
792
|
+
!n.initialRoles && t && (async () => {
|
|
793
|
+
try {
|
|
794
|
+
S(!0);
|
|
795
|
+
const R = new W(s), U = new ae(R), { roles: I } = await U.getRolesByApp(t);
|
|
796
|
+
T(I);
|
|
797
|
+
} catch (R) {
|
|
798
|
+
console.error("Failed to fetch roles:", R);
|
|
799
|
+
} finally {
|
|
800
|
+
S(!1);
|
|
801
|
+
}
|
|
802
|
+
})();
|
|
803
|
+
}, [t, s, n.initialRoles]), K(() => {
|
|
804
|
+
const m = c.getUser();
|
|
805
|
+
m && c.hasValidSession() && w(m);
|
|
806
|
+
}, [c]), /* @__PURE__ */ i(he.Provider, { value: F, children: e });
|
|
807
|
+
}
|
|
808
|
+
function ee() {
|
|
809
|
+
const n = re(he);
|
|
810
|
+
if (!n)
|
|
811
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
812
|
+
return n;
|
|
813
|
+
}
|
|
814
|
+
class xe {
|
|
815
|
+
constructor(e, t) {
|
|
816
|
+
this.httpService = e, this.sessionManager = t;
|
|
817
|
+
}
|
|
818
|
+
async createFeatureFlag(e) {
|
|
819
|
+
if (!this.sessionManager)
|
|
820
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
821
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
822
|
+
return (await this.httpService.post(
|
|
823
|
+
"/feature-flags/",
|
|
824
|
+
e,
|
|
825
|
+
{
|
|
826
|
+
headers: t
|
|
827
|
+
}
|
|
828
|
+
)).data;
|
|
829
|
+
}
|
|
830
|
+
async getFeatureFlags(e) {
|
|
831
|
+
if (!this.sessionManager)
|
|
832
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
833
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
834
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
835
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
836
|
+
headers: t
|
|
837
|
+
});
|
|
838
|
+
return {
|
|
839
|
+
featureFlags: o.data,
|
|
840
|
+
meta: o.meta
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
async getFeatureFlagById(e) {
|
|
844
|
+
if (!this.sessionManager)
|
|
845
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
846
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
847
|
+
return (await this.httpService.get(`/feature-flags/${e}`, {
|
|
848
|
+
headers: t
|
|
849
|
+
})).data;
|
|
850
|
+
}
|
|
851
|
+
async updateFeatureFlag(e, t) {
|
|
852
|
+
if (!this.sessionManager)
|
|
853
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
854
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
855
|
+
return (await this.httpService.put(
|
|
856
|
+
`/feature-flags/${e}`,
|
|
857
|
+
t,
|
|
858
|
+
{
|
|
859
|
+
headers: r
|
|
860
|
+
}
|
|
861
|
+
)).data;
|
|
862
|
+
}
|
|
863
|
+
async deleteFeatureFlag(e) {
|
|
864
|
+
if (!this.sessionManager)
|
|
865
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
866
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
867
|
+
await this.httpService.delete(`/feature-flags/${e}`, {
|
|
868
|
+
headers: t
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
// Public endpoint - no auth required
|
|
872
|
+
async getTenantFeatureFlags(e, t) {
|
|
873
|
+
if (!e || !t)
|
|
874
|
+
throw new Error("Tenant ID and App ID are required");
|
|
875
|
+
const r = new URLSearchParams();
|
|
876
|
+
r.append("tenantId", e), r.append("appId", t);
|
|
877
|
+
const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
|
|
878
|
+
return (await this.httpService.get(s, {
|
|
879
|
+
headers: { "X-Tenant-ID": e }
|
|
880
|
+
})).data;
|
|
881
|
+
}
|
|
882
|
+
// Public endpoint - no auth required
|
|
883
|
+
async getTenantFeatureFlag(e, t, r) {
|
|
884
|
+
if (!e || !t || !r)
|
|
885
|
+
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
886
|
+
const s = new URLSearchParams();
|
|
887
|
+
s.append("tenantId", t), s.append("appId", r);
|
|
888
|
+
const o = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
889
|
+
return (await this.httpService.get(o, {
|
|
890
|
+
headers: { "X-Tenant-ID": t }
|
|
891
|
+
})).data;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
const ge = te(null);
|
|
895
|
+
function Je({ config: n = {}, children: e }) {
|
|
896
|
+
const { tenant: t, baseUrl: r, appId: s } = G(), [o, T] = b([]), [M, S] = b(!1), [E, w] = b(null), p = N(() => {
|
|
897
|
+
const y = new W(r);
|
|
898
|
+
return new xe(y);
|
|
899
|
+
}, [r]), v = async () => {
|
|
900
|
+
if (!(t != null && t.id)) {
|
|
901
|
+
T([]);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
S(!0), w(null);
|
|
905
|
+
try {
|
|
906
|
+
const y = await p.getTenantFeatureFlags(t.id, s);
|
|
907
|
+
T(y);
|
|
908
|
+
} catch (y) {
|
|
909
|
+
const c = y instanceof Error ? y.message : "Failed to fetch feature flags";
|
|
910
|
+
w(c), n.onError && n.onError(y instanceof Error ? y : new Error(c));
|
|
911
|
+
} finally {
|
|
912
|
+
S(!1);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
K(() => {
|
|
916
|
+
v();
|
|
917
|
+
const y = n.refreshInterval || 5 * 60 * 1e3, c = setInterval(v, y);
|
|
918
|
+
return () => clearInterval(c);
|
|
919
|
+
}, [t == null ? void 0 : t.id, n.refreshInterval]);
|
|
920
|
+
const f = N(() => ({
|
|
921
|
+
featureFlags: o,
|
|
922
|
+
loading: M,
|
|
923
|
+
error: E,
|
|
924
|
+
isEnabled: (d) => {
|
|
925
|
+
const l = o.find((a) => a.key === d);
|
|
926
|
+
return (l == null ? void 0 : l.value) === !0;
|
|
927
|
+
},
|
|
928
|
+
getFlag: (d) => o.find((l) => l.key === d),
|
|
929
|
+
getFlagState: (d) => {
|
|
930
|
+
const l = o.find((a) => a.key === d);
|
|
931
|
+
return l ? l.value ? "enabled" : "disabled" : "not_found";
|
|
932
|
+
},
|
|
933
|
+
refresh: async () => {
|
|
934
|
+
await v();
|
|
935
|
+
}
|
|
936
|
+
}), [o, M, E]);
|
|
937
|
+
return /* @__PURE__ */ i(ge.Provider, { value: f, children: e });
|
|
938
|
+
}
|
|
939
|
+
function Ae() {
|
|
940
|
+
const n = re(ge);
|
|
941
|
+
if (!n)
|
|
942
|
+
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
943
|
+
return n;
|
|
944
|
+
}
|
|
945
|
+
class Pe {
|
|
946
|
+
constructor(e, t) {
|
|
947
|
+
this.httpService = e, this.sessionManager = t;
|
|
948
|
+
}
|
|
949
|
+
async createSubscription(e) {
|
|
950
|
+
if (!this.sessionManager)
|
|
951
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
952
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
953
|
+
return (await this.httpService.post(
|
|
954
|
+
"/subscriptions/",
|
|
955
|
+
e,
|
|
956
|
+
{
|
|
957
|
+
headers: t
|
|
958
|
+
}
|
|
959
|
+
)).data;
|
|
960
|
+
}
|
|
961
|
+
async getSubscriptionById(e) {
|
|
962
|
+
if (!this.sessionManager)
|
|
963
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
964
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
965
|
+
return (await this.httpService.get(
|
|
966
|
+
`/subscriptions/subscriptions/${e}`,
|
|
967
|
+
{
|
|
968
|
+
headers: t
|
|
969
|
+
}
|
|
970
|
+
)).data;
|
|
971
|
+
}
|
|
972
|
+
async updateSubscription(e, t) {
|
|
973
|
+
if (!this.sessionManager)
|
|
974
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
975
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
976
|
+
return (await this.httpService.put(
|
|
977
|
+
`/subscriptions/${e}`,
|
|
978
|
+
t,
|
|
979
|
+
{
|
|
980
|
+
headers: r
|
|
981
|
+
}
|
|
982
|
+
)).data;
|
|
983
|
+
}
|
|
984
|
+
async changeSubscriptionPlan(e, t) {
|
|
985
|
+
if (!this.sessionManager)
|
|
986
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
987
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
988
|
+
return (await this.httpService.put(
|
|
989
|
+
`/subscriptions/${e}/plan`,
|
|
990
|
+
{ planId: t },
|
|
991
|
+
{ headers: r }
|
|
992
|
+
)).data;
|
|
993
|
+
}
|
|
994
|
+
// Public endpoint - no auth required
|
|
995
|
+
async getTenantSubscriptionFeatures(e) {
|
|
996
|
+
return (await this.httpService.get(
|
|
997
|
+
`/subscriptions/tenants/${e}/subscription-features`
|
|
998
|
+
)).data;
|
|
999
|
+
}
|
|
1000
|
+
async processPayment(e, t) {
|
|
1001
|
+
if (!this.sessionManager)
|
|
1002
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
1003
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
1004
|
+
return (await this.httpService.post(
|
|
1005
|
+
`/subscriptions/${e}/process-payment`,
|
|
1006
|
+
t,
|
|
1007
|
+
{ headers: r }
|
|
1008
|
+
)).data;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
const pe = te(void 0);
|
|
1012
|
+
function Xe({ config: n = {}, children: e }) {
|
|
1013
|
+
const { tenant: t, baseUrl: r } = G(), [s, o] = b(null), [T, M] = b(!1), [S, E] = b(null), w = N(() => {
|
|
1014
|
+
const f = new W(r);
|
|
1015
|
+
return new Pe(f);
|
|
1016
|
+
}, [r]), p = async () => {
|
|
1017
|
+
if (!(t != null && t.id)) {
|
|
1018
|
+
o(null);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
M(!0), E(null);
|
|
1022
|
+
try {
|
|
1023
|
+
const f = await w.getTenantSubscriptionFeatures(t.id);
|
|
1024
|
+
o(f);
|
|
1025
|
+
} catch (f) {
|
|
1026
|
+
const y = f instanceof Error ? f.message : "Failed to fetch subscription";
|
|
1027
|
+
E(y), n.onError && n.onError(f instanceof Error ? f : new Error(y));
|
|
1028
|
+
} finally {
|
|
1029
|
+
M(!1);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
K(() => {
|
|
1033
|
+
if (p(), !n.refreshInterval) return;
|
|
1034
|
+
const f = n.refreshInterval || 10 * 60 * 1e3, y = setInterval(p, f);
|
|
1035
|
+
return () => clearInterval(y);
|
|
1036
|
+
}, [t == null ? void 0 : t.id, n.refreshInterval]);
|
|
1037
|
+
const v = N(() => {
|
|
1038
|
+
const f = (s == null ? void 0 : s.features) || [];
|
|
1039
|
+
return {
|
|
1040
|
+
subscription: s,
|
|
1041
|
+
features: f,
|
|
1042
|
+
loading: T,
|
|
1043
|
+
error: S,
|
|
1044
|
+
isFeatureEnabled: (l) => {
|
|
1045
|
+
const a = f.find((u) => u.key === l);
|
|
1046
|
+
return a ? a.type === "BOOLEAN" || a.type === "boolean" ? a.value === !0 : !!a.value : !1;
|
|
1047
|
+
},
|
|
1048
|
+
getFeature: (l) => f.find((a) => a.key === l),
|
|
1049
|
+
getFeatureValue: (l, a) => {
|
|
1050
|
+
const u = f.find((k) => k.key === l);
|
|
1051
|
+
return u ? u.value : a;
|
|
1052
|
+
},
|
|
1053
|
+
hasAllowedPlan: (l) => !s || !s.isActive ? !1 : l.includes(s.planId),
|
|
1054
|
+
refresh: async () => {
|
|
1055
|
+
await p();
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
}, [s, T, S]);
|
|
1059
|
+
return /* @__PURE__ */ i(pe.Provider, { value: v, children: e });
|
|
1060
|
+
}
|
|
1061
|
+
function Te() {
|
|
1062
|
+
const n = re(pe);
|
|
1063
|
+
if (n === void 0)
|
|
1064
|
+
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1065
|
+
return n;
|
|
1066
|
+
}
|
|
1067
|
+
const fe = te(null);
|
|
1068
|
+
function Ze({ children: n }) {
|
|
1069
|
+
const { baseUrl: e, tenant: t, appInfo: r } = G(), { sessionManager: s } = ee(), [o, T] = b(null), [M, S] = b(!1), [E, w] = b(null), p = (r == null ? void 0 : r.settingsSchema) || null, v = X(async () => {
|
|
1070
|
+
if (t != null && t.id)
|
|
1071
|
+
try {
|
|
1072
|
+
S(!0), w(null);
|
|
1073
|
+
const x = new W(e), l = await new ne(x, t.appId).getTenantSettings(t.id);
|
|
1074
|
+
T(l);
|
|
1075
|
+
} catch (x) {
|
|
1076
|
+
const d = x instanceof Error ? x : new Error("Failed to load tenant settings");
|
|
1077
|
+
w(d), T(null);
|
|
1078
|
+
} finally {
|
|
1079
|
+
S(!1);
|
|
1080
|
+
}
|
|
1081
|
+
}, [e, t]), f = X(
|
|
1082
|
+
async (x) => {
|
|
1083
|
+
if (!(t != null && t.id) || !s)
|
|
1084
|
+
throw new Error("Tenant ID and authentication required to update settings");
|
|
1085
|
+
try {
|
|
1086
|
+
S(!0), w(null);
|
|
1087
|
+
const d = new W(e), l = new ne(d, t.appId, s), a = { settings: x }, u = await l.updateTenantSettings(t.id, a);
|
|
1088
|
+
T(u);
|
|
1089
|
+
} catch (d) {
|
|
1090
|
+
const l = d instanceof Error ? d : new Error("Failed to update tenant settings");
|
|
1091
|
+
throw w(l), l;
|
|
1092
|
+
} finally {
|
|
1093
|
+
S(!1);
|
|
1094
|
+
}
|
|
1095
|
+
},
|
|
1096
|
+
[e, t, s]
|
|
1097
|
+
), y = X(() => {
|
|
1098
|
+
v();
|
|
1099
|
+
}, [v]), c = X(
|
|
1100
|
+
(x) => {
|
|
1101
|
+
if (!p)
|
|
1102
|
+
return { isValid: !0, errors: [] };
|
|
1103
|
+
const d = [];
|
|
1104
|
+
try {
|
|
1105
|
+
return p.properties && Object.entries(p.properties).forEach(([l, a]) => {
|
|
1106
|
+
var k;
|
|
1107
|
+
const u = x[l];
|
|
1108
|
+
if ((k = p.required) != null && k.includes(l) && u == null) {
|
|
1109
|
+
d.push(`Field '${l}' is required`);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (u != null) {
|
|
1113
|
+
if (a.type) {
|
|
1114
|
+
const F = a.type, m = typeof u;
|
|
1115
|
+
F === "string" && m !== "string" ? d.push(`Field '${l}' must be a string`) : (F === "number" || F === "integer") && m !== "number" ? d.push(`Field '${l}' must be a number`) : F === "boolean" && m !== "boolean" ? d.push(`Field '${l}' must be a boolean`) : F === "array" && !Array.isArray(u) && d.push(`Field '${l}' must be an array`);
|
|
1116
|
+
}
|
|
1117
|
+
a.minLength !== void 0 && typeof u == "string" && u.length < a.minLength && d.push(
|
|
1118
|
+
`Field '${l}' must be at least ${a.minLength} characters long`
|
|
1119
|
+
), a.maxLength !== void 0 && typeof u == "string" && u.length > a.maxLength && d.push(
|
|
1120
|
+
`Field '${l}' must be no more than ${a.maxLength} characters long`
|
|
1121
|
+
), a.minimum !== void 0 && typeof u == "number" && u < a.minimum && d.push(`Field '${l}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof u == "number" && u > a.maximum && d.push(`Field '${l}' must be no more than ${a.maximum}`), a.pattern && typeof u == "string" && (new RegExp(a.pattern).test(u) || d.push(`Field '${l}' does not match the required pattern`)), a.enum && !a.enum.includes(u) && d.push(`Field '${l}' must be one of: ${a.enum.join(", ")}`);
|
|
1122
|
+
}
|
|
1123
|
+
}), {
|
|
1124
|
+
isValid: d.length === 0,
|
|
1125
|
+
errors: d
|
|
1126
|
+
};
|
|
1127
|
+
} catch {
|
|
1128
|
+
return {
|
|
1129
|
+
isValid: !1,
|
|
1130
|
+
errors: ["Invalid settings schema or validation error"]
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
[p]
|
|
1135
|
+
);
|
|
1136
|
+
K(() => {
|
|
1137
|
+
t != null && t.id ? v() : (T(null), w(null), S(!1));
|
|
1138
|
+
}, [t == null ? void 0 : t.id, v]);
|
|
1139
|
+
const C = N(
|
|
1140
|
+
() => ({
|
|
1141
|
+
// Settings
|
|
1142
|
+
settings: o,
|
|
1143
|
+
settingsSchema: p,
|
|
1144
|
+
isSettingsLoading: M,
|
|
1145
|
+
settingsError: E,
|
|
1146
|
+
// Actions
|
|
1147
|
+
updateSettings: f,
|
|
1148
|
+
refreshSettings: y,
|
|
1149
|
+
// Validation
|
|
1150
|
+
validateSettings: c
|
|
1151
|
+
}),
|
|
1152
|
+
[
|
|
1153
|
+
o,
|
|
1154
|
+
p,
|
|
1155
|
+
M,
|
|
1156
|
+
E,
|
|
1157
|
+
f,
|
|
1158
|
+
y,
|
|
1159
|
+
c
|
|
1160
|
+
]
|
|
1161
|
+
);
|
|
1162
|
+
return /* @__PURE__ */ i(fe.Provider, { value: C, children: n });
|
|
1163
|
+
}
|
|
1164
|
+
function ke() {
|
|
1165
|
+
const n = re(fe);
|
|
1166
|
+
if (!n)
|
|
1167
|
+
throw new Error("useTenantSettings must be used within a TenantProvider");
|
|
1168
|
+
return n;
|
|
1169
|
+
}
|
|
1170
|
+
function et() {
|
|
1171
|
+
const {
|
|
1172
|
+
settings: n,
|
|
1173
|
+
settingsSchema: e,
|
|
1174
|
+
isSettingsLoading: t,
|
|
1175
|
+
settingsError: r,
|
|
1176
|
+
updateSettings: s,
|
|
1177
|
+
validateSettings: o
|
|
1178
|
+
} = ke();
|
|
1179
|
+
return {
|
|
1180
|
+
settings: n,
|
|
1181
|
+
settingsSchema: e,
|
|
1182
|
+
isLoading: t,
|
|
1183
|
+
error: r,
|
|
1184
|
+
updateSettings: s,
|
|
1185
|
+
validateSettings: o
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
var Z = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(Z || {});
|
|
1189
|
+
const le = () => /* @__PURE__ */ g(
|
|
1190
|
+
"div",
|
|
1191
|
+
{
|
|
1192
|
+
style: {
|
|
1193
|
+
display: "flex",
|
|
1194
|
+
flexDirection: "column",
|
|
1195
|
+
justifyContent: "center",
|
|
1196
|
+
alignItems: "center",
|
|
1197
|
+
padding: "20px",
|
|
1198
|
+
backgroundColor: "#f8f9fa",
|
|
1199
|
+
border: "1px solid #dee2e6",
|
|
1200
|
+
borderRadius: "6px",
|
|
1201
|
+
textAlign: "center",
|
|
1202
|
+
margin: "20px 0"
|
|
1203
|
+
},
|
|
1204
|
+
children: [
|
|
1205
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1206
|
+
/* @__PURE__ */ i("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1207
|
+
/* @__PURE__ */ i("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1208
|
+
/* @__PURE__ */ i(
|
|
1209
|
+
"button",
|
|
1210
|
+
{
|
|
1211
|
+
style: {
|
|
1212
|
+
padding: "8px 16px",
|
|
1213
|
+
backgroundColor: "#007bff",
|
|
1214
|
+
color: "white",
|
|
1215
|
+
border: "none",
|
|
1216
|
+
borderRadius: "4px",
|
|
1217
|
+
cursor: "pointer",
|
|
1218
|
+
fontSize: "14px"
|
|
1219
|
+
},
|
|
1220
|
+
onClick: () => window.location.href = "/login",
|
|
1221
|
+
children: "Sign In"
|
|
1222
|
+
}
|
|
1223
|
+
)
|
|
1224
|
+
]
|
|
1225
|
+
}
|
|
1226
|
+
), ce = ({
|
|
1227
|
+
userType: n,
|
|
1228
|
+
minUserType: e,
|
|
1229
|
+
missingPermissions: t
|
|
1230
|
+
}) => /* @__PURE__ */ g(
|
|
1231
|
+
"div",
|
|
1232
|
+
{
|
|
1233
|
+
style: {
|
|
1234
|
+
display: "flex",
|
|
1235
|
+
flexDirection: "column",
|
|
1236
|
+
justifyContent: "center",
|
|
1237
|
+
alignItems: "center",
|
|
1238
|
+
padding: "20px",
|
|
1239
|
+
backgroundColor: "#fff3cd",
|
|
1240
|
+
border: "1px solid #ffeaa7",
|
|
1241
|
+
borderRadius: "6px",
|
|
1242
|
+
textAlign: "center",
|
|
1243
|
+
margin: "20px 0"
|
|
1244
|
+
},
|
|
1245
|
+
children: [
|
|
1246
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1247
|
+
/* @__PURE__ */ i("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1248
|
+
e && n ? /* @__PURE__ */ g(B, { children: [
|
|
1249
|
+
/* @__PURE__ */ g("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1250
|
+
"This content requires ",
|
|
1251
|
+
/* @__PURE__ */ i("strong", { children: e }),
|
|
1252
|
+
" access level or higher."
|
|
1253
|
+
] }),
|
|
1254
|
+
/* @__PURE__ */ g("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1255
|
+
"Your current access level: ",
|
|
1256
|
+
/* @__PURE__ */ i("strong", { children: n })
|
|
1257
|
+
] })
|
|
1258
|
+
] }) : /* @__PURE__ */ g(B, { children: [
|
|
1259
|
+
/* @__PURE__ */ i("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1260
|
+
t && t.length > 0 && /* @__PURE__ */ g("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1261
|
+
"Required permissions: ",
|
|
1262
|
+
/* @__PURE__ */ i("strong", { children: t.join(", ") })
|
|
1263
|
+
] })
|
|
1264
|
+
] })
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
), Me = (n, e) => {
|
|
1268
|
+
const t = {
|
|
1269
|
+
[Z.USER]: 1,
|
|
1270
|
+
[Z.TENANT_ADMIN]: 2,
|
|
1271
|
+
[Z.SUPERUSER]: 3
|
|
1272
|
+
};
|
|
1273
|
+
return t[n] >= t[e];
|
|
1274
|
+
};
|
|
1275
|
+
function tt({
|
|
1276
|
+
children: n,
|
|
1277
|
+
fallback: e,
|
|
1278
|
+
minUserType: t,
|
|
1279
|
+
requiredPermissions: r,
|
|
1280
|
+
requireAllPermissions: s = !1
|
|
1281
|
+
}) {
|
|
1282
|
+
const { hasValidSession: o, sessionManager: T, hasPermission: M, hasAnyPermission: S, hasAllPermissions: E } = ee();
|
|
1283
|
+
if (!o())
|
|
1284
|
+
return /* @__PURE__ */ i(B, { children: e || /* @__PURE__ */ i(le, {}) });
|
|
1285
|
+
const w = T.getUser();
|
|
1286
|
+
if (!w)
|
|
1287
|
+
return /* @__PURE__ */ i(B, { children: e || /* @__PURE__ */ i(le, {}) });
|
|
1288
|
+
if (t && !Me(w.userType, t))
|
|
1289
|
+
return /* @__PURE__ */ i(ce, { userType: w.userType, minUserType: t });
|
|
1290
|
+
if (r && r.length > 0 && !(s ? E(r) : S(r))) {
|
|
1291
|
+
const v = r.filter((f) => !M(f)).map((f) => typeof f == "string" ? f : f.name);
|
|
1292
|
+
return /* @__PURE__ */ i(ce, { missingPermissions: v });
|
|
1293
|
+
}
|
|
1294
|
+
return /* @__PURE__ */ i(B, { children: n });
|
|
1295
|
+
}
|
|
1296
|
+
const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
1297
|
+
"div",
|
|
1298
|
+
{
|
|
1299
|
+
style: {
|
|
1300
|
+
display: "flex",
|
|
1301
|
+
flexDirection: "column",
|
|
1302
|
+
justifyContent: "center",
|
|
1303
|
+
alignItems: "center",
|
|
1304
|
+
minHeight: "100vh",
|
|
1305
|
+
padding: "2rem",
|
|
1306
|
+
backgroundColor: "#f9fafb",
|
|
1307
|
+
textAlign: "center"
|
|
1308
|
+
},
|
|
1309
|
+
children: /* @__PURE__ */ g(
|
|
1310
|
+
"div",
|
|
1311
|
+
{
|
|
1312
|
+
style: {
|
|
1313
|
+
backgroundColor: "#ffffff",
|
|
1314
|
+
padding: "2rem",
|
|
1315
|
+
borderRadius: "8px",
|
|
1316
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
|
|
1317
|
+
maxWidth: "400px"
|
|
1318
|
+
},
|
|
1319
|
+
children: [
|
|
1320
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1321
|
+
/* @__PURE__ */ i("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1322
|
+
/* @__PURE__ */ i("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1323
|
+
/* @__PURE__ */ g("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1324
|
+
"Redirecting to ",
|
|
1325
|
+
n,
|
|
1326
|
+
"..."
|
|
1327
|
+
] })
|
|
1328
|
+
]
|
|
1329
|
+
}
|
|
1330
|
+
)
|
|
1331
|
+
}
|
|
1332
|
+
), de = ({
|
|
1333
|
+
userType: n,
|
|
1334
|
+
minUserType: e,
|
|
1335
|
+
missingPermissions: t
|
|
1336
|
+
}) => /* @__PURE__ */ i(
|
|
1337
|
+
"div",
|
|
1338
|
+
{
|
|
1339
|
+
style: {
|
|
1340
|
+
display: "flex",
|
|
1341
|
+
flexDirection: "column",
|
|
1342
|
+
justifyContent: "center",
|
|
1343
|
+
alignItems: "center",
|
|
1344
|
+
minHeight: "100vh",
|
|
1345
|
+
padding: "2rem",
|
|
1346
|
+
backgroundColor: "#f9fafb",
|
|
1347
|
+
textAlign: "center"
|
|
1348
|
+
},
|
|
1349
|
+
children: /* @__PURE__ */ g(
|
|
1350
|
+
"div",
|
|
1351
|
+
{
|
|
1352
|
+
style: {
|
|
1353
|
+
backgroundColor: "#ffffff",
|
|
1354
|
+
padding: "2rem",
|
|
1355
|
+
borderRadius: "8px",
|
|
1356
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
|
|
1357
|
+
maxWidth: "400px"
|
|
1358
|
+
},
|
|
1359
|
+
children: [
|
|
1360
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1361
|
+
/* @__PURE__ */ i("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1362
|
+
e && n ? /* @__PURE__ */ g(B, { children: [
|
|
1363
|
+
/* @__PURE__ */ g("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1364
|
+
"This page requires ",
|
|
1365
|
+
/* @__PURE__ */ i("strong", { children: e }),
|
|
1366
|
+
" access level or higher."
|
|
1367
|
+
] }),
|
|
1368
|
+
/* @__PURE__ */ g("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1369
|
+
"Your current access level: ",
|
|
1370
|
+
/* @__PURE__ */ i("strong", { children: n })
|
|
1371
|
+
] })
|
|
1372
|
+
] }) : /* @__PURE__ */ g(B, { children: [
|
|
1373
|
+
/* @__PURE__ */ i("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1374
|
+
t && t.length > 0 && /* @__PURE__ */ g("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1375
|
+
"Required permissions: ",
|
|
1376
|
+
/* @__PURE__ */ i("strong", { children: t.join(", ") })
|
|
1377
|
+
] })
|
|
1378
|
+
] })
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
)
|
|
1382
|
+
}
|
|
1383
|
+
), Re = (n, e) => {
|
|
1384
|
+
const t = {
|
|
1385
|
+
[Z.USER]: 1,
|
|
1386
|
+
[Z.TENANT_ADMIN]: 2,
|
|
1387
|
+
[Z.SUPERUSER]: 3
|
|
1388
|
+
};
|
|
1389
|
+
return t[n] >= t[e];
|
|
1390
|
+
};
|
|
1391
|
+
function rt({
|
|
1392
|
+
children: n,
|
|
1393
|
+
redirectTo: e = "/login",
|
|
1394
|
+
minUserType: t,
|
|
1395
|
+
requiredPermissions: r,
|
|
1396
|
+
requireAllPermissions: s = !1,
|
|
1397
|
+
fallback: o
|
|
1398
|
+
}) {
|
|
1399
|
+
const { hasValidSession: T, sessionManager: M, hasPermission: S, hasAnyPermission: E, hasAllPermissions: w } = ee(), p = we();
|
|
1400
|
+
if (!T())
|
|
1401
|
+
return o ? /* @__PURE__ */ i(B, { children: o }) : /* @__PURE__ */ g(B, { children: [
|
|
1402
|
+
/* @__PURE__ */ i(Ee, { redirectPath: e }),
|
|
1403
|
+
/* @__PURE__ */ i(ie, { to: e, state: { from: p.pathname }, replace: !0 })
|
|
1404
|
+
] });
|
|
1405
|
+
const v = M.getUser();
|
|
1406
|
+
if (!v)
|
|
1407
|
+
return /* @__PURE__ */ i(ie, { to: e, state: { from: p.pathname }, replace: !0 });
|
|
1408
|
+
if (t && !Re(v.userType, t))
|
|
1409
|
+
return /* @__PURE__ */ i(de, { userType: v.userType, minUserType: t });
|
|
1410
|
+
if (r && r.length > 0 && !(s ? w(r) : E(r))) {
|
|
1411
|
+
const y = r.filter((c) => !S(c)).map((c) => typeof c == "string" ? c : c.name);
|
|
1412
|
+
return /* @__PURE__ */ i(de, { missingPermissions: y });
|
|
1413
|
+
}
|
|
1414
|
+
return /* @__PURE__ */ i(B, { children: n });
|
|
1415
|
+
}
|
|
1416
|
+
const Fe = () => /* @__PURE__ */ g(
|
|
1417
|
+
"div",
|
|
1418
|
+
{
|
|
1419
|
+
style: {
|
|
1420
|
+
padding: "2rem",
|
|
1421
|
+
textAlign: "center",
|
|
1422
|
+
backgroundColor: "#fef2f2",
|
|
1423
|
+
border: "1px solid #fecaca",
|
|
1424
|
+
borderRadius: "8px",
|
|
1425
|
+
color: "#dc2626"
|
|
1426
|
+
},
|
|
1427
|
+
children: [
|
|
1428
|
+
/* @__PURE__ */ i("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1429
|
+
/* @__PURE__ */ i("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1430
|
+
]
|
|
1431
|
+
}
|
|
1432
|
+
);
|
|
1433
|
+
function st({
|
|
1434
|
+
children: n,
|
|
1435
|
+
fallback: e = /* @__PURE__ */ i(Fe, {}),
|
|
1436
|
+
allowedPlans: t,
|
|
1437
|
+
requiredFeature: r
|
|
1438
|
+
}) {
|
|
1439
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: T, loading: M } = Te();
|
|
1440
|
+
return M ? /* @__PURE__ */ i(
|
|
1441
|
+
"div",
|
|
1442
|
+
{
|
|
1443
|
+
style: {
|
|
1444
|
+
padding: "2rem",
|
|
1445
|
+
textAlign: "center",
|
|
1446
|
+
color: "#6b7280"
|
|
1447
|
+
},
|
|
1448
|
+
children: "Loading subscription..."
|
|
1449
|
+
}
|
|
1450
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ i(B, { children: e }) : r && !T(r) ? /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: n }) : /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: e });
|
|
1451
|
+
}
|
|
1452
|
+
const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
|
|
1453
|
+
"div",
|
|
1454
|
+
{
|
|
1455
|
+
style: {
|
|
1456
|
+
display: "flex",
|
|
1457
|
+
flexDirection: "column",
|
|
1458
|
+
justifyContent: "center",
|
|
1459
|
+
alignItems: "center",
|
|
1460
|
+
padding: "15px",
|
|
1461
|
+
backgroundColor: "#f8f9fa",
|
|
1462
|
+
border: "1px solid #dee2e6",
|
|
1463
|
+
borderRadius: "6px",
|
|
1464
|
+
textAlign: "center",
|
|
1465
|
+
fontFamily: "system-ui, sans-serif",
|
|
1466
|
+
color: "#6c757d"
|
|
1467
|
+
},
|
|
1468
|
+
children: [
|
|
1469
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1470
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1471
|
+
/* @__PURE__ */ g("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1472
|
+
'Feature flag "',
|
|
1473
|
+
n,
|
|
1474
|
+
'" is disabled'
|
|
1475
|
+
] })
|
|
1476
|
+
]
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
function nt({ name: n, children: e, fallback: t }) {
|
|
1480
|
+
const { isEnabled: r, loading: s } = Ae();
|
|
1481
|
+
return s ? /* @__PURE__ */ i(
|
|
1482
|
+
"div",
|
|
1483
|
+
{
|
|
1484
|
+
style: {
|
|
1485
|
+
display: "flex",
|
|
1486
|
+
justifyContent: "center",
|
|
1487
|
+
alignItems: "center",
|
|
1488
|
+
padding: "10px",
|
|
1489
|
+
color: "#6c757d",
|
|
1490
|
+
fontSize: "14px"
|
|
1491
|
+
},
|
|
1492
|
+
children: "Loading feature flags..."
|
|
1493
|
+
}
|
|
1494
|
+
) : (console.log(n, r(n)), r(n) ? /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: t || /* @__PURE__ */ i(Ie, { flagName: n }) }));
|
|
1495
|
+
}
|
|
1496
|
+
const He = () => /* @__PURE__ */ g(
|
|
1497
|
+
"svg",
|
|
1498
|
+
{
|
|
1499
|
+
width: "16",
|
|
1500
|
+
height: "16",
|
|
1501
|
+
viewBox: "0 0 24 24",
|
|
1502
|
+
fill: "none",
|
|
1503
|
+
stroke: "currentColor",
|
|
1504
|
+
strokeWidth: "2",
|
|
1505
|
+
strokeLinecap: "round",
|
|
1506
|
+
strokeLinejoin: "round",
|
|
1507
|
+
style: { flexShrink: 0 },
|
|
1508
|
+
children: [
|
|
1509
|
+
/* @__PURE__ */ i("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1510
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "3" })
|
|
1511
|
+
]
|
|
1512
|
+
}
|
|
1513
|
+
), $e = () => /* @__PURE__ */ g(
|
|
1514
|
+
"svg",
|
|
1515
|
+
{
|
|
1516
|
+
width: "16",
|
|
1517
|
+
height: "16",
|
|
1518
|
+
viewBox: "0 0 24 24",
|
|
1519
|
+
fill: "none",
|
|
1520
|
+
stroke: "currentColor",
|
|
1521
|
+
strokeWidth: "2",
|
|
1522
|
+
strokeLinecap: "round",
|
|
1523
|
+
strokeLinejoin: "round",
|
|
1524
|
+
style: { flexShrink: 0 },
|
|
1525
|
+
children: [
|
|
1526
|
+
/* @__PURE__ */ i("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1527
|
+
/* @__PURE__ */ i("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
), Ce = {
|
|
1531
|
+
showPassword: /* @__PURE__ */ i(He, {}),
|
|
1532
|
+
hidePassword: /* @__PURE__ */ i($e, {})
|
|
1533
|
+
}, Le = {
|
|
1534
|
+
title: "Sign In",
|
|
1535
|
+
emailLabel: "Email",
|
|
1536
|
+
emailPlaceholder: "Enter your email",
|
|
1537
|
+
passwordLabel: "Password",
|
|
1538
|
+
passwordPlaceholder: "Enter your password",
|
|
1539
|
+
submitButton: "Sign In",
|
|
1540
|
+
forgotPasswordLink: "Forgot your password?",
|
|
1541
|
+
signupLink: "Sign up here",
|
|
1542
|
+
signupText: "Don't have an account?",
|
|
1543
|
+
errorMessage: "Invalid email or password",
|
|
1544
|
+
loadingText: "Signing in..."
|
|
1545
|
+
}, De = {
|
|
1546
|
+
container: {
|
|
1547
|
+
maxWidth: "400px",
|
|
1548
|
+
width: "100%",
|
|
1549
|
+
margin: "0 auto",
|
|
1550
|
+
padding: "2rem",
|
|
1551
|
+
backgroundColor: "#ffffff",
|
|
1552
|
+
borderRadius: "8px",
|
|
1553
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
1554
|
+
},
|
|
1555
|
+
title: {
|
|
1556
|
+
fontSize: "1.5rem",
|
|
1557
|
+
fontWeight: "bold",
|
|
1558
|
+
textAlign: "center",
|
|
1559
|
+
marginBottom: "1.5rem",
|
|
1560
|
+
color: "#333333"
|
|
1561
|
+
},
|
|
1562
|
+
form: {
|
|
1563
|
+
display: "flex",
|
|
1564
|
+
flexDirection: "column",
|
|
1565
|
+
gap: "1rem"
|
|
1566
|
+
},
|
|
1567
|
+
fieldGroup: {
|
|
1568
|
+
display: "flex",
|
|
1569
|
+
flexDirection: "column",
|
|
1570
|
+
gap: "0.5rem"
|
|
1571
|
+
},
|
|
1572
|
+
label: {
|
|
1573
|
+
fontSize: "0.875rem",
|
|
1574
|
+
fontWeight: "500",
|
|
1575
|
+
color: "#374151"
|
|
1576
|
+
},
|
|
1577
|
+
input: {
|
|
1578
|
+
padding: "0.75rem",
|
|
1579
|
+
border: "1px solid #d1d5db",
|
|
1580
|
+
borderRadius: "6px",
|
|
1581
|
+
fontSize: "1rem",
|
|
1582
|
+
transition: "border-color 0.15s ease-in-out",
|
|
1583
|
+
outline: "none",
|
|
1584
|
+
width: "100%"
|
|
1585
|
+
},
|
|
1586
|
+
inputError: {
|
|
1587
|
+
borderColor: "#ef4444",
|
|
1588
|
+
boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
|
|
1589
|
+
},
|
|
1590
|
+
inputContainer: {
|
|
1591
|
+
position: "relative",
|
|
1592
|
+
display: "flex",
|
|
1593
|
+
alignItems: "center"
|
|
1594
|
+
},
|
|
1595
|
+
passwordToggle: {
|
|
1596
|
+
position: "absolute",
|
|
1597
|
+
right: "0.75rem",
|
|
1598
|
+
background: "none",
|
|
1599
|
+
border: "none",
|
|
1600
|
+
cursor: "pointer",
|
|
1601
|
+
padding: "0.25rem",
|
|
1602
|
+
color: "#6b7280",
|
|
1603
|
+
display: "flex",
|
|
1604
|
+
alignItems: "center",
|
|
1605
|
+
justifyContent: "center",
|
|
1606
|
+
width: "24px",
|
|
1607
|
+
height: "24px",
|
|
1608
|
+
borderRadius: "4px",
|
|
1609
|
+
transition: "background-color 0.15s ease-in-out"
|
|
1610
|
+
},
|
|
1611
|
+
button: {
|
|
1612
|
+
padding: "0.75rem 1rem",
|
|
1613
|
+
backgroundColor: "#3b82f6",
|
|
1614
|
+
color: "white",
|
|
1615
|
+
border: "none",
|
|
1616
|
+
borderRadius: "6px",
|
|
1617
|
+
fontSize: "1rem",
|
|
1618
|
+
fontWeight: "500",
|
|
1619
|
+
cursor: "pointer",
|
|
1620
|
+
transition: "background-color 0.15s ease-in-out",
|
|
1621
|
+
marginTop: "0.5rem"
|
|
1622
|
+
},
|
|
1623
|
+
buttonDisabled: {
|
|
1624
|
+
backgroundColor: "#9ca3af",
|
|
1625
|
+
cursor: "not-allowed"
|
|
1626
|
+
},
|
|
1627
|
+
buttonLoading: {
|
|
1628
|
+
backgroundColor: "#6b7280"
|
|
1629
|
+
},
|
|
1630
|
+
errorText: {
|
|
1631
|
+
color: "#ef4444",
|
|
1632
|
+
fontSize: "0.875rem",
|
|
1633
|
+
textAlign: "center",
|
|
1634
|
+
marginTop: "0.5rem"
|
|
1635
|
+
},
|
|
1636
|
+
linkContainer: {
|
|
1637
|
+
textAlign: "center",
|
|
1638
|
+
marginTop: "1rem"
|
|
1639
|
+
},
|
|
1640
|
+
link: {
|
|
1641
|
+
color: "#3b82f6",
|
|
1642
|
+
textDecoration: "none",
|
|
1643
|
+
fontSize: "0.875rem",
|
|
1644
|
+
cursor: "pointer"
|
|
1645
|
+
},
|
|
1646
|
+
divider: {
|
|
1647
|
+
margin: "0.5rem 0",
|
|
1648
|
+
color: "#6b7280",
|
|
1649
|
+
fontSize: "0.875rem"
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1652
|
+
function it({
|
|
1653
|
+
copy: n = {},
|
|
1654
|
+
styles: e = {},
|
|
1655
|
+
icons: t = {},
|
|
1656
|
+
onSuccess: r,
|
|
1657
|
+
onError: s,
|
|
1658
|
+
onForgotPassword: o,
|
|
1659
|
+
onSignupClick: T,
|
|
1660
|
+
showForgotPassword: M = !0,
|
|
1661
|
+
showSignupLink: S = !0,
|
|
1662
|
+
className: E
|
|
1663
|
+
}) {
|
|
1664
|
+
const [w, p] = b(""), [v, f] = b(""), [y, c] = b(!1), [C, x] = b(!1), [d, l] = b(""), [a, u] = b({}), { login: k } = ee(), { tenant: F } = G(), m = { ...Le, ...n }, R = { ...De, ...e }, U = { ...Ce, ...t }, I = () => {
|
|
1665
|
+
const L = {};
|
|
1666
|
+
return w.trim() || (L.email = !0), v.trim() || (L.password = !0), u(L), Object.keys(L).length === 0;
|
|
1667
|
+
}, h = async (L) => {
|
|
1668
|
+
if (L.preventDefault(), !!I()) {
|
|
1669
|
+
if (!(F != null && F.id)) {
|
|
1670
|
+
l("Tenant not found");
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
x(!0), l("");
|
|
1674
|
+
try {
|
|
1675
|
+
const z = await k(w, v, F.id);
|
|
1676
|
+
r == null || r(z);
|
|
1677
|
+
} catch (z) {
|
|
1678
|
+
const _ = z.message || m.errorMessage;
|
|
1679
|
+
l(_), s == null || s(_);
|
|
1680
|
+
} finally {
|
|
1681
|
+
x(!1);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
}, P = (L) => ({
|
|
1685
|
+
...R.input,
|
|
1686
|
+
...a[L] ? R.inputError : {}
|
|
1687
|
+
}), Y = () => ({
|
|
1688
|
+
...R.button,
|
|
1689
|
+
...C ? R.buttonLoading : {},
|
|
1690
|
+
...!w || !v || C ? R.buttonDisabled : {}
|
|
1691
|
+
});
|
|
1692
|
+
return /* @__PURE__ */ g("div", { className: E, style: R.container, children: [
|
|
1693
|
+
/* @__PURE__ */ i("h2", { style: R.title, children: m.title }),
|
|
1694
|
+
/* @__PURE__ */ g("form", { onSubmit: h, style: R.form, children: [
|
|
1695
|
+
/* @__PURE__ */ g("div", { style: R.fieldGroup, children: [
|
|
1696
|
+
/* @__PURE__ */ i("label", { style: R.label, children: m.emailLabel }),
|
|
1697
|
+
/* @__PURE__ */ i(
|
|
1698
|
+
"input",
|
|
1699
|
+
{
|
|
1700
|
+
id: "email",
|
|
1701
|
+
name: "email",
|
|
1702
|
+
type: "email",
|
|
1703
|
+
value: w,
|
|
1704
|
+
onChange: (L) => {
|
|
1705
|
+
p(L.target.value), a.email && u((z) => ({ ...z, email: !1 }));
|
|
1706
|
+
},
|
|
1707
|
+
placeholder: m.emailPlaceholder,
|
|
1708
|
+
style: P("email"),
|
|
1709
|
+
disabled: C
|
|
1710
|
+
}
|
|
1711
|
+
)
|
|
1712
|
+
] }),
|
|
1713
|
+
/* @__PURE__ */ g("div", { style: R.fieldGroup, children: [
|
|
1714
|
+
/* @__PURE__ */ i("label", { style: R.label, children: m.passwordLabel }),
|
|
1715
|
+
/* @__PURE__ */ g("div", { style: R.inputContainer, children: [
|
|
1716
|
+
/* @__PURE__ */ i(
|
|
1717
|
+
"input",
|
|
1718
|
+
{
|
|
1719
|
+
id: "password",
|
|
1720
|
+
name: "password",
|
|
1721
|
+
type: y ? "text" : "password",
|
|
1722
|
+
value: v,
|
|
1723
|
+
onChange: (L) => {
|
|
1724
|
+
f(L.target.value), a.password && u((z) => ({ ...z, password: !1 }));
|
|
1725
|
+
},
|
|
1726
|
+
placeholder: m.passwordPlaceholder,
|
|
1727
|
+
style: {
|
|
1728
|
+
...P("password"),
|
|
1729
|
+
paddingRight: "2.5rem"
|
|
1730
|
+
// Make room for the icon
|
|
1731
|
+
},
|
|
1732
|
+
disabled: C
|
|
1733
|
+
}
|
|
1734
|
+
),
|
|
1735
|
+
/* @__PURE__ */ i(
|
|
1736
|
+
"button",
|
|
1737
|
+
{
|
|
1738
|
+
type: "button",
|
|
1739
|
+
onClick: () => c(!y),
|
|
1740
|
+
style: R.passwordToggle,
|
|
1741
|
+
disabled: C,
|
|
1742
|
+
"aria-label": y ? "Hide password" : "Show password",
|
|
1743
|
+
children: y ? U.hidePassword : U.showPassword
|
|
1744
|
+
}
|
|
1745
|
+
)
|
|
1746
|
+
] })
|
|
1747
|
+
] }),
|
|
1748
|
+
/* @__PURE__ */ i("button", { type: "submit", disabled: !w || !v || C, style: Y(), children: C ? m.loadingText : m.submitButton }),
|
|
1749
|
+
d && /* @__PURE__ */ i("div", { style: R.errorText, children: d })
|
|
1750
|
+
] }),
|
|
1751
|
+
(M || S) && /* @__PURE__ */ g("div", { style: R.linkContainer, children: [
|
|
1752
|
+
M && /* @__PURE__ */ i("a", { onClick: o, style: R.link, children: m.forgotPasswordLink }),
|
|
1753
|
+
M && S && /* @__PURE__ */ i("div", { style: R.divider, children: "•" }),
|
|
1754
|
+
S && /* @__PURE__ */ g("div", { children: [
|
|
1755
|
+
/* @__PURE__ */ g("span", { style: R.divider, children: [
|
|
1756
|
+
m.signupText,
|
|
1757
|
+
" "
|
|
1758
|
+
] }),
|
|
1759
|
+
/* @__PURE__ */ i("a", { onClick: T, style: R.link, children: m.signupLink })
|
|
1760
|
+
] })
|
|
1761
|
+
] })
|
|
1762
|
+
] });
|
|
1763
|
+
}
|
|
1764
|
+
const Be = {
|
|
1765
|
+
title: "Create Account",
|
|
1766
|
+
nameLabel: "Full Name",
|
|
1767
|
+
namePlaceholder: "Enter your full name",
|
|
1768
|
+
emailLabel: "Email",
|
|
1769
|
+
emailPlaceholder: "Enter your email",
|
|
1770
|
+
passwordLabel: "Password",
|
|
1771
|
+
passwordPlaceholder: "Enter your password",
|
|
1772
|
+
confirmPasswordLabel: "Confirm Password",
|
|
1773
|
+
confirmPasswordPlaceholder: "Confirm your password",
|
|
1774
|
+
tenantNameLabel: "Organization Name",
|
|
1775
|
+
tenantNamePlaceholder: "Enter your organization name",
|
|
1776
|
+
submitButton: "Create Account",
|
|
1777
|
+
loginLink: "Sign in here",
|
|
1778
|
+
loginText: "Already have an account?",
|
|
1779
|
+
errorMessage: "Failed to create account",
|
|
1780
|
+
loadingText: "Creating account...",
|
|
1781
|
+
passwordMismatchError: "Passwords do not match",
|
|
1782
|
+
isAdminLabel: "Create new organization",
|
|
1783
|
+
isAdminDescription: "Check this if you want to create a new organization"
|
|
1784
|
+
}, qe = {
|
|
1785
|
+
container: {
|
|
1786
|
+
maxWidth: "400px",
|
|
1787
|
+
width: "100%",
|
|
1788
|
+
margin: "0 auto",
|
|
1789
|
+
padding: "2rem",
|
|
1790
|
+
backgroundColor: "#ffffff",
|
|
1791
|
+
borderRadius: "8px",
|
|
1792
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
1793
|
+
},
|
|
1794
|
+
title: {
|
|
1795
|
+
fontSize: "1.5rem",
|
|
1796
|
+
fontWeight: "bold",
|
|
1797
|
+
textAlign: "center",
|
|
1798
|
+
marginBottom: "1.5rem",
|
|
1799
|
+
color: "#333333"
|
|
1800
|
+
},
|
|
1801
|
+
form: {
|
|
1802
|
+
display: "flex",
|
|
1803
|
+
flexDirection: "column",
|
|
1804
|
+
gap: "1rem"
|
|
1805
|
+
},
|
|
1806
|
+
fieldGroup: {
|
|
1807
|
+
display: "flex",
|
|
1808
|
+
flexDirection: "column",
|
|
1809
|
+
gap: "0.5rem"
|
|
1810
|
+
},
|
|
1811
|
+
label: {
|
|
1812
|
+
fontSize: "0.875rem",
|
|
1813
|
+
fontWeight: "500",
|
|
1814
|
+
color: "#374151"
|
|
1815
|
+
},
|
|
1816
|
+
input: {
|
|
1817
|
+
padding: "0.75rem",
|
|
1818
|
+
border: "1px solid #d1d5db",
|
|
1819
|
+
borderRadius: "6px",
|
|
1820
|
+
fontSize: "1rem",
|
|
1821
|
+
transition: "border-color 0.15s ease-in-out",
|
|
1822
|
+
outline: "none"
|
|
1823
|
+
},
|
|
1824
|
+
inputError: {
|
|
1825
|
+
borderColor: "#ef4444",
|
|
1826
|
+
boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
|
|
1827
|
+
},
|
|
1828
|
+
checkbox: {
|
|
1829
|
+
marginRight: "0.5rem"
|
|
1830
|
+
},
|
|
1831
|
+
checkboxContainer: {
|
|
1832
|
+
display: "flex",
|
|
1833
|
+
alignItems: "flex-start",
|
|
1834
|
+
gap: "0.5rem",
|
|
1835
|
+
padding: "0.5rem 0"
|
|
1836
|
+
},
|
|
1837
|
+
checkboxLabel: {
|
|
1838
|
+
fontSize: "0.875rem",
|
|
1839
|
+
color: "#374151",
|
|
1840
|
+
lineHeight: "1.4"
|
|
1841
|
+
},
|
|
1842
|
+
button: {
|
|
1843
|
+
padding: "0.75rem 1rem",
|
|
1844
|
+
backgroundColor: "#10b981",
|
|
1845
|
+
color: "white",
|
|
1846
|
+
border: "none",
|
|
1847
|
+
borderRadius: "6px",
|
|
1848
|
+
fontSize: "1rem",
|
|
1849
|
+
fontWeight: "500",
|
|
1850
|
+
cursor: "pointer",
|
|
1851
|
+
transition: "background-color 0.15s ease-in-out",
|
|
1852
|
+
marginTop: "0.5rem"
|
|
1853
|
+
},
|
|
1854
|
+
buttonDisabled: {
|
|
1855
|
+
backgroundColor: "#9ca3af",
|
|
1856
|
+
cursor: "not-allowed"
|
|
1857
|
+
},
|
|
1858
|
+
buttonLoading: {
|
|
1859
|
+
backgroundColor: "#6b7280"
|
|
1860
|
+
},
|
|
1861
|
+
errorText: {
|
|
1862
|
+
color: "#ef4444",
|
|
1863
|
+
fontSize: "0.875rem",
|
|
1864
|
+
textAlign: "center",
|
|
1865
|
+
marginTop: "0.5rem"
|
|
1866
|
+
},
|
|
1867
|
+
linkContainer: {
|
|
1868
|
+
textAlign: "center",
|
|
1869
|
+
marginTop: "1rem"
|
|
1870
|
+
},
|
|
1871
|
+
link: {
|
|
1872
|
+
color: "#3b82f6",
|
|
1873
|
+
textDecoration: "none",
|
|
1874
|
+
fontSize: "0.875rem",
|
|
1875
|
+
cursor: "pointer"
|
|
1876
|
+
},
|
|
1877
|
+
divider: {
|
|
1878
|
+
margin: "0.5rem 0",
|
|
1879
|
+
color: "#6b7280",
|
|
1880
|
+
fontSize: "0.875rem"
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
function ot({
|
|
1884
|
+
copy: n = {},
|
|
1885
|
+
styles: e = {},
|
|
1886
|
+
signupType: t = "user",
|
|
1887
|
+
onSuccess: r,
|
|
1888
|
+
onError: s,
|
|
1889
|
+
onLoginClick: o,
|
|
1890
|
+
showLoginLink: T = !0,
|
|
1891
|
+
className: M
|
|
1892
|
+
}) {
|
|
1893
|
+
const [S, E] = b(""), [w, p] = b(""), [v, f] = b(""), [y, c] = b(""), [C, x] = b(""), [d, l] = b(!1), [a, u] = b(""), [k, F] = b({}), { signup: m, signupTenantAdmin: R } = ee(), { tenant: U } = G(), I = { ...Be, ...n }, h = { ...qe, ...e }, P = () => {
|
|
1894
|
+
const H = {};
|
|
1895
|
+
return S.trim() || (H.name = !0), w.trim() || (H.email = !0), v.trim() || (H.password = !0), y.trim() || (H.confirmPassword = !0), t === "tenant" && !C.trim() && (H.tenantName = !0), F(H), Object.keys(H).length === 0;
|
|
1896
|
+
}, Y = async (H) => {
|
|
1897
|
+
if (H.preventDefault(), !!P()) {
|
|
1898
|
+
if (v !== y) {
|
|
1899
|
+
u(I.passwordMismatchError), F({ confirmPassword: !0 });
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if (t === "user" && !(U != null && U.id)) {
|
|
1903
|
+
u("Tenant not found");
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
l(!0), u("");
|
|
1907
|
+
try {
|
|
1908
|
+
let q;
|
|
1909
|
+
t === "tenant" ? q = await R(w, S, v, C) : q = await m(w, S, v, U.id), r == null || r(q);
|
|
1910
|
+
} catch (q) {
|
|
1911
|
+
const Q = q.message || I.errorMessage;
|
|
1912
|
+
u(Q), s == null || s(Q);
|
|
1913
|
+
} finally {
|
|
1914
|
+
l(!1);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}, L = (H) => ({
|
|
1918
|
+
...h.input,
|
|
1919
|
+
...k[H] ? h.inputError : {}
|
|
1920
|
+
}), z = () => ({
|
|
1921
|
+
...h.button,
|
|
1922
|
+
...d ? h.buttonLoading : {},
|
|
1923
|
+
...!S || !w || !v || !y || d || t === "tenant" && !C ? h.buttonDisabled : {}
|
|
1924
|
+
}), _ = S && w && v && y && (t === "user" || C);
|
|
1925
|
+
return /* @__PURE__ */ g("div", { className: M, style: h.container, children: [
|
|
1926
|
+
/* @__PURE__ */ i("h2", { style: h.title, children: I.title }),
|
|
1927
|
+
/* @__PURE__ */ g("form", { onSubmit: Y, style: h.form, children: [
|
|
1928
|
+
/* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
|
|
1929
|
+
/* @__PURE__ */ i("label", { style: h.label, children: I.nameLabel }),
|
|
1930
|
+
/* @__PURE__ */ i(
|
|
1931
|
+
"input",
|
|
1932
|
+
{
|
|
1933
|
+
id: "name",
|
|
1934
|
+
name: "name",
|
|
1935
|
+
type: "text",
|
|
1936
|
+
value: S,
|
|
1937
|
+
onChange: (H) => {
|
|
1938
|
+
E(H.target.value), k.name && F((q) => ({ ...q, name: !1 }));
|
|
1939
|
+
},
|
|
1940
|
+
placeholder: I.namePlaceholder,
|
|
1941
|
+
style: L("name"),
|
|
1942
|
+
disabled: d
|
|
1943
|
+
}
|
|
1944
|
+
)
|
|
1945
|
+
] }),
|
|
1946
|
+
/* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
|
|
1947
|
+
/* @__PURE__ */ i("label", { style: h.label, children: I.emailLabel }),
|
|
1948
|
+
/* @__PURE__ */ i(
|
|
1949
|
+
"input",
|
|
1950
|
+
{
|
|
1951
|
+
id: "email",
|
|
1952
|
+
name: "email",
|
|
1953
|
+
type: "email",
|
|
1954
|
+
value: w,
|
|
1955
|
+
onChange: (H) => {
|
|
1956
|
+
p(H.target.value), k.email && F((q) => ({ ...q, email: !1 }));
|
|
1957
|
+
},
|
|
1958
|
+
placeholder: I.emailPlaceholder,
|
|
1959
|
+
style: L("email"),
|
|
1960
|
+
disabled: d
|
|
1961
|
+
}
|
|
1962
|
+
)
|
|
1963
|
+
] }),
|
|
1964
|
+
/* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
|
|
1965
|
+
/* @__PURE__ */ i("label", { style: h.label, children: I.passwordLabel }),
|
|
1966
|
+
/* @__PURE__ */ i(
|
|
1967
|
+
"input",
|
|
1968
|
+
{
|
|
1969
|
+
id: "password",
|
|
1970
|
+
name: "password",
|
|
1971
|
+
type: "password",
|
|
1972
|
+
value: v,
|
|
1973
|
+
onChange: (H) => {
|
|
1974
|
+
f(H.target.value), k.password && F((q) => ({ ...q, password: !1 }));
|
|
1975
|
+
},
|
|
1976
|
+
placeholder: I.passwordPlaceholder,
|
|
1977
|
+
style: L("password"),
|
|
1978
|
+
disabled: d
|
|
1979
|
+
}
|
|
1980
|
+
)
|
|
1981
|
+
] }),
|
|
1982
|
+
/* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
|
|
1983
|
+
/* @__PURE__ */ i("label", { style: h.label, children: I.confirmPasswordLabel }),
|
|
1984
|
+
/* @__PURE__ */ i(
|
|
1985
|
+
"input",
|
|
1986
|
+
{
|
|
1987
|
+
id: "confirmPassword",
|
|
1988
|
+
name: "confirmPassword",
|
|
1989
|
+
type: "password",
|
|
1990
|
+
value: y,
|
|
1991
|
+
onChange: (H) => {
|
|
1992
|
+
c(H.target.value), k.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), a === I.passwordMismatchError && u("");
|
|
1993
|
+
},
|
|
1994
|
+
placeholder: I.confirmPasswordPlaceholder,
|
|
1995
|
+
style: L("confirmPassword"),
|
|
1996
|
+
disabled: d
|
|
1997
|
+
}
|
|
1998
|
+
)
|
|
1999
|
+
] }),
|
|
2000
|
+
t === "tenant" && /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
|
|
2001
|
+
/* @__PURE__ */ i("label", { style: h.label, children: I.tenantNameLabel }),
|
|
2002
|
+
/* @__PURE__ */ i(
|
|
2003
|
+
"input",
|
|
2004
|
+
{
|
|
2005
|
+
id: "tenantName",
|
|
2006
|
+
name: "tenantName",
|
|
2007
|
+
type: "text",
|
|
2008
|
+
value: C,
|
|
2009
|
+
onChange: (H) => {
|
|
2010
|
+
x(H.target.value), k.tenantName && F((q) => ({ ...q, tenantName: !1 }));
|
|
2011
|
+
},
|
|
2012
|
+
placeholder: I.tenantNamePlaceholder,
|
|
2013
|
+
style: L("tenantName"),
|
|
2014
|
+
disabled: d
|
|
2015
|
+
}
|
|
2016
|
+
)
|
|
2017
|
+
] }),
|
|
2018
|
+
/* @__PURE__ */ i("button", { type: "submit", disabled: !_ || d, style: z(), children: d ? I.loadingText : I.submitButton }),
|
|
2019
|
+
a && /* @__PURE__ */ i("div", { style: h.errorText, children: a })
|
|
2020
|
+
] }),
|
|
2021
|
+
T && /* @__PURE__ */ g("div", { style: h.linkContainer, children: [
|
|
2022
|
+
/* @__PURE__ */ g("span", { style: h.divider, children: [
|
|
2023
|
+
I.loginText,
|
|
2024
|
+
" "
|
|
2025
|
+
] }),
|
|
2026
|
+
/* @__PURE__ */ i("a", { onClick: o, style: h.link, children: I.loginLink })
|
|
2027
|
+
] })
|
|
2028
|
+
] });
|
|
2029
|
+
}
|
|
2030
|
+
const Ue = {
|
|
2031
|
+
title: "Reset Password",
|
|
2032
|
+
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2033
|
+
emailLabel: "Email",
|
|
2034
|
+
emailPlaceholder: "Enter your email",
|
|
2035
|
+
submitButton: "Send Reset Link",
|
|
2036
|
+
backToLoginLink: "Back to Sign In",
|
|
2037
|
+
successMessage: "Password reset link sent! Check your email.",
|
|
2038
|
+
errorMessage: "Failed to send reset link",
|
|
2039
|
+
loadingText: "Sending...",
|
|
2040
|
+
resetTitle: "Set New Password",
|
|
2041
|
+
resetSubtitle: "Enter your reset token and new password.",
|
|
2042
|
+
tokenLabel: "Reset Token",
|
|
2043
|
+
tokenPlaceholder: "Enter reset token from email",
|
|
2044
|
+
newPasswordLabel: "New Password",
|
|
2045
|
+
newPasswordPlaceholder: "Enter new password",
|
|
2046
|
+
confirmPasswordLabel: "Confirm Password",
|
|
2047
|
+
confirmPasswordPlaceholder: "Confirm new password",
|
|
2048
|
+
resetSubmitButton: "Reset Password",
|
|
2049
|
+
resetLoadingText: "Resetting...",
|
|
2050
|
+
resetSuccessMessage: "Password reset successfully!",
|
|
2051
|
+
passwordMismatchError: "Passwords do not match"
|
|
2052
|
+
}, Ne = {
|
|
2053
|
+
container: {
|
|
2054
|
+
maxWidth: "400px",
|
|
2055
|
+
margin: "0 auto",
|
|
2056
|
+
padding: "2rem",
|
|
2057
|
+
backgroundColor: "#ffffff",
|
|
2058
|
+
borderRadius: "8px",
|
|
2059
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
2060
|
+
},
|
|
2061
|
+
title: {
|
|
2062
|
+
fontSize: "1.5rem",
|
|
2063
|
+
fontWeight: "bold",
|
|
2064
|
+
textAlign: "center",
|
|
2065
|
+
marginBottom: "0.5rem",
|
|
2066
|
+
color: "#333333"
|
|
2067
|
+
},
|
|
2068
|
+
subtitle: {
|
|
2069
|
+
fontSize: "0.875rem",
|
|
2070
|
+
textAlign: "center",
|
|
2071
|
+
marginBottom: "1.5rem",
|
|
2072
|
+
color: "#6b7280",
|
|
2073
|
+
lineHeight: "1.4"
|
|
2074
|
+
},
|
|
2075
|
+
form: {
|
|
2076
|
+
display: "flex",
|
|
2077
|
+
flexDirection: "column",
|
|
2078
|
+
gap: "1rem"
|
|
2079
|
+
},
|
|
2080
|
+
fieldGroup: {
|
|
2081
|
+
display: "flex",
|
|
2082
|
+
flexDirection: "column",
|
|
2083
|
+
gap: "0.5rem"
|
|
2084
|
+
},
|
|
2085
|
+
label: {
|
|
2086
|
+
fontSize: "0.875rem",
|
|
2087
|
+
fontWeight: "500",
|
|
2088
|
+
color: "#374151"
|
|
2089
|
+
},
|
|
2090
|
+
input: {
|
|
2091
|
+
padding: "0.75rem",
|
|
2092
|
+
border: "1px solid #d1d5db",
|
|
2093
|
+
borderRadius: "6px",
|
|
2094
|
+
fontSize: "1rem",
|
|
2095
|
+
transition: "border-color 0.15s ease-in-out",
|
|
2096
|
+
outline: "none"
|
|
2097
|
+
},
|
|
2098
|
+
inputError: {
|
|
2099
|
+
borderColor: "#ef4444",
|
|
2100
|
+
boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
|
|
2101
|
+
},
|
|
2102
|
+
button: {
|
|
2103
|
+
padding: "0.75rem 1rem",
|
|
2104
|
+
backgroundColor: "#f59e0b",
|
|
2105
|
+
color: "white",
|
|
2106
|
+
border: "none",
|
|
2107
|
+
borderRadius: "6px",
|
|
2108
|
+
fontSize: "1rem",
|
|
2109
|
+
fontWeight: "500",
|
|
2110
|
+
cursor: "pointer",
|
|
2111
|
+
transition: "background-color 0.15s ease-in-out",
|
|
2112
|
+
marginTop: "0.5rem"
|
|
2113
|
+
},
|
|
2114
|
+
buttonDisabled: {
|
|
2115
|
+
backgroundColor: "#9ca3af",
|
|
2116
|
+
cursor: "not-allowed"
|
|
2117
|
+
},
|
|
2118
|
+
buttonLoading: {
|
|
2119
|
+
backgroundColor: "#6b7280"
|
|
2120
|
+
},
|
|
2121
|
+
errorText: {
|
|
2122
|
+
color: "#ef4444",
|
|
2123
|
+
fontSize: "0.875rem",
|
|
2124
|
+
textAlign: "center",
|
|
2125
|
+
marginTop: "0.5rem"
|
|
2126
|
+
},
|
|
2127
|
+
successText: {
|
|
2128
|
+
color: "#10b981",
|
|
2129
|
+
fontSize: "0.875rem",
|
|
2130
|
+
textAlign: "center",
|
|
2131
|
+
marginTop: "0.5rem"
|
|
2132
|
+
},
|
|
2133
|
+
linkContainer: {
|
|
2134
|
+
textAlign: "center",
|
|
2135
|
+
marginTop: "1rem"
|
|
2136
|
+
},
|
|
2137
|
+
link: {
|
|
2138
|
+
color: "#3b82f6",
|
|
2139
|
+
textDecoration: "none",
|
|
2140
|
+
fontSize: "0.875rem",
|
|
2141
|
+
cursor: "pointer"
|
|
2142
|
+
}
|
|
2143
|
+
};
|
|
2144
|
+
function at({
|
|
2145
|
+
copy: n = {},
|
|
2146
|
+
styles: e = {},
|
|
2147
|
+
mode: t = "request",
|
|
2148
|
+
token: r = "",
|
|
2149
|
+
onSuccess: s,
|
|
2150
|
+
onError: o,
|
|
2151
|
+
onBackToLogin: T,
|
|
2152
|
+
onModeChange: M,
|
|
2153
|
+
className: S
|
|
2154
|
+
}) {
|
|
2155
|
+
const [E, w] = b(""), [p, v] = b(r), [f, y] = b(""), [c, C] = b(""), [x, d] = b(!1), [l, a] = b(""), [u, k] = b(""), [F, m] = b({}), { requestPasswordReset: R, confirmPasswordReset: U } = ee(), { tenant: I } = G(), h = { ...Ue, ...n }, P = { ...Ne, ...e }, Y = () => {
|
|
2156
|
+
const D = {};
|
|
2157
|
+
return E.trim() || (D.email = !0), m(D), Object.keys(D).length === 0;
|
|
2158
|
+
}, L = () => {
|
|
2159
|
+
const D = {};
|
|
2160
|
+
return p.trim() || (D.token = !0), f.trim() || (D.newPassword = !0), c.trim() || (D.confirmPassword = !0), m(D), Object.keys(D).length === 0;
|
|
2161
|
+
}, z = async (D) => {
|
|
2162
|
+
if (D.preventDefault(), !!Y()) {
|
|
2163
|
+
if (!(I != null && I.id)) {
|
|
2164
|
+
a("Tenant not found");
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
d(!0), a(""), k("");
|
|
2168
|
+
try {
|
|
2169
|
+
await R(E, I.id), k(h.successMessage), s == null || s();
|
|
2170
|
+
} catch (j) {
|
|
2171
|
+
const O = j.message || h.errorMessage;
|
|
2172
|
+
a(O), o == null || o(O);
|
|
2173
|
+
} finally {
|
|
2174
|
+
d(!1);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
}, _ = async (D) => {
|
|
2178
|
+
if (D.preventDefault(), !!L()) {
|
|
2179
|
+
if (f !== c) {
|
|
2180
|
+
a(h.passwordMismatchError), m({ confirmPassword: !0 });
|
|
2181
|
+
return;
|
|
2182
|
+
}
|
|
2183
|
+
d(!0), a(""), k("");
|
|
2184
|
+
try {
|
|
2185
|
+
await U(p, f), k(h.resetSuccessMessage), s == null || s();
|
|
2186
|
+
} catch (j) {
|
|
2187
|
+
const O = j.message || h.errorMessage;
|
|
2188
|
+
a(O), o == null || o(O);
|
|
2189
|
+
} finally {
|
|
2190
|
+
d(!1);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}, H = (D) => ({
|
|
2194
|
+
...P.input,
|
|
2195
|
+
...F[D] ? P.inputError : {}
|
|
2196
|
+
}), q = () => ({
|
|
2197
|
+
...P.button,
|
|
2198
|
+
...x ? P.buttonLoading : {}
|
|
2199
|
+
});
|
|
2200
|
+
if (t === "reset") {
|
|
2201
|
+
const D = p && f && c;
|
|
2202
|
+
return /* @__PURE__ */ g("div", { className: S, style: P.container, children: [
|
|
2203
|
+
/* @__PURE__ */ i("h2", { style: P.title, children: h.resetTitle }),
|
|
2204
|
+
/* @__PURE__ */ i("p", { style: P.subtitle, children: h.resetSubtitle }),
|
|
2205
|
+
/* @__PURE__ */ g("form", { onSubmit: _, style: P.form, children: [
|
|
2206
|
+
/* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
|
|
2207
|
+
/* @__PURE__ */ i("label", { style: P.label, children: h.tokenLabel }),
|
|
2208
|
+
/* @__PURE__ */ i(
|
|
2209
|
+
"input",
|
|
2210
|
+
{
|
|
2211
|
+
type: "text",
|
|
2212
|
+
value: p,
|
|
2213
|
+
onChange: (j) => {
|
|
2214
|
+
v(j.target.value), F.token && m((O) => ({ ...O, token: !1 }));
|
|
2215
|
+
},
|
|
2216
|
+
placeholder: h.tokenPlaceholder,
|
|
2217
|
+
style: H("token"),
|
|
2218
|
+
disabled: x
|
|
2219
|
+
}
|
|
2220
|
+
)
|
|
2221
|
+
] }),
|
|
2222
|
+
/* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
|
|
2223
|
+
/* @__PURE__ */ i("label", { style: P.label, children: h.newPasswordLabel }),
|
|
2224
|
+
/* @__PURE__ */ i(
|
|
2225
|
+
"input",
|
|
2226
|
+
{
|
|
2227
|
+
type: "password",
|
|
2228
|
+
value: f,
|
|
2229
|
+
onChange: (j) => {
|
|
2230
|
+
y(j.target.value), F.newPassword && m((O) => ({ ...O, newPassword: !1 }));
|
|
2231
|
+
},
|
|
2232
|
+
placeholder: h.newPasswordPlaceholder,
|
|
2233
|
+
style: H("newPassword"),
|
|
2234
|
+
disabled: x
|
|
2235
|
+
}
|
|
2236
|
+
)
|
|
2237
|
+
] }),
|
|
2238
|
+
/* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
|
|
2239
|
+
/* @__PURE__ */ i("label", { style: P.label, children: h.confirmPasswordLabel }),
|
|
2240
|
+
/* @__PURE__ */ i(
|
|
2241
|
+
"input",
|
|
2242
|
+
{
|
|
2243
|
+
type: "password",
|
|
2244
|
+
value: c,
|
|
2245
|
+
onChange: (j) => {
|
|
2246
|
+
C(j.target.value), F.confirmPassword && m((O) => ({ ...O, confirmPassword: !1 })), l === h.passwordMismatchError && a("");
|
|
2247
|
+
},
|
|
2248
|
+
placeholder: h.confirmPasswordPlaceholder,
|
|
2249
|
+
style: H("confirmPassword"),
|
|
2250
|
+
disabled: x
|
|
2251
|
+
}
|
|
2252
|
+
)
|
|
2253
|
+
] }),
|
|
2254
|
+
/* @__PURE__ */ i(
|
|
2255
|
+
"button",
|
|
2256
|
+
{
|
|
2257
|
+
type: "submit",
|
|
2258
|
+
disabled: !D || x,
|
|
2259
|
+
style: {
|
|
2260
|
+
...q(),
|
|
2261
|
+
...!D || x ? P.buttonDisabled : {}
|
|
2262
|
+
},
|
|
2263
|
+
children: x ? h.resetLoadingText : h.resetSubmitButton
|
|
2264
|
+
}
|
|
2265
|
+
),
|
|
2266
|
+
l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
|
|
2267
|
+
u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
|
|
2268
|
+
] }),
|
|
2269
|
+
/* @__PURE__ */ g("div", { style: P.linkContainer, children: [
|
|
2270
|
+
/* @__PURE__ */ i("a", { onClick: T, style: P.link, children: h.backToLoginLink }),
|
|
2271
|
+
M && /* @__PURE__ */ g(B, { children: [
|
|
2272
|
+
/* @__PURE__ */ i("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2273
|
+
/* @__PURE__ */ i("a", { onClick: () => M("request"), style: P.link, children: "Request New Link" })
|
|
2274
|
+
] })
|
|
2275
|
+
] })
|
|
2276
|
+
] });
|
|
2277
|
+
}
|
|
2278
|
+
const Q = E;
|
|
2279
|
+
return /* @__PURE__ */ g("div", { className: S, style: P.container, children: [
|
|
2280
|
+
/* @__PURE__ */ i("h2", { style: P.title, children: h.title }),
|
|
2281
|
+
/* @__PURE__ */ i("p", { style: P.subtitle, children: h.subtitle }),
|
|
2282
|
+
/* @__PURE__ */ g("form", { onSubmit: z, style: P.form, children: [
|
|
2283
|
+
/* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
|
|
2284
|
+
/* @__PURE__ */ i("label", { style: P.label, children: h.emailLabel }),
|
|
2285
|
+
/* @__PURE__ */ i(
|
|
2286
|
+
"input",
|
|
2287
|
+
{
|
|
2288
|
+
type: "email",
|
|
2289
|
+
value: E,
|
|
2290
|
+
onChange: (D) => {
|
|
2291
|
+
w(D.target.value), F.email && m((j) => ({ ...j, email: !1 }));
|
|
2292
|
+
},
|
|
2293
|
+
placeholder: h.emailPlaceholder,
|
|
2294
|
+
style: H("email"),
|
|
2295
|
+
disabled: x
|
|
2296
|
+
}
|
|
2297
|
+
)
|
|
2298
|
+
] }),
|
|
2299
|
+
/* @__PURE__ */ i(
|
|
2300
|
+
"button",
|
|
2301
|
+
{
|
|
2302
|
+
type: "submit",
|
|
2303
|
+
disabled: !Q || x,
|
|
2304
|
+
style: {
|
|
2305
|
+
...q(),
|
|
2306
|
+
...!Q || x ? P.buttonDisabled : {}
|
|
2307
|
+
},
|
|
2308
|
+
children: x ? h.loadingText : h.submitButton
|
|
2309
|
+
}
|
|
2310
|
+
),
|
|
2311
|
+
l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
|
|
2312
|
+
u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
|
|
2313
|
+
] }),
|
|
2314
|
+
/* @__PURE__ */ g("div", { style: P.linkContainer, children: [
|
|
2315
|
+
/* @__PURE__ */ i("a", { onClick: T, style: P.link, children: h.backToLoginLink }),
|
|
2316
|
+
M && /* @__PURE__ */ g(B, { children: [
|
|
2317
|
+
/* @__PURE__ */ i("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2318
|
+
/* @__PURE__ */ i("a", { onClick: () => M("reset"), style: P.link, children: "I have a token" })
|
|
2319
|
+
] })
|
|
2320
|
+
] })
|
|
2321
|
+
] });
|
|
2322
|
+
}
|
|
2323
|
+
class lt {
|
|
2324
|
+
constructor(e, t) {
|
|
2325
|
+
this.httpService = e, this.sessionManager = t;
|
|
2326
|
+
}
|
|
2327
|
+
async createPermission(e) {
|
|
2328
|
+
if (!this.sessionManager)
|
|
2329
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
2330
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2331
|
+
return (await this.httpService.post(
|
|
2332
|
+
"/permissions/",
|
|
2333
|
+
e,
|
|
2334
|
+
{
|
|
2335
|
+
headers: t
|
|
2336
|
+
}
|
|
2337
|
+
)).data;
|
|
2338
|
+
}
|
|
2339
|
+
async getPermissions(e) {
|
|
2340
|
+
if (!this.sessionManager)
|
|
2341
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
2342
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2343
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
2344
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
2345
|
+
headers: t
|
|
2346
|
+
});
|
|
2347
|
+
return {
|
|
2348
|
+
permissions: o.data,
|
|
2349
|
+
meta: o.meta
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
async getPermissionById(e) {
|
|
2353
|
+
if (!this.sessionManager)
|
|
2354
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
2355
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2356
|
+
return (await this.httpService.get(`/permissions/${e}`, {
|
|
2357
|
+
headers: t
|
|
2358
|
+
})).data;
|
|
2359
|
+
}
|
|
2360
|
+
async updatePermission(e, t) {
|
|
2361
|
+
if (!this.sessionManager)
|
|
2362
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
2363
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
2364
|
+
return (await this.httpService.put(
|
|
2365
|
+
`/permissions/${e}`,
|
|
2366
|
+
t,
|
|
2367
|
+
{
|
|
2368
|
+
headers: r
|
|
2369
|
+
}
|
|
2370
|
+
)).data;
|
|
2371
|
+
}
|
|
2372
|
+
async deletePermission(e) {
|
|
2373
|
+
if (!this.sessionManager)
|
|
2374
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
2375
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2376
|
+
await this.httpService.delete(`/permissions/${e}`, {
|
|
2377
|
+
headers: t
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
// Public endpoint - no auth required
|
|
2381
|
+
async getAppPermissions(e, t) {
|
|
2382
|
+
const r = new URLSearchParams();
|
|
2383
|
+
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
2384
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
|
|
2385
|
+
return {
|
|
2386
|
+
permissions: o.data,
|
|
2387
|
+
meta: o.meta
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
class ct {
|
|
2392
|
+
constructor(e, t) {
|
|
2393
|
+
this.httpService = e, this.sessionManager = t;
|
|
2394
|
+
}
|
|
2395
|
+
async createSubscriptionPlan(e) {
|
|
2396
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2397
|
+
return (await this.httpService.post(
|
|
2398
|
+
"/subscription-plans/",
|
|
2399
|
+
e,
|
|
2400
|
+
{
|
|
2401
|
+
headers: t
|
|
2402
|
+
}
|
|
2403
|
+
)).data;
|
|
2404
|
+
}
|
|
2405
|
+
async getSubscriptionPlans(e) {
|
|
2406
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2407
|
+
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
|
|
2408
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
2409
|
+
headers: t
|
|
2410
|
+
});
|
|
2411
|
+
return {
|
|
2412
|
+
plans: o.data,
|
|
2413
|
+
meta: o.meta
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
async getSubscriptionPlanById(e) {
|
|
2417
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2418
|
+
return (await this.httpService.get(
|
|
2419
|
+
`/subscription-plans/${e}`,
|
|
2420
|
+
{
|
|
2421
|
+
headers: t
|
|
2422
|
+
}
|
|
2423
|
+
)).data;
|
|
2424
|
+
}
|
|
2425
|
+
async updateSubscriptionPlan(e, t) {
|
|
2426
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
2427
|
+
return (await this.httpService.put(
|
|
2428
|
+
`/subscription-plans/${e}`,
|
|
2429
|
+
t,
|
|
2430
|
+
{
|
|
2431
|
+
headers: r
|
|
2432
|
+
}
|
|
2433
|
+
)).data;
|
|
2434
|
+
}
|
|
2435
|
+
async deleteSubscriptionPlan(e) {
|
|
2436
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
2437
|
+
await this.httpService.delete(`/subscription-plans/${e}`, {
|
|
2438
|
+
headers: t
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
class dt {
|
|
2443
|
+
constructor(e) {
|
|
2444
|
+
this.httpService = e;
|
|
2445
|
+
}
|
|
2446
|
+
// Public endpoint - no auth required
|
|
2447
|
+
async checkHealth() {
|
|
2448
|
+
return await this.httpService.get("/health");
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
class ut {
|
|
2452
|
+
// Date string to Date object
|
|
2453
|
+
static toDate(e) {
|
|
2454
|
+
return new Date(e);
|
|
2455
|
+
}
|
|
2456
|
+
// Date object to ISO string
|
|
2457
|
+
static toISOString(e) {
|
|
2458
|
+
return e.toISOString();
|
|
2459
|
+
}
|
|
2460
|
+
// Transform API response pagination meta
|
|
2461
|
+
static transformPaginationMeta(e) {
|
|
2462
|
+
return {
|
|
2463
|
+
total: e.total || 0,
|
|
2464
|
+
page: e.page || 1,
|
|
2465
|
+
limit: e.limit || 100,
|
|
2466
|
+
totalPages: e.totalPages || 1,
|
|
2467
|
+
hasNext: e.hasNext || !1,
|
|
2468
|
+
hasPrev: e.hasPrev || !1
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
// Transform user data for display
|
|
2472
|
+
static transformUser(e) {
|
|
2473
|
+
return {
|
|
2474
|
+
...e,
|
|
2475
|
+
createdAt: this.toDate(e.createdAt),
|
|
2476
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2477
|
+
displayName: e.name,
|
|
2478
|
+
isActiveUser: e.isActive
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
// Transform role data for display
|
|
2482
|
+
static transformRole(e) {
|
|
2483
|
+
var t;
|
|
2484
|
+
return {
|
|
2485
|
+
...e,
|
|
2486
|
+
createdAt: this.toDate(e.createdAt),
|
|
2487
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2488
|
+
permissionCount: ((t = e.permissions) == null ? void 0 : t.length) || 0
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
// Transform tenant data for display
|
|
2492
|
+
static transformTenant(e) {
|
|
2493
|
+
return {
|
|
2494
|
+
...e,
|
|
2495
|
+
createdAt: this.toDate(e.createdAt),
|
|
2496
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2497
|
+
displayName: e.name,
|
|
2498
|
+
hasCustomDomain: !!e.domain
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
// Transform subscription data for display
|
|
2502
|
+
static transformSubscription(e) {
|
|
2503
|
+
return {
|
|
2504
|
+
...e,
|
|
2505
|
+
createdAt: this.toDate(e.createdAt),
|
|
2506
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2507
|
+
startDate: this.toDate(e.startDate),
|
|
2508
|
+
endDate: e.endDate ? this.toDate(e.endDate) : null,
|
|
2509
|
+
isActive: e.status === "ACTIVE",
|
|
2510
|
+
isExpired: e.endDate ? new Date(e.endDate) < /* @__PURE__ */ new Date() : !1
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
// Transform app data for display
|
|
2514
|
+
static transformApp(e) {
|
|
2515
|
+
return {
|
|
2516
|
+
...e,
|
|
2517
|
+
createdAt: this.toDate(e.createdAt),
|
|
2518
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2519
|
+
isAdminLevel: e.securityLevel === "ADMIN",
|
|
2520
|
+
hasDefaultPlan: !!e.defaultSubscriptionPlanId
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
// Transform feature flag data for display
|
|
2524
|
+
static transformFeatureFlag(e) {
|
|
2525
|
+
return {
|
|
2526
|
+
...e,
|
|
2527
|
+
createdAt: this.toDate(e.createdAt),
|
|
2528
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2529
|
+
isEnabled: e.isActive
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
// Transform permission data for display
|
|
2533
|
+
static transformPermission(e) {
|
|
2534
|
+
return {
|
|
2535
|
+
...e,
|
|
2536
|
+
createdAt: this.toDate(e.createdAt),
|
|
2537
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2538
|
+
fullName: `${e.resource}:${e.action}`,
|
|
2539
|
+
isSystemLevel: !e.appId
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
// Transform subscription plan data for display
|
|
2543
|
+
static transformSubscriptionPlan(e) {
|
|
2544
|
+
var t;
|
|
2545
|
+
return {
|
|
2546
|
+
...e,
|
|
2547
|
+
createdAt: this.toDate(e.createdAt),
|
|
2548
|
+
updatedAt: this.toDate(e.updatedAt),
|
|
2549
|
+
displayPrice: `${e.currency} ${e.price}`,
|
|
2550
|
+
isMonthly: e.billingCycle === "MONTHLY",
|
|
2551
|
+
featureCount: ((t = e.features) == null ? void 0 : t.length) || 0
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
// Transform error response
|
|
2555
|
+
static transformError(e) {
|
|
2556
|
+
var t;
|
|
2557
|
+
return {
|
|
2558
|
+
code: ((t = e.error) == null ? void 0 : t.code) || "UNKNOWN_ERROR",
|
|
2559
|
+
message: e.message || "An unexpected error occurred",
|
|
2560
|
+
type: e.type || "SYSTEM",
|
|
2561
|
+
isAuthError: e.type === "AUTH",
|
|
2562
|
+
isValidationError: e.type === "VALIDATION"
|
|
2563
|
+
};
|
|
2564
|
+
}
|
|
2565
|
+
// Transform query parameters for API calls
|
|
2566
|
+
static transformQueryParams(e) {
|
|
2567
|
+
const t = new URLSearchParams();
|
|
2568
|
+
return Object.entries(e).forEach(([r, s]) => {
|
|
2569
|
+
s != null && s !== "" && t.append(r, String(s));
|
|
2570
|
+
}), t;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
export {
|
|
2574
|
+
ut as ApiMappers,
|
|
2575
|
+
ye as AppApiService,
|
|
2576
|
+
_e as AppProvider,
|
|
2577
|
+
Se as AuthApiService,
|
|
2578
|
+
Qe as AuthProvider,
|
|
2579
|
+
nt as FeatureFlag,
|
|
2580
|
+
xe as FeatureFlagApiService,
|
|
2581
|
+
Je as FeatureFlagProvider,
|
|
2582
|
+
dt as HealthApiService,
|
|
2583
|
+
W as HttpService,
|
|
2584
|
+
it as LoginForm,
|
|
2585
|
+
at as PasswordRecoveryForm,
|
|
2586
|
+
lt as PermissionApiService,
|
|
2587
|
+
tt as Protected,
|
|
2588
|
+
rt as ProtectedRoute,
|
|
2589
|
+
ae as RoleApiService,
|
|
2590
|
+
be as SessionManager,
|
|
2591
|
+
ot as SignupForm,
|
|
2592
|
+
Pe as SubscriptionApiService,
|
|
2593
|
+
st as SubscriptionGuard,
|
|
2594
|
+
ct as SubscriptionPlanApiService,
|
|
2595
|
+
Xe as SubscriptionProvider,
|
|
2596
|
+
ne as TenantApiService,
|
|
2597
|
+
Ze as TenantProvider,
|
|
2598
|
+
ve as UserApiService,
|
|
2599
|
+
Z as UserType,
|
|
2600
|
+
Ke as useApi,
|
|
2601
|
+
G as useApp,
|
|
2602
|
+
ee as useAuth,
|
|
2603
|
+
Ae as useFeatureFlags,
|
|
2604
|
+
et as useSettings,
|
|
2605
|
+
Te as useSubscription,
|
|
2606
|
+
Ye as useTenant,
|
|
2607
|
+
ke as useTenantSettings
|
|
2608
|
+
};
|
|
2609
|
+
//# sourceMappingURL=index.es.js.map
|