// engine/spec-versioning/render-history.ts — Serialize SpecHistoryEntry[] to YAML (SPEC-717)
/**
 * Serialize a list of SpecHistoryEntry objects to a YAML block suitable for
 * embedding inside a spec.md frontmatter (under the `history:` key).
 *
 * @pure — no I/O.
 *
 * @example
 * renderHistoryYaml([]) => "history: []"
 * renderHistoryYaml([entry]) =>
 *   "history:\n  - at: ...\n    kind: ...\n    ..."
 */
export function renderHistoryYaml(entries) {
    if (entries.length === 0) {
        return 'history: []';
    }
    const lines = ['history:'];
    for (const e of entries) {
        lines.push(`  - at: ${e.at}`);
        lines.push(`    kind: ${e.kind}`);
        lines.push(`    spec_version_from: ${e.spec_version_from ?? 'null'}`);
        lines.push(`    spec_version_to: ${e.spec_version_to}`);
        lines.push(`    by: ${e.by}`);
        lines.push(`    reason: "${escapeYamlString(e.reason)}"`);
    }
    return lines.join('\n');
}
function escapeYamlString(s) {
    return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
}
//# sourceMappingURL=render-history.js.map