"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index$2 = require("../../teleport/index.js");
const index = require("../../../hooks/use-deprecated/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const index$4 = require("../../../hooks/use-same-target/index.js");
const index$5 = require("../../focus-trap/index.js");
const dialog = require("./dialog.js");
const index$3 = require("../../overlay/index.js");
const constants = require("./constants.js");
const dialogContent2 = require("./dialog-content2.js");
const useDialog = require("./use-dialog.js");
const Vue = require("vue");
const _hoisted_1 = [
  "aria-label",
  "aria-labelledby",
  "aria-describedby"
];
var dialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElDialog",
  inheritAttrs: false,
  __name: "dialog",
  props: dialog.dialogProps,
  emits: dialog.dialogEmits,
  setup(__props, { expose: __expose }) {
    const props = __props;
    const slots = Vue.useSlots();
    index.useDeprecated({
      scope: "el-dialog",
      from: "the title slot",
      replacement: "the header slot",
      version: "3.0.0",
      ref: "https://element-plus.org/en-US/component/dialog.html#slots"
    }, Vue.computed(() => !!slots.title));
    const ns = index$1.useNamespace("dialog");
    const dialogRef = Vue.ref();
    const headerRef = Vue.ref();
    const dialogContentRef = Vue.ref();
    const { visible, titleId, bodyId, style, overlayDialogStyle, rendered, transitionConfig, zIndex, _draggable, _alignCenter, _overflow, handleClose, onModalClick, onOpenAutoFocus, onCloseAutoFocus, onCloseRequested, onFocusoutPrevented, closing } = useDialog.useDialog(props, dialogRef);
    Vue.provide(constants.dialogInjectionKey, {
      dialogRef,
      headerRef,
      bodyId,
      ns,
      rendered,
      style
    });
    const overlayEvent = index$4.useSameTarget(onModalClick);
    const penetrable = Vue.computed(() => props.modalPenetrable && !props.modal && !props.fullscreen);
    const resetPosition = () => {
      var _a;
      (_a = dialogContentRef.value) == null ? void 0 : _a.resetPosition();
    };
    __expose({
      visible,
      dialogContentRef,
      resetPosition,
      handleClose
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.unref(index$2.ElTeleport), {
        to: __props.appendTo,
        disabled: __props.appendTo !== "body" ? false : !__props.appendToBody
      }, {
        default: Vue.withCtx(() => [Vue.createVNode(Vue.Transition, Vue.mergeProps(Vue.unref(transitionConfig), { persisted: "" }), {
          default: Vue.withCtx(() => [Vue.withDirectives(Vue.createVNode(Vue.unref(index$3.ElOverlay), {
            "custom-mask-event": "",
            mask: __props.modal,
            "overlay-class": [
              __props.modalClass ?? "",
              `${Vue.unref(ns).namespace.value}-modal-dialog`,
              Vue.unref(ns).is("penetrable", penetrable.value)
            ],
            "z-index": Vue.unref(zIndex)
          }, {
            default: Vue.withCtx(() => [Vue.createElementVNode("div", {
              role: "dialog",
              "aria-modal": "true",
              "aria-label": __props.title || void 0,
              "aria-labelledby": !__props.title ? Vue.unref(titleId) : void 0,
              "aria-describedby": Vue.unref(bodyId),
              class: Vue.normalizeClass([`${Vue.unref(ns).namespace.value}-overlay-dialog`, Vue.unref(ns).is("closing", Vue.unref(closing))]),
              style: Vue.normalizeStyle(Vue.unref(overlayDialogStyle)),
              onClick: _cache[0] || (_cache[0] = (...args) => Vue.unref(overlayEvent).onClick && Vue.unref(overlayEvent).onClick(...args)),
              onMousedown: _cache[1] || (_cache[1] = (...args) => Vue.unref(overlayEvent).onMousedown && Vue.unref(overlayEvent).onMousedown(...args)),
              onMouseup: _cache[2] || (_cache[2] = (...args) => Vue.unref(overlayEvent).onMouseup && Vue.unref(overlayEvent).onMouseup(...args))
            }, [Vue.createVNode(Vue.unref(index$5.default), {
              loop: "",
              trapped: Vue.unref(visible),
              "focus-start-el": "container",
              onFocusAfterTrapped: Vue.unref(onOpenAutoFocus),
              onFocusAfterReleased: Vue.unref(onCloseAutoFocus),
              onFocusoutPrevented: Vue.unref(onFocusoutPrevented),
              onReleaseRequested: Vue.unref(onCloseRequested)
            }, {
              default: Vue.withCtx(() => [Vue.unref(rendered) ? (Vue.openBlock(), Vue.createBlock(dialogContent2.default, Vue.mergeProps({
                key: 0,
                ref_key: "dialogContentRef",
                ref: dialogContentRef
              }, _ctx.$attrs, {
                center: __props.center,
                "align-center": Vue.unref(_alignCenter),
                "close-icon": __props.closeIcon,
                draggable: Vue.unref(_draggable),
                overflow: Vue.unref(_overflow),
                fullscreen: __props.fullscreen,
                "header-class": __props.headerClass,
                "body-class": __props.bodyClass,
                "footer-class": __props.footerClass,
                "show-close": __props.showClose,
                title: __props.title,
                "aria-level": __props.headerAriaLevel,
                onClose: Vue.unref(handleClose)
              }), Vue.createSlots({
                header: Vue.withCtx(() => [!_ctx.$slots.title ? Vue.renderSlot(_ctx.$slots, "header", {
                  key: 0,
                  close: Vue.unref(handleClose),
                  titleId: Vue.unref(titleId),
                  titleClass: Vue.unref(ns).e("title")
                }) : Vue.renderSlot(_ctx.$slots, "title", { key: 1 })]),
                default: Vue.withCtx(() => [Vue.renderSlot(_ctx.$slots, "default")]),
                _: 2
              }, [_ctx.$slots.footer ? {
                name: "footer",
                fn: Vue.withCtx(() => [Vue.renderSlot(_ctx.$slots, "footer")]),
                key: "0"
              } : void 0]), 1040, [
                "center",
                "align-center",
                "close-icon",
                "draggable",
                "overflow",
                "fullscreen",
                "header-class",
                "body-class",
                "footer-class",
                "show-close",
                "title",
                "aria-level",
                "onClose"
              ])) : Vue.createCommentVNode("v-if", true)]),
              _: 3
            }, 8, [
              "trapped",
              "onFocusAfterTrapped",
              "onFocusAfterReleased",
              "onFocusoutPrevented",
              "onReleaseRequested"
            ])], 46, _hoisted_1)]),
            _: 3
          }, 8, [
            "mask",
            "overlay-class",
            "z-index"
          ]), [[Vue.vShow, Vue.unref(visible)]])]),
          _: 3
        }, 16)]),
        _: 3
      }, 8, ["to", "disabled"]);
    };
  }
});
exports.default = dialog_vue_vue_type_script_setup_true_lang_default;
