import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose";

var _templateObject, _templateObject2, _templateObject3;

import React from 'react';
import { getTermsAggregationLabel } from '@sentecacommerce-theme/lib';
import styled from 'styled-components';
import { Checkbox } from '../../../../../Common';
var labelGettersMap = {
  terms: getTermsAggregationLabel,
  ranges: filter => {
    if (filter.data.from === '*') {
      return "\u043F\u043E\u0434 " + filter.data.to / 100 + "\u043B\u0432";
    }

    if (filter.data.to === '*') {
      return "\u043D\u0430\u0434 " + filter.data.from / 100 + "\u043B\u0432";
    }

    return filter.data.from / 100 + "\u043B\u0432 - " + filter.data.to / 100 + "\u043B\u0432";
  }
};
export var CheckboxList = (_ref) => {
  var {
    type,
    items
  } = _ref;
  return /*#__PURE__*/React.createElement(Row, null, items.map((filter, i) => {
    var _labelGettersMap$type;

    var label = ((_labelGettersMap$type = labelGettersMap[type]) == null ? void 0 : _labelGettersMap$type.call(labelGettersMap, filter)) || null;
    var {
      count
    } = filter.data;
    return /*#__PURE__*/React.createElement(Wrapper, {
      key: "Filter__" + label + "--" + i
    }, /*#__PURE__*/React.createElement(Checkbox, {
      onChange: () => filter.onClick(),
      isChecked: filter.selected,
      label: /*#__PURE__*/React.createElement(React.Fragment, null, label, Boolean(count) && /*#__PURE__*/React.createElement(Count, null, count)),
      size: "tiny"
    }));
  }));
};
var Row = styled.div.attrs({
  className: 'row row-cols-1 row-cols-md-1'
})(_templateObject || (_templateObject = _taggedTemplateLiteralLoose([""])));
var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n  @media (max-width: ", ") {\n    margin-bottom: 0.8rem;\n\n    &:last-of-type {\n      margin-bottom: 0;\n    }\n  }\n"])), (_ref2) => {
  var {
    theme
  } = _ref2;
  return theme.breakpoints.sm.max;
});
var Count = styled.span.attrs({
  className: 'd-flex align-items-center justify-content-center ml-2 px-2'
})(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n  min-width: 2.6rem;\n  height: 2rem;\n  font-size: 1rem;\n  color: ", ";\n  font-weight: bold;\n  background-color: ", ";\n  border-radius: 4rem;\n"])), (_ref3) => {
  var {
    theme
  } = _ref3;
  return theme.palette.primary;
}, (_ref4) => {
  var {
    theme
  } = _ref4;
  return theme.palette.light;
});
//# sourceMappingURL=index.js.map