import { MAP_DATE_PRESET_TO_KEY, presetToDaysAmount, } from '@wix/bex-core';
import { createElement } from 'react';
import { FilterTagContent } from '../AppliedFiltersTagList/FilterTagContent';
export const renderPresetToolbarTag = (container, params) => {
    return (filter) => {
        const { filterProps } = params;
        const { translate: t, dateFormatters } = container;
        const { preset } = filter;
        if (!preset || !presetToDaysAmount[preset]) {
            return {
                children: createElement(FilterTagContent, { filterProps }, getDateRangeLabel(filter, {
                    dateFormatters,
                })),
            };
        }
        return {
            children: createElement(FilterTagContent, { filterProps }, t(MAP_DATE_PRESET_TO_KEY[preset])),
        };
    };
};
const getDateRangeLabel = (item, { dateFormatters, }) => {
    return [item.from, item.to]
        .filter(Boolean)
        .map((date) => dateFormatters.mediumTime.format(date))
        .join(' - ');
};
//# sourceMappingURL=renderPresetToolbarTag.js.map