/**
 * Converts a number to desired currency
 * @param price Price as number
 * @param locale Localestring, e.g. de-DE
 * @param currencyAsSymbol E.g. Dollar or $
 * @param decimals Amount of digits after separator
 * @param currency currency as string, e.g. EUR
 */
export var getLocalizedDecimal = function (price, locale, currencyAsSymbol, decimals, currency) {
    var singleValue = typeof price === "number"
        ? price
        : price.min === price.max
            ? price.min
            : undefined;
    var locales = locale !== undefined ? [locale] : undefined;
    if (singleValue !== undefined) {
        if (currency) {
            return convertValueToStringWithCurrency(singleValue, locales, currencyAsSymbol, decimals, currency);
        }
        return convertValueToLocaleString(singleValue, locales);
    }
    var _a = price, min = _a.min, max = _a.max;
    return (convertValueToLocaleString(min, locales, decimals) +
        " - " +
        convertValueToStringWithCurrency(max, locales, currencyAsSymbol, decimals, currency));
};
var convertValueToStringWithCurrency = function (value, locales, currencyAsSymbol, decimals, currency) {
    return value.toLocaleString(locales, {
        style: "currency",
        currency: currency,
        currencyDisplay: currencyAsSymbol ? "symbol" : "code",
        minimumFractionDigits: decimals,
        maximumFractionDigits: decimals,
    });
};
var convertValueToLocaleString = function (value, locales, decimals) {
    return value.toLocaleString(locales, {
        minimumFractionDigits: decimals,
        maximumFractionDigits: decimals,
    });
};
