'use client'; import * as React from 'react'; import { Upload, Music } from 'lucide-react'; import { cn } from '@/lib/utils/cn'; import { isSupportedAudioFormat } from '@/lib/audio/decoder'; export interface FileUploadProps { onFileSelect: (file: File) => void; className?: string; } export function FileUpload({ onFileSelect, className }: FileUploadProps) { const [isDragging, setIsDragging] = React.useState(false); const fileInputRef = React.useRef(null); const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); setIsDragging(true); }; const handleDragLeave = (e: React.DragEvent) => { e.preventDefault(); setIsDragging(false); }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); setIsDragging(false); const files = Array.from(e.dataTransfer.files); const audioFile = files.find(isSupportedAudioFormat); if (audioFile) { onFileSelect(audioFile); } }; const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file && isSupportedAudioFormat(file)) { onFileSelect(file); } }; const handleClick = () => { fileInputRef.current?.click(); }; return (
{isDragging ? ( ) : ( )}

{isDragging ? 'Drop your audio file here' : 'Upload Audio File'}

Click to browse or drag and drop

Supported formats: WAV, MP3, OGG, FLAC, AAC, M4A, AIFF

); }