import React, { useMemo } from 'react';
import { Statistic as AntdStatistic } from 'antd';
import { locales } from '@pisell/utils';
import { PREFIX } from "../../status";
import "./index.less";
var AntdCountdown = AntdStatistic.Countdown;
var Countdown = function Countdown(_ref) {
  var props = _ref.props;
  var dataSource = props.dataSource,
    skuTextConfig = props.skuTextConfig;
  var _ref2 = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuCountdownConfig) || {},
    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]);
  return dataSource !== null && dataSource !== void 0 && dataSource.countdown ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__card-countdown"),
    style: finalStyle
  }, /*#__PURE__*/React.createElement("span", null, locales.getText('pisell2.sku-card.time.remaining'), ": "), /*#__PURE__*/React.createElement(AntdCountdown, {
    value: dataSource === null || dataSource === void 0 ? void 0 : dataSource.countdown,
    format: "HH:mm:ss",
    valueStyle: finalStyle
  })) : null;
};
export default Countdown;