import { useEffect, useRef } from "react";
export function useAgentLoadLifecycle(input) {
    const { agent, agentId, effectiveIsVisible, loadAgent } = input;
    const loadAgentRef = useRef(loadAgent);
    useEffect(() => {
        loadAgentRef.current = loadAgent;
    }, [loadAgent]);
    useEffect(() => {
        loadAgentRef.current();
    }, [agentId]);
    const previousIsVisibleRef = useRef(effectiveIsVisible);
    useEffect(() => {
        const wasHidden = !previousIsVisibleRef.current;
        const isNowVisible = effectiveIsVisible;
        previousIsVisibleRef.current = effectiveIsVisible;
        if (wasHidden && isNowVisible && agent) {
            loadAgentRef.current();
        }
    }, [agent?.id, effectiveIsVisible]);
}
//# sourceMappingURL=useAgentLoadLifecycle.js.map