'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp; /* eslint "jsx-a11y/click-events-have-key-events": "warn" */


var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

var _IconBankLine = require('instructure-icons/lib/Line/IconBankLine');

var _IconBankLine2 = _interopRequireDefault(_IconBankLine);

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

var _lib2 = _interopRequireDefault(_lib);

var _StimulusShowInfo = require('../StimulusShowInfo');

var _StimulusShowInfo2 = _interopRequireDefault(_StimulusShowInfo);

var _Overlay = require('../../../../../common/components/shared/overlay/Overlay');

var _Overlay2 = _interopRequireDefault(_Overlay);

var _index = require('../../../../../building/components/resources/ActionButtons/index');

var _index2 = _interopRequireDefault(_index);

var _formatMessage = require('../../../../format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.StimulusShow__styles__stimulus {\n  padding-top: ' + theme.stimulusPadding + ';\n  padding-bottom: ' + theme.stimulusPadding + ';\n}\n\n.StimulusShow__styles__header {\n  height: 1rem;\n  padding-left: ' + theme.headerPadding + ';\n  padding-right: ' + theme.headerPadding + ';\n\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n\n.StimulusShow__styles__leftHeader {\n  display: flex;\n  overflow: hidden;\n}\n\n.StimulusShow__styles__stimulusLabel {\n  color: ' + theme.stimulusLabelColor + ';\n  font-size: ' + theme.stimulusLabelFontSize + ';\n  margin: 0 ' + theme.stimulusLabelMargin + ';\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.StimulusShow__styles__stimulusContent {\n  height: 100%;\n  padding: ' + theme.stimulusContentPaddingTop + ' ' + theme.stimulusContentPaddingLeftRight + ' ' + theme.stimulusContentPaddingBottom + ';\n}\n';
  },
  'stimulus': 'StimulusShow__styles__stimulus',
  'header': 'StimulusShow__styles__header',
  'leftHeader': 'StimulusShow__styles__leftHeader',
  'stimulusLabel': 'StimulusShow__styles__stimulusLabel',
  'stimulusContent': 'StimulusShow__styles__stimulusContent'
};
var StimulusShow = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(StimulusShow, _Component);

  function StimulusShow() {
    (0, _classCallCheck3.default)(this, StimulusShow);
    return (0, _possibleConstructorReturn3.default)(this, (StimulusShow.__proto__ || Object.getPrototypeOf(StimulusShow)).apply(this, arguments));
  }

  (0, _createClass3.default)(StimulusShow, [{
    key: 'renderBankIcon',
    value: function renderBankIcon() {
      if (this.props.isBankedContent || this.props.quizEntry.isArchivedBankEntry) {
        return _react2.default.createElement(_IconBankLine2.default, null);
      }
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        _Overlay2.default,
        {
          onClick: this.props.switchOnEditing,
          wrapperClassName: styles.stimulusWrapper,
          tabIndex: '-1'
        },
        _react2.default.createElement(
          'div',
          { className: styles.stimulus },
          _react2.default.createElement(
            'div',
            { className: styles.header },
            _react2.default.createElement(
              'div',
              { className: styles.leftHeader },
              this.renderBankIcon(),
              _react2.default.createElement(
                'div',
                { className: styles.stimulusLabel },
                '\u523A\u6FC0'
              )
            ),
            _react2.default.createElement(_index2.default, {
              connectDragSource: this.props.connectDragSource,
              displayPosition: this.props.displayPosition,
              onDelete: this.props.openDeleteStimulusModal,
              quizEntries: this.props.quizEntries,
              quizEntry: this.props.quizEntry,
              scrollKey: this.props.scrollKey,
              shouldDisableDragHandle: this.props.shouldDisableDragHandle,
              switchOnEditing: this.props.switchOnEditing,
              shouldFocusOnMount: this.props.shouldFocusOnMount
            })
          ),
          _react2.default.createElement(
            'div',
            {
              role: 'presentation',
              onClick: this.props.switchOnEditing,
              className: styles.stimulusContent
            },
            _react2.default.createElement(_StimulusShowInfo2.default, { stimulus: this.props.stimulus })
          )
        )
      );
    }
  }]);
  StimulusShow.displayName = 'StimulusShow'
  ;
  return StimulusShow;
}(_react.Component), _class2.propTypes = {
  connectDragSource: _propTypes2.default.func.isRequired,
  displayPosition: _propTypes2.default.number.isRequired,
  isBankedContent: _propTypes2.default.bool,
  openDeleteStimulusModal: _propTypes2.default.func.isRequired,
  quizEntries: _reactImmutableProptypes2.default.listOf(_reactImmutableProptypes2.default.record).isRequired,
  quizEntry: _reactImmutableProptypes2.default.record.isRequired,
  scrollKey: _propTypes2.default.string,
  shouldDisableDragHandle: _propTypes2.default.bool,
  stimulus: _reactImmutableProptypes2.default.record.isRequired,
  switchOnEditing: _propTypes2.default.func.isRequired,
  shouldFocusOnMount: _propTypes2.default.bool.isRequired
}, _class2.defaultProps = {
  isBankedContent: false,
  scrollKey: '',
  shouldDisableDragHandle: false,
  shouldFocusOnMount: false
}, _temp)) || _class);
exports.default = StimulusShow;