"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ConnectedSearchPage = void 0;

var _reactRedux = require("react-redux");

var _get = _interopRequireDefault(require("lodash/get"));

var _SearchPage = _interopRequireDefault(require("../../components/pages/SearchPage"));

var _withConfig = _interopRequireDefault(require("../../enhancers/withConfig"));

var _optionList = require("../../actions/optionList");

var _searchPage = require("../../actions/searchPage");

var _prefs = require("../../actions/prefs");

var _reducers = require("../../reducers");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const mapStateToProps = (state, ownProps) => {
  const searchPageRecordType = (0, _reducers.getSearchPageRecordType)(state);
  return {
    keywordValue: (0, _reducers.getSearchPageKeyword)(state),
    recordTypeValue: searchPageRecordType,
    vocabularyValue: (0, _reducers.getSearchPageVocabulary)(state, searchPageRecordType),
    advancedSearchCondition: (0, _reducers.getSearchPageAdvanced)(state),
    perms: (0, _reducers.getUserPerms)(state),
    preferredAdvancedSearchBooleanOp: (0, _reducers.getAdvancedSearchBooleanOp)(state) || (0, _get.default)(ownProps, ['config', 'defaultAdvancedSearchBooleanOp']),
    getAuthorityVocabCsid: (recordType, vocabulary) => (0, _reducers.getAuthorityVocabCsid)(state, recordType, vocabulary)
  };
};

const mapDispatchToProps = {
  buildRecordFieldOptionLists: _optionList.buildRecordFieldOptionLists,
  clearSearchPage: _searchPage.clearSearchPage,
  deleteOptionList: _optionList.deleteOptionList,
  initiateSearch: _searchPage.initiateSearch,
  onAdvancedSearchConditionCommit: _searchPage.setSearchPageAdvanced,
  onClearButtonClick: _searchPage.clearSearchPage,
  onKeywordCommit: _searchPage.setSearchPageKeyword,
  onRecordTypeCommit: _prefs.setSearchPageRecordType,
  onVocabularyCommit: _prefs.setSearchPageVocabulary
};
const ConnectedSearchPage = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_SearchPage.default);
exports.ConnectedSearchPage = ConnectedSearchPage;

var _default = (0, _withConfig.default)(ConnectedSearchPage);

exports.default = _default;