import { defineComponent as E, ref as i, watch as S, unref as l, computed as n, openBlock as v, createBlock as w, withCtx as b, resolveDynamicComponent as z, mergeProps as C, renderSlot as F, createElementVNode as I, normalizeClass as N } from "vue";
import { useScrollLock as $ } from "@vueuse/core";
import "../config-provider/index.mjs";
import "../hooks/index.mjs";
import "../portal/index.mjs";
import B from "./style/index.mjs";
import { useFullScreen as L } from "../hooks/useFullScreen.mjs";
import { useNamespace as D } from "../config-provider/hooks/use-namespace.mjs";
import M from "../portal/index.vue.mjs";
const O = /* @__PURE__ */ E({
  name: "FullScreen",
  __name: "index",
  props: {
    wrapperElementName: { default: "div" },
    zIndex: { default: 2147483647 },
    to: { default: "body" }
  },
  setup(u, { expose: y }) {
    const {
      target: c,
      full: x,
      enter: g,
      exit: k
    } = L(), { b: m, bm: R, be: _ } = D("full-screen"), h = B("full-screen"), a = i(!1), t = i(), d = $(document.body), f = i();
    S(
      () => l(x),
      (e) => {
        e || (a.value = !1, t.value = void 0);
      }
    );
    async function r(e, o = !1) {
      await s(), a.value = !0, t.value = e, e === "browser" ? g(o) : d.value = !0;
    }
    async function s(e = !1) {
      a.value = !1, t.value === "browser" ? await k(e) : d.value = !1, t.value = void 0;
    }
    async function p(e, o = !1) {
      a.value ? t.value !== e ? await r(e, o) : await s(o) : await r(e, o);
    }
    return y({
      target: n(() => l(c)),
      portalRoot: n(() => l(f)),
      full: n(() => l(a)),
      mode: n(() => l(t)),
      enter: r,
      exit: s,
      toggle: p
    }), (e, o) => (v(), w(l(M), {
      to: u.to,
      disabled: t.value !== "window"
    }, {
      default: b(() => [
        (v(), w(z(u.wrapperElementName), C({
          ref_key: "target",
          ref: c
        }, e.$attrs, {
          class: [
            l(m)(),
            l(m)("wrapper"),
            a.value && t.value === "window" ? l(R)("wrapper", "full") : null,
            l(h)
          ],
          style: { zIndex: a.value && t.value === "window" ? u.zIndex : "unset" }
        }), {
          default: b(() => [
            F(e.$slots, "default", {
              full: a.value,
              enter: r,
              exit: s,
              toggle: p,
              mode: t.value,
              portalRoot: f.value
            }),
            I("div", {
              ref_key: "portalRootRef",
              ref: f,
              class: N(l(_)("wrapper", "portal-root"))
            }, null, 2)
          ]),
          _: 3
        }, 16, ["class", "style"]))
      ]),
      _: 3
    }, 8, ["to", "disabled"]));
  }
});
export {
  O as default
};
