/**
 * render.mjs — roadmap JSON → ROADMAP.md renderer (C29).
 */
/**
 * Render a per-scope roadmap.json to ROADMAP.md (human-readable).
 *
 * Each scope lives in its own directory (`.aperant/roadmap/{scope}/`), so
 * every rendered file contains a single scope's milestones. The scope name
 * is shown in the title so consumers reading a standalone file know which
 * roadmap they're looking at.
 */
export function renderRoadmapMd(roadmap) {
    const project = roadmap.project || 'Project';
    const scope = roadmap.scope || 'project';
    const lines = [`# ${project} — ${scope} Roadmap`, ''];
    lines.push(`*Scope: \`${scope}\` · Last updated: ${roadmap.updated_at}*`, '');
    const statusIcon = {
        planned: '\u25cb',
        'in-progress': '\u25b6',
        completed: '\u2713',
        blocked: '\u2716',
        skipped: '\u2014',
    };
    const allMilestones = roadmap.milestones || [];
    const renderMilestone = (milestone) => {
        lines.push(`## ${milestone.title}`, '');
        if (milestone.goal)
            lines.push(`**Goal:** ${milestone.goal}`, '');
        lines.push('| Status | Phase | Owner | Description |');
        lines.push('|--------|-------|-------|-------------|');
        for (const phase of milestone.phases || []) {
            const icon = statusIcon[phase.status] || '?';
            const owner = phase.owner || 'TBD';
            const desc = (phase.description || '').replace(/\|/g, '\\|').slice(0, 80);
            lines.push(`| ${icon} ${phase.status} | **${phase.title}** | ${owner} | ${desc} |`);
        }
        lines.push('');
        // Detailed section with deliverables + blocked_by
        for (const phase of milestone.phases || []) {
            if ((phase.deliverables && phase.deliverables.length) ||
                (phase.blocked_by && phase.blocked_by.length)) {
                lines.push(`### ${phase.title}`, '');
                if (phase.blocked_by && phase.blocked_by.length) {
                    lines.push(`*Blocked by: ${phase.blocked_by.join(', ')}*`, '');
                }
                if (phase.deliverables && phase.deliverables.length) {
                    lines.push('**Deliverables:**');
                    for (const d of phase.deliverables)
                        lines.push(`- ${d}`);
                    lines.push('');
                }
                if (phase.completed_at) {
                    lines.push(`*Completed: ${phase.completed_at}*`, '');
                }
            }
        }
    };
    for (const m of allMilestones)
        renderMilestone(m);
    lines.push('---', '', `*Auto-generated from \`.aperant/roadmap/${scope}/milestones.json\` by apt-tools*`, '');
    return lines.join('\n');
}
//# sourceMappingURL=render.mjs.map