import { Blend, Clapperboard, FlipHorizontal2, Music, Package, Palette, Scissors, Sparkles, Sticker, Subtitles, Type, Video, X, } from "lucide-react" import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { DraggableType, useDraggable } from "@/features/drag-drop" import { useResources } from "@/features/resources" import { TimelineResource } from "@/features/resources/types" /** * Компонент для отдельного ресурса с поддержкой drag */ function ResourceItem({ resource, onRemove }: { resource: TimelineResource; onRemove: (id: string) => void }) { const { t } = useTranslation() // Определяем тип для DragDropManager const getDraggableType = (resourceType: TimelineResource["type"]): DraggableType => { switch (resourceType) { case "media": return "media" case "music": return "music" case "effect": return "effect" case "filter": return "filter" case "transition": return "transition" case "template": return "template" case "styleTemplate": return "style-template" case "subtitle": return "subtitle-style" default: return "media" } } // Получаем данные для перетаскивания в зависимости от типа ресурса const getDragData = () => { if (resource.type === "media" || resource.type === "music") { return resource.file } if (resource.type === "effect") { return resource.effect } if (resource.type === "filter") { return resource.filter } if (resource.type === "transition") { return resource.transition } if (resource.type === "template") { return resource.template } if (resource.type === "styleTemplate") { return resource.template } if (resource.type === "subtitle") { return resource.style } return null } // Получаем URL для превью const getPreviewUrl = () => { const data = getDragData() if (!data) return "" if ("path" in data) return data.path if ("thumbnail" in data) return data.thumbnail return "" } // Используем DragDropManager для перетаскивания const dragProps = useDraggable(getDraggableType(resource.type), getDragData, () => ({ url: getPreviewUrl(), width: 120, height: 80, })) return (
{/* Иконка ресурса (слева) */}
{resource.type === "media" && } {resource.type === "music" && } {resource.type === "subtitle" && } {resource.type === "effect" && } {resource.type === "filter" && } {resource.type === "transition" && } {resource.type === "template" &&
{/* Название ресурса (справа) */}
{resource.type === "template" ? t(`templates.templateLabels.${resource.name}`, resource.name) : resource.type === "styleTemplate" ? t(`styleTemplates.${resource.name}`, resource.name) : resource.name}
{/* Кнопка удаления - показывается при наведении */}
) } /** * Компонент для отображения ресурсов таймлайна в левой панели */ export function ResourcesPanel() { const { t } = useTranslation() // Полностью отключаем логирование const { effectResources, filterResources, transitionResources, templateResources, styleTemplateResources, mediaResources, musicResources, subtitleResources, removeResource, } = useResources() // Полностью отключаем логирование // Категории ресурсов с их данными const categories = [ { id: "media", name: t("browser.tabs.media"), icon: , resources: mediaResources, }, { id: "music", name: t("browser.tabs.music"), icon: , resources: musicResources, }, { id: "subtitles", name: t("browser.tabs.subtitles"), icon: , resources: subtitleResources, }, { id: "effects", name: t("browser.tabs.effects"), icon: , resources: effectResources, }, { id: "filters", name: t("browser.tabs.filters"), icon: , resources: filterResources, }, { id: "transitions", name: t("browser.tabs.transitions"), icon: , resources: transitionResources, }, { id: "templates", name: t("browser.tabs.templates"), icon: