import React, { useMemo } from 'react';
import { locales } from '@pisell/utils';
import { PREFIX } from "../../status";
var Stock = function Stock(_ref) {
  var props = _ref.props;
  var dataSource = props.dataSource,
    skuTextConfig = props.skuTextConfig;
  var _ref2 = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuStockConfig) || {},
    isOpen = _ref2.isOpen,
    fontSize = _ref2.fontSize,
    fontWeight = _ref2.fontWeight,
    color = _ref2.color,
    customText = _ref2.customText;

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

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

  /**
   * @title: 库存文本
   * @description:
   * @param {*} useMemo
   * @return {*}
   * @Author: WangHan
   * @Date: 2025-09-08 15:31
   */
  var stockText = useMemo(function () {
    if ((dataSource === null || dataSource === void 0 ? void 0 : dataSource.is_track) === 0) {
      return null;
    }
    return "".concat(locales.getText('pisell2.sku-card.stock'), ": ").concat(dataSource === null || dataSource === void 0 ? void 0 : dataSource.stock_quantity);
  }, [dataSource === null || dataSource === void 0 ? void 0 : dataSource.stock_quantity, dataSource === null || dataSource === void 0 ? void 0 : dataSource.is_track]);
  return !!(dataSource !== null && dataSource !== void 0 && dataSource.is_track) ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__card-stock"),
    style: finalStyle
  }, stockText) : null;
};
export default Stock;