// 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, ReasonixIcon } from '@/components/icons/ProviderIcons';
import mascot from '@/assets/brand/banner-mascot.png';

/**
 * Glyph for a provider/agent name. `boocode` (native) is the BooCode westie
 * mascot; unmapped names fall through to a neutral dog. 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 'boocode':
      return (
        <img
          src={mascot}
          alt=""
          width={size}
          height={size}
          draggable={false}
          className="shrink-0 object-contain select-none"
        />
      );
    case 'claude':
      return <ClaudeIcon size={size} className="shrink-0" />;
    case 'opencode':
      return <OpenCodeIcon size={size} className="shrink-0" />;
    case 'reasonix':
      return <ReasonixIcon 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';
    case 'reasonix':
      return 'Reasonix';
    default:
      return name;
  }
}
