var _excluded = ["value", "precision", "showCurrencySymbol", "useThousandsSeparator", "hideDecimalForWholeNumbers", "symbol"];
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, { useMemo } from 'react';
import { formatAmountWithOptions } from '@pisell/utils';
import usePisellConfig from "../../../pisell-config-provider/hooks/usePisellConfig";
var Amount = function Amount(props) {
  var value = props.value,
    precision = props.precision,
    showCurrencySymbol = props.showCurrencySymbol,
    useThousandsSeparator = props.useThousandsSeparator,
    hideDecimalForWholeNumbers = props.hideDecimalForWholeNumbers,
    symbol = props.symbol,
    others = _objectWithoutProperties(props, _excluded);
  var config = usePisellConfig();
  var amount = useMemo(function () {
    var _config$getSymbolic;
    return formatAmountWithOptions(value, symbol || (config === null || config === void 0 ? void 0 : config.symbol) || (config === null || config === void 0 || (_config$getSymbolic = config.getSymbolic) === null || _config$getSymbolic === void 0 ? void 0 : _config$getSymbolic.call(config)) || "", {
      precision: precision,
      showCurrencySymbol: showCurrencySymbol,
      useThousandsSeparator: useThousandsSeparator,
      hideDecimalForWholeNumbers: hideDecimalForWholeNumbers
    });
  }, [value, precision, showCurrencySymbol, useThousandsSeparator, hideDecimalForWholeNumbers, config === null || config === void 0 ? void 0 : config.symbol]);
  return /*#__PURE__*/React.createElement("span", others, amount);
};
export default Amount;