@ciscode/ui-authentication-kit 1.0.5 → 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 ve, useContext as Me, useEffect as V, forwardRef as ie, createElement as ae, useState as m, useMemo as X } from "react";
3
- import le from "axios";
4
- import { jwtDecode as ke } from "jwt-decode";
5
- import Ie from "react-dom";
6
- import { useT as q } from "@ciscode/ui-translate-core";
7
- import { useNavigate as se, useLocation as oe, Routes as Le, Route as Y, Navigate as J } from "react-router";
8
- const me = e.createContext(null);
9
- function de() {
10
- const t = e.useContext(me);
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 ue = ve(null);
16
- function z() {
17
- const t = Me(ue);
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 te(t) {
23
- const a = ke(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 te(t) {
30
31
  tenantId: a.tenantId ?? ""
31
32
  };
32
33
  }
33
- let re = !1;
34
- function Ce() {
35
- re = !1;
34
+ let ce = !1;
35
+ function Le() {
36
+ ce = !1;
36
37
  }
37
- function je(t, a) {
38
+ function Pe(t, a) {
38
39
  t.defaults.withCredentials = !0;
39
40
  const r = `${a.baseUrl}${a.refreshEndpoint ?? "/auth/refresh-token"}`;
40
- t.interceptors.request.use((n) => {
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 l = !1, s = [];
45
+ let l = !1, n = [];
45
46
  return t.interceptors.response.use(
46
- (n) => n,
47
- async (n) => {
48
- var i;
49
- const o = n.config;
50
- if (((i = n.response) == null ? void 0 : i.status) !== 401 || !o || o._retry)
51
- return Promise.reject(n);
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);
52
53
  if (o._retry = !0, !l) {
53
54
  l = !0;
54
55
  try {
55
- const { data: c } = await le.post(r, {}, { withCredentials: !0 });
56
- return a.setAccessToken(c.accessToken), s.forEach((d) => d(c.accessToken)), s = [], t.request(o);
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);
57
58
  } catch (c) {
58
- return !!a.getAccessToken() && !re && (re = !0, a.logout()), s.forEach((p) => p(null)), s = [], Promise.reject(c);
59
+ return !!a.getAccessToken() && !ce && (ce = !0, a.logout()), n.forEach((b) => b(null)), n = [], Promise.reject(c);
59
60
  } finally {
60
61
  l = !1;
61
62
  }
62
63
  }
63
- return new Promise((c, d) => {
64
- s.push((p) => {
65
- if (!p)
66
- return d(n);
67
- (o.headers ?? (o.headers = {})).Authorization = `Bearer ${p}`, c(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 Se = ({ onConfirm: t }) => {
74
- const a = q("authLib");
75
- return V(() => {
76
- const { body: r } = document, l = r.style.overflow, s = r.style.pointerEvents;
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;
77
78
  return r.style.overflow = "hidden", r.style.pointerEvents = "none", () => {
78
- r.style.overflow = l, r.style.pointerEvents = s;
79
+ r.style.overflow = l, r.style.pointerEvents = n;
79
80
  };
80
- }, []), Ie.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
  {
@@ -97,25 +98,25 @@ const Se = ({ onConfirm: t }) => {
97
98
  type: a = "text",
98
99
  placeholder: r,
99
100
  color: l = "",
100
- value: s,
101
- onChange: n
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
117
  placeholder: r || void 0,
117
- value: s,
118
- onChange: (i) => n == null ? void 0 : n(i.target.value),
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
@@ -123,7 +124,7 @@ const Se = ({ onConfirm: t }) => {
123
124
  `
124
125
  }
125
126
  ));
126
- }, ge = ({ 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,130 +132,29 @@ const Se = ({ 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)), fe = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iLTMgMCAyNjIgMjYyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj48cGF0aCBkPSJNMjU1Ljg3OCAxMzMuNDUxYzAtMTAuNzM0LS44NzEtMTguNTY3LTIuNzU2LTI2LjY5SDEzMC41NXY0OC40NDhoNzEuOTQ3Yy0xLjQ1IDEyLjA0LTkuMjgzIDMwLjE3Mi0yNi42OSA0Mi4zNTZsLS4yNDQgMS42MjIgMzguNzU1IDMwLjAyMyAyLjY4NS4yNjhjMjQuNjU5LTIyLjc3NCAzOC44NzUtNTYuMjgyIDM4Ljg3NS05Ni4wMjciIGZpbGw9IiM0Mjg1RjQiLz48cGF0aCBkPSJNMTMwLjU1IDI2MS4xYzM1LjI0OCAwIDY0LjgzOS0xMS42MDUgODYuNDUzLTMxLjYyMmwtNDEuMTk2LTMxLjkxM2MtMTEuMDI0IDcuNjg4LTI1LjgyIDEzLjA1NS00NS4yNTcgMTMuMDU1LTM0LjUyMyAwLTYzLjgyNC0yMi43NzMtNzQuMjY5LTU0LjI1bC0xLjUzMS4xMy00MC4yOTggMzEuMTg3LS41MjcgMS40NjVDMzUuMzkzIDIzMS43OTggNzkuNDkgMjYxLjEgMTMwLjU1IDI2MS4xIiBmaWxsPSIjMzRBODUzIi8+PHBhdGggZD0iTTU2LjI4MSAxNTYuMzdjLTIuNzU2LTguMTIzLTQuMzUxLTE2LjgyNy00LjM1MS0yNS44MiAwLTguOTk0IDEuNTk1LTE3LjY5NyA0LjIwNi0yNS44MmwtLjA3My0xLjczTDE1LjI2IDcxLjMxMmwtMS4zMzUuNjM1QzUuMDc3IDg5LjY0NCAwIDEwOS41MTcgMCAxMzAuNTVzNS4wNzcgNDAuOTA1IDEzLjkyNSA1OC42MDJsNDIuMzU2LTMyLjc4MiIgZmlsbD0iI0ZCQkMwNSIvPjxwYXRoIGQ9Ik0xMzAuNTUgNTAuNDc5YzI0LjUxNCAwIDQxLjA1IDEwLjU4OSA1MC40NzkgMTkuNDM4bDM2Ljg0NC0zNS45NzRDMTk1LjI0NSAxMi45MSAxNjUuNzk4IDAgMTMwLjU1IDAgNzkuNDkgMCAzNS4zOTMgMjkuMzAxIDEzLjkyNSA3MS45NDdsNDIuMjExIDMyLjc4M2MxMC41OS0zMS40NzcgMzkuODkxLTU0LjI1MSA3NC40MTQtNTQuMjUxIiBmaWxsPSIjRUI0MzM1Ii8+PC9zdmc+", he = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE2IDE2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPjxwYXRoIGZpbGw9IiNGMzUzMjUiIGQ9Ik0xIDFoNi41djYuNUgxVjF6Ii8+PHBhdGggZmlsbD0iIzgxQkMwNiIgZD0iTTguNSAxSDE1djYuNUg4LjVWMXoiLz48cGF0aCBmaWxsPSIjMDVBNkYwIiBkPSJNMSA4LjVoNi41VjE1SDFWOC41eiIvPjxwYXRoIGZpbGw9IiNGRkJBMDgiIGQ9Ik04LjUgOC41SDE1VjE1SDguNVY4LjV6Ii8+PC9zdmc+";
135
- function O(t, a, r) {
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) {
136
137
  return t ? t.startsWith(`${a}-`) ? t : t.startsWith("#") ? `${t}` : r : r;
137
138
  }
138
- function xe(t, a) {
139
- const r = (a == null ? void 0 : a.bg) || "bg-sky-500", l = (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: O(t.bg ?? "", "bg", r),
142
- textClass: O(t.text ?? "", "text", l),
143
- borderClass: O(t.border ?? "", "border", s),
144
- fillClass: O(t.fill ?? "", "fill", n),
145
- strokeClass: O(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 Te = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), pe = (...t) => t.filter((a, r, l) => !!a && a.trim() !== "" && l.indexOf(a) === r).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 Pe = {
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 Ue = ie(
179
- ({
180
- color: t = "currentColor",
181
- size: a = 24,
182
- strokeWidth: r = 2,
183
- absoluteStrokeWidth: l,
184
- className: s = "",
185
- children: n,
186
- iconNode: o,
187
- ...i
188
- }, c) => ae(
189
- "svg",
190
- {
191
- ref: c,
192
- ...Pe,
193
- width: a,
194
- height: a,
195
- stroke: t,
196
- strokeWidth: l ? Number(r) * 24 / Number(a) : r,
197
- className: pe("lucide", s),
198
- ...i
199
- },
200
- [
201
- ...o.map(([d, p]) => ae(d, 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 be = (t, a) => {
213
- const r = ie(
214
- ({ className: l, ...s }, n) => ae(Ue, {
215
- ref: n,
216
- iconNode: a,
217
- className: pe(`lucide-${Te(t)}`, l),
218
- ...s
219
- })
220
- );
221
- return r.displayName = `${t}`, r;
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 ze = [
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
- ], De = be("TriangleAlert", ze);
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 Ae = [
247
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
248
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
249
- ], Be = be("X", Ae), we = ({
149
+ const le = ({
250
150
  message: t,
251
151
  dismissAfterMs: a = 4e3
252
152
  }) => {
253
- const r = q("authLib"), [l, s] = m(!1);
254
- return V(() => {
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
159
  }, [t, a]), !l || !t ? null : /* @__PURE__ */ e.createElement(
260
160
  "div",
@@ -270,12 +170,12 @@ const Ae = [
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(De, { 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),
178
+ onClick: () => n(!1),
279
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
@@ -283,64 +183,64 @@ const Ae = [
283
183
  focus-visible:ring focus-visible:ring-red-500/50
284
184
  `
285
185
  },
286
- /* @__PURE__ */ e.createElement(Be, { className: "h-4 w-4" })
186
+ /* @__PURE__ */ e.createElement(ke, { className: "h-4 w-4" })
287
187
  )
288
188
  );
289
- }, $e = () => {
290
- const t = q("authLib"), a = se(), r = oe(), {
189
+ }, Se = () => {
190
+ const t = Z("authLib"), a = q(), r = ee(), {
291
191
  brandName: l = t("brandName", { defaultValue: "MyBrand" }),
292
- colors: s = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
293
- logoUrl: n,
192
+ colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
193
+ logoUrl: s,
294
194
  oauthProviders: o = [],
295
- illustrationUrl: i = 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
198
  communityContent: c = {
299
199
  title: t("community.title"),
300
200
  description: t("community.description")
301
201
  },
302
- baseUrl: d
202
+ baseUrl: u
303
203
  // IMPORTANT: used for Google OAuth redirect
304
- } = de(), { login: p } = z(), [w, E] = m(""), [C, v] = m(""), [f, h] = m(!1), [M, g] = m(null), k = {
204
+ } = te(), { login: b } = T(), [h, m] = i(""), [k, N] = i(""), [x, g] = i(!1), [v, f] = i(null), E = {
305
205
  google: { icon: fe, label: t("social.google") },
306
206
  microsoft: { icon: he, label: t("social.microsoft") }
307
- }, b = o.filter((u) => u in k).map((u) => ({
308
- id: u,
309
- icon: k[u].icon,
310
- label: k[u].label
311
- })), { bgClass: j, textClass: N, borderClass: D } = xe(s), H = `${j} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
312
- async function A(u) {
313
- var S;
314
- if (u.preventDefault(), !f) {
315
- g(null), h(!0);
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: w, password: C });
318
- } catch (y) {
319
- ((S = y == null ? void 0 : y.response) == null ? void 0 : S.status) === 401 ? g(t("errors.invalidCredentials")) : g(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
- h(!1);
221
+ g(!1);
322
222
  }
323
223
  }
324
224
  }
325
- function _(u) {
326
- var y, B, I;
327
- if (!d) {
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 S = ((B = (y = r.state) == null ? void 0 : y.from) == null ? void 0 : B.pathname) || ((I = r.state) == null ? void 0 : I.from) || "/";
332
- if (sessionStorage.setItem("postLoginRedirect", S), u === "google") {
333
- const R = "/oauth/google/callback", F = `${window.location.origin}${R}`, T = new URL(`${d}/auth/google`);
334
- T.searchParams.set("redirect", F), window.location.href = T.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 (u === "microsoft") {
338
- const R = "/oauth/microsoft/callback", F = `${window.location.origin}${R}`, T = new URL(`${d}/auth/microsoft`);
339
- T.searchParams.set("redirect", F), window.location.href = T.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 K = /* @__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,11 +258,11 @@ const Ae = [
358
258
  }
359
259
  )
360
260
  );
361
- return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${H}` }, /* @__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 ${j}` }, /* @__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
  }
@@ -370,35 +270,35 @@ const Ae = [
370
270
  "img",
371
271
  {
372
272
  loading: "lazy",
373
- src: i,
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" }, 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 ${N} 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(
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: N
290
+ className: M
391
291
  },
392
292
  t("SignInPage.signUp")
393
- ))), M && /* @__PURE__ */ e.createElement(we, { message: M }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: A }, /* @__PURE__ */ e.createElement(
293
+ ))), v && /* @__PURE__ */ e.createElement(le, { message: v }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: L }, /* @__PURE__ */ e.createElement(
394
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: w,
401
- onChange: E
299
+ color: U,
300
+ value: h,
301
+ onChange: m
402
302
  }
403
303
  ), /* @__PURE__ */ e.createElement(
404
304
  P,
@@ -406,98 +306,98 @@ const Ae = [
406
306
  label: t("form.passwordLabel"),
407
307
  type: "password",
408
308
  placeholder: t("form.passwordPlaceholder"),
409
- color: D,
410
- value: C,
411
- onChange: v
309
+ color: U,
310
+ value: k,
311
+ onChange: N
412
312
  }
413
- ), /* @__PURE__ */ e.createElement("div", { className: "ltr:text-right rtl:text-left" }, /* @__PURE__ */ e.createElement("button", { className: `text-sm ${N}` }, 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: f,
418
- className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${f ? "opacity-60 cursor-not-allowed" : ""} ${j} 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
- f && K,
421
- t(f ? "SignInPage.signInSubmitting" : "SignInPage.signIn")
422
- ), b.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 ${j}` }), /* @__PURE__ */ e.createElement("span", { className: `${N} mx-3 text-sm` }, t("SignInPage.orLoginWith")), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${j}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, b.map((u) => /* @__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: u.id,
325
+ key: w.id,
426
326
  type: "button",
427
- onClick: () => _(u.id),
327
+ onClick: () => D(w.id),
428
328
  className: "flex-1"
429
329
  },
430
- /* @__PURE__ */ e.createElement(ge, { icon: u.icon, label: u.label })
330
+ /* @__PURE__ */ e.createElement(ge, { icon: w.icon, label: w.label })
431
331
  ))))))));
432
- }, Ve = () => {
433
- const t = q("authLib"), a = se(), r = oe(), {
332
+ }, je = () => {
333
+ const t = Z("authLib"), a = q(), r = ee(), {
434
334
  brandName: l = t("brandName", { defaultValue: "MyBrand" }),
435
- colors: s = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
436
- logoUrl: n,
335
+ colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
336
+ logoUrl: s,
437
337
  oauthProviders: o = [],
438
- illustrationUrl: i = 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
341
  communityContent: c = {
442
342
  title: t("community.title"),
443
343
  description: t("community.description")
444
344
  },
445
- baseUrl: d
345
+ baseUrl: u
446
346
  // IMPORTANT: used for OAuth redirect (same as SignIn)
447
- } = de(), { login: p, api: w } = z(), [E, C] = m(""), [v, f] = m(""), [h, M] = m(""), [g, k] = m(""), [b, j] = m(""), [N, D] = m(!1), [H, A] = m(null), [_, K] = m(!1), u = {
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 = {
448
348
  google: { icon: fe, label: t("social.google") },
449
349
  microsoft: { icon: he, label: t("social.microsoft") }
450
- }, S = o.filter((x) => x in u).map((x) => ({
451
- id: x,
452
- icon: u[x].icon,
453
- label: u[x].label
454
- })), { bgClass: y, textClass: B, borderClass: I } = xe(s), R = `${y} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
455
- async function F(x) {
456
- var Q, W, Z;
457
- if (x.preventDefault(), !N) {
458
- A(null), D(!0);
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 w.post("/api/auth/register", {
461
- fullname: { fname: E, lname: v },
462
- username: h,
463
- email: g,
464
- password: b
465
- }), await p({ email: g, password: b });
466
- } catch (L) {
467
- const $ = (Q = L == null ? void 0 : L.response) == null ? void 0 : Q.status;
468
- A(
469
- $ === 400 ? ((Z = (W = L == null ? void 0 : L.response) == null ? void 0 : W.data) == null ? void 0 : Z.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", {
470
370
  defaultValue: "Please check the fields and try again."
471
- }) : $ === 409 ? t("errors.emailInUse", {
371
+ }) : F === 409 ? t("errors.emailInUse", {
472
372
  defaultValue: "This email is already in use."
473
373
  }) : t("errors.generic", {
474
374
  defaultValue: "Something went wrong. Please try again."
475
375
  })
476
376
  );
477
377
  } finally {
478
- D(!1);
378
+ U(!1);
479
379
  }
480
380
  }
481
381
  }
482
- function T(x) {
483
- var W, Z, L;
484
- if (!d) {
382
+ function V(y) {
383
+ var O, H, j;
384
+ if (!u) {
485
385
  console.error("Auth baseUrl is not configured.");
486
386
  return;
487
387
  }
488
- const Q = ((Z = (W = r.state) == null ? void 0 : W.from) == null ? void 0 : Z.pathname) || ((L = r.state) == null ? void 0 : L.from) || "/";
489
- if (sessionStorage.setItem("postLoginRedirect", Q), x === "google") {
490
- const $ = "/oauth/google/callback", ee = `${window.location.origin}${$}`, G = new URL(`${d}/auth/google`);
491
- G.searchParams.set("redirect", ee), window.location.href = G.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();
492
392
  return;
493
393
  }
494
- if (x === "microsoft") {
495
- const $ = "/oauth/microsoft/callback", ee = `${window.location.origin}${$}`, G = new URL(`${d}/auth/microsoft`);
496
- G.searchParams.set("redirect", ee), window.location.href = G.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();
497
397
  return;
498
398
  }
499
399
  }
500
- const Ne = /* @__PURE__ */ e.createElement(
400
+ const be = /* @__PURE__ */ e.createElement(
501
401
  "svg",
502
402
  {
503
403
  className: "h-4 w-4 animate-spin stroke-current",
@@ -515,11 +415,11 @@ const Ae = [
515
415
  }
516
416
  )
517
417
  );
518
- return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${R}` }, /* @__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 ${y}` }, /* @__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(
519
419
  "img",
520
420
  {
521
421
  loading: "lazy",
522
- src: n,
422
+ src: s,
523
423
  alt: "Brand Logo",
524
424
  className: "bg-white h-8 md:h-22 rounded-lg"
525
425
  }
@@ -527,37 +427,37 @@ const Ae = [
527
427
  "img",
528
428
  {
529
429
  loading: "lazy",
530
- src: i,
430
+ src: d,
531
431
  alt: "Sign up illustration",
532
432
  className: "max-w-sm w-full mx-auto rounded-lg shadow-lg transform hover:scale-105 transition-transform duration-300 p-6"
533
433
  }
534
- )))), /* @__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(
535
435
  "img",
536
436
  {
537
437
  loading: "lazy",
538
- src: n,
438
+ src: s,
539
439
  alt: "Brand Logo",
540
- className: `h-22 rounded-full border ${I}`
440
+ className: `h-22 rounded-full border ${S}`
541
441
  }
542
- ) : /* @__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 ${B} 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", {
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", {
543
443
  defaultValue: "Already have an account?"
544
444
  }), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
545
445
  "button",
546
446
  {
547
447
  type: "button",
548
448
  onClick: () => a("/login"),
549
- className: B
449
+ className: $
550
450
  },
551
451
  t("SignUpPage.signIn", { defaultValue: "Sign in" })
552
- ))), H && /* @__PURE__ */ e.createElement(we, { message: H }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: F }, /* @__PURE__ */ e.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ e.createElement(
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(
553
453
  P,
554
454
  {
555
455
  label: t("form.fnameLabel", { defaultValue: "First Name" }),
556
456
  type: "text",
557
457
  placeholder: t("form.fnamePlaceholder", { defaultValue: "Enter your first name" }),
558
- color: I,
559
- value: E,
560
- onChange: C
458
+ color: S,
459
+ value: m,
460
+ onChange: k
561
461
  }
562
462
  ), /* @__PURE__ */ e.createElement(
563
463
  P,
@@ -565,9 +465,9 @@ const Ae = [
565
465
  label: t("form.lnameLabel", { defaultValue: "Last Name" }),
566
466
  type: "text",
567
467
  placeholder: t("form.lnamePlaceholder", { defaultValue: "Enter your last name" }),
568
- color: I,
569
- value: v,
570
- onChange: f
468
+ color: S,
469
+ value: N,
470
+ onChange: x
571
471
  }
572
472
  )), /* @__PURE__ */ e.createElement(
573
473
  P,
@@ -575,9 +475,9 @@ const Ae = [
575
475
  label: t("form.usernameLabel", { defaultValue: "Username" }),
576
476
  type: "text",
577
477
  placeholder: t("form.usernamePlaceholder", { defaultValue: "Choose a username" }),
578
- color: I,
579
- value: h,
580
- onChange: M
478
+ color: S,
479
+ value: g,
480
+ onChange: v
581
481
  }
582
482
  ), /* @__PURE__ */ e.createElement(
583
483
  P,
@@ -585,9 +485,9 @@ const Ae = [
585
485
  label: t("form.emailLabel"),
586
486
  type: "email",
587
487
  placeholder: t("form.emailPlaceholder"),
588
- color: I,
589
- value: g,
590
- onChange: k
488
+ color: S,
489
+ value: f,
490
+ onChange: E
591
491
  }
592
492
  ), /* @__PURE__ */ e.createElement(
593
493
  P,
@@ -595,232 +495,348 @@ const Ae = [
595
495
  label: t("form.passwordLabel"),
596
496
  type: "password",
597
497
  placeholder: t("form.passwordPlaceholder"),
598
- color: I,
599
- value: b,
600
- onChange: j
498
+ color: S,
499
+ value: p,
500
+ onChange: C
601
501
  }
602
502
  ), /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ e.createElement(
603
503
  "input",
604
504
  {
605
505
  id: "agree",
606
506
  type: "checkbox",
607
- checked: _,
608
- onChange: (x) => K(x.target.checked),
507
+ checked: D,
508
+ onChange: (y) => re(y.target.checked),
609
509
  className: "form-checkbox"
610
510
  }
611
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(
612
512
  "button",
613
513
  {
614
514
  type: "submit",
615
- disabled: N,
616
- className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${N ? "opacity-60 cursor-not-allowed" : ""} ${y} 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`
617
517
  },
618
- N && Ne,
619
- N ? t("SignUpPage.signUpSubmitting", {
518
+ M && be,
519
+ M ? t("SignUpPage.signUpSubmitting", {
620
520
  defaultValue: "Creating account..."
621
521
  }) : t("SignUpPage.signUp", { defaultValue: "Sign up" })
622
- ), S.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 ${y}` }), /* @__PURE__ */ e.createElement("span", { className: `${B} 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", {
623
523
  defaultValue: "Or continue with"
624
- })), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${y}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, S.map((x) => /* @__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(
625
525
  "button",
626
526
  {
627
- key: x.id,
527
+ key: y.id,
628
528
  type: "button",
629
- onClick: () => T(x.id),
529
+ onClick: () => V(y.id),
630
530
  className: "flex-1"
631
531
  },
632
- /* @__PURE__ */ e.createElement(ge, { icon: x.icon, label: x.label })
532
+ /* @__PURE__ */ e.createElement(ge, { icon: y.icon, label: y.label })
633
533
  ))))))));
634
- }, ce = () => (V(() => {
534
+ }, me = () => (W(() => {
635
535
  const t = new URLSearchParams(window.location.search), a = t.get("accessToken"), r = t.get("refreshToken");
636
536
  a && localStorage.setItem("authToken", a), r && localStorage.setItem("refreshToken", r);
637
537
  const l = sessionStorage.getItem("postLoginRedirect") || "/";
638
538
  sessionStorage.removeItem("postLoginRedirect"), window.location.replace(l);
639
- }, []), /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center min-h-screen text-gray-700" }, "Finishing Google sign-in…")), Re = ({ children: t }) => {
640
- const { isAuthenticated: a } = z(), r = oe();
641
- return a ? t : /* @__PURE__ */ e.createElement(J, { to: "/login", state: { from: r }, replace: !0 });
642
- }, He = ({ config: t, children: a }) => {
643
- const r = se(), [l, s] = m(
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 });
658
+ }, We = ({ config: t, children: a }) => {
659
+ const r = q(), [l, n] = i(
644
660
  () => localStorage.getItem("authToken")
645
- ), [n, o] = m(null), [i, c] = m(!0), [d, p] = m(!1);
646
- async function w() {
661
+ ), [s, o] = i(null), [d, c] = i(!0), [u, b] = i(!1);
662
+ async function h() {
647
663
  try {
648
- await E.post("/auth/logout");
649
- } catch (f) {
650
- console.warn("Logout endpoint failed, proceeding with local logout:", f);
664
+ await m.post("/auth/logout");
665
+ } catch (x) {
666
+ console.warn("Logout endpoint failed, proceeding with local logout:", x);
651
667
  }
652
- s(null), o(null), localStorage.removeItem("authToken"), sessionStorage.clear(), p(!1), r("/login", { replace: !0 });
668
+ n(null), o(null), localStorage.removeItem("authToken"), sessionStorage.clear(), b(!1), r("/login", { replace: !0 });
653
669
  }
654
- const E = X(() => {
655
- const f = le.create({
670
+ const m = J(() => {
671
+ const x = oe.create({
656
672
  baseURL: t.baseUrl,
657
673
  withCredentials: !0
658
674
  });
659
- return je(f, {
675
+ return Pe(x, {
660
676
  baseUrl: t.baseUrl,
661
677
  getAccessToken: () => l,
662
- setAccessToken: (h) => s(h),
663
- logout: () => p(!0)
664
- }), f;
678
+ setAccessToken: (g) => n(g),
679
+ logout: () => b(!0)
680
+ }), x;
665
681
  }, [t.baseUrl, l]);
666
- V(() => {
682
+ W(() => {
667
683
  (async () => {
668
684
  if (l) {
669
- o(te(l)), c(!1);
685
+ o(ne(l)), c(!1);
670
686
  return;
671
687
  }
672
688
  try {
673
- const { data: h } = await le.post(
689
+ const { data: g } = await oe.post(
674
690
  `${t.baseUrl}/auth/refresh-token`,
675
691
  {},
676
692
  { withCredentials: !0 }
677
693
  );
678
- s(h.accessToken), o(te(h.accessToken)), localStorage.setItem("authToken", h.accessToken);
694
+ n(g.accessToken), o(ne(g.accessToken)), localStorage.setItem("authToken", g.accessToken);
679
695
  } catch {
680
696
  } finally {
681
697
  c(!1);
682
698
  }
683
699
  })();
684
700
  }, [l, t.baseUrl]);
685
- async function C(f) {
686
- const { data: h } = await E.post("/api/auth/login", f);
687
- s(h.accessToken), o(te(h.accessToken)), localStorage.setItem("authToken", h.accessToken), Ce(), r("/", { replace: !0 });
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 });
688
704
  }
689
- const v = X(
705
+ const N = J(
690
706
  () => ({
691
707
  isAuthenticated: !!l,
692
708
  accessToken: l,
693
- user: n,
694
- login: C,
695
- logout: w,
696
- api: E,
709
+ user: s,
710
+ login: k,
711
+ logout: h,
712
+ api: m,
697
713
  setUser: o
698
714
  }),
699
- [l, n, E]
715
+ [l, s, m]
700
716
  );
701
- return /* @__PURE__ */ e.createElement(me.Provider, { value: t }, /* @__PURE__ */ e.createElement(ue.Provider, { value: v }, /* @__PURE__ */ e.createElement(Le, null, /* @__PURE__ */ e.createElement(
702
- Y,
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,
703
719
  {
704
720
  path: "login",
705
- element: l ? /* @__PURE__ */ e.createElement(J, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement($e, { 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 })
706
722
  }
707
723
  ), /* @__PURE__ */ e.createElement(
708
- Y,
724
+ B,
709
725
  {
710
726
  path: "signup",
711
- element: l ? /* @__PURE__ */ e.createElement(J, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(Ve, null)
727
+ element: l ? /* @__PURE__ */ e.createElement(K, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(je, null)
712
728
  }
713
- ), /* @__PURE__ */ e.createElement(
714
- Y,
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,
715
731
  {
716
732
  path: "oauth/google/callback",
717
- element: /* @__PURE__ */ e.createElement(ce, null)
733
+ element: /* @__PURE__ */ e.createElement(me, null)
718
734
  }
719
735
  ), /* @__PURE__ */ e.createElement(
720
- Y,
736
+ B,
721
737
  {
722
738
  path: "/oauth/microsoft/callback",
723
- element: /* @__PURE__ */ e.createElement(ce, null)
739
+ element: /* @__PURE__ */ e.createElement(me, null)
724
740
  }
725
741
  ), /* @__PURE__ */ e.createElement(
726
- Y,
742
+ B,
727
743
  {
728
744
  path: "*",
729
- element: /* @__PURE__ */ e.createElement(Re, null, a)
745
+ element: /* @__PURE__ */ e.createElement(ze, null, a)
730
746
  }
731
- )), d && /* @__PURE__ */ e.createElement(Se, { onConfirm: w })));
747
+ )), u && /* @__PURE__ */ e.createElement(Ce, { onConfirm: h })));
732
748
  };
733
- function Ee(...t) {
734
- const { user: a } = z(), r = (a == null ? void 0 : a.roles) ?? [];
749
+ function pe(...t) {
750
+ const { user: a } = T(), r = (a == null ? void 0 : a.roles) ?? [];
735
751
  return t.some((l) => r.includes(l));
736
752
  }
737
- function Qe(t) {
738
- const { user: a } = z();
753
+ function Ze(t) {
754
+ const { user: a } = T();
739
755
  return (a == null ? void 0 : a.modules.includes(t)) ?? !1;
740
756
  }
741
- function ne(...t) {
742
- const { user: a } = z(), r = (a == null ? void 0 : a.permissions) ?? [];
757
+ function ie(...t) {
758
+ const { user: a } = T(), r = (a == null ? void 0 : a.permissions) ?? [];
743
759
  return t.every((l) => r.includes(l));
744
760
  }
745
- const Xe = ({
761
+ const Ge = ({
746
762
  children: t,
747
763
  fallbackpermessions: a = [],
748
764
  anyPermessions: r = [],
749
765
  fallbackRoles: l = ["super-admin"],
750
- redirectTo: s = "/dashboard"
766
+ redirectTo: n = "/dashboard"
751
767
  }) => {
752
- if (l.some((c) => Ee(c)))
768
+ if (l.some((c) => pe(c)))
753
769
  return /* @__PURE__ */ e.createElement(e.Fragment, null, t);
754
- const o = a.length === 0 || a.every((c) => ne(c)), i = r.length === 0 || r.some((c) => ne(c));
755
- return o && i ? /* @__PURE__ */ e.createElement(e.Fragment, null, t) : /* @__PURE__ */ e.createElement(J, { to: s, replace: !0 });
756
- }, ye = e.createContext({}), Je = ye.Provider;
757
- function qe(t, a) {
758
- var s, n, o;
759
- const l = (s = e.useContext(ye)[t]) == null ? void 0 : s[a];
760
- return l ? !!((n = l.perms) != null && n.some((i) => ne(i)) || (o = l.fallbackRoles) != null && o.some((i) => Ee(i))) : !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;
761
777
  }
762
- const _e = () => {
763
- const { user: t, api: a, setUser: r } = z(), [l, s] = m((t == null ? void 0 : t.name) ?? ""), [n, o] = m((t == null ? void 0 : t.email) ?? ""), [i, c] = m(!1), [d, p] = m(!1), [w, E] = m({
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({
764
780
  open: !1,
765
781
  type: "success",
766
782
  title: "",
767
783
  message: ""
768
- }), C = "+971 50 827 8229";
769
- V(() => {
770
- if (!w.open)
784
+ }), k = "+971 50 827 8229";
785
+ W(() => {
786
+ if (!h.open)
771
787
  return;
772
- const g = window.setTimeout(() => E((k) => ({ ...k, open: !1 })), 3e3);
773
- return () => window.clearTimeout(g);
774
- }, [w.open]), V(() => {
775
- let g = !1;
776
- async function k() {
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() {
777
793
  try {
778
- const { data: b } = await a.get("/auth/client/me");
779
- if (g)
794
+ const { data: p } = await a.get("/auth/client/me");
795
+ if (f)
780
796
  return;
781
- r(b), s((b == null ? void 0 : b.name) ?? ""), o((b == null ? void 0 : b.email) ?? "");
782
- } catch (b) {
783
- console.error("Failed to load profile details:", b);
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);
784
800
  }
785
801
  }
786
- return k(), () => {
787
- g = !0;
802
+ return E(), () => {
803
+ f = !0;
788
804
  };
789
805
  }, [a, r]);
790
- const v = X(() => (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]), f = X(() => v.charAt(0).toUpperCase() || "?", [v]);
791
- async function h() {
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]);
807
+ async function g() {
792
808
  if (t) {
793
- p(!0);
809
+ b(!0);
794
810
  try {
795
- await a.patch("/auth/client/me", { name: l }), r({ ...t, name: l }), c(!1), E({
811
+ await a.patch("/auth/client/me", { name: l }), r({ ...t, name: l }), c(!1), m({
796
812
  open: !0,
797
813
  type: "success",
798
814
  title: "Changes saved",
799
815
  message: "Your profile was updated successfully."
800
816
  });
801
- } catch (g) {
802
- console.error("Failed to update profile:", g), E({
817
+ } catch (f) {
818
+ console.error("Failed to update profile:", f), m({
803
819
  open: !0,
804
820
  type: "error",
805
821
  title: "Save failed",
806
822
  message: "Failed to save changes. Please try again."
807
823
  });
808
824
  } finally {
809
- p(!1);
825
+ b(!1);
810
826
  }
811
827
  }
812
828
  }
813
829
  if (!t)
814
830
  return /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "No user data available.");
815
- const M = w.type === "success";
816
- return /* @__PURE__ */ e.createElement("div", { className: "max-w-3xl mx-auto" }, w.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(
817
833
  "div",
818
834
  {
819
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",
820
836
  role: "status",
821
837
  "aria-live": "polite",
822
838
  style: {
823
- borderColor: M ? "#BBF7D0" : "#FECACA"
839
+ borderColor: v ? "#BBF7D0" : "#FECACA"
824
840
  }
825
841
  },
826
842
  /* @__PURE__ */ e.createElement(
@@ -828,10 +844,10 @@ const _e = () => {
828
844
  {
829
845
  className: "flex h-9 w-9 items-center justify-center rounded-full",
830
846
  style: {
831
- backgroundColor: M ? "#ECFDF5" : "#FEF2F2"
847
+ backgroundColor: v ? "#ECFDF5" : "#FEF2F2"
832
848
  }
833
849
  },
834
- M ? /* @__PURE__ */ e.createElement(
850
+ v ? /* @__PURE__ */ e.createElement(
835
851
  "svg",
836
852
  {
837
853
  width: "18",
@@ -894,15 +910,15 @@ const _e = () => {
894
910
  "span",
895
911
  {
896
912
  className: "text-sm font-semibold",
897
- style: { color: M ? "#15803D" : "#B91C1C" }
913
+ style: { color: v ? "#15803D" : "#B91C1C" }
898
914
  },
899
- w.title
900
- ), w.message && /* @__PURE__ */ e.createElement("span", { className: "text-xs text-gray-500" }, w.message)),
915
+ h.title
916
+ ), h.message && /* @__PURE__ */ e.createElement("span", { className: "text-xs text-gray-500" }, h.message)),
901
917
  /* @__PURE__ */ e.createElement(
902
918
  "button",
903
919
  {
904
920
  type: "button",
905
- onClick: () => E((g) => ({ ...g, open: !1 })),
921
+ onClick: () => m((f) => ({ ...f, open: !1 })),
906
922
  className: "ml-2 rounded-md px-2 py-1 text-gray-500 hover:bg-gray-100",
907
923
  "aria-label": "Close",
908
924
  title: "Close"
@@ -936,7 +952,7 @@ const _e = () => {
936
952
  )
937
953
  )
938
954
  )
939
- ), /* @__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" }, f), /* @__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(
940
956
  "button",
941
957
  {
942
958
  type: "button",
@@ -971,15 +987,15 @@ const _e = () => {
971
987
  }
972
988
  )
973
989
  )
974
- )), /* @__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"))), i ? /* @__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(
975
991
  "button",
976
992
  {
977
993
  type: "button",
978
- onClick: h,
979
- disabled: d,
994
+ onClick: g,
995
+ disabled: u,
980
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"
981
997
  },
982
- d ? "Saving…" : "Save changes"
998
+ u ? "Saving…" : "Save changes"
983
999
  ) : /* @__PURE__ */ e.createElement(
984
1000
  "button",
985
1001
  {
@@ -1021,15 +1037,15 @@ const _e = () => {
1021
1037
  {
1022
1038
  type: "text",
1023
1039
  value: l,
1024
- disabled: !i || d,
1025
- onChange: (g) => s(g.target.value),
1026
- className: `w-full rounded-lg border px-3 py-2 text-sm outline-none ${i ? "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"}`
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"}`
1027
1043
  }
1028
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(
1029
1045
  "input",
1030
1046
  {
1031
1047
  type: "email",
1032
- value: n,
1048
+ value: s,
1033
1049
  disabled: !0,
1034
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"
1035
1051
  }
@@ -1037,17 +1053,17 @@ const _e = () => {
1037
1053
  "input",
1038
1054
  {
1039
1055
  type: "text",
1040
- value: C,
1056
+ value: k,
1041
1057
  disabled: !0,
1042
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"
1043
1059
  }
1044
- ))), i && /* @__PURE__ */ e.createElement(
1060
+ ))), d && /* @__PURE__ */ e.createElement(
1045
1061
  "button",
1046
1062
  {
1047
1063
  type: "button",
1048
- disabled: d,
1064
+ disabled: u,
1049
1065
  onClick: () => {
1050
- c(!1), s((t == null ? void 0 : t.name) ?? "");
1066
+ c(!1), n((t == null ? void 0 : t.name) ?? "");
1051
1067
  },
1052
1068
  className: "mt-6 text-sm font-medium text-gray-600 hover:text-gray-900"
1053
1069
  },
@@ -1055,14 +1071,14 @@ const _e = () => {
1055
1071
  ))));
1056
1072
  };
1057
1073
  export {
1058
- He as AuthProvider,
1059
- _e as ProfilePage,
1060
- ye as RbacContext,
1061
- Je as RbacProvider,
1062
- Xe as RequirePermissions,
1063
- z as useAuthState,
1064
- ne as useCan,
1065
- qe as useGrant,
1066
- Qe as useHasModule,
1067
- Ee as useHasRole
1074
+ We as AuthProvider,
1075
+ He as ProfilePage,
1076
+ xe as RbacContext,
1077
+ Ye as RbacProvider,
1078
+ Ge as RequirePermissions,
1079
+ T as useAuthState,
1080
+ ie as useCan,
1081
+ Oe as useGrant,
1082
+ Ze as useHasModule,
1083
+ pe as useHasRole
1068
1084
  };