"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useHover = void 0;
const react_1 = require("react");
const useHover = (element, { enabled = true } = {}) => {
    const [isHovered, setHover] = (0, react_1.useState)(false);
    const handleMouseEnter = () => setHover(true);
    const handleMouseLeave = () => setHover(false);
    (0, react_1.useEffect)(() => {
        if (!enabled) {
            setHover(false);
            return undefined;
        }
        if (!element) {
            return undefined;
        }
        element.addEventListener('mouseenter', handleMouseEnter);
        element.addEventListener('mouseleave', handleMouseLeave);
        return () => {
            element.removeEventListener('mouseenter', handleMouseEnter);
            element.removeEventListener('mouseleave', handleMouseLeave);
        };
    }, [element, enabled]);
    return { isHovered };
};
exports.useHover = useHover;
