import { extractPerSpecData } from './spec-data-extractor.js';
import { buildSpecHeaderSection, buildSpecMetricsSection, buildSpecDependenciesSection, buildSpecTagsSection, buildEffortDistributionSvg, buildSpecFooterSection, buildAcceptanceCriteriaSection, buildActualsComparisonSection, buildRiskScorecard, buildLivingSpecSection, buildSimilarSpecsSection, } from './spec-section-builders.js';
import { wrapPerSpecHtml } from './html-wrapper.js';
/**
 * Generate a self-contained HTML executive report for a single spec.
 * Includes: header, metrics, actuals comparison, acceptance criteria,
 * risk scorecard, living spec status, dependencies, effort SVG, tags.
 * All rich sections are conditionally rendered based on data availability.
 */
export function generatePerSpecExecutiveReport(spec, affectedFiles, architecturalDecisions) {
    const data = extractPerSpecData(spec, affectedFiles, architecturalDecisions);
    const actualsSection = data.actuals !== undefined
        ? buildActualsComparisonSection(data.actuals, data.devHours, data.reviewHours, data.totalCostUsd)
        : '';
    const acSection = data.acceptanceCriteria !== undefined && data.acceptanceCriteria.length > 0
        ? buildAcceptanceCriteriaSection(data.acceptanceCriteria)
        : '';
    const riskSection = data.riskBreakdown !== undefined && data.riskBreakdown.length > 0
        ? buildRiskScorecard(data.riskBreakdown)
        : '';
    const livingSection = data.livingSpec !== undefined ? buildLivingSpecSection(data.livingSpec) : '';
    const similarSection = data.similarSpecs !== undefined && data.similarSpecs.length > 0
        ? buildSimilarSpecsSection(data.similarSpecs)
        : '';
    const body = [
        buildSpecHeaderSection(data),
        buildSpecMetricsSection(data),
        actualsSection,
        buildEffortDistributionSvg(data.devHours, data.reviewHours),
        acSection,
        riskSection,
        livingSection,
        buildSpecDependenciesSection(data),
        buildSpecTagsSection(data),
        similarSection,
        buildSpecFooterSection(),
    ]
        .filter(Boolean)
        .join('\n');
    const title = `Executive Report — ${data.specId}: ${data.title}`;
    const content = wrapPerSpecHtml(title, body);
    return {
        type: 'per-spec-executive',
        title,
        path: `executive-report.html`,
        content,
        audience: 'stakeholder',
        sections: [],
        diagrams: [],
        relatedSpecs: [data.specId],
    };
}
//# sourceMappingURL=executive-report.js.map