'use strict';

import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import { Popup } from './Popup';
import { Button } from '../Button';
import { DangerousHTML } from '../DangerousHTML';
export var Alert =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(Alert, _React$Component);

  function Alert(props, context) {
    var _this;

    _this = _React$Component.call(this, props, context) || this;
    _this.submitAction = _this.submitAction.bind(_assertThisInitialized(_this));
    return _this;
  }

  var _proto = Alert.prototype;

  _proto.submitAction = function submitAction() {
    Popup.close();

    if (this.props.submitAction) {
      this.props.submitAction();
    }
  };

  _proto.render = function render() {
    var _this$props = this.props,
        buttonYesStyle = _this$props.buttonYesStyle,
        submitText = _this$props.submitText,
        submitAction = _this$props.submitAction,
        props = _objectWithoutPropertiesLoose(_this$props, ["buttonYesStyle", "submitText", "submitAction"]);

    var buttons = [React.createElement(Button, {
      testAutomationId: "buttonYes",
      key: "buttonYes",
      bsStyle: buttonYesStyle,
      onClick: this.submitAction
    }, React.createElement(DangerousHTML, null, submitText))];
    return React.createElement(Popup, _extends({}, props, {
      bsSize: "sm",
      footer: buttons,
      onClose: this.submitAction
    }));
  };

  return Alert;
}(React.Component);

_defineProperty(Alert, "propTypes", {
  buttonYesStyle: PropTypes.string,
  submitAction: PropTypes.func,
  submitText: PropTypes.string,
  title: PropTypes.string,
  testAutomationId: PropTypes.string,
  shouldDeriveDescFromBody: PropTypes.bool
});

_defineProperty(Alert, "defaultProps", {
  buttonYesStyle: 'primary',
  title: 'TRANSLATE:ALERT',
  submitText: 'TRANSLATE:OK',
  submitAction: null,
  testAutomationId: 'alert',
  shouldDeriveDescFromBody: true
});