import u from "./accelbyte-widgets210.mjs";
import { Ctx as g } from "./accelbyte-widgets33.mjs";
import { AccPath as E } from "./accelbyte-widgets34.mjs";
import { FeUtils as h } from "./accelbyte-widgets45.mjs";
import e from "react";
import { Trans as i } from "react-i18next";
import { AccountHistoryLogic as y, EditableInputWithHistory as A } from "./accelbyte-widgets324.mjs";
import { AccountHistoryPageDetail as H } from "./accelbyte-widgets325.mjs";
import { EditorTypePreview as f } from "./accelbyte-widgets326.mjs";
class D extends e.Component {
  constructor(t) {
    var r;
    super(t), this.renderTableHistories = (s) => /* @__PURE__ */ e.createElement("table", { className: "historyTable common" }, /* @__PURE__ */ e.createElement("thead", null, /* @__PURE__ */ e.createElement("tr", null, /* @__PURE__ */ e.createElement("th", null, /* @__PURE__ */ e.createElement(i, { i18nKey: "EmailAddressAccountHistoryPage.emailAddress" }, "Email Address")), /* @__PURE__ */ e.createElement("th", null, /* @__PURE__ */ e.createElement(i, { i18nKey: "EmailAddressAccountHistoryPage.date" }, "Date")), /* @__PURE__ */ e.createElement("th", null, /* @__PURE__ */ e.createElement(i, { i18nKey: "EmailAddressAccountHistoryPage.editedBy" }, "Edited By")))), /* @__PURE__ */ e.createElement("tbody", null, s.map((a) => /* @__PURE__ */ e.createElement("tr", { key: a.timestamp }, /* @__PURE__ */ e.createElement("td", null, a.payload && a.payload.userAccount && a.payload.userAccount.emailAddress), /* @__PURE__ */ e.createElement("td", null, h.formatDate(a.timestamp, { type: "dynamic", format: "LL" })), /* @__PURE__ */ e.createElement("td", null, /* @__PURE__ */ e.createElement(f, { history: a })))))), this.appState = g.getAppState(), this.logic = new y({
      userId: ((r = this.appState.getUser()) == null ? void 0 : r.userId) || "",
      page: t.page,
      startDate: t.startDate,
      endDate: t.endDate,
      type: A.enum.email,
      appState: this.appState
    }), this.logic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    this.logic.fetchAccountHistoryData();
  }
  render() {
    var o;
    const { startDate: t, endDate: r } = this.logic.state, { accountHistory: s, errorFetchingHistory: a, isFetchingHistory: c } = this.appState.getUserManager().state, { changeEndDate: l, changeStartDate: m } = this.logic, { page: d } = this.props, p = ((o = this.appState.getUser()) == null ? void 0 : o.userId) || "";
    return /* @__PURE__ */ e.createElement(
      H,
      {
        changeEndDate: l,
        changeStartDate: m,
        editHistory: s,
        endDate: r,
        startDate: t,
        fetchError: a,
        isFetching: c,
        page: d,
        paginationPath: E.EmailHistory.makePath(),
        userId: p,
        renderTableHistories: this.renderTableHistories
      }
    );
  }
}
const K = u(D, (n, t) => n.page !== t.page);
export {
  K as EmailAddressAccountHistoryPage
};
