import { isShadowRoot as f } from "./domHelpers.js";
import { shadowDOM as o } from "../../../../../@react-stately_flags@3.1.2/node_modules/@react-stately/flags/dist/import.js";
function n(t, a) {
  if (!o()) return a && t ? t.contains(a) : !1;
  if (!t || !a) return !1;
  let e = a;
  for (; e !== null; ) {
    if (e === t) return !0;
    e.tagName === "SLOT" && e.assignedSlot ? e = e.assignedSlot.parentNode : f(e) ? e = e.host : e = e.parentNode;
  }
  return !1;
}
const s = (t = document) => {
  var a;
  if (!o()) return t.activeElement;
  let e = t.activeElement;
  for (; e && "shadowRoot" in e && (!((a = e.shadowRoot) === null || a === void 0) && a.activeElement); ) e = e.shadowRoot.activeElement;
  return e;
};
function d(t) {
  return o() && t.target.shadowRoot && t.composedPath ? t.composedPath()[0] : t.target;
}
export {
  s as getActiveElement,
  d as getEventTarget,
  n as nodeContains
};
