/** * Индикатор персон на Timeline клипе * Показывает маленькие аватары персон, обнаруженных в клипе */ import { User, Users } from "lucide-react" import { useState } from "react" import { Badge } from "@/components/ui/badge" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import type { PersonProfile } from "../../../person-identification/types/person" import type { TimelinePersonAppearance } from "../../hooks/use-timeline-persons" interface PersonIndicatorProps { persons: PersonProfile[] appearances?: TimelinePersonAppearance[] clipId: string compact?: boolean maxVisible?: number onClick?: (personId: string) => void } export function PersonIndicator({ persons, appearances = [], clipId, compact = false, maxVisible = 3, onClick, }: PersonIndicatorProps) { const [showTooltip, setShowTooltip] = useState(false) // Фильтруем персон, которые появляются в этом клипе const clipAppearances = appearances.filter((app) => app.clipId === clipId) const personsInClip = persons.filter((person) => clipAppearances.some((app) => app.personId === person.id)) if (personsInClip.length === 0) { return null } const visiblePersons = personsInClip.slice(0, maxVisible) const hiddenCount = Math.max(0, personsInClip.length - maxVisible) if (compact) { return ( { e.stopPropagation() if (personsInClip.length === 1) { onClick?.(personsInClip[0].id) } }} > {personsInClip.length === 1 ? ( ) : ( <> {personsInClip.length} )}
{personsInClip.map((person) => (
{person.name || "Безымянная персона"}
))}
) } return (
{visiblePersons.map((person, index) => { const appearance = clipAppearances.find((app) => app.personId === person.id) const confidence = appearance ? Math.round(appearance.confidence * 100) : 0 return (
{ e.stopPropagation() onClick?.(person.id) }} style={{ zIndex: visiblePersons.length - index }} >
{person.thumbnails && person.thumbnails.length > 0 ? ( {person.name ) : ( )}
{/* Индикатор уверенности */} {confidence > 0 && (
= 80 ? "bg-green-500" : confidence >= 60 ? "bg-yellow-500" : "bg-red-500"} `} /> )}
{person.name || "Безымянная персона"}
{confidence > 0 &&
Уверенность: {confidence}%
} {appearance && (
{Math.round(appearance.startTime)}с - {Math.round(appearance.endTime)}с
)}
) })} {hiddenCount > 0 && ( +{hiddenCount}
{personsInClip.slice(maxVisible).map((person) => (
{person.name || "Безымянная персона"}
))}
)}
) }