//#region src/utils/createWindowFromScrollPosition.ts
function createWindowFromScrollPosition({ scrollTop, scrollHeight, height, containerOffset = 0, fitPerfectly, overscrollSize }) {
	const windowHeight = height + overscrollSize * 2;
	const effectiveHeight = fitPerfectly ? height : windowHeight;
	scrollHeight = Math.max(scrollHeight, effectiveHeight);
	if (windowHeight >= scrollHeight || fitPerfectly) {
		const top$1 = Math.max(scrollTop - containerOffset, 0);
		const bottom$1 = Math.min(scrollTop + effectiveHeight, scrollHeight) - containerOffset;
		return {
			top: top$1,
			bottom: Math.max(bottom$1, top$1)
		};
	}
	let top = scrollTop + height / 2 - windowHeight / 2;
	let bottom = top + windowHeight;
	if (top < 0) {
		top = 0;
		bottom = Math.min(windowHeight, scrollHeight);
	} else if (bottom > scrollHeight) {
		bottom = scrollHeight;
		top = Math.max(bottom - windowHeight, 0);
	}
	top = Math.floor(Math.max(top - containerOffset, 0));
	return {
		top,
		bottom: Math.ceil(Math.max(Math.min(bottom, scrollHeight) - containerOffset, top))
	};
}

//#endregion
export { createWindowFromScrollPosition };
//# sourceMappingURL=createWindowFromScrollPosition.js.map