"use strict";

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

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

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

var _SearchToSelectModal = _interopRequireWildcard(require("../../components/search/SearchToSelectModal"));

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

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

var _searchToSelect = require("../../actions/searchToSelect");

var _search = require("../../actions/search");

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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

const mapStateToProps = (state, ownProps) => {
  const searchToSelectRecordType = (0, _reducers.getSearchToSelectRecordType)(state);
  return {
    keywordValue: (0, _reducers.getSearchToSelectKeyword)(state),
    recordTypeValue: searchToSelectRecordType,
    vocabularyValue: (0, _reducers.getSearchToSelectVocabulary)(state, searchToSelectRecordType),
    advancedSearchCondition: (0, _reducers.getSearchToSelectAdvanced)(state),
    perms: (0, _reducers.getUserPerms)(state),
    preferredAdvancedSearchBooleanOp: (0, _reducers.getAdvancedSearchBooleanOp)(state) || (0, _get.default)(ownProps, ['config', 'defaultAdvancedSearchBooleanOp']),
    preferredPageSize: (0, _reducers.getSearchToSelectPageSize)(state),
    selectedItems: (0, _reducers.getSearchSelectedItems)(state, _SearchToSelectModal.searchName),
    getAuthorityVocabCsid: (recordType, vocabulary) => (0, _reducers.getAuthorityVocabCsid)(state, recordType, vocabulary)
  };
};

const mapDispatchToProps = {
  buildRecordFieldOptionLists: _optionList.buildRecordFieldOptionLists,
  clearSearchResults: _search.clearSearchResults,
  deleteOptionList: _optionList.deleteOptionList,
  search: _search.search,
  onAdvancedSearchConditionCommit: _searchToSelect.setSearchToSelectAdvanced,
  onClearButtonClick: _searchToSelect.clearSearchToSelect,
  onKeywordCommit: _searchToSelect.setSearchToSelectKeyword,
  onRecordTypeCommit: _searchToSelect.setSearchToSelectRecordType,
  onVocabularyCommit: _searchToSelect.setSearchToSelectVocabulary,
  onItemSelectChange: _search.setResultItemSelected,
  setAllItemsSelected: _search.setAllResultItemsSelected,
  setPreferredPageSize: _prefs.setSearchToSelectPageSize
};

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_SearchToSelectModal.default);

exports.default = _default;