"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _redux = require("redux");

var _immutable = require("immutable");

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

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

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

var _quizEntries = require("../../../api/quizEntries");

var _presenter = _interopRequireDefault(require("./presenter"));

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

function mapStateToProps(state, props) {
  var _state$getIn$toObject = state.getIn(['ui', _constants.DELETE_STIMULUS_DATA], (0, _immutable.Map)()).toObject(),
      stimulusEntry = _state$getIn$toObject.stimulusEntry,
      childEntries = _state$getIn$toObject.childEntries,
      quizId = _state$getIn$toObject.quizId;

  var selectedChildren = state.getIn(['ui', _constants.DELETE_STIMULUS_MODAL_SELECTED_CHILDREN]);
  var deletionMode = state.getIn(['ui', _constants.DELETE_STIMULUS_MODAL_DELETION_MODE]);
  return {
    modalOpen: state.getIn(['modal', 'isOpen']) === _constants.DELETE_STIMULUS_MODAL,
    stimulusEntry: stimulusEntry,
    selectedChildren: selectedChildren,
    deletionMode: deletionMode,
    quizId: quizId,
    childEntries: childEntries || (0, _immutable.List)()
  };
}

var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    closeModal: (0, _redux.bindActionCreators)(_modal.closeModal, dispatch),
    removeStimulus: (0, _redux.bindActionCreators)(_quizEntries.removeStimulusQuizEntry, dispatch),
    setUi: (0, _redux.bindActionCreators)(_ui.set, dispatch),
    withConfirm: (0, _redux.bindActionCreators)(_modal.withConfirm, dispatch)
  };
};

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

exports.default = _default;