import { sliceMessagesByTurns } from './history-turns.js';
import { getLastLentaEmit, messagesFingerprint } from './lenta-seq-journal.js';
/** Canonical lenta in store vs last socket `agent:messages` emit. */
export function isLentaDeliveryPending(agentId, storeMessages, clientTurnLimit) {
    if (!storeMessages.length)
        return false;
    const last = getLastLentaEmit(agentId);
    if (!last)
        return true;
    const visible = clientTurnLimit != null && clientTurnLimit > 0
        ? sliceMessagesByTurns(storeMessages, { turnLimit: clientTurnLimit }).messages
        : storeMessages;
    if (!visible.length)
        return false;
    return messagesFingerprint(visible) !== last.messagesSig;
}
