import { defineComponent, ref, watch, openBlock, createBlock, withCtx, unref, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createCommentVNode } from "vue";
import "../../../adapter-vue.mjs";
import Overlay from "../Overlay/index.vue.mjs";
const _hoisted_1 = { class: "drawer-container" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    visible: { type: Boolean, default: true },
    popDirection: { default: "bottom" },
    useMask: { type: Boolean, default: true },
    isFullScreen: { type: Boolean, default: true },
    overlayColor: {},
    drawerStyle: { default: () => ({}) }
  },
  emits: ["onOverlayClick"],
  setup(__props, { expose: __expose, emit: __emit }) {
    var _a;
    const emits = __emit;
    const props = __props;
    const drawerDomRef = ref();
    const overlayDomInstanceRef = ref();
    const isDrawerShow = ref(false);
    const styles = ref(props.drawerStyle[props.popDirection] || {});
    watch(() => props.visible, (visible) => {
      if (visible) {
        isDrawerShow.value = true;
      } else {
        setTimeout(() => {
          isDrawerShow.value = false;
        }, 150);
      }
    }, {
      immediate: true
    });
    function onOverlayClick(e) {
      emits("onOverlayClick", e);
    }
    __expose({
      drawerDomRef,
      overlayDomRef: (_a = overlayDomInstanceRef.value) == null ? void 0 : _a.overlayDomRef
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(Overlay, {
        ref_key: "overlayDomInstanceRef",
        ref: overlayDomInstanceRef,
        visible: props.visible,
        useMask: props.useMask,
        maskColor: props.overlayColor,
        isFullScreen: props.isFullScreen,
        onOnOverlayClick: onOverlayClick
      }, {
        default: withCtx(() => [
          unref(isDrawerShow) ? (openBlock(), createElementBlock("div", {
            key: 0,
            ref_key: "drawerDomRef",
            ref: drawerDomRef,
            class: normalizeClass({
              "drawer": true,
              "origin-bottom": props.popDirection === "bottom",
              "origin-right": props.popDirection === "right",
              "slide-bottom": _ctx.visible && props.popDirection === "bottom",
              "slide-right": _ctx.visible && props.popDirection === "right"
            }),
            style: normalizeStyle({
              minHeight: unref(styles).minHeight,
              maxHeight: unref(styles).maxHeight,
              borderRadius: unref(styles).borderRadius,
              boxShadow: unref(styles).boxShadow,
              width: unref(styles).width
            })
          }, [
            createElementVNode("div", _hoisted_1, [
              renderSlot(_ctx.$slots, "default", {}, void 0, true)
            ])
          ], 6)) : createCommentVNode("", true)
        ]),
        _: 3
      }, 8, ["visible", "useMask", "maskColor", "isFullScreen"]);
    };
  }
});
export {
  _sfc_main as default
};
