import { j as d } from "./jsx-runtime-OVHDjVDe.js";
import { d as C, u as E, B as b } from "./Animated-M9ynNzcI.js";
import { createPortal as j } from "react-dom";
import { C as o } from "./css-D6ZBcSwh.js";
import { a as M } from "./Box-D5Qv__kr.js";
const S = (l = "root") => document.getElementById(l) ?? document.body, R = ({
  style: l,
  background: m = 0,
  className: c,
  bordered: g = !0,
  rounded: u = 1,
  passthrough: a = !1,
  children: y,
  ...x
}) => {
  const {
    ref: f,
    targetCorner: i,
    dialogCorner: n,
    style: s,
    modalPosition: p
  } = C(), { visible: r, variant: t } = E();
  if (!r && !a) return null;
  const B = r && (Object.keys(s).length > 0 || t === "modal");
  let e = /* @__PURE__ */ d.jsx(
    M,
    {
      pack: !0,
      ref: f,
      y: !0,
      background: m,
      className: o(
        o.BE("dialog", "dialog"),
        o.loc(i.x),
        o.loc(i.y),
        o.BEM("dialog", "dialog", n.x),
        o.BEM("dialog", "dialog", n.y),
        o.visible(B),
        a && o.BM("dialog", "passthrough"),
        o.M(t),
        t === "modal" && o.BM("dialog", "modal", "position", p.toString()),
        c
      ),
      rounded: u,
      role: "dialog",
      empty: !0,
      bordered: g,
      align: "stretch",
      style: { ...s, ...l },
      ...x,
      children: y
    }
  );
  return t === "modal" && (e = /* @__PURE__ */ d.jsx(b, { empty: !0, align: "center", visible: r, children: e })), a ? e : j(e, S());
};
export {
  R as D
};
