import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { useConfiguration } from '../../hooks';
import VisuallyHiddenText from '../VisuallyHiddenText';
import NoValue from '../NoValue/NoValue';
import { formatCurrency, isValidCurrency } from './utils';
const CurrencyDisplay = forwardRef(function CurrencyDisplay({ value, currencyISOCode, formattingOptions: { currency = 'symbol', negative = 'minus-sign', notation = 'standard', groupSeparators = true, fractionDigits } = {}, ...restProps }, ref) {
    const { locale } = useConfiguration();
    const options = currencyISOCode && isValidCurrency(currencyISOCode)
        ? {
            style: 'currency',
            currency: currencyISOCode,
            currencyDisplay: currency,
            useGrouping: groupSeparators,
            notation,
            currencySign: negative === 'parentheses' ? 'accounting' : 'standard',
            minimumFractionDigits: fractionDigits,
            maximumFractionDigits: fractionDigits
        }
        : undefined;
    const srOptions = {
        ...options,
        useGrouping: false,
        currencySign: 'standard',
        currencyDisplay: 'name'
    };
    return (_jsx("span", { ref: ref, ...restProps, children: value || value === 0 ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, children: formatCurrency(value, { locale, options }) }), _jsx(VisuallyHiddenText, { children: formatCurrency(value, { locale, options: srOptions }) })] })) : (_jsx(NoValue, {})) }));
});
export default CurrencyDisplay;
//# sourceMappingURL=CurrencyDisplay.js.map