'use client'; import * as React from 'react'; import { Plus, ChevronDown, ChevronRight } from 'lucide-react'; import type { Track as TrackType } from '@/types/track'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/utils/cn'; import { EffectDevice } from '@/components/effects/EffectDevice'; import { EffectBrowser } from '@/components/effects/EffectBrowser'; import type { EffectType } from '@/lib/audio/effects/chain'; export interface TrackExtensionsProps { track: TrackType; onUpdateTrack: (trackId: string, updates: Partial) => void; onToggleEffect?: (effectId: string) => void; onRemoveEffect?: (effectId: string) => void; onUpdateEffect?: (effectId: string, parameters: any) => void; onAddEffect?: (effectType: EffectType) => void; } export function TrackExtensions({ track, onUpdateTrack, onToggleEffect, onRemoveEffect, onUpdateEffect, onAddEffect, }: TrackExtensionsProps) { const [effectBrowserOpen, setEffectBrowserOpen] = React.useState(false); // Don't render if track is collapsed if (track.collapsed) { return null; } return ( <> {/* Effects Section (Collapsible, Full Width) */}
{/* Effects Header - clickable to toggle */}
{ onUpdateTrack(track.id, { showEffects: !track.showEffects, }); }} > {track.showEffects ? ( ) : ( )} {/* Show mini effect chain when collapsed */} {!track.showEffects && track.effectChain.effects.length > 0 ? (
{track.effectChain.effects.map((effect) => (
{effect.name}
))}
) : ( Devices ({track.effectChain.effects.length}) )}
{/* Horizontal scrolling device rack - expanded state */} {track.showEffects && (
{track.effectChain.effects.length === 0 ? (
No devices. Click + to add an effect.
) : ( track.effectChain.effects.map((effect) => ( onToggleEffect?.(effect.id)} onRemove={() => onRemoveEffect?.(effect.id)} onUpdateParameters={(params) => onUpdateEffect?.(effect.id, params)} /> )) )}
)}
{/* Effect Browser Dialog */} setEffectBrowserOpen(false)} onSelectEffect={(effectType) => { if (onAddEffect) { onAddEffect(effectType); } }} /> ); }