@ciscode/ui-authentication-kit 1.0.4 → 1.0.6

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.mjs CHANGED
@@ -1,26 +1,27 @@
1
- import * as U from "react";
2
- import e, { createContext as pe, useContext as be, useEffect as R, forwardRef as le, createElement as q, useState as u, useMemo as Y } from "react";
3
- import _ from "axios";
4
- import { jwtDecode as we } from "jwt-decode";
5
- import ye from "react-dom";
6
- import { useT as H } from "@ciscode/ui-translate-core";
7
- import { useNavigate as te, useLocation as ae, Routes as Ee, Route as Z, Navigate as O } from "react-router";
8
- const ne = e.createContext(null);
9
- function se() {
10
- const t = e.useContext(ne);
1
+ import * as R from "react";
2
+ import e, { createContext as we, useContext as Ee, useEffect as W, useState as i, useMemo as J } from "react";
3
+ import oe from "axios";
4
+ import { jwtDecode as ye } from "jwt-decode";
5
+ import Ne from "react-dom";
6
+ import { useT as Z } from "@ciscode/ui-translate-core";
7
+ import { AlertTriangle as ve, X as ke } from "lucide-react";
8
+ import { useNavigate as q, useLocation as ee, Link as Me, Routes as Ie, Route as B, Navigate as K } from "react-router-dom";
9
+ const de = e.createContext(null);
10
+ function te() {
11
+ const t = e.useContext(de);
11
12
  if (!t)
12
13
  throw new Error("useAuthConfig must be used within an AuthConfigProvider");
13
14
  return t;
14
15
  }
15
- const oe = pe(null);
16
- function z() {
17
- const t = be(oe);
16
+ const ue = we(null);
17
+ function T() {
18
+ const t = Ee(ue);
18
19
  if (!t)
19
20
  throw new Error("useAuthState must be inside <AuthProvider>");
20
21
  return t;
21
22
  }
22
- function J(t) {
23
- const a = we(t);
23
+ function ne(t) {
24
+ const a = ye(t);
24
25
  return {
25
26
  id: a.sub,
26
27
  email: a.email ?? "",
@@ -30,54 +31,54 @@ function J(t) {
30
31
  tenantId: a.tenantId ?? ""
31
32
  };
32
33
  }
33
- let K = !1;
34
- function Ne() {
35
- K = !1;
34
+ let ce = !1;
35
+ function Le() {
36
+ ce = !1;
36
37
  }
37
- function ve(t, a) {
38
+ function Pe(t, a) {
38
39
  t.defaults.withCredentials = !0;
39
- const l = `${a.baseUrl}${a.refreshEndpoint ?? "/auth/refresh-token"}`;
40
- t.interceptors.request.use((n) => {
40
+ const r = `${a.baseUrl}${a.refreshEndpoint ?? "/auth/refresh-token"}`;
41
+ t.interceptors.request.use((s) => {
41
42
  const o = a.getAccessToken();
42
- return o && (n.headers.Authorization = `Bearer ${o}`), n;
43
+ return o && (s.headers.Authorization = `Bearer ${o}`), s;
43
44
  });
44
- let r = !1, s = [];
45
+ let l = !1, n = [];
45
46
  return t.interceptors.response.use(
46
- (n) => n,
47
- async (n) => {
48
- var c;
49
- const o = n.config;
50
- if (((c = n.response) == null ? void 0 : c.status) !== 401 || !o || o._retry)
51
- return Promise.reject(n);
52
- if (o._retry = !0, !r) {
53
- r = !0;
47
+ (s) => s,
48
+ async (s) => {
49
+ var d;
50
+ const o = s.config;
51
+ if (((d = s.response) == null ? void 0 : d.status) !== 401 || !o || o._retry)
52
+ return Promise.reject(s);
53
+ if (o._retry = !0, !l) {
54
+ l = !0;
54
55
  try {
55
- const { data: i } = await _.post(l, {}, { withCredentials: !0 });
56
- return a.setAccessToken(i.accessToken), s.forEach((m) => m(i.accessToken)), s = [], t.request(o);
57
- } catch (i) {
58
- return !!a.getAccessToken() && !K && (K = !0, a.logout()), s.forEach((p) => p(null)), s = [], Promise.reject(i);
56
+ const { data: c } = await oe.post(r, {}, { withCredentials: !0 });
57
+ return a.setAccessToken(c.accessToken), n.forEach((u) => u(c.accessToken)), n = [], t.request(o);
58
+ } catch (c) {
59
+ return !!a.getAccessToken() && !ce && (ce = !0, a.logout()), n.forEach((b) => b(null)), n = [], Promise.reject(c);
59
60
  } finally {
60
- r = !1;
61
+ l = !1;
61
62
  }
62
63
  }
63
- return new Promise((i, m) => {
64
- s.push((p) => {
65
- if (!p)
66
- return m(n);
67
- (o.headers ?? (o.headers = {})).Authorization = `Bearer ${p}`, i(t.request(o));
64
+ return new Promise((c, u) => {
65
+ n.push((b) => {
66
+ if (!b)
67
+ return u(s);
68
+ (o.headers ?? (o.headers = {})).Authorization = `Bearer ${b}`, c(t.request(o));
68
69
  });
69
70
  });
70
71
  }
71
72
  ), t;
72
73
  }
73
- const Me = ({ onConfirm: t }) => {
74
- const a = H("authLib");
75
- return R(() => {
76
- const { body: l } = document, r = l.style.overflow, s = l.style.pointerEvents;
77
- return l.style.overflow = "hidden", l.style.pointerEvents = "none", () => {
78
- l.style.overflow = r, l.style.pointerEvents = s;
74
+ const Ce = ({ onConfirm: t }) => {
75
+ const a = Z("authLib");
76
+ return W(() => {
77
+ const { body: r } = document, l = r.style.overflow, n = r.style.pointerEvents;
78
+ return r.style.overflow = "hidden", r.style.pointerEvents = "none", () => {
79
+ r.style.overflow = l, r.style.pointerEvents = n;
79
80
  };
80
- }, []), ye.createPortal(
81
+ }, []), Ne.createPortal(
81
82
  /* @__PURE__ */ e.createElement("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/40 backdrop-blur-sm" }, /* @__PURE__ */ e.createElement("div", { className: "pointer-events-auto w-full max-w-sm rounded-xl bg-white p-6 shadow-xl" }, /* @__PURE__ */ e.createElement("h2", { className: "mb-4 text-xl font-semibold text-gray-800 ltr:text-left rtl:text-center" }, a("sessionExpired.title")), /* @__PURE__ */ e.createElement("p", { className: "mb-8 text-sm text-gray-600 ltr:text-left rtl:text-center" }, a("sessionExpired.message")), /* @__PURE__ */ e.createElement("div", { className: "flex justify-end" }, /* @__PURE__ */ e.createElement(
82
83
  "button",
83
84
  {
@@ -92,38 +93,38 @@ const Me = ({ onConfirm: t }) => {
92
93
  )))),
93
94
  document.body
94
95
  );
95
- }, G = ({
96
+ }, P = ({
96
97
  label: t,
97
98
  type: a = "text",
98
- placeholder: l,
99
- color: r = "",
100
- value: s,
101
- onChange: n
99
+ placeholder: r,
100
+ color: l = "",
101
+ value: n,
102
+ onChange: s
102
103
  }) => {
103
- const o = U.useId();
104
- return /* @__PURE__ */ U.createElement("div", { className: "mt-8 flex flex-col" }, t && /* @__PURE__ */ U.createElement(
104
+ const o = R.useId();
105
+ return /* @__PURE__ */ R.createElement("div", { className: "mt-8 flex flex-col" }, t && /* @__PURE__ */ R.createElement(
105
106
  "label",
106
107
  {
107
108
  htmlFor: o,
108
109
  className: "self-start text-base text-black dark:text-white block ltr:text-left rtl:text-right"
109
110
  },
110
111
  t
111
- ), /* @__PURE__ */ U.createElement(
112
+ ), /* @__PURE__ */ R.createElement(
112
113
  "input",
113
114
  {
114
115
  id: o,
115
116
  type: a,
116
- placeholder: l || void 0,
117
- value: s,
118
- onChange: (c) => n == null ? void 0 : n(c.target.value),
117
+ placeholder: r || void 0,
118
+ value: n,
119
+ onChange: (d) => s == null ? void 0 : s(d.target.value),
119
120
  className: `
120
121
  px-4 py-4 mt-3.5 text-sm font-light rounded-lg border border-solid w-full
121
122
  ltr:text-left rtl:text-right
122
- ${r}
123
+ ${l}
123
124
  `
124
125
  }
125
126
  ));
126
- }, ie = ({ icon: t, label: a }) => /* @__PURE__ */ U.createElement("div", { className: "flex gap-5 px-8 py-3 items-center bg-indigo-50 rounded-lg max-md:px-5" }, /* @__PURE__ */ U.createElement(
127
+ }, ge = ({ icon: t, label: a }) => /* @__PURE__ */ R.createElement("div", { className: "flex gap-5 px-8 py-3 items-center bg-indigo-50 rounded-lg max-md:px-5" }, /* @__PURE__ */ R.createElement(
127
128
  "img",
128
129
  {
129
130
  loading: "lazy",
@@ -131,132 +132,31 @@ const Me = ({ onConfirm: t }) => {
131
132
  alt: a || "",
132
133
  className: "object-contain shrink-0 aspect-square w-[26px]"
133
134
  }
134
- ), a && /* @__PURE__ */ U.createElement("div", { className: "basis-auto text-sm hidden md:block ltr:text-left rtl:text-right" }, a)), ce = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iLTMgMCAyNjIgMjYyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj48cGF0aCBkPSJNMjU1Ljg3OCAxMzMuNDUxYzAtMTAuNzM0LS44NzEtMTguNTY3LTIuNzU2LTI2LjY5SDEzMC41NXY0OC40NDhoNzEuOTQ3Yy0xLjQ1IDEyLjA0LTkuMjgzIDMwLjE3Mi0yNi42OSA0Mi4zNTZsLS4yNDQgMS42MjIgMzguNzU1IDMwLjAyMyAyLjY4NS4yNjhjMjQuNjU5LTIyLjc3NCAzOC44NzUtNTYuMjgyIDM4Ljg3NS05Ni4wMjciIGZpbGw9IiM0Mjg1RjQiLz48cGF0aCBkPSJNMTMwLjU1IDI2MS4xYzM1LjI0OCAwIDY0LjgzOS0xMS42MDUgODYuNDUzLTMxLjYyMmwtNDEuMTk2LTMxLjkxM2MtMTEuMDI0IDcuNjg4LTI1LjgyIDEzLjA1NS00NS4yNTcgMTMuMDU1LTM0LjUyMyAwLTYzLjgyNC0yMi43NzMtNzQuMjY5LTU0LjI1bC0xLjUzMS4xMy00MC4yOTggMzEuMTg3LS41MjcgMS40NjVDMzUuMzkzIDIzMS43OTggNzkuNDkgMjYxLjEgMTMwLjU1IDI2MS4xIiBmaWxsPSIjMzRBODUzIi8+PHBhdGggZD0iTTU2LjI4MSAxNTYuMzdjLTIuNzU2LTguMTIzLTQuMzUxLTE2LjgyNy00LjM1MS0yNS44MiAwLTguOTk0IDEuNTk1LTE3LjY5NyA0LjIwNi0yNS44MmwtLjA3My0xLjczTDE1LjI2IDcxLjMxMmwtMS4zMzUuNjM1QzUuMDc3IDg5LjY0NCAwIDEwOS41MTcgMCAxMzAuNTVzNS4wNzcgNDAuOTA1IDEzLjkyNSA1OC42MDJsNDIuMzU2LTMyLjc4MiIgZmlsbD0iI0ZCQkMwNSIvPjxwYXRoIGQ9Ik0xMzAuNTUgNTAuNDc5YzI0LjUxNCAwIDQxLjA1IDEwLjU4OSA1MC40NzkgMTkuNDM4bDM2Ljg0NC0zNS45NzRDMTk1LjI0NSAxMi45MSAxNjUuNzk4IDAgMTMwLjU1IDAgNzkuNDkgMCAzNS4zOTMgMjkuMzAxIDEzLjkyNSA3MS45NDdsNDIuMjExIDMyLjc4M2MxMC41OS0zMS40NzcgMzkuODkxLTU0LjI1MSA3NC40MTQtNTQuMjUxIiBmaWxsPSIjRUI0MzM1Ii8+PC9zdmc+", me = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE2IDE2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPjxwYXRoIGZpbGw9IiNGMzUzMjUiIGQ9Ik0xIDFoNi41djYuNUgxVjF6Ii8+PHBhdGggZmlsbD0iIzgxQkMwNiIgZD0iTTguNSAxSDE1djYuNUg4LjVWMXoiLz48cGF0aCBmaWxsPSIjMDVBNkYwIiBkPSJNMSA4LjVoNi41VjE1SDFWOC41eiIvPjxwYXRoIGZpbGw9IiNGRkJBMDgiIGQ9Ik04LjUgOC41SDE1VjE1SDguNVY4LjV6Ii8+PC9zdmc+";
135
- function F(t, a, l) {
136
- return t ? t.startsWith(`${a}-`) ? t : t.startsWith("#") ? `${t}` : l : l;
135
+ ), a && /* @__PURE__ */ R.createElement("div", { className: "basis-auto text-sm hidden md:block ltr:text-left rtl:text-right" }, a)), fe = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iLTMgMCAyNjIgMjYyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj48cGF0aCBkPSJNMjU1Ljg3OCAxMzMuNDUxYzAtMTAuNzM0LS44NzEtMTguNTY3LTIuNzU2LTI2LjY5SDEzMC41NXY0OC40NDhoNzEuOTQ3Yy0xLjQ1IDEyLjA0LTkuMjgzIDMwLjE3Mi0yNi42OSA0Mi4zNTZsLS4yNDQgMS42MjIgMzguNzU1IDMwLjAyMyAyLjY4NS4yNjhjMjQuNjU5LTIyLjc3NCAzOC44NzUtNTYuMjgyIDM4Ljg3NS05Ni4wMjciIGZpbGw9IiM0Mjg1RjQiLz48cGF0aCBkPSJNMTMwLjU1IDI2MS4xYzM1LjI0OCAwIDY0LjgzOS0xMS42MDUgODYuNDUzLTMxLjYyMmwtNDEuMTk2LTMxLjkxM2MtMTEuMDI0IDcuNjg4LTI1LjgyIDEzLjA1NS00NS4yNTcgMTMuMDU1LTM0LjUyMyAwLTYzLjgyNC0yMi43NzMtNzQuMjY5LTU0LjI1bC0xLjUzMS4xMy00MC4yOTggMzEuMTg3LS41MjcgMS40NjVDMzUuMzkzIDIzMS43OTggNzkuNDkgMjYxLjEgMTMwLjU1IDI2MS4xIiBmaWxsPSIjMzRBODUzIi8+PHBhdGggZD0iTTU2LjI4MSAxNTYuMzdjLTIuNzU2LTguMTIzLTQuMzUxLTE2LjgyNy00LjM1MS0yNS44MiAwLTguOTk0IDEuNTk1LTE3LjY5NyA0LjIwNi0yNS44MmwtLjA3My0xLjczTDE1LjI2IDcxLjMxMmwtMS4zMzUuNjM1QzUuMDc3IDg5LjY0NCAwIDEwOS41MTcgMCAxMzAuNTVzNS4wNzcgNDAuOTA1IDEzLjkyNSA1OC42MDJsNDIuMzU2LTMyLjc4MiIgZmlsbD0iI0ZCQkMwNSIvPjxwYXRoIGQ9Ik0xMzAuNTUgNTAuNDc5YzI0LjUxNCAwIDQxLjA1IDEwLjU4OSA1MC40NzkgMTkuNDM4bDM2Ljg0NC0zNS45NzRDMTk1LjI0NSAxMi45MSAxNjUuNzk4IDAgMTMwLjU1IDAgNzkuNDkgMCAzNS4zOTMgMjkuMzAxIDEzLjkyNSA3MS45NDdsNDIuMjExIDMyLjc4M2MxMC41OS0zMS40NzcgMzkuODkxLTU0LjI1MSA3NC40MTQtNTQuMjUxIiBmaWxsPSIjRUI0MzM1Ii8+PC9zdmc+", he = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE2IDE2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPjxwYXRoIGZpbGw9IiNGMzUzMjUiIGQ9Ik0xIDFoNi41djYuNUgxVjF6Ii8+PHBhdGggZmlsbD0iIzgxQkMwNiIgZD0iTTguNSAxSDE1djYuNUg4LjVWMXoiLz48cGF0aCBmaWxsPSIjMDVBNkYwIiBkPSJNMSA4LjVoNi41VjE1SDFWOC41eiIvPjxwYXRoIGZpbGw9IiNGRkJBMDgiIGQ9Ik04LjUgOC41SDE1VjE1SDguNVY4LjV6Ii8+PC9zdmc+";
136
+ function X(t, a, r) {
137
+ return t ? t.startsWith(`${a}-`) ? t : t.startsWith("#") ? `${t}` : r : r;
137
138
  }
138
- function de(t, a) {
139
- const l = (a == null ? void 0 : a.bg) || "bg-sky-500", r = (a == null ? void 0 : a.text) || "text-gray-800", s = (a == null ? void 0 : a.border) || "border-gray-300", n = (a == null ? void 0 : a.fill) || "fill-current", o = (a == null ? void 0 : a.stroke) || "stroke-current";
139
+ function ae(t, a) {
140
+ const r = (a == null ? void 0 : a.bg) || "bg-sky-500", l = (a == null ? void 0 : a.text) || "text-gray-800", n = (a == null ? void 0 : a.border) || "border-gray-300", s = (a == null ? void 0 : a.fill) || "fill-current", o = (a == null ? void 0 : a.stroke) || "stroke-current";
140
141
  return {
141
- bgClass: F(t.bg ?? "", "bg", l),
142
- textClass: F(t.text ?? "", "text", r),
143
- borderClass: F(t.border ?? "", "border", s),
144
- fillClass: F(t.fill ?? "", "fill", n),
145
- strokeClass: F(t.stroke ?? "", "stroke", o)
142
+ bgClass: X(t.bg ?? "", "bg", r),
143
+ textClass: X(t.text ?? "", "text", l),
144
+ borderClass: X(t.border ?? "", "border", n),
145
+ fillClass: X(t.fill ?? "", "fill", s),
146
+ strokeClass: X(t.stroke ?? "", "stroke", o)
146
147
  };
147
148
  }
148
- /**
149
- * @license lucide-react v0.481.0 - ISC
150
- *
151
- * This source code is licensed under the ISC license.
152
- * See the LICENSE file in the root directory of this source tree.
153
- */
154
- const Ie = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ue = (...t) => t.filter((a, l, r) => !!a && a.trim() !== "" && r.indexOf(a) === l).join(" ").trim();
155
- /**
156
- * @license lucide-react v0.481.0 - ISC
157
- *
158
- * This source code is licensed under the ISC license.
159
- * See the LICENSE file in the root directory of this source tree.
160
- */
161
- var ke = {
162
- xmlns: "http://www.w3.org/2000/svg",
163
- width: 24,
164
- height: 24,
165
- viewBox: "0 0 24 24",
166
- fill: "none",
167
- stroke: "currentColor",
168
- strokeWidth: 2,
169
- strokeLinecap: "round",
170
- strokeLinejoin: "round"
171
- };
172
- /**
173
- * @license lucide-react v0.481.0 - ISC
174
- *
175
- * This source code is licensed under the ISC license.
176
- * See the LICENSE file in the root directory of this source tree.
177
- */
178
- const Le = le(
179
- ({
180
- color: t = "currentColor",
181
- size: a = 24,
182
- strokeWidth: l = 2,
183
- absoluteStrokeWidth: r,
184
- className: s = "",
185
- children: n,
186
- iconNode: o,
187
- ...c
188
- }, i) => q(
189
- "svg",
190
- {
191
- ref: i,
192
- ...ke,
193
- width: a,
194
- height: a,
195
- stroke: t,
196
- strokeWidth: r ? Number(l) * 24 / Number(a) : l,
197
- className: ue("lucide", s),
198
- ...c
199
- },
200
- [
201
- ...o.map(([m, p]) => q(m, p)),
202
- ...Array.isArray(n) ? n : [n]
203
- ]
204
- )
205
- );
206
- /**
207
- * @license lucide-react v0.481.0 - ISC
208
- *
209
- * This source code is licensed under the ISC license.
210
- * See the LICENSE file in the root directory of this source tree.
211
- */
212
- const ge = (t, a) => {
213
- const l = le(
214
- ({ className: r, ...s }, n) => q(Le, {
215
- ref: n,
216
- iconNode: a,
217
- className: ue(`lucide-${Ie(t)}`, r),
218
- ...s
219
- })
220
- );
221
- return l.displayName = `${t}`, l;
222
- };
223
- /**
224
- * @license lucide-react v0.481.0 - ISC
225
- *
226
- * This source code is licensed under the ISC license.
227
- * See the LICENSE file in the root directory of this source tree.
228
- */
229
- const Ce = [
230
- [
231
- "path",
232
- {
233
- d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
234
- key: "wmoenq"
235
- }
236
- ],
237
- ["path", { d: "M12 9v4", key: "juzpu7" }],
238
- ["path", { d: "M12 17h.01", key: "p32p05" }]
239
- ], je = ge("TriangleAlert", Ce);
240
- /**
241
- * @license lucide-react v0.481.0 - ISC
242
- *
243
- * This source code is licensed under the ISC license.
244
- * See the LICENSE file in the root directory of this source tree.
245
- */
246
- const Se = [
247
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
248
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
249
- ], Te = ge("X", Se), fe = ({
149
+ const le = ({
250
150
  message: t,
251
151
  dismissAfterMs: a = 4e3
252
152
  }) => {
253
- const l = H("authLib"), [r, s] = u(!1);
254
- return R(() => {
255
- if (s(!!t), t && a > 0) {
256
- const n = window.setTimeout(() => s(!1), a);
257
- return () => window.clearTimeout(n);
153
+ const r = Z("authLib"), [l, n] = i(!1);
154
+ return W(() => {
155
+ if (n(!!t), t && a > 0) {
156
+ const s = window.setTimeout(() => n(!1), a);
157
+ return () => window.clearTimeout(s);
258
158
  }
259
- }, [t, a]), !r || !t ? null : /* @__PURE__ */ e.createElement(
159
+ }, [t, a]), !l || !t ? null : /* @__PURE__ */ e.createElement(
260
160
  "div",
261
161
  {
262
162
  role: "alert",
@@ -266,81 +166,81 @@ const Se = [
266
166
  rounded-lg border border-red-300 bg-red-50/80 p-4 pr-6 text-sm text-red-800
267
167
  shadow-lg backdrop-blur
268
168
  transition-all duration-300 ease-out
269
- ${r ? "translate-y-0 opacity-100" : "-translate-y-2 opacity-0"}
169
+ ${l ? "translate-y-0 opacity-100" : "-translate-y-2 opacity-0"}
270
170
  `
271
171
  },
272
172
  /* @__PURE__ */ e.createElement("span", { className: "absolute ltr:left-0 rtl:right-0 top-0 h-full w-1 bg-gradient-to-b from-red-500 to-red-400" }),
273
- /* @__PURE__ */ e.createElement(je, { className: "mt-0.5 h-5 w-5 flex-none" }),
173
+ /* @__PURE__ */ e.createElement(ve, { className: "mt-0.5 h-5 w-5 flex-none" }),
274
174
  /* @__PURE__ */ e.createElement("span", { className: "grow leading-5 ltr:text-left rtl:text-right" }, t),
275
175
  /* @__PURE__ */ e.createElement(
276
176
  "button",
277
177
  {
278
- onClick: () => s(!1),
279
- "aria-label": l("inlineError.dismiss"),
178
+ onClick: () => n(!1),
179
+ "aria-label": r("inlineError.dismiss"),
280
180
  className: `
281
181
  absolute ltr:right-2 rtl:left-2 top-2 rounded p-1 text-red-600/70
282
182
  hover:bg-red-100 hover:text-red-700 focus:outline-none
283
183
  focus-visible:ring focus-visible:ring-red-500/50
284
184
  `
285
185
  },
286
- /* @__PURE__ */ e.createElement(Te, { className: "h-4 w-4" })
186
+ /* @__PURE__ */ e.createElement(ke, { className: "h-4 w-4" })
287
187
  )
288
188
  );
289
- }, Pe = () => {
290
- const t = H("authLib"), a = te(), l = ae(), {
291
- brandName: r = t("brandName", { defaultValue: "MyBrand" }),
292
- colors: s = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
293
- logoUrl: n,
189
+ }, Se = () => {
190
+ const t = Z("authLib"), a = q(), r = ee(), {
191
+ brandName: l = t("brandName", { defaultValue: "MyBrand" }),
192
+ colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
193
+ logoUrl: s,
294
194
  oauthProviders: o = [],
295
- illustrationUrl: c = t("community.illustrationUrl", {
195
+ illustrationUrl: d = t("community.illustrationUrl", {
296
196
  defaultValue: "https://cdn.builder.io/api/v1/image/assets/TEMP/35ba84b8335fda2819c3a14ea3d00321a0fd0e79e571caa31108468010868ca5?placeholderIfAbsent=true&apiKey=a460e9a46e514356ac1106eada03046c"
297
197
  }),
298
- communityContent: i = {
198
+ communityContent: c = {
299
199
  title: t("community.title"),
300
200
  description: t("community.description")
301
201
  },
302
- baseUrl: m
202
+ baseUrl: u
303
203
  // IMPORTANT: used for Google OAuth redirect
304
- } = se(), { login: p } = z(), [b, E] = u(""), [C, N] = u(""), [h, g] = u(!1), [I, d] = u(null), v = {
305
- google: { icon: ce, label: t("social.google") },
306
- microsoft: { icon: me, label: t("social.microsoft") }
307
- }, w = o.filter((x) => x in v).map((x) => ({
308
- id: x,
309
- icon: v[x].icon,
310
- label: v[x].label
311
- })), { bgClass: M, textClass: j, borderClass: D } = de(s), T = `${M} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
312
- async function V(x) {
313
- var B;
314
- if (x.preventDefault(), !h) {
315
- d(null), g(!0);
204
+ } = te(), { login: b } = T(), [h, m] = i(""), [k, N] = i(""), [x, g] = i(!1), [v, f] = i(null), E = {
205
+ google: { icon: fe, label: t("social.google") },
206
+ microsoft: { icon: he, label: t("social.microsoft") }
207
+ }, p = o.filter((w) => w in E).map((w) => ({
208
+ id: w,
209
+ icon: E[w].icon,
210
+ label: E[w].label
211
+ })), { bgClass: C, textClass: M, borderClass: U } = ae(n), z = `${C} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
212
+ async function L(w) {
213
+ var A;
214
+ if (w.preventDefault(), !x) {
215
+ f(null), g(!0);
316
216
  try {
317
- await p({ email: b, password: C });
318
- } catch (S) {
319
- ((B = S == null ? void 0 : S.response) == null ? void 0 : B.status) === 401 ? d(t("errors.invalidCredentials")) : d(t("errors.generic"));
217
+ await b({ email: h, password: k });
218
+ } catch (I) {
219
+ ((A = I == null ? void 0 : I.response) == null ? void 0 : A.status) === 401 ? f(t("errors.invalidCredentials")) : f(t("errors.generic"));
320
220
  } finally {
321
221
  g(!1);
322
222
  }
323
223
  }
324
224
  }
325
- function A(x) {
326
- var S, f, P;
327
- if (!m) {
225
+ function D(w) {
226
+ var I, $, S;
227
+ if (!u) {
328
228
  console.error("Auth baseUrl is not configured.");
329
229
  return;
330
230
  }
331
- const B = ((f = (S = l.state) == null ? void 0 : S.from) == null ? void 0 : f.pathname) || ((P = l.state) == null ? void 0 : P.from) || "/";
332
- if (sessionStorage.setItem("postLoginRedirect", B), x === "google") {
333
- const k = "/oauth/google/callback", L = `${window.location.origin}${k}`, y = new URL(`${m}/auth/google`);
334
- y.searchParams.set("redirect", L), window.location.href = y.toString();
231
+ const A = (($ = (I = r.state) == null ? void 0 : I.from) == null ? void 0 : $.pathname) || ((S = r.state) == null ? void 0 : S.from) || "/";
232
+ if (sessionStorage.setItem("postLoginRedirect", A), w === "google") {
233
+ const G = "/oauth/google/callback", Y = `${window.location.origin}${G}`, V = new URL(`${u}/auth/google`);
234
+ V.searchParams.set("redirect", Y), window.location.href = V.toString();
335
235
  return;
336
236
  }
337
- if (x === "microsoft") {
338
- const k = "/oauth/microsoft/callback", L = `${window.location.origin}${k}`, y = new URL(`${m}/auth/microsoft`);
339
- y.searchParams.set("redirect", L), window.location.href = y.toString();
237
+ if (w === "microsoft") {
238
+ const G = "/oauth/microsoft/callback", Y = `${window.location.origin}${G}`, V = new URL(`${u}/auth/microsoft`);
239
+ V.searchParams.set("redirect", Y), window.location.href = V.toString();
340
240
  return;
341
241
  }
342
242
  }
343
- const Q = /* @__PURE__ */ e.createElement(
243
+ const re = /* @__PURE__ */ e.createElement(
344
244
  "svg",
345
245
  {
346
246
  className: "h-4 w-4 animate-spin stroke-current",
@@ -358,145 +258,146 @@ const Se = [
358
258
  }
359
259
  )
360
260
  );
361
- return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${T}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${M}` }, /* @__PURE__ */ e.createElement("div", null, n ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
261
+ return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${z}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${C}` }, /* @__PURE__ */ e.createElement("div", null, s ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
362
262
  "img",
363
263
  {
364
264
  loading: "lazy",
365
- src: n,
265
+ src: s,
366
266
  alt: "Brand Logo",
367
267
  className: "bg-white h-8 md:h-22 rounded-lg"
368
268
  }
369
- ), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, r)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, r)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, i.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, i.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
269
+ ), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, l)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, c.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, c.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
370
270
  "img",
371
271
  {
372
272
  loading: "lazy",
373
- src: c,
273
+ src: d,
374
274
  alt: "Sign in illustration",
375
275
  className: "max-w-sm w-full mx-auto rounded-lg shadow-lg transform hover:scale-105 transition-transform duration-300 p-6"
376
276
  }
377
- )))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, n ? /* @__PURE__ */ e.createElement(
277
+ )))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, s ? /* @__PURE__ */ e.createElement(
378
278
  "img",
379
279
  {
380
280
  loading: "lazy",
381
- src: n,
281
+ src: s,
382
282
  alt: "Brand Logo",
383
- className: `h-22 rounded-full border ${D}`
283
+ className: `h-22 rounded-full border ${U}`
384
284
  }
385
- ) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, r)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignInPage.welcome"), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${j} uppercase` }, r)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignInPage.signIn"))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignInPage.noAccount"), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
285
+ ) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignInPage.welcome"), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${M} uppercase` }, l)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignInPage.signIn"))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignInPage.noAccount"), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
386
286
  "button",
387
287
  {
388
288
  type: "button",
389
289
  onClick: () => a("/signup"),
390
- className: j
290
+ className: M
391
291
  },
392
292
  t("SignInPage.signUp")
393
- ))), I && /* @__PURE__ */ e.createElement(fe, { message: I }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: V }, /* @__PURE__ */ e.createElement(
394
- G,
293
+ ))), v && /* @__PURE__ */ e.createElement(le, { message: v }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: L }, /* @__PURE__ */ e.createElement(
294
+ P,
395
295
  {
396
296
  label: t("form.emailLabel"),
397
297
  type: "email",
398
298
  placeholder: t("form.emailPlaceholder"),
399
- color: D,
400
- value: b,
401
- onChange: E
299
+ color: U,
300
+ value: h,
301
+ onChange: m
402
302
  }
403
303
  ), /* @__PURE__ */ e.createElement(
404
- G,
304
+ P,
405
305
  {
406
306
  label: t("form.passwordLabel"),
407
307
  type: "password",
408
308
  placeholder: t("form.passwordPlaceholder"),
409
- color: D,
410
- value: C,
309
+ color: U,
310
+ value: k,
411
311
  onChange: N
412
312
  }
413
- ), /* @__PURE__ */ e.createElement("div", { className: "ltr:text-right rtl:text-left" }, /* @__PURE__ */ e.createElement("button", { className: `text-sm ${j}` }, t("SignInPage.forgotPassword"))), /* @__PURE__ */ e.createElement(
313
+ ), /* @__PURE__ */ e.createElement("div", { className: "ltr:text-right rtl:text-left" }, /* @__PURE__ */ e.createElement(Me, { to: "/forgot-password", className: M }, t("SignInPage.forgotPassword"))), /* @__PURE__ */ e.createElement(
414
314
  "button",
415
315
  {
416
316
  type: "submit",
417
- disabled: h,
418
- className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${h ? "opacity-60 cursor-not-allowed" : ""} ${M} text-white`
317
+ disabled: x,
318
+ className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${x ? "opacity-60 cursor-not-allowed" : ""} ${C} text-white`
419
319
  },
420
- h && Q,
421
- t(h ? "SignInPage.signInSubmitting" : "SignInPage.signIn")
422
- ), w.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${M}` }), /* @__PURE__ */ e.createElement("span", { className: `${j} mx-3 text-sm` }, t("SignInPage.orLoginWith")), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${M}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, w.map((x) => /* @__PURE__ */ e.createElement(
320
+ x && re,
321
+ t(x ? "SignInPage.signInSubmitting" : "SignInPage.signIn")
322
+ ), p.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${C}` }), /* @__PURE__ */ e.createElement("span", { className: `${M} mx-3 text-sm` }, t("SignInPage.orLoginWith")), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${C}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, p.map((w) => /* @__PURE__ */ e.createElement(
423
323
  "button",
424
324
  {
425
- key: x.id,
325
+ key: w.id,
426
326
  type: "button",
427
- onClick: () => A(x.id),
327
+ onClick: () => D(w.id),
428
328
  className: "flex-1"
429
329
  },
430
- /* @__PURE__ */ e.createElement(ie, { icon: x.icon, label: x.label })
330
+ /* @__PURE__ */ e.createElement(ge, { icon: w.icon, label: w.label })
431
331
  ))))))));
432
- }, Ue = () => {
433
- const t = H("authLib"), a = te(), l = ae(), {
434
- brandName: r = t("brandName", { defaultValue: "MyBrand" }),
435
- colors: s = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
436
- logoUrl: n,
332
+ }, je = () => {
333
+ const t = Z("authLib"), a = q(), r = ee(), {
334
+ brandName: l = t("brandName", { defaultValue: "MyBrand" }),
335
+ colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
336
+ logoUrl: s,
437
337
  oauthProviders: o = [],
438
- illustrationUrl: c = t("community.illustrationUrl", {
338
+ illustrationUrl: d = t("community.illustrationUrl", {
439
339
  defaultValue: "https://cdn.builder.io/api/v1/image/assets/TEMP/35ba84b8335fda2819c3a14ea3d00321a0fd0e79e571caa31108468010868ca5?placeholderIfAbsent=true&apiKey=a460e9a46e514356ac1106eada03046c"
440
340
  }),
441
- communityContent: i = {
341
+ communityContent: c = {
442
342
  title: t("community.title"),
443
343
  description: t("community.description")
444
344
  },
445
- baseUrl: m
345
+ baseUrl: u
446
346
  // IMPORTANT: used for OAuth redirect (same as SignIn)
447
- } = se(), { login: p, api: b } = z(), [E, C] = u(""), [N, h] = u(""), [g, I] = u(""), [d, v] = u(!1), [w, M] = u(null), j = {
448
- google: { icon: ce, label: t("social.google") },
449
- microsoft: { icon: me, label: t("social.microsoft") }
450
- }, D = o.filter((f) => f in j).map((f) => ({
451
- id: f,
452
- icon: j[f].icon,
453
- label: j[f].label
454
- })), { bgClass: T, textClass: V, borderClass: A } = de(s), Q = `${T} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
455
- async function x(f) {
456
- var P, k, L;
457
- if (f.preventDefault(), !d) {
458
- M(null), v(!0);
347
+ } = te(), { login: b, api: h } = T(), [m, k] = i(""), [N, x] = i(""), [g, v] = i(""), [f, E] = i(""), [p, C] = i(""), [M, U] = i(!1), [z, L] = i(null), [D, re] = i(!1), w = {
348
+ google: { icon: fe, label: t("social.google") },
349
+ microsoft: { icon: he, label: t("social.microsoft") }
350
+ }, A = o.filter((y) => y in w).map((y) => ({
351
+ id: y,
352
+ icon: w[y].icon,
353
+ label: w[y].label
354
+ })), { bgClass: I, textClass: $, borderClass: S } = ae(n), G = `${I} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
355
+ async function Y(y) {
356
+ var _, O, H;
357
+ if (y.preventDefault(), !M) {
358
+ L(null), U(!0);
459
359
  try {
460
- await b.post("/auth/clients/register", {
461
- email: N,
462
- password: g,
463
- name: E || void 0
464
- }), await p({ email: N, password: g });
465
- } catch (y) {
466
- const $ = (P = y == null ? void 0 : y.response) == null ? void 0 : P.status;
467
- M(
468
- $ === 400 ? ((L = (k = y == null ? void 0 : y.response) == null ? void 0 : k.data) == null ? void 0 : L.message) || t("errors.invalidData", {
360
+ await h.post("/api/auth/register", {
361
+ fullname: { fname: m, lname: N },
362
+ username: g,
363
+ email: f,
364
+ password: p
365
+ }), await b({ email: f, password: p });
366
+ } catch (j) {
367
+ const F = (_ = j == null ? void 0 : j.response) == null ? void 0 : _.status;
368
+ L(
369
+ F === 400 ? ((H = (O = j == null ? void 0 : j.response) == null ? void 0 : O.data) == null ? void 0 : H.message) || t("errors.invalidData", {
469
370
  defaultValue: "Please check the fields and try again."
470
- }) : $ === 409 ? t("errors.emailInUse", {
371
+ }) : F === 409 ? t("errors.emailInUse", {
471
372
  defaultValue: "This email is already in use."
472
373
  }) : t("errors.generic", {
473
374
  defaultValue: "Something went wrong. Please try again."
474
375
  })
475
376
  );
476
377
  } finally {
477
- v(!1);
378
+ U(!1);
478
379
  }
479
380
  }
480
381
  }
481
- function B(f) {
482
- var k, L, y;
483
- if (!m) {
382
+ function V(y) {
383
+ var O, H, j;
384
+ if (!u) {
484
385
  console.error("Auth baseUrl is not configured.");
485
386
  return;
486
387
  }
487
- const P = ((L = (k = l.state) == null ? void 0 : k.from) == null ? void 0 : L.pathname) || ((y = l.state) == null ? void 0 : y.from) || "/";
488
- if (sessionStorage.setItem("postLoginRedirect", P), f === "google") {
489
- const $ = "/oauth/google/callback", X = `${window.location.origin}${$}`, W = new URL(`${m}/auth/google`);
490
- W.searchParams.set("redirect", X), window.location.href = W.toString();
388
+ const _ = ((H = (O = r.state) == null ? void 0 : O.from) == null ? void 0 : H.pathname) || ((j = r.state) == null ? void 0 : j.from) || "/";
389
+ if (sessionStorage.setItem("postLoginRedirect", _), y === "google") {
390
+ const F = "/oauth/google/callback", se = `${window.location.origin}${F}`, Q = new URL(`${u}/auth/google`);
391
+ Q.searchParams.set("redirect", se), window.location.href = Q.toString();
491
392
  return;
492
393
  }
493
- if (f === "microsoft") {
494
- const $ = "/oauth/microsoft/callback", X = `${window.location.origin}${$}`, W = new URL(`${m}/auth/microsoft`);
495
- W.searchParams.set("redirect", X), window.location.href = W.toString();
394
+ if (y === "microsoft") {
395
+ const F = "/oauth/microsoft/callback", se = `${window.location.origin}${F}`, Q = new URL(`${u}/auth/microsoft`);
396
+ Q.searchParams.set("redirect", se), window.location.href = Q.toString();
496
397
  return;
497
398
  }
498
399
  }
499
- const S = /* @__PURE__ */ e.createElement(
400
+ const be = /* @__PURE__ */ e.createElement(
500
401
  "svg",
501
402
  {
502
403
  className: "h-4 w-4 animate-spin stroke-current",
@@ -514,285 +415,428 @@ const Se = [
514
415
  }
515
416
  )
516
417
  );
517
- return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${Q}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${T}` }, /* @__PURE__ */ e.createElement("div", null, n ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
418
+ return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${G}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${I}` }, /* @__PURE__ */ e.createElement("div", null, s ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
518
419
  "img",
519
420
  {
520
421
  loading: "lazy",
521
- src: n,
422
+ src: s,
522
423
  alt: "Brand Logo",
523
424
  className: "bg-white h-8 md:h-22 rounded-lg"
524
425
  }
525
- ), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, r)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, r)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, i.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, i.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
426
+ ), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, l)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, c.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, c.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
526
427
  "img",
527
428
  {
528
429
  loading: "lazy",
529
- src: c,
430
+ src: d,
530
431
  alt: "Sign up illustration",
531
432
  className: "max-w-sm w-full mx-auto rounded-lg shadow-lg transform hover:scale-105 transition-transform duration-300 p-6"
532
433
  }
533
- )))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, n ? /* @__PURE__ */ e.createElement(
434
+ )))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, s ? /* @__PURE__ */ e.createElement(
534
435
  "img",
535
436
  {
536
437
  loading: "lazy",
537
- src: n,
438
+ src: s,
538
439
  alt: "Brand Logo",
539
- className: `h-22 rounded-full border ${A}`
440
+ className: `h-22 rounded-full border ${S}`
540
441
  }
541
- ) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, r)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignUpPage.welcome", { defaultValue: "Join" }), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${V} uppercase` }, r)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignUpPage.signUp", { defaultValue: "Sign up" }))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignUpPage.alreadyHaveAccount", {
442
+ ) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignUpPage.welcome", { defaultValue: "Join" }), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${$} uppercase` }, l)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignUpPage.signUp", { defaultValue: "Sign up" }))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignUpPage.alreadyHaveAccount", {
542
443
  defaultValue: "Already have an account?"
543
444
  }), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
544
445
  "button",
545
446
  {
546
447
  type: "button",
547
448
  onClick: () => a("/login"),
548
- className: V
449
+ className: $
549
450
  },
550
451
  t("SignUpPage.signIn", { defaultValue: "Sign in" })
551
- ))), w && /* @__PURE__ */ e.createElement(fe, { message: w }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: x }, /* @__PURE__ */ e.createElement(
552
- G,
452
+ ))), z && /* @__PURE__ */ e.createElement(le, { message: z }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: Y }, /* @__PURE__ */ e.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ e.createElement(
453
+ P,
553
454
  {
554
- label: t("form.nameLabel", { defaultValue: "Name" }),
455
+ label: t("form.fnameLabel", { defaultValue: "First Name" }),
555
456
  type: "text",
556
- placeholder: t("form.namePlaceholder", {
557
- defaultValue: "Enter your name"
558
- }),
559
- color: A,
560
- value: E,
561
- onChange: C
457
+ placeholder: t("form.fnamePlaceholder", { defaultValue: "Enter your first name" }),
458
+ color: S,
459
+ value: m,
460
+ onChange: k
562
461
  }
563
462
  ), /* @__PURE__ */ e.createElement(
564
- G,
463
+ P,
464
+ {
465
+ label: t("form.lnameLabel", { defaultValue: "Last Name" }),
466
+ type: "text",
467
+ placeholder: t("form.lnamePlaceholder", { defaultValue: "Enter your last name" }),
468
+ color: S,
469
+ value: N,
470
+ onChange: x
471
+ }
472
+ )), /* @__PURE__ */ e.createElement(
473
+ P,
474
+ {
475
+ label: t("form.usernameLabel", { defaultValue: "Username" }),
476
+ type: "text",
477
+ placeholder: t("form.usernamePlaceholder", { defaultValue: "Choose a username" }),
478
+ color: S,
479
+ value: g,
480
+ onChange: v
481
+ }
482
+ ), /* @__PURE__ */ e.createElement(
483
+ P,
565
484
  {
566
485
  label: t("form.emailLabel"),
567
486
  type: "email",
568
487
  placeholder: t("form.emailPlaceholder"),
569
- color: A,
570
- value: N,
571
- onChange: h
488
+ color: S,
489
+ value: f,
490
+ onChange: E
572
491
  }
573
492
  ), /* @__PURE__ */ e.createElement(
574
- G,
493
+ P,
575
494
  {
576
495
  label: t("form.passwordLabel"),
577
496
  type: "password",
578
497
  placeholder: t("form.passwordPlaceholder"),
579
- color: A,
580
- value: g,
581
- onChange: I
498
+ color: S,
499
+ value: p,
500
+ onChange: C
582
501
  }
583
- ), /* @__PURE__ */ e.createElement(
502
+ ), /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ e.createElement(
503
+ "input",
504
+ {
505
+ id: "agree",
506
+ type: "checkbox",
507
+ checked: D,
508
+ onChange: (y) => re(y.target.checked),
509
+ className: "form-checkbox"
510
+ }
511
+ ), /* @__PURE__ */ e.createElement("label", { htmlFor: "agree", className: "text-sm" }, "I agree to the ", /* @__PURE__ */ e.createElement("span", { className: "underline cursor-pointer" }, "terms and conditions"), " (placeholder)")), /* @__PURE__ */ e.createElement(
584
512
  "button",
585
513
  {
586
514
  type: "submit",
587
- disabled: d,
588
- className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${d ? "opacity-60 cursor-not-allowed" : ""} ${T} text-white`
515
+ disabled: M,
516
+ className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${M ? "opacity-60 cursor-not-allowed" : ""} ${I} text-white`
589
517
  },
590
- d && S,
591
- d ? t("SignUpPage.signUpSubmitting", {
518
+ M && be,
519
+ M ? t("SignUpPage.signUpSubmitting", {
592
520
  defaultValue: "Creating account..."
593
521
  }) : t("SignUpPage.signUp", { defaultValue: "Sign up" })
594
- ), D.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${T}` }), /* @__PURE__ */ e.createElement("span", { className: `${V} mx-3 text-sm` }, t("SignUpPage.orContinueWith", {
522
+ ), A.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${I}` }), /* @__PURE__ */ e.createElement("span", { className: `${$} mx-3 text-sm` }, t("SignUpPage.orContinueWith", {
595
523
  defaultValue: "Or continue with"
596
- })), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${T}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, D.map((f) => /* @__PURE__ */ e.createElement(
524
+ })), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${I}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, A.map((y) => /* @__PURE__ */ e.createElement(
597
525
  "button",
598
526
  {
599
- key: f.id,
527
+ key: y.id,
600
528
  type: "button",
601
- onClick: () => B(f.id),
529
+ onClick: () => V(y.id),
602
530
  className: "flex-1"
603
531
  },
604
- /* @__PURE__ */ e.createElement(ie, { icon: f.icon, label: f.label })
532
+ /* @__PURE__ */ e.createElement(ge, { icon: y.icon, label: y.label })
605
533
  ))))))));
606
- }, re = () => (R(() => {
607
- const t = new URLSearchParams(window.location.search), a = t.get("accessToken"), l = t.get("refreshToken");
608
- a && localStorage.setItem("authToken", a), l && localStorage.setItem("refreshToken", l);
609
- const r = sessionStorage.getItem("postLoginRedirect") || "/";
610
- sessionStorage.removeItem("postLoginRedirect"), window.location.replace(r);
611
- }, []), /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center min-h-screen text-gray-700" }, "Finishing Google sign-in…")), ze = ({ children: t }) => {
612
- const { isAuthenticated: a } = z(), l = ae();
613
- return a ? t : /* @__PURE__ */ e.createElement(O, { to: "/login", state: { from: l }, replace: !0 });
534
+ }, me = () => (W(() => {
535
+ const t = new URLSearchParams(window.location.search), a = t.get("accessToken"), r = t.get("refreshToken");
536
+ a && localStorage.setItem("authToken", a), r && localStorage.setItem("refreshToken", r);
537
+ const l = sessionStorage.getItem("postLoginRedirect") || "/";
538
+ sessionStorage.removeItem("postLoginRedirect"), window.location.replace(l);
539
+ }, []), /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center min-h-screen text-gray-700" }, "Finishing Google sign-in…")), Te = () => {
540
+ const t = Z("authLib"), a = q(), { colors: r, brandName: l = t("brandName", { defaultValue: "MyBrand" }), logoUrl: n } = te(), { api: s } = T(), { bgClass: o, textClass: d, borderClass: c } = ae(r), u = `${o} bg-gradient-to-r from-white/10 via-white/0 to-white/0`, [b, h] = i(""), [m, k] = i(!1), [N, x] = i(null), [g, v] = i(!1);
541
+ async function f(E) {
542
+ if (E.preventDefault(), !m) {
543
+ x(null), k(!0);
544
+ try {
545
+ await s.post("/api/auth/forgot-password", { email: b }), v(!0);
546
+ } catch (p) {
547
+ v(!0), console.error("Forgot password request failed", p);
548
+ } finally {
549
+ k(!1);
550
+ }
551
+ }
552
+ }
553
+ return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${u}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: "w-full p-6 md:p-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between mb-6" }, n ? /* @__PURE__ */ e.createElement(
554
+ "img",
555
+ {
556
+ loading: "lazy",
557
+ src: n,
558
+ alt: "Brand Logo",
559
+ className: `h-10 rounded-lg border ${c}`
560
+ }
561
+ ) : /* @__PURE__ */ e.createElement("h2", { className: "text-xl font-bold" }, l), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => a("/login"), className: `text-sm ${d}` }, t("ForgotPasswordPage.backToLogin", { defaultValue: "Back to Sign In" }))), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-3xl font-bold text-gray-800" }, t("ForgotPasswordPage.title", { defaultValue: "Forgot your password?" })), /* @__PURE__ */ e.createElement("p", { className: "mt-2 text-sm text-gray-600" }, t("ForgotPasswordPage.subtitle", { defaultValue: "Enter your email to receive a reset link." })), N && /* @__PURE__ */ e.createElement(le, { message: N }), g ? /* @__PURE__ */ e.createElement("div", { className: "mt-6 rounded-lg border border-green-300 bg-green-50 p-4 text-green-800 text-sm" }, t("ForgotPasswordPage.sent", {
562
+ defaultValue: "If the email exists, we’ve sent a reset link. Please check your inbox."
563
+ })) : /* @__PURE__ */ e.createElement("form", { className: "space-y-6 mt-4", onSubmit: f }, /* @__PURE__ */ e.createElement(
564
+ P,
565
+ {
566
+ label: t("form.emailLabel"),
567
+ type: "email",
568
+ placeholder: t("form.emailPlaceholder"),
569
+ color: c,
570
+ value: b,
571
+ onChange: h
572
+ }
573
+ ), /* @__PURE__ */ e.createElement(
574
+ "button",
575
+ {
576
+ type: "submit",
577
+ disabled: m || !b,
578
+ className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${m ? "opacity-60 cursor-not-allowed" : ""} ${o} text-white`
579
+ },
580
+ m && /* @__PURE__ */ e.createElement("svg", { className: "h-4 w-4 animate-spin stroke-current", viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ e.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "4" }), /* @__PURE__ */ e.createElement("path", { className: "opacity-75", d: "M4 12a8 8 0 018-8", strokeWidth: "4", strokeLinecap: "round" })),
581
+ t("ForgotPasswordPage.sendLink", { defaultValue: "Send Reset Link" })
582
+ )))));
583
+ }, Ue = () => {
584
+ const t = Z("authLib"), a = q(), r = ee(), { colors: l, brandName: n = t("brandName", { defaultValue: "MyBrand" }), logoUrl: s } = te(), { api: o } = T(), { bgClass: d, textClass: c, borderClass: u } = ae(l), b = `${d} bg-gradient-to-r from-white/10 via-white/0 to-white/0`, h = J(() => new URLSearchParams(r.search).get("token"), [r.search]), [m, k] = i(""), [N, x] = i(""), [g, v] = i(!1), [f, E] = i(null), p = 6, C = h && m.length >= p && m === N;
585
+ async function M(U) {
586
+ var z;
587
+ if (U.preventDefault(), !g) {
588
+ if (E(null), !h) {
589
+ E(t("ResetPasswordPage.invalidLink", { defaultValue: "Invalid reset link." }));
590
+ return;
591
+ }
592
+ if (m.length < p) {
593
+ E(
594
+ t("ResetPasswordPage.tooShort", { defaultValue: `Password must be at least ${p} characters.` })
595
+ );
596
+ return;
597
+ }
598
+ if (m !== N) {
599
+ E(t("ResetPasswordPage.mismatch", { defaultValue: "Passwords do not match." }));
600
+ return;
601
+ }
602
+ v(!0);
603
+ try {
604
+ await o.post("/api/auth/reset-password", { token: h, newPassword: m }), a("/login", { replace: !0 });
605
+ } catch (L) {
606
+ const D = (z = L == null ? void 0 : L.response) == null ? void 0 : z.status;
607
+ E(
608
+ D === 400 || D === 401 || D === 410 ? t("ResetPasswordPage.invalidOrExpired", {
609
+ defaultValue: "Reset link is invalid or has expired. Request a new one."
610
+ }) : t("errors.generic", { defaultValue: "Something went wrong. Please try again." })
611
+ );
612
+ } finally {
613
+ v(!1);
614
+ }
615
+ }
616
+ }
617
+ return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${b}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: "w-full p-6 md:p-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between mb-6" }, s ? /* @__PURE__ */ e.createElement(
618
+ "img",
619
+ {
620
+ loading: "lazy",
621
+ src: s,
622
+ alt: "Brand Logo",
623
+ className: `h-10 rounded-lg border ${u}`
624
+ }
625
+ ) : /* @__PURE__ */ e.createElement("h2", { className: "text-xl font-bold" }, n), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => a("/login"), className: `text-sm ${c}` }, t("ResetPasswordPage.backToLogin", { defaultValue: "Back to Sign In" }))), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-3xl font-bold text-gray-800" }, t("ResetPasswordPage.title", { defaultValue: "Reset your password" })), /* @__PURE__ */ e.createElement("p", { className: "mt-2 text-sm text-gray-600" }, t("ResetPasswordPage.subtitle", { defaultValue: "Choose a new password to access your account." })), f && /* @__PURE__ */ e.createElement(le, { message: f }), !h && /* @__PURE__ */ e.createElement("div", { className: "mt-6 rounded-lg border border-red-300 bg-red-50 p-4 text-red-800 text-sm" }, t("ResetPasswordPage.invalidLink", { defaultValue: "Invalid reset link." })), /* @__PURE__ */ e.createElement("form", { className: "space-y-6 mt-4", onSubmit: M }, /* @__PURE__ */ e.createElement(
626
+ P,
627
+ {
628
+ label: t("form.passwordLabel"),
629
+ type: "password",
630
+ placeholder: t("form.passwordPlaceholder"),
631
+ color: u,
632
+ value: m,
633
+ onChange: k
634
+ }
635
+ ), /* @__PURE__ */ e.createElement(
636
+ P,
637
+ {
638
+ label: t("ResetPasswordPage.confirmLabel", { defaultValue: "Confirm Password" }),
639
+ type: "password",
640
+ placeholder: t("ResetPasswordPage.confirmPlaceholder", { defaultValue: "Re-enter your password" }),
641
+ color: u,
642
+ value: N,
643
+ onChange: x
644
+ }
645
+ ), /* @__PURE__ */ e.createElement(
646
+ "button",
647
+ {
648
+ type: "submit",
649
+ disabled: g || !C,
650
+ className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${g ? "opacity-60 cursor-not-allowed" : ""} ${d} text-white`
651
+ },
652
+ g && /* @__PURE__ */ e.createElement("svg", { className: "h-4 w-4 animate-spin stroke-current", viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ e.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "4" }), /* @__PURE__ */ e.createElement("path", { className: "opacity-75", d: "M4 12a8 8 0 018-8", strokeWidth: "4", strokeLinecap: "round" })),
653
+ t("ResetPasswordPage.submit", { defaultValue: "Reset Password" })
654
+ )))));
655
+ }, ze = ({ children: t }) => {
656
+ const { isAuthenticated: a } = T(), r = ee();
657
+ return a ? t : /* @__PURE__ */ e.createElement(K, { to: "/login", state: { from: r }, replace: !0 });
614
658
  }, We = ({ config: t, children: a }) => {
615
- const l = te(), [r, s] = u(
659
+ const r = q(), [l, n] = i(
616
660
  () => localStorage.getItem("authToken")
617
- ), [n, o] = u(null), [c, i] = u(!0), [m, p] = u(!1);
618
- async function b() {
661
+ ), [s, o] = i(null), [d, c] = i(!0), [u, b] = i(!1);
662
+ async function h() {
619
663
  try {
620
- await E.post("/auth/logout");
621
- } catch (h) {
622
- console.warn("Logout endpoint failed, proceeding with local logout:", h);
664
+ await m.post("/auth/logout");
665
+ } catch (x) {
666
+ console.warn("Logout endpoint failed, proceeding with local logout:", x);
623
667
  }
624
- s(null), o(null), localStorage.removeItem("authToken"), sessionStorage.clear(), p(!1), l("/login", { replace: !0 });
668
+ n(null), o(null), localStorage.removeItem("authToken"), sessionStorage.clear(), b(!1), r("/login", { replace: !0 });
625
669
  }
626
- const E = Y(() => {
627
- const h = _.create({
670
+ const m = J(() => {
671
+ const x = oe.create({
628
672
  baseURL: t.baseUrl,
629
673
  withCredentials: !0
630
674
  });
631
- return ve(h, {
675
+ return Pe(x, {
632
676
  baseUrl: t.baseUrl,
633
- getAccessToken: () => r,
634
- setAccessToken: (g) => s(g),
635
- logout: () => p(!0)
636
- }), h;
637
- }, [t.baseUrl, r]);
638
- R(() => {
677
+ getAccessToken: () => l,
678
+ setAccessToken: (g) => n(g),
679
+ logout: () => b(!0)
680
+ }), x;
681
+ }, [t.baseUrl, l]);
682
+ W(() => {
639
683
  (async () => {
640
- if (r) {
641
- o(J(r)), i(!1);
684
+ if (l) {
685
+ o(ne(l)), c(!1);
642
686
  return;
643
687
  }
644
688
  try {
645
- const { data: g } = await _.post(
689
+ const { data: g } = await oe.post(
646
690
  `${t.baseUrl}/auth/refresh-token`,
647
691
  {},
648
692
  { withCredentials: !0 }
649
693
  );
650
- s(g.accessToken), o(J(g.accessToken)), localStorage.setItem("authToken", g.accessToken);
694
+ n(g.accessToken), o(ne(g.accessToken)), localStorage.setItem("authToken", g.accessToken);
651
695
  } catch {
652
696
  } finally {
653
- i(!1);
697
+ c(!1);
654
698
  }
655
699
  })();
656
- }, [r, t.baseUrl]);
657
- async function C(h) {
658
- const { data: g } = await E.post("/auth/clients/login", h);
659
- s(g.accessToken), o(J(g.accessToken)), localStorage.setItem("authToken", g.accessToken), Ne(), l("/", { replace: !0 });
700
+ }, [l, t.baseUrl]);
701
+ async function k(x) {
702
+ const { data: g } = await m.post("/api/auth/login", x);
703
+ n(g.accessToken), o(ne(g.accessToken)), localStorage.setItem("authToken", g.accessToken), Le(), r("/", { replace: !0 });
660
704
  }
661
- const N = Y(
705
+ const N = J(
662
706
  () => ({
663
- isAuthenticated: !!r,
664
- accessToken: r,
665
- user: n,
666
- login: C,
667
- logout: b,
668
- api: E,
707
+ isAuthenticated: !!l,
708
+ accessToken: l,
709
+ user: s,
710
+ login: k,
711
+ logout: h,
712
+ api: m,
669
713
  setUser: o
670
714
  }),
671
- [r, n, E]
715
+ [l, s, m]
672
716
  );
673
- return /* @__PURE__ */ e.createElement(ne.Provider, { value: t }, /* @__PURE__ */ e.createElement(oe.Provider, { value: N }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(
674
- Z,
717
+ return /* @__PURE__ */ e.createElement(de.Provider, { value: t }, /* @__PURE__ */ e.createElement(ue.Provider, { value: N }, /* @__PURE__ */ e.createElement(Ie, null, /* @__PURE__ */ e.createElement(
718
+ B,
675
719
  {
676
720
  path: "login",
677
- element: r ? /* @__PURE__ */ e.createElement(O, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(Pe, { baseUrl: t.baseUrl, colors: t.colors })
721
+ element: l ? /* @__PURE__ */ e.createElement(K, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(Se, { baseUrl: t.baseUrl, colors: t.colors })
678
722
  }
679
723
  ), /* @__PURE__ */ e.createElement(
680
- Z,
724
+ B,
681
725
  {
682
726
  path: "signup",
683
- element: r ? /* @__PURE__ */ e.createElement(O, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(Ue, null)
727
+ element: l ? /* @__PURE__ */ e.createElement(K, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(je, null)
684
728
  }
685
- ), /* @__PURE__ */ e.createElement(
686
- Z,
729
+ ), /* @__PURE__ */ e.createElement(B, { path: "forgot-password", element: /* @__PURE__ */ e.createElement(Te, null) }), /* @__PURE__ */ e.createElement(B, { path: "reset-password", element: /* @__PURE__ */ e.createElement(Ue, null) }), /* @__PURE__ */ e.createElement(
730
+ B,
687
731
  {
688
732
  path: "oauth/google/callback",
689
- element: /* @__PURE__ */ e.createElement(re, null)
733
+ element: /* @__PURE__ */ e.createElement(me, null)
690
734
  }
691
735
  ), /* @__PURE__ */ e.createElement(
692
- Z,
736
+ B,
693
737
  {
694
738
  path: "/oauth/microsoft/callback",
695
- element: /* @__PURE__ */ e.createElement(re, null)
739
+ element: /* @__PURE__ */ e.createElement(me, null)
696
740
  }
697
741
  ), /* @__PURE__ */ e.createElement(
698
- Z,
742
+ B,
699
743
  {
700
744
  path: "*",
701
745
  element: /* @__PURE__ */ e.createElement(ze, null, a)
702
746
  }
703
- )), m && /* @__PURE__ */ e.createElement(Me, { onConfirm: b })));
747
+ )), u && /* @__PURE__ */ e.createElement(Ce, { onConfirm: h })));
704
748
  };
705
- function he(...t) {
706
- const { user: a } = z(), l = (a == null ? void 0 : a.roles) ?? [];
707
- return t.some((r) => l.includes(r));
749
+ function pe(...t) {
750
+ const { user: a } = T(), r = (a == null ? void 0 : a.roles) ?? [];
751
+ return t.some((l) => r.includes(l));
708
752
  }
709
753
  function Ze(t) {
710
- const { user: a } = z();
754
+ const { user: a } = T();
711
755
  return (a == null ? void 0 : a.modules.includes(t)) ?? !1;
712
756
  }
713
- function ee(...t) {
714
- const { user: a } = z(), l = (a == null ? void 0 : a.permissions) ?? [];
715
- return t.every((r) => l.includes(r));
757
+ function ie(...t) {
758
+ const { user: a } = T(), r = (a == null ? void 0 : a.permissions) ?? [];
759
+ return t.every((l) => r.includes(l));
716
760
  }
717
- const Fe = ({
761
+ const Ge = ({
718
762
  children: t,
719
763
  fallbackpermessions: a = [],
720
- anyPermessions: l = [],
721
- fallbackRoles: r = ["super-admin"],
722
- redirectTo: s = "/dashboard"
764
+ anyPermessions: r = [],
765
+ fallbackRoles: l = ["super-admin"],
766
+ redirectTo: n = "/dashboard"
723
767
  }) => {
724
- if (r.some((i) => he(i)))
768
+ if (l.some((c) => pe(c)))
725
769
  return /* @__PURE__ */ e.createElement(e.Fragment, null, t);
726
- const o = a.length === 0 || a.every((i) => ee(i)), c = l.length === 0 || l.some((i) => ee(i));
727
- return o && c ? /* @__PURE__ */ e.createElement(e.Fragment, null, t) : /* @__PURE__ */ e.createElement(O, { to: s, replace: !0 });
728
- }, xe = e.createContext({}), Ge = xe.Provider;
729
- function Ye(t, a) {
730
- var s, n, o;
731
- const r = (s = e.useContext(xe)[t]) == null ? void 0 : s[a];
732
- return r ? !!((n = r.perms) != null && n.some((c) => ee(c)) || (o = r.fallbackRoles) != null && o.some((c) => he(c))) : !1;
770
+ const o = a.length === 0 || a.every((c) => ie(c)), d = r.length === 0 || r.some((c) => ie(c));
771
+ return o && d ? /* @__PURE__ */ e.createElement(e.Fragment, null, t) : /* @__PURE__ */ e.createElement(K, { to: n, replace: !0 });
772
+ }, xe = e.createContext({}), Ye = xe.Provider;
773
+ function Oe(t, a) {
774
+ var n, s, o;
775
+ const l = (n = e.useContext(xe)[t]) == null ? void 0 : n[a];
776
+ return l ? !!((s = l.perms) != null && s.some((d) => ie(d)) || (o = l.fallbackRoles) != null && o.some((d) => pe(d))) : !1;
733
777
  }
734
- const Oe = () => {
735
- const { user: t, api: a, setUser: l } = z(), [r, s] = u((t == null ? void 0 : t.name) ?? ""), [n, o] = u((t == null ? void 0 : t.email) ?? ""), [c, i] = u(!1), [m, p] = u(!1), [b, E] = u({
778
+ const He = () => {
779
+ const { user: t, api: a, setUser: r } = T(), [l, n] = i((t == null ? void 0 : t.name) ?? ""), [s, o] = i((t == null ? void 0 : t.email) ?? ""), [d, c] = i(!1), [u, b] = i(!1), [h, m] = i({
736
780
  open: !1,
737
781
  type: "success",
738
782
  title: "",
739
783
  message: ""
740
- }), C = "+971 50 827 8229";
741
- R(() => {
742
- if (!b.open)
784
+ }), k = "+971 50 827 8229";
785
+ W(() => {
786
+ if (!h.open)
743
787
  return;
744
- const d = window.setTimeout(() => E((v) => ({ ...v, open: !1 })), 3e3);
745
- return () => window.clearTimeout(d);
746
- }, [b.open]), R(() => {
747
- let d = !1;
748
- async function v() {
788
+ const f = window.setTimeout(() => m((E) => ({ ...E, open: !1 })), 3e3);
789
+ return () => window.clearTimeout(f);
790
+ }, [h.open]), W(() => {
791
+ let f = !1;
792
+ async function E() {
749
793
  try {
750
- const { data: w } = await a.get("/auth/client/me");
751
- if (d)
794
+ const { data: p } = await a.get("/auth/client/me");
795
+ if (f)
752
796
  return;
753
- l(w), s((w == null ? void 0 : w.name) ?? ""), o((w == null ? void 0 : w.email) ?? "");
754
- } catch (w) {
755
- console.error("Failed to load profile details:", w);
797
+ r(p), n((p == null ? void 0 : p.name) ?? ""), o((p == null ? void 0 : p.email) ?? "");
798
+ } catch (p) {
799
+ console.error("Failed to load profile details:", p);
756
800
  }
757
801
  }
758
- return v(), () => {
759
- d = !0;
802
+ return E(), () => {
803
+ f = !0;
760
804
  };
761
- }, [a, l]);
762
- const N = Y(() => (r || (t == null ? void 0 : t.name) || (t == null ? void 0 : t.email) || "").trim(), [r, t == null ? void 0 : t.name, t == null ? void 0 : t.email]), h = Y(() => N.charAt(0).toUpperCase() || "?", [N]);
805
+ }, [a, r]);
806
+ const N = J(() => (l || (t == null ? void 0 : t.name) || (t == null ? void 0 : t.email) || "").trim(), [l, t == null ? void 0 : t.name, t == null ? void 0 : t.email]), x = J(() => N.charAt(0).toUpperCase() || "?", [N]);
763
807
  async function g() {
764
808
  if (t) {
765
- p(!0);
809
+ b(!0);
766
810
  try {
767
- await a.patch("/auth/client/me", { name: r }), l({ ...t, name: r }), i(!1), E({
811
+ await a.patch("/auth/client/me", { name: l }), r({ ...t, name: l }), c(!1), m({
768
812
  open: !0,
769
813
  type: "success",
770
814
  title: "Changes saved",
771
815
  message: "Your profile was updated successfully."
772
816
  });
773
- } catch (d) {
774
- console.error("Failed to update profile:", d), E({
817
+ } catch (f) {
818
+ console.error("Failed to update profile:", f), m({
775
819
  open: !0,
776
820
  type: "error",
777
821
  title: "Save failed",
778
822
  message: "Failed to save changes. Please try again."
779
823
  });
780
824
  } finally {
781
- p(!1);
825
+ b(!1);
782
826
  }
783
827
  }
784
828
  }
785
829
  if (!t)
786
830
  return /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "No user data available.");
787
- const I = b.type === "success";
788
- return /* @__PURE__ */ e.createElement("div", { className: "max-w-3xl mx-auto" }, b.open && /* @__PURE__ */ e.createElement(
831
+ const v = h.type === "success";
832
+ return /* @__PURE__ */ e.createElement("div", { className: "max-w-3xl mx-auto" }, h.open && /* @__PURE__ */ e.createElement(
789
833
  "div",
790
834
  {
791
835
  className: "fixed top-6 right-6 z-[999999] flex items-center gap-3 rounded-xl border bg-white px-4 py-3 shadow-lg",
792
836
  role: "status",
793
837
  "aria-live": "polite",
794
838
  style: {
795
- borderColor: I ? "#BBF7D0" : "#FECACA"
839
+ borderColor: v ? "#BBF7D0" : "#FECACA"
796
840
  }
797
841
  },
798
842
  /* @__PURE__ */ e.createElement(
@@ -800,10 +844,10 @@ const Oe = () => {
800
844
  {
801
845
  className: "flex h-9 w-9 items-center justify-center rounded-full",
802
846
  style: {
803
- backgroundColor: I ? "#ECFDF5" : "#FEF2F2"
847
+ backgroundColor: v ? "#ECFDF5" : "#FEF2F2"
804
848
  }
805
849
  },
806
- I ? /* @__PURE__ */ e.createElement(
850
+ v ? /* @__PURE__ */ e.createElement(
807
851
  "svg",
808
852
  {
809
853
  width: "18",
@@ -866,15 +910,15 @@ const Oe = () => {
866
910
  "span",
867
911
  {
868
912
  className: "text-sm font-semibold",
869
- style: { color: I ? "#15803D" : "#B91C1C" }
913
+ style: { color: v ? "#15803D" : "#B91C1C" }
870
914
  },
871
- b.title
872
- ), b.message && /* @__PURE__ */ e.createElement("span", { className: "text-xs text-gray-500" }, b.message)),
915
+ h.title
916
+ ), h.message && /* @__PURE__ */ e.createElement("span", { className: "text-xs text-gray-500" }, h.message)),
873
917
  /* @__PURE__ */ e.createElement(
874
918
  "button",
875
919
  {
876
920
  type: "button",
877
- onClick: () => E((d) => ({ ...d, open: !1 })),
921
+ onClick: () => m((f) => ({ ...f, open: !1 })),
878
922
  className: "ml-2 rounded-md px-2 py-1 text-gray-500 hover:bg-gray-100",
879
923
  "aria-label": "Close",
880
924
  title: "Close"
@@ -908,7 +952,7 @@ const Oe = () => {
908
952
  )
909
953
  )
910
954
  )
911
- ), /* @__PURE__ */ e.createElement("div", { className: "rounded-2xl border border-gray-200 bg-white shadow-sm" }, /* @__PURE__ */ e.createElement("div", { className: "px-6 pt-6 pb-4" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "h-16 w-16 rounded-full bg-blue-600 flex items-center justify-center text-white text-2xl font-semibold" }, h), /* @__PURE__ */ e.createElement(
955
+ ), /* @__PURE__ */ e.createElement("div", { className: "rounded-2xl border border-gray-200 bg-white shadow-sm" }, /* @__PURE__ */ e.createElement("div", { className: "px-6 pt-6 pb-4" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "h-16 w-16 rounded-full bg-blue-600 flex items-center justify-center text-white text-2xl font-semibold" }, x), /* @__PURE__ */ e.createElement(
912
956
  "button",
913
957
  {
914
958
  type: "button",
@@ -943,20 +987,20 @@ const Oe = () => {
943
987
  }
944
988
  )
945
989
  )
946
- )), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("h1", { className: "text-2xl font-semibold" }, "My Profile"), /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "Personal details"))), c ? /* @__PURE__ */ e.createElement(
990
+ )), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("h1", { className: "text-2xl font-semibold" }, "My Profile"), /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "Personal details"))), d ? /* @__PURE__ */ e.createElement(
947
991
  "button",
948
992
  {
949
993
  type: "button",
950
994
  onClick: g,
951
- disabled: m,
995
+ disabled: u,
952
996
  className: "rounded-full border border-blue-200 bg-blue-50 px-4 py-2 text-sm font-medium text-blue-700 hover:bg-blue-100 disabled:opacity-60"
953
997
  },
954
- m ? "Saving…" : "Save changes"
998
+ u ? "Saving…" : "Save changes"
955
999
  ) : /* @__PURE__ */ e.createElement(
956
1000
  "button",
957
1001
  {
958
1002
  type: "button",
959
- onClick: () => i(!0),
1003
+ onClick: () => c(!0),
960
1004
  title: "Edit profile",
961
1005
  className: "h-9 w-9 rounded-full border border-gray-200 bg-white shadow-sm flex items-center justify-center hover:bg-gray-50"
962
1006
  },
@@ -992,16 +1036,16 @@ const Oe = () => {
992
1036
  "input",
993
1037
  {
994
1038
  type: "text",
995
- value: r,
996
- disabled: !c || m,
997
- onChange: (d) => s(d.target.value),
998
- className: `w-full rounded-lg border px-3 py-2 text-sm outline-none ${c ? "border-gray-300 bg-white focus:border-blue-500 focus:ring-2 focus:ring-blue-100" : "border-gray-200 bg-gray-50 text-gray-700"}`
1039
+ value: l,
1040
+ disabled: !d || u,
1041
+ onChange: (f) => n(f.target.value),
1042
+ className: `w-full rounded-lg border px-3 py-2 text-sm outline-none ${d ? "border-gray-300 bg-white focus:border-blue-500 focus:ring-2 focus:ring-blue-100" : "border-gray-200 bg-gray-50 text-gray-700"}`
999
1043
  }
1000
1044
  )), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("label", { className: "block text-xs font-medium text-gray-500 mb-2" }, "Email ID"), /* @__PURE__ */ e.createElement(
1001
1045
  "input",
1002
1046
  {
1003
1047
  type: "email",
1004
- value: n,
1048
+ value: s,
1005
1049
  disabled: !0,
1006
1050
  className: "w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 cursor-not-allowed"
1007
1051
  }
@@ -1009,17 +1053,17 @@ const Oe = () => {
1009
1053
  "input",
1010
1054
  {
1011
1055
  type: "text",
1012
- value: C,
1056
+ value: k,
1013
1057
  disabled: !0,
1014
1058
  className: "w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 cursor-not-allowed"
1015
1059
  }
1016
- ))), c && /* @__PURE__ */ e.createElement(
1060
+ ))), d && /* @__PURE__ */ e.createElement(
1017
1061
  "button",
1018
1062
  {
1019
1063
  type: "button",
1020
- disabled: m,
1064
+ disabled: u,
1021
1065
  onClick: () => {
1022
- i(!1), s((t == null ? void 0 : t.name) ?? "");
1066
+ c(!1), n((t == null ? void 0 : t.name) ?? "");
1023
1067
  },
1024
1068
  className: "mt-6 text-sm font-medium text-gray-600 hover:text-gray-900"
1025
1069
  },
@@ -1028,13 +1072,13 @@ const Oe = () => {
1028
1072
  };
1029
1073
  export {
1030
1074
  We as AuthProvider,
1031
- Oe as ProfilePage,
1075
+ He as ProfilePage,
1032
1076
  xe as RbacContext,
1033
- Ge as RbacProvider,
1034
- Fe as RequirePermissions,
1035
- z as useAuthState,
1036
- ee as useCan,
1037
- Ye as useGrant,
1077
+ Ye as RbacProvider,
1078
+ Ge as RequirePermissions,
1079
+ T as useAuthState,
1080
+ ie as useCan,
1081
+ Oe as useGrant,
1038
1082
  Ze as useHasModule,
1039
- he as useHasRole
1083
+ pe as useHasRole
1040
1084
  };