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/plus/productSelect/ProductCard/SkuCard/components/Price/index.tsx
var Price_exports = {};
__export(Price_exports, {
  default: () => Price_default
});
module.exports = __toCommonJS(Price_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_pisellPriceText = __toESM(require("../../../../components/pisellPriceText"));
var import_status = require("../../status");
var import_index = require("./index.less");
var Price = ({ props }) => {
  const { dataSource, skuTextConfig } = props;
  const {
    isOpen,
    isOriginPrice,
    isPrice,
    isTaxPrice,
    originPriceFontSize,
    originPriceFontWeight,
    originPriceColor,
    priceFontSize,
    priceFontWeight,
    priceColor,
    isCustomText,
    customTextType,
    customTextValue,
    customTextMinValue,
    customTextMaxValue,
    isShowZeroPrice,
    isShowFreePrice,
    isMiniPrice
  } = (skuTextConfig == null ? void 0 : skuTextConfig.skuPriceConfig) || {};
  if (!isOpen) return null;
  const isShowPrice = (0, import_react.useMemo)(() => {
    if (!isPrice) return false;
    if (Number(dataSource == null ? void 0 : dataSource.price) === 0 && !isShowZeroPrice) return false;
    return true;
  }, [isPrice, isShowZeroPrice, dataSource == null ? void 0 : dataSource.price]);
  const priceText = (0, import_react.useMemo)(() => {
    if (!isShowPrice) return null;
    if (Number(dataSource == null ? void 0 : dataSource.price) === 0 && isShowFreePrice) {
      return import_utils.locales.getText("pisell2.sku-card.free");
    }
    if (isCustomText) {
      if (customTextType === "from") {
        return /* @__PURE__ */ import_react.default.createElement(import_pisellPriceText.default, { value: customTextValue || 0, isMini: true });
      }
      if (customTextType === "end") {
        return /* @__PURE__ */ import_react.default.createElement(
          import_pisellPriceText.default,
          {
            value: customTextValue || 0,
            isMini: true,
            customPrefixText: import_utils.locales.getText("pisell2.sku-card.max"),
            customSuffixText: import_utils.locales.getText("pisell2.sku-card.max")
          }
        );
      }
      if (customTextType === "range") {
        return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_status.PREFIX}__card-price-range` }, /* @__PURE__ */ import_react.default.createElement(import_pisellPriceText.default, { value: customTextMinValue || 0 }), "~", /* @__PURE__ */ import_react.default.createElement(import_pisellPriceText.default, { value: customTextMaxValue || 0 }));
      }
    }
    return /* @__PURE__ */ import_react.default.createElement(import_pisellPriceText.default, { value: (dataSource == null ? void 0 : dataSource.price) || 0 });
  }, [
    isShowPrice,
    dataSource == null ? void 0 : dataSource.price,
    isShowFreePrice,
    isCustomText,
    customTextType,
    customTextValue,
    customTextMinValue,
    customTextMaxValue
  ]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_status.PREFIX}__card-price-wrap` }, isShowPrice ? /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `${import_status.PREFIX}__card-price`,
      style: {
        fontSize: priceFontSize,
        fontWeight: priceFontWeight,
        color: priceColor
      }
    },
    priceText
  ) : null, isTaxPrice && parseFloat(String((dataSource == null ? void 0 : dataSource.tax_fee) || 0)) > 0 ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_status.PREFIX}__card-tax-price` }, `(${import_utils.locales.getText("pisell2.sku-card.gst")} : `, /* @__PURE__ */ import_react.default.createElement(
    import_pisellPriceText.default,
    {
      value: (dataSource == null ? void 0 : dataSource.tax_fee) || 0,
      isMini: isMiniPrice
    }
  ), `)`) : null, isOriginPrice && parseFloat(String((dataSource == null ? void 0 : dataSource.original_price) || 0)) ? /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `${import_status.PREFIX}__card-original-price`,
      style: {
        fontSize: originPriceFontSize,
        fontWeight: originPriceFontWeight,
        color: originPriceColor
      }
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_pisellPriceText.default,
      {
        value: (dataSource == null ? void 0 : dataSource.original_price) || 0,
        isMini: isMiniPrice
      }
    )
  ) : null);
};
var Price_default = Price;
