"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _reactDom = _interopRequireDefault(require("react-dom"));

require("./index.less");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var _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["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "message-container"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "modal-shadow",
      onClick: this.close
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: "modal-content"
    }, title && /*#__PURE__*/_react["default"].createElement("div", {
      className: "modal-title"
    }, title), /*#__PURE__*/_react["default"].createElement("div", {
      className: "modal-message"
    }, content), /*#__PURE__*/_react["default"].createElement("div", {
      className: "modal-btn-wrap"
    }, cancelText && /*#__PURE__*/_react["default"].createElement("button", {
      className: "cancel",
      onClick: function onClick() {
        return _this.onCancel(onCancel);
      }
    }, cancelText), okText && /*#__PURE__*/_react["default"].createElement("button", {
      className: "confirm",
      onClick: function onClick() {
        return _this.onOk(onOk);
      }
    }, okText)))));

    _reactDom["default"].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();
  }
};
exports["default"] = _default;