"use client"; import { useEffect, useRef, useState } from "react"; import { useTranslations } from "next-intl"; import { ArrowLeft, AudioLines, Captions, Check, ChevronDown, Combine, Crop, Download, History, Palette, Pause, Play, Redo2, Scan, Scissors, SkipBack, SkipForward, SlidersHorizontal, Type, Undo2, } from "lucide-react"; import { DEMO_CLIPS } from "@/lib/demo"; import { cn } from "@/lib/utils"; import { Reveal, SectionHeading } from "./reveal"; type Tab = "captions" | "framing" | "audio" | "effects"; const TABS: { id: Tab; icon: React.ComponentType<{ className?: string }> }[] = [ { id: "captions", icon: Captions }, { id: "framing", icon: Crop }, { id: "audio", icon: AudioLines }, { id: "effects", icon: Palette }, ]; // Illustrative word timings for the transcript panel (words heard in clip 1). const WORDS = [ { word: "really", start: 3.2, end: 3.5 }, { word: "work", start: 3.5, end: 3.8 }, { word: "and", start: 3.8, end: 3.9 }, { word: "reach", start: 3.9, end: 4.3 }, ]; const WAVEFORM = Array.from({ length: 90 }, (_, i) => 0.2 + 0.8 * Math.abs(Math.sin(i * 0.9) * Math.cos(i * 0.23))); function Slider({ label, value, onChange, min = 0, max = 200, suffix = "%", }: { label: string; value: number; onChange: (value: number) => void; min?: number; max?: number; suffix?: string; }) { return ( ); } function Segmented({ options, value, onChange }: { options: { id: T; label: string }[]; value: T; onChange: (value: T) => void; }) { return (
{options.map((option) => ( ))}
); } function StudioMock() { const t = useTranslations("editor"); const videoRef = useRef(null); const [active, setActive] = useState(0); const [tab, setTab] = useState("captions"); const [playing, setPlaying] = useState(false); const [time, setTime] = useState(0); const [duration, setDuration] = useState(DEMO_CLIPS[0].previewSeconds); const [safeArea, setSafeArea] = useState(true); const [style, setStyle] = useState<"clean" | "highlight" | "pop">("highlight"); const [aspect, setAspect] = useState<"vertical" | "square" | "original">("vertical"); const [fit, setFit] = useState<"fill" | "contain">("fill"); const [zoom, setZoom] = useState(100); const [volume, setVolume] = useState(100); const [muted, setMuted] = useState(true); const [effects, setEffects] = useState({ brightness: 100, contrast: 100, saturation: 100 }); const clip = DEMO_CLIPS[active]; // Play while the studio is on screen, like a live preview. useEffect(() => { const video = videoRef.current; if (!video) return; const observer = new IntersectionObserver(([entry]) => { if (entry.isIntersecting) video.play().then(() => setPlaying(true)).catch(() => setPlaying(false)); else video.pause(); }, { threshold: 0.4 }); observer.observe(video); return () => observer.disconnect(); }, [active]); useEffect(() => { if (videoRef.current) videoRef.current.muted = muted; }, [muted, active]); useEffect(() => { if (videoRef.current) videoRef.current.volume = Math.min(volume, 100) / 100; }, [volume, active]); const togglePlay = () => { const video = videoRef.current; if (!video) return; if (video.paused) video.play().then(() => setPlaying(true)).catch(() => setPlaying(false)); else { video.pause(); setPlaying(false); } }; const progress = duration ? time / duration : 0; const format = (seconds: number) => `0:${seconds.toFixed(2).padStart(5, "0")}`; const filter = `brightness(${effects.brightness}%) contrast(${effects.contrast}%) saturate(${effects.saturation}%)`; return (
{/* Top bar */}

{t("workspace.generation")} / {t("clipLabel", { order: active + 1 })}

{clip.hook}

{t("status.saved")} {t("workspace.export")}
{/* Clips */} {/* Preview + timeline */}

{t("preview.title")}

1× {format(time)} / {format(duration)}
{/* Timeline */}

{t("timeline.title")}{" "} {t("timeline.summaryOther", { count: 2, duration: clip.duration })}

{t("timeline.split")}
{Array.from({ length: 12 }, (_, i) => ( // eslint-disable-next-line @next/next/no-img-element ))}
{WAVEFORM.map((height, i) => ( ))}
{/* A cut between the two segments */}
{[ { label: t("timeline.segment", { n: 1 }), range: "0:00 – 0:32" }, { label: t("timeline.segment", { n: 2 }), range: "0:37 – 0:55" }, ].map((segment, i) => ( {segment.label} {segment.range} ))}
{/* Inspector */}
{TABS.map(({ id, icon: Icon }) => ( ))}
{tab === "captions" && ( <>

{t("captions.styleTitle")}

{(["clean", "highlight", "pop"] as const).map((id) => ( ))}

{t("captions.font")}

Montserrat

{t("captions.transcript")} {t("captions.editScript")}

{WORDS.map((word, i) => (
{word.word} {word.start.toFixed(1)} → {word.end.toFixed(1)}
))}
)} {tab === "framing" && ( <>

{t("framing.aspect")}

({ id, label: t(`framing.aspects.${id}`) }))} />

{t("framing.fit")}

{t("framing.center")} )} {tab === "audio" && ( <>

{t("audioPanel.description")}

)} {tab === "effects" && ( <>

{t("effects.description")}

{(["brightness", "contrast", "saturation"] as const).map((key) => ( setEffects((prev) => ({ ...prev, [key]: value }))} min={50} max={150} /> ))} )}
); } const POINTS = [ { key: "timeline", icon: Scissors }, { key: "transcript", icon: Type }, { key: "captions", icon: Captions }, { key: "framing", icon: Crop }, { key: "audio", icon: SlidersHorizontal }, { key: "combine", icon: Combine }, { key: "drafts", icon: History }, { key: "export", icon: Download }, ] as const; export function EditorSection() { const t = useTranslations("marketing.editor"); return (

{t("tryIt")}

{POINTS.map(({ key, icon: Icon }, i) => (

{t(`points.${key}.title`)}

{t(`points.${key}.description`)}

))}
); }