import { CommonError as l } from "./accelbyte-widgets124.mjs";
import { Loading as d, LoadingSize as g } from "./accelbyte-widgets136.mjs";
import { Pagination as u } from "./accelbyte-widgets256.mjs";
import { t as s } from "./accelbyte-widgets58.mjs";
import c from "./accelbyte-widgets210.mjs";
import { SkeletonGameCards as h } from "./accelbyte-widgets531.mjs";
import { Ctx as n } from "./accelbyte-widgets33.mjs";
import { ItemType as S } from "./accelbyte-widgets185.mjs";
import { EcomPath as p } from "./accelbyte-widgets59.mjs";
import { PageTitleUtils as f } from "./accelbyte-widgets188.mjs";
import { ItemListingAppManager as C } from "./accelbyte-widgets532.mjs";
import r from "react";
import { Helmet as E } from "react-helmet";
import { Trans as L } from "react-i18next";
import "./accelbyte-widgets193.mjs";
import { StoreGridItem as y } from "./accelbyte-widgets416.mjs";
class P extends r.Component {
  constructor(e) {
    super(e), this.appStoreLogic = new C(n.getAppState().getSdk()), this.appStoreLogic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    const { page: e, pageSize: t, country: o, language: i } = this.props;
    this.appStoreLogic.getItemsByCriteria({ page: e, pageSize: t, country: o, language: i, itemType: S.enum.CODE }), this.appStoreLogic.getCurrencyMap();
  }
  renderCodeItems() {
    const { platformItemsList: e, currencyMap: t } = this.appStoreLogic.state;
    return /* @__PURE__ */ r.createElement("div", { className: "bundlesList" }, !t && /* @__PURE__ */ r.createElement(h, { numberOfCards: e == null ? void 0 : e.data.length }), !!e && t && e.data.map((o) => /* @__PURE__ */ r.createElement(y, { key: o.itemId, item: o, currencyMap: t })));
  }
  renderGamePagination() {
    const { platformItemsList: e } = this.appStoreLogic.state;
    if (!e)
      return;
    const { paging: t } = e, o = !!(t != null && t.next), i = !!(t != null && t.previous), m = this.props.page;
    return /* @__PURE__ */ r.createElement("div", { className: "pagination" }, /* @__PURE__ */ r.createElement(
      u,
      {
        next: o && p.CodeList.withSearchParams({ page: m + 1 }),
        prev: i && p.CodeList.withSearchParams({ page: m - 1 })
      }
    ));
  }
  render() {
    const { error: e, isFetching: t, platformItemsList: o } = this.appStoreLogic.state;
    return /* @__PURE__ */ r.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ r.createElement(E, null, /* @__PURE__ */ r.createElement("title", null, f.getPageTitle(n.getAppState().state.discovery || null, s("CodeStore.title"), s("CodeStore.title")))), t && /* @__PURE__ */ r.createElement(d, { className: g.medium }, /* @__PURE__ */ r.createElement(L, { i18nKey: "InitialUserFetchPage.notice" })), !t && e && /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(l, { error: e })), !t && o && this.renderCodeItems(), !t && o && this.renderGamePagination());
  }
}
const I = c(P, (a, e) => a.country !== e.country), B = c(
  ({ page: a, pageSize: e, language: t }) => {
    const o = n.getAppState().getUser(), i = o && o.country || void 0;
    return /* @__PURE__ */ r.createElement(I, { page: a, pageSize: e, country: i, language: t });
  },
  (a, e) => e.page !== a.page || e.language !== a.language
);
export {
  P as CodeStore,
  B as default
};
