import * as u from "react";
import { useTooltipRootContext as C } from "../root/TooltipRootContext.js";
import { useTooltipPositionerContext as x } from "../positioner/TooltipPositionerContext.js";
import { popupStateMapping as T } from "../../utils/popupStateMapping.js";
import { transitionStatusMapping as R } from "../../utils/stateAttributesMapping.js";
import { useOpenChangeComplete as y } from "../../utils/useOpenChangeComplete.js";
import { useRenderElement as P } from "../../utils/useRenderElement.js";
import { getDisabledMountTransitionStyles as b } from "../../utils/getDisabledMountTransitionStyles.js";
import { useHoverFloatingInteraction as M } from "../../floating-ui-react/hooks/useHoverFloatingInteraction.js";
const D = {
  ...T,
  ...R
}, E = /* @__PURE__ */ u.forwardRef(function(n, l) {
  const {
    className: v,
    render: O,
    ...m
  } = n, t = C(), {
    side: p,
    align: s
  } = x(), e = t.useState("open"), i = t.useState("instantType"), o = t.useState("transitionStatus"), c = t.useState("popupProps"), f = t.useState("floatingRootContext");
  y({
    open: e,
    ref: t.context.popupRef,
    onComplete() {
      var a, r;
      e && ((r = (a = t.context).onOpenChangeComplete) == null || r.call(a, !0));
    }
  });
  const S = t.useState("disabled"), d = t.useState("closeDelay");
  M(f, {
    enabled: !S,
    closeDelay: d
  });
  const g = u.useMemo(() => ({
    open: e,
    side: p,
    align: s,
    instant: i,
    transitionStatus: o
  }), [e, p, s, i, o]);
  return P("div", n, {
    state: g,
    ref: [l, t.context.popupRef, t.useStateSetter("popupElement")],
    props: [c, b(o), m],
    stateAttributesMapping: D
  });
});
process.env.NODE_ENV !== "production" && (E.displayName = "TooltipPopup");
export {
  E as TooltipPopup
};
