import { defineComponent as a, ref as s, onMounted as d, onBeforeUnmount as u, openBlock as c, createBlock as m, Teleport as _, createElementVNode as f, createVNode as p, Transition as k, withCtx as v, createElementBlock as C, renderSlot as h, createCommentVNode as B } from "vue";
const E = { class: "cds-modal" }, y = /* @__PURE__ */ a({
  __name: "index",
  emits: ["close-modal"],
  setup(T, { emit: l }) {
    const e = s(null), o = s(!0), r = () => document.addEventListener("click", n, !0), n = (t) => {
      (e.value ? e.value.contains(t.target) : null) || (o.value = !1, setTimeout(() => l("close-modal"), 350));
    };
    return d(() => setTimeout(() => r(), 40)), u(() => document.removeEventListener("click", n, !0)), (t, i) => (c(), m(_, { to: "body" }, [
      f("div", E, [
        p(k, {
          name: "slide-top",
          mode: "in-out",
          appear: ""
        }, {
          default: v(() => [
            o.value ? (c(), C("div", {
              key: 0,
              class: "cds-modal__inner",
              ref_key: "inner",
              ref: e
            }, [
              h(t.$slots, "default")
            ], 512)) : B("", !0)
          ]),
          _: 3
        })
      ])
    ]));
  }
});
export {
  y as default
};
//# sourceMappingURL=index-143f8d5e.mjs.map
