import { useRef as u, useEffect as o } from "react";
const i = (n, t = 0.5) => {
  const e = u(null);
  return o(() => {
    const r = new IntersectionObserver(
      (s) => {
        s.forEach((c) => {
          c.isIntersecting && n();
        });
      },
      {
        threshold: t
      }
    );
    return e.current && r.observe(e.current), () => {
      e.current && r.unobserve(e.current), r.disconnect();
    };
  }, [n, t, e, e.current]), { ref: e };
};
export {
  i as u
};
