'use client'

import { ApiEndpoint, CodeBlock, InfoBox, ParameterTable } from '@/components/DevPortalLayout'

export function TechFileSection() {
  return (
    <>
      <h2>CE Technical File</h2>
      <p>
        LLM-gestuetzte Generierung der Technischen Dokumentation (CE Technical File).
        Die API generiert alle erforderlichen Abschnitte basierend auf den Projektdaten.
      </p>

      <InfoBox type="info" title="LLM-Generierung">
        Die Generierung verwendet einen LLM-Service (qwen3:30b-a3b oder claude-sonnet-4-5)
        fuer kontextbasierte Texterstellung. Alle generierten Abschnitte muessen vor der
        Freigabe manuell geprueft werden (Human Oversight).
      </InfoBox>

      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects/:id/tech-file/generate" description="Alle Tech-File-Abschnitte generieren (LLM-basiert)" />

      <CodeBlock language="bash" filename="cURL">
{`curl -X POST "https://api.breakpilot.io/sdk/v1/iace/projects/proj_a1b2c3d4/tech-file/generate" \\
  -H "Authorization: Bearer YOUR_API_KEY"`}
      </CodeBlock>

      <h3>Response (200 OK)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": {
    "sections_generated": 8,
    "sections": [
      { "section": "general_description", "title": "Allgemeine Beschreibung", "status": "generated", "word_count": 450 },
      { "section": "risk_assessment", "title": "Risikobeurteilung", "status": "generated", "word_count": 1200 },
      { "section": "safety_requirements", "title": "Sicherheitsanforderungen", "status": "generated", "word_count": 800 },
      { "section": "verification_results", "title": "Verifizierungsergebnisse", "status": "generated", "word_count": 600 }
    ],
    "total_word_count": 4850,
    "generation_time_ms": 12500
  }
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects/:id/tech-file" description="Alle Tech-File-Abschnitte auflisten" />
      <ApiEndpoint method="PUT" path="/sdk/v1/iace/projects/:id/tech-file/:section" description="Abschnitt-Inhalt manuell aktualisieren" />
      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects/:id/tech-file/:section/approve" description="Abschnitt freigeben (Human Oversight)" />
      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects/:id/tech-file/:section/generate" description="Einzelnen Abschnitt (neu) generieren via LLM" />

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects/:id/tech-file/export?format=pdf|xlsx|docx|md|json" description="Tech File exportieren" />

      <h3>Export-Formate</h3>
      <ParameterTable
        parameters={[
          { name: 'format', type: 'string', required: true, description: 'Export-Format: "pdf", "xlsx", "docx", "md", "json"' },
        ]}
      />

      <CodeBlock language="bash" filename="cURL">
{`# PDF Export
curl -X GET "https://api.breakpilot.io/sdk/v1/iace/projects/proj_a1b2c3d4/tech-file/export?format=pdf" \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -o technical-file.pdf

# Markdown Export
curl -X GET "https://api.breakpilot.io/sdk/v1/iace/projects/proj_a1b2c3d4/tech-file/export?format=md" \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -o technical-file.md`}
      </CodeBlock>
    </>
  )
}
