"use strict";

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

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

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

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

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

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

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

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

var _react = _interopRequireWildcard(require("react"));

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _Heading = _interopRequireDefault(require("@instructure/ui-elements/lib/components/Heading"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

var _CustomPropTypes = _interopRequireDefault(require("../../../../util/CustomPropTypes"));

var _SessionItemResult = _interopRequireDefault(require("../SessionItemResult"));

var _ResultStimulus = _interopRequireDefault(require("../ResultStimulus"));

var _generateDisplayPositions = _interopRequireDefault(require("../../../../util/generateDisplayPositions"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'tONnG',
  template: function template(theme) {
    return "\n\n.tONnG_fnuh{margin:".concat(theme.sessionItemResultsListHeaderWrapperMarginTopBottom || 'inherit', " ").concat(theme.sessionItemResultsListHeaderWrapperMarginLeftRight || 'inherit', ";text-align:left}\n\n[dir=ltr] .tONnG_fnuh,[dir=rtl] .tONnG_fnuh{text-align:left}\n\n.tONnG_crKU{font-size:").concat(theme.sessionItemResultsListHeaderFontSize || 'inherit', "}\n\n.tONnG_cMxE{border-bottom:solid ").concat(theme.sessionItemResultsListBorderWidth || 'inherit', " ").concat(theme.sessionItemResultsListBorderColor || 'inherit', ";margin-top:").concat(theme.sessionItemResultsListMargin || 'inherit', "}");
  },
  'sessionItemResultsListHeaderWrapper': 'tONnG_fnuh',
  'sessionItemResultsListHeader': 'tONnG_crKU',
  'sessionItemResultsList': 'tONnG_cMxE'
};
var SessionItemResultsList = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(SessionItemResultsList, _Component);

  function SessionItemResultsList() {
    var _getPrototypeOf2;

    var _this;

    (0, _classCallCheck2.default)(this, SessionItemResultsList);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(SessionItemResultsList)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.renderSessionItem = function (sessionItem, shouldRenderTopBorder) {
      return _react.default.createElement(_SessionItemResult.default, {
        appContainer: _this.props.appContainer,
        key: sessionItem.id,
        sessionItem: sessionItem,
        sessionItemResult: sessionItem.sessionItemResult,
        shouldRenderTopBorder: shouldRenderTopBorder
      });
    };

    _this.renderItems = function () {
      return (0, _generateDisplayPositions.default)(_this.props.sessionItems).map(function (si) {
        return _this.renderItem(si.record);
      });
    };

    return _this;
  }

  (0, _createClass2.default)(SessionItemResultsList, [{
    key: "renderItem",
    value: function renderItem(sessionItem) {
      if (sessionItem.isStimulus) {
        return _react.default.createElement(_ResultStimulus.default, {
          key: sessionItem.id,
          renderItem: this.renderSessionItem,
          stimulus: sessionItem.stimulusRecord,
          sessionItem: sessionItem
        });
      }

      return this.renderSessionItem(sessionItem, true);
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", null, _react.default.createElement("div", {
        className: styles.sessionItemResultsListHeaderWrapper
      }, _react.default.createElement("div", {
        className: styles.sessionItemResultsListHeader,
        "data-automation": "sdk-session-item-results-list-header"
      }, _react.default.createElement(_Heading.default, {
        level: "h2"
      }, "\u0625\u062C\u0627\u0628\u0627\u062A\u0643:"))), _react.default.createElement("div", {
        className: styles.sessionItemResultsList
      }, this.renderItems()));
    }
  }]);
  SessionItemResultsList.displayName = "SessionItemResultsList";
  return SessionItemResultsList;
}(_react.Component), _class2.propTypes = {
  appContainer: _CustomPropTypes.default.selectors.isRequired,
  sessionItems: _reactImmutableProptypes.default.list.isRequired
}, _temp)) || _class);
exports.default = SessionItemResultsList;