import { parseBypassMarker } from '../../../../modules/tracking/entities/bypassMarker/bypassMarker.js';
const MISSING_REASON_MESSAGE = 'Le bypass nécessite une raison explicite. Format attendu : /bypass-quality "raison"';
export class RecordBypassUseCase {
    trackingGateway;
    constructor(trackingGateway) {
        this.trackingGateway = trackingGateway;
    }
    execute(input) {
        const parsed = parseBypassMarker(input.commentBody);
        if (parsed.kind === 'no-marker') {
            return { kind: 'no-marker' };
        }
        if (parsed.kind === 'invalid-missing-reason') {
            return { kind: 'rejected-missing-reason', message: MISSING_REASON_MESSAGE };
        }
        const mr = this.trackingGateway.getById(input.projectPath, input.mrId);
        if (!mr)
            return { kind: 'mr-not-found' };
        const bypass = {
            author: input.author,
            reason: parsed.reason,
            recordedAt: input.now(),
        };
        this.trackingGateway.update(input.projectPath, input.mrId, { bypass });
        return { kind: 'recorded', bypass };
    }
}
//# sourceMappingURL=recordBypass.usecase.js.map