import { defineComponent, ref, provide, computed, resolveComponent, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives, unref, createElementVNode, normalizeClass, normalizeStyle, createSlots, renderSlot, createCommentVNode, vShow } from 'vue';
import '../../../hooks/index.mjs';
import '../../../tokens/index.mjs';
import { dialogProps } from './dialog2.mjs';
import { useDialog } from './use-dialog.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { dialogInjectionKey } from '../../../tokens/dialog.mjs';
import { useDraggable } from '../../../hooks/use-draggable/index.mjs';

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

export { Dialog as default };
//# sourceMappingURL=dialog.mjs.map
