import { Edit2, FolderClosed, FolderOpen, Lock, Palette, Plus, Trash2, Unlock, Users } from "lucide-react" import { useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" import { cn } from "@/lib/utils" import { useClipGroups } from "../../hooks/use-clip-groups" import { useTimeline } from "../../hooks/use-timeline" import type { ClipGroup, GroupColorKey } from "../../types/clip-groups" import { GroupColors } from "../../types/clip-groups" import type { TimelineClip } from "../../types/timeline" export function GroupManagerPanel() { const { groups, createGroup, renameGroup, setGroupColor, toggleCollapse, lockGroup, ungroupClips } = useClipGroups() const { uiState, project } = useTimeline() const [editingGroupId, setEditingGroupId] = useState(null) const [editingName, setEditingName] = useState("") const selectedClipCount = uiState.selectedClipIds.length const handleCreateGroup = () => { if (!project || selectedClipCount < 2) return // Получаем выбранные клипы const selectedClips: TimelineClip[] = [] project.globalTracks.forEach((track) => { track.clips.forEach((clip) => { if (uiState.selectedClipIds.includes(clip.id)) { selectedClips.push(clip) } }) }) project.sections.forEach((section) => { section.tracks.forEach((track) => { track.clips.forEach((clip) => { if (uiState.selectedClipIds.includes(clip.id)) { selectedClips.push(clip) } }) }) }) if (selectedClips.length >= 2) { createGroup(selectedClips) } } const handleStartRename = (group: ClipGroup) => { setEditingGroupId(group.id) setEditingName(group.name) } const handleFinishRename = (groupId: string) => { if (editingName.trim()) { renameGroup(groupId, editingName.trim()) } setEditingGroupId(null) setEditingName("") } const handleColorChange = (groupId: string, color: string) => { setGroupColor(groupId, color) } const colorOptions = Object.entries(GroupColors as Record) return (
{/* Header */}

Clip Groups

{selectedClipCount > 0 && ( )}
{/* Groups list */}
{groups.length === 0 ? (

No groups created yet

) : ( groups.map((group) => (
{/* Collapse toggle */} {/* Group name */}
{editingGroupId === group.id ? ( setEditingName(e.target.value)} onBlur={() => handleFinishRename(group.id)} onKeyDown={(e) => { if (e.key === "Enter") { handleFinishRename(group.id) } else if (e.key === "Escape") { setEditingGroupId(null) } }} className="h-6 text-xs" autoFocus /> ) : (
{group.name} ({group.clips.length} clips)
)}
{/* Actions */}
{/* Edit name */} {/* Color picker */}
{colorOptions.map(([key, color]) => (
{/* Lock toggle */} {/* Ungroup */}
)) )}
) }