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

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 _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames = _interopRequireDefault(require("classnames"));

var _IconPlus = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconPlus"));

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

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

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

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

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'WGKSa',
  template: function template(theme) {
    return "\n\n.quiz-core__Button--newItemButton {\n  border: none;\n  margin: ".concat(theme.newItemButtonMargin || 'inherit', ";\n  padding: ").concat(theme.newItemButtonPadding || 'inherit', ";\n  background-color: ").concat(theme.newItemButtonBackgroundColor || 'inherit', ";\n  border-radius: ").concat(theme.newItemButtonBorderRadius || 'inherit', ";\n  line-height: 0;\n  font-size: ").concat(theme.newItemButtonFontSize || 'inherit', ";\n  font-weight: ").concat(theme.newItemButtonFontWeight || 'inherit', ";\n  text-align: center;\n  color: ").concat(theme.newItemButtonColor || 'inherit', ";\n  box-shadow: ").concat(theme.newItemButtonBoxShadow || 'inherit', ";\n  transform: rotate(0deg);\n  transition: ").concat(theme.newItemButtonTransition || 'inherit', ";\n  z-index: ").concat(theme.newItemButtonZIndex || 'inherit', ";\n}\n\n[dir=\"ltr\"] .quiz-core__Button--newItemButton {\n  text-align: center;\n}\n\n[dir=\"rtl\"] .quiz-core__Button--newItemButton {\n  text-align: center;\n}\n\n.quiz-core__Button--newItemButton:focus {\n  outline: ").concat(theme.newItemButtonFocusOutline || 'inherit', ";\n}\n\n.quiz-core__Button--newItemButton.quiz-core__Button--newItemButtonEditing {\n  background-color: ").concat(theme.newItemButtonEditingBackgroundColor || 'inherit', ";\n  transform: rotate(45deg);\n  transition: ").concat(theme.newItemButtonTransition || 'inherit', ";\n}\n\n.quiz-core__Button--newItemButtonHolder {\n  display: flex;\n  justify-content: center;\n  width: 100%;\n  z-index: ").concat(theme.newItemButtonHolderZIndex || 'inherit', ";\n  margin-top: -1.5rem;\n}\n\n.quiz-core__Button--attachQuestionButtonHolder {\n  display: flex;\n  justify-content: center;\n  width: 100%;\n  z-index: ").concat(theme.attachQuestionButtonHolderZIndex || 'inherit', ";\n}\n");
  },
  'newItemButton': 'quiz-core__Button--newItemButton',
  'newItemButtonEditing': 'quiz-core__Button--newItemButtonEditing',
  'newItemButtonHolder': 'quiz-core__Button--newItemButtonHolder',
  'attachQuestionButtonHolder': 'quiz-core__Button--attachQuestionButtonHolder'
};
var AddContentButton = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(AddContentButton, _Component);

  function AddContentButton() {
    var _getPrototypeOf2;

    var _this;

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

    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)(AddContentButton)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.storeButtonElemRef = function (c) {
      _this.buttonElem = c;
    };

    return _this;
  }

  (0, _createClass2.default)(AddContentButton, [{
    key: "focus",
    value: function focus() {
      this.buttonElem.focus();
    }
  }, {
    key: "renderStimulus",
    value: function renderStimulus() {
      return _react.default.createElement("div", {
        className: styles.attachQuestionButtonHolder
      }, _react.default.createElement(_Button.default, {
        ref: this.storeButtonElemRef,
        variant: "primary",
        margin: "medium",
        onClick: this.props.onClick,
        "data-automation": "sdk-attach-question-button"
      }, "L\xE4gg till fr\xE5ga"));
    }
  }, {
    key: "renderNonStimulus",
    value: function renderNonStimulus() {
      var _classNames;

      var buttonClasses = (0, _classnames.default)((_classNames = {}, (0, _defineProperty2.default)(_classNames, styles.newItemButton, true), (0, _defineProperty2.default)(_classNames, "newItemButton_".concat(this.props.position), true), (0, _defineProperty2.default)(_classNames, styles.newItemButtonEditing, this.props.isEditing), _classNames));
      return _react.default.createElement("div", {
        className: styles.newItemButtonHolder
      }, _react.default.createElement("button", {
        ref: this.storeButtonElemRef,
        onClick: this.props.onClick,
        className: buttonClasses,
        "data-automation": "sdk-add-content-button"
      }, _react.default.createElement(_IconPlus.default, {
        title: "L\xE4gg till inneh\xE5ll"
      })));
    }
  }, {
    key: "render",
    value: function render() {
      return this.props.useStimulusTrigger ? this.renderStimulus() : this.renderNonStimulus();
    }
  }]);
  AddContentButton.displayName = "AddContentButton";
  return AddContentButton;
}(_react.Component), _class2.propTypes = {
  isEditing: _propTypes.default.bool.isRequired,
  onClick: _propTypes.default.func,
  position: _propTypes.default.number.isRequired,
  useStimulusTrigger: _propTypes.default.bool.isRequired
}, _class2.defaultProps = {
  onClick: function onClick() {}
}, _temp)) || _class);
exports.default = AddContentButton;