import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { style } from 'typestyle';
import Dialog from '@material-ui/core/Dialog';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import DialogActions from '@material-ui/core/DialogActions';
import AlertError from '@material-ui/icons/Error';
import red from '@material-ui/core/colors/red';
import { Confirm, Abort } from './Buttons';
var cn = {
  root: style({
    textAlign: 'center'
  }),
  icon: style({
    marginRight: 10,
    marginBottom: -6,
    color: red['400']
  })
};

var DeleteDialog =
/*#__PURE__*/
function (_Component) {
  _inherits(DeleteDialog, _Component);

  function DeleteDialog(props) {
    var _this;

    _classCallCheck(this, DeleteDialog);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(DeleteDialog).call(this, props));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleDelete", function () {
      var _this$props = _this.props,
          resolve = _this$props.resolve,
          onRequestClose = _this$props.onRequestClose,
          content = _this$props.content;
      resolve(content);
      onRequestClose();
    });

    return _this;
  }

  _createClass(DeleteDialog, [{
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          onRequestClose = _this$props2.onRequestClose,
          content = _this$props2.content;
      return React.createElement(Dialog, {
        open: true,
        onClose: onRequestClose
      }, React.createElement(DialogTitle, null, "Do you really want to delete ", React.createElement("b", null, content && content.name), "?"), React.createElement(DialogContent, {
        style: cn.root
      }, React.createElement(AlertError, {
        style: cn.icon
      }), "This operation can not be undone."), React.createElement(DialogActions, null, React.createElement(Abort, {
        onClick: onRequestClose
      }, "Cancel"), ",", React.createElement(Confirm, {
        onClick: this.handleDelete
      }, "Delete")));
    }
  }]);

  return DeleteDialog;
}(Component);

_defineProperty(DeleteDialog, "propTypes", {
  resolve: PropTypes.func.isRequired,
  onRequestClose: PropTypes.func.isRequired,
  content: PropTypes.any
});

export { DeleteDialog as default };