/** Parse `ref` against `currentScope`. Throws when `ref` is empty. */
export function resolveTaskRef(ref, currentScope) {
    if (!ref || typeof ref !== 'string') {
        throw new Error('resolveTaskRef: ref must be a non-empty string');
    }
    const trimmed = ref.trim();
    if (!trimmed)
        throw new Error('resolveTaskRef: ref must be a non-empty string');
    const colonIdx = trimmed.indexOf(':');
    // Heuristic: a scoped ref is "{scope}:{task_id}" where `scope` contains
    // no slashes or spaces. We reject strings that look like URLs ("://"),
    // which belong in `roadmap_ref_url` instead.
    if (colonIdx > 0 && !/[\s/]/.test(trimmed.slice(0, colonIdx)) && !trimmed.startsWith('http')) {
        const scope = trimmed.slice(0, colonIdx);
        const task_id = trimmed.slice(colonIdx + 1);
        if (!task_id)
            throw new Error(`resolveTaskRef: "${ref}" missing task_id after colon`);
        return { scope: scope, task_id };
    }
    return { scope: currentScope, task_id: trimmed };
}
/** Inverse: render a ResolvedTaskRef back to the wire format. */
export function formatTaskRef(resolved) {
    return `${resolved.scope}:${resolved.task_id}`;
}
//# sourceMappingURL=task-ref.js.map