import { useEffect } from "react";
import { normalizeDialogAgentId } from "../agentMessageHelpers";
export function useAgentTerminalReadyEvents(input) {
    const { agentId, agentStubId, terminalInstanceIdRef } = input;
    useEffect(() => {
        const normalizedStubId = normalizeDialogAgentId(agentStubId);
        if (normalizedStubId) {
            window.dispatchEvent(new CustomEvent("agent:terminal:ready", {
                detail: {
                    agentId: normalizedStubId,
                    terminalInstanceId: terminalInstanceIdRef.current,
                },
            }));
        }
    }, [agentStubId, terminalInstanceIdRef]);
    useEffect(() => {
        const normalizedAgentId = normalizeDialogAgentId(agentId);
        const normalizedStubId = normalizeDialogAgentId(agentStubId);
        if (normalizedAgentId && normalizedAgentId !== normalizedStubId) {
            window.dispatchEvent(new CustomEvent("agent:terminal:ready", {
                detail: {
                    agentId: normalizedAgentId,
                    terminalInstanceId: terminalInstanceIdRef.current,
                },
            }));
        }
    }, [agentId, agentStubId, terminalInstanceIdRef]);
}
//# sourceMappingURL=useAgentTerminalReadyEvents.js.map