/**
 * 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 const getLocalizedDecimal = (price, locale, currencyAsSymbol, decimals, currency) => {
    const singleValue = typeof price === "number"
        ? price
        : price.min === price.max
            ? price.min
            : undefined;
    const locales = locale !== undefined ? [locale] : undefined;
    if (singleValue !== undefined) {
        if (currency) {
            return convertValueToStringWithCurrency(singleValue, locales, currencyAsSymbol, decimals, currency);
        }
        return convertValueToLocaleString(singleValue, locales);
    }
    const { min, max } = price;
    return (convertValueToLocaleString(min, locales, decimals) +
        " - " +
        convertValueToStringWithCurrency(max, locales, currencyAsSymbol, decimals, currency));
};
const convertValueToStringWithCurrency = (value, locales, currencyAsSymbol, decimals, currency) => value.toLocaleString(locales, {
    style: "currency",
    currency,
    currencyDisplay: currencyAsSymbol ? "symbol" : "code",
    minimumFractionDigits: decimals,
    maximumFractionDigits: decimals,
});
const convertValueToLocaleString = (value, locales, decimals) => value.toLocaleString(locales, {
    minimumFractionDigits: decimals,
    maximumFractionDigits: decimals,
});
