'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var shared = require('@vue/shared');
require('../../../../utils/index.js');
var elementPlus = require('element-plus');
var is = require('../../../../utils/src/is.js');

function MessageBox(options, appContext = null) {
  if (is.isString(options) || vue.isVNode(options)) {
    options = {
      message: options
    };
  }
  return elementPlus.ElMessageBox(options, appContext);
}
const MESSAGE_BOX_VARIANTS = ["alert", "confirm", "prompt"];
const MESSAGE_BOX_DEFAULT_OPTS = {
  alert: { closeOnPressEscape: false, closeOnClickModal: false },
  confirm: { showCancelButton: true },
  prompt: { showCancelButton: true, showInput: true }
};
MESSAGE_BOX_VARIANTS.forEach((boxType) => {
  MessageBox[boxType] = messageBoxFactory(boxType);
});
function messageBoxFactory(boxType) {
  return (message, title, options, appContext) => {
    let titleOrOpts = "";
    if (shared.isObject(title)) {
      options = title;
      titleOrOpts = "";
    } else if (is.isUndefined(title)) {
      titleOrOpts = "";
    } else {
      titleOrOpts = title;
    }
    return MessageBox(
      Object.assign(
        {
          title: titleOrOpts,
          message,
          type: "",
          ...MESSAGE_BOX_DEFAULT_OPTS[boxType]
        },
        options,
        {
          boxType
        }
      ),
      appContext
    );
  };
}
MessageBox.close = elementPlus.ElMessageBox.close;
MessageBox._context = elementPlus.ElMessageBox._context;

exports.default = MessageBox;
//# sourceMappingURL=method.js.map
