'use strict';

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

var vue = require('vue');
var index$2 = require('../../overlay/index.js');
require('../../../hooks/index.js');
require('../../../tokens/index.js');
var dialogContent = require('./dialog-content.js');
var dialog = require('./dialog.js');
var useDialog = require('./use-dialog.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var dialog$1 = require('../../../tokens/dialog.js');
var index$1 = require('../../../hooks/use-draggable/index.js');

const __default__ = {
  name: "PsDialog"
};
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: dialog.dialogProps,
  setup(__props, { expose }) {
    const props = __props;
    const ns = index.useNamespace("dialog");
    const dialogRef = vue.ref();
    const headerRef = vue.ref();
    const {
      visible,
      style,
      rendered,
      zIndex
    } = useDialog.useDialog(props, dialogRef);
    vue.provide(dialog$1.dialogInjectionKey, {
      dialogRef,
      headerRef,
      ns,
      rendered,
      style
    });
    const draggable = vue.computed(() => props.draggable && !props.fullscreen);
    index$1.useDraggable(dialogRef, headerRef, draggable);
    expose({
      visible
    });
    return (_ctx, _cache) => {
      return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(index$2.PsOverlay), {
        "custom-mask-event": "",
        mask: _ctx.modal,
        "overlay-class": (_ctx.modalClass || "") + (_ctx.widget ? ` ps--dialog-widget-class` : ""),
        "z-index": vue.unref(zIndex)
      }, {
        default: vue.withCtx(() => [
          vue.createElementVNode("div", {
            class: vue.normalizeClass(`${vue.unref(ns).namespace.value}-overlay-dialog`)
          }, [
            vue.unref(rendered) ? (vue.openBlock(), vue.createBlock(dialogContent["default"], {
              key: 0,
              "custom-class": _ctx.customClass,
              center: _ctx.center,
              "close-icon": _ctx.closeIcon,
              draggable: vue.unref(draggable),
              fullscreen: _ctx.fullscreen,
              "show-close": _ctx.showClose,
              style: vue.normalizeStyle(vue.unref(style)),
              title: _ctx.title,
              widget: _ctx.widget
            }, vue.createSlots({
              title: vue.withCtx(() => [
                vue.renderSlot(_ctx.$slots, "title")
              ]),
              default: vue.withCtx(() => [
                vue.renderSlot(_ctx.$slots, "default")
              ]),
              _: 2
            }, [
              _ctx.$slots.footer ? {
                name: "footer",
                fn: vue.withCtx(() => [
                  vue.renderSlot(_ctx.$slots, "footer")
                ])
              } : void 0
            ]), 1032, ["custom-class", "center", "close-icon", "draggable", "fullscreen", "show-close", "style", "title", "widget"])) : vue.createCommentVNode("v-if", true)
          ], 2)
        ]),
        _: 3
      }, 8, ["mask", "overlay-class", "z-index"])), [
        [vue.vShow, vue.unref(visible)]
      ]);
    };
  }
});
var Dialog = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/dialog/src/dialog.vue"]]);

exports["default"] = Dialog;
//# sourceMappingURL=dialog2.js.map
