"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.FiltersPanelAppliedFiltersSection = void 0;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireDefault(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _mobx = require("mobx");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/FiltersPanel/FiltersPanelAppliedFiltersSection.tsx";
function _FiltersPanelAppliedFiltersSection(props) {
  const {
    state,
    onClearButtonClicked
  } = props;
  const {
    collection
  } = state;
  const {
    translate: t,
    query
  } = collection;
  const {
    nonPersistentCustomFiltersCount
  } = query;
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    weight: "bold",
    dataHook: "applied-filters",
    size: "small",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 28,
      columnNumber: 7
    }
  }, t('cairo.appliedFilters', {
    num: nonPersistentCustomFiltersCount
  })), /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    align: "right",
    flex: 1,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 34,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
    dataHook: "clear-all-filters",
    size: "small",
    onClick: () => {
      var _state$sidePanel$focu;
      (0, _mobx.runInAction)(() => {
        const {
          query: {
            nonPersistentCustomFilters
          }
        } = collection;
        collection.emitter.emit('beforeClearFilters', {
          origin: 'sidebar'
        });
        nonPersistentCustomFilters.filter(filter => !filter._hideFromToolbar).forEach(filter => {
          filter == null || filter.reset({
            emitEvents: ['change', 'refresh']
          });
        });
      });
      onClearButtonClicked == null || onClearButtonClicked();
      (_state$sidePanel$focu = state.sidePanel.focus.modalElement) == null || _state$sidePanel$focu.focus();
    },
    disabled: !nonPersistentCustomFiltersCount,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 35,
      columnNumber: 9
    }
  }, t('cairo.clear'))));
}
const FiltersPanelAppliedFiltersSection = exports.FiltersPanelAppliedFiltersSection = (0, _mobxReactLite.observer)(_FiltersPanelAppliedFiltersSection);
//# sourceMappingURL=FiltersPanelAppliedFiltersSection.js.map