function hasActiveClientOnAgent(allClientStates, agentId) {
    return allClientStates.some((state) => state.focusedAgentId === agentId && state.appVisible && !state.isStale);
}
function hasActiveWebClient(allClientStates) {
    return allClientStates.some((state) => state.deviceType === "web" && !state.isStale);
}
function hasOtherCompetingClient(clientState, allClientStates) {
    return allClientStates.some((state) => state !== clientState && (state.deviceType === "mobile" || state.deviceType === null));
}
function hasActiveForegroundMobileClient(allClientStates) {
    return allClientStates.some((state) => state.deviceType === "mobile" && state.appVisible && !state.isStale);
}
export function computeShouldNotifyClient({ clientState, allClientStates, agentId, }) {
    if (hasActiveClientOnAgent(allClientStates, agentId)) {
        return false;
    }
    if (clientState.deviceType === null) {
        return true;
    }
    if (!clientState.isStale && clientState.appVisible && clientState.focusedAgentId !== null) {
        return true;
    }
    if (!clientState.isStale) {
        return false;
    }
    if (clientState.deviceType === "mobile") {
        return !hasActiveWebClient(allClientStates);
    }
    if (clientState.deviceType === "web") {
        return !hasOtherCompetingClient(clientState, allClientStates);
    }
    return true;
}
export function computeShouldSendPush({ reason, allClientStates, }) {
    if (reason === "error") {
        return false;
    }
    return !hasActiveWebClient(allClientStates) && !hasActiveForegroundMobileClient(allClientStates);
}
//# sourceMappingURL=agent-attention-policy.js.map