import {
CheckCircle,
ClosedCaptioning,
Eye,
EyeSlash,
ListBullets,
PersonSimpleRun,
Trash,
Waveform,
} from "@phosphor-icons/react";
import { formatTime, getSegmentStartTime } from "../lib/timeline.js";
import { HistoryPanel, MyVoicesPanel, VoiceSynthesisPanel } from "./panels.jsx";
function CaptionContextPanel({
t,
captionSegments,
selectedCaptionSegment,
selectedSegmentId,
setSelectedSegmentId,
currentSegmentIndex,
captionTargetDuration,
updateCaptionSegmentText,
toggleCaptionSegmentHidden,
deleteCaptionSegment,
seekTo,
sourceAudioBlob,
generateCaptionsFromSourceAudio,
isGeneratingCaptions,
automaticCaptionProgress,
}) {
const selectedIndex = Math.max(
0,
captionSegments.findIndex((segment) => segment.id === selectedCaptionSegment?.id),
);
const selectedStart = captionSegments.length
? getSegmentStartTime(captionSegments, selectedIndex, captionTargetDuration)
: 0;
return (
{selectedCaptionSegment ? (
) : (
{t("noCaptionSegments")}
{t("captionEmptyHint", "选择时间线字幕片段后,这里会同步编辑。")}
)}
{!captionSegments.length ? (
) : null}
{t("captionList", "字幕列表")}
{captionSegments.length ? (
captionSegments.map((segment, index) => (
))
) : (
{t("noCaptionSegments")}
)}
);
}
function AvatarContextPanel({ t, hasVisual, visualType, audioBlob, audioDuration, captionSegments, selectedVoice }) {
const hasPortrait = hasVisual && visualType === "image";
return (
{t("avatarKicker")}{t("avatarLipSyncTitle")}{t("avatarLipSyncDescription")}
{t("avatarPortrait")}{hasPortrait ? t("avatarCurrentPortrait") : t("avatarNeedsPortrait")}
{t("avatarAudio")}{audioBlob ? `${selectedVoice?.name ?? "AI"} · ${audioDuration.toFixed(1)}s` : t("avatarNeedsAudio")}
{t("avatarLipSyncSource")}{captionSegments.length ? `${captionSegments.length} ${t("captionSegmentsUnit")} · ${t("avatarCaptionSync")}` : t("avatarNeedsCaptions")}
{t("avatarSyncMode")}{t("avatarSyncModeCaption")}
{t("avatarGenerationNote")}
{t("avatarServiceNeeded")}{t("avatarServiceHint")}
);
}
export function VoicePanel({
t,
activeTool,
status,
statusText,
voiceTab,
setVoiceTab,
script,
updateScript,
selectedVoiceId,
setSelectedVoiceId,
selectedVoice,
filteredVoices,
voiceFilter,
setVoiceFilter,
showVoiceFilter,
setShowVoiceFilter,
speed,
setSpeed,
volume,
setVolume,
progressPercent,
audioBlob,
generateVoiceover,
downloadBlob,
favoriteVoiceIds,
setFavoriteVoiceIds,
recordedVoices,
recordingState,
recordingElapsed,
startVoiceRecording,
stopVoiceRecording,
useRecordedVoice,
historyItems,
useHistoryItem,
setHistoryItems,
notify,
audioUrl,
audioRef,
sourceAudioRef,
musicRef,
sourceAudioUrl,
musicUrl,
captionSegments,
selectedCaptionSegment,
selectedSegmentId,
setSelectedSegmentId,
currentSegmentIndex,
captionTargetDuration,
updateCaptionSegmentText,
toggleCaptionSegmentHidden,
deleteCaptionSegment,
seekTo,
sourceAudioBlob,
generateCaptionsFromSourceAudio,
isGeneratingCaptions,
automaticCaptionProgress,
avatarPanelOpen,
hasVisual,
visualType,
audioDuration,
}) {
const isCaptionContext = activeTool === "caption";
const isAvatarContext = activeTool === "smart" && avatarPanelOpen;
const title = isAvatarContext ? t("avatarTitle") : isCaptionContext ? t("caption") : t("aiVoice");
const panelStatusText = isCaptionContext
? captionSegments.length
? `${captionSegments.length} ${t("captionSegmentsUnit", "条字幕")}`
: t("noCaptionSegments")
: isAvatarContext
? t("avatarServiceNeeded")
: statusText === "模型待命"
? t("modelReady")
: statusText;
return (
);
}