import { ItemImageTag as P } from "./accelbyte-widgets192.mjs";
import { EcomPath as h } from "./accelbyte-widgets59.mjs";
import { ItemHelper as v } from "./accelbyte-widgets398.mjs";
import I from "./accelbyte-widgets261.mjs";
import y from "classnames";
import e from "react";
import { Trans as i } from "react-i18next";
import { Link as w } from "react-router-dom";
import { PurchaseHelper as B } from "./accelbyte-widgets211.mjs";
import C from "./accelbyte-widgets421.mjs";
const L = ({ link: o, thumbnail: m, name: r, type: c, quantity: l, otherInfo: t }) => /* @__PURE__ */ e.createElement(w, { to: o, className: "catalogItem" }, /* @__PURE__ */ e.createElement("div", { className: "catalogItemImage" }, /* @__PURE__ */ e.createElement("img", { src: m || I, loading: "lazy" })), /* @__PURE__ */ e.createElement("div", { className: "catalogItemDetail" }, /* @__PURE__ */ e.createElement("div", { className: y("catalogItemHeading", { owned: t.owned }) }, r), /* @__PURE__ */ e.createElement("div", { className: "catalogItemType" }, c, t.owned && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("span", { className: "mx-1" }, "•"), /* @__PURE__ */ e.createElement("span", { className: "ownedTag" }, /* @__PURE__ */ e.createElement(i, { i18nKey: "CatalogBundleItemList.ownedItem" }, "OWNED ITEM")))), /* @__PURE__ */ e.createElement("div", { className: "catalogItemQty" }, l > 1 && `x${l}`), t.finalPrice && /* @__PURE__ */ e.createElement("div", { className: "catalogItemHeading flex" }, /* @__PURE__ */ e.createElement("div", null, t.finalPrice), t.originalPrice && /* @__PURE__ */ e.createElement("s", { className: "priceStrikethrough" }, /* @__PURE__ */ e.createElement("div", { className: "price" }, t.originalPrice)))));
class S extends e.Component {
  constructor(m) {
    super(m), this.state = {
      showAll: !1
    };
  }
  render() {
    const { items: m, bundleItem: r, currencyMap: c, activatedRegionData: l } = this.props;
    return /* @__PURE__ */ e.createElement("div", { className: y(C.catalogBundleItemList, "catalogBundleItemList") }, /* @__PURE__ */ e.createElement("h2", { className: "catalogHeading" }, /* @__PURE__ */ e.createElement(i, { i18nKey: "CatalogBundleItemList.heading" }, "Inside the Bundle")), m.length > 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogList" }, m.map((t) => {
      var p, u;
      const E = t.appType || t.itemType, s = (p = t.regionData) == null ? void 0 : p.find(
        ({ currencyCode: a, currencyNamespace: N }) => a === (l == null ? void 0 : l.currencyCode) && N === l.currencyNamespace
      ), n = (u = l == null ? void 0 : l.priceDetails) == null ? void 0 : u.find(({ itemId: a }) => a === t.itemId);
      let d = "", g = "";
      if (s && c && (!n || !n.owned)) {
        const a = B.makePaymentOption(s, c);
        a && (a.originalPrice !== a.finalPrice && (d = `${a.currencySymbol} ${a.originalPrice}`), g = `${a.currencySymbol} ${a.finalPrice}`);
      }
      const f = v.getFilteredImageUrlByTag(t.images, P.productCover) || I;
      return /* @__PURE__ */ e.createElement(
        L,
        {
          key: t.itemId,
          link: h.getItemDetailRoute(t),
          thumbnail: f,
          name: t.title || t.name || "",
          type: E,
          quantity: r.itemQty ? r.itemQty[t.itemId] : 1,
          otherInfo: { originalPrice: d, finalPrice: g, owned: !!(n != null && n.owned) }
        }
      );
    })), m.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogNoItem" }, /* @__PURE__ */ e.createElement(i, { i18nKey: "CatalogBundleItemList.noItem" }, "Looks like there aren't any bundles for this game yet.")));
  }
}
export {
  S as CatalogBundleItemList
};
