import { computed, unref, warn } from "vue";
import { IN_BROWSER } from "@veno-ui/utils";
function useTeleport(target = false) {
  const teleportTarget = computed(() => {
    const _target = unref(target);
    if (_target === true || !IN_BROWSER)
      return void 0;
    const targetElement = _target === false ? document.body : typeof _target === "string" ? document.querySelector(_target) : _target;
    if (targetElement == null) {
      warn(`Unable to locate target ${_target}`);
      return void 0;
    }
    if (!useTeleport.cache.has(targetElement)) {
      const el = document.createElement("div");
      el.className = "ve-overlay-container";
      targetElement.appendChild(el);
      useTeleport.cache.set(targetElement, el);
    }
    return useTeleport.cache.get(targetElement);
  });
  return { teleportTarget };
}
useTeleport.cache = /* @__PURE__ */ new WeakMap();
export {
  useTeleport
};
//# sourceMappingURL=index.mjs.map
