src/UI/Primitives.ps1

# Primitives — Componentes pequeños reutilizables: Pill, BranchChip, K, AheadBehind.
# Cada método devuelve el string ANSI listo para imprimir.

class Primitives {
    [object] $Theme   # ThemeService

    Primitives($themeService) { $this.Theme = $themeService }

    # Pill coloreada según kind: clean | dirty | unpushed | behind | conflict | nogit | ok | acc
    [string] Pill([string]$kind, [string]$text) {
        $fgKey = switch ($kind) {
            'clean'    { 'gitClean' }
            'dirty'    { 'gitDirty' }
            'unpushed' { 'gitUnpushed' }
            'behind'   { 'gitBehind' }
            'conflict' { 'gitConflict' }
            'nogit'    { 'gitNoGit' }
            'ok'       { 'gitClean' }
            'acc'      { 'acc' }
            default    { 'fg2' }
        }
        $fg = $this.Theme.Fg($fgKey)
        $reset = [AnsiService]::Reset
        return "${fg}● ${text}${reset}"
    }

    # Branch chip con glifo ⎇.
    [string] BranchChip([string]$name, [bool]$isMain) {
        $color = if ($isMain) { 'acc' } else { 'fg1' }
        $fg = $this.Theme.Fg($color)
        $reset = [AnsiService]::Reset
        return "${fg}⎇ ${name}${reset}"
    }

    # Key chip [K]
    [string] K([string]$key) {
        $fg = $this.Theme.Fg('acc')
        $bg = $this.Theme.Bg('bg3')
        $reset = [AnsiService]::Reset
        return "${bg}${fg} ${key} ${reset}"
    }

    # Ahead/behind compact: ▲N ▼M
    [string] AheadBehind([int]$ahead, [int]$behind) {
        $reset = [AnsiService]::Reset
        $parts = @()
        if ($ahead -gt 0) {
            $fg = $this.Theme.Fg('gitAhead')
            $parts += "${fg}▲${ahead}${reset}"
        }
        if ($behind -gt 0) {
            $fg = $this.Theme.Fg('gitBehind')
            $parts += "${fg}▼${behind}${reset}"
        }
        if ($parts.Count -eq 0) { return '' }
        return ($parts -join ' ')
    }

    # Star para favoritos
    [string] Star() {
        $fg = $this.Theme.Fg('palette')[2]   # warm yellow ish
        $reset = [AnsiService]::Reset
        # palette es array, no funciona Fg directamente; uso color hex de palette[2]
        $hex = $this.Theme.GetActive().palette[2]
        $fg = [AnsiService]::FgHex($hex)
        return "${fg}★${reset}"
    }
}