"use strict";

exports.__esModule = true;
exports.default = exports.TOTAL_SLIDES_STACK = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _toString2 = _interopRequireDefault(require("lodash/fp/toString"));
var _reviewSlide = _interopRequireDefault(require("../review-slide"));
var _propTypes = _interopRequireDefault(require("./prop-types"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const TOTAL_SLIDES_STACK = exports.TOTAL_SLIDES_STACK = 5;
const stylesByPosition = {
  0: _style.default.position0,
  1: _style.default.position1,
  2: _style.default.position2,
  3: _style.default.position3,
  4: _style.default.position4
};
const unstackByPosition = {
  0: _style.default.slideOutAndIn0,
  1: _style.default.slideOutAndIn1,
  2: _style.default.slideOutAndIn2,
  3: _style.default.slideOutAndIn3,
  4: _style.default.slideOutAndIn4
};
const getSlideAnimation = (action, position) => {
  switch (action) {
    case 'unstack':
      return _style.default.slideOutHideAndIn;
    case 'restack':
      return unstackByPosition[position];
    default:
      return null;
  }
};
const StackedSlides = ({
  slides,
  endReview,
  validateButton,
  correctionPopinProps
}) => {
  const stackedSlides = [];
  // eslint-disable-next-line fp/no-loops
  for (let slideIndex = 0; slideIndex < TOTAL_SLIDES_STACK; slideIndex++) {
    const slide = slides[(0, _toString2.default)(slideIndex)];
    const {
      animationType,
      position
    } = slide;
    const slideView = /*#__PURE__*/_react.default.createElement("div", {
      key: `slide-${slideIndex}`,
      "data-name": `slide-${slideIndex}`,
      className: (0, _classnames.default)(_style.default.slideBase, getSlideAnimation(animationType, position), position < 0 ? _style.default.hiddenSlide : stylesByPosition[position], endReview ? _style.default.endReview : null)
    }, /*#__PURE__*/_react.default.createElement(_reviewSlide.default, {
      slideIndex: (0, _toString2.default)(slideIndex),
      slide,
      validateButton,
      correctionPopinProps,
      key: slideIndex
    }));
    stackedSlides.push(slideView);
  }
  return /*#__PURE__*/_react.default.createElement("div", {
    key: "stacked-slides-container-y-overflow",
    className: _style.default.stackedSlidesYAxisOverflowContainer
  }, /*#__PURE__*/_react.default.createElement("div", {
    key: "stacked-slides-container",
    "data-name": "stacked-slides-container",
    className: _style.default.stackedSlidesContainer
  }, stackedSlides));
};
StackedSlides.propTypes = process.env.NODE_ENV !== "production" ? _propTypes.default : {};
var _default = exports.default = StackedSlides;
//# sourceMappingURL=index.js.map