"use client";
import * as o from "react";
import f from "react-dom";
import { Primitive as m } from "../../react-primitive/dist/index.js";
import { useLayoutEffect as c } from "../../react-use-layout-effect/dist/index.js";
import { jsx as u } from "react/jsx-runtime";
var l = "Portal", p = o.forwardRef((r, e) => {
  const { container: a, ...i } = r, [n, s] = o.useState(!1);
  c(() => s(!0), []);
  const t = a || n && globalThis?.document?.body;
  return t ? f.createPortal(/* @__PURE__ */ u(m.div, { ...i, ref: e }), t) : null;
});
p.displayName = l;
export {
  p as Portal
};
