import { useState } from 'react';
import { History, ChevronLeft, ChevronRight, SkipBack, SkipForward } from 'lucide-react';
import type { NegotiationMessage } from '@/types';
import { cn, roleBgColor, roleLabel } from '@/lib/utils';
import CharacterAvatar from '@/components/CharacterAvatar';
interface ReplayViewerProps {
messages: NegotiationMessage[];
className?: string;
}
export default function ReplayViewer({ messages, className }: ReplayViewerProps) {
const [currentIndex, setCurrentIndex] = useState(0);
if (messages.length === 0) {
return (
Replay
No messages to replay
);
}
const totalRounds = Math.max(...messages.map((m) => m.round));
const currentRound = messages[currentIndex]?.round ?? 1;
return (
Replay
Round {currentRound} / {totalRounds}
} onClick={() => setCurrentIndex(0)} disabled={currentIndex === 0} />
} onClick={() => setCurrentIndex(Math.max(0, currentIndex - 1))} disabled={currentIndex === 0} />
{currentIndex + 1} / {messages.length}
} onClick={() => setCurrentIndex(Math.min(messages.length - 1, currentIndex + 1))} disabled={currentIndex === messages.length - 1} />
} onClick={() => setCurrentIndex(messages.length - 1)} disabled={currentIndex === messages.length - 1} />
{messages[currentIndex] && (
{roleLabel(messages[currentIndex].role)} ยท Round {messages[currentIndex].round}
{messages[currentIndex].message}
)}
);
}
function ScrubBtn({ icon, onClick, disabled }: { icon: React.ReactNode; onClick: () => void; disabled: boolean }) {
return (
);
}