"use client";
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
const require_components_client_BottomSheet_utils = require('./utils.cjs');
let react = require("react");

//#region src/components/client/BottomSheet/useVirtualKeyboard.ts
/**
* Minimum keyboard height (px) to treat as a real virtual keyboard.
* Filters out small residual values (e.g. iOS safe area insets) that
* don't represent an actual keyboard.
*/
const MIN_VIRTUAL_KEYBOARD_HEIGHT_PX = 100;
/**
* Hook to get the height of the virtual keyboard.
* @param isEnabled - Whether the virtual keyboard is enabled.
* @returns The height of the virtual keyboard in pixels, or 0 if below the minimum threshold.
*/
function useVirtualKeyboard(isEnabled) {
	const [keyboardHeightPx, setKeyboardHeightPx] = (0, react.useState)(0);
	const keyboardIsOpenRef = (0, react.useRef)(false);
	(0, react.useEffect)(() => {
		if (!isEnabled) {
			keyboardIsOpenRef.current = false;
			setKeyboardHeightPx(0);
			return;
		}
		const vv = window.visualViewport;
		if (!vv) return;
		const viewport = vv;
		function onVisualViewportResize() {
			const nextKeyboardHeight = Math.max(window.innerHeight - viewport.height, 0);
			const focused = document.activeElement;
			const keyboardIsOpen = nextKeyboardHeight > 0 && (require_components_client_BottomSheet_utils.isInputLike(focused) || keyboardIsOpenRef.current);
			keyboardIsOpenRef.current = keyboardIsOpen;
			setKeyboardHeightPx(keyboardIsOpen ? nextKeyboardHeight : 0);
		}
		onVisualViewportResize();
		viewport.addEventListener("resize", onVisualViewportResize);
		return () => viewport.removeEventListener("resize", onVisualViewportResize);
	}, [isEnabled]);
	const height = isEnabled ? keyboardHeightPx : 0;
	return height >= MIN_VIRTUAL_KEYBOARD_HEIGHT_PX ? height : 0;
}

//#endregion
exports.useVirtualKeyboard = useVirtualKeyboard;