import { resolveInfiniteRootMargin as e, shouldObserveInfiniteTrigger as t } from "../../internal/infinite/infiniteLoad.js";
import { trigger as n } from "./infiniteScrollTrigger.css.js";
import { useEffect as r, useRef as i } from "react";
import { jsx as a } from "react/jsx-runtime";
//#region src/components/infinite/InfiniteScrollTrigger.tsx
var o = ({ enabled: o, hasNext: s, isLoading: c, onTrigger: l, thresholdPx: u = 800, loadingLabel: d }) => {
	let f = i(null);
	return r(() => {
		if (!t({
			enabled: o,
			hasNext: s,
			isLoading: c
		})) return () => {};
		let n = f.current;
		if (n == null || typeof window > "u" || typeof IntersectionObserver > "u") return () => {};
		let r = new IntersectionObserver((e) => {
			e[0]?.isIntersecting === !0 && l();
		}, {
			root: null,
			rootMargin: e({
				thresholdPx: u,
				axis: "both"
			})
		});
		return r.observe(n), () => {
			r.disconnect();
		};
	}, [
		o,
		s,
		c,
		l,
		u
	]), !o || !s ? null : /* @__PURE__ */ a("div", {
		ref: f,
		className: n,
		"aria-hidden": "true",
		children: c && /* @__PURE__ */ a("span", {
			className: "_14q3b2q1 txvbqb9j txvbqb1bg3",
			children: d
		})
	});
};
//#endregion
export { o as InfiniteScrollTrigger, o as default };

//# sourceMappingURL=InfiniteScrollTrigger.js.map