@skylabs-digital/react-identity-access 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as s, Fragment as H, jsxs as c } from "react/jsx-runtime";
2
- import { createContext as te, useState as b, useMemo as z, useCallback as Z, useEffect as Y, useContext as re } from "react";
3
- import { useLocation as ae, Navigate as ie } from "react-router";
4
- class G {
1
+ import { jsx as n, Fragment as N, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as de, useMemo as Q, useState as v, useCallback as ne, useEffect as te, useContext as ue } from "react";
3
+ import { useLocation as we, Navigate as pe } from "react-router-dom";
4
+ class re {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -12,44 +12,44 @@ class G {
12
12
  getBaseUrl() {
13
13
  return this.baseUrl;
14
14
  }
15
- async request(e, t, r, n) {
16
- return this.executeRequest(e, t, r, n, !1);
15
+ async request(e, t, r, s) {
16
+ return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
- async executeRequest(e, t, r, n, o = !1) {
19
- const m = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, T = (n == null ? void 0 : n.timeout) || this.timeout;
20
- let M = {
18
+ async executeRequest(e, t, r, s, a = !1) {
19
+ const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, I = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let A = {
21
21
  "Content-Type": "application/json",
22
- ...n == null ? void 0 : n.headers
22
+ ...s == null ? void 0 : s.headers
23
23
  };
24
- if (!(n != null && n.skipAuth) && this.sessionManager)
24
+ if (!(s != null && s.skipAuth) && this.sessionManager)
25
25
  try {
26
- const h = await this.sessionManager.getAuthHeaders();
27
- M = { ...M, ...h };
28
- } catch (h) {
29
- console.warn("Failed to inject auth headers:", h);
26
+ const b = await this.sessionManager.getAuthHeaders();
27
+ A = { ...A, ...b };
28
+ } catch (b) {
29
+ console.warn("Failed to inject auth headers:", b);
30
30
  }
31
- const P = new AbortController(), g = setTimeout(() => P.abort(), T);
31
+ const x = new AbortController(), P = setTimeout(() => x.abort(), I);
32
32
  try {
33
- const h = await fetch(m, {
33
+ const b = await fetch(p, {
34
34
  method: e,
35
- headers: M,
35
+ headers: A,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: P.signal
37
+ signal: x.signal
38
38
  });
39
- if (clearTimeout(g), h.status === 401 && !(n != null && n.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(P), b.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
- const p = this.sessionManager.getTokens();
42
- if (p != null && p.refreshToken)
43
- return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, n, !0);
41
+ const h = this.sessionManager.getTokens();
42
+ if (h != null && h.refreshToken)
43
+ return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${h.status}: ${h.statusText}`);
45
+ throw new Error(`HTTP ${b.status}: ${b.statusText}`);
46
46
  }
47
- if (!h.ok)
48
- throw new Error(`HTTP ${h.status}: ${h.statusText}`);
49
- const x = h.headers.get("content-type");
50
- return !x || !x.includes("application/json") ? {} : await h.json();
51
- } catch (h) {
52
- throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${T}ms`) : h;
47
+ if (!b.ok)
48
+ throw new Error(`HTTP ${b.status}: ${b.statusText}`);
49
+ const m = b.headers.get("content-type");
50
+ return !m || !m.includes("application/json") ? {} : await b.json();
51
+ } catch (b) {
52
+ throw clearTimeout(P), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,7 +65,7 @@ class G {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class Se {
68
+ class be {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -78,12 +78,12 @@ class Se {
78
78
  async getApps(e) {
79
79
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
80
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);
81
- const n = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
81
+ const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
82
82
  headers: t
83
83
  });
84
84
  return {
85
- apps: o.data,
86
- meta: o.meta
85
+ apps: a.data,
86
+ meta: a.meta
87
87
  };
88
88
  }
89
89
  async getAppById(e) {
@@ -110,11 +110,11 @@ class Se {
110
110
  )).data;
111
111
  }
112
112
  async updateSettingsSchema(e, t, r) {
113
- const n = await this.sessionManager.getAuthHeaders();
113
+ const s = await this.sessionManager.getAuthHeaders();
114
114
  return (await this.httpService.put(
115
115
  `/apps/${e}/settings-schema`,
116
116
  { schema: t, defaultSettings: r },
117
- { headers: n }
117
+ { headers: s }
118
118
  )).data;
119
119
  }
120
120
  async exportConfig(e) {
@@ -124,7 +124,7 @@ class Se {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const pe = te(null), ve = () => /* @__PURE__ */ s(
127
+ const Ae = de(null), De = () => /* @__PURE__ */ n(
128
128
  "div",
129
129
  {
130
130
  style: {
@@ -134,9 +134,9 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
134
134
  height: "100vh",
135
135
  fontFamily: "system-ui, sans-serif"
136
136
  },
137
- children: /* @__PURE__ */ s("div", { children: "Loading application..." })
137
+ children: /* @__PURE__ */ n("div", { children: "Loading application..." })
138
138
  }
139
- ), xe = ({ error: i, retry: e }) => /* @__PURE__ */ c(
139
+ ), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
140
140
  "div",
141
141
  {
142
142
  style: {
@@ -150,9 +150,9 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
150
150
  padding: "20px"
151
151
  },
152
152
  children: [
153
- /* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
154
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
155
- /* @__PURE__ */ s(
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(
156
156
  "button",
157
157
  {
158
158
  onClick: e,
@@ -170,55 +170,113 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
170
170
  ]
171
171
  }
172
172
  );
173
- function et({ config: i, children: e }) {
174
- const [t, r] = b(null), [n, o] = b(!0), [m, T] = b(null), M = z(() => {
175
- const g = () => {
173
+ function St({ config: i, children: e }) {
174
+ const t = Q(
175
+ () => {
176
+ var m, h, S;
177
+ return {
178
+ enabled: ((m = i.cache) == null ? void 0 : m.enabled) ?? !0,
179
+ ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
180
+ // 5 minutes default
181
+ storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `app_cache_${i.appId}`
182
+ };
183
+ },
184
+ [i.cache, i.appId]
185
+ ), [r, s] = v(() => {
186
+ if (!t.enabled) return null;
187
+ try {
188
+ const m = localStorage.getItem(t.storageKey);
189
+ if (!m) return null;
190
+ const h = JSON.parse(m);
191
+ return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
192
+ } catch {
193
+ return null;
194
+ }
195
+ }), [a, p] = v(!r), [I, A] = v(null), x = Q(() => {
196
+ const m = () => {
176
197
  P();
177
198
  };
178
199
  return {
179
200
  appId: i.appId,
180
201
  baseUrl: i.baseUrl,
181
202
  // App info
182
- appInfo: t,
183
- isAppLoading: n,
184
- appError: m,
185
- retryApp: g
203
+ appInfo: r,
204
+ isAppLoading: a,
205
+ appError: I,
206
+ retryApp: m
186
207
  };
187
- }, [i, t, n, m]), P = Z(async () => {
188
- try {
189
- o(!0), T(null);
190
- const g = new G(i.baseUrl), x = await new Se(g, {}).getPublicAppInfo(i.appId);
191
- r(x);
192
- } catch (g) {
193
- const h = g instanceof Error ? g : new Error("Failed to load app information");
194
- T(h), r(null);
195
- } finally {
196
- o(!1);
197
- }
198
- }, [i.baseUrl, i.appId]);
199
- if (Y(() => {
200
- P();
201
- }, [P]), n)
202
- return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(ve, {}) });
203
- if (m) {
204
- const g = typeof i.errorFallback == "function" ? i.errorFallback(m, () => P()) : i.errorFallback || /* @__PURE__ */ s(xe, { error: m, retry: () => P() });
205
- return /* @__PURE__ */ s(H, { children: g });
206
- }
207
- return /* @__PURE__ */ s(pe.Provider, { value: M, children: e });
208
+ }, [i, r, a, I]), P = ne(
209
+ async (m = !1) => {
210
+ if (!(!m && t.enabled && r))
211
+ try {
212
+ p(!0), A(null);
213
+ const h = new re(i.baseUrl), L = await new be(h, {}).getPublicAppInfo(i.appId);
214
+ if (s(L), t.enabled)
215
+ try {
216
+ const C = {
217
+ data: L,
218
+ timestamp: Date.now(),
219
+ appId: i.appId
220
+ };
221
+ localStorage.setItem(t.storageKey, JSON.stringify(C));
222
+ } catch (C) {
223
+ console.warn("Failed to cache app info:", C);
224
+ }
225
+ } catch (h) {
226
+ const S = h instanceof Error ? h : new Error("Failed to load app information");
227
+ A(S), s(null);
228
+ } finally {
229
+ p(!1);
230
+ }
231
+ },
232
+ [i.baseUrl, i.appId, t, r]
233
+ ), b = ne(async () => {
234
+ if (!(!t.enabled || !r))
235
+ try {
236
+ const m = localStorage.getItem(t.storageKey);
237
+ if (!m) return;
238
+ const h = JSON.parse(m);
239
+ if (Date.now() - h.timestamp > t.ttl * 0.5) {
240
+ const L = new re(i.baseUrl), q = await new be(L, {}).getPublicAppInfo(i.appId);
241
+ s(q);
242
+ const k = {
243
+ data: q,
244
+ timestamp: Date.now(),
245
+ appId: i.appId
246
+ };
247
+ localStorage.setItem(t.storageKey, JSON.stringify(k));
248
+ }
249
+ } catch (m) {
250
+ console.warn("Background app refresh failed:", m);
251
+ }
252
+ }, [i, t, r]);
253
+ if (te(() => {
254
+ r ? b() : P();
255
+ }, []), a)
256
+ return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
257
+ if (I) {
258
+ const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
259
+ return /* @__PURE__ */ n(N, { children: m });
260
+ }
261
+ return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
208
262
  }
209
- function se() {
210
- const i = re(pe);
263
+ function he() {
264
+ const i = ue(Ae);
211
265
  if (!i)
212
266
  throw new Error("useApp must be used within an AppProvider");
213
267
  return i;
214
268
  }
215
- const tt = se;
216
- class Ae {
269
+ const vt = he;
270
+ class ye {
217
271
  constructor(e = {}) {
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 || {
272
+ this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
273
+ }
274
+ // Helper to create a TokenStorage for a specific key
275
+ createTokenStorage(e) {
276
+ return {
219
277
  get: () => {
220
278
  try {
221
- const t = localStorage.getItem(this.storageKey);
279
+ const t = localStorage.getItem(e);
222
280
  return t ? JSON.parse(t) : null;
223
281
  } catch {
224
282
  return null;
@@ -226,13 +284,13 @@ class Ae {
226
284
  },
227
285
  set: (t) => {
228
286
  try {
229
- localStorage.setItem(this.storageKey, JSON.stringify(t));
287
+ localStorage.setItem(e, JSON.stringify(t));
230
288
  } catch {
231
289
  }
232
290
  },
233
291
  clear: () => {
234
292
  try {
235
- localStorage.removeItem(this.storageKey);
293
+ localStorage.removeItem(e);
236
294
  } catch {
237
295
  }
238
296
  }
@@ -281,10 +339,10 @@ class Ae {
281
339
  try {
282
340
  await this.refreshPromise;
283
341
  const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
284
- return this.refreshQueue.forEach(({ resolve: n }) => n(r)), this.refreshQueue = [], r;
342
+ return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
285
343
  } catch (t) {
286
344
  const r = t instanceof Error ? t : new Error("Token refresh failed");
287
- return this.refreshQueue.forEach(({ reject: n }) => n(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
345
+ return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
288
346
  } finally {
289
347
  this.refreshPromise = null;
290
348
  }
@@ -303,11 +361,11 @@ class Ae {
303
361
  });
304
362
  if (!r.ok)
305
363
  throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
306
- const n = await r.json();
364
+ const s = await r.json();
307
365
  this.setTokens({
308
- accessToken: n.accessToken,
309
- refreshToken: n.refreshToken || e,
310
- expiresIn: n.expiresIn
366
+ accessToken: s.accessToken,
367
+ refreshToken: s.refreshToken || e,
368
+ expiresIn: s.expiresIn
311
369
  });
312
370
  }
313
371
  setUser(e) {
@@ -325,12 +383,37 @@ class Ae {
325
383
  clearSession() {
326
384
  this.clearTokens(), this.clearUser();
327
385
  }
386
+ /**
387
+ * Decode JWT token and extract payload
388
+ * Returns null if token is invalid or cannot be decoded
389
+ */
390
+ getTokenPayload() {
391
+ try {
392
+ const e = this.getTokens();
393
+ if (!(e != null && e.accessToken)) return null;
394
+ const t = e.accessToken.split(".");
395
+ if (t.length !== 3) return null;
396
+ const r = t[1], s = atob(r.replace(/-/g, "+").replace(/_/g, "/"));
397
+ return JSON.parse(s);
398
+ } catch {
399
+ return null;
400
+ }
401
+ }
402
+ /**
403
+ * Get userId from token (source of truth) or fallback to stored user
404
+ */
405
+ getUserId() {
406
+ const e = this.getTokenPayload();
407
+ if (e != null && e.userId) return e.userId;
408
+ const t = this.getUser();
409
+ return (t == null ? void 0 : t.id) || null;
410
+ }
328
411
  hasValidSession() {
329
412
  const e = this.getTokens();
330
413
  return e !== null && !this.isTokenExpired(e);
331
414
  }
332
415
  }
333
- class Pe {
416
+ class Ne {
334
417
  constructor(e) {
335
418
  this.httpService = e;
336
419
  }
@@ -354,6 +437,18 @@ class Pe {
354
437
  async requestPasswordReset(e) {
355
438
  await this.httpService.post("/auth/password-reset/request", e);
356
439
  }
440
+ async sendMagicLink(e) {
441
+ return await this.httpService.post(
442
+ "/auth/magic-link/send",
443
+ e
444
+ );
445
+ }
446
+ async verifyMagicLink(e) {
447
+ return await this.httpService.post(
448
+ "/auth/magic-link/verify",
449
+ e
450
+ );
451
+ }
357
452
  async confirmPasswordReset(e) {
358
453
  await this.httpService.post("/auth/password-reset/confirm", e);
359
454
  }
@@ -364,7 +459,7 @@ class Pe {
364
459
  });
365
460
  }
366
461
  }
367
- class ce {
462
+ class Se {
368
463
  constructor(e, t) {
369
464
  this.httpService = e, this.sessionManager = t;
370
465
  }
@@ -404,10 +499,10 @@ class ce {
404
499
  async getRolesByApp(e, t) {
405
500
  const r = new URLSearchParams();
406
501
  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);
407
- const n = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
502
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
408
503
  return {
409
- roles: o.data,
410
- meta: o.meta
504
+ roles: a.data,
505
+ meta: a.meta
411
506
  };
412
507
  }
413
508
  async assignRole(e, t) {
@@ -429,18 +524,18 @@ class ce {
429
524
  async getUserRoles(e, t) {
430
525
  if (!this.sessionManager)
431
526
  throw new Error("SessionManager is required for private endpoints");
432
- const r = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
433
- t != null && t.page && n.append("page", t.page.toString()), t != null && t.limit && n.append("limit", t.limit.toString()), t != null && t.sortBy && n.append("sortBy", t.sortBy), t != null && t.sortOrder && n.append("sortOrder", t.sortOrder);
434
- const o = `/roles/user/${e}${n.toString() ? `?${n.toString()}` : ""}`, m = await this.httpService.get(o, {
527
+ const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
528
+ 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);
529
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(a, {
435
530
  headers: r
436
531
  });
437
532
  return {
438
- roles: m.data,
439
- meta: m.meta
533
+ roles: p.data,
534
+ meta: p.meta
440
535
  };
441
536
  }
442
537
  }
443
- class ke {
538
+ class Be {
444
539
  constructor(e, t) {
445
540
  this.httpService = e, this.sessionManager = t;
446
541
  }
@@ -453,12 +548,12 @@ class ke {
453
548
  async getUsers(e) {
454
549
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
455
550
  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);
456
- const n = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
551
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
457
552
  headers: t
458
553
  });
459
554
  return {
460
- users: o.data,
461
- meta: o.meta
555
+ users: a.data,
556
+ meta: a.meta
462
557
  };
463
558
  }
464
559
  async getUserById(e) {
@@ -480,7 +575,7 @@ class ke {
480
575
  });
481
576
  }
482
577
  }
483
- class de {
578
+ class ce {
484
579
  constructor(e, t, r) {
485
580
  this.httpService = e, this.appId = t, this.sessionManager = r;
486
581
  }
@@ -497,12 +592,12 @@ class de {
497
592
  throw new Error("SessionManager is required for private endpoints");
498
593
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
499
594
  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 n = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
595
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
501
596
  headers: t
502
597
  });
503
598
  return {
504
- tenants: o.data,
505
- meta: o.meta
599
+ tenants: a.data,
600
+ meta: a.meta
506
601
  };
507
602
  }
508
603
  async getTenantById(e) {
@@ -558,7 +653,7 @@ class de {
558
653
  )).data;
559
654
  }
560
655
  }
561
- const fe = te(null), Te = () => /* @__PURE__ */ s(
656
+ const Pe = de(null), Ue = () => /* @__PURE__ */ n(
562
657
  "div",
563
658
  {
564
659
  style: {
@@ -568,9 +663,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
568
663
  height: "100vh",
569
664
  fontFamily: "system-ui, sans-serif"
570
665
  },
571
- children: /* @__PURE__ */ s("div", { children: "Loading tenant..." })
666
+ children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
667
  }
573
- ), Me = ({ error: i, retry: e }) => /* @__PURE__ */ c(
668
+ ), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
574
669
  "div",
575
670
  {
576
671
  style: {
@@ -584,9 +679,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
584
679
  padding: "20px"
585
680
  },
586
681
  children: [
587
- /* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
588
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
589
- /* @__PURE__ */ s(
682
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
683
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
684
+ /* @__PURE__ */ n(
590
685
  "button",
591
686
  {
592
687
  onClick: e,
@@ -604,77 +699,134 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
604
699
  ]
605
700
  }
606
701
  );
607
- function rt({ config: i, children: e }) {
608
- const { baseUrl: t, appInfo: r, appId: n } = se(), [o, m] = b(i.initialTenant || null), [T, M] = b(!i.initialTenant), [P, g] = b(null), [h, x] = b(null), [p, A] = b(!1), [F, f] = b(null), L = Z(() => {
609
- const d = i.tenantMode || "selector", w = "tenant";
702
+ function xt({ config: i, children: e }) {
703
+ const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
704
+ const o = i.tenantMode || "selector", g = "tenant";
610
705
  if (typeof window > "u") return null;
611
- if (d === "subdomain") {
612
- const a = window.location.hostname.split(".");
613
- if (a.length >= 3) {
614
- const l = a[0];
615
- return localStorage.setItem(w, l), l;
706
+ if (o === "subdomain") {
707
+ const d = window.location.hostname.split(".");
708
+ if (d.length >= 3) {
709
+ const c = d[0];
710
+ return localStorage.setItem(g, c), c;
616
711
  }
617
- return localStorage.getItem(w);
618
- } else if (d === "selector") {
619
- const a = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
620
- return a ? (localStorage.setItem(w, a), a) : localStorage.getItem(w);
712
+ return localStorage.getItem(g);
713
+ } else if (o === "selector") {
714
+ const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
715
+ return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
621
716
  }
622
717
  return null;
623
- }, [i.tenantMode, i.selectorParam]), y = z(() => L(), [L]), S = (r == null ? void 0 : r.settingsSchema) || null, k = Z(
624
- async (d) => {
718
+ }, [i.tenantMode, i.selectorParam]), [p, I] = v(() => a()), A = Q(
719
+ () => {
720
+ var o, g, f;
721
+ return {
722
+ enabled: ((o = i.cache) == null ? void 0 : o.enabled) ?? !0,
723
+ ttl: ((g = i.cache) == null ? void 0 : g.ttl) ?? 5 * 60 * 1e3,
724
+ // 5 minutes default
725
+ storageKey: ((f = i.cache) == null ? void 0 : f.storageKey) ?? `tenant_cache_${p || "default"}`
726
+ };
727
+ },
728
+ [i.cache, p]
729
+ ), [x, P] = v(() => {
730
+ if (i.initialTenant) return i.initialTenant;
731
+ if (!A.enabled || !p) return null;
732
+ try {
733
+ const o = localStorage.getItem(A.storageKey);
734
+ if (!o) return null;
735
+ const g = JSON.parse(o);
736
+ return Date.now() - g.timestamp < A.ttl && g.tenantSlug === p ? g.data : (localStorage.removeItem(A.storageKey), null);
737
+ } catch {
738
+ return null;
739
+ }
740
+ }), [b, m] = v(!x && !i.initialTenant), [h, S] = v(null), [L, C] = v(null), [q, k] = v(!1), [u, T] = v(null);
741
+ te(() => {
742
+ const o = a();
743
+ I(o);
744
+ }, [a]);
745
+ const R = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
746
+ async (o, g = !1) => {
747
+ if (!(!g && A.enabled && x && x.domain === o))
748
+ try {
749
+ m(!0), S(null);
750
+ const f = new re(t), c = await new ce(f, s).getPublicTenantInfo(o);
751
+ if (P(c), A.enabled)
752
+ try {
753
+ const y = {
754
+ data: c,
755
+ timestamp: Date.now(),
756
+ tenantSlug: o
757
+ };
758
+ localStorage.setItem(A.storageKey, JSON.stringify(y));
759
+ } catch (y) {
760
+ console.warn("Failed to cache tenant info:", y);
761
+ }
762
+ } catch (f) {
763
+ const d = f instanceof Error ? f : new Error("Failed to load tenant information");
764
+ S(d), P(null);
765
+ } finally {
766
+ m(!1);
767
+ }
768
+ },
769
+ [t, s, A, x]
770
+ ), G = ne(async () => {
771
+ if (!(!A.enabled || !x || !p))
625
772
  try {
626
- M(!0), g(null);
627
- const w = new G(t), a = await new de(w, n).getPublicTenantInfo(d);
628
- m(a);
629
- } catch (w) {
630
- const u = w instanceof Error ? w : new Error("Failed to load tenant information");
631
- g(u), m(null);
632
- } finally {
633
- M(!1);
773
+ const o = localStorage.getItem(A.storageKey);
774
+ if (!o) return;
775
+ const g = JSON.parse(o);
776
+ if (Date.now() - g.timestamp > A.ttl * 0.5) {
777
+ const d = new re(t), y = await new ce(d, s).getPublicTenantInfo(p);
778
+ P(y);
779
+ const W = {
780
+ data: y,
781
+ timestamp: Date.now(),
782
+ tenantSlug: p
783
+ };
784
+ localStorage.setItem(A.storageKey, JSON.stringify(W));
785
+ }
786
+ } catch (o) {
787
+ console.warn("Background tenant refresh failed:", o);
634
788
  }
635
- },
636
- [t, n]
637
- ), R = Z(async () => {
638
- if (o != null && o.id)
789
+ }, [t, s, A, x, p]), F = ne(async () => {
790
+ if (x != null && x.id)
639
791
  try {
640
- A(!0), f(null);
641
- const d = new G(t), u = await new de(d, o.appId).getTenantSettings(o.id);
642
- x(u);
643
- } catch (d) {
644
- const w = d instanceof Error ? d : new Error("Failed to load tenant settings");
645
- f(w), x(null);
792
+ k(!0), T(null);
793
+ const o = new re(t), f = await new ce(o, x.appId).getTenantSettings(x.id);
794
+ C(f);
795
+ } catch (o) {
796
+ const g = o instanceof Error ? o : new Error("Failed to load tenant settings");
797
+ T(g), C(null);
646
798
  } finally {
647
- A(!1);
799
+ k(!1);
648
800
  }
649
- }, [t, o]), D = Z(() => {
650
- R();
651
- }, [R]), E = Z(
652
- (d) => {
653
- if (!S)
801
+ }, [t, x]), V = ne(() => {
802
+ F();
803
+ }, [F]), w = ne(
804
+ (o) => {
805
+ if (!R)
654
806
  return { isValid: !0, errors: [] };
655
- const w = [];
807
+ const g = [];
656
808
  try {
657
- return S.properties && Object.entries(S.properties).forEach(([u, a]) => {
658
- var W;
659
- const l = d[u];
660
- if ((W = S.required) != null && W.includes(u) && l == null) {
661
- w.push(`Field '${u}' is required`);
809
+ return R.properties && Object.entries(R.properties).forEach(([f, d]) => {
810
+ var y;
811
+ const c = o[f];
812
+ if ((y = R.required) != null && y.includes(f) && c == null) {
813
+ g.push(`Field '${f}' is required`);
662
814
  return;
663
815
  }
664
- if (l != null) {
665
- if (a.type) {
666
- const I = a.type, N = typeof l;
667
- I === "string" && N !== "string" ? w.push(`Field '${u}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${u}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${u}' must be a boolean`) : I === "array" && !Array.isArray(l) && w.push(`Field '${u}' must be an array`);
816
+ if (c != null) {
817
+ if (d.type) {
818
+ const W = d.type, ee = typeof c;
819
+ W === "string" && ee !== "string" ? g.push(`Field '${f}' must be a string`) : (W === "number" || W === "integer") && ee !== "number" ? g.push(`Field '${f}' must be a number`) : W === "boolean" && ee !== "boolean" ? g.push(`Field '${f}' must be a boolean`) : W === "array" && !Array.isArray(c) && g.push(`Field '${f}' must be an array`);
668
820
  }
669
- a.minLength !== void 0 && typeof l == "string" && l.length < a.minLength && w.push(
670
- `Field '${u}' must be at least ${a.minLength} characters long`
671
- ), a.maxLength !== void 0 && typeof l == "string" && l.length > a.maxLength && w.push(
672
- `Field '${u}' must be no more than ${a.maxLength} characters long`
673
- ), a.minimum !== void 0 && typeof l == "number" && l < a.minimum && w.push(`Field '${u}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof l == "number" && l > a.maximum && w.push(`Field '${u}' must be no more than ${a.maximum}`), a.pattern && typeof l == "string" && (new RegExp(a.pattern).test(l) || w.push(`Field '${u}' does not match the required pattern`)), a.enum && !a.enum.includes(l) && w.push(`Field '${u}' must be one of: ${a.enum.join(", ")}`);
821
+ d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && g.push(
822
+ `Field '${f}' must be at least ${d.minLength} characters long`
823
+ ), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && g.push(
824
+ `Field '${f}' must be no more than ${d.maxLength} characters long`
825
+ ), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && g.push(`Field '${f}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && g.push(`Field '${f}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || g.push(`Field '${f}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && g.push(`Field '${f}' must be one of: ${d.enum.join(", ")}`);
674
826
  }
675
827
  }), {
676
- isValid: w.length === 0,
677
- errors: w
828
+ isValid: g.length === 0,
829
+ errors: g
678
830
  };
679
831
  } catch {
680
832
  return {
@@ -683,276 +835,378 @@ function rt({ config: i, children: e }) {
683
835
  };
684
836
  }
685
837
  },
686
- [S]
838
+ [R]
687
839
  );
688
- Y(() => {
689
- !i.initialTenant && y ? k(y) : !i.initialTenant && !y && (m(null), g(null), M(!1));
690
- }, [i.initialTenant, y, k]), Y(() => {
691
- o != null && o.id ? R() : (x(null), f(null), A(!1));
692
- }, [o == null ? void 0 : o.id, R]);
693
- const B = z(() => ({
840
+ te(() => {
841
+ !i.initialTenant && p ? x ? G() : H(p) : !i.initialTenant && !p && (P(null), S(null), m(!1));
842
+ }, [i.initialTenant, p, x, H, G]), te(() => {
843
+ x != null && x.id ? F() : (C(null), T(null), k(!1));
844
+ }, [x == null ? void 0 : x.id, F]);
845
+ const M = ne(
846
+ (o, g = "reload") => {
847
+ const f = i.tenantMode || "selector";
848
+ if (console.log("[TenantProvider] Switching tenant:", {
849
+ targetTenantSlug: o,
850
+ currentTenantSlug: p,
851
+ tenantMode: f,
852
+ mode: g
853
+ }), localStorage.setItem("tenant", o), f === "subdomain") {
854
+ const d = window.location.hostname, c = d.split(".");
855
+ if (c.length >= 2) {
856
+ c[0] = o;
857
+ const y = c.join("."), W = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
858
+ console.log("[TenantProvider] Redirecting to:", W), window.location.href = W;
859
+ } else
860
+ console.warn(
861
+ "[TenantProvider] Cannot switch subdomain, invalid hostname:",
862
+ d
863
+ );
864
+ } else if (f === "selector") {
865
+ const d = new URLSearchParams(window.location.search);
866
+ if (d.set(i.selectorParam || "tenant", o), g === "reload") {
867
+ const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
868
+ console.log("[TenantProvider] Reloading with new tenant:", c), window.location.href = c;
869
+ } else {
870
+ const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
871
+ console.log("[TenantProvider] Navigating without reload:", c), window.history.pushState({}, "", c), I(o), H(o);
872
+ }
873
+ }
874
+ },
875
+ [i.tenantMode, i.selectorParam, H, p]
876
+ ), E = Q(() => ({
694
877
  // Tenant info
695
- tenant: o,
696
- tenantSlug: y,
697
- isTenantLoading: T,
698
- tenantError: P,
878
+ tenant: x,
879
+ tenantSlug: p,
880
+ isTenantLoading: b,
881
+ tenantError: h,
699
882
  retryTenant: () => {
700
- y && k(y);
883
+ p && H(p);
701
884
  },
702
885
  // Settings
703
- settings: h,
704
- settingsSchema: S,
705
- isSettingsLoading: p,
706
- settingsError: F,
886
+ settings: L,
887
+ settingsSchema: R,
888
+ isSettingsLoading: q,
889
+ settingsError: u,
707
890
  // Actions
708
- refreshSettings: D,
891
+ refreshSettings: V,
892
+ switchTenant: M,
709
893
  // Validation
710
- validateSettings: E
894
+ validateSettings: w
711
895
  }), [
712
- o,
713
- y,
714
- T,
715
- P,
716
- h,
717
- S,
896
+ x,
718
897
  p,
719
- F,
720
- D,
721
- E
898
+ b,
899
+ h,
900
+ L,
901
+ R,
902
+ q,
903
+ u,
904
+ V,
905
+ M,
906
+ w
722
907
  ]);
723
- if (T)
724
- return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(Te, {}) });
725
- if (P) {
726
- const d = typeof i.errorFallback == "function" ? i.errorFallback(P, () => k(y || "")) : i.errorFallback || /* @__PURE__ */ s(Me, { error: P, retry: () => k(y || "") });
727
- return /* @__PURE__ */ s(H, { children: d });
908
+ if (b)
909
+ return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
910
+ if (h) {
911
+ const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
912
+ return /* @__PURE__ */ n(N, { children: o });
728
913
  }
729
- return /* @__PURE__ */ s(fe.Provider, { value: B, children: e });
914
+ return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
730
915
  }
731
- function le() {
732
- const i = re(fe);
916
+ function fe() {
917
+ const i = ue(Pe);
733
918
  if (!i)
734
919
  throw new Error("useTenant must be used within a TenantProvider");
735
920
  return i;
736
921
  }
737
- const st = le;
738
- function nt() {
739
- const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: n } = le();
922
+ const kt = fe;
923
+ function At() {
924
+ const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
740
925
  return {
741
926
  settings: i,
742
927
  settingsSchema: e,
743
928
  isLoading: t,
744
929
  error: r,
745
- validateSettings: n
930
+ validateSettings: s
746
931
  };
747
932
  }
748
- function K() {
749
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: n } = le();
933
+ function se() {
934
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = fe();
750
935
  return {
751
936
  tenant: i,
752
937
  tenantSlug: e,
753
938
  isLoading: t,
754
939
  error: r,
755
- retry: n
940
+ retry: s
756
941
  };
757
942
  }
758
- const ye = te(null);
759
- function it({ config: i = {}, children: e }) {
760
- const { appId: t, baseUrl: r } = se(), n = K(), o = (n == null ? void 0 : n.tenantSlug) || null, [m, T] = b(i.initialRoles || []), [M, P] = b(!i.initialRoles), [g, h] = b(null), [x, p] = b(!1), [A, F] = b(null), f = z(() => {
761
- const d = o ? `auth_tokens_${o}` : "auth_tokens", w = {
762
- get: () => {
763
- try {
764
- const u = localStorage.getItem(d);
765
- return u ? JSON.parse(u) : null;
766
- } catch {
767
- return null;
768
- }
769
- },
770
- set: (u) => {
771
- try {
772
- localStorage.setItem(d, JSON.stringify(u));
773
- } catch {
943
+ const Te = de(null);
944
+ function Pt({ config: i = {}, children: e }) {
945
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: a, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, P] = v(!i.initialRoles), [b, m] = v(null), [h, S] = v(!1), [L, C] = v(null), [q, k] = v(0), u = Q(() => new ye({
946
+ tenantSlug: a,
947
+ // SessionManager will generate storageKey internally
948
+ onRefreshFailed: i.onRefreshFailed,
949
+ baseUrl: r
950
+ }), [a, r, i.onRefreshFailed]), T = Q(() => {
951
+ const g = new re(r);
952
+ return g.setSessionManager(u), g;
953
+ }, [r, u]), R = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(T, u), [T, u]), G = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, o = Q(() => {
954
+ const g = async ($ = !1) => {
955
+ try {
956
+ if (!u.hasValidSession())
957
+ return;
958
+ const U = Date.now();
959
+ if (!$ && U - q < E && b)
960
+ return;
961
+ const j = u.getUserId();
962
+ if (!j) {
963
+ console.warn("[AuthProvider] No userId available in token or storage");
964
+ return;
774
965
  }
775
- },
776
- clear: () => {
966
+ S(!0), C(null);
967
+ const X = await H.getUserById(j);
968
+ m(X), u.setUser(X), k(Date.now());
969
+ } catch (U) {
970
+ const K = U instanceof Error ? U : new Error("Failed to load user data");
971
+ C(K), console.error("[AuthProvider] Failed to load user data:", K);
972
+ } finally {
973
+ S(!1);
974
+ }
975
+ }, f = async () => {
976
+ await g();
977
+ }, d = async ($) => {
978
+ const { username: U, password: K, tenantSlug: j } = $;
979
+ let X = s == null ? void 0 : s.id, Y = a, Z = u;
980
+ j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
981
+ const J = await R.login({
982
+ username: U,
983
+ password: K,
984
+ appId: t,
985
+ tenantId: X
986
+ }), ae = j && j !== a;
987
+ if (ae && (Z = new ye({
988
+ tenantSlug: Y,
989
+ baseUrl: r
990
+ })), Z.setTokens({
991
+ accessToken: J.accessToken,
992
+ refreshToken: J.refreshToken,
993
+ expiresIn: J.expiresIn
994
+ }), J.user) {
995
+ Z.setUser(J.user), m(J.user);
777
996
  try {
778
- localStorage.removeItem(d);
779
- } catch {
997
+ await g();
998
+ } catch (le) {
999
+ console.warn("Failed to load complete user data after login:", le);
780
1000
  }
781
1001
  }
782
- };
783
- return new Ae({
784
- onRefreshFailed: i.onRefreshFailed,
785
- tokenStorage: w,
786
- baseUrl: r
787
- });
788
- }, [o, r, i.onRefreshFailed]), L = z(() => {
789
- const d = new G(r);
790
- return d.setSessionManager(f), d;
791
- }, [r, f]), y = z(() => new Pe(new G(r)), [r]), S = z(() => new ke(L, f), [L, f]), k = z(() => new ce(new G(r)), [r]), R = z(() => g || f.getUser(), [g, f]), D = z(() => R != null && R.roleId && m.find((d) => d.id === R.roleId) || null, [R, m]), E = z(() => (D == null ? void 0 : D.permissions) || [], [D]);
792
- Y(() => {
793
- console.log("AuthProvider - userPermissions changed:", E);
794
- }, [E]);
795
- const B = z(() => {
796
- const d = async () => {
797
- try {
798
- p(!0), F(null);
799
- const v = f.getUser();
800
- if (!(v != null && v.id))
801
- throw new Error("No user ID available in session");
802
- const $ = await S.getUserById(v.id);
803
- h($), f.setUser($);
804
- } catch (v) {
805
- const $ = v instanceof Error ? v : new Error("Failed to load user data");
806
- F($), console.error("Failed to load user data:", $);
807
- } finally {
808
- p(!1);
809
- }
810
- }, w = async () => {
811
- await d();
812
- }, u = async (v, $, J) => {
813
- const V = await y.login({
814
- email: v,
815
- password: $,
816
- tenantId: J
1002
+ return ae && Y && Y !== a && p(Y), J;
1003
+ }, c = async ($) => {
1004
+ const { email: U, phoneNumber: K, name: j, password: X, lastName: Y, tenantId: Z } = $;
1005
+ if (!U && !K)
1006
+ throw new Error("Either email or phoneNumber is required");
1007
+ if (!j || !X)
1008
+ throw new Error("Name and password are required");
1009
+ const J = Z ?? (s == null ? void 0 : s.id);
1010
+ return await R.signup({
1011
+ email: U,
1012
+ phoneNumber: K,
1013
+ name: j,
1014
+ password: X,
1015
+ tenantId: J,
1016
+ lastName: Y,
1017
+ appId: t
1018
+ });
1019
+ }, y = async ($) => {
1020
+ const { email: U, phoneNumber: K, name: j, password: X, tenantName: Y, lastName: Z } = $;
1021
+ if (!U && !K)
1022
+ throw new Error("Either email or phoneNumber is required");
1023
+ if (!j || !X || !Y)
1024
+ throw new Error("Name, password, and tenantName are required");
1025
+ return await R.signupTenantAdmin({
1026
+ email: U,
1027
+ phoneNumber: K,
1028
+ name: j,
1029
+ password: X,
1030
+ tenantName: Y,
1031
+ appId: t,
1032
+ lastName: Z
817
1033
  });
818
- if (f.setTokens({
819
- accessToken: V.accessToken,
820
- refreshToken: V.refreshToken,
821
- expiresIn: V.expiresIn
822
- }), V.user) {
823
- f.setUser(V.user), h(V.user);
1034
+ }, W = async ($) => {
1035
+ const { currentPassword: U, newPassword: K } = $, j = await u.getAuthHeaders();
1036
+ await R.changePassword({ currentPassword: U, newPassword: K }, j);
1037
+ }, ee = async ($) => {
1038
+ const { email: U, tenantId: K } = $, j = K ?? (s == null ? void 0 : s.id);
1039
+ if (!j)
1040
+ throw new Error("tenantId is required for password reset");
1041
+ await R.requestPasswordReset({ email: U, tenantId: j });
1042
+ }, z = async ($) => {
1043
+ const { token: U, newPassword: K } = $;
1044
+ await R.confirmPasswordReset({ token: U, newPassword: K });
1045
+ }, B = async ($) => {
1046
+ const { email: U, frontendUrl: K, name: j, lastName: X, tenantId: Y } = $, Z = Y ?? (s == null ? void 0 : s.id);
1047
+ if (!Z)
1048
+ throw new Error("tenantId is required for magic link authentication");
1049
+ return await R.sendMagicLink({
1050
+ email: U,
1051
+ tenantId: Z,
1052
+ frontendUrl: K,
1053
+ name: j,
1054
+ lastName: X,
1055
+ appId: t
1056
+ });
1057
+ }, O = async ($) => {
1058
+ const { token: U, email: K, tenantSlug: j } = $;
1059
+ let X = s == null ? void 0 : s.id, Y = a, Z = u;
1060
+ j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
1061
+ const J = await R.verifyMagicLink({
1062
+ token: U,
1063
+ email: K,
1064
+ appId: t,
1065
+ tenantId: X
1066
+ }), ae = j && j !== a;
1067
+ if (ae && (Z = new ye({
1068
+ tenantSlug: Y,
1069
+ baseUrl: r
1070
+ })), Z.setTokens({
1071
+ accessToken: J.accessToken,
1072
+ refreshToken: J.refreshToken,
1073
+ expiresIn: J.expiresIn
1074
+ }), J.user) {
1075
+ Z.setUser(J.user), m(J.user);
824
1076
  try {
825
- await d();
826
- } catch (ee) {
827
- console.warn("Failed to load complete user data after login:", ee);
1077
+ await g();
1078
+ } catch (le) {
1079
+ console.warn("Failed to load complete user data after magic link login:", le);
828
1080
  }
829
1081
  }
830
- return V;
831
- }, a = async (v, $, J, V, ee) => await y.signup({
832
- email: v,
833
- name: $,
834
- password: J,
835
- tenantId: V,
836
- lastName: ee
837
- }), l = async (v, $, J, V, ee) => await y.signupTenantAdmin({
838
- email: v,
839
- name: $,
840
- password: J,
841
- tenantName: V,
842
- appId: t,
843
- lastName: ee
844
- }), W = async (v, $) => {
845
- const J = await f.getAuthHeaders();
846
- await y.changePassword({ currentPassword: v, newPassword: $ }, J);
847
- }, I = async (v, $) => {
848
- await y.requestPasswordReset({ email: v, tenantId: $ });
849
- }, N = async (v, $) => {
850
- await y.confirmPasswordReset({ token: v, newPassword: $ });
851
- }, _ = async () => {
852
- const v = f.getTokens();
853
- if (!(v != null && v.refreshToken))
1082
+ return ae && Y && Y !== a && p(Y), J;
1083
+ }, D = async () => {
1084
+ const $ = u.getTokens();
1085
+ if (!($ != null && $.refreshToken))
854
1086
  throw new Error("No refresh token available");
855
- const $ = await y.refreshToken({
856
- refreshToken: v.refreshToken
1087
+ const U = await R.refreshToken({
1088
+ refreshToken: $.refreshToken
857
1089
  });
858
- f.setTokens({
859
- accessToken: $.accessToken,
860
- refreshToken: $.refreshToken || v.refreshToken,
861
- expiresIn: $.expiresIn
1090
+ u.setTokens({
1091
+ accessToken: U.accessToken,
1092
+ refreshToken: U.refreshToken || $.refreshToken,
1093
+ expiresIn: U.expiresIn
862
1094
  });
863
- }, C = () => {
864
- f.clearSession(), h(null), F(null);
865
- }, U = (v) => {
866
- f.setTokens(v);
867
- }, Q = () => f.hasValidSession(), q = () => {
868
- f.clearSession(), h(null), F(null);
869
- }, O = async () => {
1095
+ }, _ = () => {
1096
+ u.clearSession(), m(null), C(null);
1097
+ }, ge = ($) => {
1098
+ u.setTokens($);
1099
+ }, Re = () => u.hasValidSession(), Ce = () => {
1100
+ u.clearSession(), m(null), C(null);
1101
+ }, Le = async () => {
870
1102
  if (t)
871
1103
  try {
872
1104
  P(!0);
873
- const { roles: v } = await k.getRolesByApp(t);
874
- T(v);
875
- } catch (v) {
876
- console.error("Failed to fetch roles:", v);
1105
+ const { roles: $ } = await G.getRolesByApp(t);
1106
+ A($);
1107
+ } catch ($) {
1108
+ console.error("Failed to fetch roles:", $);
877
1109
  } finally {
878
1110
  P(!1);
879
1111
  }
880
- }, j = async () => {
881
- await O();
882
- }, oe = (v) => {
883
- if (!E || E.length === 0)
1112
+ }, Fe = async () => {
1113
+ await Le();
1114
+ }, me = ($) => {
1115
+ if (!w || w.length === 0)
884
1116
  return !1;
885
- if (typeof v == "string")
886
- return E.includes(v);
887
- const $ = `${v.resource}.${v.action}`;
888
- return E.includes($);
1117
+ if (typeof $ == "string")
1118
+ return w.includes($);
1119
+ const U = `${$.resource}.${$.action}`;
1120
+ return w.includes(U);
889
1121
  };
890
1122
  return {
891
- sessionManager: f,
892
- authenticatedHttpService: L,
893
- login: u,
894
- signup: a,
895
- signupTenantAdmin: l,
1123
+ // RFC-003: Authentication state
1124
+ isAuthenticated: M,
1125
+ sessionManager: u,
1126
+ authenticatedHttpService: T,
1127
+ login: d,
1128
+ signup: c,
1129
+ signupTenantAdmin: y,
1130
+ sendMagicLink: B,
1131
+ verifyMagicLink: O,
896
1132
  changePassword: W,
897
- requestPasswordReset: I,
898
- confirmPasswordReset: N,
899
- refreshToken: _,
900
- logout: C,
901
- setTokens: U,
902
- hasValidSession: Q,
903
- clearSession: q,
904
- currentUser: g,
905
- isUserLoading: x,
906
- userError: A,
907
- refreshUser: w,
908
- userRole: D,
909
- userPermissions: E,
910
- availableRoles: m,
911
- rolesLoading: M,
912
- hasPermission: oe,
913
- hasAnyPermission: (v) => v.some(($) => oe($)),
914
- hasAllPermissions: (v) => v.every(($) => oe($)),
915
- getUserPermissionStrings: () => E || [],
916
- refreshRoles: j
1133
+ requestPasswordReset: ee,
1134
+ confirmPasswordReset: z,
1135
+ refreshToken: D,
1136
+ logout: _,
1137
+ setTokens: ge,
1138
+ hasValidSession: Re,
1139
+ clearSession: Ce,
1140
+ currentUser: b,
1141
+ isUserLoading: h,
1142
+ userError: L,
1143
+ loadUserData: g,
1144
+ refreshUser: f,
1145
+ userRole: V,
1146
+ userPermissions: w,
1147
+ availableRoles: I,
1148
+ rolesLoading: x,
1149
+ hasPermission: me,
1150
+ hasAnyPermission: ($) => $.some((U) => me(U)),
1151
+ hasAllPermissions: ($) => $.every((U) => me(U)),
1152
+ getUserPermissionStrings: () => w || [],
1153
+ refreshRoles: Fe
917
1154
  };
918
1155
  }, [
919
- f,
920
- L,
921
- y,
922
- S,
923
- k,
1156
+ M,
1157
+ u,
1158
+ T,
1159
+ R,
1160
+ H,
1161
+ G,
924
1162
  t,
925
- m,
926
- g,
927
- x,
928
- A,
929
- D,
1163
+ s,
1164
+ a,
1165
+ p,
1166
+ I,
1167
+ b,
1168
+ h,
1169
+ L,
1170
+ V,
1171
+ w,
1172
+ q,
930
1173
  E
931
1174
  ]);
932
- return Y(() => {
1175
+ return te(() => {
933
1176
  !i.initialRoles && t && (async () => {
934
1177
  try {
935
1178
  P(!0);
936
- const w = new G(r), u = new ce(w), { roles: a } = await u.getRolesByApp(t);
937
- T(a);
938
- } catch (w) {
939
- console.error("Failed to fetch roles:", w);
1179
+ const f = new re(r), d = new Se(f), { roles: c } = await d.getRolesByApp(t);
1180
+ A(c);
1181
+ } catch (f) {
1182
+ console.error("Failed to fetch roles:", f);
940
1183
  } finally {
941
1184
  P(!1);
942
1185
  }
943
1186
  })();
944
- }, [t, r, i.initialRoles]), Y(() => {
945
- const d = f.getUser();
946
- d && f.hasValidSession() && h(d);
947
- }, [f]), /* @__PURE__ */ s(ye.Provider, { value: B, children: e });
1187
+ }, [t, r, i.initialRoles]), te(() => {
1188
+ const g = u.getUser();
1189
+ g && u.hasValidSession() && m(g);
1190
+ }, [u]), te(() => {
1191
+ !b && !h && o.loadUserData().catch(() => {
1192
+ });
1193
+ }, [b, h, o]), te(() => {
1194
+ if (!u.hasValidSession() || !b)
1195
+ return;
1196
+ const g = setInterval(() => {
1197
+ o.loadUserData().catch(() => {
1198
+ });
1199
+ }, E);
1200
+ return () => clearInterval(g);
1201
+ }, [u, b, o, E]), /* @__PURE__ */ n(Te.Provider, { value: o, children: e });
948
1202
  }
949
- function ne() {
950
- const i = re(ye);
1203
+ function oe() {
1204
+ const i = ue(Te);
951
1205
  if (!i)
952
1206
  throw new Error("useAuth must be used within an AuthProvider");
953
1207
  return i;
954
1208
  }
955
- class Ee {
1209
+ class ze {
956
1210
  constructor(e, t) {
957
1211
  this.httpService = e, this.sessionManager = t;
958
1212
  }
@@ -973,12 +1227,12 @@ class Ee {
973
1227
  throw new Error("SessionManager is required for private endpoints");
974
1228
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
975
1229
  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);
976
- const n = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
1230
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
977
1231
  headers: t
978
1232
  });
979
1233
  return {
980
- featureFlags: o.data,
981
- meta: o.meta
1234
+ featureFlags: a.data,
1235
+ meta: a.meta
982
1236
  };
983
1237
  }
984
1238
  async getFeatureFlagById(e) {
@@ -1015,8 +1269,8 @@ class Ee {
1015
1269
  throw new Error("Tenant ID and App ID are required");
1016
1270
  const r = new URLSearchParams();
1017
1271
  r.append("tenantId", e), r.append("appId", t);
1018
- const n = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
1019
- return (await this.httpService.get(n, {
1272
+ const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
1273
+ return (await this.httpService.get(s, {
1020
1274
  headers: { "X-Tenant-ID": e }
1021
1275
  })).data;
1022
1276
  }
@@ -1024,66 +1278,66 @@ class Ee {
1024
1278
  async getTenantFeatureFlag(e, t, r) {
1025
1279
  if (!e || !t || !r)
1026
1280
  throw new Error("Flag Key, Tenant ID and App ID are required");
1027
- const n = new URLSearchParams();
1028
- n.append("tenantId", t), n.append("appId", r);
1029
- const o = `/tenant-feature-flags/${e}${n.toString() ? `?${n.toString()}` : ""}`;
1030
- return (await this.httpService.get(o, {
1281
+ const s = new URLSearchParams();
1282
+ s.append("tenantId", t), s.append("appId", r);
1283
+ const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1284
+ return (await this.httpService.get(a, {
1031
1285
  headers: { "X-Tenant-ID": t }
1032
1286
  })).data;
1033
1287
  }
1034
1288
  }
1035
- const we = te(null);
1036
- function ot({ config: i = {}, children: e }) {
1037
- const { baseUrl: t, appId: r } = se(), { tenant: n } = K(), [o, m] = b([]), [T, M] = b(!1), [P, g] = b(null), h = z(() => {
1038
- const A = new G(t);
1039
- return new Ee(A);
1040
- }, [t]), x = async () => {
1041
- if (!(n != null && n.id)) {
1042
- m([]);
1289
+ const Me = de(null);
1290
+ function Tt({ config: i = {}, children: e }) {
1291
+ const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [a, p] = v([]), [I, A] = v(!1), [x, P] = v(null), b = Q(() => {
1292
+ const S = new re(t);
1293
+ return new ze(S);
1294
+ }, [t]), m = async () => {
1295
+ if (!(s != null && s.id)) {
1296
+ p([]);
1043
1297
  return;
1044
1298
  }
1045
- M(!0), g(null);
1299
+ A(!0), P(null);
1046
1300
  try {
1047
- const A = await h.getTenantFeatureFlags(n.id, r);
1048
- m(A);
1049
- } catch (A) {
1050
- const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
1051
- g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
1301
+ const S = await b.getTenantFeatureFlags(s.id, r);
1302
+ p(S);
1303
+ } catch (S) {
1304
+ const L = S instanceof Error ? S.message : "Failed to fetch feature flags";
1305
+ P(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
1052
1306
  } finally {
1053
- M(!1);
1307
+ A(!1);
1054
1308
  }
1055
1309
  };
1056
- Y(() => {
1057
- x();
1058
- const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
1059
- return () => clearInterval(F);
1060
- }, [n == null ? void 0 : n.id, i.refreshInterval]);
1061
- const p = z(() => ({
1062
- featureFlags: o,
1063
- loading: T,
1064
- error: P,
1065
- isEnabled: (y) => {
1066
- const S = o.find((k) => k.key === y);
1067
- return (S == null ? void 0 : S.value) === !0;
1310
+ te(() => {
1311
+ m();
1312
+ const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(m, S);
1313
+ return () => clearInterval(L);
1314
+ }, [s == null ? void 0 : s.id, i.refreshInterval]);
1315
+ const h = Q(() => ({
1316
+ featureFlags: a,
1317
+ loading: I,
1318
+ error: x,
1319
+ isEnabled: (k) => {
1320
+ const u = a.find((T) => T.key === k);
1321
+ return (u == null ? void 0 : u.value) === !0;
1068
1322
  },
1069
- getFlag: (y) => o.find((S) => S.key === y),
1070
- getFlagState: (y) => {
1071
- const S = o.find((k) => k.key === y);
1072
- return S ? S.value ? "enabled" : "disabled" : "not_found";
1323
+ getFlag: (k) => a.find((u) => u.key === k),
1324
+ getFlagState: (k) => {
1325
+ const u = a.find((T) => T.key === k);
1326
+ return u ? u.value ? "enabled" : "disabled" : "not_found";
1073
1327
  },
1074
1328
  refresh: async () => {
1075
- await x();
1329
+ await m();
1076
1330
  }
1077
- }), [o, T, P]);
1078
- return /* @__PURE__ */ s(we.Provider, { value: p, children: e });
1331
+ }), [a, I, x]);
1332
+ return /* @__PURE__ */ n(Me.Provider, { value: h, children: e });
1079
1333
  }
1080
- function Re() {
1081
- const i = re(we);
1334
+ function Oe() {
1335
+ const i = ue(Me);
1082
1336
  if (!i)
1083
1337
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1084
1338
  return i;
1085
1339
  }
1086
- class Fe {
1340
+ class je {
1087
1341
  constructor(e, t) {
1088
1342
  this.httpService = e, this.sessionManager = t;
1089
1343
  }
@@ -1149,64 +1403,64 @@ class Fe {
1149
1403
  )).data;
1150
1404
  }
1151
1405
  }
1152
- const me = te(void 0);
1153
- function at({ config: i = {}, children: e }) {
1154
- const { baseUrl: t } = se(), { tenant: r } = K(), [n, o] = b(null), [m, T] = b(!1), [M, P] = b(null), g = z(() => {
1155
- const p = new G(t);
1156
- return new Fe(p);
1157
- }, [t]), h = async () => {
1406
+ const Ie = de(void 0);
1407
+ function Mt({ config: i = {}, children: e }) {
1408
+ const { baseUrl: t } = he(), { tenant: r } = se(), [s, a] = v(null), [p, I] = v(!1), [A, x] = v(null), P = Q(() => {
1409
+ const h = new re(t);
1410
+ return new je(h);
1411
+ }, [t]), b = async () => {
1158
1412
  if (!(r != null && r.id)) {
1159
- o(null);
1413
+ a(null);
1160
1414
  return;
1161
1415
  }
1162
- T(!0), P(null);
1416
+ I(!0), x(null);
1163
1417
  try {
1164
- const p = await g.getTenantSubscriptionFeatures(r.id);
1165
- o(p);
1166
- } catch (p) {
1167
- const A = p instanceof Error ? p.message : "Failed to fetch subscription";
1168
- P(A), i.onError && i.onError(p instanceof Error ? p : new Error(A));
1418
+ const h = await P.getTenantSubscriptionFeatures(r.id);
1419
+ a(h);
1420
+ } catch (h) {
1421
+ const S = h instanceof Error ? h.message : "Failed to fetch subscription";
1422
+ x(S), i.onError && i.onError(h instanceof Error ? h : new Error(S));
1169
1423
  } finally {
1170
- T(!1);
1424
+ I(!1);
1171
1425
  }
1172
1426
  };
1173
- Y(() => {
1174
- if (h(), !i.refreshInterval) return;
1175
- const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
1176
- return () => clearInterval(A);
1427
+ te(() => {
1428
+ if (b(), !i.refreshInterval) return;
1429
+ const h = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(b, h);
1430
+ return () => clearInterval(S);
1177
1431
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1178
- const x = z(() => {
1179
- const p = (n == null ? void 0 : n.features) || [];
1432
+ const m = Q(() => {
1433
+ const h = (s == null ? void 0 : s.features) || [];
1180
1434
  return {
1181
- subscription: n,
1182
- features: p,
1183
- loading: m,
1184
- error: M,
1185
- isFeatureEnabled: (S) => {
1186
- const k = p.find((R) => R.key === S);
1187
- return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
1435
+ subscription: s,
1436
+ features: h,
1437
+ loading: p,
1438
+ error: A,
1439
+ isFeatureEnabled: (u) => {
1440
+ const T = h.find((R) => R.key === u);
1441
+ return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
1188
1442
  },
1189
- getFeature: (S) => p.find((k) => k.key === S),
1190
- getFeatureValue: (S, k) => {
1191
- const R = p.find((D) => D.key === S);
1192
- return R ? R.value : k;
1443
+ getFeature: (u) => h.find((T) => T.key === u),
1444
+ getFeatureValue: (u, T) => {
1445
+ const R = h.find((H) => H.key === u);
1446
+ return R ? R.value : T;
1193
1447
  },
1194
- hasAllowedPlan: (S) => !n || !n.isActive ? !1 : S.includes(n.planId),
1448
+ hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
1195
1449
  refresh: async () => {
1196
- await h();
1450
+ await b();
1197
1451
  }
1198
1452
  };
1199
- }, [n, m, M]);
1200
- return /* @__PURE__ */ s(me.Provider, { value: x, children: e });
1453
+ }, [s, p, A]);
1454
+ return /* @__PURE__ */ n(Ie.Provider, { value: m, children: e });
1201
1455
  }
1202
- function Ie() {
1203
- const i = re(me);
1456
+ function Ve() {
1457
+ const i = ue(Ie);
1204
1458
  if (i === void 0)
1205
1459
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1206
1460
  return i;
1207
1461
  }
1208
- var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
1209
- const ue = () => /* @__PURE__ */ c(
1462
+ var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
1463
+ const ve = () => /* @__PURE__ */ l(
1210
1464
  "div",
1211
1465
  {
1212
1466
  style: {
@@ -1222,10 +1476,10 @@ const ue = () => /* @__PURE__ */ c(
1222
1476
  margin: "20px 0"
1223
1477
  },
1224
1478
  children: [
1225
- /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1226
- /* @__PURE__ */ s("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1227
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1228
- /* @__PURE__ */ s(
1479
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1480
+ /* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1481
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1482
+ /* @__PURE__ */ n(
1229
1483
  "button",
1230
1484
  {
1231
1485
  style: {
@@ -1243,11 +1497,11 @@ const ue = () => /* @__PURE__ */ c(
1243
1497
  )
1244
1498
  ]
1245
1499
  }
1246
- ), he = ({
1500
+ ), xe = ({
1247
1501
  userType: i,
1248
1502
  minUserType: e,
1249
1503
  missingPermissions: t
1250
- }) => /* @__PURE__ */ c(
1504
+ }) => /* @__PURE__ */ l(
1251
1505
  "div",
1252
1506
  {
1253
1507
  style: {
@@ -1263,57 +1517,57 @@ const ue = () => /* @__PURE__ */ c(
1263
1517
  margin: "20px 0"
1264
1518
  },
1265
1519
  children: [
1266
- /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1267
- /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1268
- e && i ? /* @__PURE__ */ c(H, { children: [
1269
- /* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1520
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1521
+ /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1522
+ e && i ? /* @__PURE__ */ l(N, { children: [
1523
+ /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1270
1524
  "This content requires ",
1271
- /* @__PURE__ */ s("strong", { children: e }),
1525
+ /* @__PURE__ */ n("strong", { children: e }),
1272
1526
  " access level or higher."
1273
1527
  ] }),
1274
- /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1528
+ /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1275
1529
  "Your current access level: ",
1276
- /* @__PURE__ */ s("strong", { children: i })
1530
+ /* @__PURE__ */ n("strong", { children: i })
1277
1531
  ] })
1278
- ] }) : /* @__PURE__ */ c(H, { children: [
1279
- /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1280
- t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1532
+ ] }) : /* @__PURE__ */ l(N, { children: [
1533
+ /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1534
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1281
1535
  "Required permissions: ",
1282
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1536
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1283
1537
  ] })
1284
1538
  ] })
1285
1539
  ]
1286
1540
  }
1287
- ), He = (i, e) => {
1541
+ ), We = (i, e) => {
1288
1542
  const t = {
1289
- [X.USER]: 1,
1290
- [X.TENANT_ADMIN]: 2,
1291
- [X.SUPERUSER]: 3
1543
+ [ie.USER]: 1,
1544
+ [ie.TENANT_ADMIN]: 2,
1545
+ [ie.SUPERUSER]: 3
1292
1546
  };
1293
1547
  return t[i] >= t[e];
1294
1548
  };
1295
- function lt({
1549
+ function It({
1296
1550
  children: i,
1297
1551
  fallback: e,
1298
1552
  minUserType: t,
1299
1553
  requiredPermissions: r,
1300
- requireAllPermissions: n = !1
1554
+ requireAllPermissions: s = !1
1301
1555
  }) {
1302
- const { hasValidSession: o, sessionManager: m, hasPermission: T, hasAnyPermission: M, hasAllPermissions: P } = ne();
1303
- if (!o())
1304
- return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
1305
- const g = m.getUser();
1306
- if (!g)
1307
- return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
1308
- if (t && !He(g.userType, t))
1309
- return /* @__PURE__ */ s(he, { userType: g.userType, minUserType: t });
1310
- if (r && r.length > 0 && !(n ? P(r) : M(r))) {
1311
- const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
1312
- return /* @__PURE__ */ s(he, { missingPermissions: x });
1313
- }
1314
- return /* @__PURE__ */ s(H, { children: i });
1556
+ const { hasValidSession: a, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
1557
+ if (!a())
1558
+ return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1559
+ const P = p.getUser();
1560
+ if (!P)
1561
+ return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1562
+ if (t && !We(P.userType, t))
1563
+ return /* @__PURE__ */ n(xe, { userType: P.userType, minUserType: t });
1564
+ if (r && r.length > 0 && !(s ? x(r) : A(r))) {
1565
+ const m = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
1566
+ return /* @__PURE__ */ n(xe, { missingPermissions: m });
1567
+ }
1568
+ return /* @__PURE__ */ n(N, { children: i });
1315
1569
  }
1316
- const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1570
+ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
1317
1571
  "div",
1318
1572
  {
1319
1573
  style: {
@@ -1326,7 +1580,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1326
1580
  backgroundColor: "#f9fafb",
1327
1581
  textAlign: "center"
1328
1582
  },
1329
- children: /* @__PURE__ */ c(
1583
+ children: /* @__PURE__ */ l(
1330
1584
  "div",
1331
1585
  {
1332
1586
  style: {
@@ -1337,10 +1591,10 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1337
1591
  maxWidth: "400px"
1338
1592
  },
1339
1593
  children: [
1340
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1341
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1342
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1343
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1594
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1595
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1596
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1597
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1344
1598
  "Redirecting to ",
1345
1599
  i,
1346
1600
  "..."
@@ -1349,11 +1603,11 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1349
1603
  }
1350
1604
  )
1351
1605
  }
1352
- ), ge = ({
1606
+ ), ke = ({
1353
1607
  userType: i,
1354
1608
  minUserType: e,
1355
1609
  missingPermissions: t
1356
- }) => /* @__PURE__ */ s(
1610
+ }) => /* @__PURE__ */ n(
1357
1611
  "div",
1358
1612
  {
1359
1613
  style: {
@@ -1366,7 +1620,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1366
1620
  backgroundColor: "#f9fafb",
1367
1621
  textAlign: "center"
1368
1622
  },
1369
- children: /* @__PURE__ */ c(
1623
+ children: /* @__PURE__ */ l(
1370
1624
  "div",
1371
1625
  {
1372
1626
  style: {
@@ -1377,63 +1631,63 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1377
1631
  maxWidth: "400px"
1378
1632
  },
1379
1633
  children: [
1380
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1381
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1382
- e && i ? /* @__PURE__ */ c(H, { children: [
1383
- /* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1634
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1635
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1636
+ e && i ? /* @__PURE__ */ l(N, { children: [
1637
+ /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1384
1638
  "This page requires ",
1385
- /* @__PURE__ */ s("strong", { children: e }),
1639
+ /* @__PURE__ */ n("strong", { children: e }),
1386
1640
  " access level or higher."
1387
1641
  ] }),
1388
- /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1642
+ /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1389
1643
  "Your current access level: ",
1390
- /* @__PURE__ */ s("strong", { children: i })
1644
+ /* @__PURE__ */ n("strong", { children: i })
1391
1645
  ] })
1392
- ] }) : /* @__PURE__ */ c(H, { children: [
1393
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1394
- t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1646
+ ] }) : /* @__PURE__ */ l(N, { children: [
1647
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1648
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1395
1649
  "Required permissions: ",
1396
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1650
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1397
1651
  ] })
1398
1652
  ] })
1399
1653
  ]
1400
1654
  }
1401
1655
  )
1402
1656
  }
1403
- ), $e = (i, e) => {
1657
+ ), Ke = (i, e) => {
1404
1658
  const t = {
1405
- [X.USER]: 1,
1406
- [X.TENANT_ADMIN]: 2,
1407
- [X.SUPERUSER]: 3
1659
+ [ie.USER]: 1,
1660
+ [ie.TENANT_ADMIN]: 2,
1661
+ [ie.SUPERUSER]: 3
1408
1662
  };
1409
1663
  return t[i] >= t[e];
1410
1664
  };
1411
- function ct({
1665
+ function Et({
1412
1666
  children: i,
1413
1667
  redirectTo: e = "/login",
1414
1668
  minUserType: t,
1415
1669
  requiredPermissions: r,
1416
- requireAllPermissions: n = !1,
1417
- fallback: o
1670
+ requireAllPermissions: s = !1,
1671
+ fallback: a
1418
1672
  }) {
1419
- const { hasValidSession: m, sessionManager: T, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = ne(), h = ae();
1420
- if (!m())
1421
- return o ? /* @__PURE__ */ s(H, { children: o }) : /* @__PURE__ */ c(H, { children: [
1422
- /* @__PURE__ */ s(Ce, { redirectPath: e }),
1423
- /* @__PURE__ */ s(ie, { to: e, state: { from: h.pathname }, replace: !0 })
1673
+ const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: P } = oe(), b = we();
1674
+ if (!p())
1675
+ return a ? /* @__PURE__ */ n(N, { children: a }) : /* @__PURE__ */ l(N, { children: [
1676
+ /* @__PURE__ */ n(Ge, { redirectPath: e }),
1677
+ /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
1424
1678
  ] });
1425
- const x = T.getUser();
1426
- if (!x)
1427
- return /* @__PURE__ */ s(ie, { to: e, state: { from: h.pathname }, replace: !0 });
1428
- if (t && !$e(x.userType, t))
1429
- return /* @__PURE__ */ s(ge, { userType: x.userType, minUserType: t });
1430
- if (r && r.length > 0 && !(n ? g(r) : P(r))) {
1431
- const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
1432
- return /* @__PURE__ */ s(ge, { missingPermissions: A });
1433
- }
1434
- return /* @__PURE__ */ s(H, { children: i });
1679
+ const m = I.getUser();
1680
+ if (!m)
1681
+ return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
1682
+ if (t && !Ke(m.userType, t))
1683
+ return /* @__PURE__ */ n(ke, { userType: m.userType, minUserType: t });
1684
+ if (r && r.length > 0 && !(s ? P(r) : x(r))) {
1685
+ const S = r.filter((L) => !A(L)).map((L) => typeof L == "string" ? L : L.name);
1686
+ return /* @__PURE__ */ n(ke, { missingPermissions: S });
1687
+ }
1688
+ return /* @__PURE__ */ n(N, { children: i });
1435
1689
  }
1436
- const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1690
+ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1437
1691
  "div",
1438
1692
  {
1439
1693
  style: {
@@ -1446,7 +1700,7 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1446
1700
  backgroundColor: "#f9fafb",
1447
1701
  textAlign: "center"
1448
1702
  },
1449
- children: /* @__PURE__ */ c(
1703
+ children: /* @__PURE__ */ l(
1450
1704
  "div",
1451
1705
  {
1452
1706
  style: {
@@ -1457,10 +1711,10 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1457
1711
  maxWidth: "400px"
1458
1712
  },
1459
1713
  children: [
1460
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1461
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1462
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1463
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1714
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1715
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1716
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1717
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1464
1718
  "Redirecting to ",
1465
1719
  i,
1466
1720
  "..."
@@ -1470,14 +1724,14 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1470
1724
  )
1471
1725
  }
1472
1726
  );
1473
- function dt({ children: i, redirectTo: e = "/", fallback: t }) {
1474
- const { tenant: r, isLoading: n, error: o } = K(), m = ae();
1475
- return n || o ? null : r ? /* @__PURE__ */ s(H, { children: i }) : t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
1476
- /* @__PURE__ */ s(Le, { redirectPath: e }),
1477
- /* @__PURE__ */ s(ie, { to: e, state: { from: m.pathname }, replace: !0 })
1727
+ function Rt({ children: i, redirectTo: e = "/", fallback: t }) {
1728
+ const { tenant: r, isLoading: s, error: a } = se(), p = we();
1729
+ return s || a ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1730
+ /* @__PURE__ */ n(_e, { redirectPath: e }),
1731
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1478
1732
  ] });
1479
1733
  }
1480
- const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1734
+ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1481
1735
  "div",
1482
1736
  {
1483
1737
  style: {
@@ -1490,7 +1744,7 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1490
1744
  backgroundColor: "#f9fafb",
1491
1745
  textAlign: "center"
1492
1746
  },
1493
- children: /* @__PURE__ */ c(
1747
+ children: /* @__PURE__ */ l(
1494
1748
  "div",
1495
1749
  {
1496
1750
  style: {
@@ -1501,10 +1755,10 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1501
1755
  maxWidth: "400px"
1502
1756
  },
1503
1757
  children: [
1504
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1505
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1506
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1507
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1758
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1759
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1760
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1761
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1508
1762
  "Redirecting to ",
1509
1763
  i,
1510
1764
  "..."
@@ -1514,14 +1768,14 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1514
1768
  )
1515
1769
  }
1516
1770
  );
1517
- function ut({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1518
- const { tenant: r, isLoading: n, error: o } = K(), m = ae();
1519
- return n || o ? null : r ? t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
1520
- /* @__PURE__ */ s(De, { redirectPath: e }),
1521
- /* @__PURE__ */ s(ie, { to: e, state: { from: m.pathname }, replace: !0 })
1522
- ] }) : /* @__PURE__ */ s(H, { children: i });
1771
+ function Ct({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1772
+ const { tenant: r, isLoading: s, error: a } = se(), p = we();
1773
+ return s || a ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1774
+ /* @__PURE__ */ n(Je, { redirectPath: e }),
1775
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1776
+ ] }) : /* @__PURE__ */ n(N, { children: i });
1523
1777
  }
1524
- const Be = () => /* @__PURE__ */ c(
1778
+ const Ye = () => /* @__PURE__ */ l(
1525
1779
  "div",
1526
1780
  {
1527
1781
  style: {
@@ -1533,19 +1787,19 @@ const Be = () => /* @__PURE__ */ c(
1533
1787
  color: "#dc2626"
1534
1788
  },
1535
1789
  children: [
1536
- /* @__PURE__ */ s("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1537
- /* @__PURE__ */ s("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1790
+ /* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1791
+ /* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1538
1792
  ]
1539
1793
  }
1540
1794
  );
1541
- function ht({
1795
+ function Lt({
1542
1796
  children: i,
1543
- fallback: e = /* @__PURE__ */ s(Be, {}),
1797
+ fallback: e = /* @__PURE__ */ n(Ye, {}),
1544
1798
  allowedPlans: t,
1545
1799
  requiredFeature: r
1546
1800
  }) {
1547
- const { subscription: n, hasAllowedPlan: o, isFeatureEnabled: m, loading: T } = Ie();
1548
- return T ? /* @__PURE__ */ s(
1801
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: p, loading: I } = Ve();
1802
+ return I ? /* @__PURE__ */ n(
1549
1803
  "div",
1550
1804
  {
1551
1805
  style: {
@@ -1555,9 +1809,9 @@ function ht({
1555
1809
  },
1556
1810
  children: "Loading subscription..."
1557
1811
  }
1558
- ) : n ? n.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(H, { children: e }) : r && !m(r) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: i }) : /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: e });
1812
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
1559
1813
  }
1560
- const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1814
+ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
1561
1815
  "div",
1562
1816
  {
1563
1817
  style: {
@@ -1574,9 +1828,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1574
1828
  color: "#6c757d"
1575
1829
  },
1576
1830
  children: [
1577
- /* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1578
- /* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1579
- /* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1831
+ /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1832
+ /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1833
+ /* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1580
1834
  'Feature flag "',
1581
1835
  i,
1582
1836
  '" is disabled'
@@ -1584,9 +1838,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1584
1838
  ]
1585
1839
  }
1586
1840
  );
1587
- function gt({ name: i, children: e, fallback: t }) {
1588
- const { isEnabled: r, loading: n } = Re();
1589
- return n ? /* @__PURE__ */ s(
1841
+ function Ft({ name: i, children: e, fallback: t }) {
1842
+ const { isEnabled: r, loading: s } = Oe();
1843
+ return s ? /* @__PURE__ */ n(
1590
1844
  "div",
1591
1845
  {
1592
1846
  style: {
@@ -1599,9 +1853,9 @@ function gt({ name: i, children: e, fallback: t }) {
1599
1853
  },
1600
1854
  children: "Loading feature flags..."
1601
1855
  }
1602
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: t || /* @__PURE__ */ s(qe, { flagName: i }) }));
1856
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) }));
1603
1857
  }
1604
- const Ue = () => /* @__PURE__ */ c(
1858
+ const Xe = () => /* @__PURE__ */ l(
1605
1859
  "svg",
1606
1860
  {
1607
1861
  width: "16",
@@ -1614,11 +1868,11 @@ const Ue = () => /* @__PURE__ */ c(
1614
1868
  strokeLinejoin: "round",
1615
1869
  style: { flexShrink: 0 },
1616
1870
  children: [
1617
- /* @__PURE__ */ s("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1618
- /* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
1871
+ /* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1872
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1619
1873
  ]
1620
1874
  }
1621
- ), Ne = () => /* @__PURE__ */ c(
1875
+ ), Ze = () => /* @__PURE__ */ l(
1622
1876
  "svg",
1623
1877
  {
1624
1878
  width: "16",
@@ -1631,26 +1885,28 @@ const Ue = () => /* @__PURE__ */ c(
1631
1885
  strokeLinejoin: "round",
1632
1886
  style: { flexShrink: 0 },
1633
1887
  children: [
1634
- /* @__PURE__ */ s("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" }),
1635
- /* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1888
+ /* @__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" }),
1889
+ /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1636
1890
  ]
1637
1891
  }
1638
- ), ze = {
1639
- showPassword: /* @__PURE__ */ s(Ue, {}),
1640
- hidePassword: /* @__PURE__ */ s(Ne, {})
1641
- }, Oe = {
1892
+ ), et = {
1893
+ showPassword: /* @__PURE__ */ n(Xe, {}),
1894
+ hidePassword: /* @__PURE__ */ n(Ze, {})
1895
+ }, tt = {
1642
1896
  title: "Sign In",
1643
- emailLabel: "Email",
1644
- emailPlaceholder: "Enter your email",
1897
+ usernameLabel: "Email or Phone",
1898
+ usernamePlaceholder: "Enter your email or phone number",
1645
1899
  passwordLabel: "Password",
1646
1900
  passwordPlaceholder: "Enter your password",
1647
1901
  submitButton: "Sign In",
1648
1902
  forgotPasswordLink: "Forgot your password?",
1649
1903
  signupLink: "Sign up here",
1650
1904
  signupText: "Don't have an account?",
1651
- errorMessage: "Invalid email or password",
1905
+ magicLinkText: "Prefer passwordless?",
1906
+ magicLinkLink: "Use Magic Link",
1907
+ errorMessage: "Invalid credentials",
1652
1908
  loadingText: "Signing in..."
1653
- }, je = {
1909
+ }, rt = {
1654
1910
  container: {
1655
1911
  maxWidth: "400px",
1656
1912
  width: "100%",
@@ -1757,124 +2013,142 @@ const Ue = () => /* @__PURE__ */ c(
1757
2013
  fontSize: "0.875rem"
1758
2014
  }
1759
2015
  };
1760
- function pt({
2016
+ function $t({
1761
2017
  copy: i = {},
1762
2018
  styles: e = {},
1763
2019
  icons: t = {},
1764
2020
  onSuccess: r,
1765
- onError: n,
1766
- onForgotPassword: o,
1767
- onSignupClick: m,
1768
- showForgotPassword: T = !0,
1769
- showSignupLink: M = !0,
1770
- className: P
2021
+ onError: s,
2022
+ onForgotPassword: a,
2023
+ onSignupClick: p,
2024
+ onMagicLinkClick: I,
2025
+ showForgotPassword: A = !0,
2026
+ showSignupLink: x = !0,
2027
+ showMagicLinkOption: P = !0,
2028
+ className: b
1771
2029
  }) {
1772
- const [g, h] = b(""), [x, p] = b(""), [A, F] = b(!1), [f, L] = b(!1), [y, S] = b(""), [k, R] = b({}), { login: D } = ne(), { tenant: E } = K(), B = { ...Oe, ...i }, d = { ...je, ...e }, w = { ...ze, ...t }, u = () => {
1773
- const I = {};
1774
- return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
1775
- }, a = async (I) => {
1776
- if (I.preventDefault(), !!u()) {
1777
- if (!(E != null && E.id)) {
1778
- S("Tenant not found");
2030
+ const [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, o = () => {
2031
+ const c = {};
2032
+ return m.trim() || (c.username = !0), S.trim() || (c.password = !0), G(c), Object.keys(c).length === 0;
2033
+ }, g = async (c) => {
2034
+ if (c.preventDefault(), !!o()) {
2035
+ if (!(V != null && V.id)) {
2036
+ R("Tenant not found");
1779
2037
  return;
1780
2038
  }
1781
- L(!0), S("");
2039
+ u(!0), R("");
1782
2040
  try {
1783
- const N = await D(g, x, E.id);
1784
- r == null || r(N);
1785
- } catch (N) {
1786
- const _ = N.message || B.errorMessage;
1787
- S(_), n == null || n(_);
2041
+ const y = await F({
2042
+ username: m,
2043
+ password: S
2044
+ // tenantId inferred from context automatically
2045
+ });
2046
+ r == null || r(y);
2047
+ } catch (y) {
2048
+ const W = y.message || w.errorMessage;
2049
+ R(W), s == null || s(W);
1788
2050
  } finally {
1789
- L(!1);
2051
+ u(!1);
1790
2052
  }
1791
2053
  }
1792
- }, l = (I) => ({
1793
- ...d.input,
1794
- ...k[I] ? d.inputError : {}
1795
- }), W = () => ({
1796
- ...d.button,
1797
- ...f ? d.buttonLoading : {},
1798
- ...!g || !x || f ? d.buttonDisabled : {}
2054
+ }, f = (c) => ({
2055
+ ...M.input,
2056
+ ...H[c] ? M.inputError : {}
2057
+ }), d = () => ({
2058
+ ...M.button,
2059
+ ...k ? M.buttonLoading : {},
2060
+ ...!m || !S || k ? M.buttonDisabled : {}
1799
2061
  });
1800
- return /* @__PURE__ */ c("div", { className: P, style: d.container, children: [
1801
- /* @__PURE__ */ s("h2", { style: d.title, children: B.title }),
1802
- /* @__PURE__ */ c("form", { onSubmit: a, style: d.form, children: [
1803
- /* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
1804
- /* @__PURE__ */ s("label", { style: d.label, children: B.emailLabel }),
1805
- /* @__PURE__ */ s(
2062
+ return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
2063
+ /* @__PURE__ */ n("h2", { style: M.title, children: w.title }),
2064
+ /* @__PURE__ */ l("form", { onSubmit: g, style: M.form, children: [
2065
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2066
+ /* @__PURE__ */ n("label", { style: M.label, children: w.usernameLabel }),
2067
+ /* @__PURE__ */ n(
1806
2068
  "input",
1807
2069
  {
1808
- id: "email",
1809
- name: "email",
1810
- type: "email",
1811
- value: g,
1812
- onChange: (I) => {
1813
- h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
2070
+ id: "username",
2071
+ name: "username",
2072
+ type: "text",
2073
+ value: m,
2074
+ onChange: (c) => {
2075
+ h(c.target.value), H.username && G((y) => ({ ...y, username: !1 }));
1814
2076
  },
1815
- placeholder: B.emailPlaceholder,
1816
- style: l("email"),
1817
- disabled: f
2077
+ placeholder: w.usernamePlaceholder,
2078
+ style: f("username"),
2079
+ disabled: k
1818
2080
  }
1819
2081
  )
1820
2082
  ] }),
1821
- /* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
1822
- /* @__PURE__ */ s("label", { style: d.label, children: B.passwordLabel }),
1823
- /* @__PURE__ */ c("div", { style: d.inputContainer, children: [
1824
- /* @__PURE__ */ s(
2083
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2084
+ /* @__PURE__ */ n("label", { style: M.label, children: w.passwordLabel }),
2085
+ /* @__PURE__ */ l("div", { style: M.inputContainer, children: [
2086
+ /* @__PURE__ */ n(
1825
2087
  "input",
1826
2088
  {
1827
2089
  id: "password",
1828
2090
  name: "password",
1829
- type: A ? "text" : "password",
1830
- value: x,
1831
- onChange: (I) => {
1832
- p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
2091
+ type: C ? "text" : "password",
2092
+ value: S,
2093
+ onChange: (c) => {
2094
+ L(c.target.value), H.password && G((y) => ({ ...y, password: !1 }));
1833
2095
  },
1834
- placeholder: B.passwordPlaceholder,
2096
+ placeholder: w.passwordPlaceholder,
1835
2097
  style: {
1836
- ...l("password"),
2098
+ ...f("password"),
1837
2099
  paddingRight: "2.5rem"
1838
2100
  // Make room for the icon
1839
2101
  },
1840
- disabled: f
2102
+ disabled: k
1841
2103
  }
1842
2104
  ),
1843
- /* @__PURE__ */ s(
2105
+ /* @__PURE__ */ n(
1844
2106
  "button",
1845
2107
  {
1846
2108
  type: "button",
1847
- onClick: () => F(!A),
1848
- style: d.passwordToggle,
1849
- disabled: f,
1850
- "aria-label": A ? "Hide password" : "Show password",
1851
- children: A ? w.hidePassword : w.showPassword
2109
+ onClick: () => q(!C),
2110
+ style: M.passwordToggle,
2111
+ disabled: k,
2112
+ "aria-label": C ? "Hide password" : "Show password",
2113
+ children: C ? E.hidePassword : E.showPassword
1852
2114
  }
1853
2115
  )
1854
2116
  ] })
1855
2117
  ] }),
1856
- /* @__PURE__ */ s("button", { type: "submit", disabled: !g || !x || f, style: W(), children: f ? B.loadingText : B.submitButton }),
1857
- y && /* @__PURE__ */ s("div", { style: d.errorText, children: y })
2118
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !m || !S || k, style: d(), children: k ? w.loadingText : w.submitButton }),
2119
+ T && /* @__PURE__ */ n("div", { style: M.errorText, children: T })
1858
2120
  ] }),
1859
- (T || M) && /* @__PURE__ */ c("div", { style: d.linkContainer, children: [
1860
- T && /* @__PURE__ */ s("a", { onClick: o, style: d.link, children: B.forgotPasswordLink }),
1861
- T && M && /* @__PURE__ */ s("div", { style: d.divider, children: "•" }),
1862
- M && /* @__PURE__ */ c("div", { children: [
1863
- /* @__PURE__ */ c("span", { style: d.divider, children: [
1864
- B.signupText,
2121
+ (A || x || P) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2122
+ P && /* @__PURE__ */ l("div", { children: [
2123
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2124
+ w.magicLinkText,
1865
2125
  " "
1866
2126
  ] }),
1867
- /* @__PURE__ */ s("a", { onClick: m, style: d.link, children: B.signupLink })
2127
+ /* @__PURE__ */ n("a", { onClick: I, style: M.link, children: w.magicLinkLink })
2128
+ ] }),
2129
+ P && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2130
+ A && /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: w.forgotPasswordLink }),
2131
+ A && x && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2132
+ x && /* @__PURE__ */ l("div", { children: [
2133
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2134
+ w.signupText,
2135
+ " "
2136
+ ] }),
2137
+ /* @__PURE__ */ n("a", { onClick: p, style: M.link, children: w.signupLink })
1868
2138
  ] })
1869
2139
  ] })
1870
2140
  ] });
1871
2141
  }
1872
- const Ve = {
2142
+ const nt = {
1873
2143
  title: "Create Account",
1874
- nameLabel: "Full Name",
1875
- namePlaceholder: "Enter your full name",
2144
+ nameLabel: "First Name",
2145
+ namePlaceholder: "Enter your first name",
2146
+ lastNameLabel: "Last Name",
2147
+ lastNamePlaceholder: "Enter your last name",
1876
2148
  emailLabel: "Email",
1877
2149
  emailPlaceholder: "Enter your email",
2150
+ phoneNumberLabel: "Phone Number",
2151
+ phoneNumberPlaceholder: "Enter your phone number",
1878
2152
  passwordLabel: "Password",
1879
2153
  passwordPlaceholder: "Enter your password",
1880
2154
  confirmPasswordLabel: "Confirm Password",
@@ -1884,12 +2158,14 @@ const Ve = {
1884
2158
  submitButton: "Create Account",
1885
2159
  loginLink: "Sign in here",
1886
2160
  loginText: "Already have an account?",
2161
+ magicLinkText: "Prefer passwordless?",
2162
+ magicLinkLink: "Use Magic Link",
1887
2163
  errorMessage: "Failed to create account",
1888
2164
  loadingText: "Creating account...",
1889
2165
  passwordMismatchError: "Passwords do not match",
1890
2166
  isAdminLabel: "Create new organization",
1891
2167
  isAdminDescription: "Check this if you want to create a new organization"
1892
- }, We = {
2168
+ }, st = {
1893
2169
  container: {
1894
2170
  maxWidth: "400px",
1895
2171
  width: "100%",
@@ -1988,154 +2264,786 @@ const Ve = {
1988
2264
  fontSize: "0.875rem"
1989
2265
  }
1990
2266
  };
1991
- function ft({
2267
+ function Dt({
1992
2268
  copy: i = {},
1993
2269
  styles: e = {},
1994
2270
  signupType: t = "user",
1995
2271
  onSuccess: r,
1996
- onError: n,
1997
- onLoginClick: o,
1998
- showLoginLink: m = !0,
1999
- className: T
2272
+ onError: s,
2273
+ onLoginClick: a,
2274
+ onMagicLinkClick: p,
2275
+ showLoginLink: I = !0,
2276
+ showMagicLinkOption: A = !0,
2277
+ className: x
2000
2278
  }) {
2001
- const [M, P] = b(""), [g, h] = b(""), [x, p] = b(""), [A, F] = b(""), [f, L] = b(""), [y, S] = b(!1), [k, R] = b(""), [D, E] = b({}), { signup: B, signupTenantAdmin: d } = ne(), { tenant: w } = K(), u = { ...Ve, ...i }, a = { ...We, ...e }, l = () => {
2002
- const C = {};
2003
- return M.trim() || (C.name = !0), g.trim() || (C.email = !0), x.trim() || (C.password = !0), A.trim() || (C.confirmPassword = !0), t === "tenant" && !f.trim() && (C.tenantName = !0), E(C), Object.keys(C).length === 0;
2004
- }, W = async (C) => {
2005
- if (C.preventDefault(), !!l()) {
2006
- if (x !== A) {
2007
- R(u.passwordMismatchError), E({ confirmPassword: !0 });
2279
+ const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(""), [k, u] = v(""), [T, R] = v(""), [H, G] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, o] = v({}), { signup: g, signupTenantAdmin: f } = oe(), { tenant: d } = se(), c = { ...nt, ...i }, y = { ...st, ...e }, W = () => {
2280
+ const D = {};
2281
+ return P.trim() || (D.name = !0), !S.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), T.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), o(D), Object.keys(D).length === 0;
2282
+ }, ee = async (D) => {
2283
+ if (D.preventDefault(), !!W()) {
2284
+ if (k !== T) {
2285
+ M(c.passwordMismatchError), o({ confirmPassword: !0 });
2008
2286
  return;
2009
2287
  }
2010
- if (t === "user" && !(w != null && w.id)) {
2011
- R("Tenant not found");
2288
+ if (t === "user" && !(d != null && d.id)) {
2289
+ M("Tenant not found");
2012
2290
  return;
2013
2291
  }
2014
- S(!0), R("");
2292
+ V(!0), M("");
2015
2293
  try {
2016
- let U;
2017
- t === "tenant" ? U = await d(g, M, x, f) : U = await B(g, M, x, w.id), r == null || r(U);
2018
- } catch (U) {
2019
- const Q = U.message || u.errorMessage;
2020
- R(Q), n == null || n(Q);
2294
+ let _;
2295
+ t === "tenant" ? _ = await f({
2296
+ email: S || void 0,
2297
+ phoneNumber: C || void 0,
2298
+ name: P,
2299
+ password: k,
2300
+ tenantName: H,
2301
+ lastName: m || void 0
2302
+ }) : _ = await g({
2303
+ email: S || void 0,
2304
+ phoneNumber: C || void 0,
2305
+ name: P,
2306
+ password: k,
2307
+ tenantId: d.id,
2308
+ lastName: m || void 0
2309
+ }), r == null || r(_);
2310
+ } catch (_) {
2311
+ const ge = _.message || c.errorMessage;
2312
+ M(ge), s == null || s(ge);
2021
2313
  } finally {
2022
- S(!1);
2314
+ V(!1);
2023
2315
  }
2024
2316
  }
2025
- }, I = (C) => ({
2026
- ...a.input,
2027
- ...D[C] ? a.inputError : {}
2028
- }), N = () => ({
2029
- ...a.button,
2030
- ...y ? a.buttonLoading : {},
2031
- ...!M || !g || !x || !A || y || t === "tenant" && !f ? a.buttonDisabled : {}
2032
- }), _ = M && g && x && A && (t === "user" || f);
2033
- return /* @__PURE__ */ c("div", { className: T, style: a.container, children: [
2034
- /* @__PURE__ */ s("h2", { style: a.title, children: u.title }),
2035
- /* @__PURE__ */ c("form", { onSubmit: W, style: a.form, children: [
2036
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2037
- /* @__PURE__ */ s("label", { style: a.label, children: u.nameLabel }),
2038
- /* @__PURE__ */ s(
2317
+ }, z = (D) => ({
2318
+ ...y.input,
2319
+ ...E[D] ? y.inputError : {}
2320
+ }), B = () => ({
2321
+ ...y.button,
2322
+ ...F ? y.buttonLoading : {},
2323
+ ...!P || !S && !C || !k || !T || F || t === "tenant" && !H ? y.buttonDisabled : {}
2324
+ }), O = P && (S || C) && k && T && (t === "user" || H);
2325
+ return /* @__PURE__ */ l("div", { className: x, style: y.container, children: [
2326
+ /* @__PURE__ */ n("h2", { style: y.title, children: c.title }),
2327
+ /* @__PURE__ */ l("form", { onSubmit: ee, style: y.form, children: [
2328
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2329
+ /* @__PURE__ */ n("label", { style: y.label, children: c.nameLabel }),
2330
+ /* @__PURE__ */ n(
2039
2331
  "input",
2040
2332
  {
2041
2333
  id: "name",
2042
2334
  name: "name",
2043
2335
  type: "text",
2044
- value: M,
2045
- onChange: (C) => {
2046
- P(C.target.value), D.name && E((U) => ({ ...U, name: !1 }));
2336
+ value: P,
2337
+ onChange: (D) => {
2338
+ b(D.target.value), E.name && o((_) => ({ ..._, name: !1 }));
2047
2339
  },
2048
- placeholder: u.namePlaceholder,
2049
- style: I("name"),
2050
- disabled: y
2340
+ placeholder: c.namePlaceholder,
2341
+ style: z("name"),
2342
+ disabled: F
2051
2343
  }
2052
2344
  )
2053
2345
  ] }),
2054
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2055
- /* @__PURE__ */ s("label", { style: a.label, children: u.emailLabel }),
2056
- /* @__PURE__ */ s(
2346
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2347
+ /* @__PURE__ */ n("label", { style: y.label, children: c.lastNameLabel }),
2348
+ /* @__PURE__ */ n(
2349
+ "input",
2350
+ {
2351
+ id: "lastName",
2352
+ name: "lastName",
2353
+ type: "text",
2354
+ value: m,
2355
+ onChange: (D) => h(D.target.value),
2356
+ placeholder: c.lastNamePlaceholder,
2357
+ style: y.input,
2358
+ disabled: F
2359
+ }
2360
+ )
2361
+ ] }),
2362
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2363
+ /* @__PURE__ */ n("label", { style: y.label, children: c.emailLabel }),
2364
+ /* @__PURE__ */ n(
2057
2365
  "input",
2058
2366
  {
2059
2367
  id: "email",
2060
2368
  name: "email",
2061
2369
  type: "email",
2062
- value: g,
2063
- onChange: (C) => {
2064
- h(C.target.value), D.email && E((U) => ({ ...U, email: !1 }));
2370
+ value: S,
2371
+ onChange: (D) => {
2372
+ L(D.target.value), E.email && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2373
+ },
2374
+ placeholder: c.emailPlaceholder,
2375
+ style: z("email"),
2376
+ disabled: F
2377
+ }
2378
+ )
2379
+ ] }),
2380
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2381
+ /* @__PURE__ */ n("label", { style: y.label, children: c.phoneNumberLabel }),
2382
+ /* @__PURE__ */ n(
2383
+ "input",
2384
+ {
2385
+ id: "phoneNumber",
2386
+ name: "phoneNumber",
2387
+ type: "tel",
2388
+ value: C,
2389
+ onChange: (D) => {
2390
+ q(D.target.value), E.phoneNumber && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2065
2391
  },
2066
- placeholder: u.emailPlaceholder,
2067
- style: I("email"),
2068
- disabled: y
2392
+ placeholder: c.phoneNumberPlaceholder,
2393
+ style: z("phoneNumber"),
2394
+ disabled: F
2069
2395
  }
2070
2396
  )
2071
2397
  ] }),
2072
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2073
- /* @__PURE__ */ s("label", { style: a.label, children: u.passwordLabel }),
2074
- /* @__PURE__ */ s(
2398
+ /* @__PURE__ */ n(
2399
+ "div",
2400
+ {
2401
+ style: {
2402
+ fontSize: "0.875rem",
2403
+ color: "#6b7280",
2404
+ textAlign: "center",
2405
+ margin: "0.5rem 0"
2406
+ },
2407
+ children: "At least one contact method (email or phone) is required"
2408
+ }
2409
+ ),
2410
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2411
+ /* @__PURE__ */ n("label", { style: y.label, children: c.passwordLabel }),
2412
+ /* @__PURE__ */ n(
2075
2413
  "input",
2076
2414
  {
2077
2415
  id: "password",
2078
2416
  name: "password",
2079
2417
  type: "password",
2080
- value: x,
2081
- onChange: (C) => {
2082
- p(C.target.value), D.password && E((U) => ({ ...U, password: !1 }));
2418
+ value: k,
2419
+ onChange: (D) => {
2420
+ u(D.target.value), E.password && o((_) => ({ ..._, password: !1 }));
2083
2421
  },
2084
- placeholder: u.passwordPlaceholder,
2085
- style: I("password"),
2086
- disabled: y
2422
+ placeholder: c.passwordPlaceholder,
2423
+ style: z("password"),
2424
+ disabled: F
2087
2425
  }
2088
2426
  )
2089
2427
  ] }),
2090
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2091
- /* @__PURE__ */ s("label", { style: a.label, children: u.confirmPasswordLabel }),
2092
- /* @__PURE__ */ s(
2428
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2429
+ /* @__PURE__ */ n("label", { style: y.label, children: c.confirmPasswordLabel }),
2430
+ /* @__PURE__ */ n(
2093
2431
  "input",
2094
2432
  {
2095
2433
  id: "confirmPassword",
2096
2434
  name: "confirmPassword",
2097
2435
  type: "password",
2098
- value: A,
2099
- onChange: (C) => {
2100
- F(C.target.value), D.confirmPassword && E((U) => ({ ...U, confirmPassword: !1 })), k === u.passwordMismatchError && R("");
2436
+ value: T,
2437
+ onChange: (D) => {
2438
+ R(D.target.value), E.confirmPassword && o((_) => ({ ..._, confirmPassword: !1 })), w === c.passwordMismatchError && M("");
2101
2439
  },
2102
- placeholder: u.confirmPasswordPlaceholder,
2103
- style: I("confirmPassword"),
2104
- disabled: y
2440
+ placeholder: c.confirmPasswordPlaceholder,
2441
+ style: z("confirmPassword"),
2442
+ disabled: F
2105
2443
  }
2106
2444
  )
2107
2445
  ] }),
2108
- t === "tenant" && /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2109
- /* @__PURE__ */ s("label", { style: a.label, children: u.tenantNameLabel }),
2110
- /* @__PURE__ */ s(
2446
+ t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2447
+ /* @__PURE__ */ n("label", { style: y.label, children: c.tenantNameLabel }),
2448
+ /* @__PURE__ */ n(
2111
2449
  "input",
2112
2450
  {
2113
2451
  id: "tenantName",
2114
2452
  name: "tenantName",
2115
2453
  type: "text",
2116
- value: f,
2117
- onChange: (C) => {
2118
- L(C.target.value), D.tenantName && E((U) => ({ ...U, tenantName: !1 }));
2454
+ value: H,
2455
+ onChange: (D) => {
2456
+ G(D.target.value), E.tenantName && o((_) => ({ ..._, tenantName: !1 }));
2457
+ },
2458
+ placeholder: c.tenantNamePlaceholder,
2459
+ style: z("tenantName"),
2460
+ disabled: F
2461
+ }
2462
+ )
2463
+ ] }),
2464
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? c.loadingText : c.submitButton }),
2465
+ w && /* @__PURE__ */ n("div", { style: y.errorText, children: w })
2466
+ ] }),
2467
+ (I || A) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
2468
+ A && /* @__PURE__ */ l("div", { children: [
2469
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2470
+ c.magicLinkText,
2471
+ " "
2472
+ ] }),
2473
+ /* @__PURE__ */ n("a", { onClick: p, style: y.link, children: c.magicLinkLink })
2474
+ ] }),
2475
+ A && I && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
2476
+ I && /* @__PURE__ */ l("div", { children: [
2477
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2478
+ c.loginText,
2479
+ " "
2480
+ ] }),
2481
+ /* @__PURE__ */ n("a", { onClick: a, style: y.link, children: c.loginLink })
2482
+ ] })
2483
+ ] })
2484
+ ] });
2485
+ }
2486
+ const it = {
2487
+ title: "Sign In with Magic Link",
2488
+ emailLabel: "Email",
2489
+ emailPlaceholder: "Enter your email",
2490
+ nameLabel: "Name",
2491
+ namePlaceholder: "Enter your name",
2492
+ lastNameLabel: "Last Name",
2493
+ lastNamePlaceholder: "Enter your last name",
2494
+ submitButton: "Send Magic Link",
2495
+ loginLink: "Sign in with password",
2496
+ signupLink: "Sign up with password",
2497
+ loginText: "Already have an account?",
2498
+ signupText: "Prefer traditional signup?",
2499
+ successMessage: "Magic link sent! Check your email and click the link to sign in.",
2500
+ errorMessage: "Failed to send magic link. Please try again.",
2501
+ loadingText: "Sending magic link...",
2502
+ verifyingText: "Verifying magic link...",
2503
+ description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2504
+ }, ot = {
2505
+ container: {
2506
+ maxWidth: "400px",
2507
+ width: "100%",
2508
+ margin: "0 auto",
2509
+ padding: "2rem",
2510
+ backgroundColor: "#ffffff",
2511
+ borderRadius: "8px",
2512
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2513
+ },
2514
+ title: {
2515
+ fontSize: "1.5rem",
2516
+ fontWeight: "bold",
2517
+ textAlign: "center",
2518
+ marginBottom: "1rem",
2519
+ color: "#333333"
2520
+ },
2521
+ description: {
2522
+ fontSize: "0.875rem",
2523
+ color: "#6b7280",
2524
+ textAlign: "center",
2525
+ marginBottom: "1.5rem",
2526
+ lineHeight: "1.5"
2527
+ },
2528
+ form: {
2529
+ display: "flex",
2530
+ flexDirection: "column",
2531
+ gap: "1rem"
2532
+ },
2533
+ fieldGroup: {
2534
+ display: "flex",
2535
+ flexDirection: "column",
2536
+ gap: "0.5rem"
2537
+ },
2538
+ label: {
2539
+ fontSize: "0.875rem",
2540
+ fontWeight: "500",
2541
+ color: "#374151"
2542
+ },
2543
+ input: {
2544
+ padding: "0.75rem",
2545
+ border: "1px solid #d1d5db",
2546
+ borderRadius: "6px",
2547
+ fontSize: "1rem",
2548
+ transition: "border-color 0.15s ease-in-out",
2549
+ outline: "none",
2550
+ width: "100%"
2551
+ },
2552
+ inputError: {
2553
+ borderColor: "#ef4444",
2554
+ boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
2555
+ },
2556
+ button: {
2557
+ padding: "0.75rem 1rem",
2558
+ backgroundColor: "#3b82f6",
2559
+ color: "white",
2560
+ border: "none",
2561
+ borderRadius: "6px",
2562
+ fontSize: "1rem",
2563
+ fontWeight: "500",
2564
+ cursor: "pointer",
2565
+ transition: "background-color 0.15s ease-in-out",
2566
+ marginTop: "0.5rem"
2567
+ },
2568
+ buttonDisabled: {
2569
+ backgroundColor: "#9ca3af",
2570
+ cursor: "not-allowed"
2571
+ },
2572
+ buttonLoading: {
2573
+ backgroundColor: "#6b7280"
2574
+ },
2575
+ errorText: {
2576
+ color: "#ef4444",
2577
+ fontSize: "0.875rem",
2578
+ textAlign: "center",
2579
+ marginTop: "0.5rem"
2580
+ },
2581
+ successText: {
2582
+ color: "#10b981",
2583
+ fontSize: "0.875rem",
2584
+ textAlign: "center",
2585
+ marginTop: "0.5rem",
2586
+ padding: "0.75rem",
2587
+ backgroundColor: "#f0fdf4",
2588
+ borderRadius: "6px",
2589
+ border: "1px solid #bbf7d0"
2590
+ },
2591
+ linkContainer: {
2592
+ textAlign: "center",
2593
+ marginTop: "1rem"
2594
+ },
2595
+ link: {
2596
+ color: "#3b82f6",
2597
+ textDecoration: "none",
2598
+ fontSize: "0.875rem",
2599
+ cursor: "pointer"
2600
+ },
2601
+ divider: {
2602
+ margin: "0.5rem 0",
2603
+ color: "#6b7280",
2604
+ fontSize: "0.875rem"
2605
+ }
2606
+ };
2607
+ function Ht({
2608
+ copy: i = {},
2609
+ styles: e = {},
2610
+ onSuccess: t,
2611
+ onError: r,
2612
+ onLoginClick: s,
2613
+ onSignupClick: a,
2614
+ showTraditionalLinks: p = !0,
2615
+ className: I,
2616
+ verifyToken: A,
2617
+ frontendUrl: x
2618
+ }) {
2619
+ const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: o } = oe(), { tenant: g } = se(), f = { ...it, ...i }, d = { ...ot, ...e };
2620
+ te(() => {
2621
+ A && c(A);
2622
+ }, [A]);
2623
+ const c = async (B) => {
2624
+ if (!g || !P) {
2625
+ R("Missing tenant or email");
2626
+ return;
2627
+ }
2628
+ u(!0), R("");
2629
+ try {
2630
+ const O = await o({
2631
+ token: B,
2632
+ email: P
2633
+ // tenantId inferred from context automatically
2634
+ });
2635
+ t == null || t(O);
2636
+ } catch (O) {
2637
+ const D = O.message || "Failed to verify magic link";
2638
+ R(D), r == null || r(D);
2639
+ } finally {
2640
+ u(!1);
2641
+ }
2642
+ }, y = () => {
2643
+ const B = {};
2644
+ return P.trim() || (B.email = !0), w && !m.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
2645
+ }, W = async (B) => {
2646
+ if (B.preventDefault(), !!y()) {
2647
+ if (!(g != null && g.id)) {
2648
+ R("Tenant not found");
2649
+ return;
2650
+ }
2651
+ q(!0), R(""), G("");
2652
+ try {
2653
+ const O = x || (typeof window < "u" ? window.location.origin : ""), D = await E({
2654
+ email: P,
2655
+ tenantId: g.id,
2656
+ frontendUrl: O,
2657
+ name: w ? m : void 0,
2658
+ lastName: w ? S : void 0
2659
+ });
2660
+ G(f.successMessage), t == null || t(D);
2661
+ } catch (O) {
2662
+ const D = O.message || f.errorMessage;
2663
+ R(D), r == null || r(D);
2664
+ } finally {
2665
+ q(!1);
2666
+ }
2667
+ }
2668
+ }, ee = (B) => ({
2669
+ ...d.input,
2670
+ ...F[B] ? d.inputError : {}
2671
+ }), z = () => ({
2672
+ ...d.button,
2673
+ ...C || k ? d.buttonLoading : {},
2674
+ ...!P || C || k ? d.buttonDisabled : {}
2675
+ });
2676
+ return k ? /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2677
+ /* @__PURE__ */ n("h2", { style: d.title, children: f.verifyingText }),
2678
+ /* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
2679
+ ] }) : /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2680
+ /* @__PURE__ */ n("h2", { style: d.title, children: f.title }),
2681
+ /* @__PURE__ */ n("p", { style: d.description, children: f.description }),
2682
+ /* @__PURE__ */ l("form", { onSubmit: W, style: d.form, children: [
2683
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2684
+ /* @__PURE__ */ n("label", { style: d.label, children: f.emailLabel }),
2685
+ /* @__PURE__ */ n(
2686
+ "input",
2687
+ {
2688
+ id: "email",
2689
+ name: "email",
2690
+ type: "email",
2691
+ value: P,
2692
+ onChange: (B) => {
2693
+ b(B.target.value), F.email && V((O) => ({ ...O, email: !1 }));
2119
2694
  },
2120
- placeholder: u.tenantNamePlaceholder,
2121
- style: I("tenantName"),
2122
- disabled: y
2695
+ placeholder: f.emailPlaceholder,
2696
+ style: ee("email"),
2697
+ disabled: C || k
2123
2698
  }
2124
2699
  )
2125
2700
  ] }),
2126
- /* @__PURE__ */ s("button", { type: "submit", disabled: !_ || y, style: N(), children: y ? u.loadingText : u.submitButton }),
2127
- k && /* @__PURE__ */ s("div", { style: a.errorText, children: k })
2701
+ !w && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2702
+ "button",
2703
+ {
2704
+ type: "button",
2705
+ onClick: () => M(!0),
2706
+ style: {
2707
+ background: "none",
2708
+ border: "none",
2709
+ color: "#3b82f6",
2710
+ fontSize: "0.875rem",
2711
+ cursor: "pointer",
2712
+ textDecoration: "underline"
2713
+ },
2714
+ children: "New user? Add your name"
2715
+ }
2716
+ ) }),
2717
+ w && /* @__PURE__ */ l(N, { children: [
2718
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2719
+ /* @__PURE__ */ n("label", { style: d.label, children: f.nameLabel }),
2720
+ /* @__PURE__ */ n(
2721
+ "input",
2722
+ {
2723
+ id: "name",
2724
+ name: "name",
2725
+ type: "text",
2726
+ value: m,
2727
+ onChange: (B) => {
2728
+ h(B.target.value), F.name && V((O) => ({ ...O, name: !1 }));
2729
+ },
2730
+ placeholder: f.namePlaceholder,
2731
+ style: ee("name"),
2732
+ disabled: C || k
2733
+ }
2734
+ )
2735
+ ] }),
2736
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2737
+ /* @__PURE__ */ n("label", { style: d.label, children: f.lastNameLabel }),
2738
+ /* @__PURE__ */ n(
2739
+ "input",
2740
+ {
2741
+ id: "lastName",
2742
+ name: "lastName",
2743
+ type: "text",
2744
+ value: S,
2745
+ onChange: (B) => L(B.target.value),
2746
+ placeholder: f.lastNamePlaceholder,
2747
+ style: d.input,
2748
+ disabled: C || k
2749
+ }
2750
+ )
2751
+ ] }),
2752
+ /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2753
+ "button",
2754
+ {
2755
+ type: "button",
2756
+ onClick: () => {
2757
+ M(!1), h(""), L("");
2758
+ },
2759
+ style: {
2760
+ background: "none",
2761
+ border: "none",
2762
+ color: "#6b7280",
2763
+ fontSize: "0.875rem",
2764
+ cursor: "pointer",
2765
+ textDecoration: "underline"
2766
+ },
2767
+ children: "Existing user? Hide name fields"
2768
+ }
2769
+ ) })
2770
+ ] }),
2771
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !P || C || k, style: z(), children: C ? f.loadingText : f.submitButton }),
2772
+ T && /* @__PURE__ */ n("div", { style: d.errorText, children: T }),
2773
+ H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
2128
2774
  ] }),
2129
- m && /* @__PURE__ */ c("div", { style: a.linkContainer, children: [
2130
- /* @__PURE__ */ c("span", { style: a.divider, children: [
2131
- u.loginText,
2132
- " "
2775
+ p && /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
2776
+ /* @__PURE__ */ l("div", { children: [
2777
+ /* @__PURE__ */ l("span", { style: d.divider, children: [
2778
+ f.loginText,
2779
+ " "
2780
+ ] }),
2781
+ /* @__PURE__ */ n("a", { onClick: s, style: d.link, children: f.loginLink })
2133
2782
  ] }),
2134
- /* @__PURE__ */ s("a", { onClick: o, style: a.link, children: u.loginLink })
2783
+ /* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
2784
+ /* @__PURE__ */ l("div", { children: [
2785
+ /* @__PURE__ */ l("span", { style: d.divider, children: [
2786
+ f.signupText,
2787
+ " "
2788
+ ] }),
2789
+ /* @__PURE__ */ n("a", { onClick: a, style: d.link, children: f.signupLink })
2790
+ ] })
2135
2791
  ] })
2136
2792
  ] });
2137
2793
  }
2138
- const Ge = {
2794
+ const at = {
2795
+ title: "Verifying Magic Link",
2796
+ verifyingMessage: "Please wait while we verify your magic link...",
2797
+ successMessage: "Magic link verified successfully! You are now logged in.",
2798
+ errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
2799
+ redirectingMessage: "Redirecting you to the dashboard...",
2800
+ retryButton: "Try Again",
2801
+ backToLoginButton: "Back to Login"
2802
+ }, Ee = {
2803
+ container: {
2804
+ maxWidth: "400px",
2805
+ width: "100%",
2806
+ margin: "0 auto",
2807
+ padding: "2rem",
2808
+ backgroundColor: "#ffffff",
2809
+ borderRadius: "8px",
2810
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2811
+ },
2812
+ card: {
2813
+ // Not used in new design, keeping for compatibility
2814
+ backgroundColor: "transparent",
2815
+ padding: "0",
2816
+ borderRadius: "0",
2817
+ boxShadow: "none",
2818
+ maxWidth: "100%",
2819
+ width: "100%",
2820
+ textAlign: "center"
2821
+ },
2822
+ title: {
2823
+ fontSize: "1.5rem",
2824
+ fontWeight: "bold",
2825
+ textAlign: "center",
2826
+ marginBottom: "1.5rem",
2827
+ color: "#333333"
2828
+ },
2829
+ message: {
2830
+ fontSize: "1rem",
2831
+ color: "#6b7280",
2832
+ marginBottom: "1.5rem",
2833
+ lineHeight: "1.5",
2834
+ textAlign: "center"
2835
+ },
2836
+ successMessage: {
2837
+ fontSize: "1rem",
2838
+ color: "#059669",
2839
+ marginBottom: "1.5rem",
2840
+ lineHeight: "1.5",
2841
+ textAlign: "center"
2842
+ },
2843
+ errorMessage: {
2844
+ fontSize: "0.875rem",
2845
+ color: "#ef4444",
2846
+ textAlign: "center",
2847
+ marginBottom: "1rem",
2848
+ lineHeight: "1.5"
2849
+ },
2850
+ spinner: {
2851
+ display: "inline-block",
2852
+ width: "20px",
2853
+ height: "20px",
2854
+ border: "2px solid #e5e7eb",
2855
+ borderTop: "2px solid #3b82f6",
2856
+ borderRadius: "50%",
2857
+ animation: "spin 1s linear infinite",
2858
+ marginRight: "0.5rem"
2859
+ },
2860
+ buttonContainer: {
2861
+ display: "flex",
2862
+ gap: "0.75rem",
2863
+ justifyContent: "center",
2864
+ flexWrap: "wrap",
2865
+ marginTop: "1rem"
2866
+ },
2867
+ retryButton: {
2868
+ padding: "0.75rem 1rem",
2869
+ backgroundColor: "#3b82f6",
2870
+ color: "white",
2871
+ border: "none",
2872
+ borderRadius: "6px",
2873
+ fontSize: "1rem",
2874
+ fontWeight: "500",
2875
+ cursor: "pointer",
2876
+ transition: "background-color 0.15s ease-in-out"
2877
+ },
2878
+ backButton: {
2879
+ padding: "0.75rem 1rem",
2880
+ backgroundColor: "#f3f4f6",
2881
+ color: "#374151",
2882
+ border: "1px solid #d1d5db",
2883
+ borderRadius: "6px",
2884
+ fontSize: "1rem",
2885
+ fontWeight: "500",
2886
+ cursor: "pointer",
2887
+ transition: "all 0.15s ease-in-out"
2888
+ }
2889
+ }, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ l(
2890
+ "svg",
2891
+ {
2892
+ width: "48",
2893
+ height: "48",
2894
+ viewBox: "0 0 24 24",
2895
+ fill: "none",
2896
+ stroke: "#059669",
2897
+ strokeWidth: "2",
2898
+ strokeLinecap: "round",
2899
+ strokeLinejoin: "round",
2900
+ style: { margin: "0 auto 1rem auto", display: "block" },
2901
+ children: [
2902
+ /* @__PURE__ */ n("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
2903
+ /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2904
+ ]
2905
+ }
2906
+ ), dt = () => /* @__PURE__ */ l(
2907
+ "svg",
2908
+ {
2909
+ width: "48",
2910
+ height: "48",
2911
+ viewBox: "0 0 24 24",
2912
+ fill: "none",
2913
+ stroke: "#ef4444",
2914
+ strokeWidth: "2",
2915
+ strokeLinecap: "round",
2916
+ strokeLinejoin: "round",
2917
+ style: { margin: "0 auto 1rem auto", display: "block" },
2918
+ children: [
2919
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "10" }),
2920
+ /* @__PURE__ */ n("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
2921
+ /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2922
+ ]
2923
+ }
2924
+ ), ut = {
2925
+ loading: /* @__PURE__ */ n(lt, {}),
2926
+ success: /* @__PURE__ */ n(ct, {}),
2927
+ error: /* @__PURE__ */ n(dt, {})
2928
+ };
2929
+ function Nt({
2930
+ copy: i = {},
2931
+ styles: e = {},
2932
+ icons: t = {},
2933
+ onSuccess: r,
2934
+ onError: s,
2935
+ onRetry: a,
2936
+ onBackToLogin: p,
2937
+ className: I,
2938
+ token: A,
2939
+ email: x,
2940
+ appId: P,
2941
+ tenantSlug: b,
2942
+ autoRedirectDelay: m = 3e3
2943
+ }) {
2944
+ const [h, S] = v("verifying"), [L, C] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, T = { ...ut, ...t }, R = () => {
2945
+ if (typeof window > "u") return {};
2946
+ const w = new URLSearchParams(window.location.search);
2947
+ return {
2948
+ token: A || w.get("token") || "",
2949
+ email: x || w.get("email") || "",
2950
+ appId: P || w.get("appId") || "",
2951
+ tenantSlug: b || w.get("tenantSlug") || void 0
2952
+ };
2953
+ }, H = async () => {
2954
+ S("verifying"), C("");
2955
+ try {
2956
+ const w = R();
2957
+ if (!w.token || !w.email)
2958
+ throw new Error("Missing required parameters: token or email");
2959
+ const M = await q({
2960
+ token: w.token,
2961
+ email: w.email,
2962
+ tenantSlug: w.tenantSlug
2963
+ });
2964
+ S("success"), r == null || r(M), m > 0 && setTimeout(() => {
2965
+ S("redirecting");
2966
+ }, m);
2967
+ } catch (w) {
2968
+ const M = w.message || k.errorMessage;
2969
+ C(M), S("error"), s == null || s(M);
2970
+ }
2971
+ }, G = () => {
2972
+ a == null || a(), H();
2973
+ }, F = () => {
2974
+ p == null || p();
2975
+ };
2976
+ te(() => {
2977
+ H();
2978
+ }, []);
2979
+ const V = () => {
2980
+ switch (h) {
2981
+ case "verifying":
2982
+ return /* @__PURE__ */ l("div", { style: u.message, children: [
2983
+ T.loading,
2984
+ k.verifyingMessage
2985
+ ] });
2986
+ case "success":
2987
+ return /* @__PURE__ */ l(N, { children: [
2988
+ T.success,
2989
+ /* @__PURE__ */ n("div", { style: u.successMessage, children: k.successMessage })
2990
+ ] });
2991
+ case "redirecting":
2992
+ return /* @__PURE__ */ l(N, { children: [
2993
+ T.loading,
2994
+ /* @__PURE__ */ n("div", { style: u.message, children: k.redirectingMessage })
2995
+ ] });
2996
+ case "error":
2997
+ return /* @__PURE__ */ l(N, { children: [
2998
+ T.error,
2999
+ /* @__PURE__ */ n("div", { style: u.errorMessage, children: L || k.errorMessage }),
3000
+ /* @__PURE__ */ l("div", { style: u.buttonContainer, children: [
3001
+ /* @__PURE__ */ n(
3002
+ "button",
3003
+ {
3004
+ onClick: G,
3005
+ style: u.retryButton,
3006
+ onMouseOver: (w) => {
3007
+ w.currentTarget.style.backgroundColor = "#2563eb";
3008
+ },
3009
+ onMouseOut: (w) => {
3010
+ w.currentTarget.style.backgroundColor = "#3b82f6";
3011
+ },
3012
+ children: k.retryButton
3013
+ }
3014
+ ),
3015
+ /* @__PURE__ */ n(
3016
+ "button",
3017
+ {
3018
+ onClick: F,
3019
+ style: u.backButton,
3020
+ onMouseOver: (w) => {
3021
+ w.currentTarget.style.backgroundColor = "#e5e7eb";
3022
+ },
3023
+ onMouseOut: (w) => {
3024
+ w.currentTarget.style.backgroundColor = "#f3f4f6";
3025
+ },
3026
+ children: k.backToLoginButton
3027
+ }
3028
+ )
3029
+ ] })
3030
+ ] });
3031
+ default:
3032
+ return null;
3033
+ }
3034
+ };
3035
+ return /* @__PURE__ */ l("div", { style: u.container, className: I, children: [
3036
+ /* @__PURE__ */ n("style", { children: `
3037
+ @keyframes spin {
3038
+ 0% { transform: rotate(0deg); }
3039
+ 100% { transform: rotate(360deg); }
3040
+ }
3041
+ ` }),
3042
+ /* @__PURE__ */ n("h1", { style: u.title, children: k.title }),
3043
+ V()
3044
+ ] });
3045
+ }
3046
+ const ht = {
2139
3047
  title: "Reset Password",
2140
3048
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2141
3049
  emailLabel: "Email",
@@ -2157,7 +3065,7 @@ const Ge = {
2157
3065
  resetLoadingText: "Resetting...",
2158
3066
  resetSuccessMessage: "Password reset successfully!",
2159
3067
  passwordMismatchError: "Passwords do not match"
2160
- }, _e = {
3068
+ }, gt = {
2161
3069
  container: {
2162
3070
  maxWidth: "400px",
2163
3071
  margin: "0 auto",
@@ -2249,186 +3157,186 @@ const Ge = {
2249
3157
  cursor: "pointer"
2250
3158
  }
2251
3159
  };
2252
- function yt({
3160
+ function Bt({
2253
3161
  copy: i = {},
2254
3162
  styles: e = {},
2255
3163
  mode: t = "request",
2256
3164
  token: r = "",
2257
- onSuccess: n,
2258
- onError: o,
2259
- onBackToLogin: m,
2260
- onModeChange: T,
2261
- className: M
3165
+ onSuccess: s,
3166
+ onError: a,
3167
+ onBackToLogin: p,
3168
+ onModeChange: I,
3169
+ className: A
2262
3170
  }) {
2263
- const [P, g] = b(""), [h, x] = b(r), [p, A] = b(""), [F, f] = b(""), [L, y] = b(!1), [S, k] = b(""), [R, D] = b(""), [E, B] = b({}), { requestPasswordReset: d, confirmPasswordReset: w } = ne(), { tenant: u } = K(), a = { ...Ge, ...i }, l = { ..._e, ...e }, W = () => {
2264
- const q = {};
2265
- return P.trim() || (q.email = !0), B(q), Object.keys(q).length === 0;
2266
- }, I = () => {
2267
- const q = {};
2268
- return h.trim() || (q.token = !0), p.trim() || (q.newPassword = !0), F.trim() || (q.confirmPassword = !0), B(q), Object.keys(q).length === 0;
2269
- }, N = async (q) => {
2270
- if (q.preventDefault(), !!W()) {
2271
- if (!(u != null && u.id)) {
2272
- k("Tenant not found");
3171
+ const [x, P] = v(""), [b, m] = v(r), [h, S] = v(""), [L, C] = v(""), [q, k] = v(!1), [u, T] = v(""), [R, H] = v(""), [G, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, o = { ...gt, ...e }, g = () => {
3172
+ const z = {};
3173
+ return x.trim() || (z.email = !0), F(z), Object.keys(z).length === 0;
3174
+ }, f = () => {
3175
+ const z = {};
3176
+ return b.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), L.trim() || (z.confirmPassword = !0), F(z), Object.keys(z).length === 0;
3177
+ }, d = async (z) => {
3178
+ if (z.preventDefault(), !!g()) {
3179
+ if (!(M != null && M.id)) {
3180
+ T("Tenant not found");
2273
3181
  return;
2274
3182
  }
2275
- y(!0), k(""), D("");
3183
+ k(!0), T(""), H("");
2276
3184
  try {
2277
- await d(P, u.id), D(a.successMessage), n == null || n();
2278
- } catch (O) {
2279
- const j = O.message || a.errorMessage;
2280
- k(j), o == null || o(j);
3185
+ await V({ email: x, tenantId: M.id }), H(E.successMessage), s == null || s();
3186
+ } catch (B) {
3187
+ const O = B.message || E.errorMessage;
3188
+ T(O), a == null || a(O);
2281
3189
  } finally {
2282
- y(!1);
3190
+ k(!1);
2283
3191
  }
2284
3192
  }
2285
- }, _ = async (q) => {
2286
- if (q.preventDefault(), !!I()) {
2287
- if (p !== F) {
2288
- k(a.passwordMismatchError), B({ confirmPassword: !0 });
3193
+ }, c = async (z) => {
3194
+ if (z.preventDefault(), !!f()) {
3195
+ if (h !== L) {
3196
+ T(E.passwordMismatchError), F({ confirmPassword: !0 });
2289
3197
  return;
2290
3198
  }
2291
- y(!0), k(""), D("");
3199
+ k(!0), T(""), H("");
2292
3200
  try {
2293
- await w(h, p), D(a.resetSuccessMessage), n == null || n();
2294
- } catch (O) {
2295
- const j = O.message || a.errorMessage;
2296
- k(j), o == null || o(j);
3201
+ await w({ token: b, newPassword: h }), H(E.resetSuccessMessage), s == null || s();
3202
+ } catch (B) {
3203
+ const O = B.message || E.errorMessage;
3204
+ T(O), a == null || a(O);
2297
3205
  } finally {
2298
- y(!1);
3206
+ k(!1);
2299
3207
  }
2300
3208
  }
2301
- }, C = (q) => ({
2302
- ...l.input,
2303
- ...E[q] ? l.inputError : {}
2304
- }), U = () => ({
2305
- ...l.button,
2306
- ...L ? l.buttonLoading : {}
3209
+ }, y = (z) => ({
3210
+ ...o.input,
3211
+ ...G[z] ? o.inputError : {}
3212
+ }), W = () => ({
3213
+ ...o.button,
3214
+ ...q ? o.buttonLoading : {}
2307
3215
  });
2308
3216
  if (t === "reset") {
2309
- const q = h && p && F;
2310
- return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
2311
- /* @__PURE__ */ s("h2", { style: l.title, children: a.resetTitle }),
2312
- /* @__PURE__ */ s("p", { style: l.subtitle, children: a.resetSubtitle }),
2313
- /* @__PURE__ */ c("form", { onSubmit: _, style: l.form, children: [
2314
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2315
- /* @__PURE__ */ s("label", { style: l.label, children: a.tokenLabel }),
2316
- /* @__PURE__ */ s(
3217
+ const z = b && h && L;
3218
+ return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3219
+ /* @__PURE__ */ n("h2", { style: o.title, children: E.resetTitle }),
3220
+ /* @__PURE__ */ n("p", { style: o.subtitle, children: E.resetSubtitle }),
3221
+ /* @__PURE__ */ l("form", { onSubmit: c, style: o.form, children: [
3222
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3223
+ /* @__PURE__ */ n("label", { style: o.label, children: E.tokenLabel }),
3224
+ /* @__PURE__ */ n(
2317
3225
  "input",
2318
3226
  {
2319
3227
  type: "text",
2320
- value: h,
2321
- onChange: (O) => {
2322
- x(O.target.value), E.token && B((j) => ({ ...j, token: !1 }));
3228
+ value: b,
3229
+ onChange: (B) => {
3230
+ m(B.target.value), G.token && F((O) => ({ ...O, token: !1 }));
2323
3231
  },
2324
- placeholder: a.tokenPlaceholder,
2325
- style: C("token"),
2326
- disabled: L
3232
+ placeholder: E.tokenPlaceholder,
3233
+ style: y("token"),
3234
+ disabled: q
2327
3235
  }
2328
3236
  )
2329
3237
  ] }),
2330
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2331
- /* @__PURE__ */ s("label", { style: l.label, children: a.newPasswordLabel }),
2332
- /* @__PURE__ */ s(
3238
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3239
+ /* @__PURE__ */ n("label", { style: o.label, children: E.newPasswordLabel }),
3240
+ /* @__PURE__ */ n(
2333
3241
  "input",
2334
3242
  {
2335
3243
  type: "password",
2336
- value: p,
2337
- onChange: (O) => {
2338
- A(O.target.value), E.newPassword && B((j) => ({ ...j, newPassword: !1 }));
3244
+ value: h,
3245
+ onChange: (B) => {
3246
+ S(B.target.value), G.newPassword && F((O) => ({ ...O, newPassword: !1 }));
2339
3247
  },
2340
- placeholder: a.newPasswordPlaceholder,
2341
- style: C("newPassword"),
2342
- disabled: L
3248
+ placeholder: E.newPasswordPlaceholder,
3249
+ style: y("newPassword"),
3250
+ disabled: q
2343
3251
  }
2344
3252
  )
2345
3253
  ] }),
2346
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2347
- /* @__PURE__ */ s("label", { style: l.label, children: a.confirmPasswordLabel }),
2348
- /* @__PURE__ */ s(
3254
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3255
+ /* @__PURE__ */ n("label", { style: o.label, children: E.confirmPasswordLabel }),
3256
+ /* @__PURE__ */ n(
2349
3257
  "input",
2350
3258
  {
2351
3259
  type: "password",
2352
- value: F,
2353
- onChange: (O) => {
2354
- f(O.target.value), E.confirmPassword && B((j) => ({ ...j, confirmPassword: !1 })), S === a.passwordMismatchError && k("");
3260
+ value: L,
3261
+ onChange: (B) => {
3262
+ C(B.target.value), G.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && T("");
2355
3263
  },
2356
- placeholder: a.confirmPasswordPlaceholder,
2357
- style: C("confirmPassword"),
2358
- disabled: L
3264
+ placeholder: E.confirmPasswordPlaceholder,
3265
+ style: y("confirmPassword"),
3266
+ disabled: q
2359
3267
  }
2360
3268
  )
2361
3269
  ] }),
2362
- /* @__PURE__ */ s(
3270
+ /* @__PURE__ */ n(
2363
3271
  "button",
2364
3272
  {
2365
3273
  type: "submit",
2366
- disabled: !q || L,
3274
+ disabled: !z || q,
2367
3275
  style: {
2368
- ...U(),
2369
- ...!q || L ? l.buttonDisabled : {}
3276
+ ...W(),
3277
+ ...!z || q ? o.buttonDisabled : {}
2370
3278
  },
2371
- children: L ? a.resetLoadingText : a.resetSubmitButton
3279
+ children: q ? E.resetLoadingText : E.resetSubmitButton
2372
3280
  }
2373
3281
  ),
2374
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2375
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3282
+ u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3283
+ R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
2376
3284
  ] }),
2377
- /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
2378
- /* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
2379
- T && /* @__PURE__ */ c(H, { children: [
2380
- /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2381
- /* @__PURE__ */ s("a", { onClick: () => T("request"), style: l.link, children: "Request New Link" })
3285
+ /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3286
+ /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3287
+ I && /* @__PURE__ */ l(N, { children: [
3288
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3289
+ /* @__PURE__ */ n("a", { onClick: () => I("request"), style: o.link, children: "Request New Link" })
2382
3290
  ] })
2383
3291
  ] })
2384
3292
  ] });
2385
3293
  }
2386
- const Q = P;
2387
- return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
2388
- /* @__PURE__ */ s("h2", { style: l.title, children: a.title }),
2389
- /* @__PURE__ */ s("p", { style: l.subtitle, children: a.subtitle }),
2390
- /* @__PURE__ */ c("form", { onSubmit: N, style: l.form, children: [
2391
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2392
- /* @__PURE__ */ s("label", { style: l.label, children: a.emailLabel }),
2393
- /* @__PURE__ */ s(
3294
+ const ee = x;
3295
+ return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3296
+ /* @__PURE__ */ n("h2", { style: o.title, children: E.title }),
3297
+ /* @__PURE__ */ n("p", { style: o.subtitle, children: E.subtitle }),
3298
+ /* @__PURE__ */ l("form", { onSubmit: d, style: o.form, children: [
3299
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3300
+ /* @__PURE__ */ n("label", { style: o.label, children: E.emailLabel }),
3301
+ /* @__PURE__ */ n(
2394
3302
  "input",
2395
3303
  {
2396
3304
  type: "email",
2397
- value: P,
2398
- onChange: (q) => {
2399
- g(q.target.value), E.email && B((O) => ({ ...O, email: !1 }));
3305
+ value: x,
3306
+ onChange: (z) => {
3307
+ P(z.target.value), G.email && F((B) => ({ ...B, email: !1 }));
2400
3308
  },
2401
- placeholder: a.emailPlaceholder,
2402
- style: C("email"),
2403
- disabled: L
3309
+ placeholder: E.emailPlaceholder,
3310
+ style: y("email"),
3311
+ disabled: q
2404
3312
  }
2405
3313
  )
2406
3314
  ] }),
2407
- /* @__PURE__ */ s(
3315
+ /* @__PURE__ */ n(
2408
3316
  "button",
2409
3317
  {
2410
3318
  type: "submit",
2411
- disabled: !Q || L,
3319
+ disabled: !ee || q,
2412
3320
  style: {
2413
- ...U(),
2414
- ...!Q || L ? l.buttonDisabled : {}
3321
+ ...W(),
3322
+ ...!ee || q ? o.buttonDisabled : {}
2415
3323
  },
2416
- children: L ? a.loadingText : a.submitButton
3324
+ children: q ? E.loadingText : E.submitButton
2417
3325
  }
2418
3326
  ),
2419
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2420
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3327
+ u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3328
+ R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
2421
3329
  ] }),
2422
- /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
2423
- /* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
2424
- T && /* @__PURE__ */ c(H, { children: [
2425
- /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2426
- /* @__PURE__ */ s("a", { onClick: () => T("reset"), style: l.link, children: "I have a token" })
3330
+ /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3331
+ /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3332
+ I && /* @__PURE__ */ l(N, { children: [
3333
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3334
+ /* @__PURE__ */ n("a", { onClick: () => I("reset"), style: o.link, children: "I have a token" })
2427
3335
  ] })
2428
3336
  ] })
2429
3337
  ] });
2430
3338
  }
2431
- class wt {
3339
+ class Ut {
2432
3340
  constructor(e, t) {
2433
3341
  this.httpService = e, this.sessionManager = t;
2434
3342
  }
@@ -2449,12 +3357,12 @@ class wt {
2449
3357
  throw new Error("SessionManager is required for private endpoints");
2450
3358
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2451
3359
  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);
2452
- const n = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
3360
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2453
3361
  headers: t
2454
3362
  });
2455
3363
  return {
2456
- permissions: o.data,
2457
- meta: o.meta
3364
+ permissions: a.data,
3365
+ meta: a.meta
2458
3366
  };
2459
3367
  }
2460
3368
  async getPermissionById(e) {
@@ -2489,14 +3397,14 @@ class wt {
2489
3397
  async getAppPermissions(e, t) {
2490
3398
  const r = new URLSearchParams();
2491
3399
  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);
2492
- const n = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
3400
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
2493
3401
  return {
2494
- permissions: o.data,
2495
- meta: o.meta
3402
+ permissions: a.data,
3403
+ meta: a.meta
2496
3404
  };
2497
3405
  }
2498
3406
  }
2499
- class mt {
3407
+ class qt {
2500
3408
  constructor(e, t) {
2501
3409
  this.httpService = e, this.sessionManager = t;
2502
3410
  }
@@ -2513,12 +3421,12 @@ class mt {
2513
3421
  async getSubscriptionPlans(e) {
2514
3422
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2515
3423
  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);
2516
- const n = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
3424
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2517
3425
  headers: t
2518
3426
  });
2519
3427
  return {
2520
- plans: o.data,
2521
- meta: o.meta
3428
+ plans: a.data,
3429
+ meta: a.meta
2522
3430
  };
2523
3431
  }
2524
3432
  async getSubscriptionPlanById(e) {
@@ -2547,7 +3455,7 @@ class mt {
2547
3455
  });
2548
3456
  }
2549
3457
  }
2550
- class bt {
3458
+ class zt {
2551
3459
  constructor(e) {
2552
3460
  this.httpService = e;
2553
3461
  }
@@ -2556,7 +3464,7 @@ class bt {
2556
3464
  return await this.httpService.get("/health");
2557
3465
  }
2558
3466
  }
2559
- class St {
3467
+ class Ot {
2560
3468
  // Date string to Date object
2561
3469
  static toDate(e) {
2562
3470
  return new Date(e);
@@ -2673,48 +3581,50 @@ class St {
2673
3581
  // Transform query parameters for API calls
2674
3582
  static transformQueryParams(e) {
2675
3583
  const t = new URLSearchParams();
2676
- return Object.entries(e).forEach(([r, n]) => {
2677
- n != null && n !== "" && t.append(r, String(n));
3584
+ return Object.entries(e).forEach(([r, s]) => {
3585
+ s != null && s !== "" && t.append(r, String(s));
2678
3586
  }), t;
2679
3587
  }
2680
3588
  }
2681
3589
  export {
2682
- St as ApiMappers,
2683
- Se as AppApiService,
2684
- et as AppProvider,
2685
- Pe as AuthApiService,
2686
- it as AuthProvider,
2687
- gt as FeatureFlag,
2688
- Ee as FeatureFlagApiService,
2689
- ot as FeatureFlagProvider,
2690
- bt as HealthApiService,
2691
- G as HttpService,
2692
- ut as LandingRoute,
2693
- pt as LoginForm,
2694
- yt as PasswordRecoveryForm,
2695
- wt as PermissionApiService,
2696
- lt as Protected,
2697
- ct as ProtectedRoute,
2698
- ce as RoleApiService,
2699
- Ae as SessionManager,
2700
- ft as SignupForm,
2701
- Fe as SubscriptionApiService,
2702
- ht as SubscriptionGuard,
2703
- mt as SubscriptionPlanApiService,
2704
- at as SubscriptionProvider,
2705
- de as TenantApiService,
2706
- rt as TenantProvider,
2707
- dt as TenantRoute,
2708
- ke as UserApiService,
2709
- X as UserType,
2710
- tt as useApi,
2711
- se as useApp,
2712
- ne as useAuth,
2713
- Re as useFeatureFlags,
2714
- nt as useSettings,
2715
- Ie as useSubscription,
2716
- le as useTenant,
2717
- K as useTenantInfo,
2718
- st as useTenantSettings
3590
+ Ot as ApiMappers,
3591
+ be as AppApiService,
3592
+ St as AppProvider,
3593
+ Ne as AuthApiService,
3594
+ Pt as AuthProvider,
3595
+ Ft as FeatureFlag,
3596
+ ze as FeatureFlagApiService,
3597
+ Tt as FeatureFlagProvider,
3598
+ zt as HealthApiService,
3599
+ re as HttpService,
3600
+ Ct as LandingRoute,
3601
+ $t as LoginForm,
3602
+ Ht as MagicLinkForm,
3603
+ Nt as MagicLinkVerify,
3604
+ Bt as PasswordRecoveryForm,
3605
+ Ut as PermissionApiService,
3606
+ It as Protected,
3607
+ Et as ProtectedRoute,
3608
+ Se as RoleApiService,
3609
+ ye as SessionManager,
3610
+ Dt as SignupForm,
3611
+ je as SubscriptionApiService,
3612
+ Lt as SubscriptionGuard,
3613
+ qt as SubscriptionPlanApiService,
3614
+ Mt as SubscriptionProvider,
3615
+ ce as TenantApiService,
3616
+ xt as TenantProvider,
3617
+ Rt as TenantRoute,
3618
+ Be as UserApiService,
3619
+ ie as UserType,
3620
+ vt as useApi,
3621
+ he as useApp,
3622
+ oe as useAuth,
3623
+ Oe as useFeatureFlags,
3624
+ At as useSettings,
3625
+ Ve as useSubscription,
3626
+ fe as useTenant,
3627
+ se as useTenantInfo,
3628
+ kt as useTenantSettings
2719
3629
  };
2720
3630
  //# sourceMappingURL=index.es.js.map