/**
 * Certification Badge Generation
 *
 * Generates SVG badges for certification status that can be embedded
 * in README files or displayed on dashboards.
 *
 * @module certification/badge
 */
/**
 * Color palette for certification levels
 */
const LEVEL_COLORS = {
    CERTIFIED: "#22c55e", // Green
    APPROVED: "#eab308", // Yellow
    REVIEW_REQUIRED: "#f97316", // Orange
    BLOCKED: "#ef4444", // Red
};
/**
 * Human-readable labels for certification levels
 */
const LEVEL_LABELS = {
    CERTIFIED: "Certified",
    APPROVED: "Approved",
    REVIEW_REQUIRED: "Review Required",
    BLOCKED: "Blocked",
};
/**
 * Default color for unknown levels
 */
const DEFAULT_COLOR = "#6b7280"; // Gray
/**
 * Badge dimensions
 */
const BADGE_HEIGHT = 20;
const LABEL_WIDTH = 80;
const VALUE_WIDTH = 120;
const TOTAL_WIDTH = LABEL_WIDTH + VALUE_WIDTH;
/**
 * Generate an SVG certification badge.
 *
 * Creates a shields.io-style badge showing certification level and score.
 *
 * @param level - The certification level
 * @param score - The overall score (0-100)
 * @returns SVG string that can be saved to a file or embedded in markdown
 *
 * @example
 * ```typescript
 * const svg = generateBadgeSvg("APPROVED", 85);
 * // Returns SVG showing "certification | Approved 85/100"
 * ```
 */
export function generateBadgeSvg(level, score) {
    const color = LEVEL_COLORS[level] || DEFAULT_COLOR;
    const label = LEVEL_LABELS[level] || level;
    const scoreText = `${Math.round(score)}/100`;
    return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${TOTAL_WIDTH}" height="${BADGE_HEIGHT}" role="img" aria-label="certification: ${label} ${scoreText}">
  <title>certification: ${label} ${scoreText}</title>
  <linearGradient id="s" x2="0" y2="100%">
    <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
    <stop offset="1" stop-opacity=".1"/>
  </linearGradient>
  <clipPath id="r">
    <rect width="${TOTAL_WIDTH}" height="${BADGE_HEIGHT}" rx="3" fill="#fff"/>
  </clipPath>
  <g clip-path="url(#r)">
    <rect width="${LABEL_WIDTH}" height="${BADGE_HEIGHT}" fill="#555"/>
    <rect x="${LABEL_WIDTH}" width="${VALUE_WIDTH}" height="${BADGE_HEIGHT}" fill="${color}"/>
    <rect width="${TOTAL_WIDTH}" height="${BADGE_HEIGHT}" fill="url(#s)"/>
  </g>
  <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
    <text aria-hidden="true" x="${LABEL_WIDTH / 2}" y="15" fill="#010101" fill-opacity=".3">certification</text>
    <text x="${LABEL_WIDTH / 2}" y="14">certification</text>
    <text aria-hidden="true" x="${LABEL_WIDTH + VALUE_WIDTH / 2}" y="15" fill="#010101" fill-opacity=".3">${label} ${scoreText}</text>
    <text x="${LABEL_WIDTH + VALUE_WIDTH / 2}" y="14">${label} ${scoreText}</text>
  </g>
</svg>`;
}
/**
 * Generate a simple text badge for markdown.
 *
 * @param level - The certification level
 * @param score - The overall score (0-100)
 * @returns Markdown badge text
 *
 * @example
 * ```typescript
 * const badge = generateTextBadge("APPROVED", 85);
 * // Returns: "![Certification: Approved](https://img.shields.io/badge/certification-Approved%2085%2F100-eab308)"
 * ```
 */
export function generateTextBadge(level, score) {
    const color = LEVEL_COLORS[level]?.replace("#", "") || "gray";
    const label = encodeURIComponent(LEVEL_LABELS[level] || level);
    const scoreText = encodeURIComponent(`${Math.round(score)}/100`);
    return `![Certification: ${LEVEL_LABELS[level] || level}](https://img.shields.io/badge/certification-${label}%20${scoreText}-${color})`;
}
/**
 * Generate a compact score-only badge.
 *
 * @param score - The overall score (0-100)
 * @returns SVG string for score badge
 */
export function generateScoreBadgeSvg(score) {
    const roundedScore = Math.round(score);
    // Determine color based on score
    let color;
    if (roundedScore >= 90) {
        color = LEVEL_COLORS.CERTIFIED;
    }
    else if (roundedScore >= 70) {
        color = LEVEL_COLORS.APPROVED;
    }
    else if (roundedScore >= 40) {
        color = LEVEL_COLORS.REVIEW_REQUIRED;
    }
    else {
        color = LEVEL_COLORS.BLOCKED;
    }
    const width = 90;
    return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${BADGE_HEIGHT}" role="img" aria-label="score: ${roundedScore}">
  <title>score: ${roundedScore}</title>
  <linearGradient id="s" x2="0" y2="100%">
    <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
    <stop offset="1" stop-opacity=".1"/>
  </linearGradient>
  <clipPath id="r">
    <rect width="${width}" height="${BADGE_HEIGHT}" rx="3" fill="#fff"/>
  </clipPath>
  <g clip-path="url(#r)">
    <rect width="45" height="${BADGE_HEIGHT}" fill="#555"/>
    <rect x="45" width="45" height="${BADGE_HEIGHT}" fill="${color}"/>
    <rect width="${width}" height="${BADGE_HEIGHT}" fill="url(#s)"/>
  </g>
  <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
    <text aria-hidden="true" x="22" y="15" fill="#010101" fill-opacity=".3">score</text>
    <text x="22" y="14">score</text>
    <text aria-hidden="true" x="67" y="15" fill="#010101" fill-opacity=".3">${roundedScore}/100</text>
    <text x="67" y="14">${roundedScore}/100</text>
  </g>
</svg>`;
}
/**
 * Generate badge markdown for embedding in README.
 *
 * @param level - The certification level
 * @param score - The overall score (0-100)
 * @param badgePath - Relative path to the badge SVG file
 * @returns Markdown string for embedding the badge
 */
export function generateBadgeMarkdown(level, score, badgePath = "./certification-badge.svg") {
    const label = LEVEL_LABELS[level] || level;
    return `[![Certification: ${label} ${Math.round(score)}/100](${badgePath})](./CERTIFICATION.md)`;
}
//# sourceMappingURL=badge.js.map