import { Duration } from '../../../../modules/shared-kernel/entities/shared/duration.valueObject.js';
const TRIGGER_SOURCE_LABELS = {
    'webhook-initial': 'Webhook',
    'webhook-followup': 'Webhook',
    'dashboard-manual': 'Manuel',
};
export class PendingReviewPresenter {
    now;
    constructor(options = {}) {
        this.now = options.now ?? (() => new Date());
    }
    present(pending) {
        return {
            identifier: pending.pendingReviewRequestId,
            mrNumber: pending.job.mrNumber,
            displayTitle: this.formatDisplayTitle(pending),
            projectPath: pending.job.projectPath,
            mrUrl: pending.job.mrUrl,
            jobTypeLabel: pending.jobType === 'followup' ? 'Followup' : 'Review',
            triggerSourceLabel: TRIGGER_SOURCE_LABELS[pending.triggerSource],
            createdAtRelative: this.formatRelative(pending.createdAt),
            confirmActionUrl: `/api/pending-reviews/${pending.pendingReviewRequestId}/confirm`,
            dismissActionUrl: `/api/pending-reviews/${pending.pendingReviewRequestId}`,
        };
    }
    formatDisplayTitle(pending) {
        const title = pending.job.title ?? '';
        return title.length > 0
            ? `MR !${pending.job.mrNumber} - ${title}`
            : `MR !${pending.job.mrNumber}`;
    }
    formatRelative(isoString) {
        const createdAtMs = new Date(isoString).getTime();
        if (Number.isNaN(createdAtMs)) {
            return '';
        }
        const elapsedMs = Math.max(0, this.now().getTime() - createdAtMs);
        return `il y a ${Duration.fromMilliseconds(elapsedMs).formatted}`;
    }
}
//# sourceMappingURL=pendingReview.presenter.js.map