'use strict';

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

var _redux = require('redux');

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

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

var _presenter2 = _interopRequireDefault(_presenter);

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

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

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

var modalActions = _interopRequireWildcard(_modal);

var _quizzes = require('../../../api/quizzes');

var _errorsShowing = require('../../../../common/actions/errorsShowing');

var _stateHelper = require('../../../../common/util/stateHelper');

var _stateHelper2 = _interopRequireDefault(_stateHelper);

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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function mapStateToProps(state) {
  var activeQuiz = _stateHelper2.default.activeQuiz();
  var quizEntriesIncludingTemp = activeQuiz.getWorkingQuizEntries();

  return {
    banks: state.get('banks'), // needed to force Build to re-render when banks are deleted
    quiz: activeQuiz,
    quizEntries: quizEntriesIncludingTemp,
    stimulusOn: (0, _featureCheck.featureOn)('stimulus')
  };
}

function mapDispatchToProps(dispatch) {
  return {
    addError: (0, _redux.bindActionCreators)(_alerts.addError, dispatch),
    clearErrorsShowing: (0, _redux.bindActionCreators)(_errorsShowing.clearErrorsShowing, dispatch),
    modalActions: (0, _redux.bindActionCreators)(modalActions, dispatch),
    quizBuildingSession: (0, _redux.bindActionCreators)(_quizzes.quizBuildingSession, dispatch),
    removeAlert: (0, _redux.bindActionCreators)(_alerts.removeAlert, dispatch),
    screenreaderNotification: (0, _redux.bindActionCreators)(_alerts.screenreaderNotification, dispatch)
  };
}

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