import { U as d, ae as g, T as r, af as m, ac as N, F as P, a as D, g as f, L as H, i as I } from "./index-162fd1aa.mjs";
import { B as O } from "./BackLinkIcon-de8f5572.mjs";
import { O as h } from "./OrderLogic-4c8a06be.mjs";
import { d as T } from "./default-item-image-9aab0e29.mjs";
import e from "react";
import { Link as v } from "react-router-dom";
import { A as x, b, a as C } from "./AccountMainSection-4c35f8d7.mjs";
import "./dateFns-2367ee5b.mjs";
import "./validator-61879ab7.mjs";
import "./reactPlayer-2f69f369.mjs";
import "./reactSlick-cb4a2d39.mjs";
import "./PendingOrdersAppManager-4782fef4.mjs";
const S = "orderHistoryDetailPage _orderHistoryDetailPage_87f04", A = {
  orderHistoryDetailPage: S
};
class V extends e.Component {
  constructor(i) {
    var l;
    super(i), this.getItemImage = (t) => {
      const { thumbnailUrl: n } = t;
      if (n && d.isValidUrl(n))
        return n;
      const a = g.getGameIconImage(t);
      return a && d.isValidUrl(a) ? a : T;
    }, this.renderOrderItem = (t, n, a) => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "orderItemContainer" }, /* @__PURE__ */ e.createElement("div", { className: "tableHead" }, /* @__PURE__ */ e.createElement("p", { className: "itemName" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.item" }, "Item")), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.price" }, "Price")), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.quantity" }, "Quantity")), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.subtotal" }, "Subtotal"))), /* @__PURE__ */ e.createElement("div", { className: "divider top" }), n.regionDataItem && /* @__PURE__ */ e.createElement("div", { className: "itemInfoContainer" }, /* @__PURE__ */ e.createElement("div", { className: "itemContainer" }, /* @__PURE__ */ e.createElement("img", { className: "itemImage", src: this.getItemImage(a), alt: a.title, loading: "lazy" }), /* @__PURE__ */ e.createElement("p", { className: "itemName" }, a.title)), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, `${t.currency.currencySymbol} ${m.calculateIntegerPrice(
      (t.subtotalPrice ? t.subtotalPrice : 0) / t.quantity,
      t.currency
    )}`), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, t.quantity), /* @__PURE__ */ e.createElement("p", { className: "itemText" }, `${t.currency.currencySymbol} ${m.calculateIntegerPrice(
      t.subtotalPrice ? t.subtotalPrice : 0,
      t.currency
    )}`))), /* @__PURE__ */ e.createElement("div", { className: "divider bottom" }), this.renderTotalOrder(t)), this.renderTotalOrder = (t) => {
      const {
        status: n,
        currency: { currencySymbol: a },
        totalPrice: u = 0,
        totalTax: y = 0
      } = t, E = m.calculateIntegerPrice(y, t.currency), p = m.calculateIntegerPrice(u, t.currency), o = t.currency.currencyType === N.enum.REAL;
      return /* @__PURE__ */ e.createElement("div", { className: "totalOrderContainer" }, /* @__PURE__ */ e.createElement("div", { className: "infoNameColumn" }, o && /* @__PURE__ */ e.createElement("p", { className: "infoText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.tax" }, "Tax")), /* @__PURE__ */ e.createElement("p", { className: "infoText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.total" }, "Total")), /* @__PURE__ */ e.createElement("p", { className: "infoText" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.status" }, "Status"))), /* @__PURE__ */ e.createElement("div", { className: "emptyDividerColumn" }), /* @__PURE__ */ e.createElement("div", { className: "infoAmountColumn" }, o && /* @__PURE__ */ e.createElement("p", { className: "infoAmount" }, a, " ", E), /* @__PURE__ */ e.createElement("p", { className: "infoAmount" }, a, " ", p), /* @__PURE__ */ e.createElement("p", { className: "infoAmount" }, n)));
    }, this.renderOrderHistoryDetail = (t, n) => {
      const a = P.formatDate(t.createdTime, "LLLL");
      return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "orderInfoContainer" }, /* @__PURE__ */ e.createElement("p", { className: "infoTitle" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.orderDate" }, "Order date")), /* @__PURE__ */ e.createElement("p", null, a)), /* @__PURE__ */ e.createElement("div", { className: "orderInfoContainer" }, /* @__PURE__ */ e.createElement("p", { className: "infoTitle" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.orderID" }, "Order No")), /* @__PURE__ */ e.createElement("p", null, t.orderNo)), !t.itemSnapshot && /* @__PURE__ */ e.createElement("div", { className: "noData" }, /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.noItemDataFound" }, "Item data not found")), t.itemSnapshot && this.renderOrderItem(t, t.itemSnapshot, n));
    };
    const { orderNo: c } = this.props, s = ((l = D.getAppState().getUser()) == null ? void 0 : l.userId) || "";
    this.logic = new h({ userId: s, orderNo: c }), this.logic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    this.logic.init();
  }
  render() {
    const { isFetching: i, order: c, item: s, error: l } = this.logic.state;
    return /* @__PURE__ */ e.createElement(x, { className: A.orderHistoryDetailPage }, /* @__PURE__ */ e.createElement(b, null, /* @__PURE__ */ e.createElement("span", { className: "navigationContainer" }, /* @__PURE__ */ e.createElement(v, { to: f.OrderHistory.makePath() }, /* @__PURE__ */ e.createElement(O, null))), /* @__PURE__ */ e.createElement(r, { i18nKey: "OrderHistoryDetailPage.title" }, "Order History")), /* @__PURE__ */ e.createElement(C, null, i && /* @__PURE__ */ e.createElement(H, { className: "loading" }), !i && l && /* @__PURE__ */ e.createElement("div", { className: "errorContainer" }, /* @__PURE__ */ e.createElement(I, { error: l })), !i && c && s && this.renderOrderHistoryDetail(c, s)));
  }
}
export {
  V as default
};
