const DIFFICULTY_COLORS = {
    1: '#10B981', // trivial — green
    2: '#3B82F6', // simple — blue
    3: '#F59E0B', // moderate — amber
    4: '#EF4444', // complex — red
    5: '#7C3AED', // expert — purple
};
/** Generate an SVG showing stacked architecture layers with gradient colors. */
export function generateArchitectureSvg(arch) {
    const layers = arch.layers.length > 0 ? arch.layers : ['No layers detected'];
    const boxHeight = 40;
    const boxWidth = 360;
    const gap = 10;
    const totalHeight = layers.length * (boxHeight + gap) + gap + 40;
    const svgWidth = 440;
    const gradients = layers.map((_, i) => {
        const ratio = layers.length > 1 ? i / (layers.length - 1) : 0;
        const r = Math.round(79 + (124 - 79) * ratio);
        const g = Math.round(70 + (58 - 70) * ratio);
        const b = Math.round(229 + (237 - 229) * ratio);
        return `rgb(${r},${g},${b})`;
    });
    const boxes = layers
        .map((layer, i) => {
        const y = gap + i * (boxHeight + gap);
        const color = gradients[i] ?? '#4F46E5';
        const arrowY = y + boxHeight;
        const arrow = i < layers.length - 1
            ? `<line x1="${svgWidth / 2}" y1="${arrowY}" x2="${svgWidth / 2}" y2="${arrowY + gap}" stroke="#94a3b8" stroke-width="2" marker-end="url(#arrow)"/>`
            : '';
        return `
    <rect x="${(svgWidth - boxWidth) / 2}" y="${y}" width="${boxWidth}" height="${boxHeight}" rx="6" fill="${color}" opacity="0.9"/>
    <text x="${svgWidth / 2}" y="${y + boxHeight / 2 + 5}" text-anchor="middle" font-family="sans-serif" font-size="13" fill="white" font-weight="600">${escapeXml(layer)}</text>
    ${arrow}`;
    })
        .join('');
    return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svgWidth} ${totalHeight}" style="max-width:100%;font-family:sans-serif">
  <defs>
    <marker id="arrow" markerWidth="8" markerHeight="8" refX="4" refY="4" orient="auto">
      <path d="M0,0 L8,4 L0,8 Z" fill="#94a3b8"/>
    </marker>
  </defs>
  ${boxes}
</svg>`;
}
/** Generate an SVG timeline: horizontal bars proportional to devHours, colored by difficulty. */
export function generateTimelineSvg(specs) {
    if (specs.length === 0) {
        return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 60" style="max-width:100%">
  <text x="200" y="35" text-anchor="middle" font-family="sans-serif" font-size="14" fill="#94a3b8">No specs available</text>
</svg>`;
    }
    const maxHours = Math.max(...specs.map((s) => s.devHours), 1);
    const rowHeight = 28;
    const labelWidth = 150;
    const barMaxWidth = 220;
    const svgWidth = labelWidth + barMaxWidth + 60;
    const svgHeight = specs.length * rowHeight + 20;
    const rows = specs
        .map((spec, i) => {
        const y = 10 + i * rowHeight;
        const barWidth = Math.round((spec.devHours / maxHours) * barMaxWidth);
        const color = DIFFICULTY_COLORS[spec.difficulty] ?? '#94a3b8';
        const label = spec.title.length > 20 ? spec.title.slice(0, 18) + '…' : spec.title;
        return `
    <text x="${labelWidth - 5}" y="${y + 16}" text-anchor="end" font-family="sans-serif" font-size="11" fill="#374151">${escapeXml(label)}</text>
    <rect x="${labelWidth}" y="${y + 4}" width="${barWidth}" height="18" rx="3" fill="${color}" opacity="0.85"/>
    <text x="${labelWidth + barWidth + 5}" y="${y + 16}" font-family="sans-serif" font-size="10" fill="#6b7280">${spec.devHours}h</text>`;
    })
        .join('');
    return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svgWidth} ${svgHeight}" style="max-width:100%;font-family:sans-serif">
  ${rows}
</svg>`;
}
/** Generate an SVG stacked horizontal bar for risk distribution. */
export function generateRiskDistributionSvg(risk) {
    const total = risk.low + risk.medium + risk.high + risk.critical;
    if (total === 0) {
        return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 60" style="max-width:100%">
  <text x="200" y="35" text-anchor="middle" font-family="sans-serif" font-size="14" fill="#94a3b8">No risk data</text>
</svg>`;
    }
    const barWidth = 380;
    const barHeight = 30;
    const svgWidth = 420;
    const svgHeight = 90;
    const segments = [
        { count: risk.low, color: '#10B981', label: 'Low' },
        { count: risk.medium, color: '#F59E0B', label: 'Medium' },
        { count: risk.high, color: '#F97316', label: 'High' },
        { count: risk.critical, color: '#EF4444', label: 'Critical' },
    ];
    let xOffset = 20;
    const bars = segments
        .map(({ count, color }) => {
        if (count === 0) {
            return '';
        }
        const width = Math.round((count / total) * barWidth);
        const bar = `<rect x="${xOffset}" y="10" width="${width}" height="${barHeight}" fill="${color}" opacity="0.9"/><text x="${xOffset + width / 2}" y="30" text-anchor="middle" font-family="sans-serif" font-size="11" fill="white" font-weight="600">${count}</text>`;
        xOffset += width;
        return bar;
    })
        .join('');
    const legend = segments
        .map(({ color, label }, i) => {
        const lx = 20 + i * 100;
        return `<rect x="${lx}" y="52" width="12" height="12" fill="${color}" rx="2"/><text x="${lx + 16}" y="63" font-family="sans-serif" font-size="11" fill="#374151">${label}</text>`;
    })
        .join('');
    return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svgWidth} ${svgHeight}" style="max-width:100%;font-family:sans-serif">
  ${bars}
  ${legend}
</svg>`;
}
function escapeXml(str) {
    return str
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#39;');
}
//# sourceMappingURL=svg-diagrams.js.map