'use strict';

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

var _immutable = require('immutable');

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

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

var _presenter2 = _interopRequireDefault(_presenter);

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

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

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

var _Item2 = _interopRequireDefault(_Item);

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

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

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

var _constants = require('../../../../constants');

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

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 _Item2.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
};

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