import React, { useMemo } from 'react';
import { locales } from '@pisell/utils';
import { PisellTags, Icon } from '@pisell/materials';
import PisellPriceText from "../../../../components/pisellPriceText";
import { PREFIX } from "../../status";
import "./index.less";
var MemberPrice = function MemberPrice(_ref) {
  var props = _ref.props;
  var dataSource = props.dataSource,
    skuTextConfig = props.skuTextConfig;
  var _ref2 = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuMemberPriceConfig) || {},
    isOpen = _ref2.isOpen,
    isMemberPrice = _ref2.isMemberPrice,
    isIndicator = _ref2.isIndicator,
    isIndicatorBorder = _ref2.isIndicatorBorder,
    indicatorBackground = _ref2.indicatorBackground,
    indicatorPaddingY = _ref2.indicatorPaddingY,
    indicatorPaddingX = _ref2.indicatorPaddingX,
    indicatorMarginX = _ref2.indicatorMarginX,
    indicatorRadius = _ref2.indicatorRadius,
    indicatorBorderWidth = _ref2.indicatorBorderWidth,
    indicatorBorderColor = _ref2.indicatorBorderColor,
    indicatorFontSize = _ref2.indicatorFontSize,
    indicatorFontWeight = _ref2.indicatorFontWeight,
    indicatorColor = _ref2.indicatorColor,
    fontSize = _ref2.fontSize,
    fontWeight = _ref2.fontWeight,
    color = _ref2.color,
    indicatorIcon = _ref2.indicatorIcon,
    customText = _ref2.customText;

  // 不开启
  if (!isOpen) return null;

  // 自定义文本
  if (customText) return customText;
  var memberPriceStyle = useMemo(function () {
    return {
      fontSize: fontSize,
      fontWeight: fontWeight,
      color: color
    };
  }, [fontSize, fontWeight, color]);

  /**
   * @title: 标识样式
   * @description:
   * @param {*} useMemo
   * @return {*}
   * @Author: WangHan
   * @Date: 2025-09-08 11:50
   */
  var indicatorStyle = useMemo(function () {
    return {
      backgroundColor: indicatorBackground,
      padding: "".concat(indicatorPaddingY, "px ").concat(indicatorPaddingX, "px"),
      margin: "0 ".concat(indicatorMarginX, "px"),
      border: isIndicatorBorder ? "".concat(indicatorBorderWidth, "px solid ").concat(indicatorBorderColor) : 'none',
      borderRadius: indicatorRadius,
      fontSize: indicatorFontSize,
      fontWeight: indicatorFontWeight,
      color: indicatorColor
    };
  }, [indicatorBackground, indicatorPaddingY, indicatorPaddingX, indicatorMarginX, indicatorRadius, indicatorBorderWidth, indicatorBorderColor, indicatorFontSize, indicatorFontWeight, indicatorColor, isIndicatorBorder]);
  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__card-member-price")
  }, isMemberPrice ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__card-member-price-text"),
    style: memberPriceStyle
  }, /*#__PURE__*/React.createElement(PisellPriceText, {
    value: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.member_price) || 0
  })) : null, isIndicator ? /*#__PURE__*/React.createElement(PisellTags, {
    type: "pill_color",
    style: indicatorStyle
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__card-member-price-tag")
  }, indicatorIcon ? indicatorIcon : /*#__PURE__*/React.createElement(Icon, {
    type: "pisell2-check-verified-02",
    size: 12,
    rotate: 0,
    spin: false,
    color: "#CA8504"
  }), /*#__PURE__*/React.createElement("span", null, locales.getText('pisell2.sku-card.member-price')))) : null);
};
export default MemberPrice;