"use strict";

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

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

var _redux = require("redux");

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

var _quizSessions = require("../../../../selectors/quizSessions");

var _sidebar = require("../../../../actions/sidebar");

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

var mapStateToProps = function mapStateToProps(state, props) {
  var hideOnTake = (0, _quizSessions.isOneQuestionAtATime)(state) && !(0, _quizSessions.getBacktrackingIsAllowed)(state);
  var quizSessionNotLoaded = (0, _quizSessions.getActiveQuizSessionId)(state) === '0';
  var hidden = !!props.onTake && (hideOnTake || quizSessionNotLoaded);
  return {
    hidden: hidden
  };
};

exports.mapStateToProps = mapStateToProps;

function mapDispatchToProps(dispatch, props) {
  return {
    sidebarMenuClick: props.sidebarMenuClick || (0, _redux.bindActionCreators)(_sidebar.toggleSidebar, dispatch)
  };
}

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

exports.default = _default;