import { Duration } from '../../../../modules/shared-kernel/entities/shared/duration.valueObject.js';
export class JobStatusPresenter {
    present(jobStatus) {
        const { job } = jobStatus;
        const { statusLabel, statusColor } = this.getStatusDisplay(jobStatus.status);
        const progressPercent = jobStatus.progress?.overallProgress ?? 0;
        const showProgress = jobStatus.status === 'running';
        return {
            identifier: job.id,
            displayTitle: this.formatDisplayTitle(job),
            projectPath: job.projectPath,
            mrUrl: job.mrUrl,
            jobType: job.jobType ?? 'review',
            jobTypeLabel: this.getJobTypeLabel(job.jobType),
            statusLabel,
            statusColor,
            progressPercent,
            showProgress,
            errorMessage: jobStatus.error ?? null,
            showRetry: jobStatus.status === 'failed',
            elapsedTime: this.formatElapsedTime(jobStatus),
            duration: this.formatDuration(jobStatus),
        };
    }
    formatElapsedTime(jobStatus) {
        if (!jobStatus.startedAt)
            return '';
        const elapsedMs = Date.now() - jobStatus.startedAt.getTime();
        return Duration.fromMilliseconds(elapsedMs).formatted;
    }
    formatDuration(jobStatus) {
        if (!jobStatus.startedAt || !jobStatus.completedAt)
            return '';
        const durationMs = jobStatus.completedAt.getTime() - jobStatus.startedAt.getTime();
        return Duration.fromMilliseconds(durationMs).formatted;
    }
    formatDisplayTitle(job) {
        const title = job.title ?? '';
        return `MR #${job.mrNumber} - ${title}`;
    }
    getJobTypeLabel(jobType) {
        return jobType === 'followup' ? 'Followup' : 'Review';
    }
    getStatusDisplay(status) {
        switch (status) {
            case 'queued':
                return { statusLabel: 'En attente', statusColor: 'gray' };
            case 'running':
                return { statusLabel: 'En cours', statusColor: 'blue' };
            case 'completed':
                return { statusLabel: 'Terminé', statusColor: 'green' };
            case 'failed':
                return { statusLabel: 'Échec', statusColor: 'red' };
        }
    }
}
//# sourceMappingURL=jobStatus.presenter.js.map