"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveIssueRunBaseBranch = resolveIssueRunBaseBranch;
exports.resolveIssueCreationBaseBranch = resolveIssueCreationBaseBranch;
const default_issue_workspace_manager_1 = require("../../workspaces/default-issue-workspace-manager");
function resolveIssueRunBaseBranch(workflowState) {
    if (workflowState === null) {
        throw new Error("Issue workflow state is required to resolve base branch.");
    }
    return workflowState.baseBranch;
}
function resolveIssueCreationBaseBranch(input) {
    switch (input.branchTarget) {
        case "effective_base_branch":
            return (input.effectiveWorkflowState?.baseBranch ??
                input.config.repositoryHost.baseBranch);
        case "parent_issue_branch":
            if (input.parentIssue === undefined) {
                throw new Error("parent_issue_branch target requires a parent issue.");
            }
            return (0, default_issue_workspace_manager_1.resolveIssueBranchName)(input.config.branchPrefix, input.parentIssue);
    }
}
