"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-common/lib/format-message"));

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

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fcFqb',
  template: function template(theme) {
    return "\n\n.ResultStimulus__styles__root {\n  border-bottom: ".concat(theme.rootBorderWidth || 'inherit', " solid ").concat(theme.rootBorderColor || 'inherit', ";\n  overflow: hidden;\n}\n\n.ResultStimulus__styles__instructions {\n  padding: ").concat(theme.instructionsPaddingTopBottom || 'inherit', " ").concat(theme.instructionsPaddingLeftRight || 'inherit', ";\n  border: ").concat(theme.instructionsBorderWidth || 'inherit', " solid ").concat(theme.instructionsBorderColor || 'inherit', ";\n}\n\n.ResultStimulus__styles__instructionsHeader {\n  padding-bottom: ").concat(theme.instructionsHeaderPadding || 'inherit', ";\n  font-weight: ").concat(theme.instructionsHeaderFontWeight || 'inherit', ";\n}\n\n.ResultStimulus__styles__info {\n  padding: ").concat(theme.infoPaddingTopBottom || 'inherit', " ").concat(theme.infoPaddingLeftRight || 'inherit', ";\n  background-color: ").concat(theme.infoBackgroundColor || 'inherit', ";\n  height: 100%;\n  overflow: scroll;\n}\n\n.ResultStimulus__styles__header {\n  padding-top: ").concat(theme.headerPaddingTop || 'inherit', ";\n  padding-bottom: ").concat(theme.headerPaddingBottom || 'inherit', ";\n}\n\n.ResultStimulus__styles__title {\n  font-size: ").concat(theme.titleFontSize || 'inherit', ";\n  font-weight: ").concat(theme.titleFontWeight || 'inherit', ";\n}\n\n.ResultStimulus__styles__items {\n  padding: ").concat(theme.itemsPadding || 'inherit', ";\n  width: 50%;\n}\n\n.ResultStimulus__styles__stimulusItem {\n  flex: 1 1 auto;\n}\n\n.ResultStimulus__styles__stimulusGroup {\n  display: flex;\n  flex-direction: row;\n}\n\n.ResultStimulus__styles__stimulusInfo {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  .ResultStimulus__styles__stimulusGroup {\n    flex-direction: column;\n  }\n\n  .ResultStimulus__styles__stimulusInfo {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__items {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__instructions {\n    padding: ").concat(theme.phoneInstructionsPaddingTopBottom || 'inherit', " ").concat(theme.phoneInstructionsPaddingLeftRight || 'inherit', ";\n  }\n\n  .ResultStimulus__styles__info {\n    padding: ").concat(theme.phoneInfoPadding || 'inherit', ";\n  }\n\n  .ResultStimulus__styles__connectingLines {\n    flex: 0 0 1rem;\n\n    border-left: ").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;\n    border-bottom: ").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;\n    border-color: ").concat(theme.phoneConnectingLinesBorderColor || 'inherit', ";\n\n    margin-top: ").concat(theme.phoneConnectingLinesMargin || 'inherit', ";\n    margin-right: ").concat(theme.phoneConnectingLinesMargin || 'inherit', ";\n    height: 2rem;\n    width: 1.5rem;\n  }\n}\n");
  },
  'root': 'ResultStimulus__styles__root',
  'instructions': 'ResultStimulus__styles__instructions',
  'instructionsHeader': 'ResultStimulus__styles__instructionsHeader',
  'info': 'ResultStimulus__styles__info',
  'header': 'ResultStimulus__styles__header',
  'title': 'ResultStimulus__styles__title',
  'items': 'ResultStimulus__styles__items',
  'stimulusItem': 'ResultStimulus__styles__stimulusItem',
  'stimulusGroup': 'ResultStimulus__styles__stimulusGroup',
  'stimulusInfo': 'ResultStimulus__styles__stimulusInfo',
  'connectingLines': 'ResultStimulus__styles__connectingLines'
};
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
        }, "Enstriksyon"), _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;