"use client";
import { useEffect, useRef, useState } from "react";
import { useReducedMotion } from "@mantine/hooks";
//#region packages/@mantine/core/src/components/ModalBase/use-lock-scroll.ts
function useLockScroll({ opened, transitionDuration }) {
	const [shouldLockScroll, setShouldLockScroll] = useState(opened);
	const timeout = useRef(-1);
	const _transitionDuration = useReducedMotion() ? 0 : transitionDuration;
	useEffect(() => {
		if (opened) {
			setShouldLockScroll(true);
			window.clearTimeout(timeout.current);
		} else if (_transitionDuration === 0) setShouldLockScroll(false);
		else timeout.current = window.setTimeout(() => setShouldLockScroll(false), _transitionDuration);
		return () => window.clearTimeout(timeout.current);
	}, [opened, _transitionDuration]);
	return shouldLockScroll;
}
//#endregion
export { useLockScroll };

//# sourceMappingURL=use-lock-scroll.mjs.map