'use strict';

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

var _immutable = require('immutable');

var immutable = _interopRequireWildcard(_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('../../../banks/api/banks');

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

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

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

var _constants = require('@instructure/quiz-common/lib/constants');

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

var _bankSearch = require('../../../common/actions/bankSearch');

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

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

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function mapStateToProps(state, props) {
  var bank = new _Bank2.default(state.getIn(['banks', props.bankId]));
  var search = state.get('bankSearch', 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,
  openModal: _modal.openModal,
  resetSearch: _bankSearch.reset,
  screenreaderNotification: _alerts.screenreaderNotification
};

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