/**
 * Detail-view body composer for ReactAppStarter (Phase 3)
 *
 * Thin wrapper around walkPattern('detail-view'). Section meanings
 * (header / main / related-lists) and the rendering of each section
 * live in the runtime pattern registry + section resolvers
 * (field-list, related-tables); this composer just emits the
 * resulting tree to JSX source.
 */

import { walkPattern } from '@specverse/runtime/views/core';
import type { EmitContext } from './view-emitter.js';
import { emitJsxSource } from './emit-jsx-source.js';

export function composeDetailBody(context: EmitContext): string {
  const imports = new Set<string>();
  const nodes = walkPattern('detail-view', {
    model: context.model,
    modelSchemas: context.modelSchemas as any,
    view: context.view,
  });
  return emitJsxSource(nodes, { imports, indent: 6 });
}
