import React, { useState, useCallback, useEffect } from 'react'; import { Save, AlertCircle, Crown, FolderOpen, Sparkles, Image as ImageIcon, Film, Volume2, Music } from 'lucide-react'; import { CustomVideoPlayer } from './ui/CustomVideoPlayer'; import { useMediaResolver } from '../hooks/useMediaResolver'; import { DesignMD, CompanyProfile, BrandAsset } from '../types'; import { BrandTabGeneral } from './brand/BrandTabGeneral'; import { BrandTabVisual } from './brand/BrandTabVisual'; import { BrandTabTypography } from './brand/BrandTabTypography'; import { BrandTabMedia } from './brand/BrandTabMedia'; import { BrandTabVoice } from './brand/BrandTabVoice'; import { BrandPreview } from './brand/BrandPreview'; import { Toast } from './ui/Toast'; import { UnifiedMediaItem } from './content-grid/UnifiedMediaLibrary'; interface BrandArchitectureProps { company: CompanyProfile; handleCompanyChange: (company: CompanyProfile) => void; designMD: DesignMD; handleDesignChange: (key: keyof DesignMD, value: string | number | string[] | boolean) => void; onContinue: () => void; onEditAsset?: (type: keyof DesignMD, url: string) => void; } const TABS = [ { id: 'general', label: 'Información', icon: '📋' }, { id: 'visual', label: 'Visual y Colores', icon: '🎨' }, { id: 'typography', label: 'Tipografía', icon: '🔤' }, { id: 'voice', label: 'Voz de Marca', icon: '🎙️' }, { id: 'media', label: 'Librería', icon: '📁' }, ] as const; type TabId = typeof TABS[number]['id']; export const BrandArchitecture: React.FC = ({ company, handleCompanyChange, designMD, handleDesignChange, onContinue, onEditAsset }) => { const [zoom, setZoom] = useState(1); const [aspectRatio, setAspectRatio] = useState<'16:9'|'1:1'|'9:16'>('9:16'); const [activeTab, setActiveTab] = useState('general'); const [showToast, setShowToast] = useState(false); const [validationErrors, setValidationErrors] = useState([]); const [selectedMediaItem, setSelectedMediaItem] = useState(null); const { getMediaUrl } = useMediaResolver(); const validate = useCallback((): string[] => { const errors: string[] = []; if (!company?.name || company.name.trim().length < 2) { errors.push('El nombre de la marca es requerido (mín. 2 caracteres)'); } if (!designMD.logoUrl || designMD.logoUrl.trim().length === 0) { errors.push('El logo de la marca es requerido'); } return errors; }, [company, designMD]); const handleSave = () => { const errors = validate(); if (errors.length > 0) { setValidationErrors(errors); setTimeout(() => setValidationErrors([]), 5000); return; } setValidationErrors([]); setShowToast(true); setTimeout(() => { onContinue(); }, 800); }; const handleOpenFolder = async () => { if (window.electronAPI && company?.id) { const wp = await window.electronAPI.fs.getWorkspacePath(); const folderPath = `${wp}/${company.id}`; await window.electronAPI.fs.openFolder(folderPath); } }; return (
{/* ═══ Sticky Header: Title + Brand Identity ═══ */}
{/* Left: Title + Description */}

Reglas de tu Marca (Design MD)

Establece el plano arquitectónico visual de la empresa. Todos los videos y renders futuros adoptarán estrictamente estos parámetros sin intervención de IA.

{/* Right: Brand Identity Card + Save */}
{/* Brand Identity Card */}
{/* Logo / Avatar */}
{designMD.logoUrl ? ( {company.name} ) : ( {company.name?.charAt(0)?.toUpperCase() || '?'} )}
{/* Name + Plan */}

{company.name || 'Sin nombre'}

{company.industry || 'Marca'}
{/* Brand color dot indicator */}
{/* Save Button */}
{/* ═══ Full-Width Tabbar ═══ */}
{TABS.map((tab, idx) => { const isActive = activeTab === tab.id; return ( ); })}
{/* ═══ Main Content: Form + Preview Split ═══ */}
{/* Form Column */}
{/* Validation Errors */} {validationErrors.length > 0 && (
{validationErrors.map((err, i) => (

{err}

))}
)} {/* Tab Content */} {activeTab === 'general' && ( )} {activeTab === 'visual' && ( )} {activeTab === 'typography' && ( )} {activeTab === 'voice' && ( )} {activeTab === 'media' && ( )}
{/* Preview Column */} {activeTab === 'media' ? (
{selectedMediaItem ? (
{selectedMediaItem.type === 'video' ? ( ) : selectedMediaItem.type === 'audio' ? (
) : ( {selectedMediaItem.id} )}

{selectedMediaItem.id}

{'date' in selectedMediaItem && selectedMediaItem.date ? new Date((selectedMediaItem as any).date).toLocaleString() : 'Asset Base'}

) : (

Selecciona un archivo para previsualizarlo.

)}
) : ( )}
{/* Success Toast */} {showToast && ( setShowToast(false)} /> )}
); };