'use client'
import { BookMarked, FileText, Hash, Image as ImageIcon, Library, Scale } from 'lucide-react'
import type { AdvisorResponse } from '@/lib/sdk/advisor/contract'
import {
provisionSummary,
summarizeEvidence,
type FamilyGroup,
} from '@/lib/sdk/advisor/evidence-grouping'
const plural = (n: number, one: string, many: string) => (n === 1 ? one : many)
function Count({
icon,
value,
label,
dim,
}: {
icon: React.ReactNode
value: number
label: string
dim?: boolean
}) {
return (
{icon}
{value}{' '}
{label}
)
}
function GroupRow({ group, icon }: { group: FamilyGroup; icon: React.ReactNode }) {
// A single-unit guidance doc needs no "1 Fundstelle" noise; norms always show their provisions.
const detail = group.sections.length === 0 && group.units <= 1 ? '' : provisionSummary(group)
return (
{icon}
{group.label}
{detail && {detail}}
)
}
function Section({
title,
groups,
icon,
}: {
title: string
groups: FamilyGroup[]
icon: React.ReactNode
}) {
if (groups.length === 0) return null
return (
{title}
{groups.map((g) => (
))}
)
}
/**
* "Diese Antwort stützt sich auf" — describes the EVIDENCE (not the documents), objective counts
* only (no fabricated trust score). When the Legal-KG ships `bindingness`, binding Rechtsgrundlagen
* are split from Leitlinien (soft-law guidance); until then it shows a neutral evidence breakdown.
*/
export function EvidenceSummary({ response }: { response: AdvisorResponse }) {
const m = summarizeEvidence(response.evidence)
const figures = response.visual_evidence.length
const notes = response.footnotes.length
const cls = 'h-4 w-4'
const smallIcon = 'h-3.5 w-3.5'
return (
Diese Antwort stützt sich auf
{m.hasBindingness && (
<>
}
value={m.normProvisions}
label={plural(m.normProvisions, 'Rechtsgrundlage', 'Rechtsgrundlagen')}
/>
}
value={m.guidanceCount}
label={plural(m.guidanceCount, 'Leitlinie', 'Leitlinien')}
dim={m.guidanceCount === 0}
/>
>
)}
}
value={figures}
label={plural(figures, 'Abbildung', 'Abbildungen')}
dim={figures === 0}
/>
}
value={notes}
label={plural(notes, 'Fußnote', 'Fußnoten')}
dim={notes === 0}
/>
} value={m.unitCount} label="Evidence Units" />
{m.groups.length > 0 && (
{m.hasBindingness ? (
<>
} />
} />
} />
>
) : (
m.groups.map((g) => } />)
)}
)}
)
}