'use client' import type { ExcludeRegion, StructureResult } from '@/app/(admin)/ai/ocr-kombi/types' import { COLOR_HEX, getDocLayoutColor } from './structure-detection-utils' interface StructureResultDetailsProps { result: StructureResult excludeRegions: ExcludeRegion[] } export function StructureResultDetails({ result, excludeRegions }: StructureResultDetailsProps) { return (
{/* Summary badges */}
{result.zones.length} Zone(n) {result.boxes.length} Box(en) {result.layout_regions && result.layout_regions.length > 0 && ( {result.layout_regions.length} Layout-Region(en) )} {result.graphics && result.graphics.length > 0 && ( {result.graphics.length} Grafik(en) )} {result.has_words && ( {result.word_count} Woerter )} {excludeRegions.length > 0 && ( {excludeRegions.length} Ausschluss )} {(result.border_ghosts_removed ?? 0) > 0 && ( {result.border_ghosts_removed} Rahmenlinien entfernt )} {result.detection_method && ( {result.detection_method === 'ppdoclayout' ? 'PP-DocLayout' : 'OpenCV'} | )} {result.image_width}x{result.image_height}px | {result.duration_seconds}s
{/* Boxes detail */} {result.boxes.length > 0 && ( )} {/* PP-DocLayout regions detail */} {result.layout_regions && result.layout_regions.length > 0 && ( )} {/* Zones detail */} {/* Graphics / visual elements */} {result.graphics && result.graphics.length > 0 && ( )} {/* Color regions */} {Object.keys(result.color_pixel_counts).length > 0 && ( )}
) } /* ------------------------------------------------------------------ */ /* Sub-sections */ /* ------------------------------------------------------------------ */ function BoxesDetail({ boxes }: { boxes: StructureResult['boxes'] }) { return (

Erkannte Boxen

{boxes.map((box, i) => (
Box {i + 1}: {box.w}x{box.h}px @ ({box.x}, {box.y}) {box.bg_color_name && box.bg_color_name !== 'unknown' && box.bg_color_name !== 'white' && ( {box.bg_color_name} )} {box.border_thickness > 0 && ( Rahmen: {box.border_thickness}px )} {Math.round(box.confidence * 100)}%
))}
) } function LayoutRegionsDetail({ regions }: { regions: NonNullable }) { return (

PP-DocLayout Regionen ({regions.length})

{regions.map((region, i) => { const color = getDocLayoutColor(region.class_name) return (
{region.class_name} {region.w}x{region.h}px @ ({region.x}, {region.y}) {Math.round(region.confidence * 100)}%
) })}
) } function ZonesDetail({ zones }: { zones: StructureResult['zones'] }) { return (

Seitenzonen

{zones.map((zone) => ( {zone.zone_type === 'box' ? 'Box' : 'Inhalt'} {zone.index} ({zone.w}x{zone.h}) ))}
) } function GraphicsDetail({ graphics }: { graphics: StructureResult['graphics'] }) { // Summary by shape const shapeCounts: Record = {} for (const g of graphics) { shapeCounts[g.shape] = (shapeCounts[g.shape] || 0) + 1 } return (

Graphische Elemente ({graphics.length})

{/* Summary by shape */}
{Object.entries(shapeCounts) .sort(([, a], [, b]) => b - a) .map(([shape, count]) => ( {shape === 'arrow' ? '\u2192' : shape === 'circle' ? '\u25CF' : shape === 'line' ? '\u2500' : shape === 'exclamation' ? '\u2757' : shape === 'dot' ? '\u2022' : shape === 'illustration' ? '\uD83D\uDDBC' : '\u25C6'} {' '}{shape} x{count} ))}
{/* Individual graphics list */}
{graphics.map((g, i) => (
{g.shape} {g.w}x{g.h}px @ ({g.x}, {g.y}) {g.color_name} {Math.round(g.confidence * 100)}%
))}
) } function ColorRegionsDetail({ colorPixelCounts }: { colorPixelCounts: Record }) { return (

Erkannte Farben

{Object.entries(colorPixelCounts) .sort(([, a], [, b]) => b - a) .map(([name, count]) => ( {name} {count.toLocaleString()}px ))}
) }