"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

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

var _redux = require("redux");

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

var _items = require("../../../building/api/items");

var _stimuli = require("../../../building/api/stimuli");

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

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

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

var bankEntryApiActions = _interopRequireWildcard(require("../../api/bankEntries"));

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

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

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

var _this = void 0;

var rowKey = function rowKey(props) {
  return "BANK_ENTRY_".concat(props.bankEntry.get('id'), "_EXPANDED");
};

var mapStateToProps = function mapStateToProps(state, props) {
  return {
    activeQuizId: state.getIn(['quizzes', 'activeQuizId']),
    isExpanded: !!state.getIn(['ui', rowKey(props)]),
    position: state.getIn(['ui', _constants.BUILD_TRAY_POSITION]),
    stimulusId: state.getIn(['ui', _constants.BUILD_TRAY_STIMULUS_ID]),
    setEditButtonFocus: state.getIn(['ui', _constants.SET_EDIT_BUTTON_FOCUS]),
    tagAssociations: state.getIn(['tagAssociations', props.bankEntry.entry.get('schema'), props.bankEntry.entry.get('id')]),
    useBankTags: (0, _featureCheck.featureOn)('item_bank_tagging')
  };
};

var mapDispatchToProps = function mapDispatchToProps(dispatch, props) {
  return {
    clearUi: (0, _redux.bindActionCreators)(_ui.clear, dispatch),
    createItem: (0, _redux.bindActionCreators)(_items.createItem, dispatch),
    createStimulus: (0, _redux.bindActionCreators)(_stimuli.createStimulus, dispatch),
    openModal: (0, _redux.bindActionCreators)(modalActions.openModal, dispatch),
    removeBankEntry: (0, _redux.bindActionCreators)(bankEntryApiActions.removeBankEntry, dispatch),
    screenreaderNotification: (0, _redux.bindActionCreators)(_alerts.screenreaderNotification, dispatch),
    setUi: (0, _redux.bindActionCreators)(_ui.set, dispatch),
    toggleExpanded: (0, _redux.bindActionCreators)(_ui.toggle.bind(_this, rowKey(props)), dispatch),
    withConfirm: (0, _redux.bindActionCreators)(modalActions.withConfirm, dispatch)
  };
};

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

exports.default = _default;