/**
 * `findRootOwnerId` — walks up from a node to find the nearest ancestor
 * carrying `data-rootownerid`. Mirrors
 * `packages/react/src/menu/utils/findRootOwnerId.ts`.
 *
 * Used by `<ContextMenu.Trigger>`'s mouseup handler to detect mouseups
 * that originated inside a nested menu owned by this root (so a nested
 * context menu's mouseup doesn't cancel the outer open).
 */
import { getParentNode, isHTMLElement, isLastTraversableNode } from "@floating-ui/utils/dom";
export function findRootOwnerId(node) {
  if (isHTMLElement(node) && node.hasAttribute("data-rootownerid")) {
    return node.getAttribute("data-rootownerid") ?? undefined;
  }
  if (isLastTraversableNode(node)) {
    return undefined;
  }
  return findRootOwnerId(getParentNode(node));
}
//# sourceMappingURL=find-root-owner-id.jsx.map
