"use strict";

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

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

var _redux = require("redux");

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

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

var _scrolling = require("../../../../actions/scrolling");

function getStimulus(parent) {
  return parent.entryType === 'BankEntry' ? parent.getEntry().getEntry() : parent.getEntry();
}

var mapDispatchToProps = function mapDispatchToProps(dispatch, props) {
  return {
    childEntries: props.stimulusParent.getNestedEntries(),
    scrollToItem: props.scrollToItem || (0, _redux.bindActionCreators)(_scrolling.scrollToItem, dispatch)
  };
};

exports.mapDispatchToProps = mapDispatchToProps;

var mapStateToProps = function mapStateToProps(state, props) {
  var stimulus = getStimulus(props.stimulusParent);
  var isShowingItems = state.getIn(['sidebar', stimulus.id], false);
  return {
    isShowingItems: isShowingItems,
    stimulus: stimulus
  };
};

exports.mapStateToProps = mapStateToProps;

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

exports.default = _default;