/**
 * Form-view body composer for ReactAppStarter (Phase 3)
 *
 * Thin wrapper around walkPattern('form-view'). 'What a form view
 * looks like' lives in the runtime pattern registry + section
 * resolvers (form-fields, existing-entities-list). Each resolver is
 * a pure function producing a RenderNode tree; this composer just
 * emits the 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 composeFormBody(context: EmitContext): string {
  const imports = new Set<string>();
  const nodes = walkPattern('form-view', {
    model: context.model,
    modelSchemas: context.modelSchemas as any,
    view: context.view,
  });
  return emitJsxSource(nodes, { imports, indent: 6 });
}
