import { useLayoutEffect } from 'react';
export function useInfiniteScrollInModal({ canLoad, enabled, onIntersect, rootSelector, target }) {
    useLayoutEffect(() => {
        if (!enabled)
            return;
        if (!target.current)
            return;
        const rootEl = document.querySelector(rootSelector);
        const io = new IntersectionObserver((entries) => {
            var _a;
            if (!((_a = entries[0]) === null || _a === void 0 ? void 0 : _a.isIntersecting))
                return;
            if (!canLoad)
                return;
            onIntersect();
        }, {
            root: rootEl,
            rootMargin: '80px',
            threshold: 0,
        });
        io.observe(target.current);
        return () => io.disconnect();
    }, [enabled, target, rootSelector, onIntersect, canLoad]);
}
//# sourceMappingURL=useInfiniteScrollInModal.js.map