function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React, { useMemo } from 'react';
import { PisellCardList } from '@pisell/materials';
import DiscountTextMode from "./DiscountTextMode";
import { locales } from '@pisell/utils';
import "./index.less";
import { useToast } from "../../../../../../hooks";
var DiscountWallet = function DiscountWallet(props) {
  var isCardMode = props.isCardMode,
    cardData = props.cardData,
    selectedWalletIds = props.selectedWalletIds,
    onSelectWallet = props.onSelectWallet,
    onDetail = props.onDetail,
    discountDisabled = props.discountDisabled;
  var Toast = useToast();
  var formatData = useMemo(function () {
    if (!discountDisabled) {
      return cardData;
    }
    return cardData.map(function (item) {
      return _objectSpread(_objectSpread({}, item), {}, {
        disabled: true
      });
    });
  }, [discountDisabled, cardData]);
  var handleClick = function handleClick() {
    if (discountDisabled) {
      Toast.info(locales.getText('wallet-pass-module-discount-partially-paid'));
    }
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "discount-wallet-list-container"
  }, isCardMode ? /*#__PURE__*/React.createElement(PisellCardList, {
    className: "",
    showName: true,
    showActiveBackground: true,
    showStoreName: function showStoreName(data) {
      var _data$originData;
      if ((data === null || data === void 0 || (_data$originData = data.originData) === null || _data$originData === void 0 ? void 0 : _data$originData.tag) === 'good_pass') {
        return data.active;
      }
      return true;
    },
    onItemClick: handleClick,
    disabled: discountDisabled,
    showRedeem: false,
    showBalance: false,
    showCode: false,
    showValidDate: false,
    showDetail: false,
    showQrCode: false,
    showCover: false,
    showActions: false,
    platform: "pc",
    mode: "multiple",
    direction: "horizontal",
    type: "mini",
    data: formatData,
    hasMore: false,
    showEmpty: false,
    fullWidth: false,
    value: selectedWalletIds,
    useExternalDetail: true,
    onDetail: onDetail,
    showStatus: false,
    nameTitleStyle: {
      fontSize: 20,
      fontWeight: 600,
      color: '#FF8A1E'
    },
    onChange: onSelectWallet,
    actions: {
      layout: 'expanded',
      detail: {
        visible: false,
        iconColor: '#1570EF'
      },
      edit: {
        visible: false,
        iconColor: '#1570EF'
      }
    },
    enableEditAmount: false
  }) : /*#__PURE__*/React.createElement(DiscountTextMode, {
    cardData: cardData,
    selectedWalletIds: selectedWalletIds
  }));
};
export default DiscountWallet;