/* Tab: Música de fondo — biblioteca de carpetas + canciones para el montaje de vídeos */ const MUSIC_MAX_BYTES = 30 * 1024 * 1024; function formatDuration(sec) { sec = Math.round(sec || 0); const m = Math.floor(sec / 60); const s = sec % 60; return `${m}:${String(s).padStart(2, "0")}`; } function NewMusicFolderModal({ onClose, onCreated }) { const [name, setName] = React.useState(""); const [loading, setLoading] = React.useState(false); const [error, setError] = React.useState(""); async function handleCreate(e) { e.preventDefault(); if (!name.trim()) { setError("El nombre es obligatorio"); return; } setLoading(true); setError(""); try { const r = await fetch("/api/music/folders", { method: "POST", credentials: "same-origin", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: name.trim() }), }); const d = await r.json(); if (r.ok && d.success) { onCreated(d.folder); onClose(); } else setError(d.detail || "Error al crear la carpeta"); } catch { setError("Error de conexión"); } finally { setLoading(false); } } return (