import React from 'react';
import ReactDOM from 'react-dom';
import './index.less';
export default {
  dom: null,
  success: function success(_ref) {
    var _this = this;

    var title = _ref.title,
        content = _ref.content,
        onOk = _ref.onOk,
        onCancel = _ref.onCancel,
        okText = _ref.okText,
        cancelText = _ref.cancelText;
    this.close();
    this.dom = document.createElement('div');
    this.dom.setAttribute('id', 'message_modal');
    var JSXdom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
      className: "message-container"
    }, /*#__PURE__*/React.createElement("div", {
      className: "modal-shadow",
      onClick: this.close
    }), /*#__PURE__*/React.createElement("div", {
      className: "modal-content"
    }, title && /*#__PURE__*/React.createElement("div", {
      className: "modal-title"
    }, title), /*#__PURE__*/React.createElement("div", {
      className: "modal-message"
    }, content), /*#__PURE__*/React.createElement("div", {
      className: "modal-btn-wrap"
    }, cancelText && /*#__PURE__*/React.createElement("button", {
      className: "cancel",
      onClick: function onClick() {
        return _this.onCancel(onCancel);
      }
    }, cancelText), okText && /*#__PURE__*/React.createElement("button", {
      className: "confirm",
      onClick: function onClick() {
        return _this.onOk(onOk);
      }
    }, okText)))));
    ReactDOM.render(JSXdom, this.dom);
    document.body.appendChild(this.dom);
  },
  onCancel: function onCancel(_onCancel) {
    _onCancel instanceof Function && _onCancel();
    this.close();
  },
  onOk: function onOk(_onOk) {
    _onOk instanceof Function && _onOk();
    this.close();
  },
  close: function close() {
    var dom = document.querySelector('#message_modal');
    dom && dom.remove();
  }
};