// Shared provider icon + label helpers for BooCoder UI.
//
// Single source of truth for the per-provider glyph used in the
// AgentComposerBar picker and the CoderPane DiffPanel agent-attribution
// badges (v2.6 Phase 1-UX §9a/§9b). Extracted from AgentComposerBar's local
// `providerIcon` switch so both call sites stay in sync.

import type { ReactNode } from 'react';
import { Bird, Dog, Terminal as TermIcon } from 'lucide-react';
import { ClaudeIcon, OpenCodeIcon } from '@/components/icons/ProviderIcons';

/**
 * Glyph for a provider/agent name. Mirrors AgentComposerBar's original
 * `providerIcon` switch verbatim — `boocode` (native) falls through to the
 * neutral dog like any unmapped name, preserving the composer's prior look.
 * Sized to match the picker (13px) by default; pass a different size for
 * inline badges.
 */
export function providerIcon(name: string | null, size = 13): ReactNode {
  switch (name) {
    case 'claude':
      return <ClaudeIcon size={size} className="shrink-0" />;
    case 'opencode':
      return <OpenCodeIcon size={size} className="shrink-0" />;
    case 'goose':
      return <Bird size={size} className="shrink-0" />;
    case 'qwen':
      return <TermIcon size={size} className="shrink-0" />;
    default:
      return <Dog size={size} className="shrink-0" />;
  }
}

/**
 * Human label for a provider/agent name. `null` → "manual" (a RightRail-staged
 * change with no dispatching agent, per §9a). Unknown names pass through
 * verbatim so a future provider still reads sensibly.
 */
export function providerLabel(name: string | null): string {
  switch (name) {
    case null:
      return 'manual';
    case 'boocode':
      return 'BooCode';
    case 'opencode':
      return 'opencode';
    case 'claude':
      return 'Claude';
    case 'goose':
      return 'goose';
    case 'qwen':
      return 'Qwen';
    default:
      return name;
  }
}
