var _excluded = ["precision", "currencySymbol", "noStyle", "className", "children"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';

// 内库使用-start
import MathUtil from "./../../../../utils/MathUtil";
import DOMUtil from "./../../../../utils/DOMUtil";
// 内库使用-end

/* 测试使用-start
import { MathUtil, DOMUtil } from 'seedsui-react'
测试使用-end */

// 金额
function Amount(_ref) {
  var _num$split, _num$split2;
  var _ref$precision = _ref.precision,
    precision = _ref$precision === void 0 ? 2 : _ref$precision,
    currencySymbol = _ref.currencySymbol,
    noStyle = _ref.noStyle,
    className = _ref.className,
    children = _ref.children,
    props = _objectWithoutProperties(_ref, _excluded);
  if (isNaN(children)) {
    return null;
  }
  var num = MathUtil.thousands(Number(children).toFixed(precision));
  var integer = (_num$split = num.split('.')) === null || _num$split === void 0 ? void 0 : _num$split[0];
  var decimal = (_num$split2 = num.split('.')) === null || _num$split2 === void 0 ? void 0 : _num$split2[1];
  var displayValue = null;
  // No style
  if (noStyle) {
    displayValue = (currencySymbol || '') + (integer || '') + (decimal ? '.' + decimal : '');
  }
  // Default style
  else {
    displayValue = /*#__PURE__*/React.createElement(React.Fragment, null, currencySymbol && /*#__PURE__*/React.createElement("span", {
      className: "typography-amount-symbol"
    }, currencySymbol), /*#__PURE__*/React.createElement("span", {
      className: "typography-amount-integer"
    }, integer), decimal && /*#__PURE__*/React.createElement("span", {
      className: "typography-amount-decimal"
    }, ".", decimal));
  }
  return /*#__PURE__*/React.createElement("span", _extends({
    className: DOMUtil.classNames(noStyle ? '' : 'typography-amount', props === null || props === void 0 ? void 0 : props.className)
  }, props), displayValue);
}
export default Amount;