"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyWorkflowClosingFollowupRecommendation = applyWorkflowClosingFollowupRecommendation;
exports.buildWorkflowClosingFollowupRecommendationSource = buildWorkflowClosingFollowupRecommendationSource;
function applyWorkflowClosingFollowupRecommendation(input) {
    const followup = input.workflowState?.followup;
    if (input.workflowState === null ||
        followup === undefined ||
        followup.proposalPolicy === "off") {
        return input.workflowState;
    }
    return {
        ...input.workflowState,
        followup: {
            ...followup,
            recommendation: input.recommendation ?? null,
            ...(input.recommendationSource !== undefined
                ? { recommendationSource: input.recommendationSource }
                : {}),
        },
    };
}
function buildWorkflowClosingFollowupRecommendationSource(input) {
    return {
        kind: "workflow_closing",
        freshnessVerified: input.freshnessVerified ?? true,
        workspaceHeadCommitOid: input.workerExecution.workspaceHeadCommitOidBeforeRun,
        ...(input.expectedCommitOid !== undefined
            ? { expectedCommitOid: input.expectedCommitOid }
            : {}),
        ...(input.expectedCommitKind !== undefined
            ? { expectedCommitKind: input.expectedCommitKind }
            : {}),
        ...(input.pullRequestNumber !== undefined
            ? { pullRequestNumber: input.pullRequestNumber }
            : {}),
        ...(input.pullRequestUrl !== undefined
            ? { pullRequestUrl: input.pullRequestUrl }
            : {}),
    };
}
