//! Dev mode UI banners and display functions
//!
//! UI display helpers for development mode.

use crate::dev::node_selection::NodeToRun;
use anyhow::Result;

/// Print dev mode header banner
pub fn print_header() {
    println!();
    println!("🔧 Mecha10 Development Mode");
    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
    println!();
}

/// Print project information
pub fn print_project_info(name: &str, version: &str) {
    println!("Project: {}", name);
    println!("Version: {}", version);
    println!();
}

/// Print list of nodes that will run
pub fn print_nodes(nodes: &[NodeToRun]) {
    println!("Nodes to run:");
    for node in nodes {
        println!("  • {}", node.identifier);
    }
    println!();
}

/// Print current mode and node status
///
/// Shows which mode is active and lists running vs stopped nodes
pub fn print_mode_status(mode: &str, running_nodes: &[String], all_configured_nodes: &[NodeToRun]) {
    println!("Mode: {}", mode);
    println!();

    // Show running nodes
    if !running_nodes.is_empty() {
        println!("Running nodes:");
        for node in running_nodes {
            println!("  ✅ {}", node);
        }
        println!();
    }

    // Show stopped nodes (configured but not running)
    // Compare against both identifier and name to handle both formats
    let stopped: Vec<_> = all_configured_nodes
        .iter()
        .filter(|n| !running_nodes.contains(&n.identifier) && !running_nodes.contains(&n.name))
        .collect();

    if !stopped.is_empty() {
        println!("Stopped nodes:");
        for node in stopped {
            println!("  ⏸  {}", node.identifier);
        }
        println!();
    }
}

/// Print message when no nodes are configured
pub fn print_no_nodes() -> Result<()> {
    println!("No nodes configured to run.");
    println!();
    println!("To add nodes:");
    println!("  mecha10 add <component>");
    println!();
    Ok(())
}
