@skylabs-digital/react-identity-access 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as 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 {
1
+ import { jsx as n, Fragment as U, jsxs as u } from "react/jsx-runtime";
2
+ import { createContext as te, useState as m, useMemo as z, useCallback as J, useEffect as K, useContext as re } from "react";
3
+ import { useLocation as me, Navigate as le } from "react-router";
4
+ class _ {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -15,41 +15,41 @@ class W {
15
15
  async request(e, t, r, s) {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
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 = {
18
+ async executeRequest(e, t, r, s, a = !1) {
19
+ const x = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, d = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let M = {
21
21
  "Content-Type": "application/json",
22
22
  ...s == null ? void 0 : s.headers
23
23
  };
24
24
  if (!(s != null && s.skipAuth) && this.sessionManager)
25
25
  try {
26
- const p = await this.sessionManager.getAuthHeaders();
27
- S = { ...S, ...p };
28
- } catch (p) {
29
- console.warn("Failed to inject auth headers:", p);
26
+ const h = await this.sessionManager.getAuthHeaders();
27
+ M = { ...M, ...h };
28
+ } catch (h) {
29
+ console.warn("Failed to inject auth headers:", h);
30
30
  }
31
- const E = new AbortController(), w = setTimeout(() => E.abort(), M);
31
+ const P = new AbortController(), g = setTimeout(() => P.abort(), d);
32
32
  try {
33
- const p = await fetch(T, {
33
+ const h = await fetch(x, {
34
34
  method: e,
35
- headers: S,
35
+ headers: M,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: E.signal
37
+ signal: P.signal
38
38
  });
39
- if (clearTimeout(w), p.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(g), h.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
- const f = this.sessionManager.getTokens();
42
- if (f != null && f.refreshToken)
41
+ const y = this.sessionManager.getTokens();
42
+ if (y != null && y.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${p.status}: ${p.statusText}`);
45
+ throw new Error(`HTTP ${h.status}: ${h.statusText}`);
46
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;
47
+ if (!h.ok)
48
+ throw new Error(`HTTP ${h.status}: ${h.statusText}`);
49
+ const b = h.headers.get("content-type");
50
+ return !b || !b.includes("application/json") ? {} : await h.json();
51
+ } catch (h) {
52
+ throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${d}ms`) : h;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,85 +65,7 @@ class W {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
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 {
68
+ class be {
147
69
  constructor(e, t) {
148
70
  this.httpService = e, this.sessionManager = t;
149
71
  }
@@ -156,12 +78,12 @@ class ye {
156
78
  async getApps(e) {
157
79
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
158
80
  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, {
81
+ const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
160
82
  headers: t
161
83
  });
162
84
  return {
163
- apps: o.data,
164
- meta: o.meta
85
+ apps: a.data,
86
+ meta: a.meta
165
87
  };
166
88
  }
167
89
  async getAppById(e) {
@@ -202,7 +124,7 @@ class ye {
202
124
  })).data;
203
125
  }
204
126
  }
205
- const ue = te(null), me = () => /* @__PURE__ */ i(
127
+ const ge = te(null), Se = () => /* @__PURE__ */ n(
206
128
  "div",
207
129
  {
208
130
  style: {
@@ -212,9 +134,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
212
134
  height: "100vh",
213
135
  fontFamily: "system-ui, sans-serif"
214
136
  },
215
- children: /* @__PURE__ */ i("div", { children: "Loading application..." })
137
+ children: /* @__PURE__ */ n("div", { children: "Loading application..." })
216
138
  }
217
- ), oe = ({ error: n, retry: e }) => /* @__PURE__ */ g(
139
+ ), ve = ({ error: i, retry: e }) => /* @__PURE__ */ u(
218
140
  "div",
219
141
  {
220
142
  style: {
@@ -228,9 +150,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
228
150
  padding: "20px"
229
151
  },
230
152
  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(
153
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
154
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
155
+ /* @__PURE__ */ n(
234
156
  "button",
235
157
  {
236
158
  onClick: e,
@@ -248,113 +170,50 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
248
170
  ]
249
171
  }
250
172
  );
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();
173
+ function Je({ config: i, children: e }) {
174
+ const [t, r] = m(null), [s, a] = m(!0), [x, d] = m(null), M = z(() => {
175
+ const g = () => {
176
+ P();
273
177
  };
274
178
  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,
179
+ appId: i.appId,
180
+ baseUrl: i.baseUrl,
283
181
  // App info
284
- appInfo: S,
285
- isAppLoading: w,
286
- appError: v,
287
- retryApp: a
182
+ appInfo: t,
183
+ isAppLoading: s,
184
+ appError: x,
185
+ retryApp: g
288
186
  };
289
- }, [n, t, c, s, T, S, w, v]), x = X(async () => {
187
+ }, [i, t, s, x]), P = J(async () => {
290
188
  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);
189
+ a(!0), d(null);
190
+ const g = new _(i.baseUrl), b = await new be(g, {}).getPublicAppInfo(i.appId);
191
+ r(b);
192
+ } catch (g) {
193
+ const h = g instanceof Error ? g : new Error("Failed to load app information");
194
+ d(h), r(null);
297
195
  } finally {
298
- p(!1);
196
+ a(!1);
299
197
  }
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
- );
198
+ }, [i.baseUrl, i.appId]);
315
199
  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 });
200
+ P();
201
+ }, [P]), s)
202
+ return /* @__PURE__ */ n(U, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
203
+ if (x) {
204
+ const g = typeof i.errorFallback == "function" ? i.errorFallback(x, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: x, retry: () => P() });
205
+ return /* @__PURE__ */ n(U, { children: g });
206
+ }
207
+ return /* @__PURE__ */ n(ge.Provider, { value: M, children: e });
339
208
  }
340
- function G() {
341
- const n = re(ue);
342
- if (!n)
209
+ function se() {
210
+ const i = re(ge);
211
+ if (!i)
343
212
  throw new Error("useApp must be used within an AppProvider");
344
- return n;
213
+ return i;
345
214
  }
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 {
215
+ const Xe = se;
216
+ class xe {
358
217
  constructor(e = {}) {
359
218
  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
219
  get: () => {
@@ -471,7 +330,7 @@ class be {
471
330
  return e !== null && !this.isTokenExpired(e);
472
331
  }
473
332
  }
474
- class Se {
333
+ class Ae {
475
334
  constructor(e) {
476
335
  this.httpService = e;
477
336
  }
@@ -505,7 +364,7 @@ class Se {
505
364
  });
506
365
  }
507
366
  }
508
- class ae {
367
+ class ce {
509
368
  constructor(e, t) {
510
369
  this.httpService = e, this.sessionManager = t;
511
370
  }
@@ -545,10 +404,10 @@ class ae {
545
404
  async getRolesByApp(e, t) {
546
405
  const r = new URLSearchParams();
547
406
  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);
407
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
549
408
  return {
550
- roles: o.data,
551
- meta: o.meta
409
+ roles: a.data,
410
+ meta: a.meta
552
411
  };
553
412
  }
554
413
  async assignRole(e, t) {
@@ -572,16 +431,16 @@ class ae {
572
431
  throw new Error("SessionManager is required for private endpoints");
573
432
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
574
433
  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, {
434
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, x = await this.httpService.get(a, {
576
435
  headers: r
577
436
  });
578
437
  return {
579
- roles: T.data,
580
- meta: T.meta
438
+ roles: x.data,
439
+ meta: x.meta
581
440
  };
582
441
  }
583
442
  }
584
- class ve {
443
+ class Pe {
585
444
  constructor(e, t) {
586
445
  this.httpService = e, this.sessionManager = t;
587
446
  }
@@ -594,12 +453,12 @@ class ve {
594
453
  async getUsers(e) {
595
454
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
596
455
  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, {
456
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
598
457
  headers: t
599
458
  });
600
459
  return {
601
- users: o.data,
602
- meta: o.meta
460
+ users: a.data,
461
+ meta: a.meta
603
462
  };
604
463
  }
605
464
  async getUserById(e) {
@@ -621,197 +480,503 @@ class ve {
621
480
  });
622
481
  }
623
482
  }
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 = {
483
+ class oe {
484
+ constructor(e, t, r) {
485
+ this.httpService = e, this.appId = t, this.sessionManager = r;
486
+ }
487
+ async createTenant(e) {
488
+ if (!this.sessionManager)
489
+ throw new Error("SessionManager is required for private endpoints");
490
+ const t = await this.sessionManager.getAuthHeaders();
491
+ return (await this.httpService.post("/tenants/", e, {
492
+ headers: t
493
+ })).data;
494
+ }
495
+ async getTenants(e) {
496
+ if (!this.sessionManager)
497
+ throw new Error("SessionManager is required for private endpoints");
498
+ const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
499
+ 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);
500
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
501
+ headers: t
502
+ });
503
+ return {
504
+ tenants: a.data,
505
+ meta: a.meta
506
+ };
507
+ }
508
+ async getTenantById(e) {
509
+ if (!this.sessionManager)
510
+ throw new Error("SessionManager is required for private endpoints");
511
+ const t = await this.sessionManager.getAuthHeaders();
512
+ return (await this.httpService.get(`/tenants/${e}`, {
513
+ headers: t
514
+ })).data;
515
+ }
516
+ async updateTenant(e, t) {
517
+ if (!this.sessionManager)
518
+ throw new Error("SessionManager is required for private endpoints");
519
+ const r = await this.sessionManager.getAuthHeaders();
520
+ return (await this.httpService.put(`/tenants/${e}`, t, {
521
+ headers: r
522
+ })).data;
523
+ }
524
+ async adminUpdateTenant(e, t) {
525
+ if (!this.sessionManager)
526
+ throw new Error("SessionManager is required for private endpoints");
527
+ const r = await this.sessionManager.getAuthHeaders();
528
+ return (await this.httpService.put(
529
+ `/tenants/${e}/admin-update`,
530
+ t,
531
+ {
532
+ headers: r
533
+ }
534
+ )).data;
535
+ }
536
+ // Public endpoint - no auth required
537
+ async getPublicTenantInfo(e) {
538
+ return (await this.httpService.get(
539
+ `/tenants/${this.appId}/${e}/public`
540
+ )).data;
541
+ }
542
+ // Settings endpoints
543
+ async getTenantSettings(e) {
544
+ return (await this.httpService.get(
545
+ `/tenants/${e}/settings`
546
+ )).data;
547
+ }
548
+ async updateTenantSettings(e, t) {
549
+ if (!this.sessionManager)
550
+ throw new Error("SessionManager is required for private endpoints");
551
+ const r = await this.sessionManager.getAuthHeaders();
552
+ return (await this.httpService.put(
553
+ `/tenants/${e}/settings`,
554
+ t,
555
+ {
556
+ headers: r
557
+ }
558
+ )).data;
559
+ }
560
+ }
561
+ const pe = te(null), Te = () => /* @__PURE__ */ n(
562
+ "div",
563
+ {
564
+ style: {
565
+ display: "flex",
566
+ justifyContent: "center",
567
+ alignItems: "center",
568
+ height: "100vh",
569
+ fontFamily: "system-ui, sans-serif"
570
+ },
571
+ children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
+ }
573
+ ), ke = ({ error: i, retry: e }) => /* @__PURE__ */ u(
574
+ "div",
575
+ {
576
+ style: {
577
+ display: "flex",
578
+ flexDirection: "column",
579
+ justifyContent: "center",
580
+ alignItems: "center",
581
+ height: "100vh",
582
+ fontFamily: "system-ui, sans-serif",
583
+ textAlign: "center",
584
+ padding: "20px"
585
+ },
586
+ children: [
587
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
588
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
589
+ /* @__PURE__ */ n(
590
+ "button",
591
+ {
592
+ onClick: e,
593
+ style: {
594
+ padding: "8px 16px",
595
+ backgroundColor: "#007bff",
596
+ color: "white",
597
+ border: "none",
598
+ borderRadius: "4px",
599
+ cursor: "pointer"
600
+ },
601
+ children: "Retry"
602
+ }
603
+ )
604
+ ]
605
+ }
606
+ );
607
+ function Ze({ config: i, children: e }) {
608
+ const { baseUrl: t, appInfo: r, appId: s } = se(), a = ee(), x = a == null ? void 0 : a.sessionManager, [d, M] = m(i.initialTenant || null), [P, g] = m(!i.initialTenant), [h, b] = m(null), [y, S] = m(null), [$, p] = m(!1), [D, A] = m(null), E = J(() => {
609
+ const o = i.tenantMode || "optional", l = "tenant";
610
+ if (o === "fixed")
611
+ return i.fixedTenantSlug || null;
612
+ if (typeof window > "u") return null;
613
+ if (o === "subdomain") {
614
+ const c = window.location.hostname.split(".");
615
+ if (c.length >= 3) {
616
+ const k = c[0];
617
+ return localStorage.setItem(l, k), k;
618
+ }
619
+ return localStorage.getItem(l);
620
+ } else if (o === "selector") {
621
+ const c = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
622
+ return c ? (localStorage.setItem(l, c), c) : localStorage.getItem(l);
623
+ }
624
+ return null;
625
+ }, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), f = z(() => E(), [E]), I = (r == null ? void 0 : r.settingsSchema) || null, C = J(
626
+ async (o) => {
627
+ try {
628
+ g(!0), b(null);
629
+ const l = new _(t), c = await new oe(l, s).getPublicTenantInfo(o);
630
+ M(c);
631
+ } catch (l) {
632
+ const H = l instanceof Error ? l : new Error("Failed to load tenant information");
633
+ b(H), M(null);
634
+ } finally {
635
+ g(!1);
636
+ }
637
+ },
638
+ [t, s]
639
+ ), F = J(async () => {
640
+ if (d != null && d.id)
641
+ try {
642
+ p(!0), A(null);
643
+ const o = new _(t), H = await new oe(o, d.appId).getTenantSettings(d.id);
644
+ S(H);
645
+ } catch (o) {
646
+ const l = o instanceof Error ? o : new Error("Failed to load tenant settings");
647
+ A(l), S(null);
648
+ } finally {
649
+ p(!1);
650
+ }
651
+ }, [t, d]), B = J(
652
+ async (o) => {
653
+ if (!(d != null && d.id) || !x)
654
+ throw new Error("Tenant ID and authentication required to update settings");
655
+ try {
656
+ p(!0), A(null);
657
+ const l = new _(t), H = new oe(l, d.appId, x), c = { settings: o }, k = await H.updateTenantSettings(d.id, c);
658
+ S(k);
659
+ } catch (l) {
660
+ const H = l instanceof Error ? l : new Error("Failed to update tenant settings");
661
+ throw A(H), H;
662
+ } finally {
663
+ p(!1);
664
+ }
665
+ },
666
+ [t, d, x]
667
+ ), w = J(() => {
668
+ F();
669
+ }, [F]), O = J(
670
+ (o) => {
671
+ if (!I)
672
+ return { isValid: !0, errors: [] };
673
+ const l = [];
674
+ try {
675
+ return I.properties && Object.entries(I.properties).forEach(([H, c]) => {
676
+ var W;
677
+ const k = o[H];
678
+ if ((W = I.required) != null && W.includes(H) && k == null) {
679
+ l.push(`Field '${H}' is required`);
680
+ return;
681
+ }
682
+ if (k != null) {
683
+ if (c.type) {
684
+ const R = c.type, q = typeof k;
685
+ R === "string" && q !== "string" ? l.push(`Field '${H}' must be a string`) : (R === "number" || R === "integer") && q !== "number" ? l.push(`Field '${H}' must be a number`) : R === "boolean" && q !== "boolean" ? l.push(`Field '${H}' must be a boolean`) : R === "array" && !Array.isArray(k) && l.push(`Field '${H}' must be an array`);
686
+ }
687
+ c.minLength !== void 0 && typeof k == "string" && k.length < c.minLength && l.push(
688
+ `Field '${H}' must be at least ${c.minLength} characters long`
689
+ ), c.maxLength !== void 0 && typeof k == "string" && k.length > c.maxLength && l.push(
690
+ `Field '${H}' must be no more than ${c.maxLength} characters long`
691
+ ), c.minimum !== void 0 && typeof k == "number" && k < c.minimum && l.push(`Field '${H}' must be at least ${c.minimum}`), c.maximum !== void 0 && typeof k == "number" && k > c.maximum && l.push(`Field '${H}' must be no more than ${c.maximum}`), c.pattern && typeof k == "string" && (new RegExp(c.pattern).test(k) || l.push(`Field '${H}' does not match the required pattern`)), c.enum && !c.enum.includes(k) && l.push(`Field '${H}' must be one of: ${c.enum.join(", ")}`);
692
+ }
693
+ }), {
694
+ isValid: l.length === 0,
695
+ errors: l
696
+ };
697
+ } catch {
698
+ return {
699
+ isValid: !1,
700
+ errors: ["Invalid settings schema or validation error"]
701
+ };
702
+ }
703
+ },
704
+ [I]
705
+ );
706
+ K(() => {
707
+ const o = i.tenantMode || "optional";
708
+ !i.initialTenant && f ? C(f) : !i.initialTenant && !f && o === "fixed" ? (b(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), g(!1)) : !i.initialTenant && !f && (o === "subdomain" || o === "selector") ? (b(
709
+ new Error(`No tenant ${o === "subdomain" ? "subdomain" : "parameter"} found`)
710
+ ), g(!1)) : !i.initialTenant && !f && o === "optional" && (M(null), b(null), g(!1));
711
+ }, [i.initialTenant, f, C, i.tenantMode, i.fixedTenantSlug]), K(() => {
712
+ d != null && d.id ? F() : (S(null), A(null), p(!1));
713
+ }, [d == null ? void 0 : d.id, F]);
714
+ const T = z(() => ({
715
+ // Tenant info
716
+ tenant: d,
717
+ tenantSlug: f,
718
+ isTenantLoading: P,
719
+ tenantError: h,
720
+ retryTenant: () => {
721
+ f && C(f);
722
+ },
723
+ // Settings
724
+ settings: y,
725
+ settingsSchema: I,
726
+ isSettingsLoading: $,
727
+ settingsError: D,
728
+ // Actions
729
+ updateSettings: B,
730
+ refreshSettings: w,
731
+ // Validation
732
+ validateSettings: O
733
+ }), [
734
+ d,
735
+ f,
736
+ P,
737
+ h,
738
+ y,
739
+ I,
740
+ $,
741
+ D,
742
+ B,
743
+ w,
744
+ O
745
+ ]);
746
+ if (P)
747
+ return /* @__PURE__ */ n(U, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
748
+ if (h && i.tenantMode !== "optional") {
749
+ const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => C(f || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: h, retry: () => C(f || "") });
750
+ return /* @__PURE__ */ n(U, { children: o });
751
+ }
752
+ return /* @__PURE__ */ n(pe.Provider, { value: T, children: e });
753
+ }
754
+ function ae() {
755
+ const i = re(pe);
756
+ if (!i)
757
+ throw new Error("useTenant must be used within a TenantProvider");
758
+ return i;
759
+ }
760
+ const et = ae;
761
+ function tt() {
762
+ const {
763
+ settings: i,
764
+ settingsSchema: e,
765
+ isSettingsLoading: t,
766
+ settingsError: r,
767
+ updateSettings: s,
768
+ validateSettings: a
769
+ } = ae();
770
+ return {
771
+ settings: i,
772
+ settingsSchema: e,
773
+ isLoading: t,
774
+ error: r,
775
+ updateSettings: s,
776
+ validateSettings: a
777
+ };
778
+ }
779
+ function Z() {
780
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ae();
781
+ return {
782
+ tenant: i,
783
+ tenantSlug: e,
784
+ isLoading: t,
785
+ error: r,
786
+ retry: s
787
+ };
788
+ }
789
+ const fe = te(null);
790
+ function rt({ config: i = {}, children: e }) {
791
+ const { appId: t, baseUrl: r } = se(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [x, d] = m(i.initialRoles || []), [M, P] = m(!i.initialRoles), [g, h] = m(null), [b, y] = m(!1), [S, $] = m(null), p = z(() => {
792
+ const w = a ? `auth_tokens_${a}` : "auth_tokens", O = {
628
793
  get: () => {
629
794
  try {
630
- const U = localStorage.getItem(m);
631
- return U ? JSON.parse(U) : null;
795
+ const T = localStorage.getItem(w);
796
+ return T ? JSON.parse(T) : null;
632
797
  } catch {
633
798
  return null;
634
799
  }
635
800
  },
636
- set: (U) => {
801
+ set: (T) => {
637
802
  try {
638
- localStorage.setItem(m, JSON.stringify(U));
803
+ localStorage.setItem(w, JSON.stringify(T));
639
804
  } catch {
640
805
  }
641
806
  },
642
807
  clear: () => {
643
808
  try {
644
- localStorage.removeItem(m);
809
+ localStorage.removeItem(w);
645
810
  } catch {
646
811
  }
647
812
  }
648
813
  };
649
- return new be({
650
- onRefreshFailed: n.onRefreshFailed,
651
- tokenStorage: R,
652
- baseUrl: s
814
+ return new xe({
815
+ onRefreshFailed: i.onRefreshFailed,
816
+ tokenStorage: O,
817
+ baseUrl: r
653
818
  });
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]);
819
+ }, [a, r, i.onRefreshFailed]), D = z(() => {
820
+ const w = new _(r);
821
+ return w.setSessionManager(p), w;
822
+ }, [r, p]), A = z(() => new Ae(new _(r)), [r]), E = z(() => new Pe(D, p), [D, p]), f = z(() => new ce(new _(r)), [r]), I = z(() => g || p.getUser(), [g, p]), C = z(() => I != null && I.roleId && x.find((w) => w.id === I.roleId) || null, [I, x]), F = z(() => (C == null ? void 0 : C.permissions) || [], [C]);
658
823
  K(() => {
659
- console.log("AuthProvider - userPermissions changed:", k);
660
- }, [k]);
661
- const F = N(() => {
662
- const m = async () => {
824
+ console.log("AuthProvider - userPermissions changed:", F);
825
+ }, [F]);
826
+ const B = z(() => {
827
+ const w = async () => {
663
828
  try {
664
- v(!0), y(null);
665
- const A = c.getUser();
666
- if (!(A != null && A.id))
829
+ y(!0), $(null);
830
+ const v = p.getUser();
831
+ if (!(v != null && v.id))
667
832
  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:", $);
833
+ const L = await E.getUserById(v.id);
834
+ h(L), p.setUser(L);
835
+ } catch (v) {
836
+ const L = v instanceof Error ? v : new Error("Failed to load user data");
837
+ $(L), console.error("Failed to load user data:", L);
673
838
  } finally {
674
- v(!1);
839
+ y(!1);
675
840
  }
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
841
+ }, O = async () => {
842
+ await w();
843
+ }, T = async (v, L, Q) => {
844
+ const G = await A.login({
845
+ email: v,
846
+ password: L,
847
+ tenantId: Q
683
848
  });
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);
849
+ if (p.setTokens({
850
+ accessToken: G.accessToken,
851
+ refreshToken: G.refreshToken,
852
+ expiresIn: G.expiresIn
853
+ }), G.user) {
854
+ p.setUser(G.user), h(G.user);
690
855
  try {
691
- await m();
692
- } catch (se) {
693
- console.warn("Failed to load complete user data after login:", se);
856
+ await w();
857
+ } catch (ie) {
858
+ console.warn("Failed to load complete user data after login:", ie);
694
859
  }
695
860
  }
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,
861
+ return G;
862
+ }, o = async (v, L, Q, G) => await A.signup({ email: v, name: L, password: Q, tenantId: G }), l = async (v, L, Q, G) => await A.signupTenantAdmin({
863
+ email: v,
864
+ name: L,
865
+ password: Q,
866
+ tenantName: G,
702
867
  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))
868
+ }), H = async (v, L) => {
869
+ const Q = await p.getAuthHeaders();
870
+ await A.changePassword({ currentPassword: v, newPassword: L }, Q);
871
+ }, c = async (v, L) => {
872
+ await A.requestPasswordReset({ email: v, tenantId: L });
873
+ }, k = async (v, L) => {
874
+ await A.confirmPasswordReset({ token: v, newPassword: L });
875
+ }, W = async () => {
876
+ const v = p.getTokens();
877
+ if (!(v != null && v.refreshToken))
713
878
  throw new Error("No refresh token available");
714
- const $ = await x.refreshToken({
715
- refreshToken: A.refreshToken
879
+ const L = await A.refreshToken({
880
+ refreshToken: v.refreshToken
716
881
  });
717
- c.setTokens({
718
- accessToken: $.accessToken,
719
- refreshToken: $.refreshToken || A.refreshToken,
720
- expiresIn: $.expiresIn
882
+ p.setTokens({
883
+ accessToken: L.accessToken,
884
+ refreshToken: L.refreshToken || v.refreshToken,
885
+ expiresIn: L.expiresIn
721
886
  });
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 () => {
887
+ }, R = () => {
888
+ p.clearSession(), h(null), $(null);
889
+ }, q = (v) => {
890
+ p.setTokens(v);
891
+ }, Y = () => p.hasValidSession(), N = () => {
892
+ p.clearSession(), h(null), $(null);
893
+ }, j = async () => {
729
894
  if (t)
730
895
  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);
896
+ P(!0);
897
+ const { roles: v } = await f.getRolesByApp(t);
898
+ d(v);
899
+ } catch (v) {
900
+ console.error("Failed to fetch roles:", v);
736
901
  } finally {
737
- S(!1);
902
+ P(!1);
738
903
  }
739
- }, j = async () => {
740
- await D();
741
- }, O = (A) => {
742
- if (!k || k.length === 0)
904
+ }, V = async () => {
905
+ await j();
906
+ }, ne = (v) => {
907
+ if (!F || F.length === 0)
743
908
  return !1;
744
- if (typeof A == "string")
745
- return k.includes(A);
746
- const $ = `${A.resource}.${A.action}`;
747
- return k.includes($);
909
+ if (typeof v == "string")
910
+ return F.includes(v);
911
+ const L = `${v.resource}.${v.action}`;
912
+ return F.includes(L);
748
913
  };
749
914
  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,
915
+ sessionManager: p,
916
+ authenticatedHttpService: D,
917
+ login: T,
918
+ signup: o,
919
+ signupTenantAdmin: l,
920
+ changePassword: H,
921
+ requestPasswordReset: c,
922
+ confirmPasswordReset: k,
923
+ refreshToken: W,
924
+ logout: R,
925
+ setTokens: q,
926
+ hasValidSession: Y,
927
+ clearSession: N,
928
+ currentUser: g,
929
+ isUserLoading: b,
930
+ userError: S,
931
+ refreshUser: O,
932
+ userRole: C,
933
+ userPermissions: F,
934
+ availableRoles: x,
770
935
  rolesLoading: M,
771
- hasPermission: O,
772
- hasAnyPermission: (A) => A.some(($) => O($)),
773
- hasAllPermissions: (A) => A.every(($) => O($)),
774
- getUserPermissionStrings: () => k || [],
775
- refreshRoles: j
936
+ hasPermission: ne,
937
+ hasAnyPermission: (v) => v.some((L) => ne(L)),
938
+ hasAllPermissions: (v) => v.every((L) => ne(L)),
939
+ getUserPermissionStrings: () => F || [],
940
+ refreshRoles: V
776
941
  };
777
942
  }, [
778
- c,
779
- C,
780
- x,
781
- d,
782
- l,
783
- t,
784
- o,
785
- E,
786
943
  p,
944
+ D,
945
+ A,
946
+ E,
787
947
  f,
788
- u,
789
- k
948
+ t,
949
+ x,
950
+ g,
951
+ b,
952
+ S,
953
+ C,
954
+ F
790
955
  ]);
791
956
  return K(() => {
792
- !n.initialRoles && t && (async () => {
957
+ !i.initialRoles && t && (async () => {
793
958
  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);
959
+ P(!0);
960
+ const O = new _(r), T = new ce(O), { roles: o } = await T.getRolesByApp(t);
961
+ d(o);
962
+ } catch (O) {
963
+ console.error("Failed to fetch roles:", O);
799
964
  } finally {
800
- S(!1);
965
+ P(!1);
801
966
  }
802
967
  })();
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 });
968
+ }, [t, r, i.initialRoles]), K(() => {
969
+ const w = p.getUser();
970
+ w && p.hasValidSession() && h(w);
971
+ }, [p]), /* @__PURE__ */ n(fe.Provider, { value: B, children: e });
807
972
  }
808
973
  function ee() {
809
- const n = re(he);
810
- if (!n)
974
+ const i = re(fe);
975
+ if (!i)
811
976
  throw new Error("useAuth must be used within an AuthProvider");
812
- return n;
977
+ return i;
813
978
  }
814
- class xe {
979
+ class Me {
815
980
  constructor(e, t) {
816
981
  this.httpService = e, this.sessionManager = t;
817
982
  }
@@ -832,12 +997,12 @@ class xe {
832
997
  throw new Error("SessionManager is required for private endpoints");
833
998
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
834
999
  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, {
1000
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
836
1001
  headers: t
837
1002
  });
838
1003
  return {
839
- featureFlags: o.data,
840
- meta: o.meta
1004
+ featureFlags: a.data,
1005
+ meta: a.meta
841
1006
  };
842
1007
  }
843
1008
  async getFeatureFlagById(e) {
@@ -885,64 +1050,64 @@ class xe {
885
1050
  throw new Error("Flag Key, Tenant ID and App ID are required");
886
1051
  const s = new URLSearchParams();
887
1052
  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, {
1053
+ const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1054
+ return (await this.httpService.get(a, {
890
1055
  headers: { "X-Tenant-ID": t }
891
1056
  })).data;
892
1057
  }
893
1058
  }
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([]);
1059
+ const ye = te(null);
1060
+ function st({ config: i = {}, children: e }) {
1061
+ const { baseUrl: t, appId: r } = se(), { tenant: s } = Z(), [a, x] = m([]), [d, M] = m(!1), [P, g] = m(null), h = z(() => {
1062
+ const S = new _(t);
1063
+ return new Me(S);
1064
+ }, [t]), b = async () => {
1065
+ if (!(s != null && s.id)) {
1066
+ x([]);
902
1067
  return;
903
1068
  }
904
- S(!0), w(null);
1069
+ M(!0), g(null);
905
1070
  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));
1071
+ const S = await h.getTenantFeatureFlags(s.id, r);
1072
+ x(S);
1073
+ } catch (S) {
1074
+ const $ = S instanceof Error ? S.message : "Failed to fetch feature flags";
1075
+ g($), i.onError && i.onError(S instanceof Error ? S : new Error($));
911
1076
  } finally {
912
- S(!1);
1077
+ M(!1);
913
1078
  }
914
1079
  };
915
1080
  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;
1081
+ b();
1082
+ const S = i.refreshInterval || 5 * 60 * 1e3, $ = setInterval(b, S);
1083
+ return () => clearInterval($);
1084
+ }, [s == null ? void 0 : s.id, i.refreshInterval]);
1085
+ const y = z(() => ({
1086
+ featureFlags: a,
1087
+ loading: d,
1088
+ error: P,
1089
+ isEnabled: (A) => {
1090
+ const E = a.find((f) => f.key === A);
1091
+ return (E == null ? void 0 : E.value) === !0;
927
1092
  },
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";
1093
+ getFlag: (A) => a.find((E) => E.key === A),
1094
+ getFlagState: (A) => {
1095
+ const E = a.find((f) => f.key === A);
1096
+ return E ? E.value ? "enabled" : "disabled" : "not_found";
932
1097
  },
933
1098
  refresh: async () => {
934
- await v();
1099
+ await b();
935
1100
  }
936
- }), [o, M, E]);
937
- return /* @__PURE__ */ i(ge.Provider, { value: f, children: e });
1101
+ }), [a, d, P]);
1102
+ return /* @__PURE__ */ n(ye.Provider, { value: y, children: e });
938
1103
  }
939
- function Ae() {
940
- const n = re(ge);
941
- if (!n)
1104
+ function Ee() {
1105
+ const i = re(ye);
1106
+ if (!i)
942
1107
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
943
- return n;
1108
+ return i;
944
1109
  }
945
- class Pe {
1110
+ class Re {
946
1111
  constructor(e, t) {
947
1112
  this.httpService = e, this.sessionManager = t;
948
1113
  }
@@ -1008,185 +1173,64 @@ class Pe {
1008
1173
  )).data;
1009
1174
  }
1010
1175
  }
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);
1176
+ const we = te(void 0);
1177
+ function nt({ config: i = {}, children: e }) {
1178
+ const { baseUrl: t } = se(), { tenant: r } = Z(), [s, a] = m(null), [x, d] = m(!1), [M, P] = m(null), g = z(() => {
1179
+ const y = new _(t);
1180
+ return new Re(y);
1181
+ }, [t]), h = async () => {
1182
+ if (!(r != null && r.id)) {
1183
+ a(null);
1019
1184
  return;
1020
1185
  }
1021
- M(!0), E(null);
1186
+ d(!0), P(null);
1022
1187
  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));
1188
+ const y = await g.getTenantSubscriptionFeatures(r.id);
1189
+ a(y);
1190
+ } catch (y) {
1191
+ const S = y instanceof Error ? y.message : "Failed to fetch subscription";
1192
+ P(S), i.onError && i.onError(y instanceof Error ? y : new Error(S));
1028
1193
  } finally {
1029
- M(!1);
1194
+ d(!1);
1030
1195
  }
1031
1196
  };
1032
1197
  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) || [];
1198
+ if (h(), !i.refreshInterval) return;
1199
+ const y = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(h, y);
1200
+ return () => clearInterval(S);
1201
+ }, [r == null ? void 0 : r.id, i.refreshInterval]);
1202
+ const b = z(() => {
1203
+ const y = (s == null ? void 0 : s.features) || [];
1039
1204
  return {
1040
1205
  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;
1206
+ features: y,
1207
+ loading: x,
1208
+ error: M,
1209
+ isFeatureEnabled: (E) => {
1210
+ const f = y.find((I) => I.key === E);
1211
+ return f ? f.type === "BOOLEAN" || f.type === "boolean" ? f.value === !0 : !!f.value : !1;
1047
1212
  },
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;
1213
+ getFeature: (E) => y.find((f) => f.key === E),
1214
+ getFeatureValue: (E, f) => {
1215
+ const I = y.find((C) => C.key === E);
1216
+ return I ? I.value : f;
1052
1217
  },
1053
- hasAllowedPlan: (l) => !s || !s.isActive ? !1 : l.includes(s.planId),
1218
+ hasAllowedPlan: (E) => !s || !s.isActive ? !1 : E.includes(s.planId),
1054
1219
  refresh: async () => {
1055
- await p();
1220
+ await h();
1056
1221
  }
1057
1222
  };
1058
- }, [s, T, S]);
1059
- return /* @__PURE__ */ i(pe.Provider, { value: v, children: e });
1223
+ }, [s, x, M]);
1224
+ return /* @__PURE__ */ n(we.Provider, { value: b, children: e });
1060
1225
  }
1061
- function Te() {
1062
- const n = re(pe);
1063
- if (n === void 0)
1226
+ function Fe() {
1227
+ const i = re(we);
1228
+ if (i === void 0)
1064
1229
  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
- };
1230
+ return i;
1187
1231
  }
1188
- var Z = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(Z || {});
1189
- const le = () => /* @__PURE__ */ g(
1232
+ var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
1233
+ const de = () => /* @__PURE__ */ u(
1190
1234
  "div",
1191
1235
  {
1192
1236
  style: {
@@ -1202,10 +1246,10 @@ const le = () => /* @__PURE__ */ g(
1202
1246
  margin: "20px 0"
1203
1247
  },
1204
1248
  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(
1249
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1250
+ /* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1251
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1252
+ /* @__PURE__ */ n(
1209
1253
  "button",
1210
1254
  {
1211
1255
  style: {
@@ -1223,11 +1267,11 @@ const le = () => /* @__PURE__ */ g(
1223
1267
  )
1224
1268
  ]
1225
1269
  }
1226
- ), ce = ({
1227
- userType: n,
1270
+ ), ue = ({
1271
+ userType: i,
1228
1272
  minUserType: e,
1229
1273
  missingPermissions: t
1230
- }) => /* @__PURE__ */ g(
1274
+ }) => /* @__PURE__ */ u(
1231
1275
  "div",
1232
1276
  {
1233
1277
  style: {
@@ -1243,57 +1287,57 @@ const le = () => /* @__PURE__ */ g(
1243
1287
  margin: "20px 0"
1244
1288
  },
1245
1289
  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: [
1290
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1291
+ /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1292
+ e && i ? /* @__PURE__ */ u(U, { children: [
1293
+ /* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1250
1294
  "This content requires ",
1251
- /* @__PURE__ */ i("strong", { children: e }),
1295
+ /* @__PURE__ */ n("strong", { children: e }),
1252
1296
  " access level or higher."
1253
1297
  ] }),
1254
- /* @__PURE__ */ g("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1298
+ /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1255
1299
  "Your current access level: ",
1256
- /* @__PURE__ */ i("strong", { children: n })
1300
+ /* @__PURE__ */ n("strong", { children: i })
1257
1301
  ] })
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: [
1302
+ ] }) : /* @__PURE__ */ u(U, { children: [
1303
+ /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1304
+ t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1261
1305
  "Required permissions: ",
1262
- /* @__PURE__ */ i("strong", { children: t.join(", ") })
1306
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1263
1307
  ] })
1264
1308
  ] })
1265
1309
  ]
1266
1310
  }
1267
- ), Me = (n, e) => {
1311
+ ), Ie = (i, e) => {
1268
1312
  const t = {
1269
- [Z.USER]: 1,
1270
- [Z.TENANT_ADMIN]: 2,
1271
- [Z.SUPERUSER]: 3
1313
+ [X.USER]: 1,
1314
+ [X.TENANT_ADMIN]: 2,
1315
+ [X.SUPERUSER]: 3
1272
1316
  };
1273
- return t[n] >= t[e];
1317
+ return t[i] >= t[e];
1274
1318
  };
1275
- function tt({
1276
- children: n,
1319
+ function it({
1320
+ children: i,
1277
1321
  fallback: e,
1278
1322
  minUserType: t,
1279
1323
  requiredPermissions: r,
1280
1324
  requireAllPermissions: s = !1
1281
1325
  }) {
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 });
1326
+ const { hasValidSession: a, sessionManager: x, hasPermission: d, hasAnyPermission: M, hasAllPermissions: P } = ee();
1327
+ if (!a())
1328
+ return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
1329
+ const g = x.getUser();
1330
+ if (!g)
1331
+ return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
1332
+ if (t && !Ie(g.userType, t))
1333
+ return /* @__PURE__ */ n(ue, { userType: g.userType, minUserType: t });
1334
+ if (r && r.length > 0 && !(s ? P(r) : M(r))) {
1335
+ const b = r.filter((y) => !d(y)).map((y) => typeof y == "string" ? y : y.name);
1336
+ return /* @__PURE__ */ n(ue, { missingPermissions: b });
1337
+ }
1338
+ return /* @__PURE__ */ n(U, { children: i });
1295
1339
  }
1296
- const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1340
+ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1297
1341
  "div",
1298
1342
  {
1299
1343
  style: {
@@ -1306,7 +1350,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1306
1350
  backgroundColor: "#f9fafb",
1307
1351
  textAlign: "center"
1308
1352
  },
1309
- children: /* @__PURE__ */ g(
1353
+ children: /* @__PURE__ */ u(
1310
1354
  "div",
1311
1355
  {
1312
1356
  style: {
@@ -1317,23 +1361,23 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1317
1361
  maxWidth: "400px"
1318
1362
  },
1319
1363
  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: [
1364
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1365
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1366
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1367
+ /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1324
1368
  "Redirecting to ",
1325
- n,
1369
+ i,
1326
1370
  "..."
1327
1371
  ] })
1328
1372
  ]
1329
1373
  }
1330
1374
  )
1331
1375
  }
1332
- ), de = ({
1333
- userType: n,
1376
+ ), he = ({
1377
+ userType: i,
1334
1378
  minUserType: e,
1335
1379
  missingPermissions: t
1336
- }) => /* @__PURE__ */ i(
1380
+ }) => /* @__PURE__ */ n(
1337
1381
  "div",
1338
1382
  {
1339
1383
  style: {
@@ -1346,7 +1390,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1346
1390
  backgroundColor: "#f9fafb",
1347
1391
  textAlign: "center"
1348
1392
  },
1349
- children: /* @__PURE__ */ g(
1393
+ children: /* @__PURE__ */ u(
1350
1394
  "div",
1351
1395
  {
1352
1396
  style: {
@@ -1357,63 +1401,63 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1357
1401
  maxWidth: "400px"
1358
1402
  },
1359
1403
  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: [
1404
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1405
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1406
+ e && i ? /* @__PURE__ */ u(U, { children: [
1407
+ /* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1364
1408
  "This page requires ",
1365
- /* @__PURE__ */ i("strong", { children: e }),
1409
+ /* @__PURE__ */ n("strong", { children: e }),
1366
1410
  " access level or higher."
1367
1411
  ] }),
1368
- /* @__PURE__ */ g("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1412
+ /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1369
1413
  "Your current access level: ",
1370
- /* @__PURE__ */ i("strong", { children: n })
1414
+ /* @__PURE__ */ n("strong", { children: i })
1371
1415
  ] })
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: [
1416
+ ] }) : /* @__PURE__ */ u(U, { children: [
1417
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1418
+ t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1375
1419
  "Required permissions: ",
1376
- /* @__PURE__ */ i("strong", { children: t.join(", ") })
1420
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1377
1421
  ] })
1378
1422
  ] })
1379
1423
  ]
1380
1424
  }
1381
1425
  )
1382
1426
  }
1383
- ), Re = (n, e) => {
1427
+ ), $e = (i, e) => {
1384
1428
  const t = {
1385
- [Z.USER]: 1,
1386
- [Z.TENANT_ADMIN]: 2,
1387
- [Z.SUPERUSER]: 3
1429
+ [X.USER]: 1,
1430
+ [X.TENANT_ADMIN]: 2,
1431
+ [X.SUPERUSER]: 3
1388
1432
  };
1389
- return t[n] >= t[e];
1433
+ return t[i] >= t[e];
1390
1434
  };
1391
- function rt({
1392
- children: n,
1435
+ function ot({
1436
+ children: i,
1393
1437
  redirectTo: e = "/login",
1394
1438
  minUserType: t,
1395
1439
  requiredPermissions: r,
1396
1440
  requireAllPermissions: s = !1,
1397
- fallback: o
1441
+ fallback: a
1398
1442
  }) {
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 })
1443
+ const { hasValidSession: x, sessionManager: d, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = ee(), h = me();
1444
+ if (!x())
1445
+ return a ? /* @__PURE__ */ n(U, { children: a }) : /* @__PURE__ */ u(U, { children: [
1446
+ /* @__PURE__ */ n(He, { redirectPath: e }),
1447
+ /* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 })
1404
1448
  ] });
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 });
1449
+ const b = d.getUser();
1450
+ if (!b)
1451
+ return /* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 });
1452
+ if (t && !$e(b.userType, t))
1453
+ return /* @__PURE__ */ n(he, { userType: b.userType, minUserType: t });
1454
+ if (r && r.length > 0 && !(s ? g(r) : P(r))) {
1455
+ const S = r.filter(($) => !M($)).map(($) => typeof $ == "string" ? $ : $.name);
1456
+ return /* @__PURE__ */ n(he, { missingPermissions: S });
1457
+ }
1458
+ return /* @__PURE__ */ n(U, { children: i });
1415
1459
  }
1416
- const Fe = () => /* @__PURE__ */ g(
1460
+ const Ce = () => /* @__PURE__ */ u(
1417
1461
  "div",
1418
1462
  {
1419
1463
  style: {
@@ -1425,19 +1469,19 @@ const Fe = () => /* @__PURE__ */ g(
1425
1469
  color: "#dc2626"
1426
1470
  },
1427
1471
  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." })
1472
+ /* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1473
+ /* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1430
1474
  ]
1431
1475
  }
1432
1476
  );
1433
- function st({
1434
- children: n,
1435
- fallback: e = /* @__PURE__ */ i(Fe, {}),
1477
+ function at({
1478
+ children: i,
1479
+ fallback: e = /* @__PURE__ */ n(Ce, {}),
1436
1480
  allowedPlans: t,
1437
1481
  requiredFeature: r
1438
1482
  }) {
1439
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: T, loading: M } = Te();
1440
- return M ? /* @__PURE__ */ i(
1483
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: x, loading: d } = Fe();
1484
+ return d ? /* @__PURE__ */ n(
1441
1485
  "div",
1442
1486
  {
1443
1487
  style: {
@@ -1447,9 +1491,9 @@ function st({
1447
1491
  },
1448
1492
  children: "Loading subscription..."
1449
1493
  }
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 });
1494
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(U, { children: e }) : r && !x(r) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: i }) : /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: e });
1451
1495
  }
1452
- const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
1496
+ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
1453
1497
  "div",
1454
1498
  {
1455
1499
  style: {
@@ -1466,19 +1510,19 @@ const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
1466
1510
  color: "#6c757d"
1467
1511
  },
1468
1512
  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: [
1513
+ /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1514
+ /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1515
+ /* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1472
1516
  'Feature flag "',
1473
- n,
1517
+ i,
1474
1518
  '" is disabled'
1475
1519
  ] })
1476
1520
  ]
1477
1521
  }
1478
1522
  );
1479
- function nt({ name: n, children: e, fallback: t }) {
1480
- const { isEnabled: r, loading: s } = Ae();
1481
- return s ? /* @__PURE__ */ i(
1523
+ function lt({ name: i, children: e, fallback: t }) {
1524
+ const { isEnabled: r, loading: s } = Ee();
1525
+ return s ? /* @__PURE__ */ n(
1482
1526
  "div",
1483
1527
  {
1484
1528
  style: {
@@ -1491,9 +1535,9 @@ function nt({ name: n, children: e, fallback: t }) {
1491
1535
  },
1492
1536
  children: "Loading feature flags..."
1493
1537
  }
1494
- ) : (console.log(n, r(n)), r(n) ? /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: t || /* @__PURE__ */ i(Ie, { flagName: n }) }));
1538
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
1495
1539
  }
1496
- const He = () => /* @__PURE__ */ g(
1540
+ const De = () => /* @__PURE__ */ u(
1497
1541
  "svg",
1498
1542
  {
1499
1543
  width: "16",
@@ -1506,11 +1550,11 @@ const He = () => /* @__PURE__ */ g(
1506
1550
  strokeLinejoin: "round",
1507
1551
  style: { flexShrink: 0 },
1508
1552
  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" })
1553
+ /* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1554
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1511
1555
  ]
1512
1556
  }
1513
- ), $e = () => /* @__PURE__ */ g(
1557
+ ), Be = () => /* @__PURE__ */ u(
1514
1558
  "svg",
1515
1559
  {
1516
1560
  width: "16",
@@ -1523,14 +1567,14 @@ const He = () => /* @__PURE__ */ g(
1523
1567
  strokeLinejoin: "round",
1524
1568
  style: { flexShrink: 0 },
1525
1569
  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" })
1570
+ /* @__PURE__ */ n("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" }),
1571
+ /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1528
1572
  ]
1529
1573
  }
1530
- ), Ce = {
1531
- showPassword: /* @__PURE__ */ i(He, {}),
1532
- hidePassword: /* @__PURE__ */ i($e, {})
1533
- }, Le = {
1574
+ ), qe = {
1575
+ showPassword: /* @__PURE__ */ n(De, {}),
1576
+ hidePassword: /* @__PURE__ */ n(Be, {})
1577
+ }, Ue = {
1534
1578
  title: "Sign In",
1535
1579
  emailLabel: "Email",
1536
1580
  emailPlaceholder: "Enter your email",
@@ -1542,7 +1586,7 @@ const He = () => /* @__PURE__ */ g(
1542
1586
  signupText: "Don't have an account?",
1543
1587
  errorMessage: "Invalid email or password",
1544
1588
  loadingText: "Signing in..."
1545
- }, De = {
1589
+ }, Ne = {
1546
1590
  container: {
1547
1591
  maxWidth: "400px",
1548
1592
  width: "100%",
@@ -1649,119 +1693,119 @@ const He = () => /* @__PURE__ */ g(
1649
1693
  fontSize: "0.875rem"
1650
1694
  }
1651
1695
  };
1652
- function it({
1653
- copy: n = {},
1696
+ function ct({
1697
+ copy: i = {},
1654
1698
  styles: e = {},
1655
1699
  icons: t = {},
1656
1700
  onSuccess: r,
1657
1701
  onError: s,
1658
- onForgotPassword: o,
1659
- onSignupClick: T,
1660
- showForgotPassword: M = !0,
1661
- showSignupLink: S = !0,
1662
- className: E
1702
+ onForgotPassword: a,
1703
+ onSignupClick: x,
1704
+ showForgotPassword: d = !0,
1705
+ showSignupLink: M = !0,
1706
+ className: P
1663
1707
  }) {
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()) {
1708
+ const [g, h] = m(""), [b, y] = m(""), [S, $] = m(!1), [p, D] = m(!1), [A, E] = m(""), [f, I] = m({}), { login: C } = ee(), { tenant: F } = Z(), B = { ...Ue, ...i }, w = { ...Ne, ...e }, O = { ...qe, ...t }, T = () => {
1709
+ const c = {};
1710
+ return g.trim() || (c.email = !0), b.trim() || (c.password = !0), I(c), Object.keys(c).length === 0;
1711
+ }, o = async (c) => {
1712
+ if (c.preventDefault(), !!T()) {
1669
1713
  if (!(F != null && F.id)) {
1670
- l("Tenant not found");
1714
+ E("Tenant not found");
1671
1715
  return;
1672
1716
  }
1673
- x(!0), l("");
1717
+ D(!0), E("");
1674
1718
  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(_);
1719
+ const k = await C(g, b, F.id);
1720
+ r == null || r(k);
1721
+ } catch (k) {
1722
+ const W = k.message || B.errorMessage;
1723
+ E(W), s == null || s(W);
1680
1724
  } finally {
1681
- x(!1);
1725
+ D(!1);
1682
1726
  }
1683
1727
  }
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 : {}
1728
+ }, l = (c) => ({
1729
+ ...w.input,
1730
+ ...f[c] ? w.inputError : {}
1731
+ }), H = () => ({
1732
+ ...w.button,
1733
+ ...p ? w.buttonLoading : {},
1734
+ ...!g || !b || p ? w.buttonDisabled : {}
1691
1735
  });
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(
1736
+ return /* @__PURE__ */ u("div", { className: P, style: w.container, children: [
1737
+ /* @__PURE__ */ n("h2", { style: w.title, children: B.title }),
1738
+ /* @__PURE__ */ u("form", { onSubmit: o, style: w.form, children: [
1739
+ /* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
1740
+ /* @__PURE__ */ n("label", { style: w.label, children: B.emailLabel }),
1741
+ /* @__PURE__ */ n(
1698
1742
  "input",
1699
1743
  {
1700
1744
  id: "email",
1701
1745
  name: "email",
1702
1746
  type: "email",
1703
- value: w,
1704
- onChange: (L) => {
1705
- p(L.target.value), a.email && u((z) => ({ ...z, email: !1 }));
1747
+ value: g,
1748
+ onChange: (c) => {
1749
+ h(c.target.value), f.email && I((k) => ({ ...k, email: !1 }));
1706
1750
  },
1707
- placeholder: m.emailPlaceholder,
1708
- style: P("email"),
1709
- disabled: C
1751
+ placeholder: B.emailPlaceholder,
1752
+ style: l("email"),
1753
+ disabled: p
1710
1754
  }
1711
1755
  )
1712
1756
  ] }),
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(
1757
+ /* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
1758
+ /* @__PURE__ */ n("label", { style: w.label, children: B.passwordLabel }),
1759
+ /* @__PURE__ */ u("div", { style: w.inputContainer, children: [
1760
+ /* @__PURE__ */ n(
1717
1761
  "input",
1718
1762
  {
1719
1763
  id: "password",
1720
1764
  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 }));
1765
+ type: S ? "text" : "password",
1766
+ value: b,
1767
+ onChange: (c) => {
1768
+ y(c.target.value), f.password && I((k) => ({ ...k, password: !1 }));
1725
1769
  },
1726
- placeholder: m.passwordPlaceholder,
1770
+ placeholder: B.passwordPlaceholder,
1727
1771
  style: {
1728
- ...P("password"),
1772
+ ...l("password"),
1729
1773
  paddingRight: "2.5rem"
1730
1774
  // Make room for the icon
1731
1775
  },
1732
- disabled: C
1776
+ disabled: p
1733
1777
  }
1734
1778
  ),
1735
- /* @__PURE__ */ i(
1779
+ /* @__PURE__ */ n(
1736
1780
  "button",
1737
1781
  {
1738
1782
  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
1783
+ onClick: () => $(!S),
1784
+ style: w.passwordToggle,
1785
+ disabled: p,
1786
+ "aria-label": S ? "Hide password" : "Show password",
1787
+ children: S ? O.hidePassword : O.showPassword
1744
1788
  }
1745
1789
  )
1746
1790
  ] })
1747
1791
  ] }),
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 })
1792
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !g || !b || p, style: H(), children: p ? B.loadingText : B.submitButton }),
1793
+ A && /* @__PURE__ */ n("div", { style: w.errorText, children: A })
1750
1794
  ] }),
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,
1795
+ (d || M) && /* @__PURE__ */ u("div", { style: w.linkContainer, children: [
1796
+ d && /* @__PURE__ */ n("a", { onClick: a, style: w.link, children: B.forgotPasswordLink }),
1797
+ d && M && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
1798
+ M && /* @__PURE__ */ u("div", { children: [
1799
+ /* @__PURE__ */ u("span", { style: w.divider, children: [
1800
+ B.signupText,
1757
1801
  " "
1758
1802
  ] }),
1759
- /* @__PURE__ */ i("a", { onClick: T, style: R.link, children: m.signupLink })
1803
+ /* @__PURE__ */ n("a", { onClick: x, style: w.link, children: B.signupLink })
1760
1804
  ] })
1761
1805
  ] })
1762
1806
  ] });
1763
1807
  }
1764
- const Be = {
1808
+ const Oe = {
1765
1809
  title: "Create Account",
1766
1810
  nameLabel: "Full Name",
1767
1811
  namePlaceholder: "Enter your full name",
@@ -1781,7 +1825,7 @@ const Be = {
1781
1825
  passwordMismatchError: "Passwords do not match",
1782
1826
  isAdminLabel: "Create new organization",
1783
1827
  isAdminDescription: "Check this if you want to create a new organization"
1784
- }, qe = {
1828
+ }, ze = {
1785
1829
  container: {
1786
1830
  maxWidth: "400px",
1787
1831
  width: "100%",
@@ -1880,154 +1924,154 @@ const Be = {
1880
1924
  fontSize: "0.875rem"
1881
1925
  }
1882
1926
  };
1883
- function ot({
1884
- copy: n = {},
1927
+ function dt({
1928
+ copy: i = {},
1885
1929
  styles: e = {},
1886
1930
  signupType: t = "user",
1887
1931
  onSuccess: r,
1888
1932
  onError: s,
1889
- onLoginClick: o,
1890
- showLoginLink: T = !0,
1891
- className: M
1933
+ onLoginClick: a,
1934
+ showLoginLink: x = !0,
1935
+ className: d
1892
1936
  }) {
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 });
1937
+ const [M, P] = m(""), [g, h] = m(""), [b, y] = m(""), [S, $] = m(""), [p, D] = m(""), [A, E] = m(!1), [f, I] = m(""), [C, F] = m({}), { signup: B, signupTenantAdmin: w } = ee(), { tenant: O } = Z(), T = { ...Oe, ...i }, o = { ...ze, ...e }, l = () => {
1938
+ const R = {};
1939
+ return M.trim() || (R.name = !0), g.trim() || (R.email = !0), b.trim() || (R.password = !0), S.trim() || (R.confirmPassword = !0), t === "tenant" && !p.trim() && (R.tenantName = !0), F(R), Object.keys(R).length === 0;
1940
+ }, H = async (R) => {
1941
+ if (R.preventDefault(), !!l()) {
1942
+ if (b !== S) {
1943
+ I(T.passwordMismatchError), F({ confirmPassword: !0 });
1900
1944
  return;
1901
1945
  }
1902
- if (t === "user" && !(U != null && U.id)) {
1903
- u("Tenant not found");
1946
+ if (t === "user" && !(O != null && O.id)) {
1947
+ I("Tenant not found");
1904
1948
  return;
1905
1949
  }
1906
- l(!0), u("");
1950
+ E(!0), I("");
1907
1951
  try {
1908
1952
  let q;
1909
- t === "tenant" ? q = await R(w, S, v, C) : q = await m(w, S, v, U.id), r == null || r(q);
1953
+ t === "tenant" ? q = await w(g, M, b, p) : q = await B(g, M, b, O.id), r == null || r(q);
1910
1954
  } catch (q) {
1911
- const Q = q.message || I.errorMessage;
1912
- u(Q), s == null || s(Q);
1955
+ const Y = q.message || T.errorMessage;
1956
+ I(Y), s == null || s(Y);
1913
1957
  } finally {
1914
- l(!1);
1958
+ E(!1);
1915
1959
  }
1916
1960
  }
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(
1961
+ }, c = (R) => ({
1962
+ ...o.input,
1963
+ ...C[R] ? o.inputError : {}
1964
+ }), k = () => ({
1965
+ ...o.button,
1966
+ ...A ? o.buttonLoading : {},
1967
+ ...!M || !g || !b || !S || A || t === "tenant" && !p ? o.buttonDisabled : {}
1968
+ }), W = M && g && b && S && (t === "user" || p);
1969
+ return /* @__PURE__ */ u("div", { className: d, style: o.container, children: [
1970
+ /* @__PURE__ */ n("h2", { style: o.title, children: T.title }),
1971
+ /* @__PURE__ */ u("form", { onSubmit: H, style: o.form, children: [
1972
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1973
+ /* @__PURE__ */ n("label", { style: o.label, children: T.nameLabel }),
1974
+ /* @__PURE__ */ n(
1931
1975
  "input",
1932
1976
  {
1933
1977
  id: "name",
1934
1978
  name: "name",
1935
1979
  type: "text",
1936
- value: S,
1937
- onChange: (H) => {
1938
- E(H.target.value), k.name && F((q) => ({ ...q, name: !1 }));
1980
+ value: M,
1981
+ onChange: (R) => {
1982
+ P(R.target.value), C.name && F((q) => ({ ...q, name: !1 }));
1939
1983
  },
1940
- placeholder: I.namePlaceholder,
1941
- style: L("name"),
1942
- disabled: d
1984
+ placeholder: T.namePlaceholder,
1985
+ style: c("name"),
1986
+ disabled: A
1943
1987
  }
1944
1988
  )
1945
1989
  ] }),
1946
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1947
- /* @__PURE__ */ i("label", { style: h.label, children: I.emailLabel }),
1948
- /* @__PURE__ */ i(
1990
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1991
+ /* @__PURE__ */ n("label", { style: o.label, children: T.emailLabel }),
1992
+ /* @__PURE__ */ n(
1949
1993
  "input",
1950
1994
  {
1951
1995
  id: "email",
1952
1996
  name: "email",
1953
1997
  type: "email",
1954
- value: w,
1955
- onChange: (H) => {
1956
- p(H.target.value), k.email && F((q) => ({ ...q, email: !1 }));
1998
+ value: g,
1999
+ onChange: (R) => {
2000
+ h(R.target.value), C.email && F((q) => ({ ...q, email: !1 }));
1957
2001
  },
1958
- placeholder: I.emailPlaceholder,
1959
- style: L("email"),
1960
- disabled: d
2002
+ placeholder: T.emailPlaceholder,
2003
+ style: c("email"),
2004
+ disabled: A
1961
2005
  }
1962
2006
  )
1963
2007
  ] }),
1964
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1965
- /* @__PURE__ */ i("label", { style: h.label, children: I.passwordLabel }),
1966
- /* @__PURE__ */ i(
2008
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2009
+ /* @__PURE__ */ n("label", { style: o.label, children: T.passwordLabel }),
2010
+ /* @__PURE__ */ n(
1967
2011
  "input",
1968
2012
  {
1969
2013
  id: "password",
1970
2014
  name: "password",
1971
2015
  type: "password",
1972
- value: v,
1973
- onChange: (H) => {
1974
- f(H.target.value), k.password && F((q) => ({ ...q, password: !1 }));
2016
+ value: b,
2017
+ onChange: (R) => {
2018
+ y(R.target.value), C.password && F((q) => ({ ...q, password: !1 }));
1975
2019
  },
1976
- placeholder: I.passwordPlaceholder,
1977
- style: L("password"),
1978
- disabled: d
2020
+ placeholder: T.passwordPlaceholder,
2021
+ style: c("password"),
2022
+ disabled: A
1979
2023
  }
1980
2024
  )
1981
2025
  ] }),
1982
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1983
- /* @__PURE__ */ i("label", { style: h.label, children: I.confirmPasswordLabel }),
1984
- /* @__PURE__ */ i(
2026
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2027
+ /* @__PURE__ */ n("label", { style: o.label, children: T.confirmPasswordLabel }),
2028
+ /* @__PURE__ */ n(
1985
2029
  "input",
1986
2030
  {
1987
2031
  id: "confirmPassword",
1988
2032
  name: "confirmPassword",
1989
2033
  type: "password",
1990
- value: y,
1991
- onChange: (H) => {
1992
- c(H.target.value), k.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), a === I.passwordMismatchError && u("");
2034
+ value: S,
2035
+ onChange: (R) => {
2036
+ $(R.target.value), C.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), f === T.passwordMismatchError && I("");
1993
2037
  },
1994
- placeholder: I.confirmPasswordPlaceholder,
1995
- style: L("confirmPassword"),
1996
- disabled: d
2038
+ placeholder: T.confirmPasswordPlaceholder,
2039
+ style: c("confirmPassword"),
2040
+ disabled: A
1997
2041
  }
1998
2042
  )
1999
2043
  ] }),
2000
- t === "tenant" && /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
2001
- /* @__PURE__ */ i("label", { style: h.label, children: I.tenantNameLabel }),
2002
- /* @__PURE__ */ i(
2044
+ t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2045
+ /* @__PURE__ */ n("label", { style: o.label, children: T.tenantNameLabel }),
2046
+ /* @__PURE__ */ n(
2003
2047
  "input",
2004
2048
  {
2005
2049
  id: "tenantName",
2006
2050
  name: "tenantName",
2007
2051
  type: "text",
2008
- value: C,
2009
- onChange: (H) => {
2010
- x(H.target.value), k.tenantName && F((q) => ({ ...q, tenantName: !1 }));
2052
+ value: p,
2053
+ onChange: (R) => {
2054
+ D(R.target.value), C.tenantName && F((q) => ({ ...q, tenantName: !1 }));
2011
2055
  },
2012
- placeholder: I.tenantNamePlaceholder,
2013
- style: L("tenantName"),
2014
- disabled: d
2056
+ placeholder: T.tenantNamePlaceholder,
2057
+ style: c("tenantName"),
2058
+ disabled: A
2015
2059
  }
2016
2060
  )
2017
2061
  ] }),
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 })
2062
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !W || A, style: k(), children: A ? T.loadingText : T.submitButton }),
2063
+ f && /* @__PURE__ */ n("div", { style: o.errorText, children: f })
2020
2064
  ] }),
2021
- T && /* @__PURE__ */ g("div", { style: h.linkContainer, children: [
2022
- /* @__PURE__ */ g("span", { style: h.divider, children: [
2023
- I.loginText,
2065
+ x && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
2066
+ /* @__PURE__ */ u("span", { style: o.divider, children: [
2067
+ T.loginText,
2024
2068
  " "
2025
2069
  ] }),
2026
- /* @__PURE__ */ i("a", { onClick: o, style: h.link, children: I.loginLink })
2070
+ /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: T.loginLink })
2027
2071
  ] })
2028
2072
  ] });
2029
2073
  }
2030
- const Ue = {
2074
+ const je = {
2031
2075
  title: "Reset Password",
2032
2076
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2033
2077
  emailLabel: "Email",
@@ -2049,7 +2093,7 @@ const Ue = {
2049
2093
  resetLoadingText: "Resetting...",
2050
2094
  resetSuccessMessage: "Password reset successfully!",
2051
2095
  passwordMismatchError: "Passwords do not match"
2052
- }, Ne = {
2096
+ }, Ve = {
2053
2097
  container: {
2054
2098
  maxWidth: "400px",
2055
2099
  margin: "0 auto",
@@ -2141,186 +2185,186 @@ const Ue = {
2141
2185
  cursor: "pointer"
2142
2186
  }
2143
2187
  };
2144
- function at({
2145
- copy: n = {},
2188
+ function ut({
2189
+ copy: i = {},
2146
2190
  styles: e = {},
2147
2191
  mode: t = "request",
2148
2192
  token: r = "",
2149
2193
  onSuccess: s,
2150
- onError: o,
2151
- onBackToLogin: T,
2152
- onModeChange: M,
2153
- className: S
2194
+ onError: a,
2195
+ onBackToLogin: x,
2196
+ onModeChange: d,
2197
+ className: M
2154
2198
  }) {
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");
2199
+ const [P, g] = m(""), [h, b] = m(r), [y, S] = m(""), [$, p] = m(""), [D, A] = m(!1), [E, f] = m(""), [I, C] = m(""), [F, B] = m({}), { requestPasswordReset: w, confirmPasswordReset: O } = ee(), { tenant: T } = Z(), o = { ...je, ...i }, l = { ...Ve, ...e }, H = () => {
2200
+ const N = {};
2201
+ return P.trim() || (N.email = !0), B(N), Object.keys(N).length === 0;
2202
+ }, c = () => {
2203
+ const N = {};
2204
+ return h.trim() || (N.token = !0), y.trim() || (N.newPassword = !0), $.trim() || (N.confirmPassword = !0), B(N), Object.keys(N).length === 0;
2205
+ }, k = async (N) => {
2206
+ if (N.preventDefault(), !!H()) {
2207
+ if (!(T != null && T.id)) {
2208
+ f("Tenant not found");
2165
2209
  return;
2166
2210
  }
2167
- d(!0), a(""), k("");
2211
+ A(!0), f(""), C("");
2168
2212
  try {
2169
- await R(E, I.id), k(h.successMessage), s == null || s();
2213
+ await w(P, T.id), C(o.successMessage), s == null || s();
2170
2214
  } catch (j) {
2171
- const O = j.message || h.errorMessage;
2172
- a(O), o == null || o(O);
2215
+ const V = j.message || o.errorMessage;
2216
+ f(V), a == null || a(V);
2173
2217
  } finally {
2174
- d(!1);
2218
+ A(!1);
2175
2219
  }
2176
2220
  }
2177
- }, _ = async (D) => {
2178
- if (D.preventDefault(), !!L()) {
2179
- if (f !== c) {
2180
- a(h.passwordMismatchError), m({ confirmPassword: !0 });
2221
+ }, W = async (N) => {
2222
+ if (N.preventDefault(), !!c()) {
2223
+ if (y !== $) {
2224
+ f(o.passwordMismatchError), B({ confirmPassword: !0 });
2181
2225
  return;
2182
2226
  }
2183
- d(!0), a(""), k("");
2227
+ A(!0), f(""), C("");
2184
2228
  try {
2185
- await U(p, f), k(h.resetSuccessMessage), s == null || s();
2229
+ await O(h, y), C(o.resetSuccessMessage), s == null || s();
2186
2230
  } catch (j) {
2187
- const O = j.message || h.errorMessage;
2188
- a(O), o == null || o(O);
2231
+ const V = j.message || o.errorMessage;
2232
+ f(V), a == null || a(V);
2189
2233
  } finally {
2190
- d(!1);
2234
+ A(!1);
2191
2235
  }
2192
2236
  }
2193
- }, H = (D) => ({
2194
- ...P.input,
2195
- ...F[D] ? P.inputError : {}
2237
+ }, R = (N) => ({
2238
+ ...l.input,
2239
+ ...F[N] ? l.inputError : {}
2196
2240
  }), q = () => ({
2197
- ...P.button,
2198
- ...x ? P.buttonLoading : {}
2241
+ ...l.button,
2242
+ ...D ? l.buttonLoading : {}
2199
2243
  });
2200
2244
  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(
2245
+ const N = h && y && $;
2246
+ return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
2247
+ /* @__PURE__ */ n("h2", { style: l.title, children: o.resetTitle }),
2248
+ /* @__PURE__ */ n("p", { style: l.subtitle, children: o.resetSubtitle }),
2249
+ /* @__PURE__ */ u("form", { onSubmit: W, style: l.form, children: [
2250
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2251
+ /* @__PURE__ */ n("label", { style: l.label, children: o.tokenLabel }),
2252
+ /* @__PURE__ */ n(
2209
2253
  "input",
2210
2254
  {
2211
2255
  type: "text",
2212
- value: p,
2256
+ value: h,
2213
2257
  onChange: (j) => {
2214
- v(j.target.value), F.token && m((O) => ({ ...O, token: !1 }));
2258
+ b(j.target.value), F.token && B((V) => ({ ...V, token: !1 }));
2215
2259
  },
2216
- placeholder: h.tokenPlaceholder,
2217
- style: H("token"),
2218
- disabled: x
2260
+ placeholder: o.tokenPlaceholder,
2261
+ style: R("token"),
2262
+ disabled: D
2219
2263
  }
2220
2264
  )
2221
2265
  ] }),
2222
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2223
- /* @__PURE__ */ i("label", { style: P.label, children: h.newPasswordLabel }),
2224
- /* @__PURE__ */ i(
2266
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2267
+ /* @__PURE__ */ n("label", { style: l.label, children: o.newPasswordLabel }),
2268
+ /* @__PURE__ */ n(
2225
2269
  "input",
2226
2270
  {
2227
2271
  type: "password",
2228
- value: f,
2272
+ value: y,
2229
2273
  onChange: (j) => {
2230
- y(j.target.value), F.newPassword && m((O) => ({ ...O, newPassword: !1 }));
2274
+ S(j.target.value), F.newPassword && B((V) => ({ ...V, newPassword: !1 }));
2231
2275
  },
2232
- placeholder: h.newPasswordPlaceholder,
2233
- style: H("newPassword"),
2234
- disabled: x
2276
+ placeholder: o.newPasswordPlaceholder,
2277
+ style: R("newPassword"),
2278
+ disabled: D
2235
2279
  }
2236
2280
  )
2237
2281
  ] }),
2238
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2239
- /* @__PURE__ */ i("label", { style: P.label, children: h.confirmPasswordLabel }),
2240
- /* @__PURE__ */ i(
2282
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2283
+ /* @__PURE__ */ n("label", { style: l.label, children: o.confirmPasswordLabel }),
2284
+ /* @__PURE__ */ n(
2241
2285
  "input",
2242
2286
  {
2243
2287
  type: "password",
2244
- value: c,
2288
+ value: $,
2245
2289
  onChange: (j) => {
2246
- C(j.target.value), F.confirmPassword && m((O) => ({ ...O, confirmPassword: !1 })), l === h.passwordMismatchError && a("");
2290
+ p(j.target.value), F.confirmPassword && B((V) => ({ ...V, confirmPassword: !1 })), E === o.passwordMismatchError && f("");
2247
2291
  },
2248
- placeholder: h.confirmPasswordPlaceholder,
2249
- style: H("confirmPassword"),
2250
- disabled: x
2292
+ placeholder: o.confirmPasswordPlaceholder,
2293
+ style: R("confirmPassword"),
2294
+ disabled: D
2251
2295
  }
2252
2296
  )
2253
2297
  ] }),
2254
- /* @__PURE__ */ i(
2298
+ /* @__PURE__ */ n(
2255
2299
  "button",
2256
2300
  {
2257
2301
  type: "submit",
2258
- disabled: !D || x,
2302
+ disabled: !N || D,
2259
2303
  style: {
2260
2304
  ...q(),
2261
- ...!D || x ? P.buttonDisabled : {}
2305
+ ...!N || D ? l.buttonDisabled : {}
2262
2306
  },
2263
- children: x ? h.resetLoadingText : h.resetSubmitButton
2307
+ children: D ? o.resetLoadingText : o.resetSubmitButton
2264
2308
  }
2265
2309
  ),
2266
- l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
2267
- u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
2310
+ E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
2311
+ I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
2268
2312
  ] }),
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" })
2313
+ /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2314
+ /* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
2315
+ d && /* @__PURE__ */ u(U, { children: [
2316
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2317
+ /* @__PURE__ */ n("a", { onClick: () => d("request"), style: l.link, children: "Request New Link" })
2274
2318
  ] })
2275
2319
  ] })
2276
2320
  ] });
2277
2321
  }
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(
2322
+ const Y = P;
2323
+ return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
2324
+ /* @__PURE__ */ n("h2", { style: l.title, children: o.title }),
2325
+ /* @__PURE__ */ n("p", { style: l.subtitle, children: o.subtitle }),
2326
+ /* @__PURE__ */ u("form", { onSubmit: k, style: l.form, children: [
2327
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2328
+ /* @__PURE__ */ n("label", { style: l.label, children: o.emailLabel }),
2329
+ /* @__PURE__ */ n(
2286
2330
  "input",
2287
2331
  {
2288
2332
  type: "email",
2289
- value: E,
2290
- onChange: (D) => {
2291
- w(D.target.value), F.email && m((j) => ({ ...j, email: !1 }));
2333
+ value: P,
2334
+ onChange: (N) => {
2335
+ g(N.target.value), F.email && B((j) => ({ ...j, email: !1 }));
2292
2336
  },
2293
- placeholder: h.emailPlaceholder,
2294
- style: H("email"),
2295
- disabled: x
2337
+ placeholder: o.emailPlaceholder,
2338
+ style: R("email"),
2339
+ disabled: D
2296
2340
  }
2297
2341
  )
2298
2342
  ] }),
2299
- /* @__PURE__ */ i(
2343
+ /* @__PURE__ */ n(
2300
2344
  "button",
2301
2345
  {
2302
2346
  type: "submit",
2303
- disabled: !Q || x,
2347
+ disabled: !Y || D,
2304
2348
  style: {
2305
2349
  ...q(),
2306
- ...!Q || x ? P.buttonDisabled : {}
2350
+ ...!Y || D ? l.buttonDisabled : {}
2307
2351
  },
2308
- children: x ? h.loadingText : h.submitButton
2352
+ children: D ? o.loadingText : o.submitButton
2309
2353
  }
2310
2354
  ),
2311
- l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
2312
- u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
2355
+ E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
2356
+ I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
2313
2357
  ] }),
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" })
2358
+ /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2359
+ /* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
2360
+ d && /* @__PURE__ */ u(U, { children: [
2361
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2362
+ /* @__PURE__ */ n("a", { onClick: () => d("reset"), style: l.link, children: "I have a token" })
2319
2363
  ] })
2320
2364
  ] })
2321
2365
  ] });
2322
2366
  }
2323
- class lt {
2367
+ class ht {
2324
2368
  constructor(e, t) {
2325
2369
  this.httpService = e, this.sessionManager = t;
2326
2370
  }
@@ -2341,12 +2385,12 @@ class lt {
2341
2385
  throw new Error("SessionManager is required for private endpoints");
2342
2386
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2343
2387
  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, {
2388
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2345
2389
  headers: t
2346
2390
  });
2347
2391
  return {
2348
- permissions: o.data,
2349
- meta: o.meta
2392
+ permissions: a.data,
2393
+ meta: a.meta
2350
2394
  };
2351
2395
  }
2352
2396
  async getPermissionById(e) {
@@ -2381,14 +2425,14 @@ class lt {
2381
2425
  async getAppPermissions(e, t) {
2382
2426
  const r = new URLSearchParams();
2383
2427
  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);
2428
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
2385
2429
  return {
2386
- permissions: o.data,
2387
- meta: o.meta
2430
+ permissions: a.data,
2431
+ meta: a.meta
2388
2432
  };
2389
2433
  }
2390
2434
  }
2391
- class ct {
2435
+ class gt {
2392
2436
  constructor(e, t) {
2393
2437
  this.httpService = e, this.sessionManager = t;
2394
2438
  }
@@ -2405,12 +2449,12 @@ class ct {
2405
2449
  async getSubscriptionPlans(e) {
2406
2450
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2407
2451
  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, {
2452
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2409
2453
  headers: t
2410
2454
  });
2411
2455
  return {
2412
- plans: o.data,
2413
- meta: o.meta
2456
+ plans: a.data,
2457
+ meta: a.meta
2414
2458
  };
2415
2459
  }
2416
2460
  async getSubscriptionPlanById(e) {
@@ -2439,7 +2483,7 @@ class ct {
2439
2483
  });
2440
2484
  }
2441
2485
  }
2442
- class dt {
2486
+ class pt {
2443
2487
  constructor(e) {
2444
2488
  this.httpService = e;
2445
2489
  }
@@ -2448,7 +2492,7 @@ class dt {
2448
2492
  return await this.httpService.get("/health");
2449
2493
  }
2450
2494
  }
2451
- class ut {
2495
+ class ft {
2452
2496
  // Date string to Date object
2453
2497
  static toDate(e) {
2454
2498
  return new Date(e);
@@ -2571,39 +2615,40 @@ class ut {
2571
2615
  }
2572
2616
  }
2573
2617
  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,
2618
+ ft as ApiMappers,
2619
+ be as AppApiService,
2620
+ Je as AppProvider,
2621
+ Ae as AuthApiService,
2622
+ rt as AuthProvider,
2623
+ lt as FeatureFlag,
2624
+ Me as FeatureFlagApiService,
2625
+ st as FeatureFlagProvider,
2626
+ pt as HealthApiService,
2627
+ _ as HttpService,
2628
+ ct as LoginForm,
2629
+ ut as PasswordRecoveryForm,
2630
+ ht as PermissionApiService,
2631
+ it as Protected,
2632
+ ot as ProtectedRoute,
2633
+ ce as RoleApiService,
2634
+ xe as SessionManager,
2635
+ dt as SignupForm,
2636
+ Re as SubscriptionApiService,
2637
+ at as SubscriptionGuard,
2638
+ gt as SubscriptionPlanApiService,
2639
+ nt as SubscriptionProvider,
2640
+ oe as TenantApiService,
2597
2641
  Ze as TenantProvider,
2598
- ve as UserApiService,
2599
- Z as UserType,
2600
- Ke as useApi,
2601
- G as useApp,
2642
+ Pe as UserApiService,
2643
+ X as UserType,
2644
+ Xe as useApi,
2645
+ se as useApp,
2602
2646
  ee as useAuth,
2603
- Ae as useFeatureFlags,
2604
- et as useSettings,
2605
- Te as useSubscription,
2606
- Ye as useTenant,
2607
- ke as useTenantSettings
2647
+ Ee as useFeatureFlags,
2648
+ tt as useSettings,
2649
+ Fe as useSubscription,
2650
+ ae as useTenant,
2651
+ Z as useTenantInfo,
2652
+ et as useTenantSettings
2608
2653
  };
2609
2654
  //# sourceMappingURL=index.es.js.map