"use client"; import type { ComponentProps, ReactNode } from "react"; import { Button } from "@/components/ui/button"; import { Kbd, KbdGroup } from "@/components/ui/kbd"; import { Label } from "@/components/ui/label"; import { Slider } from "@/components/ui/slider"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; /** A studio card: white, softly rounded, floating on the stone canvas. */ export function Panel({ className, ...props }: ComponentProps<"section">) { return (
); } export function PanelHeader({ title, meta, children, className, }: { title: ReactNode; meta?: ReactNode; children?: ReactNode; className?: string; }) { return (

{title}

{meta && ( {meta} )}
{children &&
{children}
}
); } export function Section({ title, description, action, children, className, }: { title: ReactNode; description?: ReactNode; action?: ReactNode; children?: ReactNode; className?: string; }) { return (

{title}

{description && (

{description}

)}
{action}
{children}
); } export function Field({ label, htmlFor, children, className, }: { label: ReactNode; htmlFor?: string; children: ReactNode; className?: string; }) { return (
{children}
); } export function Range({ label, value, min, max, step = 1, unit = "", onChange, }: { label: string; value: number; min: number; max: number; step?: number; unit?: string; onChange: (value: number) => void; }) { return (
{label} {Number(value.toFixed(2))} {unit}
onChange(v[0])} />
); } /** Keyboard shortcut label; accepts one key or a sequence rendered as a group. */ export function Keys({ keys, className, }: { keys: string | string[]; className?: string; }) { const list = Array.isArray(keys) ? keys : [keys]; return ( {list.map((key) => ( {key} ))} ); } /** Icon button with a tooltip that doubles as shortcut documentation. */ export function ToolButton({ label, shortcut, children, ...props }: ComponentProps & { label: string; shortcut?: string | string[]; }) { return ( {label} {shortcut && } ); } type Translate = (key: string) => string; /** English strings produced outside these components, shown through `error.message` or editor status. */ const EDITOR_STATUS_KEYS: Record = { "Preparing preview…": "status.preparing", "All changes saved": "status.saved", "Unsaved changes": "status.unsaved", "Saving…": "status.saving", "Save failed · draft kept locally": "status.saveFailed", "Recovered local draft": "status.recovered", }; const EDITOR_ERROR_KEYS: Record = { "Could not save draft": "errors.saveDraft", "Preview preparation failed": "errors.previewFailed", "A newer draft exists on the server. Your local changes are retained. Download a draft backup, then reload the saved version to resolve the conflict.": "errors.conflict", "Could not load editor": "errors.load", "Preview is not ready": "errors.notReady", "Combine cancelled": "errors.combineCancelled", "The combine is still running in the export queue. Refresh your clips when it completes.": "errors.combineTimeout", "Source preparation is taking longer than expected. Reopen the editor to check its status.": "errors.prepareTimeout", "Could not prepare clip": "errors.prepareFailed", "Export failed": "errors.exportFailed", "Edit this long transcript one word at a time.": "errors.transcriptTooLong", "This browser cannot encode this video. Choose background export to render it on the server.": "errors.cannotEncode", "Could not load the source video.": "errors.cannotLoadSource", "Canvas is unavailable. Use background export.": "errors.canvasUnavailable", "This browser cannot decode the source. Use background export.": "errors.cannotDecode", "Audio encoding is unavailable. Use background export.": "errors.audioEncodeUnavailable", "Export produced no video.": "errors.noVideo", }; export function editorStatus(t: Translate, status: string) { const key = EDITOR_STATUS_KEYS[status]; return key ? t(key) : status; } export function editorMessage(t: Translate, message: string) { const key = EDITOR_ERROR_KEYS[message]; return key ? t(key) : message; }