"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TableFiltersBody = TableFiltersBody;
var _react = _interopRequireDefault(require("react"));
var _useTranslation = require("../../hooks/use-translation");
var _button = require("../../button");
var _badge = require("../../badge");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function TableFiltersBody({
  filters,
  children,
  isOpen,
  onFilterClose,
  onClearAllFilters,
  onCancel,
  onApply,
  localizationText,
  cancelButtonProps = {},
  applyButtonProps = {},
  clearButtonProps = {}
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "table-filter-body",
    children: [!!filters.length && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "table-filter-applied",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: "table-filter-title",
        children: localizationText?.appliedFilters || t('Filters applied:')
      }), filters.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
        badgeContainerTestId: item.badgeContainerTestId,
        plain: true,
        onClose: () => onFilterClose(item),
        children: item.label
      }, item.key)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
        onClick: onClearAllFilters,
        accentType: _button.ACCENT_TYPES.GHOST,
        ...clearButtonProps,
        children: localizationText?.clearFilters ?? t('Clear all')
      })]
    }), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "table-filter-active",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        children: children
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "table-filter-buttons",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
          onClick: onCancel,
          accentType: _button.ACCENT_TYPES.SECONDARY,
          ...cancelButtonProps,
          children: localizationText?.cancelFilters ?? t('Cancel')
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
          onClick: onApply,
          accentType: _button.ACCENT_TYPES.PRIMARY,
          ...applyButtonProps,
          children: localizationText?.applyFilters ?? t('Apply filters')
        })]
      })]
    })]
  });
}