"use strict";

exports.__esModule = true;
exports.default = void 0;
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _select = _interopRequireDefault(require("../../atom/select"));
var _inputSwitch = _interopRequireDefault(require("../../atom/input-switch"));
var _radioGroup = _interopRequireDefault(require("../../atom/radio-group"));
var _range = _interopRequireDefault(require("../../atom/range"));
var _filtersWapper = _interopRequireDefault(require("./filters-wapper.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const FiltersWapper = (props, context) => {
  const {
    filters,
    className,
    filterGroupAriaLabel
  } = props;
  const buildFilter = (filter, idx) => {
    const {
      type,
      fieldName
    } = filter;
    switch (type) {
      case 'select':
        return /*#__PURE__*/_react.default.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: _filtersWapper.default.choice,
          key: idx
        }, /*#__PURE__*/_react.default.createElement(_select.default, filter));
      case 'radio':
        return /*#__PURE__*/_react.default.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: _filtersWapper.default.choice,
          key: idx
        }, /*#__PURE__*/_react.default.createElement("p", {
          className: _filtersWapper.default.title
        }, filter.title), /*#__PURE__*/_react.default.createElement(_radioGroup.default, _extends({}, filter, {
          className: _filtersWapper.default.radioGroup
        })));
      case 'range':
        return /*#__PURE__*/_react.default.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: _filtersWapper.default.timerWrapper,
          key: idx
        }, /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("span", {
          className: _filtersWapper.default.title
        }, filter.title), /*#__PURE__*/_react.default.createElement("p", {
          className: _filtersWapper.default.timerSubtitle
        }, filter.subtitle), /*#__PURE__*/_react.default.createElement(_range.default, filter)));
      case 'switch':
        return /*#__PURE__*/_react.default.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: (0, _classnames.default)(_filtersWapper.default.choice, _filtersWapper.default.switchContainer),
          key: idx
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: _filtersWapper.default.toggle
        }, /*#__PURE__*/_react.default.createElement(_inputSwitch.default, _extends({}, filter.display, {
          "aria-labelledby": `title-id-${idx}`
        }))), /*#__PURE__*/_react.default.createElement("label", {
          id: `title-id-${idx}`,
          className: _filtersWapper.default.switchTitle
        }, filter.title));
      default:
        return null;
    }
  };
  const filtersList = _map2.default.convert({
    cap: false
  })(buildFilter, filters);
  const emptyFilters = (0, _isEmpty2.default)(filters);
  return /*#__PURE__*/_react.default.createElement("form", null, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(className, emptyFilters ? _filtersWapper.default.wrapperNone : _filtersWapper.default.wrapper),
    role: "group",
    "aria-label": filterGroupAriaLabel
  }, filtersList));
};
FiltersWapper.propTypes = process.env.NODE_ENV !== "production" ? {
  className: _propTypes.default.string,
  filters: _propTypes.default.arrayOf(_propTypes.default.shape({
    type: _propTypes.default.oneOf(['select', 'range', 'radio', 'switch']).isRequired,
    fieldName: _propTypes.default.string.isRequired
  })),
  filterGroupAriaLabel: _propTypes.default.string
} : {};
var _default = exports.default = FiltersWapper;
//# sourceMappingURL=filters-wrapper.js.map