import { jsx as e, jsxs as t, Fragment as y } from "react/jsx-runtime";
import { useState as s, useEffect as A } from "react";
import { useTranslation as D } from "react-i18next";
import { useSearchParams as F, useNavigate as M, Link as f } from "react-router-dom";
import { XCircle as P, CheckCircle2 as O, Lock as p, AlertCircle as K, EyeOff as N, Eye as k, Loader2 as R } from "lucide-react";
import { T as q, d as B } from "./index-CeEMms9z.js";
function G() {
  const { t: r } = D("auth"), [C] = F(), T = M(), l = C.get("token"), [n, j] = s(""), [v, E] = s(""), [m, S] = s(!1), [x, L] = s(!1), [i, g] = s(!1), [c, h] = s("form"), [d, a] = s(null);
  A(() => {
    l || (h("invalid_token"), a(r("resetPasswordPage.invalidToken")));
  }, [l, r]);
  const I = () => n.length < 8 ? (a(r("resetPasswordPage.passwordTooShort")), !1) : n !== v ? (a(r("resetPasswordPage.passwordMismatch")), !1) : !0, _ = async (o) => {
    if (o.preventDefault(), a(null), !(!I() || !l)) {
      g(!0);
      try {
        await B.resetPassword(l, n), h("success");
      } catch (b) {
        const w = b, u = b?.code;
        u === "TOKEN_EXPIRED" || u === "TOKEN_ALREADY_USED" || u === "INVALID_TOKEN" ? (h("error"), a(w?.message || r("resetPasswordPage.errorMessage"))) : a(w?.message || r("common:error"));
      } finally {
        g(!1);
      }
    }
  };
  return /* @__PURE__ */ e("div", { className: "min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-8", children: /* @__PURE__ */ t("div", { className: "w-full max-w-md", children: [
    /* @__PURE__ */ e("div", { className: "flex justify-end mb-8", children: /* @__PURE__ */ e(q, {}) }),
    /* @__PURE__ */ t("div", { className: "bg-[var(--bg-secondary)] rounded-2xl shadow-xl p-8", children: [
      c === "invalid_token" && /* @__PURE__ */ t("div", { className: "text-center", children: [
        /* @__PURE__ */ e("div", { className: "w-16 h-16 bg-[var(--error-bg)] rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ e(P, { className: "w-10 h-10 text-[var(--error-text)]" }) }),
        /* @__PURE__ */ e("h2", { className: "text-xl font-semibold text-[var(--text-primary)] mb-2", children: r("resetPasswordPage.errorTitle") }),
        /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mb-6", children: d }),
        /* @__PURE__ */ e(
          f,
          {
            to: "/forgot-password",
            className: "inline-flex items-center justify-center gap-2 px-6 py-3 bg-[var(--color-accent-600)] text-white rounded-lg font-medium hover:opacity-90 transition-colors",
            children: r("forgotPasswordPage.pageTitle")
          }
        )
      ] }),
      c === "error" && /* @__PURE__ */ t("div", { className: "text-center", children: [
        /* @__PURE__ */ e("div", { className: "w-16 h-16 bg-[var(--error-bg)] rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ e(P, { className: "w-10 h-10 text-[var(--error-text)]" }) }),
        /* @__PURE__ */ e("h2", { className: "text-xl font-semibold text-[var(--text-primary)] mb-2", children: r("resetPasswordPage.errorTitle") }),
        /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mb-6", children: d }),
        /* @__PURE__ */ e(
          f,
          {
            to: "/forgot-password",
            className: "inline-flex items-center justify-center gap-2 px-6 py-3 bg-[var(--color-accent-600)] text-white rounded-lg font-medium hover:opacity-90 transition-colors",
            children: r("forgotPasswordPage.pageTitle")
          }
        )
      ] }),
      c === "success" && /* @__PURE__ */ t("div", { className: "text-center", children: [
        /* @__PURE__ */ e("div", { className: "w-16 h-16 bg-[var(--success-bg)] rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ e(O, { className: "w-10 h-10 text-[var(--success-text)]" }) }),
        /* @__PURE__ */ e("h2", { className: "text-xl font-semibold text-[var(--text-primary)] mb-2", children: r("resetPasswordPage.successTitle") }),
        /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mb-6", children: r("resetPasswordPage.successMessage") }),
        /* @__PURE__ */ e(
          "button",
          {
            onClick: () => T("/login"),
            className: "inline-flex items-center justify-center gap-2 px-6 py-3 bg-[var(--color-accent-600)] text-white rounded-lg font-medium hover:opacity-90 transition-all",
            children: r("confirmEmailPage.signIn")
          }
        )
      ] }),
      c === "form" && /* @__PURE__ */ t(y, { children: [
        /* @__PURE__ */ t("div", { className: "text-center mb-8", children: [
          /* @__PURE__ */ e("div", { className: "w-16 h-16 bg-[var(--info-bg)] rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ e(p, { className: "w-8 h-8 text-[var(--info-text)]" }) }),
          /* @__PURE__ */ e("h2", { className: "text-2xl font-bold text-[var(--text-primary)] mb-2", children: r("resetPasswordPage.submitButton") }),
          /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: r("resetPasswordPage.successMessage") })
        ] }),
        d && /* @__PURE__ */ t("div", { className: "mb-6 p-4 bg-[var(--error-bg)] border border-[var(--error-border)] rounded-lg flex items-start gap-3", children: [
          /* @__PURE__ */ e(K, { className: "w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5" }),
          /* @__PURE__ */ e("p", { className: "text-sm text-[var(--error-text)]", children: d })
        ] }),
        /* @__PURE__ */ t("form", { onSubmit: _, className: "space-y-4", children: [
          /* @__PURE__ */ t("div", { children: [
            /* @__PURE__ */ e("label", { htmlFor: "password", className: "block text-sm font-medium text-[var(--text-secondary)] mb-2", children: r("resetPasswordPage.password") }),
            /* @__PURE__ */ t("div", { className: "relative", children: [
              /* @__PURE__ */ e("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: /* @__PURE__ */ e(p, { className: "h-5 w-5 text-[var(--text-tertiary)]" }) }),
              /* @__PURE__ */ e(
                "input",
                {
                  id: "password",
                  type: m ? "text" : "password",
                  value: n,
                  onChange: (o) => j(o.target.value),
                  className: "block w-full pl-10 pr-10 py-2.5 border border-[var(--border-color)] rounded-lg bg-[var(--bg-card)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:ring-2 focus:ring-[var(--info-border)] focus:border-transparent",
                  placeholder: r("resetPasswordPage.passwordPlaceholder"),
                  required: !0,
                  autoComplete: "new-password",
                  disabled: i
                }
              ),
              /* @__PURE__ */ e(
                "button",
                {
                  type: "button",
                  onClick: () => S(!m),
                  className: "absolute inset-y-0 right-0 pr-3 flex items-center text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",
                  tabIndex: -1,
                  children: m ? /* @__PURE__ */ e(N, { className: "h-5 w-5" }) : /* @__PURE__ */ e(k, { className: "h-5 w-5" })
                }
              )
            ] }),
            /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-[var(--text-tertiary)]", children: r("resetPasswordPage.passwordHint") })
          ] }),
          /* @__PURE__ */ t("div", { children: [
            /* @__PURE__ */ e("label", { htmlFor: "confirmPassword", className: "block text-sm font-medium text-[var(--text-secondary)] mb-2", children: r("resetPasswordPage.confirmPassword") }),
            /* @__PURE__ */ t("div", { className: "relative", children: [
              /* @__PURE__ */ e("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: /* @__PURE__ */ e(p, { className: "h-5 w-5 text-[var(--text-tertiary)]" }) }),
              /* @__PURE__ */ e(
                "input",
                {
                  id: "confirmPassword",
                  type: x ? "text" : "password",
                  value: v,
                  onChange: (o) => E(o.target.value),
                  className: "block w-full pl-10 pr-10 py-2.5 border border-[var(--border-color)] rounded-lg bg-[var(--bg-card)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:ring-2 focus:ring-[var(--info-border)] focus:border-transparent",
                  placeholder: r("resetPasswordPage.passwordPlaceholder"),
                  required: !0,
                  autoComplete: "new-password",
                  disabled: i
                }
              ),
              /* @__PURE__ */ e(
                "button",
                {
                  type: "button",
                  onClick: () => L(!x),
                  className: "absolute inset-y-0 right-0 pr-3 flex items-center text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",
                  tabIndex: -1,
                  children: x ? /* @__PURE__ */ e(N, { className: "h-5 w-5" }) : /* @__PURE__ */ e(k, { className: "h-5 w-5" })
                }
              )
            ] })
          ] }),
          /* @__PURE__ */ e(
            "button",
            {
              type: "submit",
              disabled: i,
              className: "w-full flex items-center justify-center gap-2 px-4 py-3 bg-[var(--color-accent-600)] text-white rounded-lg font-medium hover:opacity-90 disabled:opacity-50 transition-all",
              children: i ? /* @__PURE__ */ t(y, { children: [
                /* @__PURE__ */ e(R, { className: "h-5 w-5 animate-spin" }),
                r("resetPasswordPage.submitting")
              ] }) : r("resetPasswordPage.submitButton")
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { className: "mt-6 pt-6 border-t border-[var(--border-color)]", children: /* @__PURE__ */ e(
        f,
        {
          to: "/login",
          className: "flex items-center justify-center text-sm text-[var(--text-secondary)] hover:text-[var(--info-text)] transition-colors",
          children: r("resetPasswordPage.backToLogin")
        }
      ) })
    ] })
  ] }) });
}
export {
  G as ResetPasswordPage
};
//# sourceMappingURL=ResetPasswordPage-BMGUoGt6.js.map
