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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import { getAttach } from '../utils/dom.js';
import { globalConfigSymbol } from '../config-provider/config-provider.js';
import _Dialog from './dialog.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import 'lodash/isNumber';
import 'lodash/throttle';
import '@ldesign/icons-vue';
import '../button/index.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import 'lodash/isObject';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../loading/plugin.js';
import '../config.js';
import '../loading/loading.js';
import '../utils/render-tnode.js';
import '@vue/composition-api';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/transfer-dom.js';
import '../config-provider/config-receiver.js';
import '../utils/mixins.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isArray';
import '../loading/style/css.js';
import '../loading/type.js';
import '../utils/ripple.js';
import '../button/props.js';
import '../button/style/css.js';
import '../button/type.js';
import '../utils/event.js';
import '../utils/helper.js';
import '../hooks/useDestroyOnClose.js';
import '../_common/js/utils/getScrollbarWidth.js';
import './stack.js';
import './props.js';
import './actions.js';
import '../_chunks/dep-c89aafbb.js';

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(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.prototype[globalConfigSymbol];
  var dialog = new _Dialog({
    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 = 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.prototype.$dialog = createDialog;
    Object.keys(extraApi).forEach(function (funcName) {
      Vue.prototype.$dialog[funcName] = extraApi[funcName];
    });
  }
};
Object.keys(extraApi).forEach(function (funcName) {
  _DialogPlugin[funcName] = extraApi[funcName];
});
var DialogPlugin = _DialogPlugin;

export { DialogPlugin, DialogPlugin as default };
//# sourceMappingURL=plugin.js.map
