"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_number = require('../primordials/number.js');
const require_primordials_json = require('../primordials/json.js');
const require_strings_format = require('../strings/format.js');

//#region src/cover/formatters.ts
/**
* @file Coverage output formatters.
*/
/**
* Coverage emoji thresholds for visual feedback.
*/
const COVERAGE_EMOJI_THRESHOLDS = [
	{
		emoji: " 🚀",
		threshold: 99
	},
	{
		emoji: " 🎯",
		threshold: 95
	},
	{
		emoji: " ✨",
		threshold: 90
	},
	{
		emoji: " 💚",
		threshold: 85
	},
	{
		emoji: " ✅",
		threshold: 80
	},
	{
		emoji: " 🟢",
		threshold: 70
	},
	{
		emoji: " 🟡",
		threshold: 60
	},
	{
		emoji: " 🔨",
		threshold: 50
	},
	{
		emoji: " ⚠️",
		threshold: 0
	}
];
/**
* Calculate overall coverage percentage.
*/
function calculateOverall(code, type) {
	const metrics = [
		require_primordials_number.NumberParseFloat(code.statements.percent),
		require_primordials_number.NumberParseFloat(code.branches.percent),
		require_primordials_number.NumberParseFloat(code.functions.percent),
		require_primordials_number.NumberParseFloat(code.lines.percent)
	].map((val) => require_primordials_number.NumberIsNaN(val) ? 0 : val);
	if (type) {
		const typePercent = require_primordials_number.NumberParseFloat(type.percent);
		metrics.push(require_primordials_number.NumberIsNaN(typePercent) ? 0 : typePercent);
	}
	return require_primordials_number.NumberPrototypeToFixed(metrics.reduce((sum, val) => sum + val, 0) / metrics.length, 2);
}
/**
* Format coverage data for console output.
*
* @example
*   ;```typescript
*   const output = formatCoverage({
*     code: {
*       statements: { percent: '85.00' },
*       branches: { percent: '80.00' },
*       functions: { percent: '90.00' },
*       lines: { percent: '88.00' },
*     },
*   })
*   ```
*/
function formatCoverage(options) {
	const { code, format, type } = {
		__proto__: null,
		format: "default",
		...options
	};
	if (format === "json") return require_primordials_json.JSONStringify({
		code,
		type
	}, void 0, 2);
	const overall = calculateOverall(code, type);
	if (format === "simple") return overall;
	let output = "";
	output += "Code Coverage:\n";
	output += /* @__PURE__ */ require_strings_format.indentString(`Statements: ${code.statements.percent}%\n`, { count: 2 });
	output += /* @__PURE__ */ require_strings_format.indentString(`Branches: ${code.branches.percent}%\n`, { count: 2 });
	output += /* @__PURE__ */ require_strings_format.indentString(`Functions: ${code.functions.percent}%\n`, { count: 2 });
	output += /* @__PURE__ */ require_strings_format.indentString(`Lines: ${code.lines.percent}%\n`, { count: 2 });
	if (type) {
		output += "\nType Coverage:\n";
		output += /* @__PURE__ */ require_strings_format.indentString(`${type.percent}% (${type.covered}/${type.total})\n`, { count: 2 });
	}
	const overallValue = require_primordials_number.NumberParseFloat(overall);
	const emoji = getCoverageEmoji(require_primordials_number.NumberIsNaN(overallValue) ? 0 : overallValue);
	output += `\nOverall: ${overall}%${emoji}\n`;
	return output;
}
/**
* Get emoji for coverage percentage.
*
* @example
*   ;```typescript
*   getCoverageEmoji(95) // ' \u{1F3AF}'
*   getCoverageEmoji(50) // ' \u{1F528}'
*   ```
*/
function getCoverageEmoji(percent) {
	return COVERAGE_EMOJI_THRESHOLDS.find(({ threshold }) => percent >= threshold)?.emoji || "";
}

//#endregion
exports.calculateOverall = calculateOverall;
exports.formatCoverage = formatCoverage;
exports.getCoverageEmoji = getCoverageEmoji;