"use strict";

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

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

var _immutable = require("immutable");

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

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

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

var _QuizEntry = _interopRequireDefault(require("../../../../common/records/QuizEntry"));

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.MOVE_IMMUTABLE_DATA], (0, _immutable.Map)()).toObject(),
      movedInSidebar = _state$getIn$toObject.movedInSidebar,
      quizId = _state$getIn$toObject.quizId,
      position = _state$getIn$toObject.position,
      stimulusQuizEntryId = _state$getIn$toObject.stimulusQuizEntryId,
      quizEntryId = _state$getIn$toObject.quizEntryId;

  var quizEntry = _QuizEntry.default.create(state.getIn(['quizEntries', quizEntryId]));

  return {
    modalOpen: state.getIn(['modal', 'isOpen']) === _constants.MOVE_IMMUTABLE_MODAL,
    movedInSidebar: movedInSidebar,
    quizId: quizId,
    position: position,
    stimulusQuizEntryId: stimulusQuizEntryId,
    quizEntry: quizEntry
  };
}

var mapDispatchToProps = {
  closeModal: _modal.closeModal,
  moveImmutableQuizEntry: _quizEntries.moveImmutableQuizEntry,
  setUI: _ui.set
};

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

exports.default = _default;