import { DEFAULT_FOLLOWUP_AGENTS } from '../../../../modules/review-execution/entities/progress/agentDefinition.type.js';
import { calculateOverallProgress } from '../../../../modules/review-execution/entities/progress/progress.calculator.js';
export class ReviewContextProgressPresenter {
    toReviewProgress(contextProgress) {
        const stepsCompleted = contextProgress.stepsCompleted ?? [];
        const currentStep = contextProgress.currentStep;
        const agentDefinitions = this.resolveAgents(contextProgress);
        const agents = agentDefinitions.map(agent => {
            let status = 'pending';
            if (stepsCompleted.includes(agent.name)) {
                status = 'completed';
            }
            else if (currentStep === agent.name) {
                status = 'running';
            }
            return {
                name: agent.name,
                displayName: agent.displayName,
                status,
            };
        });
        const phase = this.mapPhase(contextProgress.phase);
        const progress = {
            agents,
            currentPhase: phase,
            overallProgress: 0,
            lastUpdate: contextProgress.updatedAt ? new Date(contextProgress.updatedAt) : new Date(),
        };
        progress.overallProgress = phase === 'completed' ? 100 : calculateOverallProgress(progress);
        return progress;
    }
    resolveAgents(contextProgress) {
        if (contextProgress.agents && contextProgress.agents.length > 0) {
            return contextProgress.agents;
        }
        return DEFAULT_FOLLOWUP_AGENTS;
    }
    mapPhase(phase) {
        if (phase === 'pending') {
            return 'initializing';
        }
        return phase;
    }
}
//# sourceMappingURL=reviewContextProgress.presenter.js.map