import { buildHeroSection, buildExecutiveSummarySection, buildScopeSection, buildSpecBreakdownSection, buildTimelineSection, buildBudgetSection, buildInvestmentSummarySection, buildArchitectureSection, buildRiskSection, buildDecisionsSection, buildImpactAnalysisSection, buildGapAnalysisSection, buildTeamResourcesSection, buildPricingMethodologySection, buildDesignSystemSection, buildQualityMetricsSection, buildLivingSpecSection, buildAssumptionsSection, buildAlternativesSection, buildPostLaunchSection, buildModuleMappingSection, buildFooterSection, } from './proposal-section-builders.js';
import { buildScorecardSection, buildMermaidSection, buildVerdictSection, } from './proposal-section-builders-advanced.js';
import { wrapProposalHtml } from './proposal-html-wrapper.js';
/** Canonical section IDs for includeSections / excludeSections filtering. */
export const SECTION_IDS = [
    'hero',
    'executive-summary',
    'scope',
    'spec-breakdown',
    'timeline',
    'budget',
    'investment-summary',
    'architecture',
    'risk',
    'decisions',
    'impact-analysis',
    'gap-analysis',
    'team-resources',
    'pricing-methodology',
    'design-system',
    'quality-metrics',
    'living-spec',
    'assumptions',
    'alternatives',
    'post-launch',
    'module-mapping',
];
/** Build a section filter based on include/exclude lists. */
function makeSectionFilter(include, exclude) {
    if (include && include.length > 0) {
        return (id) => include.includes(id);
    }
    if (exclude && exclude.length > 0) {
        return (id) => !exclude.includes(id);
    }
    return () => true;
}
function buildCoreSections(data, isEnabled) {
    return [
        isEnabled('executive-summary') ? buildExecutiveSummarySection(data) : '',
        isEnabled('scope') ? buildScopeSection(data) : '',
        isEnabled('spec-breakdown') ? buildSpecBreakdownSection(data) : '',
        isEnabled('timeline') ? buildTimelineSection(data) : '',
        isEnabled('budget') ? buildBudgetSection(data) : '',
        isEnabled('investment-summary') ? buildInvestmentSummarySection(data) : '',
        isEnabled('architecture') ? buildArchitectureSection(data) : '',
        isEnabled('risk') ? buildRiskSection(data) : '',
        isEnabled('decisions') ? buildDecisionsSection(data) : '',
        isEnabled('impact-analysis') ? buildImpactAnalysisSection(data) : '',
    ];
}
function buildAdvancedSections(data, isEnabled) {
    const scorecardHtml = data.scorecard && data.scorecard.length > 0 ? buildScorecardSection(data.scorecard) : '';
    const mermaidHtml = data.mermaidDiagrams && data.mermaidDiagrams.length > 0
        ? buildMermaidSection(data.mermaidDiagrams)
        : '';
    const verdictHtml = data.verdict ? buildVerdictSection(data.verdict) : '';
    return [
        isEnabled('gap-analysis') ? buildGapAnalysisSection(data) : '',
        isEnabled('team-resources') ? buildTeamResourcesSection(data) : '',
        isEnabled('pricing-methodology') ? buildPricingMethodologySection(data) : '',
        isEnabled('design-system') ? buildDesignSystemSection(data) : '',
        isEnabled('quality-metrics') ? buildQualityMetricsSection(data) : '',
        isEnabled('living-spec') ? buildLivingSpecSection(data) : '',
        isEnabled('assumptions') ? buildAssumptionsSection(data) : '',
        isEnabled('alternatives') ? buildAlternativesSection(data) : '',
        isEnabled('post-launch') ? buildPostLaunchSection(data) : '',
        isEnabled('module-mapping') ? buildModuleMappingSection(data) : '',
        scorecardHtml,
        mermaidHtml,
        verdictHtml,
    ];
}
/** Build all content sections (everything except hero and footer). */
function buildContentSections(data, isEnabled) {
    return [...buildCoreSections(data, isEnabled), ...buildAdvancedSections(data, isEnabled)]
        .filter(Boolean)
        .join('\n');
}
/**
 * Generate a self-contained HTML proposal document.
 * All sections are conditional — empty string returned when data is insufficient.
 * Sections can be filtered via ProposalConfig.includeSections / excludeSections.
 */
export function generateProposal(data) {
    const { includeSections, excludeSections, theme, language } = data.config;
    const isEnabled = makeSectionFilter(includeSections, excludeSections);
    const hero = isEnabled('hero') ? buildHeroSection(data) : '';
    const contentSections = buildContentSections(data, isEnabled);
    const body = [
        hero,
        contentSections ? `<div class="content">\n${contentSections}\n</div>` : '',
        buildFooterSection(data),
    ]
        .filter(Boolean)
        .join('\n');
    const docTitle = data.config.title ?? data.projectName;
    const docTheme = theme ?? 'light';
    const docLang = language ?? 'en';
    const hasMermaid = Boolean(data.mermaidDiagrams && data.mermaidDiagrams.length > 0);
    return wrapProposalHtml(docTitle, body, docTheme, docLang, hasMermaid);
}
//# sourceMappingURL=proposal-generator.js.map