import { A as m, b as u, a as d } from "./AccountMainSection-4c35f8d7.mjs";
import { a as r, g as l, h as p, i as h, T as a, $ as g, t as y, f, S as D, x as E, j as w } from "./index-162fd1aa.mjs";
import e from "react";
import { A } from "./AccountDeletionSuccessPageLock-3a9c670d.mjs";
import { Link as P } from "react-router-dom";
import { g as S } from "./MockVars-1cf2eb0a.mjs";
import "./reactSlick-cb4a2d39.mjs";
import "./dateFns-2367ee5b.mjs";
import "./reactPlayer-2f69f369.mjs";
import "./validator-61879ab7.mjs";
const b = ({ className: c }) => /* @__PURE__ */ e.createElement("i", { className: c }, /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 48 48" }, /* @__PURE__ */ e.createElement("mask", { id: "a", width: "48", height: "48", x: "0", y: "0", maskUnits: "userSpaceOnUse" }, /* @__PURE__ */ e.createElement("path", { fill: "#fff", d: "M0 0H48V48H0z" })), /* @__PURE__ */ e.createElement("g", { fill: "#fff", fillRule: "evenodd", clipRule: "evenodd", mask: "url(#a)" }, /* @__PURE__ */ e.createElement("path", { d: "M12.147 14.823a9.5 9.5 0 015.489.54 1.5 1.5 0 11-1.149 2.772 6.5 6.5 0 00-6.098 11.41 1.5 1.5 0 11-1.667 2.495 9.5 9.5 0 013.425-17.217zM36.658 16.804A8.495 8.495 0 0035 16.641a1.5 1.5 0 000 3 5.501 5.501 0 013.056 10.073 1.5 1.5 0 001.666 2.494 8.5 8.5 0 00-3.064-15.404z" }), /* @__PURE__ */ e.createElement("path", { d: "M30.39 8.58a11.5 11.5 0 014.889 11.806 1.5 1.5 0 11-2.942-.585 8.5 8.5 0 00-16.446-4.209 1.5 1.5 0 11-2.861-.9A11.5 11.5 0 0130.39 8.58zM24 41.5a1.5 1.5 0 001.5-1.5V22a1.5 1.5 0 00-3 0v18a1.5 1.5 0 001.5 1.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M22.94 41.06a1.5 1.5 0 002.12 0l8-8a1.5 1.5 0 00-2.12-2.12L24 37.878l-6.94-6.94a1.5 1.5 0 00-2.12 2.122l8 8z" })))), v = "accountDeletionPage _accountDeletionPage_98efa", N = {
  accountDeletionPage: v
};
class R extends e.Component {
  constructor(n) {
    super(n), this.notifyAccountDeletionSuccess = () => {
      const { appHistory: t } = r.getAppState().state;
      A.lock(), t.push(l.AccountDeletionSuccess.link);
    }, this.notifyAccountDeletionError = (t) => {
      this.setState({
        alert: {
          type: p.danger,
          element: /* @__PURE__ */ e.createElement(h, { error: t })
        }
      });
    }, this.onPasswordChange = (t) => {
      this.setState({
        password: t.target.value
      });
    }, this.requestAccountDeletion = async (t) => {
      t.preventDefault();
      const { password: s } = this.state, { user: o } = this.appState.getUserManager().state;
      o && (this.setState({ password: "" }), this.logic.deleteAccount(s, o.userId).then(() => {
        this.notifyAccountDeletionSuccess();
      }).catch((i) => {
        this.notifyAccountDeletionError(i);
      }));
    }, this.renderFormPassword = () => {
      const { password: t } = this.state, { isRequestingDeletion: s } = this.logic.state, o = this.props.isPreviewMode;
      return /* @__PURE__ */ e.createElement("form", { className: "formPassword", onSubmit: this.requestAccountDeletion }, /* @__PURE__ */ e.createElement("label", { className: "passwordLabel" }, /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.form.passwordLabel" }, "If you are ready to delete your account, input your password to proceed the deletion")), /* @__PURE__ */ e.createElement(
        g,
        {
          type: "password",
          value: o ? S : t,
          name: "password",
          className: "passwordInput",
          placeholder: y("AccountDeletionPage.form.passwordPlaceholder"),
          onChange: this.onPasswordChange,
          readOnly: o
        }
      ), /* @__PURE__ */ e.createElement(f, { disabled: !t || s, className: "btn big btn-primary btnDelete", type: "submit" }, s ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(D, { className: `${E.inline} spinner` }), /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.form.processing" }, "Processing")) : /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.form.deleteAccountButton" }, "Delete my Account")));
    }, this.appState = r.getAppState(), this.logic = this.appState.getGdprManager(), this.logic.subscribe(() => this.setState({})), this.state = {
      password: "",
      alert: null
    };
  }
  render() {
    const { alert: n } = this.state, { isRequestingDeletion: t } = this.logic.state;
    return /* @__PURE__ */ e.createElement(m, { className: N.accountDeletionPage }, /* @__PURE__ */ e.createElement(u, null, /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.title" }, "Account Deletion")), /* @__PURE__ */ e.createElement(d, { className: "mainBody min-w-xl" }, !!n && !t && /* @__PURE__ */ e.createElement(w, { type: n.type, className: "alert", onDismiss: () => this.setState({ alert: null }) }, n.element), /* @__PURE__ */ e.createElement("div", { className: "warningDeleteAccountMessage" }, /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.warningDeleteAccount" }, /* @__PURE__ */ e.createElement("p", null, "This action cannot be undone and it will permanently erase your account. Once the deletion process has begun, you won't be able to reactivate your account or retrieve any of the content of information that you've added."), /* @__PURE__ */ e.createElement("p", { className: "bottom" }, "Before you delete your account, you might like to:"))), /* @__PURE__ */ e.createElement("div", { className: "downloadPersonalDataContainer" }, /* @__PURE__ */ e.createElement(b, { className: "icon" }), /* @__PURE__ */ e.createElement("div", { className: "messageContainer" }, /* @__PURE__ */ e.createElement(a, { i18nKey: "AccountDeletionPage.downloadPersonalData" }, /* @__PURE__ */ e.createElement("p", { className: "downloadAccount" }, "Download your account information & data"), /* @__PURE__ */ e.createElement("p", { className: "savePersonalData" }, "You can save your personal data before your account is permanently deleted"), /* @__PURE__ */ e.createElement(P, { to: l.PersonalData.makePath(), className: "btnDownload" }, "Download Personal Data")))), this.renderFormPassword()));
  }
}
export {
  R as default
};
