#!/usr/bin/env python3
"""Simple validation of refactored component structure."""

import sys
import os

# Add utils directory to path for imports
sys.path.insert(0, os.path.dirname(__file__))

from utils.validation_common import (
    validate_jsx_component, 
    count_complexity, 
    print_validation_header,
    print_component_validation,
    print_complexity_analysis,
    print_class_validation,
    print_summary_footer
)

def main():
    """Validate the refactoring results."""
    print_validation_header("Refactored Components")
    
    # Check TicketsPanel refactoring
    print("1. TicketsPanel Refactoring:")
    
    components = [
        'src/proxym/dashboard/components/tickets/TicketFilters.jsx',
        'src/proxym/dashboard/components/tickets/TicketStats.jsx', 
        'src/proxym/dashboard/components/tickets/BulkOperations.jsx',
        'src/proxym/dashboard/components/tickets/TicketList.jsx',
        'src/proxym/dashboard/components/tickets/TicketsPanelRefactored.jsx'
    ]
    
    print_component_validation(components)
    
    # Check TicketManager refactoring
    print("\n2. TicketManager Refactoring:")
    
    manager_file = 'src/proxym/dashboard/tickets/TicketManagerRefactored.py'
    expected_classes = ['TicketFilter', 'TicketValidator', 'TicketPersistence', 'TicketManagerRefactored']
    print_class_validation(manager_file, expected_classes)
    
    # Check HealthChecker refactoring
    print("\n3. HealthChecker Refactoring:")
    
    health_file = 'src/proxym/dashboard/tools/HealthCheckerRefactored.py'
    expected_health_classes = ['HealthCheck', 'BinaryHealthCheck', 'InstanceHealthCheck', 'HealthStatusCalculator', 'HealthCheckerRefactored']
    print_class_validation(health_file, expected_health_classes)
    
    # Compare with original files
    print("\n4. Complexity Comparison:")
    
    original_tickets = 'src/proxym/dashboard/components/tickets.jsx'
    if os.path.exists(original_tickets):
        orig_complexity = count_complexity(original_tickets)
        if orig_complexity:
            print(f"  📊 Original tickets.jsx: {orig_complexity['lines']} lines, complexity: {orig_complexity['complexity']}")
    
    # Check if refactored components are smaller
    total_refactored_lines = 0
    for component in components:
        if os.path.exists(component):
            with open(component, 'r') as f:
                total_refactored_lines += len(f.read().split('\n'))
    
    if total_refactored_lines > 0:
        print(f"  📊 Refactored components: {total_refactored_lines} lines total")
        print(f"  📈 Average per component: {total_refactored_lines // len(components)} lines")
    
    print_summary_footer()
    
    print("\n🎯 Next Steps:")
    print("  1. Run existing tests to ensure functionality")
    print("  2. Update imports to use refactored components")
    print("  3. Add unit tests for new components")
    print("  4. Monitor performance improvements")
    print("  5. Apply similar refactoring to other high-CC components")

if __name__ == "__main__":
    main()
