/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var utils_dom = require('../utils/dom.js');
var configProvider_configProvider = require('../config-provider/config-provider.js');
var dialog_dialog = require('./dialog.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('lodash/isNumber');
require('lodash/throttle');
require('@ldesign/icons-vue');
require('../button/index.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../button/button.js');
require('../loading/index.js');
require('../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../loading/loading.js');
require('../utils/render-tnode.js');
require('@vue/composition-api');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isArray');
require('../utils/ripple.js');
require('../button/props.js');
require('../utils/event.js');
require('../utils/helper.js');
require('../hooks/useDestroyOnClose.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('./stack.js');
require('./props.js');
require('./actions.js');
require('../_chunks/dep-c3e1ffac.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var createDialog = function createDialog(props) {
  var options = _objectSpread({}, props);
  var globalOptions = Vue__default["default"].prototype[configProvider_configProvider.globalConfigSymbol];
  var dialog = new dialog_dialog["default"]({
    propsData: _objectSpread(_objectSpread({}, options), {}, {
      onClose: options.onClose || function () {
        dialog.visible = false;
      },
      instanceGlobal: globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.dialog
    })
  }).$mount();
  dialog.visible = true;
  if (options.className) {
    options.className.split(" ").forEach(function (name) {
      dialog.$el.classList.add(name.trim());
    });
  }
  if (options.style) dialog.$el.style.cssText += options.style;
  var container = utils_dom.getAttach(options.attach);
  if (container) container.appendChild(dialog.$el);else console.error("attach is not exist");
  var dialogNode = {
    show: function show() {
      dialog.visible = true;
    },
    hide: function hide() {
      dialog.visible = false;
    },
    update: function update(options2) {
      Object.assign(dialog, options2);
    },
    destroy: function destroy() {
      dialog.visible = false;
      container.contains(dialog.$el) && container.removeChild(dialog.$el);
    }
  };
  return dialogNode;
};
var confirm = function confirm(props) {
  return createDialog(props);
};
var alert = function alert(props) {
  var options = _objectSpread({}, props);
  options.cancelBtn = null;
  return createDialog(options);
};
var extraApi = {
  confirm: confirm,
  alert: alert
};
var _DialogPlugin = {
  install: function install() {
    Vue__default["default"].prototype.$dialog = createDialog;
    Object.keys(extraApi).forEach(function (funcName) {
      Vue__default["default"].prototype.$dialog[funcName] = extraApi[funcName];
    });
  }
};
Object.keys(extraApi).forEach(function (funcName) {
  _DialogPlugin[funcName] = extraApi[funcName];
});
var DialogPlugin = _DialogPlugin;

exports.DialogPlugin = DialogPlugin;
exports["default"] = DialogPlugin;
//# sourceMappingURL=plugin.js.map
