'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, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

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

var _lib2 = _interopRequireDefault(_lib);

var _TakeButton = require('../TakeButton');

var _TakeButton2 = _interopRequireDefault(_TakeButton);

var _formatMessage = require('../../../../../common/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.TakeFooter__styles__footer {\n  padding: ' + theme.footerPadding + ';\n  display: flex;\n  align-items: center;\n  justify-content: flex-end;\n}\n\n.TakeFooter__styles__oqaatFooter {\n  padding: 0 1rem;\n  margin: ' + theme.oqaatFooterMargin + ' 0;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n';
  },
  'footer': 'TakeFooter__styles__footer',
  'oqaatFooter': 'TakeFooter__styles__oqaatFooter'
};
var TakeFooter = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp2 = _class2 = function (_Component) {
  (0, _inherits3.default)(TakeFooter, _Component);

  function TakeFooter() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, TakeFooter);

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

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = TakeFooter.__proto__ || Object.getPrototypeOf(TakeFooter)).call.apply(_ref, [this].concat(args))), _this), _this.previousQuestion = function () {
      var msg = '\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u0633\u0624\u0627\u0644 \u0627\u0644\u0633\u0627\u0628\u0642';
      _this.props.screenreaderNotification(msg);

      _this.props.previousQuestion();
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(TakeFooter, [{
    key: 'renderPreviousButton',
    value: function renderPreviousButton() {
      if (!this.props.shouldRenderPrevious) {
        return _react2.default.createElement('div', null);
      }

      return _react2.default.createElement(
        _Button2.default,
        { onClick: this.previousQuestion, variant: 'light' },
        '\u0627\u0644\u0633\u0627\u0628\u0642'
      );
    }
  }, {
    key: 'renderOQAATFooter',
    value: function renderOQAATFooter() {
      return _react2.default.createElement(
        'div',
        { className: styles.oqaatFooter },
        this.renderPreviousButton(),
        _react2.default.createElement(_TakeButton2.default, { onSubmitQuizSession: this.props.onSubmitQuizSession })
      );
    }
  }, {
    key: 'renderStandardFooter',
    value: function renderStandardFooter() {
      return _react2.default.createElement(
        'div',
        { className: styles.footer },
        _react2.default.createElement(_TakeButton2.default, { onSubmitQuizSession: this.props.onSubmitQuizSession })
      );
    }
  }, {
    key: 'render',
    value: function render() {
      return this.props.isOneQuestionAtATime ? this.renderOQAATFooter() : this.renderStandardFooter();
    }
  }]);
  TakeFooter.displayName = 'TakeFooter'
  ;
  return TakeFooter;
}(_react.Component), _class2.propTypes = {
  currentSessionItemPosition: _propTypes2.default.number.isRequired,
  isOneQuestionAtATime: _propTypes2.default.bool.isRequired,
  onSubmitQuizSession: _propTypes2.default.func, // consumer provided
  previousQuestion: _propTypes2.default.func.isRequired,
  quizSessionId: _propTypes2.default.string.isRequired,
  screenreaderNotification: _propTypes2.default.func.isRequired,
  shouldRenderPrevious: _propTypes2.default.bool.isRequired
}, _class2.defaultProps = {
  onSubmitQuizSession: function onSubmitQuizSession() {}
}, _temp2)) || _class);
exports.default = TakeFooter;