"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useDelayedTooltip", {
    enumerable: true,
    get: function() {
        return useDelayedTooltip;
    }
});
const _react = require("react");
const useDelayedTooltip = (openDelay, closeDelay)=>{
    const [opened, setOpened] = (0, _react.useState)(false);
    const openTimeoutRef = (0, _react.useRef)(null);
    const closeTimeoutRef = (0, _react.useRef)(null);
    const clearTimeouts = ()=>{
        if (openTimeoutRef.current) {
            clearTimeout(openTimeoutRef.current);
            openTimeoutRef.current = null;
        }
        if (closeTimeoutRef.current) {
            clearTimeout(closeTimeoutRef.current);
            closeTimeoutRef.current = null;
        }
    };
    const showTooltip = ()=>{
        clearTimeouts();
        openTimeoutRef.current = setTimeout(()=>{
            setOpened(true);
        }, openDelay);
    };
    const hideTooltip = ()=>{
        clearTimeouts();
        closeTimeoutRef.current = setTimeout(()=>{
            setOpened(false);
        }, closeDelay);
    };
    (0, _react.useEffect)(()=>{
        return clearTimeouts;
    }, []);
    return {
        opened,
        setOpened,
        showTooltip,
        hideTooltip
    };
};
