"use strict";

exports.__esModule = true;
exports.renderPresetToolbarTag = void 0;
var _bexCore = require("@wix/bex-core");
var _react = require("react");
var _FilterTagContent = require("../AppliedFiltersTagList/FilterTagContent");
const renderPresetToolbarTag = (container, params) => {
  return filter => {
    const {
      filterProps
    } = params;
    const {
      translate: t,
      dateFormatters
    } = container;
    const {
      preset
    } = filter;
    if (!preset || !_bexCore.presetToDaysAmount[preset]) {
      return {
        children: /*#__PURE__*/(0, _react.createElement)(_FilterTagContent.FilterTagContent, {
          filterProps
        }, getDateRangeLabel(filter, {
          dateFormatters
        }))
      };
    }
    return {
      children: /*#__PURE__*/(0, _react.createElement)(_FilterTagContent.FilterTagContent, {
        filterProps
      }, t(_bexCore.MAP_DATE_PRESET_TO_KEY[preset]))
    };
  };
};
exports.renderPresetToolbarTag = renderPresetToolbarTag;
const getDateRangeLabel = (item, {
  dateFormatters
}) => {
  return [item.from, item.to].filter(Boolean).map(date => dateFormatters.mediumTime.format(date)).join(' - ');
};
//# sourceMappingURL=renderPresetToolbarTag.js.map