import { useRef as p, useState as H, useEffect as b, startTransition as s } from "react";
function B(d = {}) {
  const { tolerance: e = 0, deepCheck: c = !1 } = d, a = p(null), [f, n] = H(!1);
  return b(() => {
    const t = a.current;
    if (!t) return;
    const m = (g) => {
      const o = t.getBoundingClientRect(), { clientX: l, clientY: i } = g;
      if (!(l >= o.left - e && l <= o.right + e && i >= o.top - e && i <= o.bottom + e)) {
        s(() => {
          n(!1);
        });
        return;
      }
      if (c) {
        const u = document.elementFromPoint(l, i), h = u === t || t.contains(u);
        s(() => {
          n(h);
        });
      } else
        s(() => {
          n(!0);
        });
    }, v = () => {
      s(() => {
        n(!1);
      });
    }, r = new AbortController();
    return document.addEventListener("mousemove", m, { signal: r.signal }), t.addEventListener("mouseleave", v, { signal: r.signal }), () => {
      r.abort();
    };
  }, [e, c]), { ref: a, isHovered: f };
}
export {
  B as default
};
//# sourceMappingURL=use-is-hovered.js.map
