// Copyright (c) 2026 Hellmai Ltd
// SPDX-License-Identifier: AGPL-3.0-only
/**
 * @file wu-state-cloud.ts
 * @description Cloud branch-pr helpers for WU state commands.
 *
 * WU-1591: Centralizes branch-pr path selection for wu:edit, wu:block,
 * wu:unblock, wu:release, and wu:delete so commands can run on the active
 * branch without micro-worktree pushes to main.
 */
import { CLAIMED_MODES } from '@lumenflow/core/wu-constants';
export const BRANCH_PR_MODE = CLAIMED_MODES.BRANCH_PR;
export const BRANCH_ONLY_MODE = CLAIMED_MODES.BRANCH_ONLY;
export const WORKTREE_EDIT_MODE = 'worktree';
export const BRANCH_PR_EDIT_MODE = 'branch-pr';
export const BLOCKED_EDIT_MODE = 'blocked';
/**
 * Returns true when command execution should run on the active claimed branch.
 */
export function shouldUseBranchPrStatePath(doc) {
    return doc.claimed_mode === BRANCH_PR_MODE;
}
/**
 * Resolve the in-progress edit mode from claimed_mode.
 */
export function resolveInProgressEditMode(claimedMode) {
    if (claimedMode === BRANCH_PR_MODE) {
        return BRANCH_PR_EDIT_MODE;
    }
    if (claimedMode === BRANCH_ONLY_MODE) {
        return BLOCKED_EDIT_MODE;
    }
    return WORKTREE_EDIT_MODE;
}
/**
 * Delete should use branch-pr path if UnsafeAny target WU is branch-pr claimed.
 */
export function shouldUseBranchPrDeletePath(docs) {
    return docs.some((doc) => shouldUseBranchPrStatePath(doc));
}
//# sourceMappingURL=wu-state-cloud.js.map