import React from 'react';
import classNames from 'classnames';
import { formatNumberWithUnit } from "./utils";
import "./ReadPretty.less";
var ReadPretty = function ReadPretty(props) {
  var value = props.value,
    useThousandsSeparator = props.useThousandsSeparator,
    previewFormatter = props.previewFormatter,
    _props$precision = props.precision,
    precision = _props$precision === void 0 ? 0 : _props$precision,
    addonAfter = props.addonAfter,
    renderMode = props.renderMode;
  var className = classNames('pisell-input-number-read-pretty', {
    'pisell-input-number-read-pretty-table-view': renderMode === 'tableView'
  });
  if (!value && value !== 0) {
    return /*#__PURE__*/React.createElement("span", {
      className: className
    }, "-");
  }
  var formattedValue = formatNumberWithUnit(Number(value), precision, previewFormatter);
  if (useThousandsSeparator && (!previewFormatter || previewFormatter === 'none')) {
    var parts = formattedValue.split('.');
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
    return /*#__PURE__*/React.createElement("span", {
      className: className
    }, parts.join('.'), addonAfter);
  }
  return /*#__PURE__*/React.createElement("span", {
    className: className
  }, formattedValue, addonAfter);
};
export default ReadPretty;