"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WORKFLOW_ASSIGNEE_RESOLUTIONS = void 0;
exports.isWorkflowAssigneeResolution = isWorkflowAssigneeResolution;
exports.resolveWorkflowAssigneeGate = resolveWorkflowAssigneeGate;
exports.buildAssigneeResolutionSummary = buildAssigneeResolutionSummary;
exports.buildAssigneeResolutionNext = buildAssigneeResolutionNext;
const catalog_1 = require("../i18n/catalog");
exports.WORKFLOW_ASSIGNEE_RESOLUTIONS = {
    missing: "missing",
    multiple: "multiple",
};
const WORKFLOW_ASSIGNEE_RESOLUTION_VALUES = Object.values(exports.WORKFLOW_ASSIGNEE_RESOLUTIONS);
function isWorkflowAssigneeResolution(value) {
    return (typeof value === "string" &&
        WORKFLOW_ASSIGNEE_RESOLUTION_VALUES.includes(value));
}
function resolveWorkflowAssigneeGate(input) {
    if (input.assignees.length === 0) {
        return { kind: exports.WORKFLOW_ASSIGNEE_RESOLUTIONS.missing };
    }
    if (input.assignees.length !== 1) {
        return { kind: exports.WORKFLOW_ASSIGNEE_RESOLUTIONS.multiple };
    }
    return {
        kind: "ok",
        assignee: input.assignees[0],
    };
}
function buildAssigneeResolutionSummary(language, resolution) {
    return (0, catalog_1.translate)(language, `run.assigneeResolution.summary.${resolution}`);
}
function buildAssigneeResolutionNext(language, resolution) {
    return (0, catalog_1.translate)(language, `run.commentNext.assigneeResolution.${resolution}`);
}
