import { AccountPageMobileNavigation as d } from "./accelbyte-widgets232.mjs";
import { AccountPageDesktopNavigation as p } from "./accelbyte-widgets233.mjs";
import { InputValidationOutdatedModal as u } from "./accelbyte-widgets141.mjs";
import { Loading as g } from "./accelbyte-widgets136.mjs";
import { UIEvent as m } from "./accelbyte-widgets138.mjs";
import { Ctx as s } from "./accelbyte-widgets33.mjs";
import { EcommerceErrorCode as f } from "./accelbyte-widgets185.mjs";
import { AccPath as h } from "./accelbyte-widgets34.mjs";
import { ErrorHelper as E } from "./accelbyte-widgets120.mjs";
import e from "react";
import P from "./accelbyte-widgets234.mjs";
import { Platform as M, ErrorEntity as S } from "@accelbyte/sdk-platform";
class _ extends e.Component {
  constructor(o) {
    super(o), this.init = async () => {
      var i;
      const a = (i = s.getAppState().getUser()) == null ? void 0 : i.userId;
      try {
        if (this.setState({ isLoading: !0 }), !a)
          return;
        const n = /* @__PURE__ */ new Set();
        await Promise.all([
          await M.PaymentAccountApi(s.getAppState().getSdk()).getPaymentAccounts_ByUserId(a).catch((t) => {
            var r, c, l;
            E.isAxiosError(t) && ((c = S.safeParse((r = t == null ? void 0 : t.response) == null ? void 0 : r.data)) != null && c.success) && ((l = t == null ? void 0 : t.response) == null ? void 0 : l.data.errorCode) === f.PAYMENT_METHOD_SAVING_UNSUPPORTED && n.add(h.PaymentMethods.link);
          })
        ]), this.setState({ listHiddenMenu: n });
      } catch (n) {
        console.error(n);
      } finally {
        this.setState({ isLoading: !1 });
      }
    }, this.state = {
      isLoading: !1,
      listHiddenMenu: /* @__PURE__ */ new Set()
    }, this.appState = s.getAppState(), s.getInputValidationManager().subscribe(() => this.setState({}));
  }
  async componentDidMount() {
    if (this.props.isPreviewMode)
      return;
    this.init(), m.updateBackground(`url(${this.props.backgroundImageUrl})`);
    const {
      miscAppManager: {
        state: { countries: o },
        fetchCountries: a
      },
      userAppManager: {
        state: { user: i },
        fetchCurrentUserInformation: n
      }
    } = this.appState;
    await Promise.allSettled([!o.length && a(), !i && n()]), s.getInputValidationManager().state.validations.length === 0 && s.getInputValidationManager().fetchValidations();
  }
  componentWillUnmount() {
    m.updateBackground(null);
  }
  render() {
    const { children: o, accountPageNav: a, isPreviewMode: i } = this.props;
    return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "accountPage" }, /* @__PURE__ */ e.createElement("div", { className: "userProfilePreviewContainer" }, /* @__PURE__ */ e.createElement("div", { className: "sideEmptySpace" }), /* @__PURE__ */ e.createElement("section", { className: "accountPageSubpages" }, /* @__PURE__ */ e.createElement(P, { isPreviewMode: i }))), /* @__PURE__ */ e.createElement("div", { className: "mainContainer" }, /* @__PURE__ */ e.createElement("div", { className: "sidebar" }, /* @__PURE__ */ e.createElement(
      p,
      {
        accountPageNav: a,
        isLoading: this.state.isLoading,
        listHiddenMenu: this.state.listHiddenMenu
      }
    )), /* @__PURE__ */ e.createElement("div", { className: "sidebar mobile" }, /* @__PURE__ */ e.createElement(d, { isLoading: this.state.isLoading, listHiddenMenu: this.state.listHiddenMenu, ...this.props })), /* @__PURE__ */ e.createElement("section", { className: "accountPageSubpages" }, /* @__PURE__ */ e.createElement(e.Suspense, { fallback: /* @__PURE__ */ e.createElement(g, null) }, o)))), /* @__PURE__ */ e.createElement(u, null));
  }
}
export {
  _ as default
};
