var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/checkout/components/WalletPassModule/components/WalletPassCardDisplay/index.tsx
var WalletPassCardDisplay_exports = {};
__export(WalletPassCardDisplay_exports, {
  default: () => WalletPassCardDisplay_default
});
module.exports = __toCommonJS(WalletPassCardDisplay_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_WalletPassTextMode = __toESM(require("../WalletPassTextMode"));
var import_utils2 = require("../../utils");
var import_index = require("./index.less");
var Amount = import_materials.PisellText.Amount;
var WalletPassCardDisplay = ({
  isCardMode,
  cardData,
  selectedWalletIds,
  onSelectWallet,
  onDetail,
  onConfirmEditAmount,
  onBeforeEditAmount
}) => {
  const handleCardListChange = (value) => {
    onSelectWallet(value);
  };
  const formatBalance = (balance, option) => {
    var _a, _b, _c, _d, _e, _f;
    if (((_a = option == null ? void 0 : option.data) == null ? void 0 : _a.originData.tag) === "point_card") {
      const value = (option == null ? void 0 : option.active) ? (balance || 0) - (((_c = (_b = option == null ? void 0 : option.data) == null ? void 0 : _b.originData) == null ? void 0 : _c.recommended_usage_par_value) || 0) : balance;
      const amount = (0, import_utils2.getPointCardAmount)(
        value || 0,
        (_e = (_d = option == null ? void 0 : option.data) == null ? void 0 : _d.originData) == null ? void 0 : _e.wallet_pass_usage_unit
      );
      return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
        Amount,
        {
          className: "pisell-card-amount-item-value",
          useThousandsSeparator: true,
          value,
          showCurrencySymbol: false
        }
      ), "(", /* @__PURE__ */ import_react.default.createElement(
        Amount,
        {
          className: "pisell-card-amount-item-value",
          useThousandsSeparator: true,
          value: amount,
          showCurrencySymbol: false
        }
      ), ")");
    }
    if (option == null ? void 0 : option.active) {
      return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
        Amount,
        {
          className: "pisell-card-amount-item-value testtest",
          useThousandsSeparator: true,
          value: balance ? balance - (((_f = option == null ? void 0 : option.data) == null ? void 0 : _f.redeem) || 0) : 0,
          showCurrencySymbol: true,
          hideDecimalForWholeNumbers: false,
          precision: 2
        }
      ));
    }
    return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
      Amount,
      {
        className: "pisell-card-amount-item-value testtest",
        useThousandsSeparator: true,
        value: balance,
        showCurrencySymbol: true,
        hideDecimalForWholeNumbers: false,
        precision: 2
      }
    ));
  };
  const formatBalanceTitle = (balanceTitle, option) => {
    if (option == null ? void 0 : option.active) {
      return /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("wallet-pass-module-balance-after"));
    }
    return /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("wallet-pass-module-balance"));
  };
  const formatRedeemTitle = (title, option) => {
    if (option == null ? void 0 : option.active) {
      return /* @__PURE__ */ import_react.default.createElement("span", null, option.originDom);
    }
    return /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("wallet-pass-module-max.use"));
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-card-display-container" }, isCardMode ? /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellCardList,
    {
      showActiveBackground: true,
      showName: true,
      showStoreName: false,
      showRedeem: true,
      showBalance: true,
      showCode: true,
      showValidDate: true,
      showDetail: true,
      showQrCode: true,
      showCover: true,
      showActions: false,
      platform: "pc",
      mode: "multiple",
      direction: "horizontal",
      formatBalance,
      formatBalanceTitle,
      formatRedeemTitle,
      type: "mini",
      data: cardData,
      hasMore: false,
      showEmpty: false,
      fullWidth: false,
      value: selectedWalletIds,
      useExternalDetail: true,
      onDetail,
      showStatus: false,
      onChange: handleCardListChange,
      actions: {
        layout: "expanded",
        detail: {
          visible: false,
          iconColor: "#1570EF"
        },
        edit: {
          visible: false,
          iconColor: "#1570EF"
        }
      },
      enableEditAmount: true,
      onConfirmEditAmount,
      onBeforeEditAmount
    }
  ) : /* @__PURE__ */ import_react.default.createElement(
    import_WalletPassTextMode.default,
    {
      cardData,
      selectedWalletIds
    }
  ));
};
var WalletPassCardDisplay_default = WalletPassCardDisplay;
