import { t as getDocumentActiveElement } from "./focus.js";
import { t as deepContains } from "./deepContains.js";
import { useEffect, useRef } from "react";
const useReturnFocusOnUnmount = (ref) => {
	const previouslyFocusedElementRef = useRef(null);
	useEffect(() => {
		const activeElement = ref.current ? getDocumentActiveElement(ref.current) : null;
		if (activeElement instanceof HTMLElement) previouslyFocusedElementRef.current = activeElement;
		return () => {
			if (previouslyFocusedElementRef.current instanceof HTMLElement && deepContains(document, previouslyFocusedElementRef.current)) previouslyFocusedElementRef.current.focus();
		};
	}, []);
};
export { useReturnFocusOnUnmount as t };

//# sourceMappingURL=useReturnFocusOnUnmount.js.map