'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _immutable = require('immutable');

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

var _reactRedux = require('../../../../common/react-redux');

var _Bank = require('../../../../common/records/Bank');

var _Bank2 = _interopRequireDefault(_Bank);

var _banks = require('../../../api/banks');

var _bankEntries = require('../../../api/bankEntries');

var _quizEntries = require('../../../../building/api/quizEntries');

var _modal = require('../../../../common/actions/modal');

var _constants = require('../../../../constants');

var _alerts = require('../../../../common/actions/alerts');

var _featureCheck = require('../../../../common/util/featureCheck');

var _ui = require('../../../../common/actions/ui');

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

function mapStateToProps(state, props) {
  var bank = new _Bank2.default(state.getIn(['banks', props.bankId]));
  var search = state.getIn(['ui', _presenter2.default.searchKey(props)], (0, _immutable.Map)());

  return {
    bank: bank,
    search: search,
    useBankSearch: (0, _featureCheck.featureOn)('item_bank_search'),
    position: state.getIn(['ui', _constants.BUILD_TRAY_POSITION]),
    stimulusId: state.getIn(['ui', _constants.BUILD_TRAY_STIMULUS_ID]),
    activeQuizId: state.getIn(['quizzes', 'activeQuizId'])
  };
}

var mapDispatchToProps = {
  addEntryToQuiz: _quizEntries.createQuizEntry,
  getBank: _banks.getBank,
  getBankEntries: _bankEntries.getBankEntries,
  mergeUI: _ui.merge,
  openModal: _modal.openModal,
  screenreaderNotification: _alerts.screenreaderNotification,
  setUI: _ui.set
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter2.default);