import { useCallback, useRef } from "react";
export function useSuppressedQueuedPrompts() {
    const suppressedQueuedPromptsRef = useRef([]);
    const pruneSuppressedQueuedPrompts = useCallback(() => {
        const cutoff = Date.now() - 15_000;
        suppressedQueuedPromptsRef.current =
            suppressedQueuedPromptsRef.current.filter((entry) => entry.createdAt >= cutoff);
    }, []);
    const registerSuppressedQueuedPrompt = useCallback((agentId, promptText) => {
        const normalizedAgentId = agentId.trim().toLowerCase();
        const normalizedPrompt = promptText.trim();
        if (!normalizedAgentId || !normalizedPrompt) {
            return null;
        }
        pruneSuppressedQueuedPrompts();
        const token = crypto.randomUUID();
        suppressedQueuedPromptsRef.current = [
            ...suppressedQueuedPromptsRef.current,
            {
                token,
                agentId: normalizedAgentId,
                prompt: normalizedPrompt,
                createdAt: Date.now(),
            },
        ];
        return token;
    }, [pruneSuppressedQueuedPrompts]);
    const clearSuppressedQueuedPrompt = useCallback((token) => {
        if (!token) {
            return;
        }
        suppressedQueuedPromptsRef.current =
            suppressedQueuedPromptsRef.current.filter((entry) => entry.token !== token);
    }, []);
    const shouldSuppressQueuedPrompt = useCallback((queueEntry) => {
        const normalizedAgentId = queueEntry?.targetAgentId?.trim().toLowerCase();
        const normalizedPrompt = queueEntry?.prompt?.trim();
        if (!normalizedAgentId || !normalizedPrompt) {
            return false;
        }
        pruneSuppressedQueuedPrompts();
        const matchedEntry = suppressedQueuedPromptsRef.current.find((entry) => entry.agentId === normalizedAgentId &&
            entry.prompt === normalizedPrompt);
        if (!matchedEntry) {
            return false;
        }
        suppressedQueuedPromptsRef.current =
            suppressedQueuedPromptsRef.current.filter((entry) => entry.token !== matchedEntry.token);
        return true;
    }, [pruneSuppressedQueuedPrompts]);
    return {
        registerSuppressedQueuedPrompt,
        clearSuppressedQueuedPrompt,
        shouldSuppressQueuedPrompt,
    };
}
//# sourceMappingURL=useSuppressedQueuedPrompts.js.map