"use strict";
/**
 * 🏆 faf formats - TURBO-CAT Format Discovery Command
 * Lists all discovered formats in the project
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatsCommand = formatsCommand;
const colors_1 = require("../fix-once/colors");
const championship_style_1 = require("../utils/championship-style");
const fab_formats_engine_1 = require("../utils/fab-formats-engine");
async function formatsCommand(projectPath, options = {}) {
    // FAF banner is now shown by cli.ts - removed duplicate
    console.log();
    console.log(championship_style_1.FAF_COLORS.fafCyan(`😽 TURBO-CAT™ --Prowling... v2.0.0`));
    console.log(championship_style_1.FAF_COLORS.fafCyan(`═══════════════════════════════════`));
    console.log();
    const fabFormats = new fab_formats_engine_1.FabFormatsEngine();
    const projectRoot = projectPath || process.cwd();
    console.log(colors_1.chalk.gray(`${championship_style_1.FAF_ICONS.lightning} Scanning project at ${projectRoot}...`));
    const startTime = Date.now();
    const analysis = await fabFormats.discoverFormats(projectRoot);
    const elapsedTime = Date.now() - startTime;
    console.log();
    console.log(championship_style_1.FAF_COLORS.fafGreen(`✅ Found ${analysis.discoveredFormats.length} formats in ${elapsedTime}ms!`));
    console.log();
    if (options.json || options.export) {
        // Export as JSON
        console.log(JSON.stringify(analysis, null, 2));
    }
    else if (options.category) {
        // Show by category (pyramid levels)
        console.log(championship_style_1.FAF_COLORS.fafCyan(`📊 By Category:`));
        console.log();
        const categories = {
            'Config': [],
            'Code': [],
            'Documentation': [],
            'Testing': [],
            'CI/CD': [],
            'Container': [],
            'Database': [],
            'Other': []
        };
        // Categorize formats
        analysis.discoveredFormats.forEach(format => {
            const formatName = format.fileName;
            if (formatName.includes('json') || formatName.includes('yaml') || formatName.includes('toml')) {
                categories['Config'].push(formatName);
            }
            else if (formatName.includes('.ts') || formatName.includes('.js') || formatName.includes('.py')) {
                categories['Code'].push(formatName);
            }
            else if (formatName.includes('.md') || formatName.includes('README')) {
                categories['Documentation'].push(formatName);
            }
            else if (formatName.includes('test') || formatName.includes('spec')) {
                categories['Testing'].push(formatName);
            }
            else if (formatName.includes('workflow') || formatName.includes('jenkins')) {
                categories['CI/CD'].push(formatName);
            }
            else if (formatName.includes('docker') || formatName.includes('compose')) {
                categories['Container'].push(formatName);
            }
            else if (formatName.includes('.sql') || formatName.includes('migration')) {
                categories['Database'].push(formatName);
            }
            else {
                categories['Other'].push(formatName);
            }
        });
        // Display categories
        Object.entries(categories).forEach(([category, formats]) => {
            if (formats.length > 0) {
                console.log(championship_style_1.FAF_COLORS.fafOrange(`  ${category}:`));
                formats.forEach(format => {
                    console.log(colors_1.chalk.gray(`    - ${format}`));
                });
                console.log();
            }
        });
    }
    else {
        // Default: alphabetical list
        console.log(championship_style_1.FAF_COLORS.fafCyan(`📋 Discovered Formats (A-Z):`));
        console.log();
        const sorted = [...analysis.discoveredFormats].sort((a, b) => a.fileName.localeCompare(b.fileName));
        sorted.forEach(format => {
            // FAB-FORMATS always confirms (it reads the file)
            const icon = '✅';
            const color = colors_1.chalk.green;
            console.log(color(`  ${icon} ${format.fileName}`));
        });
    }
    console.log();
    console.log(championship_style_1.FAF_COLORS.fafCyan(`💡 Stack Signature: ${analysis.stackSignature}`));
    console.log(championship_style_1.FAF_COLORS.fafOrange(`🏆 Intelligence Score: ${analysis.totalIntelligenceScore}`));
    console.log();
    // TURBO-CAT signature
    console.log(colors_1.chalk.gray('─'.repeat(40)));
    console.log(championship_style_1.FAF_COLORS.fafCyan(`😽 TURBO-CAT™: "I detected ${analysis.discoveredFormats.length} formats and made your stack PURRR!"`));
    console.log(colors_1.chalk.gray('─'.repeat(40)));
    console.log();
}
//# sourceMappingURL=formats.js.map