import _map from "lodash/fp/map";
import _isEmpty from "lodash/fp/isEmpty";
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); }
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Select from '../../atom/select';
import InputSwitch from '../../atom/input-switch';
import RadioGroup from '../../atom/radio-group';
import RangeSlider from '../../atom/range';
import style from './filters-wapper.css';
const FiltersWapper = (props, context) => {
  const {
    filters,
    className,
    filterGroupAriaLabel
  } = props;
  const buildFilter = (filter, idx) => {
    const {
      type,
      fieldName
    } = filter;
    switch (type) {
      case 'select':
        return /*#__PURE__*/React.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: style.choice,
          key: idx
        }, /*#__PURE__*/React.createElement(Select, filter));
      case 'radio':
        return /*#__PURE__*/React.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: style.choice,
          key: idx
        }, /*#__PURE__*/React.createElement("p", {
          className: style.title
        }, filter.title), /*#__PURE__*/React.createElement(RadioGroup, _extends({}, filter, {
          className: style.radioGroup
        })));
      case 'range':
        return /*#__PURE__*/React.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: style.timerWrapper,
          key: idx
        }, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("span", {
          className: style.title
        }, filter.title), /*#__PURE__*/React.createElement("p", {
          className: style.timerSubtitle
        }, filter.subtitle), /*#__PURE__*/React.createElement(RangeSlider, filter)));
      case 'switch':
        return /*#__PURE__*/React.createElement("div", {
          "data-name": "choice",
          "data-filter-type": fieldName,
          className: classnames(style.choice, style.switchContainer),
          key: idx
        }, /*#__PURE__*/React.createElement("div", {
          className: style.toggle
        }, /*#__PURE__*/React.createElement(InputSwitch, _extends({}, filter.display, {
          "aria-labelledby": `title-id-${idx}`
        }))), /*#__PURE__*/React.createElement("label", {
          id: `title-id-${idx}`,
          className: style.switchTitle
        }, filter.title));
      default:
        return null;
    }
  };
  const filtersList = _map.convert({
    cap: false
  })(buildFilter, filters);
  const emptyFilters = _isEmpty(filters);
  return /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement("div", {
    className: classnames(className, emptyFilters ? style.wrapperNone : style.wrapper),
    role: "group",
    "aria-label": filterGroupAriaLabel
  }, filtersList));
};
FiltersWapper.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  filters: PropTypes.arrayOf(PropTypes.shape({
    type: PropTypes.oneOf(['select', 'range', 'radio', 'switch']).isRequired,
    fieldName: PropTypes.string.isRequired
  })),
  filterGroupAriaLabel: PropTypes.string
} : {};
export default FiltersWapper;
//# sourceMappingURL=filters-wrapper.js.map