'use client'; import * as React from 'react'; import { FileAudio, History, Info, ChevronLeft, ChevronRight, Upload, Download, X, Sparkles, Link2, FolderOpen, Trash2, } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/utils/cn'; import { formatDuration } from '@/lib/audio/decoder'; import type { Selection } from '@/types/selection'; import type { HistoryState } from '@/lib/history/history-manager'; import type { EffectChain, ChainEffect, EffectPreset } from '@/lib/audio/effects/chain'; import { EffectRack } from '@/components/effects/EffectRack'; import { PresetManager } from '@/components/effects/PresetManager'; export interface SidePanelProps { // File info fileName: string | null; audioBuffer: AudioBuffer | null; onFileSelect: (file: File) => void; onClear: () => void; // Selection info selection: Selection | null; // History info historyState: HistoryState; // Effect chain effectChain: EffectChain; effectPresets: EffectPreset[]; onToggleEffect: (effectId: string) => void; onRemoveEffect: (effectId: string) => void; onReorderEffects: (fromIndex: number, toIndex: number) => void; onSavePreset: (preset: EffectPreset) => void; onLoadPreset: (preset: EffectPreset) => void; onDeletePreset: (presetId: string) => void; onClearChain: () => void; // Effects handlers onNormalize: () => void; onFadeIn: () => void; onFadeOut: () => void; onReverse: () => void; onLowPassFilter: () => void; onHighPassFilter: () => void; onBandPassFilter: () => void; onCompressor: () => void; onLimiter: () => void; onGate: () => void; onDelay: () => void; onReverb: () => void; onChorus: () => void; onFlanger: () => void; onPhaser: () => void; onPitchShift: () => void; onTimeStretch: () => void; onDistortion: () => void; onBitcrusher: () => void; className?: string; } export function SidePanel({ fileName, audioBuffer, onFileSelect, onClear, selection, historyState, effectChain, effectPresets, onToggleEffect, onRemoveEffect, onReorderEffects, onSavePreset, onLoadPreset, onDeletePreset, onClearChain, onNormalize, onFadeIn, onFadeOut, onReverse, onLowPassFilter, onHighPassFilter, onBandPassFilter, onCompressor, onLimiter, onGate, onDelay, onReverb, onChorus, onFlanger, onPhaser, onPitchShift, onTimeStretch, onDistortion, onBitcrusher, className, }: SidePanelProps) { const [isCollapsed, setIsCollapsed] = React.useState(false); const [activeTab, setActiveTab] = React.useState<'file' | 'chain' | 'history' | 'info' | 'effects'>('file'); const [presetDialogOpen, setPresetDialogOpen] = React.useState(false); const fileInputRef = React.useRef(null); const handleFileClick = () => { fileInputRef.current?.click(); }; const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { onFileSelect(file); } }; if (isCollapsed) { return (
); } return (
{/* Header */}
{/* Content */}
{activeTab === 'file' && ( <>

Audio File

{audioBuffer ? (
{fileName || 'Unknown'}
Duration: {formatDuration(audioBuffer.duration)}
Channels: {audioBuffer.numberOfChannels}
Sample Rate: {audioBuffer.sampleRate} Hz
) : (
Or drag and drop an audio file onto the waveform area.
)}
)} {activeTab === 'chain' && (

Effect Chain

{effectChain.effects.length > 0 && ( )}
setPresetDialogOpen(false)} currentChain={effectChain} presets={effectPresets} onSavePreset={onSavePreset} onLoadPreset={onLoadPreset} onDeletePreset={onDeletePreset} onExportPreset={() => {}} onImportPreset={(preset) => onSavePreset(preset)} />
)} {activeTab === 'history' && (

Edit History

{historyState.historySize > 0 ? (
{historyState.historySize} action{historyState.historySize !== 1 ? 's' : ''}
{historyState.undoDescription && (
Next undo: {historyState.undoDescription}
)} {historyState.redoDescription && (
Next redo: {historyState.redoDescription}
)}
) : (
No history available. Edit operations will appear here.
)}
)} {activeTab === 'info' && (

Selection Info

{selection ? (
Selection Active
Duration: {formatDuration(selection.end - selection.start)}
Start: {formatDuration(selection.start)}
End: {formatDuration(selection.end)}
) : (
No selection. Drag on the waveform to select a region.
)}
)} {activeTab === 'effects' && (

Basic Effects

{audioBuffer ? (
) : (
Load an audio file to apply effects.
)}

Filters

{audioBuffer ? (
) : (
Load an audio file to apply filters.
)}

Dynamics Processing

{audioBuffer ? (
) : (
Load an audio file to apply dynamics processing.
)}

Time-Based Effects

{audioBuffer ? (
) : (
Load an audio file to apply time-based effects.
)}

Advanced Effects

{audioBuffer ? (
) : (
Load an audio file to apply advanced effects.
)}
)}
); }