export const PRESENCE_THRESHOLD_MS = 180000;
export function computeNotificationPlan({ allStates, agentId, reason, nowMs, }) {
    let mostRecentPresentIndex = null;
    let mostRecentPresentAtMs = Number.NEGATIVE_INFINITY;
    for (const [clientIndex, state] of allStates.entries()) {
        const clampedActivityAtMs = state.lastActivityAtMs === null ? null : Math.min(state.lastActivityAtMs, nowMs);
        const isPresent = clampedActivityAtMs !== null && nowMs - clampedActivityAtMs <= PRESENCE_THRESHOLD_MS;
        if (!isPresent) {
            continue;
        }
        if (state.appVisible && state.focusedAgentId === agentId) {
            return { inAppRecipientIndex: null, shouldPush: false };
        }
        if (clampedActivityAtMs > mostRecentPresentAtMs) {
            mostRecentPresentIndex = clientIndex;
            mostRecentPresentAtMs = clampedActivityAtMs;
        }
    }
    if (mostRecentPresentIndex !== null) {
        return { inAppRecipientIndex: mostRecentPresentIndex, shouldPush: false };
    }
    return { inAppRecipientIndex: null, shouldPush: reason !== "error" };
}
//# sourceMappingURL=agent-attention-policy.js.map