/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import path from "node:path";
//#region ../css/dist/css/runner.helpers.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
const getDisplayPath = (cwd, targetPath) => {
	const relativePath = path.relative(cwd, targetPath);
	return relativePath.length === 0 ? "." : relativePath;
};
const getVerboseScanFileList = (cwd, filePaths) => [...new Set(filePaths.map((filePath) => getDisplayPath(cwd, filePath)))].sort((left, right) => left.localeCompare(right));
const getOptimizationDetailLines = (optimizationStats) => {
	const detailLines = [];
	if (optimizationStats.fontFacesRemoved > 0) detailLines.push(`      • removed ${optimizationStats.fontFacesRemoved} unused @font-face`);
	if (optimizationStats.emptyRulesRemoved > 0) detailLines.push(`      • removed ${optimizationStats.emptyRulesRemoved} empty rules`);
	return detailLines;
};
const formatCssDuration = (durationMs) => {
	return `${(Math.floor(durationMs / 100) / 10).toFixed(1)}s`;
};
const getCssSummaryMessage = (options) => {
	const { label, optimizationStats, sizeGzipBytes, formatBytes } = options;
	const summaryLine = `${label}: ${formatBytes(sizeGzipBytes)} gzip`;
	if (!optimizationStats) return {
		summaryLine,
		detailLines: []
	};
	const { originalSizeGzip, fontFacesRemoved, emptyRulesRemoved } = optimizationStats;
	if (originalSizeGzip - sizeGzipBytes <= 0) return {
		summaryLine,
		detailLines: []
	};
	return {
		summaryLine,
		detailLines: getOptimizationDetailLines({
			originalSizeGzip,
			fontFacesRemoved,
			emptyRulesRemoved
		})
	};
};
const getMainCssSummaryMessage = (options) => {
	return getCssSummaryMessage({
		label: "Main CSS",
		...options
	});
};
const getScopedCssSummaryMessage = (packageName, options) => getCssSummaryMessage({
	label: `${packageName} CSS`,
	...options
});
const getOutputFileSection = (cwd, outputPaths) => ({
	label: "Output files:",
	paths: outputPaths.map((outputPath) => getDisplayPath(cwd, outputPath))
});
const getScanSummaryMessage = (options) => {
	const nonComponentFileCount = Math.max(options.filesScanned - options.filesWithComponents, 0);
	const fileLabel = nonComponentFileCount === 1 ? "file" : "files";
	const componentLabel = options.componentCount === 1 ? "component" : "components";
	return `${options.label}: ${nonComponentFileCount} ${fileLabel}, ${options.componentCount} ${componentLabel} (${options.mode})`;
};
const getWatchDirectoryGroups = (entryDirs, dirs) => {
	const watchDirs = [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
	return {
		watchDirs,
		filteredPackageDirs: watchDirs.filter((dir) => !entryDirs.includes(dir))
	};
};
//#endregion
export { formatCssDuration, getMainCssSummaryMessage, getOutputFileSection, getScanSummaryMessage, getScopedCssSummaryMessage, getVerboseScanFileList, getWatchDirectoryGroups };
