// #region Imports
import { DateTimeFormatter } from '../../../../Intl/Formatters/DateTimeFormatter';
/**
 * @public
 */
export var InputFormatters;
(function (InputFormatters) {
    /**
     * Formats a number as currency.
     *
     * @public
    * @param code - The currency code (e.g., 'USD', 'EUR').
    * @param locale - The locale code (e.g., 'en-US', 'de-DE').
     * @returns {InputFormatterFn} - The function that formats the number as currency.
     */
    function currency(code, locale) {
        return (value) => {
            const numericValue = typeof value === 'string' ? parseFloat(value) : value;
            if (isNaN(numericValue)) {
                throw new Error('Invalid number value');
            }
            return new Intl.NumberFormat(locale, {
                style: 'currency',
                currency: code
            }).format(numericValue);
        };
    }
    InputFormatters.currency = currency;
    /**
     * Formats a number as a percentage.
     *
     * @public
     * @param {number} decimalPlaces - The number of decimal places to display.
     * @returns {InputFormatterFn} - The function that formats the number as a percentage.
     */
    function percentage(decimalPlaces) {
        return (value) => {
            const numericValue = typeof value === 'string' ? parseFloat(value) : value;
            if (isNaN(numericValue) || isNaN(decimalPlaces)) {
                throw new Error('Invalid number value or decimal places');
            }
            return `${(numericValue * 100).toFixed(decimalPlaces)}%`;
        };
    }
    InputFormatters.percentage = percentage;
    /**
     * Formats a number with custom decimal places.
     *
     * @public
     * @param {number} decimalPlaces - The number of decimal places to display.
     * @param {string} locale - The locale code (e.g., 'en-US', 'de-DE').
     * @returns {InputFormatterFn} - The function that formats the number with custom decimal places.
     */
    function number(decimalPlaces, locale) {
        return (value) => {
            const numericValue = typeof value === 'string' ? parseFloat(value) : value;
            if (isNaN(numericValue) || isNaN(decimalPlaces)) {
                throw new Error('Invalid number value or decimal places');
            }
            return new Intl.NumberFormat(locale, {
                minimumFractionDigits: decimalPlaces,
                maximumFractionDigits: decimalPlaces
            }).format(numericValue);
        };
    }
    InputFormatters.number = number;
    /**
     * Formats a date.
     *
     * @public
     * @param {DateTimeFormatter} format - The format options.
     * @param {string} locale - The locale code (e.g., 'en-US', 'de-DE').
     * @returns {InputFormatterFn} - The function that formats the date.
     */
    function date(format, locale) {
        return (value) => {
            const dateValue = new Date(value);
            if (isNaN(dateValue.getTime())) {
                throw new Error('Invalid date value');
            }
            return DateTimeFormatter.format(dateValue, format, locale);
        };
    }
    InputFormatters.date = date;
    /**
     * Formats a time.
     *
     * @public
     * @param {Intl.DateTimeFormatOptions} format - The format options.
     * @param {string} locale - The locale code (e.g., 'en-US', 'de-DE').
     * @returns {InputFormatterFn} - The function that formats the time.
     */
    function time(format, locale) {
        return (value) => {
            const dateValue = new Date(value);
            if (isNaN(dateValue.getTime())) {
                throw new Error('Invalid date value');
            }
            return dateValue.toLocaleTimeString(locale, format);
        };
    }
    InputFormatters.time = time;
    /**
     * Formats a date and time.
     *
     * @public
     * @param {Intl.DateTimeFormatOptions} format - The format options.
     * @param {string} locale - The locale code (e.g., 'en-US', 'de-DE').
     * @returns {InputFormatterFn} - The function that formats the date and time.
     */
    function dateTime(format, locale) {
        return (value) => {
            const dateValue = new Date(value);
            if (isNaN(dateValue.getTime())) {
                throw new Error('Invalid date value');
            }
            return dateValue.toLocaleString(locale, format);
        };
    }
    InputFormatters.dateTime = dateTime;
})(InputFormatters || (InputFormatters = {}));
//# sourceMappingURL=InputFormatterFn.js.map