"""
Centralized Rich console for PrimeFeat.

Provides consistent styling, themes, and utilities for console output.
"""

import os
from rich.console import Console
from rich.theme import Theme

# PrimeFeat color scheme
PRIMEFEAT_THEME = Theme(
    {
        "info": "cyan",
        "warning": "yellow bold",
        "error": "red bold",
        "success": "green bold",
        "header": "magenta bold",
        "value": "blue",
        "key": "cyan",
        "dim": "dim",
        "parameter": "yellow",
        "filename": "cyan underline",
        "stat": "yellow",
        "metric": "blue",
    }
)

# Environment variable controls
USE_RICH = os.getenv("PRIMEFEAT_USE_RICH", "1") == "1"
USE_EMOJI = os.getenv("PRIMEFEAT_USE_EMOJI", "1") == "1"

# Singleton console instances
if USE_RICH:
    console = Console(theme=PRIMEFEAT_THEME, emoji=USE_EMOJI)
    error_console = Console(stderr=True, theme=PRIMEFEAT_THEME, emoji=USE_EMOJI)
else:
    # Fallback to plain console
    console = Console(no_color=True, emoji=False, force_terminal=False)
    error_console = Console(
        stderr=True, no_color=True, emoji=False, force_terminal=False
    )

__all__ = ["console", "error_console", "PRIMEFEAT_THEME", "USE_RICH", "USE_EMOJI"]
