import { relative } from "path";
import chalk from "chalk";

//#region src/reporter/console-reporter.ts
/**
* Console reporter for displaying analysis results
*/
var ConsoleReporter = class {
	options;
	constructor(options) {
		this.options = options;
	}
	/**
	* Print the analysis report to console
	*/
	report(analysisReport) {
		console.log("\n" + chalk.bold.cyan("═".repeat(80)));
		console.log(chalk.bold.cyan("  Angular Unused Code Analysis Report"));
		console.log(chalk.bold.cyan("═".repeat(80)) + "\n");
		if (analysisReport.totalUnused === 0 && analysisReport.totalPossibleUnused === 0) {
			console.log(chalk.green.bold("✓ Congratulations! No unused code detected.\n"));
			return;
		}
		this.printSummary(analysisReport);
		if (this.options.type) this.printTypeResults(this.options.type, analysisReport);
		else this.printAllResults(analysisReport);
		if (this.options.detailed) {
			console.log("\n" + chalk.bold.yellow("Detailed Usage Information:"));
			console.log(chalk.yellow("─".repeat(80)) + "\n");
			this.printDetailedUsage(analysisReport);
		}
		console.log("\n" + chalk.bold.cyan("═".repeat(80)) + "\n");
	}
	/**
	* Print summary statistics
	*/
	printSummary(report) {
		console.log(chalk.bold("Summary:"));
		console.log(chalk.gray("─".repeat(50)));
		const types = [
			{
				name: "Components",
				data: report.components
			},
			{
				name: "Services",
				data: report.services
			},
			{
				name: "Pipes",
				data: report.pipes
			},
			{
				name: "Modules",
				data: report.modules
			},
			{
				name: "Directives",
				data: report.directives
			}
		];
		for (const type of types) {
			const unusedCount = type.data.unused.length;
			const possibleUnusedCount = type.data.possibleUnused.length;
			const totalCount = type.data.total;
			const usedCount = type.data.used.length;
			if (totalCount === 0) continue;
			const statusColor = unusedCount > 0 || possibleUnusedCount > 0 ? chalk.red : chalk.green;
			const percentage = totalCount > 0 ? (usedCount / totalCount * 100).toFixed(1) : "0";
			console.log(`  ${type.name.padEnd(15)} ${statusColor.bold(unusedCount.toString().padStart(3))} unused${chalk.yellow(` + ${possibleUnusedCount.toString().padStart(3)} possible`)} / ${totalCount.toString().padStart(3)} total  ${chalk.gray(`(${percentage}% used)`)}`);
		}
		console.log(chalk.gray("─".repeat(50)));
		console.log(chalk.bold(`  Total Unused:`) + " " + chalk.red.bold(report.totalUnused.toString()));
		console.log(chalk.bold(`  Total Possible Unused:`) + " " + chalk.yellow.bold(report.totalPossibleUnused.toString()));
		console.log("");
	}
	/**
	* Print all results grouped by type
	*/
	printAllResults(report) {
		this.printTypeSection("Component", report.components.unused);
		this.printTypeSection("Possible Unused Component", report.components.possibleUnused, chalk.yellow);
		this.printTypeSection("Service", report.services.unused);
		this.printTypeSection("Pipe", report.pipes.unused);
		this.printTypeSection("Module", report.modules.unused);
		this.printTypeSection("Directive", report.directives.unused);
	}
	/**
	* Print results for specific type
	*/
	printTypeResults(type, report) {
		const result = {
			component: {
				label: "Component",
				artifacts: report.components.unused
			},
			service: {
				label: "Service",
				artifacts: report.services.unused
			},
			pipe: {
				label: "Pipe",
				artifacts: report.pipes.unused
			},
			module: {
				label: "Module",
				artifacts: report.modules.unused
			},
			directive: {
				label: "Directive",
				artifacts: report.directives.unused
			}
		}[type];
		if (result) {
			this.printTypeSection(result.label, result.artifacts, result.color ?? chalk.red);
			if (type === "component") this.printTypeSection("Possible Unused Component", report.components.possibleUnused, chalk.yellow);
		}
	}
	/**
	* Print section for a specific artifact type
	*/
	printTypeSection(typeName, artifacts, color = chalk.red) {
		if (artifacts.length === 0) return;
		const plural = typeName + (typeName.endsWith("s") ? "" : "s");
		console.log(color.bold(`\n${plural} (${artifacts.length}):`));
		console.log(chalk.gray("─".repeat(80)));
		for (const artifact of artifacts) {
			const relativePath = relative(this.options.path, artifact.filePath);
			const icon = this.getIconForType(artifact.type);
			console.log(`  ${icon} ${chalk.cyan(artifact.className)}`);
			console.log(`     ${chalk.gray(relativePath)}`);
			if (artifact.selector) console.log(`     ${chalk.dim(`selector: ${artifact.selector}`)}`);
			if (artifact.standalone !== void 0) console.log(`     ${chalk.dim(`standalone: ${artifact.standalone}`)}`);
			console.log("");
		}
	}
	/**
	* Print detailed usage information
	*/
	printDetailedUsage(report) {
		const allUsed = [
			...report.components.used,
			...report.services.used,
			...report.pipes.used,
			...report.modules.used,
			...report.directives.used
		];
		if (allUsed.length === 0) {
			console.log(chalk.gray("  No used artifacts to display.\n"));
			return;
		}
		for (const artifact of allUsed) {
			if (artifact.usages.length === 0) continue;
			const relativePath = relative(this.options.path, artifact.filePath);
			const icon = this.getIconForType(artifact.type);
			console.log(`${icon} ${chalk.green.bold(artifact.className)} ${chalk.gray(`(${artifact.type})`)}`);
			console.log(`  ${chalk.dim(relativePath)}`);
			console.log(chalk.dim(`  Used in ${artifact.usages.length} place(s):`));
			for (const usage of artifact.usages) {
				const usageFile = relative(this.options.path, usage.filePath);
				const lineInfo = usage.line ? chalk.dim(`:${usage.line}`) : "";
				const context = usage.context ? chalk.dim(` - ${usage.context}`) : "";
				console.log(`    ${this.getUsageIcon(usage.type)} ${chalk.cyan(usageFile)}${lineInfo}${context}`);
			}
			console.log("");
		}
	}
	/**
	* Get icon for artifact type
	*/
	getIconForType(type) {
		return {
			component: "🧩",
			service: "⚙️",
			pipe: "🔧",
			module: "📦",
			directive: "🎯"
		}[type] || "📄";
	}
	/**
	* Get icon for usage type
	*/
	getUsageIcon(type) {
		return {
			template: "📝",
			class: "💼",
			module: "📦",
			route: "🛣️",
			injection: "💉"
		}[type] || "•";
	}
};

//#endregion
export { ConsoleReporter as t };
//# sourceMappingURL=console-reporter-DkPP8snu.mjs.map