@skylabs-digital/react-identity-access 1.5.0 → 1.6.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 D, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as ae, useState as p, useMemo as _, useCallback as oe, useEffect as Z, useContext as le } from "react";
3
+ import { useLocation as he, Navigate as de } from "react-router-dom";
4
+ class te {
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 b = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, E = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let L = {
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 m = await this.sessionManager.getAuthHeaders();
27
+ L = { ...L, ...m };
28
+ } catch (m) {
29
+ console.warn("Failed to inject auth headers:", m);
30
30
  }
31
- const P = new AbortController(), g = setTimeout(() => P.abort(), T);
31
+ const P = new AbortController(), f = setTimeout(() => P.abort(), E);
32
32
  try {
33
- const h = await fetch(m, {
33
+ const m = await fetch(b, {
34
34
  method: e,
35
- headers: M,
35
+ headers: L,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
37
  signal: P.signal
38
38
  });
39
- if (clearTimeout(g), h.status === 401 && !(n != null && n.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(f), m.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 w = this.sessionManager.getTokens();
42
+ if (w != null && w.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 ${m.status}: ${m.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 (!m.ok)
48
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
49
+ const M = m.headers.get("content-type");
50
+ return !M || !M.includes("application/json") ? {} : await m.json();
51
+ } catch (m) {
52
+ throw clearTimeout(f), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${E}ms`) : m;
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 Te {
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 we = ae(null), Me = () => /* @__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
+ ), Ee = ({ 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,9 +170,9 @@ 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 ht({ config: i, children: e }) {
174
+ const [t, r] = p(null), [s, a] = p(!0), [b, E] = p(null), L = _(() => {
175
+ const f = () => {
176
176
  P();
177
177
  };
178
178
  return {
@@ -180,40 +180,40 @@ function et({ config: i, children: e }) {
180
180
  baseUrl: i.baseUrl,
181
181
  // App info
182
182
  appInfo: t,
183
- isAppLoading: n,
184
- appError: m,
185
- retryApp: g
183
+ isAppLoading: s,
184
+ appError: b,
185
+ retryApp: f
186
186
  };
187
- }, [i, t, n, m]), P = Z(async () => {
187
+ }, [i, t, s, b]), P = oe(async () => {
188
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);
189
+ a(!0), E(null);
190
+ const f = new te(i.baseUrl), M = await new Te(f, {}).getPublicAppInfo(i.appId);
191
+ r(M);
192
+ } catch (f) {
193
+ const m = f instanceof Error ? f : new Error("Failed to load app information");
194
+ E(m), r(null);
195
195
  } finally {
196
- o(!1);
196
+ a(!1);
197
197
  }
198
198
  }, [i.baseUrl, i.appId]);
199
- if (Y(() => {
199
+ if (Z(() => {
200
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 });
201
+ }, [P]), s)
202
+ return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Me, {}) });
203
+ if (b) {
204
+ const f = typeof i.errorFallback == "function" ? i.errorFallback(b, () => P()) : i.errorFallback || /* @__PURE__ */ n(Ee, { error: b, retry: () => P() });
205
+ return /* @__PURE__ */ n(D, { children: f });
206
206
  }
207
- return /* @__PURE__ */ s(pe.Provider, { value: M, children: e });
207
+ return /* @__PURE__ */ n(we.Provider, { value: L, children: e });
208
208
  }
209
- function se() {
210
- const i = re(pe);
209
+ function ne() {
210
+ const i = le(we);
211
211
  if (!i)
212
212
  throw new Error("useApp must be used within an AppProvider");
213
213
  return i;
214
214
  }
215
- const tt = se;
216
- class Ae {
215
+ const gt = ne;
216
+ class Le {
217
217
  constructor(e = {}) {
218
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 || {
219
219
  get: () => {
@@ -281,10 +281,10 @@ class Ae {
281
281
  try {
282
282
  await this.refreshPromise;
283
283
  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;
284
+ return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
285
285
  } catch (t) {
286
286
  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(), {};
287
+ return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
288
288
  } finally {
289
289
  this.refreshPromise = null;
290
290
  }
@@ -303,11 +303,11 @@ class Ae {
303
303
  });
304
304
  if (!r.ok)
305
305
  throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
306
- const n = await r.json();
306
+ const s = await r.json();
307
307
  this.setTokens({
308
- accessToken: n.accessToken,
309
- refreshToken: n.refreshToken || e,
310
- expiresIn: n.expiresIn
308
+ accessToken: s.accessToken,
309
+ refreshToken: s.refreshToken || e,
310
+ expiresIn: s.expiresIn
311
311
  });
312
312
  }
313
313
  setUser(e) {
@@ -330,7 +330,7 @@ class Ae {
330
330
  return e !== null && !this.isTokenExpired(e);
331
331
  }
332
332
  }
333
- class Pe {
333
+ class Re {
334
334
  constructor(e) {
335
335
  this.httpService = e;
336
336
  }
@@ -354,6 +354,18 @@ class Pe {
354
354
  async requestPasswordReset(e) {
355
355
  await this.httpService.post("/auth/password-reset/request", e);
356
356
  }
357
+ async sendMagicLink(e) {
358
+ return await this.httpService.post(
359
+ "/auth/magic-link/send",
360
+ e
361
+ );
362
+ }
363
+ async verifyMagicLink(e) {
364
+ return await this.httpService.post(
365
+ "/auth/magic-link/verify",
366
+ e
367
+ );
368
+ }
357
369
  async confirmPasswordReset(e) {
358
370
  await this.httpService.post("/auth/password-reset/confirm", e);
359
371
  }
@@ -364,7 +376,7 @@ class Pe {
364
376
  });
365
377
  }
366
378
  }
367
- class ce {
379
+ class pe {
368
380
  constructor(e, t) {
369
381
  this.httpService = e, this.sessionManager = t;
370
382
  }
@@ -404,10 +416,10 @@ class ce {
404
416
  async getRolesByApp(e, t) {
405
417
  const r = new URLSearchParams();
406
418
  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);
419
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
408
420
  return {
409
- roles: o.data,
410
- meta: o.meta
421
+ roles: a.data,
422
+ meta: a.meta
411
423
  };
412
424
  }
413
425
  async assignRole(e, t) {
@@ -429,18 +441,18 @@ class ce {
429
441
  async getUserRoles(e, t) {
430
442
  if (!this.sessionManager)
431
443
  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, {
444
+ const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
445
+ 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);
446
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, b = await this.httpService.get(a, {
435
447
  headers: r
436
448
  });
437
449
  return {
438
- roles: m.data,
439
- meta: m.meta
450
+ roles: b.data,
451
+ meta: b.meta
440
452
  };
441
453
  }
442
454
  }
443
- class ke {
455
+ class Ce {
444
456
  constructor(e, t) {
445
457
  this.httpService = e, this.sessionManager = t;
446
458
  }
@@ -453,12 +465,12 @@ class ke {
453
465
  async getUsers(e) {
454
466
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
455
467
  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, {
468
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
457
469
  headers: t
458
470
  });
459
471
  return {
460
- users: o.data,
461
- meta: o.meta
472
+ users: a.data,
473
+ meta: a.meta
462
474
  };
463
475
  }
464
476
  async getUserById(e) {
@@ -480,7 +492,7 @@ class ke {
480
492
  });
481
493
  }
482
494
  }
483
- class de {
495
+ class fe {
484
496
  constructor(e, t, r) {
485
497
  this.httpService = e, this.appId = t, this.sessionManager = r;
486
498
  }
@@ -497,12 +509,12 @@ class de {
497
509
  throw new Error("SessionManager is required for private endpoints");
498
510
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
499
511
  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, {
512
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
501
513
  headers: t
502
514
  });
503
515
  return {
504
- tenants: o.data,
505
- meta: o.meta
516
+ tenants: a.data,
517
+ meta: a.meta
506
518
  };
507
519
  }
508
520
  async getTenantById(e) {
@@ -558,7 +570,7 @@ class de {
558
570
  )).data;
559
571
  }
560
572
  }
561
- const fe = te(null), Te = () => /* @__PURE__ */ s(
573
+ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
562
574
  "div",
563
575
  {
564
576
  style: {
@@ -568,9 +580,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
568
580
  height: "100vh",
569
581
  fontFamily: "system-ui, sans-serif"
570
582
  },
571
- children: /* @__PURE__ */ s("div", { children: "Loading tenant..." })
583
+ children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
584
  }
573
- ), Me = ({ error: i, retry: e }) => /* @__PURE__ */ c(
585
+ ), Fe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
574
586
  "div",
575
587
  {
576
588
  style: {
@@ -584,9 +596,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
584
596
  padding: "20px"
585
597
  },
586
598
  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(
599
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
600
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
601
+ /* @__PURE__ */ n(
590
602
  "button",
591
603
  {
592
604
  onClick: e,
@@ -604,77 +616,77 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
604
616
  ]
605
617
  }
606
618
  );
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";
619
+ function pt({ config: i, children: e }) {
620
+ const { baseUrl: t, appInfo: r, appId: s } = ne(), [a, b] = p(i.initialTenant || null), [E, L] = p(!i.initialTenant), [P, f] = p(null), [m, M] = p(null), [w, v] = p(!1), [I, g] = p(null), U = oe(() => {
621
+ const S = i.tenantMode || "selector", c = "tenant";
610
622
  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;
623
+ if (S === "subdomain") {
624
+ const o = window.location.hostname.split(".");
625
+ if (o.length >= 3) {
626
+ const d = o[0];
627
+ return localStorage.setItem(c, d), d;
616
628
  }
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);
629
+ return localStorage.getItem(c);
630
+ } else if (S === "selector") {
631
+ const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
632
+ return o ? (localStorage.setItem(c, o), o) : localStorage.getItem(c);
621
633
  }
622
634
  return null;
623
- }, [i.tenantMode, i.selectorParam]), y = z(() => L(), [L]), S = (r == null ? void 0 : r.settingsSchema) || null, k = Z(
624
- async (d) => {
635
+ }, [i.tenantMode, i.selectorParam]), u = _(() => U(), [U]), y = (r == null ? void 0 : r.settingsSchema) || null, x = oe(
636
+ async (S) => {
625
637
  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);
638
+ L(!0), f(null);
639
+ const c = new te(t), o = await new fe(c, s).getPublicTenantInfo(S);
640
+ b(o);
641
+ } catch (c) {
642
+ const h = c instanceof Error ? c : new Error("Failed to load tenant information");
643
+ f(h), b(null);
632
644
  } finally {
633
- M(!1);
645
+ L(!1);
634
646
  }
635
647
  },
636
- [t, n]
637
- ), R = Z(async () => {
638
- if (o != null && o.id)
648
+ [t, s]
649
+ ), F = oe(async () => {
650
+ if (a != null && a.id)
639
651
  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);
652
+ v(!0), g(null);
653
+ const S = new te(t), h = await new fe(S, a.appId).getTenantSettings(a.id);
654
+ M(h);
655
+ } catch (S) {
656
+ const c = S instanceof Error ? S : new Error("Failed to load tenant settings");
657
+ g(c), M(null);
646
658
  } finally {
647
- A(!1);
659
+ v(!1);
648
660
  }
649
- }, [t, o]), D = Z(() => {
650
- R();
651
- }, [R]), E = Z(
652
- (d) => {
653
- if (!S)
661
+ }, [t, a]), B = oe(() => {
662
+ F();
663
+ }, [F]), z = oe(
664
+ (S) => {
665
+ if (!y)
654
666
  return { isValid: !0, errors: [] };
655
- const w = [];
667
+ const c = [];
656
668
  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`);
669
+ return y.properties && Object.entries(y.properties).forEach(([h, o]) => {
670
+ var G;
671
+ const d = S[h];
672
+ if ((G = y.required) != null && G.includes(h) && d == null) {
673
+ c.push(`Field '${h}' is required`);
662
674
  return;
663
675
  }
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`);
676
+ if (d != null) {
677
+ if (o.type) {
678
+ const Y = o.type, H = typeof d;
679
+ Y === "string" && H !== "string" ? c.push(`Field '${h}' must be a string`) : (Y === "number" || Y === "integer") && H !== "number" ? c.push(`Field '${h}' must be a number`) : Y === "boolean" && H !== "boolean" ? c.push(`Field '${h}' must be a boolean`) : Y === "array" && !Array.isArray(d) && c.push(`Field '${h}' must be an array`);
668
680
  }
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(", ")}`);
681
+ o.minLength !== void 0 && typeof d == "string" && d.length < o.minLength && c.push(
682
+ `Field '${h}' must be at least ${o.minLength} characters long`
683
+ ), o.maxLength !== void 0 && typeof d == "string" && d.length > o.maxLength && c.push(
684
+ `Field '${h}' must be no more than ${o.maxLength} characters long`
685
+ ), o.minimum !== void 0 && typeof d == "number" && d < o.minimum && c.push(`Field '${h}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof d == "number" && d > o.maximum && c.push(`Field '${h}' must be no more than ${o.maximum}`), o.pattern && typeof d == "string" && (new RegExp(o.pattern).test(d) || c.push(`Field '${h}' does not match the required pattern`)), o.enum && !o.enum.includes(d) && c.push(`Field '${h}' must be one of: ${o.enum.join(", ")}`);
674
686
  }
675
687
  }), {
676
- isValid: w.length === 0,
677
- errors: w
688
+ isValid: c.length === 0,
689
+ errors: c
678
690
  };
679
691
  } catch {
680
692
  return {
@@ -683,276 +695,321 @@ function rt({ config: i, children: e }) {
683
695
  };
684
696
  }
685
697
  },
686
- [S]
698
+ [y]
687
699
  );
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(() => ({
700
+ Z(() => {
701
+ !i.initialTenant && u ? x(u) : !i.initialTenant && !u && (b(null), f(null), L(!1));
702
+ }, [i.initialTenant, u, x]), Z(() => {
703
+ a != null && a.id ? F() : (M(null), g(null), v(!1));
704
+ }, [a == null ? void 0 : a.id, F]);
705
+ const q = _(() => ({
694
706
  // Tenant info
695
- tenant: o,
696
- tenantSlug: y,
697
- isTenantLoading: T,
707
+ tenant: a,
708
+ tenantSlug: u,
709
+ isTenantLoading: E,
698
710
  tenantError: P,
699
711
  retryTenant: () => {
700
- y && k(y);
712
+ u && x(u);
701
713
  },
702
714
  // Settings
703
- settings: h,
704
- settingsSchema: S,
705
- isSettingsLoading: p,
706
- settingsError: F,
715
+ settings: m,
716
+ settingsSchema: y,
717
+ isSettingsLoading: w,
718
+ settingsError: I,
707
719
  // Actions
708
- refreshSettings: D,
720
+ refreshSettings: B,
709
721
  // Validation
710
- validateSettings: E
722
+ validateSettings: z
711
723
  }), [
712
- o,
713
- y,
714
- T,
724
+ a,
725
+ u,
726
+ E,
715
727
  P,
716
- h,
717
- S,
718
- p,
719
- F,
720
- D,
721
- E
728
+ m,
729
+ y,
730
+ w,
731
+ I,
732
+ B,
733
+ z
722
734
  ]);
723
- if (T)
724
- return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(Te, {}) });
735
+ if (E)
736
+ return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Ie, {}) });
725
737
  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 });
738
+ const S = typeof i.errorFallback == "function" ? i.errorFallback(P, () => x(u || "")) : i.errorFallback || /* @__PURE__ */ n(Fe, { error: P, retry: () => x(u || "") });
739
+ return /* @__PURE__ */ n(D, { children: S });
728
740
  }
729
- return /* @__PURE__ */ s(fe.Provider, { value: B, children: e });
741
+ return /* @__PURE__ */ n(ve.Provider, { value: q, children: e });
730
742
  }
731
- function le() {
732
- const i = re(fe);
743
+ function ge() {
744
+ const i = le(ve);
733
745
  if (!i)
734
746
  throw new Error("useTenant must be used within a TenantProvider");
735
747
  return i;
736
748
  }
737
- const st = le;
738
- function nt() {
739
- const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: n } = le();
749
+ const ft = ge;
750
+ function mt() {
751
+ const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = ge();
740
752
  return {
741
753
  settings: i,
742
754
  settingsSchema: e,
743
755
  isLoading: t,
744
756
  error: r,
745
- validateSettings: n
757
+ validateSettings: s
746
758
  };
747
759
  }
748
- function K() {
749
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: n } = le();
760
+ function re() {
761
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ge();
750
762
  return {
751
763
  tenant: i,
752
764
  tenantSlug: e,
753
765
  isLoading: t,
754
766
  error: r,
755
- retry: n
767
+ retry: s
756
768
  };
757
769
  }
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 = {
770
+ const Se = ae(null);
771
+ function yt({ config: i = {}, children: e }) {
772
+ const { appId: t, baseUrl: r } = ne(), s = re(), a = (s == null ? void 0 : s.tenantSlug) || null, [b, E] = p(i.initialRoles || []), [L, P] = p(!i.initialRoles), [f, m] = p(null), [M, w] = p(!1), [v, I] = p(null), g = _(() => {
773
+ const S = a ? `auth_tokens_${a}` : "auth_tokens", c = {
762
774
  get: () => {
763
775
  try {
764
- const u = localStorage.getItem(d);
765
- return u ? JSON.parse(u) : null;
776
+ const h = localStorage.getItem(S);
777
+ return h ? JSON.parse(h) : null;
766
778
  } catch {
767
779
  return null;
768
780
  }
769
781
  },
770
- set: (u) => {
782
+ set: (h) => {
771
783
  try {
772
- localStorage.setItem(d, JSON.stringify(u));
784
+ localStorage.setItem(S, JSON.stringify(h));
773
785
  } catch {
774
786
  }
775
787
  },
776
788
  clear: () => {
777
789
  try {
778
- localStorage.removeItem(d);
790
+ localStorage.removeItem(S);
779
791
  } catch {
780
792
  }
781
793
  }
782
794
  };
783
- return new Ae({
795
+ return new Le({
784
796
  onRefreshFailed: i.onRefreshFailed,
785
- tokenStorage: w,
797
+ tokenStorage: c,
786
798
  baseUrl: r
787
799
  });
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 () => {
800
+ }, [a, r, i.onRefreshFailed]), U = _(() => {
801
+ const S = new te(r);
802
+ return S.setSessionManager(g), S;
803
+ }, [r, g]), u = _(() => new Re(new te(r)), [r]), y = _(() => new Ce(U, g), [U, g]), x = _(() => new pe(new te(r)), [r]), F = _(() => f || g.getUser(), [f, g]), B = _(() => F != null && F.roleId && b.find((S) => S.id === F.roleId) || null, [F, b]), z = _(() => (B == null ? void 0 : B.permissions) || [], [B]);
804
+ Z(() => {
805
+ console.log("AuthProvider - userPermissions changed:", z);
806
+ }, [z]);
807
+ const q = _(() => {
808
+ const S = async () => {
797
809
  try {
798
- p(!0), F(null);
799
- const v = f.getUser();
800
- if (!(v != null && v.id))
810
+ w(!0), I(null);
811
+ const A = g.getUser();
812
+ if (!(A != null && A.id))
801
813
  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:", $);
814
+ const $ = await y.getUserById(A.id);
815
+ m($), g.setUser($);
816
+ } catch (A) {
817
+ const $ = A instanceof Error ? A : new Error("Failed to load user data");
818
+ I($), console.error("Failed to load user data:", $);
807
819
  } finally {
808
- p(!1);
820
+ w(!1);
809
821
  }
810
- }, w = async () => {
811
- await d();
812
- }, u = async (v, $, J) => {
813
- const V = await y.login({
814
- email: v,
822
+ }, c = async () => {
823
+ await S();
824
+ }, h = async (A, $, Q, X) => {
825
+ const W = await u.login({
826
+ username: A,
815
827
  password: $,
816
- tenantId: J
828
+ appId: Q,
829
+ tenantId: X
817
830
  });
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);
831
+ if (g.setTokens({
832
+ accessToken: W.accessToken,
833
+ refreshToken: W.refreshToken,
834
+ expiresIn: W.expiresIn
835
+ }), W.user) {
836
+ g.setUser(W.user), m(W.user);
824
837
  try {
825
- await d();
838
+ await S();
826
839
  } catch (ee) {
827
840
  console.warn("Failed to load complete user data after login:", ee);
828
841
  }
829
842
  }
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))
843
+ return W;
844
+ }, o = async (A, $, Q, X, W, ee, ce) => {
845
+ if (!A && !$)
846
+ throw new Error("Either email or phoneNumber is required");
847
+ if (!Q || !X)
848
+ throw new Error("Name and password are required");
849
+ return await u.signup({
850
+ email: A,
851
+ phoneNumber: $,
852
+ name: Q,
853
+ password: X,
854
+ tenantId: W,
855
+ lastName: ee,
856
+ appId: ce
857
+ });
858
+ }, d = async (A, $, Q, X, W, ee, ce) => {
859
+ if (!A && !$)
860
+ throw new Error("Either email or phoneNumber is required");
861
+ if (!Q || !X || !W)
862
+ throw new Error("Name, password, and tenantName are required");
863
+ return await u.signupTenantAdmin({
864
+ email: A,
865
+ phoneNumber: $,
866
+ name: Q,
867
+ password: X,
868
+ tenantName: W,
869
+ appId: ce,
870
+ lastName: ee
871
+ });
872
+ }, G = async (A, $) => {
873
+ const Q = await g.getAuthHeaders();
874
+ await u.changePassword({ currentPassword: A, newPassword: $ }, Q);
875
+ }, Y = async (A, $) => {
876
+ await u.requestPasswordReset({ email: A, tenantId: $ });
877
+ }, H = async (A, $) => {
878
+ await u.confirmPasswordReset({ token: A, newPassword: $ });
879
+ }, C = async (A, $, Q, X, W, ee) => await u.sendMagicLink({
880
+ email: A,
881
+ tenantId: $,
882
+ frontendUrl: Q,
883
+ name: X,
884
+ lastName: W,
885
+ appId: ee
886
+ }), k = async (A, $, Q, X) => {
887
+ const W = await u.verifyMagicLink({
888
+ token: A,
889
+ email: $,
890
+ appId: Q,
891
+ tenantId: X
892
+ });
893
+ if (g.setTokens({
894
+ accessToken: W.accessToken,
895
+ refreshToken: W.refreshToken,
896
+ expiresIn: W.expiresIn
897
+ }), W.user) {
898
+ g.setUser(W.user), m(W.user);
899
+ try {
900
+ await S();
901
+ } catch (ee) {
902
+ console.warn("Failed to load complete user data after magic link login:", ee);
903
+ }
904
+ }
905
+ return W;
906
+ }, T = async () => {
907
+ const A = g.getTokens();
908
+ if (!(A != null && A.refreshToken))
854
909
  throw new Error("No refresh token available");
855
- const $ = await y.refreshToken({
856
- refreshToken: v.refreshToken
910
+ const $ = await u.refreshToken({
911
+ refreshToken: A.refreshToken
857
912
  });
858
- f.setTokens({
913
+ g.setTokens({
859
914
  accessToken: $.accessToken,
860
- refreshToken: $.refreshToken || v.refreshToken,
915
+ refreshToken: $.refreshToken || A.refreshToken,
861
916
  expiresIn: $.expiresIn
862
917
  });
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 () => {
918
+ }, J = () => {
919
+ g.clearSession(), m(null), I(null);
920
+ }, O = (A) => {
921
+ g.setTokens(A);
922
+ }, j = () => g.hasValidSession(), N = () => {
923
+ g.clearSession(), m(null), I(null);
924
+ }, K = async () => {
870
925
  if (t)
871
926
  try {
872
927
  P(!0);
873
- const { roles: v } = await k.getRolesByApp(t);
874
- T(v);
875
- } catch (v) {
876
- console.error("Failed to fetch roles:", v);
928
+ const { roles: A } = await x.getRolesByApp(t);
929
+ E(A);
930
+ } catch (A) {
931
+ console.error("Failed to fetch roles:", A);
877
932
  } finally {
878
933
  P(!1);
879
934
  }
880
- }, j = async () => {
881
- await O();
882
- }, oe = (v) => {
883
- if (!E || E.length === 0)
935
+ }, R = async () => {
936
+ await K();
937
+ }, V = (A) => {
938
+ if (!z || z.length === 0)
884
939
  return !1;
885
- if (typeof v == "string")
886
- return E.includes(v);
887
- const $ = `${v.resource}.${v.action}`;
888
- return E.includes($);
940
+ if (typeof A == "string")
941
+ return z.includes(A);
942
+ const $ = `${A.resource}.${A.action}`;
943
+ return z.includes($);
889
944
  };
890
945
  return {
891
- sessionManager: f,
892
- authenticatedHttpService: L,
893
- login: u,
894
- signup: a,
895
- signupTenantAdmin: l,
896
- 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
946
+ sessionManager: g,
947
+ authenticatedHttpService: U,
948
+ login: h,
949
+ signup: o,
950
+ signupTenantAdmin: d,
951
+ sendMagicLink: C,
952
+ verifyMagicLink: k,
953
+ changePassword: G,
954
+ requestPasswordReset: Y,
955
+ confirmPasswordReset: H,
956
+ refreshToken: T,
957
+ logout: J,
958
+ setTokens: O,
959
+ hasValidSession: j,
960
+ clearSession: N,
961
+ currentUser: f,
962
+ isUserLoading: M,
963
+ userError: v,
964
+ refreshUser: c,
965
+ userRole: B,
966
+ userPermissions: z,
967
+ availableRoles: b,
968
+ rolesLoading: L,
969
+ hasPermission: V,
970
+ hasAnyPermission: (A) => A.some(($) => V($)),
971
+ hasAllPermissions: (A) => A.every(($) => V($)),
972
+ getUserPermissionStrings: () => z || [],
973
+ refreshRoles: R
917
974
  };
918
975
  }, [
919
- f,
920
- L,
921
- y,
922
- S,
923
- k,
924
- t,
925
- m,
926
976
  g,
977
+ U,
978
+ u,
979
+ y,
927
980
  x,
928
- A,
929
- D,
930
- E
981
+ t,
982
+ b,
983
+ f,
984
+ M,
985
+ v,
986
+ B,
987
+ z
931
988
  ]);
932
- return Y(() => {
989
+ return Z(() => {
933
990
  !i.initialRoles && t && (async () => {
934
991
  try {
935
992
  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);
993
+ const c = new te(r), h = new pe(c), { roles: o } = await h.getRolesByApp(t);
994
+ E(o);
995
+ } catch (c) {
996
+ console.error("Failed to fetch roles:", c);
940
997
  } finally {
941
998
  P(!1);
942
999
  }
943
1000
  })();
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 });
1001
+ }, [t, r, i.initialRoles]), Z(() => {
1002
+ const S = g.getUser();
1003
+ S && g.hasValidSession() && m(S);
1004
+ }, [g]), /* @__PURE__ */ n(Se.Provider, { value: q, children: e });
948
1005
  }
949
- function ne() {
950
- const i = re(ye);
1006
+ function ie() {
1007
+ const i = le(Se);
951
1008
  if (!i)
952
1009
  throw new Error("useAuth must be used within an AuthProvider");
953
1010
  return i;
954
1011
  }
955
- class Ee {
1012
+ class He {
956
1013
  constructor(e, t) {
957
1014
  this.httpService = e, this.sessionManager = t;
958
1015
  }
@@ -973,12 +1030,12 @@ class Ee {
973
1030
  throw new Error("SessionManager is required for private endpoints");
974
1031
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
975
1032
  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, {
1033
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
977
1034
  headers: t
978
1035
  });
979
1036
  return {
980
- featureFlags: o.data,
981
- meta: o.meta
1037
+ featureFlags: a.data,
1038
+ meta: a.meta
982
1039
  };
983
1040
  }
984
1041
  async getFeatureFlagById(e) {
@@ -1015,8 +1072,8 @@ class Ee {
1015
1072
  throw new Error("Tenant ID and App ID are required");
1016
1073
  const r = new URLSearchParams();
1017
1074
  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, {
1075
+ const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
1076
+ return (await this.httpService.get(s, {
1020
1077
  headers: { "X-Tenant-ID": e }
1021
1078
  })).data;
1022
1079
  }
@@ -1024,66 +1081,66 @@ class Ee {
1024
1081
  async getTenantFeatureFlag(e, t, r) {
1025
1082
  if (!e || !t || !r)
1026
1083
  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, {
1084
+ const s = new URLSearchParams();
1085
+ s.append("tenantId", t), s.append("appId", r);
1086
+ const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1087
+ return (await this.httpService.get(a, {
1031
1088
  headers: { "X-Tenant-ID": t }
1032
1089
  })).data;
1033
1090
  }
1034
1091
  }
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([]);
1092
+ const xe = ae(null);
1093
+ function bt({ config: i = {}, children: e }) {
1094
+ const { baseUrl: t, appId: r } = ne(), { tenant: s } = re(), [a, b] = p([]), [E, L] = p(!1), [P, f] = p(null), m = _(() => {
1095
+ const v = new te(t);
1096
+ return new He(v);
1097
+ }, [t]), M = async () => {
1098
+ if (!(s != null && s.id)) {
1099
+ b([]);
1043
1100
  return;
1044
1101
  }
1045
- M(!0), g(null);
1102
+ L(!0), f(null);
1046
1103
  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));
1104
+ const v = await m.getTenantFeatureFlags(s.id, r);
1105
+ b(v);
1106
+ } catch (v) {
1107
+ const I = v instanceof Error ? v.message : "Failed to fetch feature flags";
1108
+ f(I), i.onError && i.onError(v instanceof Error ? v : new Error(I));
1052
1109
  } finally {
1053
- M(!1);
1110
+ L(!1);
1054
1111
  }
1055
1112
  };
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,
1113
+ Z(() => {
1114
+ M();
1115
+ const v = i.refreshInterval || 5 * 60 * 1e3, I = setInterval(M, v);
1116
+ return () => clearInterval(I);
1117
+ }, [s == null ? void 0 : s.id, i.refreshInterval]);
1118
+ const w = _(() => ({
1119
+ featureFlags: a,
1120
+ loading: E,
1064
1121
  error: P,
1065
- isEnabled: (y) => {
1066
- const S = o.find((k) => k.key === y);
1067
- return (S == null ? void 0 : S.value) === !0;
1122
+ isEnabled: (u) => {
1123
+ const y = a.find((x) => x.key === u);
1124
+ return (y == null ? void 0 : y.value) === !0;
1068
1125
  },
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";
1126
+ getFlag: (u) => a.find((y) => y.key === u),
1127
+ getFlagState: (u) => {
1128
+ const y = a.find((x) => x.key === u);
1129
+ return y ? y.value ? "enabled" : "disabled" : "not_found";
1073
1130
  },
1074
1131
  refresh: async () => {
1075
- await x();
1132
+ await M();
1076
1133
  }
1077
- }), [o, T, P]);
1078
- return /* @__PURE__ */ s(we.Provider, { value: p, children: e });
1134
+ }), [a, E, P]);
1135
+ return /* @__PURE__ */ n(xe.Provider, { value: w, children: e });
1079
1136
  }
1080
- function Re() {
1081
- const i = re(we);
1137
+ function $e() {
1138
+ const i = le(xe);
1082
1139
  if (!i)
1083
1140
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1084
1141
  return i;
1085
1142
  }
1086
- class Fe {
1143
+ class De {
1087
1144
  constructor(e, t) {
1088
1145
  this.httpService = e, this.sessionManager = t;
1089
1146
  }
@@ -1149,64 +1206,64 @@ class Fe {
1149
1206
  )).data;
1150
1207
  }
1151
1208
  }
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 () => {
1209
+ const ke = ae(void 0);
1210
+ function wt({ config: i = {}, children: e }) {
1211
+ const { baseUrl: t } = ne(), { tenant: r } = re(), [s, a] = p(null), [b, E] = p(!1), [L, P] = p(null), f = _(() => {
1212
+ const w = new te(t);
1213
+ return new De(w);
1214
+ }, [t]), m = async () => {
1158
1215
  if (!(r != null && r.id)) {
1159
- o(null);
1216
+ a(null);
1160
1217
  return;
1161
1218
  }
1162
- T(!0), P(null);
1219
+ E(!0), P(null);
1163
1220
  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));
1221
+ const w = await f.getTenantSubscriptionFeatures(r.id);
1222
+ a(w);
1223
+ } catch (w) {
1224
+ const v = w instanceof Error ? w.message : "Failed to fetch subscription";
1225
+ P(v), i.onError && i.onError(w instanceof Error ? w : new Error(v));
1169
1226
  } finally {
1170
- T(!1);
1227
+ E(!1);
1171
1228
  }
1172
1229
  };
1173
- Y(() => {
1174
- if (h(), !i.refreshInterval) return;
1175
- const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
1176
- return () => clearInterval(A);
1230
+ Z(() => {
1231
+ if (m(), !i.refreshInterval) return;
1232
+ const w = i.refreshInterval || 10 * 60 * 1e3, v = setInterval(m, w);
1233
+ return () => clearInterval(v);
1177
1234
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1178
- const x = z(() => {
1179
- const p = (n == null ? void 0 : n.features) || [];
1235
+ const M = _(() => {
1236
+ const w = (s == null ? void 0 : s.features) || [];
1180
1237
  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;
1238
+ subscription: s,
1239
+ features: w,
1240
+ loading: b,
1241
+ error: L,
1242
+ isFeatureEnabled: (y) => {
1243
+ const x = w.find((F) => F.key === y);
1244
+ return x ? x.type === "BOOLEAN" || x.type === "boolean" ? x.value === !0 : !!x.value : !1;
1188
1245
  },
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;
1246
+ getFeature: (y) => w.find((x) => x.key === y),
1247
+ getFeatureValue: (y, x) => {
1248
+ const F = w.find((B) => B.key === y);
1249
+ return F ? F.value : x;
1193
1250
  },
1194
- hasAllowedPlan: (S) => !n || !n.isActive ? !1 : S.includes(n.planId),
1251
+ hasAllowedPlan: (y) => !s || !s.isActive ? !1 : y.includes(s.planId),
1195
1252
  refresh: async () => {
1196
- await h();
1253
+ await m();
1197
1254
  }
1198
1255
  };
1199
- }, [n, m, M]);
1200
- return /* @__PURE__ */ s(me.Provider, { value: x, children: e });
1256
+ }, [s, b, L]);
1257
+ return /* @__PURE__ */ n(ke.Provider, { value: M, children: e });
1201
1258
  }
1202
- function Ie() {
1203
- const i = re(me);
1259
+ function Be() {
1260
+ const i = le(ke);
1204
1261
  if (i === void 0)
1205
1262
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1206
1263
  return i;
1207
1264
  }
1208
- var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
1209
- const ue = () => /* @__PURE__ */ c(
1265
+ var se = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(se || {});
1266
+ const me = () => /* @__PURE__ */ l(
1210
1267
  "div",
1211
1268
  {
1212
1269
  style: {
@@ -1222,10 +1279,10 @@ const ue = () => /* @__PURE__ */ c(
1222
1279
  margin: "20px 0"
1223
1280
  },
1224
1281
  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(
1282
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1283
+ /* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1284
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1285
+ /* @__PURE__ */ n(
1229
1286
  "button",
1230
1287
  {
1231
1288
  style: {
@@ -1243,11 +1300,11 @@ const ue = () => /* @__PURE__ */ c(
1243
1300
  )
1244
1301
  ]
1245
1302
  }
1246
- ), he = ({
1303
+ ), ye = ({
1247
1304
  userType: i,
1248
1305
  minUserType: e,
1249
1306
  missingPermissions: t
1250
- }) => /* @__PURE__ */ c(
1307
+ }) => /* @__PURE__ */ l(
1251
1308
  "div",
1252
1309
  {
1253
1310
  style: {
@@ -1263,57 +1320,57 @@ const ue = () => /* @__PURE__ */ c(
1263
1320
  margin: "20px 0"
1264
1321
  },
1265
1322
  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: [
1323
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1324
+ /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1325
+ e && i ? /* @__PURE__ */ l(D, { children: [
1326
+ /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1270
1327
  "This content requires ",
1271
- /* @__PURE__ */ s("strong", { children: e }),
1328
+ /* @__PURE__ */ n("strong", { children: e }),
1272
1329
  " access level or higher."
1273
1330
  ] }),
1274
- /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1331
+ /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1275
1332
  "Your current access level: ",
1276
- /* @__PURE__ */ s("strong", { children: i })
1333
+ /* @__PURE__ */ n("strong", { children: i })
1277
1334
  ] })
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: [
1335
+ ] }) : /* @__PURE__ */ l(D, { children: [
1336
+ /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1337
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1281
1338
  "Required permissions: ",
1282
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1339
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1283
1340
  ] })
1284
1341
  ] })
1285
1342
  ]
1286
1343
  }
1287
- ), He = (i, e) => {
1344
+ ), Ne = (i, e) => {
1288
1345
  const t = {
1289
- [X.USER]: 1,
1290
- [X.TENANT_ADMIN]: 2,
1291
- [X.SUPERUSER]: 3
1346
+ [se.USER]: 1,
1347
+ [se.TENANT_ADMIN]: 2,
1348
+ [se.SUPERUSER]: 3
1292
1349
  };
1293
1350
  return t[i] >= t[e];
1294
1351
  };
1295
- function lt({
1352
+ function vt({
1296
1353
  children: i,
1297
1354
  fallback: e,
1298
1355
  minUserType: t,
1299
1356
  requiredPermissions: r,
1300
- requireAllPermissions: n = !1
1357
+ requireAllPermissions: s = !1
1301
1358
  }) {
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 });
1359
+ const { hasValidSession: a, sessionManager: b, hasPermission: E, hasAnyPermission: L, hasAllPermissions: P } = ie();
1360
+ if (!a())
1361
+ return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1362
+ const f = b.getUser();
1363
+ if (!f)
1364
+ return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1365
+ if (t && !Ne(f.userType, t))
1366
+ return /* @__PURE__ */ n(ye, { userType: f.userType, minUserType: t });
1367
+ if (r && r.length > 0 && !(s ? P(r) : L(r))) {
1368
+ const M = r.filter((w) => !E(w)).map((w) => typeof w == "string" ? w : w.name);
1369
+ return /* @__PURE__ */ n(ye, { missingPermissions: M });
1370
+ }
1371
+ return /* @__PURE__ */ n(D, { children: i });
1315
1372
  }
1316
- const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1373
+ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1317
1374
  "div",
1318
1375
  {
1319
1376
  style: {
@@ -1326,7 +1383,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1326
1383
  backgroundColor: "#f9fafb",
1327
1384
  textAlign: "center"
1328
1385
  },
1329
- children: /* @__PURE__ */ c(
1386
+ children: /* @__PURE__ */ l(
1330
1387
  "div",
1331
1388
  {
1332
1389
  style: {
@@ -1337,10 +1394,10 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1337
1394
  maxWidth: "400px"
1338
1395
  },
1339
1396
  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: [
1397
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1398
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1399
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1400
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1344
1401
  "Redirecting to ",
1345
1402
  i,
1346
1403
  "..."
@@ -1349,11 +1406,11 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1349
1406
  }
1350
1407
  )
1351
1408
  }
1352
- ), ge = ({
1409
+ ), be = ({
1353
1410
  userType: i,
1354
1411
  minUserType: e,
1355
1412
  missingPermissions: t
1356
- }) => /* @__PURE__ */ s(
1413
+ }) => /* @__PURE__ */ n(
1357
1414
  "div",
1358
1415
  {
1359
1416
  style: {
@@ -1366,7 +1423,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1366
1423
  backgroundColor: "#f9fafb",
1367
1424
  textAlign: "center"
1368
1425
  },
1369
- children: /* @__PURE__ */ c(
1426
+ children: /* @__PURE__ */ l(
1370
1427
  "div",
1371
1428
  {
1372
1429
  style: {
@@ -1377,63 +1434,63 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
1377
1434
  maxWidth: "400px"
1378
1435
  },
1379
1436
  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: [
1437
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1438
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1439
+ e && i ? /* @__PURE__ */ l(D, { children: [
1440
+ /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1384
1441
  "This page requires ",
1385
- /* @__PURE__ */ s("strong", { children: e }),
1442
+ /* @__PURE__ */ n("strong", { children: e }),
1386
1443
  " access level or higher."
1387
1444
  ] }),
1388
- /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1445
+ /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1389
1446
  "Your current access level: ",
1390
- /* @__PURE__ */ s("strong", { children: i })
1447
+ /* @__PURE__ */ n("strong", { children: i })
1391
1448
  ] })
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: [
1449
+ ] }) : /* @__PURE__ */ l(D, { children: [
1450
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1451
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1395
1452
  "Required permissions: ",
1396
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1453
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1397
1454
  ] })
1398
1455
  ] })
1399
1456
  ]
1400
1457
  }
1401
1458
  )
1402
1459
  }
1403
- ), $e = (i, e) => {
1460
+ ), Ue = (i, e) => {
1404
1461
  const t = {
1405
- [X.USER]: 1,
1406
- [X.TENANT_ADMIN]: 2,
1407
- [X.SUPERUSER]: 3
1462
+ [se.USER]: 1,
1463
+ [se.TENANT_ADMIN]: 2,
1464
+ [se.SUPERUSER]: 3
1408
1465
  };
1409
1466
  return t[i] >= t[e];
1410
1467
  };
1411
- function ct({
1468
+ function St({
1412
1469
  children: i,
1413
1470
  redirectTo: e = "/login",
1414
1471
  minUserType: t,
1415
1472
  requiredPermissions: r,
1416
- requireAllPermissions: n = !1,
1417
- fallback: o
1473
+ requireAllPermissions: s = !1,
1474
+ fallback: a
1418
1475
  }) {
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 })
1476
+ const { hasValidSession: b, sessionManager: E, hasPermission: L, hasAnyPermission: P, hasAllPermissions: f } = ie(), m = he();
1477
+ if (!b())
1478
+ return a ? /* @__PURE__ */ n(D, { children: a }) : /* @__PURE__ */ l(D, { children: [
1479
+ /* @__PURE__ */ n(qe, { redirectPath: e }),
1480
+ /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 })
1424
1481
  ] });
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 });
1482
+ const M = E.getUser();
1483
+ if (!M)
1484
+ return /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 });
1485
+ if (t && !Ue(M.userType, t))
1486
+ return /* @__PURE__ */ n(be, { userType: M.userType, minUserType: t });
1487
+ if (r && r.length > 0 && !(s ? f(r) : P(r))) {
1488
+ const v = r.filter((I) => !L(I)).map((I) => typeof I == "string" ? I : I.name);
1489
+ return /* @__PURE__ */ n(be, { missingPermissions: v });
1490
+ }
1491
+ return /* @__PURE__ */ n(D, { children: i });
1435
1492
  }
1436
- const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1493
+ const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
1437
1494
  "div",
1438
1495
  {
1439
1496
  style: {
@@ -1446,7 +1503,7 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1446
1503
  backgroundColor: "#f9fafb",
1447
1504
  textAlign: "center"
1448
1505
  },
1449
- children: /* @__PURE__ */ c(
1506
+ children: /* @__PURE__ */ l(
1450
1507
  "div",
1451
1508
  {
1452
1509
  style: {
@@ -1457,10 +1514,10 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1457
1514
  maxWidth: "400px"
1458
1515
  },
1459
1516
  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: [
1517
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1518
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1519
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1520
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1464
1521
  "Redirecting to ",
1465
1522
  i,
1466
1523
  "..."
@@ -1470,14 +1527,14 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1470
1527
  )
1471
1528
  }
1472
1529
  );
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 })
1530
+ function xt({ children: i, redirectTo: e = "/", fallback: t }) {
1531
+ const { tenant: r, isLoading: s, error: a } = re(), b = he();
1532
+ return s || a ? null : r ? /* @__PURE__ */ n(D, { children: i }) : t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1533
+ /* @__PURE__ */ n(ze, { redirectPath: e }),
1534
+ /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1478
1535
  ] });
1479
1536
  }
1480
- const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1537
+ const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1481
1538
  "div",
1482
1539
  {
1483
1540
  style: {
@@ -1490,7 +1547,7 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1490
1547
  backgroundColor: "#f9fafb",
1491
1548
  textAlign: "center"
1492
1549
  },
1493
- children: /* @__PURE__ */ c(
1550
+ children: /* @__PURE__ */ l(
1494
1551
  "div",
1495
1552
  {
1496
1553
  style: {
@@ -1501,10 +1558,10 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1501
1558
  maxWidth: "400px"
1502
1559
  },
1503
1560
  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: [
1561
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1562
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1563
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1564
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1508
1565
  "Redirecting to ",
1509
1566
  i,
1510
1567
  "..."
@@ -1514,14 +1571,14 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
1514
1571
  )
1515
1572
  }
1516
1573
  );
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 });
1574
+ function kt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1575
+ const { tenant: r, isLoading: s, error: a } = re(), b = he();
1576
+ return s || a ? null : r ? t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1577
+ /* @__PURE__ */ n(Oe, { redirectPath: e }),
1578
+ /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1579
+ ] }) : /* @__PURE__ */ n(D, { children: i });
1523
1580
  }
1524
- const Be = () => /* @__PURE__ */ c(
1581
+ const je = () => /* @__PURE__ */ l(
1525
1582
  "div",
1526
1583
  {
1527
1584
  style: {
@@ -1533,19 +1590,19 @@ const Be = () => /* @__PURE__ */ c(
1533
1590
  color: "#dc2626"
1534
1591
  },
1535
1592
  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." })
1593
+ /* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1594
+ /* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1538
1595
  ]
1539
1596
  }
1540
1597
  );
1541
- function ht({
1598
+ function At({
1542
1599
  children: i,
1543
- fallback: e = /* @__PURE__ */ s(Be, {}),
1600
+ fallback: e = /* @__PURE__ */ n(je, {}),
1544
1601
  allowedPlans: t,
1545
1602
  requiredFeature: r
1546
1603
  }) {
1547
- const { subscription: n, hasAllowedPlan: o, isFeatureEnabled: m, loading: T } = Ie();
1548
- return T ? /* @__PURE__ */ s(
1604
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: b, loading: E } = Be();
1605
+ return E ? /* @__PURE__ */ n(
1549
1606
  "div",
1550
1607
  {
1551
1608
  style: {
@@ -1555,9 +1612,9 @@ function ht({
1555
1612
  },
1556
1613
  children: "Loading subscription..."
1557
1614
  }
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 });
1615
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(D, { children: e }) : r && !b(r) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: i }) : /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: e });
1559
1616
  }
1560
- const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1617
+ const We = ({ flagName: i }) => /* @__PURE__ */ l(
1561
1618
  "div",
1562
1619
  {
1563
1620
  style: {
@@ -1574,9 +1631,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1574
1631
  color: "#6c757d"
1575
1632
  },
1576
1633
  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: [
1634
+ /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1635
+ /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1636
+ /* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1580
1637
  'Feature flag "',
1581
1638
  i,
1582
1639
  '" is disabled'
@@ -1584,9 +1641,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
1584
1641
  ]
1585
1642
  }
1586
1643
  );
1587
- function gt({ name: i, children: e, fallback: t }) {
1588
- const { isEnabled: r, loading: n } = Re();
1589
- return n ? /* @__PURE__ */ s(
1644
+ function Pt({ name: i, children: e, fallback: t }) {
1645
+ const { isEnabled: r, loading: s } = $e();
1646
+ return s ? /* @__PURE__ */ n(
1590
1647
  "div",
1591
1648
  {
1592
1649
  style: {
@@ -1599,9 +1656,9 @@ function gt({ name: i, children: e, fallback: t }) {
1599
1656
  },
1600
1657
  children: "Loading feature flags..."
1601
1658
  }
1602
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: t || /* @__PURE__ */ s(qe, { flagName: i }) }));
1659
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: t || /* @__PURE__ */ n(We, { flagName: i }) }));
1603
1660
  }
1604
- const Ue = () => /* @__PURE__ */ c(
1661
+ const Ve = () => /* @__PURE__ */ l(
1605
1662
  "svg",
1606
1663
  {
1607
1664
  width: "16",
@@ -1614,11 +1671,11 @@ const Ue = () => /* @__PURE__ */ c(
1614
1671
  strokeLinejoin: "round",
1615
1672
  style: { flexShrink: 0 },
1616
1673
  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" })
1674
+ /* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1675
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1619
1676
  ]
1620
1677
  }
1621
- ), Ne = () => /* @__PURE__ */ c(
1678
+ ), Ge = () => /* @__PURE__ */ l(
1622
1679
  "svg",
1623
1680
  {
1624
1681
  width: "16",
@@ -1631,26 +1688,28 @@ const Ue = () => /* @__PURE__ */ c(
1631
1688
  strokeLinejoin: "round",
1632
1689
  style: { flexShrink: 0 },
1633
1690
  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" })
1691
+ /* @__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" }),
1692
+ /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1636
1693
  ]
1637
1694
  }
1638
- ), ze = {
1639
- showPassword: /* @__PURE__ */ s(Ue, {}),
1640
- hidePassword: /* @__PURE__ */ s(Ne, {})
1641
- }, Oe = {
1695
+ ), Ye = {
1696
+ showPassword: /* @__PURE__ */ n(Ve, {}),
1697
+ hidePassword: /* @__PURE__ */ n(Ge, {})
1698
+ }, _e = {
1642
1699
  title: "Sign In",
1643
- emailLabel: "Email",
1644
- emailPlaceholder: "Enter your email",
1700
+ usernameLabel: "Email or Phone",
1701
+ usernamePlaceholder: "Enter your email or phone number",
1645
1702
  passwordLabel: "Password",
1646
1703
  passwordPlaceholder: "Enter your password",
1647
1704
  submitButton: "Sign In",
1648
1705
  forgotPasswordLink: "Forgot your password?",
1649
1706
  signupLink: "Sign up here",
1650
1707
  signupText: "Don't have an account?",
1651
- errorMessage: "Invalid email or password",
1708
+ magicLinkText: "Prefer passwordless?",
1709
+ magicLinkLink: "Use Magic Link",
1710
+ errorMessage: "Invalid credentials",
1652
1711
  loadingText: "Signing in..."
1653
- }, je = {
1712
+ }, Ke = {
1654
1713
  container: {
1655
1714
  maxWidth: "400px",
1656
1715
  width: "100%",
@@ -1757,124 +1816,138 @@ const Ue = () => /* @__PURE__ */ c(
1757
1816
  fontSize: "0.875rem"
1758
1817
  }
1759
1818
  };
1760
- function pt({
1819
+ function Tt({
1761
1820
  copy: i = {},
1762
1821
  styles: e = {},
1763
1822
  icons: t = {},
1764
1823
  onSuccess: r,
1765
- onError: n,
1766
- onForgotPassword: o,
1767
- onSignupClick: m,
1768
- showForgotPassword: T = !0,
1769
- showSignupLink: M = !0,
1770
- className: P
1824
+ onError: s,
1825
+ onForgotPassword: a,
1826
+ onSignupClick: b,
1827
+ onMagicLinkClick: E,
1828
+ showForgotPassword: L = !0,
1829
+ showSignupLink: P = !0,
1830
+ showMagicLinkOption: f = !0,
1831
+ className: m
1771
1832
  }) {
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");
1833
+ const [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p({}), { login: q } = ie(), { tenant: S } = re(), { appId: c } = ne(), h = { ..._e, ...i }, o = { ...Ke, ...e }, d = { ...Ye, ...t }, G = () => {
1834
+ const k = {};
1835
+ return M.trim() || (k.username = !0), v.trim() || (k.password = !0), z(k), Object.keys(k).length === 0;
1836
+ }, Y = async (k) => {
1837
+ if (k.preventDefault(), !!G()) {
1838
+ if (!(S != null && S.id)) {
1839
+ F("Tenant not found");
1779
1840
  return;
1780
1841
  }
1781
- L(!0), S("");
1842
+ y(!0), F("");
1782
1843
  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(_);
1844
+ const T = await q(M, v, c, S.id);
1845
+ r == null || r(T);
1846
+ } catch (T) {
1847
+ const J = T.message || h.errorMessage;
1848
+ F(J), s == null || s(J);
1788
1849
  } finally {
1789
- L(!1);
1850
+ y(!1);
1790
1851
  }
1791
1852
  }
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 : {}
1853
+ }, H = (k) => ({
1854
+ ...o.input,
1855
+ ...B[k] ? o.inputError : {}
1856
+ }), C = () => ({
1857
+ ...o.button,
1858
+ ...u ? o.buttonLoading : {},
1859
+ ...!M || !v || u ? o.buttonDisabled : {}
1799
1860
  });
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(
1861
+ return /* @__PURE__ */ l("div", { className: m, style: o.container, children: [
1862
+ /* @__PURE__ */ n("h2", { style: o.title, children: h.title }),
1863
+ /* @__PURE__ */ l("form", { onSubmit: Y, style: o.form, children: [
1864
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1865
+ /* @__PURE__ */ n("label", { style: o.label, children: h.usernameLabel }),
1866
+ /* @__PURE__ */ n(
1806
1867
  "input",
1807
1868
  {
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 }));
1869
+ id: "username",
1870
+ name: "username",
1871
+ type: "text",
1872
+ value: M,
1873
+ onChange: (k) => {
1874
+ w(k.target.value), B.username && z((T) => ({ ...T, username: !1 }));
1814
1875
  },
1815
- placeholder: B.emailPlaceholder,
1816
- style: l("email"),
1817
- disabled: f
1876
+ placeholder: h.usernamePlaceholder,
1877
+ style: H("username"),
1878
+ disabled: u
1818
1879
  }
1819
1880
  )
1820
1881
  ] }),
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(
1882
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1883
+ /* @__PURE__ */ n("label", { style: o.label, children: h.passwordLabel }),
1884
+ /* @__PURE__ */ l("div", { style: o.inputContainer, children: [
1885
+ /* @__PURE__ */ n(
1825
1886
  "input",
1826
1887
  {
1827
1888
  id: "password",
1828
1889
  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 }));
1890
+ type: g ? "text" : "password",
1891
+ value: v,
1892
+ onChange: (k) => {
1893
+ I(k.target.value), B.password && z((T) => ({ ...T, password: !1 }));
1833
1894
  },
1834
- placeholder: B.passwordPlaceholder,
1895
+ placeholder: h.passwordPlaceholder,
1835
1896
  style: {
1836
- ...l("password"),
1897
+ ...H("password"),
1837
1898
  paddingRight: "2.5rem"
1838
1899
  // Make room for the icon
1839
1900
  },
1840
- disabled: f
1901
+ disabled: u
1841
1902
  }
1842
1903
  ),
1843
- /* @__PURE__ */ s(
1904
+ /* @__PURE__ */ n(
1844
1905
  "button",
1845
1906
  {
1846
1907
  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
1908
+ onClick: () => U(!g),
1909
+ style: o.passwordToggle,
1910
+ disabled: u,
1911
+ "aria-label": g ? "Hide password" : "Show password",
1912
+ children: g ? d.hidePassword : d.showPassword
1852
1913
  }
1853
1914
  )
1854
1915
  ] })
1855
1916
  ] }),
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 })
1917
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !M || !v || u, style: C(), children: u ? h.loadingText : h.submitButton }),
1918
+ x && /* @__PURE__ */ n("div", { style: o.errorText, children: x })
1858
1919
  ] }),
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,
1920
+ (L || P || f) && /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
1921
+ f && /* @__PURE__ */ l("div", { children: [
1922
+ /* @__PURE__ */ l("span", { style: o.divider, children: [
1923
+ h.magicLinkText,
1924
+ " "
1925
+ ] }),
1926
+ /* @__PURE__ */ n("a", { onClick: E, style: o.link, children: h.magicLinkLink })
1927
+ ] }),
1928
+ f && (L || P) && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1929
+ L && /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: h.forgotPasswordLink }),
1930
+ L && P && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1931
+ P && /* @__PURE__ */ l("div", { children: [
1932
+ /* @__PURE__ */ l("span", { style: o.divider, children: [
1933
+ h.signupText,
1865
1934
  " "
1866
1935
  ] }),
1867
- /* @__PURE__ */ s("a", { onClick: m, style: d.link, children: B.signupLink })
1936
+ /* @__PURE__ */ n("a", { onClick: b, style: o.link, children: h.signupLink })
1868
1937
  ] })
1869
1938
  ] })
1870
1939
  ] });
1871
1940
  }
1872
- const Ve = {
1941
+ const Qe = {
1873
1942
  title: "Create Account",
1874
- nameLabel: "Full Name",
1875
- namePlaceholder: "Enter your full name",
1943
+ nameLabel: "First Name",
1944
+ namePlaceholder: "Enter your first name",
1945
+ lastNameLabel: "Last Name",
1946
+ lastNamePlaceholder: "Enter your last name",
1876
1947
  emailLabel: "Email",
1877
1948
  emailPlaceholder: "Enter your email",
1949
+ phoneNumberLabel: "Phone Number",
1950
+ phoneNumberPlaceholder: "Enter your phone number",
1878
1951
  passwordLabel: "Password",
1879
1952
  passwordPlaceholder: "Enter your password",
1880
1953
  confirmPasswordLabel: "Confirm Password",
@@ -1884,12 +1957,14 @@ const Ve = {
1884
1957
  submitButton: "Create Account",
1885
1958
  loginLink: "Sign in here",
1886
1959
  loginText: "Already have an account?",
1960
+ magicLinkText: "Prefer passwordless?",
1961
+ magicLinkLink: "Use Magic Link",
1887
1962
  errorMessage: "Failed to create account",
1888
1963
  loadingText: "Creating account...",
1889
1964
  passwordMismatchError: "Passwords do not match",
1890
1965
  isAdminLabel: "Create new organization",
1891
1966
  isAdminDescription: "Check this if you want to create a new organization"
1892
- }, We = {
1967
+ }, Je = {
1893
1968
  container: {
1894
1969
  maxWidth: "400px",
1895
1970
  width: "100%",
@@ -1988,154 +2063,784 @@ const Ve = {
1988
2063
  fontSize: "0.875rem"
1989
2064
  }
1990
2065
  };
1991
- function ft({
2066
+ function Mt({
1992
2067
  copy: i = {},
1993
2068
  styles: e = {},
1994
2069
  signupType: t = "user",
1995
2070
  onSuccess: r,
1996
- onError: n,
1997
- onLoginClick: o,
1998
- showLoginLink: m = !0,
1999
- className: T
2071
+ onError: s,
2072
+ onLoginClick: a,
2073
+ onMagicLinkClick: b,
2074
+ showLoginLink: E = !0,
2075
+ showMagicLinkOption: L = !0,
2076
+ className: P
2000
2077
  }) {
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 });
2078
+ const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(""), [u, y] = p(""), [x, F] = p(""), [B, z] = p(""), [q, S] = p(!1), [c, h] = p(""), [o, d] = p({}), { signup: G, signupTenantAdmin: Y } = ie(), { tenant: H } = re(), { appId: C } = ne(), k = { ...Qe, ...i }, T = { ...Je, ...e }, J = () => {
2079
+ const R = {};
2080
+ return f.trim() || (R.name = !0), !v.trim() && !g.trim() && (R.email = !0, R.phoneNumber = !0), u.trim() || (R.password = !0), x.trim() || (R.confirmPassword = !0), t === "tenant" && !B.trim() && (R.tenantName = !0), d(R), Object.keys(R).length === 0;
2081
+ }, O = async (R) => {
2082
+ if (R.preventDefault(), !!J()) {
2083
+ if (u !== x) {
2084
+ h(k.passwordMismatchError), d({ confirmPassword: !0 });
2008
2085
  return;
2009
2086
  }
2010
- if (t === "user" && !(w != null && w.id)) {
2011
- R("Tenant not found");
2087
+ if (t === "user" && !(H != null && H.id)) {
2088
+ h("Tenant not found");
2012
2089
  return;
2013
2090
  }
2014
- S(!0), R("");
2091
+ S(!0), h("");
2015
2092
  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);
2093
+ let V;
2094
+ t === "tenant" ? V = await Y(
2095
+ v || void 0,
2096
+ g || void 0,
2097
+ f,
2098
+ u,
2099
+ B,
2100
+ M || void 0,
2101
+ C
2102
+ ) : V = await G(
2103
+ v || void 0,
2104
+ g || void 0,
2105
+ f,
2106
+ u,
2107
+ H.id,
2108
+ M || void 0,
2109
+ C
2110
+ ), r == null || r(V);
2111
+ } catch (V) {
2112
+ const ue = V.message || k.errorMessage;
2113
+ h(ue), s == null || s(ue);
2021
2114
  } finally {
2022
2115
  S(!1);
2023
2116
  }
2024
2117
  }
2025
- }, I = (C) => ({
2026
- ...a.input,
2027
- ...D[C] ? a.inputError : {}
2118
+ }, j = (R) => ({
2119
+ ...T.input,
2120
+ ...o[R] ? T.inputError : {}
2028
2121
  }), 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(
2122
+ ...T.button,
2123
+ ...q ? T.buttonLoading : {},
2124
+ ...!f || !v && !g || !u || !x || q || t === "tenant" && !B ? T.buttonDisabled : {}
2125
+ }), K = f && (v || g) && u && x && (t === "user" || B);
2126
+ return /* @__PURE__ */ l("div", { className: P, style: T.container, children: [
2127
+ /* @__PURE__ */ n("h2", { style: T.title, children: k.title }),
2128
+ /* @__PURE__ */ l("form", { onSubmit: O, style: T.form, children: [
2129
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2130
+ /* @__PURE__ */ n("label", { style: T.label, children: k.nameLabel }),
2131
+ /* @__PURE__ */ n(
2039
2132
  "input",
2040
2133
  {
2041
2134
  id: "name",
2042
2135
  name: "name",
2043
2136
  type: "text",
2044
- value: M,
2045
- onChange: (C) => {
2046
- P(C.target.value), D.name && E((U) => ({ ...U, name: !1 }));
2137
+ value: f,
2138
+ onChange: (R) => {
2139
+ m(R.target.value), o.name && d((V) => ({ ...V, name: !1 }));
2047
2140
  },
2048
- placeholder: u.namePlaceholder,
2049
- style: I("name"),
2050
- disabled: y
2141
+ placeholder: k.namePlaceholder,
2142
+ style: j("name"),
2143
+ disabled: q
2051
2144
  }
2052
2145
  )
2053
2146
  ] }),
2054
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2055
- /* @__PURE__ */ s("label", { style: a.label, children: u.emailLabel }),
2056
- /* @__PURE__ */ s(
2147
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2148
+ /* @__PURE__ */ n("label", { style: T.label, children: k.lastNameLabel }),
2149
+ /* @__PURE__ */ n(
2150
+ "input",
2151
+ {
2152
+ id: "lastName",
2153
+ name: "lastName",
2154
+ type: "text",
2155
+ value: M,
2156
+ onChange: (R) => w(R.target.value),
2157
+ placeholder: k.lastNamePlaceholder,
2158
+ style: T.input,
2159
+ disabled: q
2160
+ }
2161
+ )
2162
+ ] }),
2163
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2164
+ /* @__PURE__ */ n("label", { style: T.label, children: k.emailLabel }),
2165
+ /* @__PURE__ */ n(
2057
2166
  "input",
2058
2167
  {
2059
2168
  id: "email",
2060
2169
  name: "email",
2061
2170
  type: "email",
2171
+ value: v,
2172
+ onChange: (R) => {
2173
+ I(R.target.value), o.email && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2174
+ },
2175
+ placeholder: k.emailPlaceholder,
2176
+ style: j("email"),
2177
+ disabled: q
2178
+ }
2179
+ )
2180
+ ] }),
2181
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2182
+ /* @__PURE__ */ n("label", { style: T.label, children: k.phoneNumberLabel }),
2183
+ /* @__PURE__ */ n(
2184
+ "input",
2185
+ {
2186
+ id: "phoneNumber",
2187
+ name: "phoneNumber",
2188
+ type: "tel",
2062
2189
  value: g,
2063
- onChange: (C) => {
2064
- h(C.target.value), D.email && E((U) => ({ ...U, email: !1 }));
2190
+ onChange: (R) => {
2191
+ U(R.target.value), o.phoneNumber && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2065
2192
  },
2066
- placeholder: u.emailPlaceholder,
2067
- style: I("email"),
2068
- disabled: y
2193
+ placeholder: k.phoneNumberPlaceholder,
2194
+ style: j("phoneNumber"),
2195
+ disabled: q
2069
2196
  }
2070
2197
  )
2071
2198
  ] }),
2072
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2073
- /* @__PURE__ */ s("label", { style: a.label, children: u.passwordLabel }),
2074
- /* @__PURE__ */ s(
2199
+ /* @__PURE__ */ n(
2200
+ "div",
2201
+ {
2202
+ style: {
2203
+ fontSize: "0.875rem",
2204
+ color: "#6b7280",
2205
+ textAlign: "center",
2206
+ margin: "0.5rem 0"
2207
+ },
2208
+ children: "At least one contact method (email or phone) is required"
2209
+ }
2210
+ ),
2211
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2212
+ /* @__PURE__ */ n("label", { style: T.label, children: k.passwordLabel }),
2213
+ /* @__PURE__ */ n(
2075
2214
  "input",
2076
2215
  {
2077
2216
  id: "password",
2078
2217
  name: "password",
2079
2218
  type: "password",
2080
- value: x,
2081
- onChange: (C) => {
2082
- p(C.target.value), D.password && E((U) => ({ ...U, password: !1 }));
2219
+ value: u,
2220
+ onChange: (R) => {
2221
+ y(R.target.value), o.password && d((V) => ({ ...V, password: !1 }));
2083
2222
  },
2084
- placeholder: u.passwordPlaceholder,
2085
- style: I("password"),
2086
- disabled: y
2223
+ placeholder: k.passwordPlaceholder,
2224
+ style: j("password"),
2225
+ disabled: q
2087
2226
  }
2088
2227
  )
2089
2228
  ] }),
2090
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2091
- /* @__PURE__ */ s("label", { style: a.label, children: u.confirmPasswordLabel }),
2092
- /* @__PURE__ */ s(
2229
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2230
+ /* @__PURE__ */ n("label", { style: T.label, children: k.confirmPasswordLabel }),
2231
+ /* @__PURE__ */ n(
2093
2232
  "input",
2094
2233
  {
2095
2234
  id: "confirmPassword",
2096
2235
  name: "confirmPassword",
2097
2236
  type: "password",
2098
- value: A,
2099
- onChange: (C) => {
2100
- F(C.target.value), D.confirmPassword && E((U) => ({ ...U, confirmPassword: !1 })), k === u.passwordMismatchError && R("");
2237
+ value: x,
2238
+ onChange: (R) => {
2239
+ F(R.target.value), o.confirmPassword && d((V) => ({ ...V, confirmPassword: !1 })), c === k.passwordMismatchError && h("");
2101
2240
  },
2102
- placeholder: u.confirmPasswordPlaceholder,
2103
- style: I("confirmPassword"),
2104
- disabled: y
2241
+ placeholder: k.confirmPasswordPlaceholder,
2242
+ style: j("confirmPassword"),
2243
+ disabled: q
2105
2244
  }
2106
2245
  )
2107
2246
  ] }),
2108
- t === "tenant" && /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2109
- /* @__PURE__ */ s("label", { style: a.label, children: u.tenantNameLabel }),
2110
- /* @__PURE__ */ s(
2247
+ t === "tenant" && /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2248
+ /* @__PURE__ */ n("label", { style: T.label, children: k.tenantNameLabel }),
2249
+ /* @__PURE__ */ n(
2111
2250
  "input",
2112
2251
  {
2113
2252
  id: "tenantName",
2114
2253
  name: "tenantName",
2115
2254
  type: "text",
2255
+ value: B,
2256
+ onChange: (R) => {
2257
+ z(R.target.value), o.tenantName && d((V) => ({ ...V, tenantName: !1 }));
2258
+ },
2259
+ placeholder: k.tenantNamePlaceholder,
2260
+ style: j("tenantName"),
2261
+ disabled: q
2262
+ }
2263
+ )
2264
+ ] }),
2265
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !K || q, style: N(), children: q ? k.loadingText : k.submitButton }),
2266
+ c && /* @__PURE__ */ n("div", { style: T.errorText, children: c })
2267
+ ] }),
2268
+ (E || L) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
2269
+ L && /* @__PURE__ */ l("div", { children: [
2270
+ /* @__PURE__ */ l("span", { style: T.divider, children: [
2271
+ k.magicLinkText,
2272
+ " "
2273
+ ] }),
2274
+ /* @__PURE__ */ n("a", { onClick: b, style: T.link, children: k.magicLinkLink })
2275
+ ] }),
2276
+ L && E && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
2277
+ E && /* @__PURE__ */ l("div", { children: [
2278
+ /* @__PURE__ */ l("span", { style: T.divider, children: [
2279
+ k.loginText,
2280
+ " "
2281
+ ] }),
2282
+ /* @__PURE__ */ n("a", { onClick: a, style: T.link, children: k.loginLink })
2283
+ ] })
2284
+ ] })
2285
+ ] });
2286
+ }
2287
+ const Xe = {
2288
+ title: "Sign In with Magic Link",
2289
+ emailLabel: "Email",
2290
+ emailPlaceholder: "Enter your email",
2291
+ nameLabel: "Name",
2292
+ namePlaceholder: "Enter your name",
2293
+ lastNameLabel: "Last Name",
2294
+ lastNamePlaceholder: "Enter your last name",
2295
+ submitButton: "Send Magic Link",
2296
+ loginLink: "Sign in with password",
2297
+ signupLink: "Sign up with password",
2298
+ loginText: "Already have an account?",
2299
+ signupText: "Prefer traditional signup?",
2300
+ successMessage: "Magic link sent! Check your email and click the link to sign in.",
2301
+ errorMessage: "Failed to send magic link. Please try again.",
2302
+ loadingText: "Sending magic link...",
2303
+ verifyingText: "Verifying magic link...",
2304
+ description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2305
+ }, Ze = {
2306
+ container: {
2307
+ maxWidth: "400px",
2308
+ width: "100%",
2309
+ margin: "0 auto",
2310
+ padding: "2rem",
2311
+ backgroundColor: "#ffffff",
2312
+ borderRadius: "8px",
2313
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2314
+ },
2315
+ title: {
2316
+ fontSize: "1.5rem",
2317
+ fontWeight: "bold",
2318
+ textAlign: "center",
2319
+ marginBottom: "1rem",
2320
+ color: "#333333"
2321
+ },
2322
+ description: {
2323
+ fontSize: "0.875rem",
2324
+ color: "#6b7280",
2325
+ textAlign: "center",
2326
+ marginBottom: "1.5rem",
2327
+ lineHeight: "1.5"
2328
+ },
2329
+ form: {
2330
+ display: "flex",
2331
+ flexDirection: "column",
2332
+ gap: "1rem"
2333
+ },
2334
+ fieldGroup: {
2335
+ display: "flex",
2336
+ flexDirection: "column",
2337
+ gap: "0.5rem"
2338
+ },
2339
+ label: {
2340
+ fontSize: "0.875rem",
2341
+ fontWeight: "500",
2342
+ color: "#374151"
2343
+ },
2344
+ input: {
2345
+ padding: "0.75rem",
2346
+ border: "1px solid #d1d5db",
2347
+ borderRadius: "6px",
2348
+ fontSize: "1rem",
2349
+ transition: "border-color 0.15s ease-in-out",
2350
+ outline: "none",
2351
+ width: "100%"
2352
+ },
2353
+ inputError: {
2354
+ borderColor: "#ef4444",
2355
+ boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
2356
+ },
2357
+ button: {
2358
+ padding: "0.75rem 1rem",
2359
+ backgroundColor: "#3b82f6",
2360
+ color: "white",
2361
+ border: "none",
2362
+ borderRadius: "6px",
2363
+ fontSize: "1rem",
2364
+ fontWeight: "500",
2365
+ cursor: "pointer",
2366
+ transition: "background-color 0.15s ease-in-out",
2367
+ marginTop: "0.5rem"
2368
+ },
2369
+ buttonDisabled: {
2370
+ backgroundColor: "#9ca3af",
2371
+ cursor: "not-allowed"
2372
+ },
2373
+ buttonLoading: {
2374
+ backgroundColor: "#6b7280"
2375
+ },
2376
+ errorText: {
2377
+ color: "#ef4444",
2378
+ fontSize: "0.875rem",
2379
+ textAlign: "center",
2380
+ marginTop: "0.5rem"
2381
+ },
2382
+ successText: {
2383
+ color: "#10b981",
2384
+ fontSize: "0.875rem",
2385
+ textAlign: "center",
2386
+ marginTop: "0.5rem",
2387
+ padding: "0.75rem",
2388
+ backgroundColor: "#f0fdf4",
2389
+ borderRadius: "6px",
2390
+ border: "1px solid #bbf7d0"
2391
+ },
2392
+ linkContainer: {
2393
+ textAlign: "center",
2394
+ marginTop: "1rem"
2395
+ },
2396
+ link: {
2397
+ color: "#3b82f6",
2398
+ textDecoration: "none",
2399
+ fontSize: "0.875rem",
2400
+ cursor: "pointer"
2401
+ },
2402
+ divider: {
2403
+ margin: "0.5rem 0",
2404
+ color: "#6b7280",
2405
+ fontSize: "0.875rem"
2406
+ }
2407
+ };
2408
+ function Et({
2409
+ copy: i = {},
2410
+ styles: e = {},
2411
+ onSuccess: t,
2412
+ onError: r,
2413
+ onLoginClick: s,
2414
+ onSignupClick: a,
2415
+ showTraditionalLinks: b = !0,
2416
+ className: E,
2417
+ verifyToken: L,
2418
+ frontendUrl: P
2419
+ }) {
2420
+ const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p(""), [q, S] = p({}), [c, h] = p(!1), { sendMagicLink: o, verifyMagicLink: d } = ie(), { tenant: G } = re(), { appId: Y } = ne(), H = { ...Xe, ...i }, C = { ...Ze, ...e };
2421
+ Z(() => {
2422
+ L && k(L);
2423
+ }, [L]);
2424
+ const k = async (N) => {
2425
+ y(!0), F("");
2426
+ try {
2427
+ if (!f || !Y)
2428
+ throw new Error("Email and App ID are required for magic link verification");
2429
+ const K = await d(N, f, Y, G == null ? void 0 : G.id);
2430
+ t == null || t(K);
2431
+ } catch (K) {
2432
+ const R = K.message || "Failed to verify magic link";
2433
+ F(R), r == null || r(R);
2434
+ } finally {
2435
+ y(!1);
2436
+ }
2437
+ }, T = () => {
2438
+ const N = {};
2439
+ return f.trim() || (N.email = !0), c && !M.trim() && (N.name = !0), S(N), Object.keys(N).length === 0;
2440
+ }, J = async (N) => {
2441
+ if (N.preventDefault(), !!T()) {
2442
+ if (!(G != null && G.id)) {
2443
+ F("Tenant not found");
2444
+ return;
2445
+ }
2446
+ U(!0), F(""), z("");
2447
+ try {
2448
+ const K = P || (typeof window < "u" ? window.location.origin : ""), R = await o(
2449
+ f,
2450
+ G.id,
2451
+ K,
2452
+ c ? M : void 0,
2453
+ c ? v : void 0,
2454
+ Y
2455
+ );
2456
+ z(H.successMessage), t == null || t(R);
2457
+ } catch (K) {
2458
+ const R = K.message || H.errorMessage;
2459
+ F(R), r == null || r(R);
2460
+ } finally {
2461
+ U(!1);
2462
+ }
2463
+ }
2464
+ }, O = (N) => ({
2465
+ ...C.input,
2466
+ ...q[N] ? C.inputError : {}
2467
+ }), j = () => ({
2468
+ ...C.button,
2469
+ ...g || u ? C.buttonLoading : {},
2470
+ ...!f || g || u ? C.buttonDisabled : {}
2471
+ });
2472
+ return u ? /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2473
+ /* @__PURE__ */ n("h2", { style: C.title, children: H.verifyingText }),
2474
+ /* @__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..." }) })
2475
+ ] }) : /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2476
+ /* @__PURE__ */ n("h2", { style: C.title, children: H.title }),
2477
+ /* @__PURE__ */ n("p", { style: C.description, children: H.description }),
2478
+ /* @__PURE__ */ l("form", { onSubmit: J, style: C.form, children: [
2479
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2480
+ /* @__PURE__ */ n("label", { style: C.label, children: H.emailLabel }),
2481
+ /* @__PURE__ */ n(
2482
+ "input",
2483
+ {
2484
+ id: "email",
2485
+ name: "email",
2486
+ type: "email",
2116
2487
  value: f,
2117
- onChange: (C) => {
2118
- L(C.target.value), D.tenantName && E((U) => ({ ...U, tenantName: !1 }));
2488
+ onChange: (N) => {
2489
+ m(N.target.value), q.email && S((K) => ({ ...K, email: !1 }));
2119
2490
  },
2120
- placeholder: u.tenantNamePlaceholder,
2121
- style: I("tenantName"),
2122
- disabled: y
2491
+ placeholder: H.emailPlaceholder,
2492
+ style: O("email"),
2493
+ disabled: g || u
2123
2494
  }
2124
2495
  )
2125
2496
  ] }),
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 })
2497
+ !c && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2498
+ "button",
2499
+ {
2500
+ type: "button",
2501
+ onClick: () => h(!0),
2502
+ style: {
2503
+ background: "none",
2504
+ border: "none",
2505
+ color: "#3b82f6",
2506
+ fontSize: "0.875rem",
2507
+ cursor: "pointer",
2508
+ textDecoration: "underline"
2509
+ },
2510
+ children: "New user? Add your name"
2511
+ }
2512
+ ) }),
2513
+ c && /* @__PURE__ */ l(D, { children: [
2514
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2515
+ /* @__PURE__ */ n("label", { style: C.label, children: H.nameLabel }),
2516
+ /* @__PURE__ */ n(
2517
+ "input",
2518
+ {
2519
+ id: "name",
2520
+ name: "name",
2521
+ type: "text",
2522
+ value: M,
2523
+ onChange: (N) => {
2524
+ w(N.target.value), q.name && S((K) => ({ ...K, name: !1 }));
2525
+ },
2526
+ placeholder: H.namePlaceholder,
2527
+ style: O("name"),
2528
+ disabled: g || u
2529
+ }
2530
+ )
2531
+ ] }),
2532
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2533
+ /* @__PURE__ */ n("label", { style: C.label, children: H.lastNameLabel }),
2534
+ /* @__PURE__ */ n(
2535
+ "input",
2536
+ {
2537
+ id: "lastName",
2538
+ name: "lastName",
2539
+ type: "text",
2540
+ value: v,
2541
+ onChange: (N) => I(N.target.value),
2542
+ placeholder: H.lastNamePlaceholder,
2543
+ style: C.input,
2544
+ disabled: g || u
2545
+ }
2546
+ )
2547
+ ] }),
2548
+ /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2549
+ "button",
2550
+ {
2551
+ type: "button",
2552
+ onClick: () => {
2553
+ h(!1), w(""), I("");
2554
+ },
2555
+ style: {
2556
+ background: "none",
2557
+ border: "none",
2558
+ color: "#6b7280",
2559
+ fontSize: "0.875rem",
2560
+ cursor: "pointer",
2561
+ textDecoration: "underline"
2562
+ },
2563
+ children: "Existing user? Hide name fields"
2564
+ }
2565
+ ) })
2566
+ ] }),
2567
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || g || u, style: j(), children: g ? H.loadingText : H.submitButton }),
2568
+ x && /* @__PURE__ */ n("div", { style: C.errorText, children: x }),
2569
+ B && /* @__PURE__ */ n("div", { style: C.successText, children: B })
2128
2570
  ] }),
2129
- m && /* @__PURE__ */ c("div", { style: a.linkContainer, children: [
2130
- /* @__PURE__ */ c("span", { style: a.divider, children: [
2131
- u.loginText,
2132
- " "
2571
+ b && /* @__PURE__ */ l("div", { style: C.linkContainer, children: [
2572
+ /* @__PURE__ */ l("div", { children: [
2573
+ /* @__PURE__ */ l("span", { style: C.divider, children: [
2574
+ H.loginText,
2575
+ " "
2576
+ ] }),
2577
+ /* @__PURE__ */ n("a", { onClick: s, style: C.link, children: H.loginLink })
2133
2578
  ] }),
2134
- /* @__PURE__ */ s("a", { onClick: o, style: a.link, children: u.loginLink })
2579
+ /* @__PURE__ */ n("div", { style: C.divider, children: "•" }),
2580
+ /* @__PURE__ */ l("div", { children: [
2581
+ /* @__PURE__ */ l("span", { style: C.divider, children: [
2582
+ H.signupText,
2583
+ " "
2584
+ ] }),
2585
+ /* @__PURE__ */ n("a", { onClick: a, style: C.link, children: H.signupLink })
2586
+ ] })
2135
2587
  ] })
2136
2588
  ] });
2137
2589
  }
2138
- const Ge = {
2590
+ const et = {
2591
+ title: "Verifying Magic Link",
2592
+ verifyingMessage: "Please wait while we verify your magic link...",
2593
+ successMessage: "Magic link verified successfully! You are now logged in.",
2594
+ errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
2595
+ redirectingMessage: "Redirecting you to the dashboard...",
2596
+ retryButton: "Try Again",
2597
+ backToLoginButton: "Back to Login"
2598
+ }, Ae = {
2599
+ container: {
2600
+ maxWidth: "400px",
2601
+ width: "100%",
2602
+ margin: "0 auto",
2603
+ padding: "2rem",
2604
+ backgroundColor: "#ffffff",
2605
+ borderRadius: "8px",
2606
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2607
+ },
2608
+ card: {
2609
+ // Not used in new design, keeping for compatibility
2610
+ backgroundColor: "transparent",
2611
+ padding: "0",
2612
+ borderRadius: "0",
2613
+ boxShadow: "none",
2614
+ maxWidth: "100%",
2615
+ width: "100%",
2616
+ textAlign: "center"
2617
+ },
2618
+ title: {
2619
+ fontSize: "1.5rem",
2620
+ fontWeight: "bold",
2621
+ textAlign: "center",
2622
+ marginBottom: "1.5rem",
2623
+ color: "#333333"
2624
+ },
2625
+ message: {
2626
+ fontSize: "1rem",
2627
+ color: "#6b7280",
2628
+ marginBottom: "1.5rem",
2629
+ lineHeight: "1.5",
2630
+ textAlign: "center"
2631
+ },
2632
+ successMessage: {
2633
+ fontSize: "1rem",
2634
+ color: "#059669",
2635
+ marginBottom: "1.5rem",
2636
+ lineHeight: "1.5",
2637
+ textAlign: "center"
2638
+ },
2639
+ errorMessage: {
2640
+ fontSize: "0.875rem",
2641
+ color: "#ef4444",
2642
+ textAlign: "center",
2643
+ marginBottom: "1rem",
2644
+ lineHeight: "1.5"
2645
+ },
2646
+ spinner: {
2647
+ display: "inline-block",
2648
+ width: "20px",
2649
+ height: "20px",
2650
+ border: "2px solid #e5e7eb",
2651
+ borderTop: "2px solid #3b82f6",
2652
+ borderRadius: "50%",
2653
+ animation: "spin 1s linear infinite",
2654
+ marginRight: "0.5rem"
2655
+ },
2656
+ buttonContainer: {
2657
+ display: "flex",
2658
+ gap: "0.75rem",
2659
+ justifyContent: "center",
2660
+ flexWrap: "wrap",
2661
+ marginTop: "1rem"
2662
+ },
2663
+ retryButton: {
2664
+ padding: "0.75rem 1rem",
2665
+ backgroundColor: "#3b82f6",
2666
+ color: "white",
2667
+ border: "none",
2668
+ borderRadius: "6px",
2669
+ fontSize: "1rem",
2670
+ fontWeight: "500",
2671
+ cursor: "pointer",
2672
+ transition: "background-color 0.15s ease-in-out"
2673
+ },
2674
+ backButton: {
2675
+ padding: "0.75rem 1rem",
2676
+ backgroundColor: "#f3f4f6",
2677
+ color: "#374151",
2678
+ border: "1px solid #d1d5db",
2679
+ borderRadius: "6px",
2680
+ fontSize: "1rem",
2681
+ fontWeight: "500",
2682
+ cursor: "pointer",
2683
+ transition: "all 0.15s ease-in-out"
2684
+ }
2685
+ }, tt = () => /* @__PURE__ */ n("div", { style: Ae.spinner }), rt = () => /* @__PURE__ */ l(
2686
+ "svg",
2687
+ {
2688
+ width: "48",
2689
+ height: "48",
2690
+ viewBox: "0 0 24 24",
2691
+ fill: "none",
2692
+ stroke: "#059669",
2693
+ strokeWidth: "2",
2694
+ strokeLinecap: "round",
2695
+ strokeLinejoin: "round",
2696
+ style: { margin: "0 auto 1rem auto", display: "block" },
2697
+ children: [
2698
+ /* @__PURE__ */ n("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
2699
+ /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2700
+ ]
2701
+ }
2702
+ ), nt = () => /* @__PURE__ */ l(
2703
+ "svg",
2704
+ {
2705
+ width: "48",
2706
+ height: "48",
2707
+ viewBox: "0 0 24 24",
2708
+ fill: "none",
2709
+ stroke: "#ef4444",
2710
+ strokeWidth: "2",
2711
+ strokeLinecap: "round",
2712
+ strokeLinejoin: "round",
2713
+ style: { margin: "0 auto 1rem auto", display: "block" },
2714
+ children: [
2715
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "10" }),
2716
+ /* @__PURE__ */ n("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
2717
+ /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2718
+ ]
2719
+ }
2720
+ ), st = {
2721
+ loading: /* @__PURE__ */ n(tt, {}),
2722
+ success: /* @__PURE__ */ n(rt, {}),
2723
+ error: /* @__PURE__ */ n(nt, {})
2724
+ };
2725
+ function Lt({
2726
+ copy: i = {},
2727
+ styles: e = {},
2728
+ icons: t = {},
2729
+ onSuccess: r,
2730
+ onError: s,
2731
+ onRetry: a,
2732
+ onBackToLogin: b,
2733
+ className: E,
2734
+ token: L,
2735
+ email: P,
2736
+ appId: f,
2737
+ tenantId: m,
2738
+ autoRedirectDelay: M = 3e3
2739
+ }) {
2740
+ const [w, v] = p("verifying"), [I, g] = p(""), { verifyMagicLink: U } = ie(), u = { ...et, ...i }, y = { ...Ae, ...e }, x = { ...st, ...t }, F = () => {
2741
+ if (typeof window > "u") return {};
2742
+ const c = new URLSearchParams(window.location.search);
2743
+ return {
2744
+ token: L || c.get("token") || "",
2745
+ email: P || c.get("email") || "",
2746
+ appId: f || c.get("appId") || "",
2747
+ tenantId: m || c.get("tenantId") || void 0
2748
+ };
2749
+ }, B = async () => {
2750
+ v("verifying"), g("");
2751
+ try {
2752
+ const c = F();
2753
+ if (!c.token || !c.email || !c.appId)
2754
+ throw new Error("Missing required parameters: token, email, or appId");
2755
+ const h = await U(
2756
+ c.token,
2757
+ c.email,
2758
+ c.appId,
2759
+ c.tenantId
2760
+ );
2761
+ v("success"), r == null || r(h), M > 0 && setTimeout(() => {
2762
+ v("redirecting");
2763
+ }, M);
2764
+ } catch (c) {
2765
+ const h = c.message || u.errorMessage;
2766
+ g(h), v("error"), s == null || s(h);
2767
+ }
2768
+ }, z = () => {
2769
+ a == null || a(), B();
2770
+ }, q = () => {
2771
+ b == null || b();
2772
+ };
2773
+ Z(() => {
2774
+ B();
2775
+ }, []);
2776
+ const S = () => {
2777
+ switch (w) {
2778
+ case "verifying":
2779
+ return /* @__PURE__ */ l("div", { style: y.message, children: [
2780
+ x.loading,
2781
+ u.verifyingMessage
2782
+ ] });
2783
+ case "success":
2784
+ return /* @__PURE__ */ l(D, { children: [
2785
+ x.success,
2786
+ /* @__PURE__ */ n("div", { style: y.successMessage, children: u.successMessage })
2787
+ ] });
2788
+ case "redirecting":
2789
+ return /* @__PURE__ */ l(D, { children: [
2790
+ x.loading,
2791
+ /* @__PURE__ */ n("div", { style: y.message, children: u.redirectingMessage })
2792
+ ] });
2793
+ case "error":
2794
+ return /* @__PURE__ */ l(D, { children: [
2795
+ x.error,
2796
+ /* @__PURE__ */ n("div", { style: y.errorMessage, children: I || u.errorMessage }),
2797
+ /* @__PURE__ */ l("div", { style: y.buttonContainer, children: [
2798
+ /* @__PURE__ */ n(
2799
+ "button",
2800
+ {
2801
+ onClick: z,
2802
+ style: y.retryButton,
2803
+ onMouseOver: (c) => {
2804
+ c.currentTarget.style.backgroundColor = "#2563eb";
2805
+ },
2806
+ onMouseOut: (c) => {
2807
+ c.currentTarget.style.backgroundColor = "#3b82f6";
2808
+ },
2809
+ children: u.retryButton
2810
+ }
2811
+ ),
2812
+ /* @__PURE__ */ n(
2813
+ "button",
2814
+ {
2815
+ onClick: q,
2816
+ style: y.backButton,
2817
+ onMouseOver: (c) => {
2818
+ c.currentTarget.style.backgroundColor = "#e5e7eb";
2819
+ },
2820
+ onMouseOut: (c) => {
2821
+ c.currentTarget.style.backgroundColor = "#f3f4f6";
2822
+ },
2823
+ children: u.backToLoginButton
2824
+ }
2825
+ )
2826
+ ] })
2827
+ ] });
2828
+ default:
2829
+ return null;
2830
+ }
2831
+ };
2832
+ return /* @__PURE__ */ l("div", { style: y.container, className: E, children: [
2833
+ /* @__PURE__ */ n("style", { children: `
2834
+ @keyframes spin {
2835
+ 0% { transform: rotate(0deg); }
2836
+ 100% { transform: rotate(360deg); }
2837
+ }
2838
+ ` }),
2839
+ /* @__PURE__ */ n("h1", { style: y.title, children: u.title }),
2840
+ S()
2841
+ ] });
2842
+ }
2843
+ const it = {
2139
2844
  title: "Reset Password",
2140
2845
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2141
2846
  emailLabel: "Email",
@@ -2157,7 +2862,7 @@ const Ge = {
2157
2862
  resetLoadingText: "Resetting...",
2158
2863
  resetSuccessMessage: "Password reset successfully!",
2159
2864
  passwordMismatchError: "Passwords do not match"
2160
- }, _e = {
2865
+ }, ot = {
2161
2866
  container: {
2162
2867
  maxWidth: "400px",
2163
2868
  margin: "0 auto",
@@ -2249,186 +2954,186 @@ const Ge = {
2249
2954
  cursor: "pointer"
2250
2955
  }
2251
2956
  };
2252
- function yt({
2957
+ function Rt({
2253
2958
  copy: i = {},
2254
2959
  styles: e = {},
2255
2960
  mode: t = "request",
2256
2961
  token: r = "",
2257
- onSuccess: n,
2258
- onError: o,
2259
- onBackToLogin: m,
2260
- onModeChange: T,
2261
- className: M
2962
+ onSuccess: s,
2963
+ onError: a,
2964
+ onBackToLogin: b,
2965
+ onModeChange: E,
2966
+ className: L
2262
2967
  }) {
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");
2968
+ const [P, f] = p(""), [m, M] = p(r), [w, v] = p(""), [I, g] = p(""), [U, u] = p(!1), [y, x] = p(""), [F, B] = p(""), [z, q] = p({}), { requestPasswordReset: S, confirmPasswordReset: c } = ie(), { tenant: h } = re(), o = { ...it, ...i }, d = { ...ot, ...e }, G = () => {
2969
+ const O = {};
2970
+ return P.trim() || (O.email = !0), q(O), Object.keys(O).length === 0;
2971
+ }, Y = () => {
2972
+ const O = {};
2973
+ return m.trim() || (O.token = !0), w.trim() || (O.newPassword = !0), I.trim() || (O.confirmPassword = !0), q(O), Object.keys(O).length === 0;
2974
+ }, H = async (O) => {
2975
+ if (O.preventDefault(), !!G()) {
2976
+ if (!(h != null && h.id)) {
2977
+ x("Tenant not found");
2273
2978
  return;
2274
2979
  }
2275
- y(!0), k(""), D("");
2980
+ u(!0), x(""), B("");
2276
2981
  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);
2982
+ await S(P, h.id), B(o.successMessage), s == null || s();
2983
+ } catch (j) {
2984
+ const N = j.message || o.errorMessage;
2985
+ x(N), a == null || a(N);
2281
2986
  } finally {
2282
- y(!1);
2987
+ u(!1);
2283
2988
  }
2284
2989
  }
2285
- }, _ = async (q) => {
2286
- if (q.preventDefault(), !!I()) {
2287
- if (p !== F) {
2288
- k(a.passwordMismatchError), B({ confirmPassword: !0 });
2990
+ }, C = async (O) => {
2991
+ if (O.preventDefault(), !!Y()) {
2992
+ if (w !== I) {
2993
+ x(o.passwordMismatchError), q({ confirmPassword: !0 });
2289
2994
  return;
2290
2995
  }
2291
- y(!0), k(""), D("");
2996
+ u(!0), x(""), B("");
2292
2997
  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);
2998
+ await c(m, w), B(o.resetSuccessMessage), s == null || s();
2999
+ } catch (j) {
3000
+ const N = j.message || o.errorMessage;
3001
+ x(N), a == null || a(N);
2297
3002
  } finally {
2298
- y(!1);
3003
+ u(!1);
2299
3004
  }
2300
3005
  }
2301
- }, C = (q) => ({
2302
- ...l.input,
2303
- ...E[q] ? l.inputError : {}
2304
- }), U = () => ({
2305
- ...l.button,
2306
- ...L ? l.buttonLoading : {}
3006
+ }, k = (O) => ({
3007
+ ...d.input,
3008
+ ...z[O] ? d.inputError : {}
3009
+ }), T = () => ({
3010
+ ...d.button,
3011
+ ...U ? d.buttonLoading : {}
2307
3012
  });
2308
3013
  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(
3014
+ const O = m && w && I;
3015
+ return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3016
+ /* @__PURE__ */ n("h2", { style: d.title, children: o.resetTitle }),
3017
+ /* @__PURE__ */ n("p", { style: d.subtitle, children: o.resetSubtitle }),
3018
+ /* @__PURE__ */ l("form", { onSubmit: C, style: d.form, children: [
3019
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3020
+ /* @__PURE__ */ n("label", { style: d.label, children: o.tokenLabel }),
3021
+ /* @__PURE__ */ n(
2317
3022
  "input",
2318
3023
  {
2319
3024
  type: "text",
2320
- value: h,
2321
- onChange: (O) => {
2322
- x(O.target.value), E.token && B((j) => ({ ...j, token: !1 }));
3025
+ value: m,
3026
+ onChange: (j) => {
3027
+ M(j.target.value), z.token && q((N) => ({ ...N, token: !1 }));
2323
3028
  },
2324
- placeholder: a.tokenPlaceholder,
2325
- style: C("token"),
2326
- disabled: L
3029
+ placeholder: o.tokenPlaceholder,
3030
+ style: k("token"),
3031
+ disabled: U
2327
3032
  }
2328
3033
  )
2329
3034
  ] }),
2330
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2331
- /* @__PURE__ */ s("label", { style: l.label, children: a.newPasswordLabel }),
2332
- /* @__PURE__ */ s(
3035
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3036
+ /* @__PURE__ */ n("label", { style: d.label, children: o.newPasswordLabel }),
3037
+ /* @__PURE__ */ n(
2333
3038
  "input",
2334
3039
  {
2335
3040
  type: "password",
2336
- value: p,
2337
- onChange: (O) => {
2338
- A(O.target.value), E.newPassword && B((j) => ({ ...j, newPassword: !1 }));
3041
+ value: w,
3042
+ onChange: (j) => {
3043
+ v(j.target.value), z.newPassword && q((N) => ({ ...N, newPassword: !1 }));
2339
3044
  },
2340
- placeholder: a.newPasswordPlaceholder,
2341
- style: C("newPassword"),
2342
- disabled: L
3045
+ placeholder: o.newPasswordPlaceholder,
3046
+ style: k("newPassword"),
3047
+ disabled: U
2343
3048
  }
2344
3049
  )
2345
3050
  ] }),
2346
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2347
- /* @__PURE__ */ s("label", { style: l.label, children: a.confirmPasswordLabel }),
2348
- /* @__PURE__ */ s(
3051
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3052
+ /* @__PURE__ */ n("label", { style: d.label, children: o.confirmPasswordLabel }),
3053
+ /* @__PURE__ */ n(
2349
3054
  "input",
2350
3055
  {
2351
3056
  type: "password",
2352
- value: F,
2353
- onChange: (O) => {
2354
- f(O.target.value), E.confirmPassword && B((j) => ({ ...j, confirmPassword: !1 })), S === a.passwordMismatchError && k("");
3057
+ value: I,
3058
+ onChange: (j) => {
3059
+ g(j.target.value), z.confirmPassword && q((N) => ({ ...N, confirmPassword: !1 })), y === o.passwordMismatchError && x("");
2355
3060
  },
2356
- placeholder: a.confirmPasswordPlaceholder,
2357
- style: C("confirmPassword"),
2358
- disabled: L
3061
+ placeholder: o.confirmPasswordPlaceholder,
3062
+ style: k("confirmPassword"),
3063
+ disabled: U
2359
3064
  }
2360
3065
  )
2361
3066
  ] }),
2362
- /* @__PURE__ */ s(
3067
+ /* @__PURE__ */ n(
2363
3068
  "button",
2364
3069
  {
2365
3070
  type: "submit",
2366
- disabled: !q || L,
3071
+ disabled: !O || U,
2367
3072
  style: {
2368
- ...U(),
2369
- ...!q || L ? l.buttonDisabled : {}
3073
+ ...T(),
3074
+ ...!O || U ? d.buttonDisabled : {}
2370
3075
  },
2371
- children: L ? a.resetLoadingText : a.resetSubmitButton
3076
+ children: U ? o.resetLoadingText : o.resetSubmitButton
2372
3077
  }
2373
3078
  ),
2374
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2375
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3079
+ y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3080
+ F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
2376
3081
  ] }),
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" })
3082
+ /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3083
+ /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3084
+ E && /* @__PURE__ */ l(D, { children: [
3085
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3086
+ /* @__PURE__ */ n("a", { onClick: () => E("request"), style: d.link, children: "Request New Link" })
2382
3087
  ] })
2383
3088
  ] })
2384
3089
  ] });
2385
3090
  }
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(
3091
+ const J = P;
3092
+ return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3093
+ /* @__PURE__ */ n("h2", { style: d.title, children: o.title }),
3094
+ /* @__PURE__ */ n("p", { style: d.subtitle, children: o.subtitle }),
3095
+ /* @__PURE__ */ l("form", { onSubmit: H, style: d.form, children: [
3096
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3097
+ /* @__PURE__ */ n("label", { style: d.label, children: o.emailLabel }),
3098
+ /* @__PURE__ */ n(
2394
3099
  "input",
2395
3100
  {
2396
3101
  type: "email",
2397
3102
  value: P,
2398
- onChange: (q) => {
2399
- g(q.target.value), E.email && B((O) => ({ ...O, email: !1 }));
3103
+ onChange: (O) => {
3104
+ f(O.target.value), z.email && q((j) => ({ ...j, email: !1 }));
2400
3105
  },
2401
- placeholder: a.emailPlaceholder,
2402
- style: C("email"),
2403
- disabled: L
3106
+ placeholder: o.emailPlaceholder,
3107
+ style: k("email"),
3108
+ disabled: U
2404
3109
  }
2405
3110
  )
2406
3111
  ] }),
2407
- /* @__PURE__ */ s(
3112
+ /* @__PURE__ */ n(
2408
3113
  "button",
2409
3114
  {
2410
3115
  type: "submit",
2411
- disabled: !Q || L,
3116
+ disabled: !J || U,
2412
3117
  style: {
2413
- ...U(),
2414
- ...!Q || L ? l.buttonDisabled : {}
3118
+ ...T(),
3119
+ ...!J || U ? d.buttonDisabled : {}
2415
3120
  },
2416
- children: L ? a.loadingText : a.submitButton
3121
+ children: U ? o.loadingText : o.submitButton
2417
3122
  }
2418
3123
  ),
2419
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2420
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3124
+ y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3125
+ F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
2421
3126
  ] }),
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" })
3127
+ /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3128
+ /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3129
+ E && /* @__PURE__ */ l(D, { children: [
3130
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3131
+ /* @__PURE__ */ n("a", { onClick: () => E("reset"), style: d.link, children: "I have a token" })
2427
3132
  ] })
2428
3133
  ] })
2429
3134
  ] });
2430
3135
  }
2431
- class wt {
3136
+ class Ct {
2432
3137
  constructor(e, t) {
2433
3138
  this.httpService = e, this.sessionManager = t;
2434
3139
  }
@@ -2449,12 +3154,12 @@ class wt {
2449
3154
  throw new Error("SessionManager is required for private endpoints");
2450
3155
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2451
3156
  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, {
3157
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2453
3158
  headers: t
2454
3159
  });
2455
3160
  return {
2456
- permissions: o.data,
2457
- meta: o.meta
3161
+ permissions: a.data,
3162
+ meta: a.meta
2458
3163
  };
2459
3164
  }
2460
3165
  async getPermissionById(e) {
@@ -2489,14 +3194,14 @@ class wt {
2489
3194
  async getAppPermissions(e, t) {
2490
3195
  const r = new URLSearchParams();
2491
3196
  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);
3197
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
2493
3198
  return {
2494
- permissions: o.data,
2495
- meta: o.meta
3199
+ permissions: a.data,
3200
+ meta: a.meta
2496
3201
  };
2497
3202
  }
2498
3203
  }
2499
- class mt {
3204
+ class It {
2500
3205
  constructor(e, t) {
2501
3206
  this.httpService = e, this.sessionManager = t;
2502
3207
  }
@@ -2513,12 +3218,12 @@ class mt {
2513
3218
  async getSubscriptionPlans(e) {
2514
3219
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2515
3220
  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, {
3221
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2517
3222
  headers: t
2518
3223
  });
2519
3224
  return {
2520
- plans: o.data,
2521
- meta: o.meta
3225
+ plans: a.data,
3226
+ meta: a.meta
2522
3227
  };
2523
3228
  }
2524
3229
  async getSubscriptionPlanById(e) {
@@ -2547,7 +3252,7 @@ class mt {
2547
3252
  });
2548
3253
  }
2549
3254
  }
2550
- class bt {
3255
+ class Ft {
2551
3256
  constructor(e) {
2552
3257
  this.httpService = e;
2553
3258
  }
@@ -2556,7 +3261,7 @@ class bt {
2556
3261
  return await this.httpService.get("/health");
2557
3262
  }
2558
3263
  }
2559
- class St {
3264
+ class Ht {
2560
3265
  // Date string to Date object
2561
3266
  static toDate(e) {
2562
3267
  return new Date(e);
@@ -2673,48 +3378,50 @@ class St {
2673
3378
  // Transform query parameters for API calls
2674
3379
  static transformQueryParams(e) {
2675
3380
  const t = new URLSearchParams();
2676
- return Object.entries(e).forEach(([r, n]) => {
2677
- n != null && n !== "" && t.append(r, String(n));
3381
+ return Object.entries(e).forEach(([r, s]) => {
3382
+ s != null && s !== "" && t.append(r, String(s));
2678
3383
  }), t;
2679
3384
  }
2680
3385
  }
2681
3386
  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
3387
+ Ht as ApiMappers,
3388
+ Te as AppApiService,
3389
+ ht as AppProvider,
3390
+ Re as AuthApiService,
3391
+ yt as AuthProvider,
3392
+ Pt as FeatureFlag,
3393
+ He as FeatureFlagApiService,
3394
+ bt as FeatureFlagProvider,
3395
+ Ft as HealthApiService,
3396
+ te as HttpService,
3397
+ kt as LandingRoute,
3398
+ Tt as LoginForm,
3399
+ Et as MagicLinkForm,
3400
+ Lt as MagicLinkVerify,
3401
+ Rt as PasswordRecoveryForm,
3402
+ Ct as PermissionApiService,
3403
+ vt as Protected,
3404
+ St as ProtectedRoute,
3405
+ pe as RoleApiService,
3406
+ Le as SessionManager,
3407
+ Mt as SignupForm,
3408
+ De as SubscriptionApiService,
3409
+ At as SubscriptionGuard,
3410
+ It as SubscriptionPlanApiService,
3411
+ wt as SubscriptionProvider,
3412
+ fe as TenantApiService,
3413
+ pt as TenantProvider,
3414
+ xt as TenantRoute,
3415
+ Ce as UserApiService,
3416
+ se as UserType,
3417
+ gt as useApi,
3418
+ ne as useApp,
3419
+ ie as useAuth,
3420
+ $e as useFeatureFlags,
3421
+ mt as useSettings,
3422
+ Be as useSubscription,
3423
+ ge as useTenant,
3424
+ re as useTenantInfo,
3425
+ ft as useTenantSettings
2719
3426
  };
2720
3427
  //# sourceMappingURL=index.es.js.map