import React, { useMemo } from 'react';
import { PisellCard, Iconfont, PisellText } from '@pisell/materials';
import { locales } from '@pisell/utils';
import useEngineContext from "../../../../hooks/useEngineContext";
import { mock } from "../../mock";
import classNames from 'classnames';
import "./index.less";
var PisellProductCard = function PisellProductCard(_ref) {
  var _utils$storage;
  var item = _ref.item,
    _ref$showImage = _ref.showImage,
    showImage = _ref$showImage === void 0 ? true : _ref$showImage,
    _ref$showName = _ref.showName,
    showName = _ref$showName === void 0 ? true : _ref$showName,
    _ref$showPrice = _ref.showPrice,
    showPrice = _ref$showPrice === void 0 ? true : _ref$showPrice,
    _ref$showArrow = _ref.showArrow,
    showArrow = _ref$showArrow === void 0 ? true : _ref$showArrow,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    _ref$selected = _ref.selected,
    selected = _ref$selected === void 0 ? false : _ref$selected,
    className = _ref.className,
    style = _ref.style,
    onClick = _ref.onClick;
  var context = useEngineContext();
  var utils = context.appHelper.utils || {};
  var isEn = (utils === null || utils === void 0 || (_utils$storage = utils.storage) === null || _utils$storage === void 0 ? void 0 : _utils$storage.get('umi_locale')) === 'en-US';
  var product_card = mock.product_card;
  var _ref2 = item || product_card,
    image = _ref2.image,
    title = _ref2.title,
    price = _ref2.price,
    currency = _ref2.currency,
    isMultiPrice = _ref2.isMultiPrice;

  /**
   * @title: 显示单位
   * @description:
   * @param {*} useMemo
   * @return {*}
   * @Author: WangHan
   * @Date: 2025-01-23 10:21
   */
  var fromText = useMemo(function () {
    if (!isMultiPrice) return '';
    return locales.getText('pisell2.event.price.from');
  }, [isMultiPrice]);
  return /*#__PURE__*/React.createElement(PisellCard, {
    className: classNames('pisell-product-card', className),
    style: style,
    onClick: onClick,
    borderRadius: 8,
    disabled: disabled,
    selected: selected
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-content"
  }, showImage && /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-image"
  }, image ? /*#__PURE__*/React.createElement("img", {
    src: image
  }) : /*#__PURE__*/React.createElement("div", {
    className: "image"
  })), /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-info"
  }, showName && /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-name"
  }, title), showPrice && /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-price"
  }, isEn ? fromText : '', /*#__PURE__*/React.createElement(PisellText.Amount, {
    value: price,
    showCurrencySymbol: true
  }), !isEn ? fromText : '')), showArrow && /*#__PURE__*/React.createElement("div", {
    className: "pisell-product-card-arrow"
  }, /*#__PURE__*/React.createElement(Iconfont, {
    type: "pisell2-chevron-right"
  }))));
};
export default PisellProductCard;