"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 _presenter = _interopRequireDefault(require("./presenter"));

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

var _modifications = require("../../../../common/actions/modifications");

var _Item = _interopRequireDefault(require("../../../../common/records/Item"));

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

var _modalHelpers = require("../../../../common/util/modalHelpers");

var _ImportModal = require("../../../../common/components/ImportModal");

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

function mapStateToProps(state, props) {
  var nestedModals = ['correct', 'incorrect', 'neutral'].map(_ImportModal.generateImportModalId);
  var openModal = state.getIn(['modal', 'isOpen']);
  var importModalOpen = nestedModals.includes(openModal);
  return {
    importModalOpen: importModalOpen,
    modalOpen: openModal === _constants.ITEM_FEEDBACK_MODAL,
    item: new _Item.default(state.getIn(['ui', _constants.ITEM_FEEDBACK_MODAL_ITEM])),
    feedback: state.getIn(['ui', _constants.ITEM_FEEDBACK_MODAL_FEEDBACK]) || (0, _immutable.Map)(),
    modalTrigger: (0, _modalHelpers.getModalTrigger)(state)
  };
}

var mapDispatchToProps = {
  closeModal: _modal.closeModal,
  changeItemFeedback: _modifications.changeItemFeedback,
  openModal: _modal.openModal,
  setUi: _ui.set
};

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

exports.default = _default;