"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 _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

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

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

var _RichContentRenderer = _interopRequireDefault(require("@instructure/quiz-rce/lib/components/RichContentRenderer"));

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

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

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fcFqb',
  template: function template(theme) {
    return "\n\n.fcFqb_bGBk{border-bottom:".concat(theme.rootBorderWidth || 'inherit', " solid ").concat(theme.rootBorderColor || 'inherit', ";overflow:hidden}\n\n.fcFqb_pJNU{border:").concat(theme.instructionsBorderWidth || 'inherit', " solid ").concat(theme.instructionsBorderColor || 'inherit', ";padding:").concat(theme.instructionsPaddingTopBottom || 'inherit', " ").concat(theme.instructionsPaddingLeftRight || 'inherit', "}\n\n.fcFqb_dEpm{font-weight:").concat(theme.instructionsHeaderFontWeight || 'inherit', ";padding-bottom:").concat(theme.instructionsHeaderPadding || 'inherit', "}\n\n.fcFqb_pypk{background-color:").concat(theme.infoBackgroundColor || 'inherit', ";height:100%;overflow:scroll;padding:").concat(theme.infoPaddingTopBottom || 'inherit', " ").concat(theme.infoPaddingLeftRight || 'inherit', "}\n\n.fcFqb_fsuY{padding-bottom:").concat(theme.headerPaddingBottom || 'inherit', ";padding-top:").concat(theme.headerPaddingTop || 'inherit', "}\n\n.fcFqb_nvdO{font-size:").concat(theme.titleFontSize || 'inherit', ";font-weight:").concat(theme.titleFontWeight || 'inherit', "}\n\n.fcFqb_JelF{padding:").concat(theme.itemsPadding || 'inherit', ";width:50%}\n\n.fcFqb_boAJ{flex:1 1 auto}\n\n.fcFqb_bbyJ{display:flex;flex-direction:row}\n\n.fcFqb_eNQJ{width:50%}\n\n@media screen and (--phoneBreakPoint){.fcFqb_bbyJ{flex-direction:column}.fcFqb_JelF,.fcFqb_eNQJ{width:100%}.fcFqb_pJNU{padding:").concat(theme.phoneInstructionsPaddingTopBottom || 'inherit', " ").concat(theme.phoneInstructionsPaddingLeftRight || 'inherit', "}.fcFqb_pypk{padding:").concat(theme.phoneInfoPadding || 'inherit', "}.fcFqb_eGWt{border-bottom:").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;border-color:").concat(theme.phoneConnectingLinesBorderColor || 'inherit', ";border-left:").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;flex:0 0 1rem;height:2rem;margin-right:").concat(theme.phoneConnectingLinesMargin || 'inherit', ";margin-top:").concat(theme.phoneConnectingLinesMargin || 'inherit', ";width:1.5rem}}");
  },
  'root': 'fcFqb_bGBk',
  'instructions': 'fcFqb_pJNU',
  'instructionsHeader': 'fcFqb_dEpm',
  'info': 'fcFqb_pypk',
  'header': 'fcFqb_fsuY',
  'title': 'fcFqb_nvdO',
  'items': 'fcFqb_JelF',
  'stimulusItem': 'fcFqb_boAJ',
  'stimulusGroup': 'fcFqb_bbyJ',
  'stimulusInfo': 'fcFqb_eNQJ',
  'connectingLines': 'fcFqb_eGWt'
};
var ResultStimulus = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(ResultStimulus, _Component);

  function ResultStimulus() {
    (0, _classCallCheck2.default)(this, ResultStimulus);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ResultStimulus).apply(this, arguments));
  }

  (0, _createClass2.default)(ResultStimulus, [{
    key: "renderStimulusInstructions",
    value: function renderStimulusInstructions() {
      var instructions = this.props.stimulus.instructions;

      if (instructions) {
        return _react.default.createElement("div", {
          className: styles.instructions
        }, _react.default.createElement("div", {
          className: styles.instructionsHeader
        }, "\u8BF4\u660E"), _react.default.createElement("div", null, instructions));
      }
    }
  }, {
    key: "renderStimulusInfo",
    value: function renderStimulusInfo() {
      var title = this.props.stimulus.title;
      var body = this.props.stimulus.body;
      return _react.default.createElement("div", {
        className: styles.info
      }, _react.default.createElement("div", {
        className: styles.header
      }, _react.default.createElement("div", {
        className: styles.title
      }, title)), _react.default.createElement(_RichContentRenderer.default, {
        content: body
      }));
    }
  }, {
    key: "renderStimulusItems",
    value: function renderStimulusItems() {
      var _this = this;

      return this.props.sessionItem.getNestedEntries().toArray().map(function (sessionItem, i) {
        return _react.default.createElement("div", {
          key: sessionItem.position
        }, _react.default.createElement("div", {
          className: styles.connectingLines
        }), _react.default.createElement("div", {
          className: styles.stimulusItem
        }, _this.props.renderItem(sessionItem, i !== 0)));
      });
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", null, _react.default.createElement("div", {
        className: styles.root
      }, this.renderStimulusInstructions(), _react.default.createElement("div", {
        className: styles.stimulusGroup
      }, _react.default.createElement("div", {
        className: styles.stimulusInfo
      }, this.renderStimulusInfo()), _react.default.createElement("div", {
        className: styles.items
      }, this.renderStimulusItems()))));
    }
  }]);
  ResultStimulus.displayName = "ResultStimulus";
  return ResultStimulus;
}(_react.Component), _class2.propTypes = {
  stimulus: _reactImmutableProptypes.default.record.isRequired,
  sessionItem: _reactImmutableProptypes.default.record.isRequired,
  renderItem: _propTypes.default.func.isRequired
}, _temp)) || _class);
exports.default = ResultStimulus;