"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index$3 = require("../../teleport/index.js");
const index = require("../../../hooks/use-deprecated/index.js");
const index$2 = require("../../../hooks/use-locale/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const index$6 = require("../../icon/index.js");
const index$5 = require("../../focus-trap/index.js");
const index$4 = require("../../overlay/index.js");
const useDialog = require("../../dialog/src/use-dialog.js");
const drawer = require("./drawer.js");
const useResizable = require("./composables/useResizable.js");
const index$7 = require("../../../../../@element-plus/icons-vue/dist/index.js");
const Vue = require("vue");
const _hoisted_1 = [
  "aria-label",
  "aria-labelledby",
  "aria-describedby"
];
const _hoisted_2 = ["id", "aria-level"];
const _hoisted_3 = ["aria-label"];
const _hoisted_4 = ["id"];
var drawer_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElDrawer",
  inheritAttrs: false,
  __name: "drawer",
  props: drawer.drawerProps,
  emits: drawer.drawerEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const slots = Vue.useSlots();
    index.useDeprecated({
      scope: "el-drawer",
      from: "the title slot",
      replacement: "the header slot",
      version: "3.0.0",
      ref: "https://element-plus.org/en-US/component/drawer.html#slots"
    }, Vue.computed(() => !!slots.title));
    const drawerRef = Vue.ref();
    const focusStartRef = Vue.ref();
    const draggerRef = Vue.ref();
    const ns = index$1.useNamespace("drawer");
    const { t } = index$2.useLocale();
    const { afterEnter, afterLeave, beforeLeave, visible, rendered, titleId, bodyId, zIndex, onModalClick, onOpenAutoFocus, onCloseAutoFocus, onFocusoutPrevented, onCloseRequested, handleClose } = useDialog.useDialog(props, drawerRef);
    const { isHorizontal, size, isResizing } = useResizable.useResizable(props, draggerRef, emit);
    const penetrable = Vue.computed(() => props.modalPenetrable && !props.modal);
    __expose({
      handleClose,
      afterEnter,
      afterLeave
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.unref(index$3.ElTeleport), {
        to: __props.appendTo,
        disabled: __props.appendTo !== "body" ? false : !__props.appendToBody
      }, {
        default: Vue.withCtx(() => [Vue.createVNode(Vue.Transition, {
          name: Vue.unref(ns).b("fade"),
          onAfterEnter: Vue.unref(afterEnter),
          onAfterLeave: Vue.unref(afterLeave),
          onBeforeLeave: Vue.unref(beforeLeave),
          persisted: ""
        }, {
          default: Vue.withCtx(() => [Vue.withDirectives(Vue.createVNode(Vue.unref(index$4.ElOverlay), {
            mask: __props.modal,
            "overlay-class": [
              Vue.unref(ns).is("drawer"),
              __props.modalClass ?? "",
              `${Vue.unref(ns).namespace.value}-modal-drawer`,
              Vue.unref(ns).is("penetrable", penetrable.value)
            ],
            "z-index": Vue.unref(zIndex),
            onClick: Vue.unref(onModalClick)
          }, {
            default: Vue.withCtx(() => [Vue.createVNode(Vue.unref(index$5.default), {
              loop: "",
              trapped: Vue.unref(visible),
              "focus-trap-el": drawerRef.value,
              "focus-start-el": focusStartRef.value,
              onFocusAfterTrapped: Vue.unref(onOpenAutoFocus),
              onFocusAfterReleased: Vue.unref(onCloseAutoFocus),
              onFocusoutPrevented: Vue.unref(onFocusoutPrevented),
              onReleaseRequested: Vue.unref(onCloseRequested)
            }, {
              default: Vue.withCtx(() => [Vue.createElementVNode("div", Vue.mergeProps({
                ref_key: "drawerRef",
                ref: drawerRef,
                "aria-modal": "true",
                "aria-label": __props.title || void 0,
                "aria-labelledby": !__props.title ? Vue.unref(titleId) : void 0,
                "aria-describedby": Vue.unref(bodyId)
              }, _ctx.$attrs, {
                class: [
                  Vue.unref(ns).b(),
                  __props.direction,
                  Vue.unref(visible) && "open",
                  Vue.unref(ns).is("dragging", Vue.unref(isResizing))
                ],
                style: { [Vue.unref(isHorizontal) ? "width" : "height"]: Vue.unref(size) },
                role: "dialog",
                onClick: _cache[1] || (_cache[1] = Vue.withModifiers(() => {
                }, ["stop"]))
              }), [
                Vue.createElementVNode("span", {
                  ref_key: "focusStartRef",
                  ref: focusStartRef,
                  class: Vue.normalizeClass(Vue.unref(ns).e("sr-focus")),
                  tabindex: "-1"
                }, null, 2),
                __props.withHeader ? (Vue.openBlock(), Vue.createElementBlock("header", {
                  key: 0,
                  class: Vue.normalizeClass([Vue.unref(ns).e("header"), __props.headerClass])
                }, [!_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.createElementVNode("span", {
                  id: Vue.unref(titleId),
                  role: "heading",
                  "aria-level": __props.headerAriaLevel,
                  class: Vue.normalizeClass(Vue.unref(ns).e("title"))
                }, Vue.toDisplayString(__props.title), 11, _hoisted_2)]) : Vue.renderSlot(_ctx.$slots, "title", { key: 1 }, () => [Vue.createCommentVNode(" DEPRECATED SLOT ")]), __props.showClose ? (Vue.openBlock(), Vue.createElementBlock("button", {
                  key: 2,
                  "aria-label": Vue.unref(t)("el.drawer.close"),
                  class: Vue.normalizeClass(Vue.unref(ns).e("close-btn")),
                  type: "button",
                  onClick: _cache[0] || (_cache[0] = (...args) => Vue.unref(handleClose) && Vue.unref(handleClose)(...args))
                }, [Vue.createVNode(Vue.unref(index$6.ElIcon), { class: Vue.normalizeClass(Vue.unref(ns).e("close")) }, {
                  default: Vue.withCtx(() => [Vue.createVNode(Vue.unref(index$7.Close))]),
                  _: 1
                }, 8, ["class"])], 10, _hoisted_3)) : Vue.createCommentVNode("v-if", true)], 2)) : Vue.createCommentVNode("v-if", true),
                Vue.unref(rendered) ? (Vue.openBlock(), Vue.createElementBlock("div", {
                  key: 1,
                  id: Vue.unref(bodyId),
                  class: Vue.normalizeClass([Vue.unref(ns).e("body"), __props.bodyClass])
                }, [Vue.renderSlot(_ctx.$slots, "default")], 10, _hoisted_4)) : Vue.createCommentVNode("v-if", true),
                _ctx.$slots.footer ? (Vue.openBlock(), Vue.createElementBlock("div", {
                  key: 2,
                  class: Vue.normalizeClass([Vue.unref(ns).e("footer"), __props.footerClass])
                }, [Vue.renderSlot(_ctx.$slots, "footer")], 2)) : Vue.createCommentVNode("v-if", true),
                __props.resizable ? (Vue.openBlock(), Vue.createElementBlock("div", {
                  key: 3,
                  ref_key: "draggerRef",
                  ref: draggerRef,
                  style: Vue.normalizeStyle({ zIndex: Vue.unref(zIndex) }),
                  class: Vue.normalizeClass(Vue.unref(ns).e("dragger"))
                }, null, 6)) : Vue.createCommentVNode("v-if", true)
              ], 16, _hoisted_1)]),
              _: 3
            }, 8, [
              "trapped",
              "focus-trap-el",
              "focus-start-el",
              "onFocusAfterTrapped",
              "onFocusAfterReleased",
              "onFocusoutPrevented",
              "onReleaseRequested"
            ])]),
            _: 3
          }, 8, [
            "mask",
            "overlay-class",
            "z-index",
            "onClick"
          ]), [[Vue.vShow, Vue.unref(visible)]])]),
          _: 3
        }, 8, [
          "name",
          "onAfterEnter",
          "onAfterLeave",
          "onBeforeLeave"
        ])]),
        _: 3
      }, 8, ["to", "disabled"]);
    };
  }
});
exports.default = drawer_vue_vue_type_script_setup_true_lang_default;
