// packages/plugin-awf/src/utils/branding.ts
// CLI Branding & Visual Identity for NOCK
// Uses gradient-string (MIT, ~15KB, used by Shopify/Turborepo/Microsoft)
import pc from "picocolors";
// ══════════════════════════════════════════════════════════════
// NOCK ASCII ART (embedded — no figlet dependency needed)
// ══════════════════════════════════════════════════════════════
const NOCK_ASCII_LARGE = `
  ███╗   ██╗  ██████╗   ██████╗ ██╗  ██╗
  ████╗  ██║ ██╔═══██╗ ██╔════╝ ██║ ██╔╝
  ██╔██╗ ██║ ██║   ██║ ██║      █████╔╝
  ██║╚██╗██║ ██║   ██║ ██║      ██╔═██╗
  ██║ ╚████║ ╚██████╔╝ ╚██████╗ ██║  ██╗
  ╚═╝  ╚═══╝  ╚═════╝   ╚═════╝ ╚═╝  ╚═╝`;
const NOCK_ASCII_COMPACT = `  ◆ N O C K`;
// ══════════════════════════════════════════════════════════════
// GRADIENT (lazy-loaded to avoid import cost when not used)
// ══════════════════════════════════════════════════════════════
let _gradient = null;
async function getGradient() {
    if (_gradient)
        return _gradient;
    try {
        _gradient = await import("gradient-string");
        return _gradient;
    }
    catch {
        return null; // Graceful fallback if gradient-string not installed
    }
}
// NOCK brand colors: cyan → purple → blue
const NOCK_COLORS = ["#06b6d4", "#8b5cf6", "#3b82f6"];
// ══════════════════════════════════════════════════════════════
// PUBLIC API
// ══════════════════════════════════════════════════════════════
/**
 * Show the NOCK welcome banner with gradient ASCII art.
 * Falls back to simple box banner if gradient-string unavailable.
 *
 * @param version - AWF version string (e.g., "6.4.10")
 * @param context - Context line (e.g., "Project Initialization")
 */
export async function showBanner(version, context) {
    // Skip fancy banner in CI environments
    const isCI = !!(process.env.CI || process.env.NO_COLOR);
    if (isCI) {
        showSimpleBanner(version, context);
        return;
    }
    const gradientMod = await getGradient();
    if (gradientMod) {
        // Gradient ASCII art banner
        const grad = gradientMod.default(NOCK_COLORS);
        console.log(grad.multiline(NOCK_ASCII_LARGE));
        console.log();
        console.log(`  ${pc.dim("Awesome Code Framework")}  ${pc.cyan(`v${version}`)}  ${pc.dim("·")}  ${pc.dim(context || "Ready")}`);
        console.log();
    }
    else {
        // Fallback: simple box (no gradient-string installed)
        showSimpleBanner(version, context);
    }
}
/**
 * Show compact gradient banner (for install/update commands).
 * Less visual weight than the full banner.
 */
export async function showCompactBanner(version, context) {
    const isCI = !!(process.env.CI || process.env.NO_COLOR);
    if (isCI) {
        console.log(`\n  ◆ NOCK v${version} — ${context}\n`);
        return;
    }
    const gradientMod = await getGradient();
    if (gradientMod) {
        const grad = gradientMod.default(NOCK_COLORS);
        console.log();
        console.log(grad(NOCK_ASCII_COMPACT));
        console.log(`  ${pc.dim("Awesome Code Framework")}  ${pc.cyan(`v${version}`)}  ${pc.dim("·")}  ${pc.dim(context)}`);
        console.log();
    }
    else {
        console.log(`\n  ${pc.bold(pc.cyan("◆ NOCK"))} ${pc.dim(`v${version} · ${context}`)}\n`);
    }
}
/**
 * Show installation completion stats box.
 * Displays a branded summary of what was installed.
 */
export function showCompletionStats(stats) {
    const line = pc.dim("  ─".repeat(20));
    console.log();
    console.log(line);
    console.log(`  ${pc.bold(pc.green("◆"))} ${pc.bold("NOCK Setup Complete")}`);
    console.log(line);
    if (stats.skills)
        console.log(`  ${pc.cyan("📦")} Skills:     ${pc.bold(String(stats.skills))} installed`);
    if (stats.workflows)
        console.log(`  ${pc.cyan("🔄")} Workflows:  ${pc.bold(String(stats.workflows))} commands`);
    if (stats.rules)
        console.log(`  ${pc.cyan("📜")} Rules:      ${pc.bold(String(stats.rules))} modules`);
    if (stats.ides && stats.ides.length > 0) {
        console.log(`  ${pc.cyan("🤖")} IDEs:       ${pc.bold(String(stats.ides.length))} configured ${pc.dim(`(${stats.ides.join(", ")})`)}`);
    }
    if (stats.mcp)
        console.log(`  ${pc.cyan("🔌")} MCP:        ${pc.green("domyh-hsa")} ${pc.dim("(node)")}`);
    if (stats.scope)
        console.log(`  ${pc.cyan("📍")} Scope:      ${stats.scope}`);
    console.log(line);
    console.log(`  ${pc.dim("Next:")} Open your IDE — AWF is ready! ${pc.green("✓")}`);
    console.log();
}
// ══════════════════════════════════════════════════════════════
// FALLBACK (no gradient-string)
// ══════════════════════════════════════════════════════════════
function showSimpleBanner(version, context) {
    console.log();
    console.log(pc.cyan("  ╔══════════════════════════════════════════╗"));
    console.log(pc.cyan("  ║") + `   ${pc.bold(pc.cyan("◆ NOCK"))} ${pc.dim("— Awesome Code Framework")}       ` + pc.cyan("║"));
    console.log(pc.cyan("  ║") + `   ${pc.dim(`v${version} · ${context || "Ready"}`)}`.padEnd(42) + pc.cyan("║"));
    console.log(pc.cyan("  ╚══════════════════════════════════════════╝"));
    console.log();
}
