import { jsx as e, jsxs as t, Fragment as j } from "react/jsx-runtime";
import { useState as n } from "react";
import { useNavigate as E } from "react-router-dom";
import { useTranslation as S } from "react-i18next";
import { CheckCircle as p, Lock as T, AlertTriangle as F, EyeOff as x, Eye as P, Loader2 as L } from "lucide-react";
import { d as $ } from "./index-CeEMms9z.js";
function Y() {
  const { t: r } = S(), b = E(), [d, v] = n(""), [o, y] = n(""), [c, N] = n(""), [l, C] = n(!1), [i, q] = n(!1), [h, m] = n(!1), [w, u] = n(null), [A, k] = n(!1), R = ((a) => {
    const s = [];
    return a.length < 8 && s.push(r("auth.forceChangePasswordPage.passwordRequirements_1", "At least 8 characters")), /[A-Z]/.test(a) || s.push(r("auth.forceChangePasswordPage.passwordRequirements_2", "At least one uppercase letter")), /[a-z]/.test(a) || s.push(r("auth.forceChangePasswordPage.passwordRequirements_3", "At least one lowercase letter")), /[0-9]/.test(a) || s.push(r("auth.forceChangePasswordPage.passwordRequirements_4", "At least one number")), s;
  })(o), g = o === c && R.length === 0 && d.length > 0, _ = async (a) => {
    if (a.preventDefault(), !!g) {
      m(!0), u(null);
      try {
        await $.changePassword(d, o), k(!0), setTimeout(() => {
          b("/");
        }, 2e3);
      } catch (s) {
        s instanceof Error ? u(s.message) : u(r("common:errors.generic", "An error occurred. Please try again."));
      } finally {
        m(!1);
      }
    }
  };
  return A ? /* @__PURE__ */ e("div", { className: "min-h-screen flex items-center justify-center bg-[var(--bg-secondary)] p-4", children: /* @__PURE__ */ t("div", { className: "w-full max-w-md bg-[var(--bg-card)] rounded-2xl shadow-xl p-8 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(p, { className: "w-8 h-8 text-[var(--success-text)]" }) }),
    /* @__PURE__ */ e("h2", { className: "text-2xl font-bold text-[var(--text-primary)] mb-2", children: r("auth.forceChangePasswordPage.successTitle", "Password Changed") }),
    /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: r("auth.forceChangePasswordPage.successMessage", "You will be redirected to home...") })
  ] }) }) : /* @__PURE__ */ e("div", { className: "min-h-screen flex items-center justify-center bg-[var(--bg-secondary)] p-4", children: /* @__PURE__ */ e("div", { className: "w-full max-w-md", children: /* @__PURE__ */ t("div", { className: "bg-[var(--bg-card)] rounded-2xl shadow-xl p-8", children: [
    /* @__PURE__ */ t("div", { className: "text-center mb-8", children: [
      /* @__PURE__ */ e("div", { className: "w-16 h-16 bg-[var(--warning-bg)] rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ e(T, { className: "w-8 h-8 text-[var(--warning-text)]" }) }),
      /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: r("auth.forceChangePasswordPage.title", "Password Change Required") }),
      /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mt-2", children: r("auth.forceChangePasswordPage.description", "For security reasons, you must set a new password.") })
    ] }),
    w && /* @__PURE__ */ t("div", { className: "mb-6 p-4 rounded-xl bg-[var(--error-bg)] text-[var(--error-text)] flex items-center gap-2", children: [
      /* @__PURE__ */ e(F, { className: "w-5 h-5 flex-shrink-0" }),
      /* @__PURE__ */ e("span", { children: w })
    ] }),
    /* @__PURE__ */ t("form", { onSubmit: _, className: "space-y-6", children: [
      /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1", children: r("auth.forceChangePasswordPage.currentPassword", "Current Password") }),
        /* @__PURE__ */ t("div", { className: "relative", children: [
          /* @__PURE__ */ e(
            "input",
            {
              type: l ? "text" : "password",
              required: !0,
              value: d,
              onChange: (a) => v(a.target.value),
              className: "w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-card)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--info-border)]",
              placeholder: r("auth.forceChangePasswordPage.currentPasswordPlaceholder", "Enter the password provided by the administrator")
            }
          ),
          /* @__PURE__ */ e(
            "button",
            {
              type: "button",
              onClick: () => C(!l),
              className: "absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",
              children: l ? /* @__PURE__ */ e(x, { className: "w-5 h-5" }) : /* @__PURE__ */ e(P, { className: "w-5 h-5" })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1", children: r("auth.forceChangePasswordPage.newPassword", "New Password") }),
        /* @__PURE__ */ t("div", { className: "relative", children: [
          /* @__PURE__ */ e(
            "input",
            {
              type: i ? "text" : "password",
              required: !0,
              value: o,
              onChange: (a) => y(a.target.value),
              className: "w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-card)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--info-border)]",
              placeholder: r("auth.forceChangePasswordPage.newPasswordPlaceholder", "Choose a new password")
            }
          ),
          /* @__PURE__ */ e(
            "button",
            {
              type: "button",
              onClick: () => q(!i),
              className: "absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]",
              children: i ? /* @__PURE__ */ e(x, { className: "w-5 h-5" }) : /* @__PURE__ */ e(P, { className: "w-5 h-5" })
            }
          )
        ] }),
        o && /* @__PURE__ */ e("div", { className: "mt-2 space-y-1", children: [
          r("auth.forceChangePasswordPage.passwordRequirements_1", "At least 8 characters"),
          r("auth.forceChangePasswordPage.passwordRequirements_2", "At least one uppercase letter"),
          r("auth.forceChangePasswordPage.passwordRequirements_3", "At least one lowercase letter"),
          r("auth.forceChangePasswordPage.passwordRequirements_4", "At least one number")
        ].map((a, s) => {
          const f = [
            o.length >= 8,
            /[A-Z]/.test(o),
            /[a-z]/.test(o),
            /[0-9]/.test(o)
          ];
          return /* @__PURE__ */ t("div", { className: `flex items-center gap-2 text-sm ${f[s] ? "text-[var(--success-text)]" : "text-[var(--text-tertiary)]"}`, children: [
            f[s] ? /* @__PURE__ */ e(p, { className: "w-4 h-4" }) : /* @__PURE__ */ e("div", { className: "w-4 h-4 rounded-full border border-current" }),
            a
          ] }, `pwd-req-${s}`);
        }) })
      ] }),
      /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1", children: r("auth.forceChangePasswordPage.confirmPassword", "Confirm Password") }),
        /* @__PURE__ */ e(
          "input",
          {
            type: "password",
            required: !0,
            value: c,
            onChange: (a) => N(a.target.value),
            className: `w-full px-4 py-3 rounded-xl border ${c && c !== o ? "border-[var(--error-border)] focus:ring-[var(--error-border)]" : "border-[var(--border-color)] focus:ring-[var(--info-border)]"} bg-[var(--bg-card)] text-[var(--text-primary)] focus:outline-none focus:ring-2`,
            placeholder: r("auth.forceChangePasswordPage.confirmPasswordPlaceholder", "Confirm your new password")
          }
        ),
        c && c !== o && /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-[var(--error-text)]", children: r("auth.forceChangePasswordPage.passwordMismatch", "Passwords do not match") })
      ] }),
      /* @__PURE__ */ e(
        "button",
        {
          type: "submit",
          disabled: !g || h,
          className: "w-full py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:opacity-90 text-white font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",
          children: h ? /* @__PURE__ */ t(j, { children: [
            /* @__PURE__ */ e(L, { className: "w-5 h-5 animate-spin" }),
            /* @__PURE__ */ e("span", { children: r("auth.forceChangePasswordPage.submitting", "Changing...") })
          ] }) : /* @__PURE__ */ e("span", { children: r("auth.forceChangePasswordPage.submitButton", "Change Password") })
        }
      )
    ] })
  ] }) }) });
}
export {
  Y as ForceChangePasswordPage
};
//# sourceMappingURL=ForceChangePasswordPage-DFvUScEO.js.map
