import { useRef as f, useCallback as a, useEffect as m } from "react";
const B = (o, t) => o.scrollTop + o.clientHeight >= o.scrollHeight - t, S = (o) => {
  const { enabled: t, itemCount: i, onScrollBottom: l, scrollBottomOffset: s, scrollElement: n } = o, r = f(!1), c = a(
    (e) => {
      if (!t || !e || !l)
        return;
      if (!B(e, s)) {
        r.current = !1;
        return;
      }
      r.current || (r.current = !0, l());
    },
    [t, l, s]
  );
  m(() => {
    if (!t || !n)
      return;
    r.current = !1;
    const e = requestAnimationFrame(() => {
      c(n);
    });
    return () => {
      cancelAnimationFrame(e);
    };
  }, [t, c, i, n]);
  const u = a(() => {
    r.current = !1;
  }, []);
  return {
    handleScrollBottom: c,
    resetScrollBottomTrigger: u
  };
};
export {
  S as default
};
//# sourceMappingURL=useTableBodyScrollBottom.js.map
