@neuctra/authix 1.1.27 → 1.1.28

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.
@@ -61,7 +61,7 @@ function Mt(t, e) {
61
61
  return a;
62
62
  return null;
63
63
  }
64
- const fe = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Wt = (t) => !ye(t) && t !== fe;
64
+ const xe = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Wt = (t) => !ye(t) && t !== xe;
65
65
  function Ze() {
66
66
  const { caseless: t, skipUndefined: e } = Wt(this) && this || {}, r = {}, s = (a, i) => {
67
67
  const o = t && Mt(r, i) || i;
@@ -170,14 +170,14 @@ const Yr = (t) => {
170
170
  return s;
171
171
  };
172
172
  return r(t, 0);
173
- }, Kr = oe("AsyncFunction"), Jr = (t) => t && (Te(t) || re(t)) && re(t.then) && re(t.catch), Bt = ((t, e) => t ? setImmediate : e ? ((r, s) => (fe.addEventListener("message", ({ source: a, data: i }) => {
174
- a === fe && i === r && s.length && s.shift()();
173
+ }, Kr = oe("AsyncFunction"), Jr = (t) => t && (Te(t) || re(t)) && re(t.then) && re(t.catch), Bt = ((t, e) => t ? setImmediate : e ? ((r, s) => (xe.addEventListener("message", ({ source: a, data: i }) => {
174
+ a === xe && i === r && s.length && s.shift()();
175
175
  }, !1), (a) => {
176
- s.push(a), fe.postMessage(r, "*");
176
+ s.push(a), xe.postMessage(r, "*");
177
177
  }))(`axios@${Math.random()}`, []) : (r) => setTimeout(r))(
178
178
  typeof setImmediate == "function",
179
- re(fe.postMessage)
180
- ), Xr = typeof queueMicrotask < "u" ? queueMicrotask.bind(fe) : typeof process < "u" && process.nextTick || Bt, Gr = (t) => t != null && re(t[Fe]), p = {
179
+ re(xe.postMessage)
180
+ ), Xr = typeof queueMicrotask < "u" ? queueMicrotask.bind(xe) : typeof process < "u" && process.nextTick || Bt, Gr = (t) => t != null && re(t[Fe]), p = {
181
181
  isArray: we,
182
182
  isArrayBuffer: Lt,
183
183
  isBuffer: Ce,
@@ -227,7 +227,7 @@ const Yr = (t) => {
227
227
  noop: Br,
228
228
  toFiniteNumber: Hr,
229
229
  findKey: Mt,
230
- global: fe,
230
+ global: xe,
231
231
  isContextDefined: Wt,
232
232
  isSpecCompliantForm: Vr,
233
233
  toJSONObject: Yr,
@@ -935,7 +935,7 @@ function er(t, e, r) {
935
935
  return t && (s || r == !1) ? Tn(t, e) : e;
936
936
  }
937
937
  const vt = (t) => t instanceof ne ? { ...t } : t;
938
- function he(t, e) {
938
+ function ge(t, e) {
939
939
  e = e || {};
940
940
  const r = {};
941
941
  function s(c, d, b, y) {
@@ -1000,7 +1000,7 @@ function he(t, e) {
1000
1000
  }), r;
1001
1001
  }
1002
1002
  const tr = (t) => {
1003
- const e = he({}, t);
1003
+ const e = ge({}, t);
1004
1004
  let { data: r, withXSRFToken: s, xsrfHeaderName: a, xsrfCookieName: i, headers: o, auth: l } = e;
1005
1005
  if (e.headers = o = ne.from(o), e.url = Jt(er(e.baseURL, e.url, e.allowAbsoluteUrls), t.params, t.paramsSerializer), l && o.set(
1006
1006
  "Authorization",
@@ -1433,7 +1433,7 @@ const $e = {
1433
1433
  assertOptions: Dn,
1434
1434
  validators: Be
1435
1435
  }, ie = $e.validators;
1436
- let xe = class {
1436
+ let he = class {
1437
1437
  constructor(e) {
1438
1438
  this.defaults = e || {}, this.interceptors = {
1439
1439
  request: new yt(),
@@ -1466,7 +1466,7 @@ let xe = class {
1466
1466
  }
1467
1467
  }
1468
1468
  _request(e, r) {
1469
- typeof e == "string" ? (r = r || {}, r.url = e) : r = e || {}, r = he(this.defaults, r);
1469
+ typeof e == "string" ? (r = r || {}, r.url = e) : r = e || {}, r = ge(this.defaults, r);
1470
1470
  const { transitional: s, paramsSerializer: a, headers: i } = r;
1471
1471
  s !== void 0 && $e.assertOptions(s, {
1472
1472
  silentJSONParsing: ie.transitional(ie.boolean),
@@ -1528,14 +1528,14 @@ let xe = class {
1528
1528
  return d;
1529
1529
  }
1530
1530
  getUri(e) {
1531
- e = he(this.defaults, e);
1531
+ e = ge(this.defaults, e);
1532
1532
  const r = er(e.baseURL, e.url, e.allowAbsoluteUrls);
1533
1533
  return Jt(r, e.params, e.paramsSerializer);
1534
1534
  }
1535
1535
  };
1536
1536
  p.forEach(["delete", "get", "head", "options"], function(e) {
1537
- xe.prototype[e] = function(r, s) {
1538
- return this.request(he(s || {}, {
1537
+ he.prototype[e] = function(r, s) {
1538
+ return this.request(ge(s || {}, {
1539
1539
  method: e,
1540
1540
  url: r,
1541
1541
  data: (s || {}).data
@@ -1545,7 +1545,7 @@ p.forEach(["delete", "get", "head", "options"], function(e) {
1545
1545
  p.forEach(["post", "put", "patch"], function(e) {
1546
1546
  function r(s) {
1547
1547
  return function(i, o, l) {
1548
- return this.request(he(l || {}, {
1548
+ return this.request(ge(l || {}, {
1549
1549
  method: e,
1550
1550
  headers: s ? {
1551
1551
  "Content-Type": "multipart/form-data"
@@ -1555,7 +1555,7 @@ p.forEach(["post", "put", "patch"], function(e) {
1555
1555
  }));
1556
1556
  };
1557
1557
  }
1558
- xe.prototype[e] = r(), xe.prototype[e + "Form"] = r(!0);
1558
+ he.prototype[e] = r(), he.prototype[e + "Form"] = r(!0);
1559
1559
  });
1560
1560
  let Ln = class ar {
1561
1561
  constructor(e) {
@@ -1707,13 +1707,13 @@ Object.entries(rt).forEach(([t, e]) => {
1707
1707
  rt[e] = t;
1708
1708
  });
1709
1709
  function or(t) {
1710
- const e = new xe(t), r = Ut(xe.prototype.request, e);
1711
- return p.extend(r, xe.prototype, e, { allOwnKeys: !0 }), p.extend(r, e, null, { allOwnKeys: !0 }), r.create = function(a) {
1712
- return or(he(t, a));
1710
+ const e = new he(t), r = Ut(he.prototype.request, e);
1711
+ return p.extend(r, he.prototype, e, { allOwnKeys: !0 }), p.extend(r, e, null, { allOwnKeys: !0 }), r.create = function(a) {
1712
+ return or(ge(t, a));
1713
1713
  }, r;
1714
1714
  }
1715
1715
  const W = or(Ie);
1716
- W.Axios = xe;
1716
+ W.Axios = he;
1717
1717
  W.CanceledError = je;
1718
1718
  W.CancelToken = Ln;
1719
1719
  W.isCancel = Zt;
@@ -1726,7 +1726,7 @@ W.all = function(e) {
1726
1726
  };
1727
1727
  W.spread = Fn;
1728
1728
  W.isAxiosError = Mn;
1729
- W.mergeConfig = he;
1729
+ W.mergeConfig = ge;
1730
1730
  W.AxiosHeaders = ne;
1731
1731
  W.formToJSON = (t) => Gt(p.isHTMLForm(t) ? new FormData(t) : t);
1732
1732
  W.getAdapter = nr.getAdapter;
@@ -2233,8 +2233,8 @@ React keys must be passed directly to JSX without using spread:
2233
2233
  }
2234
2234
  if (Y = null, x !== void 0 && (r(x), Y = "" + x), o(S) && (r(S.key), Y = "" + S.key), "key" in S) {
2235
2235
  x = {};
2236
- for (var ue in S)
2237
- ue !== "key" && (x[ue] = S[ue]);
2236
+ for (var pe in S)
2237
+ pe !== "key" && (x[pe] = S[pe]);
2238
2238
  } else x = S;
2239
2239
  return Y && l(
2240
2240
  x,
@@ -2854,7 +2854,7 @@ const Ls = [
2854
2854
  if (!t.baseUrl || !t.apiKey || !t.appId)
2855
2855
  throw new Error("baseUrl, apiKey, and appId are required");
2856
2856
  Ue.baseUrl = t.baseUrl, Ue.apiKey = t.apiKey, Ue.appId = t.appId;
2857
- }, ge = () => Ue, pa = ({
2857
+ }, ue = () => Ue, pa = ({
2858
2858
  logoUrl: t,
2859
2859
  logoLinkUrl: e,
2860
2860
  title: r = "Create Your Account",
@@ -2873,7 +2873,7 @@ const Ls = [
2873
2873
  onSuccess: y,
2874
2874
  onError: w
2875
2875
  }) => {
2876
- const { baseUrl: u, apiKey: j, appId: m } = ge(), _ = {
2876
+ const { baseUrl: u, apiKey: j, appId: m } = ue(), _ = {
2877
2877
  name: "",
2878
2878
  email: "",
2879
2879
  password: "",
@@ -3509,7 +3509,7 @@ const Ls = [
3509
3509
  onSuccess: c,
3510
3510
  onError: d
3511
3511
  }) => {
3512
- const { baseUrl: b, apiKey: y, appId: w } = ge(), [u, j] = O("login"), [m, _] = O(1), [R, A] = O(!1), [C, M] = O(!1), [g, I] = O(null), [v, U] = O(""), [q, F] = O(""), [V, Z] = O({
3512
+ const { baseUrl: b, apiKey: y, appId: w } = ue(), [u, j] = O("login"), [m, _] = O(1), [R, A] = O(!1), [C, M] = O(!1), [g, I] = O(null), [v, U] = O(""), [q, F] = O(""), [V, Z] = O({
3513
3513
  email: "",
3514
3514
  otp: "",
3515
3515
  newPassword: "",
@@ -4087,10 +4087,9 @@ const Ls = [
4087
4087
  fallback: e = null,
4088
4088
  className: r,
4089
4089
  width: s,
4090
- height: a,
4091
- appId: i
4090
+ height: a
4092
4091
  }) => {
4093
- const [o, l] = O(!1), [h, c] = O(!0);
4092
+ const { appId: i } = ue(), [o, l] = O(!1), [h, c] = O(!0);
4094
4093
  return te(() => {
4095
4094
  let d = !1;
4096
4095
  const b = async () => {
@@ -4191,7 +4190,7 @@ const Ls = [
4191
4190
  token: i,
4192
4191
  colors: o
4193
4192
  }) => {
4194
- const { baseUrl: l, apiKey: h, appId: c } = ge(), [d, b] = O(!1), [y, w] = O(""), [u, j] = O("warning"), [m, _] = O(!1);
4193
+ const { baseUrl: l, apiKey: h, appId: c } = ue(), [d, b] = O(!1), [y, w] = O(""), [u, j] = O("warning"), [m, _] = O(!1);
4195
4194
  if (te(() => {
4196
4195
  if (typeof window > "u") return;
4197
4196
  const g = () => {
@@ -5497,7 +5496,7 @@ const Ls = [
5497
5496
  userId: a,
5498
5497
  colors: i
5499
5498
  }) => {
5500
- const { baseUrl: o, apiKey: l, appId: h } = ge(), [c, d] = O({
5499
+ const { baseUrl: o, apiKey: l, appId: h } = ue(), [c, d] = O({
5501
5500
  currentPassword: "",
5502
5501
  newPassword: "",
5503
5502
  confirmPassword: ""
@@ -6226,7 +6225,7 @@ const Ls = [
6226
6225
  onVerify: i,
6227
6226
  primaryColor: o = "#00C212"
6228
6227
  }) => {
6229
- const { baseUrl: l, apiKey: h, appId: c } = ge(), [d, b] = O(null), [y, w] = O(e), [u, j] = O(!0), [m, _] = O(!1), [R, A] = O(!1), [C, M] = O(!1), [g, I] = O(!1), [v, U] = O(!1), [q, F] = O(!1), [V, Z] = O(!1), [T, J] = O(!1), [z, P] = O(null), [K, Q] = O(!1), [X, f] = O({
6228
+ const { baseUrl: l, apiKey: h, appId: c } = ue(), [d, b] = O(null), [y, w] = O(e), [u, j] = O(!0), [m, _] = O(!1), [R, A] = O(!1), [C, M] = O(!1), [g, I] = O(!1), [v, U] = O(!1), [q, F] = O(!1), [V, Z] = O(!1), [T, J] = O(!1), [z, P] = O(null), [K, Q] = O(!1), [X, f] = O({
6230
6229
  email: "",
6231
6230
  otp: "",
6232
6231
  appId: c
@@ -6275,7 +6274,7 @@ const Ls = [
6275
6274
  } finally {
6276
6275
  $(!1);
6277
6276
  }
6278
- }, ue = async (E) => {
6277
+ }, pe = async (E) => {
6279
6278
  if (E.preventDefault(), !X.email || !X.otp) {
6280
6279
  N("error", "Please fill in all fields");
6281
6280
  return;
@@ -6367,8 +6366,8 @@ const Ls = [
6367
6366
  y?.email && f((E) => ({ ...E, email: y.email }));
6368
6367
  }, [y?.email]);
6369
6368
  const ft = (E, H) => {
6370
- let G = parseInt(E.replace("#", ""), 16), pe = (G >> 16) + H, He = (G >> 8 & 255) + H, Ve = (G & 255) + H;
6371
- return pe = Math.min(255, Math.max(0, pe)), He = Math.min(255, Math.max(0, He)), Ve = Math.min(255, Math.max(0, Ve)), `#${(Ve | He << 8 | pe << 16).toString(16).padStart(6, "0")}`;
6369
+ let G = parseInt(E.replace("#", ""), 16), fe = (G >> 16) + H, He = (G >> 8 & 255) + H, Ve = (G & 255) + H;
6370
+ return fe = Math.min(255, Math.max(0, fe)), He = Math.min(255, Math.max(0, He)), Ve = Math.min(255, Math.max(0, Ve)), `#${(Ve | He << 8 | fe << 16).toString(16).padStart(6, "0")}`;
6372
6371
  }, D = r ? {
6373
6372
  background: "#000000",
6374
6373
  surface: "#09090b",
@@ -7104,7 +7103,7 @@ const Ls = [
7104
7103
  name: E.name,
7105
7104
  value: y[E.name],
7106
7105
  onChange: (G) => w(
7107
- (pe) => pe && { ...pe, [G.target.name]: G.target.value }
7106
+ (fe) => fe && { ...fe, [G.target.name]: G.target.value }
7108
7107
  ),
7109
7108
  style: {
7110
7109
  padding: "12px",
@@ -7327,7 +7326,7 @@ const Ls = [
7327
7326
  onClose: () => {
7328
7327
  F(!1), x(!1), f({ email: y?.email || "", otp: "", appId: c });
7329
7328
  },
7330
- onVerify: ue,
7329
+ onVerify: pe,
7331
7330
  onSendOTP: se,
7332
7331
  verifyFormData: X,
7333
7332
  setVerifyFormData: f,
@@ -7450,7 +7449,7 @@ const Ls = [
7450
7449
  viewProfileLabel: w = "View Profile",
7451
7450
  logoutLabel: u = "Sign Out"
7452
7451
  }) => {
7453
- const { baseUrl: j, apiKey: m, appId: _ } = ge(), [R, A] = O(!1), [C, M] = O(null), [g, I] = O(!0), [v, U] = O(null), q = xt(null), F = xt(null), [V, Z] = O(!1), [T, J] = O(!1);
7452
+ const { baseUrl: j, apiKey: m, appId: _ } = ue(), [R, A] = O(!1), [C, M] = O(null), [g, I] = O(!0), [v, U] = O(null), q = xt(null), F = xt(null), [V, Z] = O(!1), [T, J] = O(!1);
7454
7453
  te(() => {
7455
7454
  if (typeof window > "u") return;
7456
7455
  const x = () => {
@@ -7486,9 +7485,9 @@ const Ls = [
7486
7485
  if (typeof window > "u") return;
7487
7486
  const x = () => {
7488
7487
  if (!R || !F.current) return;
7489
- const k = F.current.getBoundingClientRect(), $ = window.innerWidth, N = window.innerHeight, Y = 280, se = $ - k.right, ue = k.left;
7488
+ const k = F.current.getBoundingClientRect(), $ = window.innerWidth, N = window.innerHeight, Y = 280, se = $ - k.right, pe = k.left;
7490
7489
  N - k.bottom;
7491
- const ve = se >= Y || se > ue;
7490
+ const ve = se >= Y || se > pe;
7492
7491
  Z(ve);
7493
7492
  };
7494
7493
  return x(), window.addEventListener("resize", x), () => window.removeEventListener("resize", x);
@@ -8013,7 +8012,7 @@ const Ls = [
8013
8012
  primaryColor: r = "#00C212",
8014
8013
  onVerify: s
8015
8014
  }) => {
8016
- const { appId: a, baseUrl: i, apiKey: o } = ge(), [l, h] = O({
8015
+ const { appId: a, baseUrl: i, apiKey: o } = ue(), [l, h] = O({
8017
8016
  email: t?.email || "",
8018
8017
  otp: "",
8019
8018
  appId: a
@@ -8235,6 +8234,6 @@ export {
8235
8234
  fa as ReactUserLogin,
8236
8235
  ga as ReactUserProfile,
8237
8236
  pa as ReactUserSignUp,
8238
- ge as getSdkConfig,
8237
+ ue as getSdkConfig,
8239
8238
  ua as setSdkConfig
8240
8239
  };
@@ -139,7 +139,7 @@ React keys must be passed directly to JSX without using spread:
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const ce=B("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
142
+ */const ue=B("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
143
143
  * @license lucide-react v0.544.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
@@ -199,12 +199,12 @@ React keys must be passed directly to JSX without using spread:
199
199
  *
200
200
  * This source code is licensed under the ISC license.
201
201
  * See the LICENSE file in the root directory of this source tree.
202
- */const Pe=B("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),qe={baseUrl:"",apiKey:"",appId:""},Zn=t=>{if(!t.baseUrl||!t.apiKey||!t.appId)throw new Error("baseUrl, apiKey, and appId are required");qe.baseUrl=t.baseUrl,qe.apiKey=t.apiKey,qe.appId=t.appId},ue=()=>qe,Qn=({logoUrl:t,logoLinkUrl:e,title:r="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:h=!1,roles:d=[],showRoleSelector:c=!1,loginUrl:b,onSuccess:y,onError:S})=>{const{baseUrl:u,apiKey:j,appId:m}=ue(),A={name:"",email:"",password:"",role:d.length?d[0]:"user",...h&&{avatarUrl:""}},[P,_]=w.useState(A),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(null),[q,F]=w.useState({}),[V,Z]=w.useState(!1),I=l?"#ffffff":"#111827",J=l?"#a1a1aa":"#6b7280",z=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",R=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const k=()=>Z(window.innerWidth<768);return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)}},[]);const K=k=>{const{name:x,value:E}=k.target;_($=>({...$,[x]:E})),q[x]&&F($=>({...$,[x]:void 0}))},te=()=>{const k={};return P.name.trim()||(k.name="Name is required"),P.email.trim()?/\S+@\S+\.\S+/.test(P.email)||(k.email="Invalid email address"):k.email="Email is required",P.password?P.password.length<6&&(k.password="Password must be at least 6 characters"):k.password="Password is required",F(k),Object.keys(k).length===0},X=async k=>{if(k.preventDefault(),!!te()){O(!0),U(null);try{const x={...P,appId:m},E=await An(x,{baseUrl:u,apiKey:j});U({type:"success",text:"Account created successfully!"}),y&&y(E)}catch(x){const E=x.message||"Signup failed. Please try again.";U({type:"error",text:E}),S&&S(x)}finally{O(!1)}}},f={width:"100%",padding:V?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:z,border:`1px solid ${R}`,borderRadius:"10px",color:I,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"};return n.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[n.jsxs("div",{style:{minWidth:V?"320px":"380px",width:"100%",maxWidth:V?"340px":"390px",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:V?"30px 24px":"20px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:I,margin:0},children:r}),n.jsx("p",{style:{fontSize:"14px",color:J},children:s})]}),h&&P.avatarUrl&&n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:n.jsx("img",{src:P.avatarUrl,alt:"Avatar Preview",style:{width:"60px",height:"60px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${a}30`},onError:k=>{const x=k.target;x.style.display="none"}})}),n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[c&&d&&d.length===2&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{style:{fontSize:"14px",fontWeight:500,color:I},children:"Select Role"}),n.jsxs("div",{style:{position:"relative",display:"flex",borderRadius:"10px",border:`1px solid ${R}`,backgroundColor:z,overflow:"hidden",cursor:"pointer",height:"42px"},children:[n.jsx("div",{style:{position:"absolute",top:0,left:0,width:"50%",height:"100%",backgroundColor:l?"#000000":"#ffffff",boxShadow:l?"0 1px 3px rgba(255,255,255,0.05)":"0 1px 3px rgba(0,0,0,0.1)",borderRadius:"10px",transition:"transform 0.3s ease, background-color 0.3s ease",transform:P.role===d[1]?"translateX(100%)":"translateX(0)",zIndex:0}}),n.jsx("button",{type:"button",onClick:()=>_(k=>({...k,role:d[0]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[0]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[0]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[0].charAt(0).toUpperCase()+d[0].slice(1)}),n.jsx("button",{type:"button",onClick:()=>_(k=>({...k,role:d[1]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[1]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[1]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[1].charAt(0).toUpperCase()+d[1].slice(1)})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-name",style:{fontSize:"14px",fontWeight:500,color:I},children:"Full Name"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-name",type:"text",name:"name",placeholder:"Enter your full name",value:P.name,onChange:K,style:{...f,borderColor:q.name?"#ef4444":R}})]}),q.name&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.name})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-email",style:{fontSize:"14px",fontWeight:500,color:I},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-email",type:"email",name:"email",placeholder:"Enter your email address",value:P.email,onChange:K,style:{...f,borderColor:q.email?"#ef4444":R}})]}),q.email&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.email})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-password",style:{fontSize:"14px",fontWeight:500,color:I},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-password",type:T?"text":"password",name:"password",placeholder:"Create a secure password",value:P.password,onChange:K,style:{...f,borderColor:q.password?"#ef4444":R}}),n.jsx("button",{type:"button",onClick:()=>M(!T),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:J,cursor:"pointer",padding:"4px"},children:T?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]}),q.password&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.password})]}),h&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-avatar",style:{fontSize:"14px",fontWeight:500,color:I},children:"Avatar URL (Optional)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(er,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-avatar",type:"url",name:"avatarUrl",placeholder:"Paste your avatar image URL",value:P.avatarUrl||"",onChange:K,style:f})]})]}),b&&n.jsx("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:n.jsx("a",{href:b,style:{color:a,textDecoration:"none",fontWeight:500},children:"Already have an account?"})}),v&&n.jsxs("div",{style:{padding:"12px",borderRadius:"12px",fontSize:"12px",display:"flex",alignItems:"start",gap:"10px",backgroundColor:v.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:v.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:v.type==="success"?a:"#ef4444"},children:[v.type==="success"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:v.text})]}),n.jsx("button",{type:"submit",disabled:g,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600,cursor:g?"not-allowed":"pointer",opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:g?n.jsxs(n.Fragment,{children:[n.jsx(Hn,{size:18,style:{animation:"spin 1s linear infinite"}}),"Creating Account..."]}):"Create Account"})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:J,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]}),n.jsx("style",{children:`
202
+ */const Pe=B("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),qe={baseUrl:"",apiKey:"",appId:""},Zn=t=>{if(!t.baseUrl||!t.apiKey||!t.appId)throw new Error("baseUrl, apiKey, and appId are required");qe.baseUrl=t.baseUrl,qe.apiKey=t.apiKey,qe.appId=t.appId},ce=()=>qe,Qn=({logoUrl:t,logoLinkUrl:e,title:r="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:h=!1,roles:d=[],showRoleSelector:c=!1,loginUrl:b,onSuccess:y,onError:S})=>{const{baseUrl:u,apiKey:j,appId:m}=ce(),A={name:"",email:"",password:"",role:d.length?d[0]:"user",...h&&{avatarUrl:""}},[P,_]=w.useState(A),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(null),[q,F]=w.useState({}),[V,Z]=w.useState(!1),I=l?"#ffffff":"#111827",J=l?"#a1a1aa":"#6b7280",z=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",R=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const k=()=>Z(window.innerWidth<768);return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)}},[]);const K=k=>{const{name:x,value:E}=k.target;_($=>({...$,[x]:E})),q[x]&&F($=>({...$,[x]:void 0}))},te=()=>{const k={};return P.name.trim()||(k.name="Name is required"),P.email.trim()?/\S+@\S+\.\S+/.test(P.email)||(k.email="Invalid email address"):k.email="Email is required",P.password?P.password.length<6&&(k.password="Password must be at least 6 characters"):k.password="Password is required",F(k),Object.keys(k).length===0},X=async k=>{if(k.preventDefault(),!!te()){O(!0),U(null);try{const x={...P,appId:m},E=await An(x,{baseUrl:u,apiKey:j});U({type:"success",text:"Account created successfully!"}),y&&y(E)}catch(x){const E=x.message||"Signup failed. Please try again.";U({type:"error",text:E}),S&&S(x)}finally{O(!1)}}},f={width:"100%",padding:V?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:z,border:`1px solid ${R}`,borderRadius:"10px",color:I,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"};return n.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[n.jsxs("div",{style:{minWidth:V?"320px":"380px",width:"100%",maxWidth:V?"340px":"390px",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:V?"30px 24px":"20px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:I,margin:0},children:r}),n.jsx("p",{style:{fontSize:"14px",color:J},children:s})]}),h&&P.avatarUrl&&n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:n.jsx("img",{src:P.avatarUrl,alt:"Avatar Preview",style:{width:"60px",height:"60px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${a}30`},onError:k=>{const x=k.target;x.style.display="none"}})}),n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[c&&d&&d.length===2&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{style:{fontSize:"14px",fontWeight:500,color:I},children:"Select Role"}),n.jsxs("div",{style:{position:"relative",display:"flex",borderRadius:"10px",border:`1px solid ${R}`,backgroundColor:z,overflow:"hidden",cursor:"pointer",height:"42px"},children:[n.jsx("div",{style:{position:"absolute",top:0,left:0,width:"50%",height:"100%",backgroundColor:l?"#000000":"#ffffff",boxShadow:l?"0 1px 3px rgba(255,255,255,0.05)":"0 1px 3px rgba(0,0,0,0.1)",borderRadius:"10px",transition:"transform 0.3s ease, background-color 0.3s ease",transform:P.role===d[1]?"translateX(100%)":"translateX(0)",zIndex:0}}),n.jsx("button",{type:"button",onClick:()=>_(k=>({...k,role:d[0]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[0]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[0]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[0].charAt(0).toUpperCase()+d[0].slice(1)}),n.jsx("button",{type:"button",onClick:()=>_(k=>({...k,role:d[1]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[1]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[1]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[1].charAt(0).toUpperCase()+d[1].slice(1)})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-name",style:{fontSize:"14px",fontWeight:500,color:I},children:"Full Name"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-name",type:"text",name:"name",placeholder:"Enter your full name",value:P.name,onChange:K,style:{...f,borderColor:q.name?"#ef4444":R}})]}),q.name&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.name})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-email",style:{fontSize:"14px",fontWeight:500,color:I},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ue,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-email",type:"email",name:"email",placeholder:"Enter your email address",value:P.email,onChange:K,style:{...f,borderColor:q.email?"#ef4444":R}})]}),q.email&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.email})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-password",style:{fontSize:"14px",fontWeight:500,color:I},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-password",type:T?"text":"password",name:"password",placeholder:"Create a secure password",value:P.password,onChange:K,style:{...f,borderColor:q.password?"#ef4444":R}}),n.jsx("button",{type:"button",onClick:()=>M(!T),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:J,cursor:"pointer",padding:"4px"},children:T?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]}),q.password&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.password})]}),h&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-avatar",style:{fontSize:"14px",fontWeight:500,color:I},children:"Avatar URL (Optional)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(er,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-avatar",type:"url",name:"avatarUrl",placeholder:"Paste your avatar image URL",value:P.avatarUrl||"",onChange:K,style:f})]})]}),b&&n.jsx("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:n.jsx("a",{href:b,style:{color:a,textDecoration:"none",fontWeight:500},children:"Already have an account?"})}),v&&n.jsxs("div",{style:{padding:"12px",borderRadius:"12px",fontSize:"12px",display:"flex",alignItems:"start",gap:"10px",backgroundColor:v.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:v.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:v.type==="success"?a:"#ef4444"},children:[v.type==="success"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:v.text})]}),n.jsx("button",{type:"submit",disabled:g,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600,cursor:g?"not-allowed":"pointer",opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:g?n.jsxs(n.Fragment,{children:[n.jsx(Hn,{size:18,style:{animation:"spin 1s linear infinite"}}),"Creating Account..."]}):"Create Account"})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:J,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]}),n.jsx("style",{children:`
203
203
  @keyframes spin {
204
204
  from { transform: rotate(0deg); }
205
205
  to { transform: rotate(360deg); }
206
206
  }
207
- `})]})},es=async(t,e)=>{const{email:r,password:s,appId:o}=t,{baseUrl:a,apiKey:i}=e;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:r,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":i}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},ts=({logoUrl:t,logoLinkUrl:e,title:r="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:h,onSuccess:d,onError:c})=>{const{baseUrl:b,apiKey:y,appId:S}=ue(),[u,j]=w.useState("login"),[m,A]=w.useState(1),[P,_]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(null),[v,U]=w.useState(""),[q,F]=w.useState(""),[V,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,J]=w.useState(!1),z=l?"#ffffff":"#111827",R=l?"#a1a1aa":"#6b7280",K=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",te=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const $=()=>J(window.innerWidth<768);return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}},[]);const X=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await es({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${N.name}`}),d?.(N)}catch(N){const Y=N.message||"Login failed";O({type:"error",text:Y}),c?.(N)}finally{M(!1)}},f=$=>{Z({...V,[$.target.name]:$.target.value})},k=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/forgot-password`,{email:V.email,appId:S},{headers:{"x-api-key":y}});N.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:N.data.message||"Failed to send OTP"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},x=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/reset-password`,V,{headers:{"x-api-key":y}});N.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:N.data.message||"Reset failed"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},E={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:K,border:`1px solid ${te}`,borderRadius:"10px",color:z,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.jsxs("div",{style:{minWidth:I?"320px":"380px",maxWidth:I?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:I?"30px 24px":"18px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:z,margin:0},children:u==="login"?r:m===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:R},children:u==="login"?s:"Follow the steps to reset your password"})]}),u==="login"&&n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:$=>U($.target.value),style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:$=>F($.target.value),style:E}),n.jsx("button",{type:"button",onClick:()=>_(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:R,cursor:"pointer"},children:P?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),u==="forgot"&&n.jsxs("form",{onSubmit:m===1?k:x,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:V.email,onChange:f,style:E})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(tr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:V.otp,onChange:f,style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:V.newPassword,onChange:f,style:E})]})]})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":m===1?"Send Reset OTP":"Reset Password"}),n.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:R,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&n.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:g.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:g.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:g.type==="success"?a:"#ef4444"},children:[g.type==="success"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:g.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:R,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},rs=({children:t,fallback:e=null,className:r,width:s,height:o,appId:a})=>{const[i,l]=w.useState(!1),[h,d]=w.useState(!0);return w.useEffect(()=>{let c=!1;const b=async()=>{try{const S=localStorage.getItem("userInfo");if(!S||S==="undefined"||S==="null"){l(!1);return}const u=JSON.parse(S);if(!u?.id){l(!1);return}const j=await fetch(`https://server.authix.neuctra.com/api/users/check-user/${u.id}?appId=${a}`,{credentials:"include"});if(!j.ok){l(!1);return}const m=await j.json();c||l(!!m?.exists)}catch{c||l(!1)}finally{c||d(!1)}};b();const y=()=>b();return window.addEventListener("storage",y),()=>{c=!0,window.removeEventListener("storage",y)}},[a]),h?null:i?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ns=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const[a,i]=w.useState(()=>{if(typeof window>"u")return!0;try{const l=localStorage.getItem("userInfo");return!l||l==="undefined"||l==="null"}catch{return!0}});return w.useEffect(()=>{const l=()=>{try{const h=localStorage.getItem("userInfo");i(!h||h==="undefined"||h==="null")}catch{i(!0)}};return l(),window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]),a?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ss=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:h,appId:d}=ue(),[c,b]=w.useState(!1),[y,S]=w.useState(""),[u,j]=w.useState("warning"),[m,A]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const g=()=>{A(window.innerWidth<640)};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),!t)return null;const P=async()=>{b(!0),j("processing");try{const{data:g}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:d},headers:{"x-api-key":h}});g.success?(r(g.message||"Account deleted successfully"),j("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(g.message||"Failed to delete account"),j("warning"))}catch(g){s(g.response?.data?.message||"Something went wrong"),j("warning")}finally{b(!1)}},_=y.toLowerCase()==="delete my account",T=g=>{g.target===g.currentTarget&&u!=="processing"&&u!=="success"&&e()},M=()=>{switch(u){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:e,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:i.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.color=i.textPrimary},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.color=i.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(nr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Gn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),n.jsx("span",{children:g.text})]},O))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:e,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),n.jsxs("button",{onClick:()=>j("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:g=>{g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(nr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.jsx("input",{type:"text",value:y,onChange:g=>S(g.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${_?i.success:i.error}`,backgroundColor:"transparent",color:i.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:g=>{g.target.style.boxShadow=`0 0 0 3px ${i.accent}20`},onBlur:g=>{g.target.style.boxShadow="none"},autoFocus:!0}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:()=>{j("warning"),S("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),n.jsxs("button",{onClick:P,disabled:!_||c,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!_||c?"not-allowed":"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",opacity:!_||c?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!_||c?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.active?`${i.accent}10`:"transparent"},children:[n.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:g.active?i.accent:i.textTertiary,transition:"all 0.3s ease",boxShadow:g.active?`0 0 0 4px ${i.accent}20`:"none"}}),n.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx(rr,{size:18,style:{color:i.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.jsx("p",{style:{color:i.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary,justifyContent:"center"},children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[n.jsx("div",{style:{backgroundColor:i.surface,border:`1px solid ${i.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:M()}),n.jsx("style",{children:`
207
+ `})]})},es=async(t,e)=>{const{email:r,password:s,appId:o}=t,{baseUrl:a,apiKey:i}=e;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:r,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":i}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},ts=({logoUrl:t,logoLinkUrl:e,title:r="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:h,onSuccess:d,onError:c})=>{const{baseUrl:b,apiKey:y,appId:S}=ce(),[u,j]=w.useState("login"),[m,A]=w.useState(1),[P,_]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(null),[v,U]=w.useState(""),[q,F]=w.useState(""),[V,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,J]=w.useState(!1),z=l?"#ffffff":"#111827",R=l?"#a1a1aa":"#6b7280",K=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",te=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const $=()=>J(window.innerWidth<768);return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}},[]);const X=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await es({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${N.name}`}),d?.(N)}catch(N){const Y=N.message||"Login failed";O({type:"error",text:Y}),c?.(N)}finally{M(!1)}},f=$=>{Z({...V,[$.target.name]:$.target.value})},k=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/forgot-password`,{email:V.email,appId:S},{headers:{"x-api-key":y}});N.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:N.data.message||"Failed to send OTP"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},x=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/reset-password`,V,{headers:{"x-api-key":y}});N.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:N.data.message||"Reset failed"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},E={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:K,border:`1px solid ${te}`,borderRadius:"10px",color:z,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.jsxs("div",{style:{minWidth:I?"320px":"380px",maxWidth:I?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:I?"30px 24px":"18px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:z,margin:0},children:u==="login"?r:m===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:R},children:u==="login"?s:"Follow the steps to reset your password"})]}),u==="login"&&n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ue,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:$=>U($.target.value),style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:$=>F($.target.value),style:E}),n.jsx("button",{type:"button",onClick:()=>_(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:R,cursor:"pointer"},children:P?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),u==="forgot"&&n.jsxs("form",{onSubmit:m===1?k:x,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ue,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:V.email,onChange:f,style:E})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(tr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:V.otp,onChange:f,style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:V.newPassword,onChange:f,style:E})]})]})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":m===1?"Send Reset OTP":"Reset Password"}),n.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:R,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&n.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:g.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:g.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:g.type==="success"?a:"#ef4444"},children:[g.type==="success"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:g.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:R,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},rs=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const{appId:a}=ce(),[i,l]=w.useState(!1),[h,d]=w.useState(!0);return w.useEffect(()=>{let c=!1;const b=async()=>{try{const S=localStorage.getItem("userInfo");if(!S||S==="undefined"||S==="null"){l(!1);return}const u=JSON.parse(S);if(!u?.id){l(!1);return}const j=await fetch(`https://server.authix.neuctra.com/api/users/check-user/${u.id}?appId=${a}`,{credentials:"include"});if(!j.ok){l(!1);return}const m=await j.json();c||l(!!m?.exists)}catch{c||l(!1)}finally{c||d(!1)}};b();const y=()=>b();return window.addEventListener("storage",y),()=>{c=!0,window.removeEventListener("storage",y)}},[a]),h?null:i?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ns=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const[a,i]=w.useState(()=>{if(typeof window>"u")return!0;try{const l=localStorage.getItem("userInfo");return!l||l==="undefined"||l==="null"}catch{return!0}});return w.useEffect(()=>{const l=()=>{try{const h=localStorage.getItem("userInfo");i(!h||h==="undefined"||h==="null")}catch{i(!0)}};return l(),window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]),a?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ss=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:h,appId:d}=ce(),[c,b]=w.useState(!1),[y,S]=w.useState(""),[u,j]=w.useState("warning"),[m,A]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const g=()=>{A(window.innerWidth<640)};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),!t)return null;const P=async()=>{b(!0),j("processing");try{const{data:g}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:d},headers:{"x-api-key":h}});g.success?(r(g.message||"Account deleted successfully"),j("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(g.message||"Failed to delete account"),j("warning"))}catch(g){s(g.response?.data?.message||"Something went wrong"),j("warning")}finally{b(!1)}},_=y.toLowerCase()==="delete my account",T=g=>{g.target===g.currentTarget&&u!=="processing"&&u!=="success"&&e()},M=()=>{switch(u){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:e,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:i.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.color=i.textPrimary},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.color=i.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(nr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Gn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),n.jsx("span",{children:g.text})]},O))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:e,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),n.jsxs("button",{onClick:()=>j("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:g=>{g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(nr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.jsx("input",{type:"text",value:y,onChange:g=>S(g.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${_?i.success:i.error}`,backgroundColor:"transparent",color:i.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:g=>{g.target.style.boxShadow=`0 0 0 3px ${i.accent}20`},onBlur:g=>{g.target.style.boxShadow="none"},autoFocus:!0}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:()=>{j("warning"),S("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),n.jsxs("button",{onClick:P,disabled:!_||c,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!_||c?"not-allowed":"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",opacity:!_||c?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!_||c?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.active?`${i.accent}10`:"transparent"},children:[n.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:g.active?i.accent:i.textTertiary,transition:"all 0.3s ease",boxShadow:g.active?`0 0 0 4px ${i.accent}20`:"none"}}),n.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx(rr,{size:18,style:{color:i.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.jsx("p",{style:{color:i.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary,justifyContent:"center"},children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[n.jsx("div",{style:{backgroundColor:i.surface,border:`1px solid ${i.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:M()}),n.jsx("style",{children:`
208
208
  @keyframes fadeIn {
209
209
  from { opacity: 0; }
210
210
  to { opacity: 1; }
@@ -306,7 +306,7 @@ React keys must be passed directly to JSX without using spread:
306
306
  transition: none !important;
307
307
  }
308
308
  }
309
- `})]})},is=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:h}=ue(),[d,c]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState({}),[S,u]=w.useState(!1),[j,m]=w.useState({currentPassword:!1,newPassword:!1,confirmPassword:!1}),[A,P]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const v=()=>{P(window.innerWidth<640)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]),!t)return null;const _=v=>{const{name:U,value:q}=v.target;c(F=>({...F,[U]:q})),b[U]&&y(F=>({...F,[U]:""}))},T=v=>{m(U=>({...U,[v]:!U[v]}))},M=()=>{const v={};return d.currentPassword||(v.currentPassword="Current password is required"),d.newPassword?d.newPassword.length<6&&(v.newPassword="Password must be at least 6 characters"):v.newPassword="New password is required",d.newPassword!==d.confirmPassword&&(v.confirmPassword="Passwords do not match"),y(v),Object.keys(v).length===0},g=async v=>{if(v.preventDefault(),!!M()){u(!0);try{const{data:U}=await W.put(`${i}/users/change-password/${o}`,{appId:h,currentPassword:d.currentPassword,newPassword:d.newPassword},{headers:{"x-api-key":l}});U.success?(r(U.message||"Password updated successfully"),c({currentPassword:"",newPassword:"",confirmPassword:""}),e()):s(U.message||"Failed to update password")}catch(U){s(U.response?.data?.message||"Something went wrong")}finally{u(!1)}}},O=[{field:"currentPassword",label:"Current Password",icon:n.jsx(ot,{size:18})},{field:"newPassword",label:"New Password",icon:n.jsx(we,{size:18})},{field:"confirmPassword",label:"Confirm Password",icon:n.jsx(we,{size:18})}];return n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e3},children:n.jsxs("div",{style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,borderRadius:"16px",maxWidth:"440px",width:"100%",padding:"24px",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",maxHeight:"90vh",overflowY:"auto"},className:"change-password-modal",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px",gap:"12px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"10px",background:`linear-gradient(135deg, ${a.accent}20, ${a.accent}40)`,display:"flex",alignItems:"center",justifyContent:"center",color:a.accent,flexShrink:0},children:n.jsx(we,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"18px",fontWeight:600,lineHeight:"1.4"},children:"Change Password"})})]}),n.jsx("button",{onClick:e,"aria-label":"Close password change modal",style:{background:"transparent",border:"none",color:a.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:v=>{v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.color=a.textPrimary},onMouseOut:v=>{v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.color=a.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("form",{onSubmit:g,children:[O.map(({field:v,label:U,icon:q})=>n.jsxs("div",{style:{marginBottom:"20px",position:"relative"},children:[n.jsx("label",{htmlFor:v,style:{display:"block",marginBottom:"8px",color:a.textPrimary,fontSize:"14px",fontWeight:500,lineHeight:"1.4"},children:U}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:a.textTertiary,zIndex:2},children:q}),n.jsx("input",{type:j[v]?"text":"password",id:v,name:v,placeholder:`Enter ${U.toLowerCase()}`,value:d[v],onChange:_,style:{width:"100%",padding:"14px 48px 14px 44px",borderRadius:"10px",border:`1.5px solid ${b[v]?a.error:a.border}`,backgroundColor:"transparent",color:a.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:F=>{F.target.style.borderColor=a.accent,F.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:F=>{F.target.style.borderColor=b[v]?a.error:a.border,F.target.style.boxShadow="none"}}),n.jsx("button",{type:"button",onClick:()=>T(v),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",cursor:"pointer",color:a.textTertiary,padding:"4px",borderRadius:"4px",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:F=>{F.currentTarget.style.backgroundColor=a.border,F.currentTarget.style.color=a.textPrimary},onMouseOut:F=>{F.currentTarget.style.backgroundColor="transparent",F.currentTarget.style.color=a.textTertiary},children:j[v]?n.jsx(nt,{size:18}):n.jsx(st,{size:18})})]}),b[v]&&n.jsxs("div",{style:{fontSize:"13px",color:a.error,marginTop:"6px",display:"flex",alignItems:"center",gap:"6px"},children:[n.jsx("span",{style:{fontSize:"16px"},children:"⚠"}),b[v]]})]},v)),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:A?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{type:"button",onClick:e,disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"120px",opacity:S?.6:1,transition:"all 0.2s ease"},onMouseOver:v=>{S||(v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.transform="translateY(-1px)")},onMouseOut:v=>{S||(v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.transform="translateY(0)")},children:"Cancel"}),n.jsx("button",{type:"submit",disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:"none",background:`linear-gradient(135deg, ${a.accent}, ${a.accent}E6)`,color:"#fff",fontSize:"14px",fontWeight:600,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"140px",opacity:S?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:S?"none":`0 4px 12px ${a.accent}40`},onMouseOver:v=>{S||(v.currentTarget.style.transform="translateY(-1px)",v.currentTarget.style.boxShadow=`0 6px 20px ${a.accent}60`)},onMouseOut:v=>{S||(v.currentTarget.style.transform="translateY(0)",v.currentTarget.style.boxShadow=`0 4px 12px ${a.accent}40`)},children:S?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Updating..."]}):"Update Password"})]})]}),n.jsx("style",{children:`
309
+ `})]})},is=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:h}=ce(),[d,c]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState({}),[S,u]=w.useState(!1),[j,m]=w.useState({currentPassword:!1,newPassword:!1,confirmPassword:!1}),[A,P]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const v=()=>{P(window.innerWidth<640)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]),!t)return null;const _=v=>{const{name:U,value:q}=v.target;c(F=>({...F,[U]:q})),b[U]&&y(F=>({...F,[U]:""}))},T=v=>{m(U=>({...U,[v]:!U[v]}))},M=()=>{const v={};return d.currentPassword||(v.currentPassword="Current password is required"),d.newPassword?d.newPassword.length<6&&(v.newPassword="Password must be at least 6 characters"):v.newPassword="New password is required",d.newPassword!==d.confirmPassword&&(v.confirmPassword="Passwords do not match"),y(v),Object.keys(v).length===0},g=async v=>{if(v.preventDefault(),!!M()){u(!0);try{const{data:U}=await W.put(`${i}/users/change-password/${o}`,{appId:h,currentPassword:d.currentPassword,newPassword:d.newPassword},{headers:{"x-api-key":l}});U.success?(r(U.message||"Password updated successfully"),c({currentPassword:"",newPassword:"",confirmPassword:""}),e()):s(U.message||"Failed to update password")}catch(U){s(U.response?.data?.message||"Something went wrong")}finally{u(!1)}}},O=[{field:"currentPassword",label:"Current Password",icon:n.jsx(ot,{size:18})},{field:"newPassword",label:"New Password",icon:n.jsx(we,{size:18})},{field:"confirmPassword",label:"Confirm Password",icon:n.jsx(we,{size:18})}];return n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e3},children:n.jsxs("div",{style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,borderRadius:"16px",maxWidth:"440px",width:"100%",padding:"24px",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",maxHeight:"90vh",overflowY:"auto"},className:"change-password-modal",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px",gap:"12px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"10px",background:`linear-gradient(135deg, ${a.accent}20, ${a.accent}40)`,display:"flex",alignItems:"center",justifyContent:"center",color:a.accent,flexShrink:0},children:n.jsx(we,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"18px",fontWeight:600,lineHeight:"1.4"},children:"Change Password"})})]}),n.jsx("button",{onClick:e,"aria-label":"Close password change modal",style:{background:"transparent",border:"none",color:a.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:v=>{v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.color=a.textPrimary},onMouseOut:v=>{v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.color=a.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("form",{onSubmit:g,children:[O.map(({field:v,label:U,icon:q})=>n.jsxs("div",{style:{marginBottom:"20px",position:"relative"},children:[n.jsx("label",{htmlFor:v,style:{display:"block",marginBottom:"8px",color:a.textPrimary,fontSize:"14px",fontWeight:500,lineHeight:"1.4"},children:U}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:a.textTertiary,zIndex:2},children:q}),n.jsx("input",{type:j[v]?"text":"password",id:v,name:v,placeholder:`Enter ${U.toLowerCase()}`,value:d[v],onChange:_,style:{width:"100%",padding:"14px 48px 14px 44px",borderRadius:"10px",border:`1.5px solid ${b[v]?a.error:a.border}`,backgroundColor:"transparent",color:a.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:F=>{F.target.style.borderColor=a.accent,F.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:F=>{F.target.style.borderColor=b[v]?a.error:a.border,F.target.style.boxShadow="none"}}),n.jsx("button",{type:"button",onClick:()=>T(v),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",cursor:"pointer",color:a.textTertiary,padding:"4px",borderRadius:"4px",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:F=>{F.currentTarget.style.backgroundColor=a.border,F.currentTarget.style.color=a.textPrimary},onMouseOut:F=>{F.currentTarget.style.backgroundColor="transparent",F.currentTarget.style.color=a.textTertiary},children:j[v]?n.jsx(nt,{size:18}):n.jsx(st,{size:18})})]}),b[v]&&n.jsxs("div",{style:{fontSize:"13px",color:a.error,marginTop:"6px",display:"flex",alignItems:"center",gap:"6px"},children:[n.jsx("span",{style:{fontSize:"16px"},children:"⚠"}),b[v]]})]},v)),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:A?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{type:"button",onClick:e,disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"120px",opacity:S?.6:1,transition:"all 0.2s ease"},onMouseOver:v=>{S||(v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.transform="translateY(-1px)")},onMouseOut:v=>{S||(v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.transform="translateY(0)")},children:"Cancel"}),n.jsx("button",{type:"submit",disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:"none",background:`linear-gradient(135deg, ${a.accent}, ${a.accent}E6)`,color:"#fff",fontSize:"14px",fontWeight:600,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"140px",opacity:S?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:S?"none":`0 4px 12px ${a.accent}40`},onMouseOver:v=>{S||(v.currentTarget.style.transform="translateY(-1px)",v.currentTarget.style.boxShadow=`0 6px 20px ${a.accent}60`)},onMouseOut:v=>{S||(v.currentTarget.style.transform="translateY(0)",v.currentTarget.style.boxShadow=`0 4px 12px ${a.accent}40`)},children:S?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Updating..."]}):"Update Password"})]})]}),n.jsx("style",{children:`
310
310
  @keyframes spin {
311
311
  from { transform: rotate(0deg); }
312
312
  to { transform: rotate(360deg); }
@@ -344,7 +344,7 @@ React keys must be passed directly to JSX without using spread:
344
344
  padding: 16px 12px;
345
345
  }
346
346
  }
347
- `})]})})},as=({isOpen:t,onClose:e,onVerify:r,onSendOTP:s,verifyFormData:o,setVerifyFormData:a,otpSent:i,verifying:l,user:h,colors:d,darkMode:c})=>{if(!t)return null;const b=()=>{e(),a({email:h?.email||"",otp:"",appId:o.appId})};return n.jsxs("div",{className:"modal-overlay",style:{backgroundColor:c?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.5)"},children:[n.jsxs("div",{className:"verify-email-modal",style:{backgroundColor:d.surface,border:`1px solid ${d.border}`},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{style:{color:d.textPrimary},children:"Verify Your Email"}),n.jsx("button",{onClick:b,className:"close-btn",style:{color:d.textTertiary},"aria-label":"Close verification modal",children:n.jsx(Pe,{size:20,"aria-hidden":"true"})})]}),n.jsxs("form",{className:"verify-form",onSubmit:r,children:[n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"Email"}),n.jsxs("div",{className:"input-container",children:[n.jsx(ce,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"email",value:o.email,onChange:y=>a(S=>({...S,email:y.target.value})),placeholder:"Enter your email",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"Email address"})]})]}),i&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"OTP"}),n.jsxs("div",{className:"input-container",children:[n.jsx(tr,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"text",value:o.otp,onChange:y=>a(S=>({...S,otp:y.target.value})),placeholder:"Enter OTP",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"One-time password"})]})]}),n.jsx("div",{className:"modal-actions",children:i?n.jsxs("button",{type:"submit",disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Verifying email":"Verify email",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(de,{size:16,"aria-hidden":"true"}),l?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:s,disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Sending OTP":"Send OTP",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(at,{size:16,"aria-hidden":"true"}),l?"Sending...":"Send OTP"]})})]})]}),n.jsx("style",{children:`
347
+ `})]})})},as=({isOpen:t,onClose:e,onVerify:r,onSendOTP:s,verifyFormData:o,setVerifyFormData:a,otpSent:i,verifying:l,user:h,colors:d,darkMode:c})=>{if(!t)return null;const b=()=>{e(),a({email:h?.email||"",otp:"",appId:o.appId})};return n.jsxs("div",{className:"modal-overlay",style:{backgroundColor:c?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.5)"},children:[n.jsxs("div",{className:"verify-email-modal",style:{backgroundColor:d.surface,border:`1px solid ${d.border}`},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{style:{color:d.textPrimary},children:"Verify Your Email"}),n.jsx("button",{onClick:b,className:"close-btn",style:{color:d.textTertiary},"aria-label":"Close verification modal",children:n.jsx(Pe,{size:20,"aria-hidden":"true"})})]}),n.jsxs("form",{className:"verify-form",onSubmit:r,children:[n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"Email"}),n.jsxs("div",{className:"input-container",children:[n.jsx(ue,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"email",value:o.email,onChange:y=>a(S=>({...S,email:y.target.value})),placeholder:"Enter your email",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"Email address"})]})]}),i&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"OTP"}),n.jsxs("div",{className:"input-container",children:[n.jsx(tr,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"text",value:o.otp,onChange:y=>a(S=>({...S,otp:y.target.value})),placeholder:"Enter OTP",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"One-time password"})]})]}),n.jsx("div",{className:"modal-actions",children:i?n.jsxs("button",{type:"submit",disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Verifying email":"Verify email",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(de,{size:16,"aria-hidden":"true"}),l?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:s,disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Sending OTP":"Send OTP",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(at,{size:16,"aria-hidden":"true"}),l?"Sending...":"Send OTP"]})})]})]}),n.jsx("style",{children:`
348
348
  .modal-overlay {
349
349
  position: fixed;
350
350
  top: 0;
@@ -491,7 +491,7 @@ React keys must be passed directly to JSX without using spread:
491
491
  animation: none;
492
492
  }
493
493
  }
494
- `})]})},ls=({token:t,user:e=null,darkMode:r=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:h,appId:d}=ue(),[c,b]=w.useState(null),[y,S]=w.useState(e),[u,j]=w.useState(!0),[m,A]=w.useState(!1),[P,_]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(!1),[q,F]=w.useState(!1),[V,Z]=w.useState(!1),[I,J]=w.useState(!1),[z,R]=w.useState(null),[K,te]=w.useState(!1),[X,f]=w.useState({email:"",otp:"",appId:d}),[k,x]=w.useState(!1),[E,$]=w.useState(!1);w.useEffect(()=>{if(typeof window<"u"){const C=()=>b(window.innerWidth);return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)}},[]);const N=(C,H)=>{R({type:C,message:H}),setTimeout(()=>R(null),3e3)},Y=()=>{J(!0);const C=setTimeout(()=>{Z(!1),J(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=H=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(H.target)&&Y()};return V&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[V]);const ie=async()=>{if(!X.email||!/\S+@\S+\.\S+/.test(X.email)){N("error","Please enter a valid email");return}try{$(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:X.email},{headers:{"x-api-key":h,"x-app-id":d}});C.data.success?(N("success",C.data.message||"OTP sent to email!"),x(!0)):N("error",C.data.message||"Failed to send OTP")}catch(C){N("error",C.response?.data?.message||"Server error")}finally{$(!1)}},he=async C=>{if(C.preventDefault(),!X.email||!X.otp){N("error","Please fill in all fields");return}try{$(!0);const H=await W.post(`${l}/users/verify-email`,X);if(H.data.success){if(N("success",H.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:t})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),x(!1),F(!1)}else N("error",H.data.message||"Verification failed")}catch(H){N("error",H.response?.data?.message||"Something went wrong")}finally{$(!1)}},Oe=async C=>{if(!y)return!1;try{const H={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,H,{headers:{"x-api-key":h}});return G.success?(S(H),localStorage.setItem("userInfo",JSON.stringify({...H,token:t})),N("success","Avatar updated successfully!"),!0):(N("error",G.message||"Failed to update avatar"),!1)}catch(H){return console.error("Avatar update error:",H),N("error","Failed to update avatar"),!1}},us=async()=>{if(y){_(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":h}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:t})),N("success","Profile updated successfully")):N("error",C.message)}catch(C){console.error(C),N("error","Update failed")}finally{_(!1)}}},sr=async C=>{try{const{data:H}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":h}});H?.success===!0&&H?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(H){console.error("⚠️ User validation request failed:",H)}};w.useEffect(()=>{(()=>{if(e)S(e),j(!1),sr(e.id);else{const H=localStorage.getItem("userInfo");if(H){const G=JSON.parse(H);S(G),j(!1),sr(G.id)}else j(!1)}})()},[e]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const or=(C,H)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+H,lt=(G>>8&255)+H,dt=(G&255)+H;return ge=Math.min(255,Math.max(0,ge)),lt=Math.min(255,Math.max(0,lt)),dt=Math.min(255,Math.max(0,dt)),`#${(dt|lt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=r?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:or(i,-15),success:"#10b981",error:"#ef4444",border:"#27272a",warning:"#f59e0b"}:{background:"#ffffff",surface:"#fafafa",surfaceLight:"#f4f4f5",surfaceLighter:"#e4e4e7",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",accent:i,accentHover:or(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(u)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[n.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[n.jsx(le,{size:40,color:L.error,"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"No profile found. Please log in again."})]})});const ps=[{label:"Full Name",value:y.name,name:"name",type:"text",icon:Se},{label:"Email Address",value:y.email,name:"email",type:"email",icon:ce},{label:"Phone Number",value:y.phone||"Not set",name:"phone",type:"tel",icon:Kn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Vn}];return n.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",lineHeight:1.5,minHeight:"80vh"},children:[z&&n.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",padding:"12px 24px",borderRadius:"12px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"blur(8px)",border:"1px solid",zIndex:1e3,display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontWeight:500,maxWidth:"400px",animation:"slideIn 0.3s ease-out",...z.type==="success"?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:r?"#34d399":"#059669"}:{backgroundColor:r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:r?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:r?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[z.type==="success"?n.jsx(de,{size:20,"aria-hidden":"true"}):n.jsx(le,{size:20,"aria-hidden":"true"}),z.message]}),n.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:n.jsxs("div",{style:{display:"grid",gap:"24px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=1024&&{gridTemplateColumns:"1fr 2fr",gap:"10px"},...c&&window.innerWidth>=768&&c&&window.innerWidth<1024&&{gap:"10px"},...c&&window.innerWidth>=600&&c&&window.innerWidth<768&&{gap:"28px"}},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",position:"relative",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",textAlign:"center",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",flex:1,minHeight:"300px"},children:[s&&n.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:n.jsx(qn,{size:20,style:{color:r?"#ffffff":"#000000"}})}),n.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[n.jsx("img",{src:y.avatarUrl||`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(y.name)}`,alt:`Profile avatar of ${y.name}`,style:{width:"128px",height:"128px",borderRadius:"50%",objectFit:"cover",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.3)",border:`3px solid ${L.border}`},width:128,height:128,loading:"eager"}),n.jsx("button",{onClick:()=>M(!0),style:{position:"absolute",bottom:"8px",right:"8px",backgroundColor:L.accent,color:"white",padding:"8px",borderRadius:"50%",border:"none",cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px"},"aria-label":"Change profile picture",children:n.jsx(tt,{size:16,"aria-hidden":"true"})})]}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),n.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),n.jsxs("div",{style:{backgroundColor:y.isVerified?r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`,padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"6px",marginTop:"8px"},children:[y.isVerified?n.jsx(de,{size:16,"aria-hidden":"true"}):n.jsx(le,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),n.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>A(!1),style:{backgroundColor:L.surfaceLight,border:`1px solid ${L.border}`,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",borderStyle:"solid",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),n.jsxs("button",{onClick:us,disabled:P,style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,opacity:P?.7:1,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:P?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[P?n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(Jn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>A(!0),style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Yn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&n.jsxs("button",{onClick:()=>F(!0),disabled:K,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:K?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:K?.7:1,flex:c&&window.innerWidth<1024?"1":"auto"},children:[K?n.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(at,{size:14,"aria-hidden":"true"}),K?"Sending...":"Verify Email"]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsxs("button",{style:{backgroundColor:L.surfaceLight,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",width:"100%",boxSizing:"border-box"},onClick:()=>Z(!V),children:[n.jsx(Wn,{size:16,"aria-hidden":"true"}),"More Actions"]}),V&&n.jsxs("div",{className:`dropdown-container ${I?"closing":""}`,style:{position:"absolute",bottom:"100%",left:0,right:0,backgroundColor:L.surface,border:`1px solid ${L.border}`,borderRadius:"12px 12px 0 0",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.25)",zIndex:200,marginBottom:"6px",overflow:"hidden",animation:`${I?"drawerSlideDown":"drawerSlideUp"} 0.25s ease-out forwards`},children:[n.jsxs("button",{onClick:()=>{O(!0),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:L.textPrimary,cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>C.currentTarget.style.backgroundColor=L.surfaceLight,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&n.jsxs("button",{onClick:()=>{o(),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:r?"#fca5a5":"#dc2626",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),n.jsxs("button",{onClick:()=>{U(!0),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:"#ef4444",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:600,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),n.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),n.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const H=C.icon;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(H,{size:16,"aria-hidden":"true"}),C.label]}),m?n.jsx("input",{type:C.type,name:C.name,value:y[C.name],onChange:G=>S(ge=>ge&&{...ge,[G.target.name]:G.target.value}),style:{padding:"12px",borderRadius:"8px",border:`1px solid ${i}`,backgroundColor:"transparent",color:L.textPrimary,fontSize:"12px",outline:"none",transition:"border-color 0.2s ease",minHeight:"44px",width:"100%",boxSizing:"border-box"},placeholder:`Enter ${C.label.toLowerCase()}`,"aria-label":C.label}):n.jsx("div",{style:{padding:"12px",borderRadius:"8px",border:"1px solid transparent",fontSize:"12px",minHeight:"44px",display:"flex",alignItems:"center",boxSizing:"border-box",color:L.textPrimary,backgroundColor:r?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(rr,{size:20,"aria-hidden":"true"}),"Security Status"]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[n.jsx(ce,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:"Email Verification"})]}),n.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?n.jsxs(n.Fragment,{children:[n.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):n.jsxs(n.Fragment,{children:[n.jsx(le,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&n.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:r?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:n.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),n.jsx(os,{isOpen:T,onClose:()=>{M(!1)},onUpdate:Oe,colors:L}),n.jsx(is,{baseUrl:l,apiKey:h,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(ss,{baseUrl:l,apiKey:h,appId:d,userId:y.id,token:t,isOpen:v,onClose:()=>U(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(as,{isOpen:q,onClose:()=>{F(!1),x(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:he,onSendOTP:ie,verifyFormData:X,setVerifyFormData:f,otpSent:k,verifying:E,user:y,colors:L,darkMode:r}),n.jsx("style",{children:`
494
+ `})]})},ls=({token:t,user:e=null,darkMode:r=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:h,appId:d}=ce(),[c,b]=w.useState(null),[y,S]=w.useState(e),[u,j]=w.useState(!0),[m,A]=w.useState(!1),[P,_]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(!1),[q,F]=w.useState(!1),[V,Z]=w.useState(!1),[I,J]=w.useState(!1),[z,R]=w.useState(null),[K,te]=w.useState(!1),[X,f]=w.useState({email:"",otp:"",appId:d}),[k,x]=w.useState(!1),[E,$]=w.useState(!1);w.useEffect(()=>{if(typeof window<"u"){const C=()=>b(window.innerWidth);return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)}},[]);const N=(C,H)=>{R({type:C,message:H}),setTimeout(()=>R(null),3e3)},Y=()=>{J(!0);const C=setTimeout(()=>{Z(!1),J(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=H=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(H.target)&&Y()};return V&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[V]);const ie=async()=>{if(!X.email||!/\S+@\S+\.\S+/.test(X.email)){N("error","Please enter a valid email");return}try{$(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:X.email},{headers:{"x-api-key":h,"x-app-id":d}});C.data.success?(N("success",C.data.message||"OTP sent to email!"),x(!0)):N("error",C.data.message||"Failed to send OTP")}catch(C){N("error",C.response?.data?.message||"Server error")}finally{$(!1)}},he=async C=>{if(C.preventDefault(),!X.email||!X.otp){N("error","Please fill in all fields");return}try{$(!0);const H=await W.post(`${l}/users/verify-email`,X);if(H.data.success){if(N("success",H.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:t})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),x(!1),F(!1)}else N("error",H.data.message||"Verification failed")}catch(H){N("error",H.response?.data?.message||"Something went wrong")}finally{$(!1)}},Oe=async C=>{if(!y)return!1;try{const H={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,H,{headers:{"x-api-key":h}});return G.success?(S(H),localStorage.setItem("userInfo",JSON.stringify({...H,token:t})),N("success","Avatar updated successfully!"),!0):(N("error",G.message||"Failed to update avatar"),!1)}catch(H){return console.error("Avatar update error:",H),N("error","Failed to update avatar"),!1}},us=async()=>{if(y){_(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":h}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:t})),N("success","Profile updated successfully")):N("error",C.message)}catch(C){console.error(C),N("error","Update failed")}finally{_(!1)}}},sr=async C=>{try{const{data:H}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":h}});H?.success===!0&&H?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(H){console.error("⚠️ User validation request failed:",H)}};w.useEffect(()=>{(()=>{if(e)S(e),j(!1),sr(e.id);else{const H=localStorage.getItem("userInfo");if(H){const G=JSON.parse(H);S(G),j(!1),sr(G.id)}else j(!1)}})()},[e]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const or=(C,H)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+H,lt=(G>>8&255)+H,dt=(G&255)+H;return ge=Math.min(255,Math.max(0,ge)),lt=Math.min(255,Math.max(0,lt)),dt=Math.min(255,Math.max(0,dt)),`#${(dt|lt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=r?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:or(i,-15),success:"#10b981",error:"#ef4444",border:"#27272a",warning:"#f59e0b"}:{background:"#ffffff",surface:"#fafafa",surfaceLight:"#f4f4f5",surfaceLighter:"#e4e4e7",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",accent:i,accentHover:or(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(u)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[n.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[n.jsx(le,{size:40,color:L.error,"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"No profile found. Please log in again."})]})});const ps=[{label:"Full Name",value:y.name,name:"name",type:"text",icon:Se},{label:"Email Address",value:y.email,name:"email",type:"email",icon:ue},{label:"Phone Number",value:y.phone||"Not set",name:"phone",type:"tel",icon:Kn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Vn}];return n.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",lineHeight:1.5,minHeight:"80vh"},children:[z&&n.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",padding:"12px 24px",borderRadius:"12px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"blur(8px)",border:"1px solid",zIndex:1e3,display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontWeight:500,maxWidth:"400px",animation:"slideIn 0.3s ease-out",...z.type==="success"?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:r?"#34d399":"#059669"}:{backgroundColor:r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:r?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:r?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[z.type==="success"?n.jsx(de,{size:20,"aria-hidden":"true"}):n.jsx(le,{size:20,"aria-hidden":"true"}),z.message]}),n.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:n.jsxs("div",{style:{display:"grid",gap:"24px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=1024&&{gridTemplateColumns:"1fr 2fr",gap:"10px"},...c&&window.innerWidth>=768&&c&&window.innerWidth<1024&&{gap:"10px"},...c&&window.innerWidth>=600&&c&&window.innerWidth<768&&{gap:"28px"}},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",position:"relative",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",textAlign:"center",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",flex:1,minHeight:"300px"},children:[s&&n.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:n.jsx(qn,{size:20,style:{color:r?"#ffffff":"#000000"}})}),n.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[n.jsx("img",{src:y.avatarUrl||`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(y.name)}`,alt:`Profile avatar of ${y.name}`,style:{width:"128px",height:"128px",borderRadius:"50%",objectFit:"cover",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.3)",border:`3px solid ${L.border}`},width:128,height:128,loading:"eager"}),n.jsx("button",{onClick:()=>M(!0),style:{position:"absolute",bottom:"8px",right:"8px",backgroundColor:L.accent,color:"white",padding:"8px",borderRadius:"50%",border:"none",cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px"},"aria-label":"Change profile picture",children:n.jsx(tt,{size:16,"aria-hidden":"true"})})]}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),n.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),n.jsxs("div",{style:{backgroundColor:y.isVerified?r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`,padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"6px",marginTop:"8px"},children:[y.isVerified?n.jsx(de,{size:16,"aria-hidden":"true"}):n.jsx(le,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),n.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>A(!1),style:{backgroundColor:L.surfaceLight,border:`1px solid ${L.border}`,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",borderStyle:"solid",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),n.jsxs("button",{onClick:us,disabled:P,style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,opacity:P?.7:1,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:P?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[P?n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(Jn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>A(!0),style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Yn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&n.jsxs("button",{onClick:()=>F(!0),disabled:K,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:K?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:K?.7:1,flex:c&&window.innerWidth<1024?"1":"auto"},children:[K?n.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(at,{size:14,"aria-hidden":"true"}),K?"Sending...":"Verify Email"]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsxs("button",{style:{backgroundColor:L.surfaceLight,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",width:"100%",boxSizing:"border-box"},onClick:()=>Z(!V),children:[n.jsx(Wn,{size:16,"aria-hidden":"true"}),"More Actions"]}),V&&n.jsxs("div",{className:`dropdown-container ${I?"closing":""}`,style:{position:"absolute",bottom:"100%",left:0,right:0,backgroundColor:L.surface,border:`1px solid ${L.border}`,borderRadius:"12px 12px 0 0",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.25)",zIndex:200,marginBottom:"6px",overflow:"hidden",animation:`${I?"drawerSlideDown":"drawerSlideUp"} 0.25s ease-out forwards`},children:[n.jsxs("button",{onClick:()=>{O(!0),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:L.textPrimary,cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>C.currentTarget.style.backgroundColor=L.surfaceLight,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&n.jsxs("button",{onClick:()=>{o(),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:r?"#fca5a5":"#dc2626",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),n.jsxs("button",{onClick:()=>{U(!0),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:"#ef4444",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:600,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),n.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),n.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const H=C.icon;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(H,{size:16,"aria-hidden":"true"}),C.label]}),m?n.jsx("input",{type:C.type,name:C.name,value:y[C.name],onChange:G=>S(ge=>ge&&{...ge,[G.target.name]:G.target.value}),style:{padding:"12px",borderRadius:"8px",border:`1px solid ${i}`,backgroundColor:"transparent",color:L.textPrimary,fontSize:"12px",outline:"none",transition:"border-color 0.2s ease",minHeight:"44px",width:"100%",boxSizing:"border-box"},placeholder:`Enter ${C.label.toLowerCase()}`,"aria-label":C.label}):n.jsx("div",{style:{padding:"12px",borderRadius:"8px",border:"1px solid transparent",fontSize:"12px",minHeight:"44px",display:"flex",alignItems:"center",boxSizing:"border-box",color:L.textPrimary,backgroundColor:r?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(rr,{size:20,"aria-hidden":"true"}),"Security Status"]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[n.jsx(ue,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:"Email Verification"})]}),n.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?n.jsxs(n.Fragment,{children:[n.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):n.jsxs(n.Fragment,{children:[n.jsx(le,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&n.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:r?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:n.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),n.jsx(os,{isOpen:T,onClose:()=>{M(!1)},onUpdate:Oe,colors:L}),n.jsx(is,{baseUrl:l,apiKey:h,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(ss,{baseUrl:l,apiKey:h,appId:d,userId:y.id,token:t,isOpen:v,onClose:()=>U(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(as,{isOpen:q,onClose:()=>{F(!1),x(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:he,onSendOTP:ie,verifyFormData:X,setVerifyFormData:f,otpSent:k,verifying:E,user:y,colors:L,darkMode:r}),n.jsx("style",{children:`
495
495
  @keyframes slideIn {
496
496
  from {
497
497
  transform: translateX(100%);
@@ -579,4 +579,4 @@ React keys must be passed directly to JSX without using spread:
579
579
  transition-duration: 0.01ms !important;
580
580
  }
581
581
  }
582
- `})]})},ds=({darkMode:t=!0,primaryColor:e="#3b82f6",onLogout:r,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:h=!0,showSettingsMenuItem:d=!0,showViewProfileMenuItem:c=!0,profileLabel:b="My Profile",settingsLabel:y="Settings",viewProfileLabel:S="View Profile",logoutLabel:u="Sign Out"})=>{const{baseUrl:j,apiKey:m,appId:A}=ue(),[P,_]=w.useState(!1),[T,M]=w.useState(null),[g,O]=w.useState(!0),[v,U]=w.useState(null),q=w.useRef(null),F=w.useRef(null),[V,Z]=w.useState(!1),[I,J]=w.useState(!1);w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{J(window.innerWidth<768)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]),w.useEffect(()=>{(async()=>{try{if(O(!0),U(null),o){if(!o.id||!o.name||!o.email)throw new Error("Invalid user data provided");M(o)}else if(typeof window<"u"){const E=localStorage.getItem("userInfo");if(E)try{const $=JSON.parse(E);if(!$.id||!$.name||!$.email)throw new Error("Invalid stored user data");M($)}catch($){console.error("Failed to parse stored user data:",$),localStorage.removeItem("userInfo"),U("Invalid user data")}}}catch(E){console.error("User initialization failed:",E),U(E.message||"Failed to load user")}finally{O(!1)}})()},[o]),w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{if(!P||!F.current)return;const E=F.current.getBoundingClientRect(),$=window.innerWidth,N=window.innerHeight,Y=280,ie=$-E.right,he=E.left;N-E.bottom;const Oe=ie>=Y||ie>he;Z(Oe)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const x=N=>{q.current&&!q.current.contains(N.target)&&!F.current?.contains(N.target)&&_(!1)},E=N=>{N.key==="Escape"&&_(!1)},$=()=>{P&&_(!1)};return P&&(document.addEventListener("mousedown",x),document.addEventListener("keydown",E),window.addEventListener("scroll",$)),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",E),window.removeEventListener("scroll",$)}},[P]);const z=t?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:e,accentHover:`${e}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:e,accentHover:`${e}e6`,error:"#ef4444"},R={wrapper:{position:"relative",display:"inline-block"},avatarButton:{display:"flex",alignItems:"center",gap:I?"6px":"8px",padding:I?"6px 10px 6px 6px":"8px 12px 8px 8px",borderRadius:"24px",backgroundColor:z.surface,cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",minWidth:I?"auto":"140px",maxWidth:I?"200px":"none",outline:"none"},avatarImage:{width:I?"28px":"32px",height:I?"28px":"32px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},userInfo:{display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1,minWidth:0,overflow:"hidden"},userName:{fontSize:I?"13px":"14px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},userEmail:{fontSize:I?"11px":"12px",color:z.textTertiary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},chevron:{transition:"transform 0.2s ease",transform:P?"rotate(180deg)":"rotate(0deg)",color:z.textTertiary,flexShrink:0},dropdown:{position:"absolute",top:"100%",marginTop:"8px",[V?"left":"right"]:"0",backgroundColor:z.surfaceElevated,border:`1px solid ${z.border}`,borderRadius:"12px",boxShadow:"0 20px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1)",width:"min(280px, 90vw)",maxWidth:"calc(100vw - 20px)",padding:"6px 6px 16px 6px",zIndex:1e3,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",opacity:P?1:0,pointerEvents:P?"auto":"none",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",transform:P?"translateY(0) scale(1)":"translateY(-8px) scale(0.95)",overflow:"hidden"},dropdownSection:{padding:I?"10px 12px":"0px 16px","&:last-child":{borderBottom:"none"}},userSection:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"14px":"16px"},dropdownAvatar:{width:I?"40px":"48px",height:I?"40px":"48px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},dropdownUserInfo:{display:"flex",flexDirection:"column",flex:1,minWidth:0},dropdownUserName:{fontSize:I?"15px":"16px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis"},dropdownUserEmail:{fontSize:I?"13px":"14px",color:z.textSecondary,lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis"},menuItem:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",color:z.textPrimary,textDecoration:"none",border:"none",background:"none",width:"100%",fontSize:I?"13px":"14px",textAlign:"left",outline:"none"},menuItemText:{flex:1},icon:{width:I?"16px":"18px",height:I?"16px":"18px",color:z.textSecondary,flexShrink:0},logoutButton:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",background:"none",border:"none",width:"100%",fontSize:I?"13px":"14px",color:z.error,textAlign:"left",outline:"none"},loadingText:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px"},errorState:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",flexDirection:"column"},retryButton:{marginTop:"8px",padding:"8px 16px",backgroundColor:z.accent,color:"#ffffff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:500,transition:"background-color 0.2s ease"}},K=async()=>{U(null),O(!0);try{const x=localStorage.getItem("userInfo");if(x){const E=JSON.parse(x);M(E)}else o&&M(o)}catch(x){console.error("Retry failed:",x),U("Invalid user data"),localStorage.removeItem("userInfo"),M(null)}finally{O(!1)}},te=(x,E)=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),E())},X=()=>i||T?.profileUrl,f=()=>{const x=X();x&&window.open(x,"_self","noopener,noreferrer")},k=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return n.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?n.jsx("div",{ref:F,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T?.name||"User"}'s avatar`,style:{width:I?"34px":"36px",height:I?"34px":"36px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy",onError:x=>{const E=x.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):n.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`,alt:"Default user avatar",style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy"})}):n.jsxs("div",{ref:F,style:R.avatarButton,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover,x.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.surface,x.currentTarget.style.boxShadow="none"},onBlur:x=>{x.currentTarget.style.outline="none"},children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:x=>{const E=x.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):n.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&n.jsxs("div",{style:R.userInfo,children:[n.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&n.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),n.jsx(Fn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&n.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?n.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:x=>{const E=x.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):n.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`,alt:`${T.name}'s default avatar`,style:R.dropdownAvatar,loading:"lazy"}),n.jsxs("div",{style:R.dropdownUserInfo,children:[n.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),n.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),n.jsxs("div",{style:R.dropdownSection,children:[h&&X()&&n.jsxs("button",{style:R.menuItem,onClick:f,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,f),role:"menuitem",tabIndex:0,children:[n.jsx(Se,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&n.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,k),role:"menuitem",tabIndex:0,children:[n.jsx(Xn,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:y})]}),c&&T.profileUrl&&n.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[n.jsx(ce,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:S})]})]}),n.jsx("div",{style:R.dropdownSection,children:n.jsxs("button",{style:R.logoutButton,onClick:r,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,r),role:"menuitem",tabIndex:0,children:[n.jsx(it,{style:{...R.icon,color:z.error},"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:u})]})})]}):n.jsxs("div",{style:R.errorState,role:"alert",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(le,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&n.jsx("button",{style:R.retryButton,onClick:K,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.accentHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.accent},children:"Try Again"})]})})]})},cs=({user:t,darkMode:e=!0,primaryColor:r="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ue(),[l,h]=w.useState({email:t?.email||"",otp:"",appId:o}),[d,c]=w.useState(!1),[b,y]=w.useState(!1),[S,u]=w.useState(null),j=(g,O)=>{let v=parseInt(g.replace("#",""),16),U=(v>>16)+O,q=(v>>8&255)+O,F=(v&255)+O;return U=Math.min(255,Math.max(0,U)),q=Math.min(255,Math.max(0,q)),F=Math.min(255,Math.max(0,F)),`#${(F|q<<8|U<<16).toString(16).padStart(6,"0")}`},m=e?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#d97706"};w.useEffect(()=>{t?.email&&h(g=>({...g,email:t.email}))},[t?.email]);const A=(g,O)=>{u({type:g,message:O}),setTimeout(()=>u(null),3e3)},P=async()=>{if(!l.email||!/\S+@\S+\.\S+/.test(l.email)){A("error","Please enter a valid email");return}try{y(!0);const g=await W.post(`${a}/users/send-verify-otp/${t?.id}`,{email:l.email},{headers:{"x-api-key":i,"x-app-id":o}});g.data.success?(A("success",g.data.message||"OTP sent!"),c(!0)):A("error",g.data.message||"Failed to send OTP")}catch(g){A("error",g.response?.data?.message||"Server error")}finally{y(!1)}},_=async g=>{if(g.preventDefault(),!l.email||!l.otp){A("error","Please fill in all fields");return}try{y(!0);const O=await W.post(`${a}/users/verify-email`,l);if(O.data.success&&t){const v={...t,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),c(!1),h({email:t.email,otp:"",appId:o})}else A("error",O.data.message||"Verification failed")}catch(O){A("error",O.response?.data?.message||"Server error")}finally{y(!1)}},T={width:"100%",padding:"12px 12px 12px 40px",borderRadius:8,border:`1px solid ${m.border}`,backgroundColor:m.surfaceLight,color:m.textPrimary,fontSize:14,outline:"none"},M=(g=!1)=>({flex:1,padding:12,borderRadius:8,color:"#fff",fontWeight:500,cursor:g?"not-allowed":"pointer",background:`linear-gradient(to right, ${m.accent}, ${m.accentHover})`,opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,fontSize:14,border:"none"});return n.jsxs("form",{onSubmit:_,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&n.jsxs("div",{style:{padding:"12px 20px",borderRadius:12,fontSize:13,fontWeight:500,color:S.type==="success"?m.success:m.warning,border:`1px solid ${S.type==="success"?m.success:m.warning}`,backgroundColor:S.type==="success"?`${m.success}20`:`${m.warning}20`,display:"flex",alignItems:"center",gap:8},children:[S.type==="success"?n.jsx(de,{size:16}):n.jsx(le,{size:16}),S.message]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"Email"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"email",value:l.email,onChange:g=>h(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"text",value:l.otp,onChange:g=>h(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),n.jsx("div",{style:{display:"flex",gap:12},children:d?n.jsxs("button",{type:"submit",disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:P,disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=On,Q.ReactEmailVerification=cs,Q.ReactSignedIn=rs,Q.ReactSignedOut=ns,Q.ReactUserButton=ds,Q.ReactUserLogin=ts,Q.ReactUserProfile=ls,Q.ReactUserSignUp=Qn,Q.getSdkConfig=ue,Q.setSdkConfig=Zn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
582
+ `})]})},ds=({darkMode:t=!0,primaryColor:e="#3b82f6",onLogout:r,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:h=!0,showSettingsMenuItem:d=!0,showViewProfileMenuItem:c=!0,profileLabel:b="My Profile",settingsLabel:y="Settings",viewProfileLabel:S="View Profile",logoutLabel:u="Sign Out"})=>{const{baseUrl:j,apiKey:m,appId:A}=ce(),[P,_]=w.useState(!1),[T,M]=w.useState(null),[g,O]=w.useState(!0),[v,U]=w.useState(null),q=w.useRef(null),F=w.useRef(null),[V,Z]=w.useState(!1),[I,J]=w.useState(!1);w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{J(window.innerWidth<768)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]),w.useEffect(()=>{(async()=>{try{if(O(!0),U(null),o){if(!o.id||!o.name||!o.email)throw new Error("Invalid user data provided");M(o)}else if(typeof window<"u"){const E=localStorage.getItem("userInfo");if(E)try{const $=JSON.parse(E);if(!$.id||!$.name||!$.email)throw new Error("Invalid stored user data");M($)}catch($){console.error("Failed to parse stored user data:",$),localStorage.removeItem("userInfo"),U("Invalid user data")}}}catch(E){console.error("User initialization failed:",E),U(E.message||"Failed to load user")}finally{O(!1)}})()},[o]),w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{if(!P||!F.current)return;const E=F.current.getBoundingClientRect(),$=window.innerWidth,N=window.innerHeight,Y=280,ie=$-E.right,he=E.left;N-E.bottom;const Oe=ie>=Y||ie>he;Z(Oe)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const x=N=>{q.current&&!q.current.contains(N.target)&&!F.current?.contains(N.target)&&_(!1)},E=N=>{N.key==="Escape"&&_(!1)},$=()=>{P&&_(!1)};return P&&(document.addEventListener("mousedown",x),document.addEventListener("keydown",E),window.addEventListener("scroll",$)),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",E),window.removeEventListener("scroll",$)}},[P]);const z=t?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:e,accentHover:`${e}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:e,accentHover:`${e}e6`,error:"#ef4444"},R={wrapper:{position:"relative",display:"inline-block"},avatarButton:{display:"flex",alignItems:"center",gap:I?"6px":"8px",padding:I?"6px 10px 6px 6px":"8px 12px 8px 8px",borderRadius:"24px",backgroundColor:z.surface,cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",minWidth:I?"auto":"140px",maxWidth:I?"200px":"none",outline:"none"},avatarImage:{width:I?"28px":"32px",height:I?"28px":"32px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},userInfo:{display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1,minWidth:0,overflow:"hidden"},userName:{fontSize:I?"13px":"14px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},userEmail:{fontSize:I?"11px":"12px",color:z.textTertiary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},chevron:{transition:"transform 0.2s ease",transform:P?"rotate(180deg)":"rotate(0deg)",color:z.textTertiary,flexShrink:0},dropdown:{position:"absolute",top:"100%",marginTop:"8px",[V?"left":"right"]:"0",backgroundColor:z.surfaceElevated,border:`1px solid ${z.border}`,borderRadius:"12px",boxShadow:"0 20px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1)",width:"min(280px, 90vw)",maxWidth:"calc(100vw - 20px)",padding:"6px 6px 16px 6px",zIndex:1e3,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",opacity:P?1:0,pointerEvents:P?"auto":"none",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",transform:P?"translateY(0) scale(1)":"translateY(-8px) scale(0.95)",overflow:"hidden"},dropdownSection:{padding:I?"10px 12px":"0px 16px","&:last-child":{borderBottom:"none"}},userSection:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"14px":"16px"},dropdownAvatar:{width:I?"40px":"48px",height:I?"40px":"48px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},dropdownUserInfo:{display:"flex",flexDirection:"column",flex:1,minWidth:0},dropdownUserName:{fontSize:I?"15px":"16px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis"},dropdownUserEmail:{fontSize:I?"13px":"14px",color:z.textSecondary,lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis"},menuItem:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",color:z.textPrimary,textDecoration:"none",border:"none",background:"none",width:"100%",fontSize:I?"13px":"14px",textAlign:"left",outline:"none"},menuItemText:{flex:1},icon:{width:I?"16px":"18px",height:I?"16px":"18px",color:z.textSecondary,flexShrink:0},logoutButton:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",background:"none",border:"none",width:"100%",fontSize:I?"13px":"14px",color:z.error,textAlign:"left",outline:"none"},loadingText:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px"},errorState:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",flexDirection:"column"},retryButton:{marginTop:"8px",padding:"8px 16px",backgroundColor:z.accent,color:"#ffffff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:500,transition:"background-color 0.2s ease"}},K=async()=>{U(null),O(!0);try{const x=localStorage.getItem("userInfo");if(x){const E=JSON.parse(x);M(E)}else o&&M(o)}catch(x){console.error("Retry failed:",x),U("Invalid user data"),localStorage.removeItem("userInfo"),M(null)}finally{O(!1)}},te=(x,E)=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),E())},X=()=>i||T?.profileUrl,f=()=>{const x=X();x&&window.open(x,"_self","noopener,noreferrer")},k=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return n.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?n.jsx("div",{ref:F,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T?.name||"User"}'s avatar`,style:{width:I?"34px":"36px",height:I?"34px":"36px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy",onError:x=>{const E=x.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):n.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`,alt:"Default user avatar",style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy"})}):n.jsxs("div",{ref:F,style:R.avatarButton,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover,x.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.surface,x.currentTarget.style.boxShadow="none"},onBlur:x=>{x.currentTarget.style.outline="none"},children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:x=>{const E=x.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):n.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&n.jsxs("div",{style:R.userInfo,children:[n.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&n.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),n.jsx(Fn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&n.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?n.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:x=>{const E=x.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):n.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`,alt:`${T.name}'s default avatar`,style:R.dropdownAvatar,loading:"lazy"}),n.jsxs("div",{style:R.dropdownUserInfo,children:[n.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),n.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),n.jsxs("div",{style:R.dropdownSection,children:[h&&X()&&n.jsxs("button",{style:R.menuItem,onClick:f,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,f),role:"menuitem",tabIndex:0,children:[n.jsx(Se,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&n.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,k),role:"menuitem",tabIndex:0,children:[n.jsx(Xn,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:y})]}),c&&T.profileUrl&&n.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[n.jsx(ue,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:S})]})]}),n.jsx("div",{style:R.dropdownSection,children:n.jsxs("button",{style:R.logoutButton,onClick:r,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,r),role:"menuitem",tabIndex:0,children:[n.jsx(it,{style:{...R.icon,color:z.error},"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:u})]})})]}):n.jsxs("div",{style:R.errorState,role:"alert",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(le,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&n.jsx("button",{style:R.retryButton,onClick:K,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.accentHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.accent},children:"Try Again"})]})})]})},cs=({user:t,darkMode:e=!0,primaryColor:r="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ce(),[l,h]=w.useState({email:t?.email||"",otp:"",appId:o}),[d,c]=w.useState(!1),[b,y]=w.useState(!1),[S,u]=w.useState(null),j=(g,O)=>{let v=parseInt(g.replace("#",""),16),U=(v>>16)+O,q=(v>>8&255)+O,F=(v&255)+O;return U=Math.min(255,Math.max(0,U)),q=Math.min(255,Math.max(0,q)),F=Math.min(255,Math.max(0,F)),`#${(F|q<<8|U<<16).toString(16).padStart(6,"0")}`},m=e?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#d97706"};w.useEffect(()=>{t?.email&&h(g=>({...g,email:t.email}))},[t?.email]);const A=(g,O)=>{u({type:g,message:O}),setTimeout(()=>u(null),3e3)},P=async()=>{if(!l.email||!/\S+@\S+\.\S+/.test(l.email)){A("error","Please enter a valid email");return}try{y(!0);const g=await W.post(`${a}/users/send-verify-otp/${t?.id}`,{email:l.email},{headers:{"x-api-key":i,"x-app-id":o}});g.data.success?(A("success",g.data.message||"OTP sent!"),c(!0)):A("error",g.data.message||"Failed to send OTP")}catch(g){A("error",g.response?.data?.message||"Server error")}finally{y(!1)}},_=async g=>{if(g.preventDefault(),!l.email||!l.otp){A("error","Please fill in all fields");return}try{y(!0);const O=await W.post(`${a}/users/verify-email`,l);if(O.data.success&&t){const v={...t,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),c(!1),h({email:t.email,otp:"",appId:o})}else A("error",O.data.message||"Verification failed")}catch(O){A("error",O.response?.data?.message||"Server error")}finally{y(!1)}},T={width:"100%",padding:"12px 12px 12px 40px",borderRadius:8,border:`1px solid ${m.border}`,backgroundColor:m.surfaceLight,color:m.textPrimary,fontSize:14,outline:"none"},M=(g=!1)=>({flex:1,padding:12,borderRadius:8,color:"#fff",fontWeight:500,cursor:g?"not-allowed":"pointer",background:`linear-gradient(to right, ${m.accent}, ${m.accentHover})`,opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,fontSize:14,border:"none"});return n.jsxs("form",{onSubmit:_,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&n.jsxs("div",{style:{padding:"12px 20px",borderRadius:12,fontSize:13,fontWeight:500,color:S.type==="success"?m.success:m.warning,border:`1px solid ${S.type==="success"?m.success:m.warning}`,backgroundColor:S.type==="success"?`${m.success}20`:`${m.warning}20`,display:"flex",alignItems:"center",gap:8},children:[S.type==="success"?n.jsx(de,{size:16}):n.jsx(le,{size:16}),S.message]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"Email"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ue,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"email",value:l.email,onChange:g=>h(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"text",value:l.otp,onChange:g=>h(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),n.jsx("div",{style:{display:"flex",gap:12},children:d?n.jsxs("button",{type:"submit",disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:P,disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=On,Q.ReactEmailVerification=cs,Q.ReactSignedIn=rs,Q.ReactSignedOut=ns,Q.ReactUserButton=ds,Q.ReactUserLogin=ts,Q.ReactUserProfile=ls,Q.ReactUserSignUp=Qn,Q.getSdkConfig=ce,Q.setSdkConfig=Zn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
@@ -5,7 +5,6 @@ interface ReactSignedInProps {
5
5
  className?: string;
6
6
  width?: string;
7
7
  height?: string;
8
- appId: string;
9
8
  }
10
9
  export declare const ReactSignedIn: React.FC<ReactSignedInProps>;
11
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SignedIn.d.ts","sourceRoot":"","sources":["../../src/react/SignedIn.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE9D,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoFtD,CAAC"}
1
+ {"version":3,"file":"SignedIn.d.ts","sourceRoot":"","sources":["../../src/react/SignedIn.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAG9D,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqFtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuctra/authix",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "Universal authentication SDK and UI components for React (v16–v19) with TailwindCSS.",
5
5
  "author": "Taha Asif",
6
6
  "license": "MIT",