"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATHS = void 0;
exports.resolveDefaultSystemWorkflowTemplatePath = resolveDefaultSystemWorkflowTemplatePath;
exports.isDefaultSystemWorkflowTemplatePath = isDefaultSystemWorkflowTemplatePath;
exports.resolveDefaultSystemWorkflowTemplate = resolveDefaultSystemWorkflowTemplate;
const paths_1 = require("../core/paths");
const types_1 = require("./types");
const workflow_template_targets_1 = require("./workflow-template-targets");
exports.DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATHS = {
    issue: `${paths_1.SYSTEM_WORKFLOW_TEMPLATE_DIRECTORY}/default-issue.md`,
    // biome-ignore lint/style/useNamingConvention: Workflow target key is snake_case by contract.
    pull_request: `${paths_1.SYSTEM_WORKFLOW_TEMPLATE_DIRECTORY}/default-pull-request.md`,
    unplanned: `${paths_1.SYSTEM_WORKFLOW_TEMPLATE_DIRECTORY}/default-unplanned.md`,
    followup: `${paths_1.SYSTEM_WORKFLOW_TEMPLATE_DIRECTORY}/default-followup.md`,
};
const DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATH_SET = new Set(Object.values(exports.DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATHS));
function resolveDefaultSystemWorkflowTemplatePath(surface) {
    return isWorkflowTemplateTarget(surface)
        ? exports.DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATHS[surface]
        : null;
}
function isDefaultSystemWorkflowTemplatePath(templatePath) {
    return DEFAULT_SYSTEM_WORKFLOW_TEMPLATE_PATH_SET.has(templatePath);
}
function resolveDefaultSystemWorkflowTemplate(input) {
    const templatePath = resolveDefaultSystemWorkflowTemplatePath(input.surface);
    if (templatePath === null || !isWorkflowTemplateTarget(input.surface)) {
        return null;
    }
    const template = input.catalog.templateByPath.get(templatePath);
    return template !== undefined &&
        (0, workflow_template_targets_1.workflowTemplateTargetsSurface)(template, input.surface)
        ? template
        : null;
}
function isWorkflowTemplateTarget(surface) {
    return types_1.WORKFLOW_TEMPLATE_TARGETS.includes(surface);
}
