import _isEmpty from "lodash/fp/isEmpty";
import _getOr from "lodash/fp/getOr";
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, { useRef } from 'react';
import PropTypes from 'prop-types';
import Provider from '../../../atom/provider';
import Button from '../../../atom/button';
import Filters from '../../../molecule/filters';
import CardsGrid from '../../../organism/cards-grid';
import CardsList from '../../../molecule/dashboard/cards-list';
import CMPopin from '../../../molecule/cm-popin';
import style from './style.css';
const SearchPage = (props, context) => {
  const {
    title,
    searchFilters,
    cards,
    noresultsfound,
    clearFilters,
    recommendations,
    moreSortAriaLabel,
    moreFilterAriaLabel,
    filterGroupAriaLabel,
    sortAriaLabel,
    popinWithCards
  } = props;
  const {
    skin
  } = context;
  const defaultColor = _getOr('#00B0FF', 'common.primary', skin);
  const nodeRef = useRef(null);
  const recommendationsView = _isEmpty(recommendations) ? null : /*#__PURE__*/React.createElement(CardsList, recommendations);
  const cardsView = _isEmpty(cards.list) ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
    className: style.noresults
  }, /*#__PURE__*/React.createElement("div", {
    className: style.noresultstxt
  }, noresultsfound), /*#__PURE__*/React.createElement(Button, _extends({}, clearFilters, {
    "data-name": "searchPageClear",
    className: style.clear,
    style: {
      background: defaultColor
    },
    type: "link"
  }))), recommendationsView) : /*#__PURE__*/React.createElement(CardsGrid, cards);
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Filters, _extends({}, searchFilters, {
    moreSortAriaLabel: moreSortAriaLabel,
    moreFilterAriaLabel: moreFilterAriaLabel,
    filterGroupAriaLabel: filterGroupAriaLabel,
    sortAriaLabel: sortAriaLabel
  })), /*#__PURE__*/React.createElement("div", {
    "data-name": "searchResult",
    className: style.cardsWrapper
  }, /*#__PURE__*/React.createElement("div", {
    className: style.title,
    role: "status"
  }, title), cardsView), popinWithCards ? /*#__PURE__*/React.createElement("div", {
    className: style.popinWithCards,
    ref: nodeRef
  }, /*#__PURE__*/React.createElement(CMPopin, popinWithCards)) : null);
};
SearchPage.contextTypes = {
  skin: Provider.childContextTypes.skin
};
SearchPage.propTypes = process.env.NODE_ENV !== "production" ? {
  noresultsfound: PropTypes.string,
  title: PropTypes.string,
  searchFilters: PropTypes.shape(Filters.propTypes),
  cards: PropTypes.shape(CardsGrid.propTypes),
  clearFilters: PropTypes.shape(Button.propTypes),
  recommendations: PropTypes.shape(CardsList.propTypes),
  moreSortAriaLabel: PropTypes.string,
  moreFilterAriaLabel: PropTypes.string,
  filterGroupAriaLabel: PropTypes.string,
  sortAriaLabel: PropTypes.string,
  popinWithCards: PropTypes.shape(CMPopin.propTypes)
} : {};
export default SearchPage;
//# sourceMappingURL=index.js.map