/**
 * Picks which adapter a workflow tool call should act on.
 *  - If the caller passed an explicit `target`, honor it (error if that side wasn't detected).
 *  - If only one side was detected, use it regardless of `target`.
 *  - If both sides were detected and no `target` was given, default to backend
 *    (matches the common "start the API, then the frontend separately" flow)
 *    but callers that care about the frontend by default (e.g. dev server) can
 *    pass `defaultTarget: 'frontend'`.
 */
export function resolveTarget(detected, target, defaultTarget = 'backend') {
    if (target === 'backend') {
        if (!detected.backend) {
            throw new Error('target "backend" was requested, but no backend (Laravel/CodeIgniter/Symfony/Django/Rails) project was detected.');
        }
        return { adapter: detected.backend, target: 'backend' };
    }
    if (target === 'frontend') {
        if (!detected.frontend) {
            throw new Error('target "frontend" was requested, but no frontend (React/Vue/Nuxt) project was detected.');
        }
        return { adapter: detected.frontend, target: 'frontend' };
    }
    if (detected.backend && detected.frontend) {
        const adapter = defaultTarget === 'frontend' ? detected.frontend : detected.backend;
        return { adapter, target: defaultTarget };
    }
    return { adapter: detected.primary, target: 'primary' };
}
//# sourceMappingURL=resolve.js.map