"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: 'MhKHA',
  template: function template(theme) {
    return "\n\n.MhKHA_ePYF{background-color:".concat(theme.newItemButtonBackgroundColor || 'inherit', ";border:none;border-radius:").concat(theme.newItemButtonBorderRadius || 'inherit', ";box-shadow:").concat(theme.newItemButtonBoxShadow || 'inherit', ";color:").concat(theme.newItemButtonColor || 'inherit', ";font-size:").concat(theme.newItemButtonFontSize || 'inherit', ";font-weight:").concat(theme.newItemButtonFontWeight || 'inherit', ";line-height:0;margin:").concat(theme.newItemButtonMargin || 'inherit', ";padding:").concat(theme.newItemButtonPadding || 'inherit', ";text-align:center;transform:rotate(0deg);transition:background-color 500ms linear,transform 500ms ease;z-index:").concat(theme.newItemButtonZIndex || 'inherit', "}\n\n[dir=ltr] .MhKHA_ePYF,[dir=rtl] .MhKHA_ePYF{text-align:center}\n\n.MhKHA_ePYF:focus{outline:").concat(theme.newItemButtonFocusOutline || 'inherit', "}\n\n.MhKHA_ePYF.MhKHA_cwUE{background-color:").concat(theme.newItemButtonEditingBackgroundColor || 'inherit', ";transform:rotate(45deg);transition:background-color 500ms linear,transform 500ms ease}\n\n.MhKHA_ekys{display:flex;justify-content:center;margin-top:-1.5rem;width:100%;z-index:").concat(theme.newItemButtonHolderZIndex || 'inherit', "}\n\n.MhKHA_egTu{display:flex;justify-content:center;width:100%;z-index:").concat(theme.attachQuestionButtonHolderZIndex || 'inherit', "}");
  },
  'newItemButton': 'MhKHA_ePYF',
  'newItemButtonEditing': 'MhKHA_cwUE',
  'newItemButtonHolder': 'MhKHA_ekys',
  'attachQuestionButtonHolder': 'MhKHA_egTu'
};
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"
      }, "Attach Question"));
    }
  }, {
    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: "Add content"
      })));
    }
  }, {
    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;