import { buildExecutiveSummaryData } from './data-extractors.js';
import { generateArchitectureSvg, generateTimelineSvg, generateRiskDistributionSvg, } from './svg-diagrams.js';
import { wrapInHtmlDocument } from './html-template.js';
import { buildHeaderSection, buildOverviewSection, buildSpecsTableSection, buildEstimationSection, buildRiskSection, buildArchitectureSection, buildTimelineSection, buildFooterSection, } from './section-builders.js';
import { buildNavbar } from '../portal/portal-navbar.js';
import { getPortalThemeCSS } from '../portal/portal-theme.js';
/**
 * Generate a self-contained HTML executive summary document.
 * Output is placed at planu/executive-summary.html (portal hub location).
 * Returns a GeneratedDocument with type 'executive-summary'.
 *
 * @param knowledge - Project knowledge data.
 * @param specs - All project specs.
 * @param _language - Language hint (reserved for future i18n).
 * @param availablePages - Portal pages that exist on disk (for navbar display).
 */
export function generateExecutiveSummary(knowledge, specs, _language, availablePages) {
    const data = buildExecutiveSummaryData(knowledge, specs);
    const archSvg = generateArchitectureSvg(data.architecture);
    const timelineSvg = generateTimelineSvg(data.specs);
    const riskSvg = generateRiskDistributionSvg(data.riskProfile);
    const hasActuals = data.specs.some((s) => s.actualDevHours !== undefined);
    // Navbar is at root level (planu/), so basePath is empty
    const navbar = buildNavbar('executive-summary', '', availablePages);
    const body = [
        navbar,
        buildHeaderSection(data.projectName, data.generatedAt, data.specs.length),
        buildOverviewSection(data.architecture),
        buildSpecsTableSection(data.specs),
        buildEstimationSection(data.estimation, hasActuals),
        buildRiskSection(data.riskProfile, riskSvg),
        buildArchitectureSection(data.architecture, archSvg),
        buildTimelineSection(timelineSvg),
        buildFooterSection(),
    ].join('\n');
    const title = `Executive Summary — ${data.projectName}`;
    // Inject portal theme CSS before the existing document CSS
    const content = wrapInHtmlDocument(title, body, getPortalThemeCSS());
    return {
        type: 'executive-summary',
        title,
        // Changed from docs/ to planu/ — this is now part of the portal hub
        path: 'planu/executive-summary.html',
        content,
        audience: 'stakeholder',
        sections: [],
        diagrams: [],
        relatedSpecs: data.specs.map((s) => s.id),
    };
}
//# sourceMappingURL=executive-summary-generator.js.map