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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useRef } from 'react'
|
| 2 |
+
import { motion, AnimatePresence } from 'framer-motion'
|
| 3 |
+
import { FaRobot, FaMicrophone, FaCode, FaImage, FaVideo, FaLanguage, FaCog, FaPaperPlane, FaStop, FaPlay, FaPause, FaDownload, FaUpload, FaTerminal, FaBrain, FaShieldAlt, FaGlobe, FaDatabase, FaCloud, FaLock, FaUnlock, FaCheckCircle, FaExclamationTriangle, FaInfoCircle } from 'react-icons/fa'
|
| 4 |
+
import ChatInterface from '../components/ChatInterface'
|
| 5 |
+
import CodeEditor from '../components/CodeEditor'
|
| 6 |
+
import MediaStudio from '../components/MediaStudio'
|
| 7 |
+
import VoiceConsole from '../components/VoiceConsole'
|
| 8 |
+
import SettingsPanel from '../components/SettingsPanel'
|
| 9 |
+
import AgentDashboard from '../components/AgentDashboard'
|
| 10 |
+
import FileExplorer from '../components/FileExplorer'
|
| 11 |
+
|
| 12 |
+
export default function Home() {
|
| 13 |
+
const [activeTab, setActiveTab] = useState('chat')
|
| 14 |
+
const [isListening, setIsListening] = useState(false)
|
| 15 |
+
const [language, setLanguage] = useState('fa')
|
| 16 |
+
const [theme, setTheme] = useState('dark')
|
| 17 |
+
const [isProcessing, setIsProcessing] = useState(false)
|
| 18 |
+
const [notifications, setNotifications] = useState([])
|
| 19 |
+
const [systemStatus, setSystemStatus] = useState({
|
| 20 |
+
aiModel: 'local',
|
| 21 |
+
internetAccess: false,
|
| 22 |
+
privacyMode: true,
|
| 23 |
+
gpuEnabled: false
|
| 24 |
+
})
|
| 25 |
+
|
| 26 |
+
const tabs = [
|
| 27 |
+
{ id: 'chat', name: language === 'fa' ? 'چت هوشمند' : 'Smart Chat', icon: FaRobot },
|
| 28 |
+
{ id: 'code', name: language === 'fa' ? 'کدنویسی' : 'Coding', icon: FaCode },
|
| 29 |
+
{ id: 'media', name: language === 'fa' ? 'استودیو رسانه' : 'Media Studio', icon: FaImage },
|
| 30 |
+
{ id: 'voice', name: language === 'fa' ? 'کنسول صوتی' : 'Voice Console', icon: FaMicrophone },
|
| 31 |
+
{ id: 'agent', name: language === 'fa' ? 'عامل خودکار' : 'Autonomous Agent', icon: FaBrain },
|
| 32 |
+
{ id: 'files', name: language === 'fa' ? 'مدیریت فایل' : 'File Manager', icon: FaDatabase },
|
| 33 |
+
{ id: 'settings', name: language === 'fa' ? 'تنظیمات' : 'Settings', icon: FaCog },
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
const addNotification = (message, type = 'info') => {
|
| 37 |
+
const id = Date.now()
|
| 38 |
+
setNotifications(prev => [...prev, { id, message, type }])
|
| 39 |
+
setTimeout(() => {
|
| 40 |
+
setNotifications(prev => prev.filter(n => n.id !== id))
|
| 41 |
+
}, 5000)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
useEffect(() => {
|
| 45 |
+
// Initialize system
|
| 46 |
+
addNotification(language === 'fa' ? 'به GhadirSync-AI خوش آمدید!' : 'Welcome to GhadirSync-AI!', 'success')
|
| 47 |
+
}, [language])
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<div className={`min-h-screen ${theme === 'dark' ? 'bg-gray-900 text-white' : 'bg-gray-50 text-gray-900'}`}>
|
| 51 |
+
{/* Header */}
|
| 52 |
+
<header className="border-b border-gray-700 bg-gradient-to-r from-primary-600 to-secondary-600">
|
| 53 |
+
<div className="container mx-auto px-4 py-4">
|
| 54 |
+
<div className="flex items-center justify-between">
|
| 55 |
+
<div className="flex items-center space-x-reverse space-x-4">
|
| 56 |
+
<motion.div
|
| 57 |
+
animate={{ rotate: isProcessing ? 360 : 0 }}
|
| 58 |
+
transition={{ duration: 2, repeat: isProcessing ? Infinity : 0, ease: "linear" }}
|
| 59 |
+
>
|
| 60 |
+
<FaRobot className="w-8 h-8 text-white" />
|
| 61 |
+
</motion.div>
|
| 62 |
+
<div>
|
| 63 |
+
<h1 className="text-2xl font-bold">GhadirSync-AI</h1>
|
| 64 |
+
<p className="text-xs opacity-90">
|
| 65 |
+
{language === 'fa' ? 'دستیار هوشمند چندوجهی' : 'Multimodal AI Assistant'}
|
| 66 |
+
</p>
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
<div className="flex items-center space-x-reverse space-x-4">
|
| 71 |
+
{/* Status Indicators */}
|
| 72 |
+
<div className="flex items-center space-x-reverse space-x-2">
|
| 73 |
+
<div className={`w-2 h-2 rounded-full ${systemStatus.aiModel === 'local' ? 'bg-green-400' : 'bg-yellow-400'}`} />
|
| 74 |
+
<span className="text-xs">
|
| 75 |
+
{language === 'fa' ? 'مدل محلی' : 'Local Model'}
|
| 76 |
+
</span>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<div className="flex items-center space-x-reverse space-x-2">
|
| 80 |
+
<FaGlobe className={`w-4 h-4 ${systemStatus.internetAccess ? 'text-green-400' : 'text-gray-400'}`} />
|
| 81 |
+
<span className="text-xs">
|
| 82 |
+
{systemStatus.internetAccess ? (language === 'fa' ? 'آنلاین' : 'Online') : (language === 'fa' ? 'آفلاین' : 'Offline')}
|
| 83 |
+
</span>
|
| 84 |
+
</div>
|
| 85 |
+
|
| 86 |
+
<div className="flex items-center space-x-reverse space-x-2">
|
| 87 |
+
<FaShieldAlt className={`w-4 h-4 ${systemStatus.privacyMode ? 'text-green-400' : 'text-gray-400'}`} />
|
| 88 |
+
<span className="text-xs">
|
| 89 |
+
{language === 'fa' ? 'حریم خصوصی' : 'Privacy'}
|
| 90 |
+
</span>
|
| 91 |
+
</div>
|
| 92 |
+
|
| 93 |
+
{/* Language Toggle */}
|
| 94 |
+
<button
|
| 95 |
+
onClick={() => setLanguage(language === 'fa' ? 'en' : 'fa')}
|
| 96 |
+
className="flex items-center space-x-reverse space-x-2 px-3 py-1 bg-white bg-opacity-20 rounded-lg hover:bg-opacity-30 transition-all"
|
| 97 |
+
>
|
| 98 |
+
<FaLanguage className="w-4 h-4" />
|
| 99 |
+
<span className="text-sm font-medium">
|
| 100 |
+
{language === 'fa' ? 'فا' : 'EN'}
|
| 101 |
+
</span>
|
| 102 |
+
</button>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
</header>
|
| 107 |
+
|
| 108 |
+
{/* Navigation Tabs */}
|
| 109 |
+
<div className="border-b border-gray-700 bg-gray-800">
|
| 110 |
+
<div className="container mx-auto px-4">
|
| 111 |
+
<div className="flex space-x-reverse space-x-1 overflow-x-auto">
|
| 112 |
+
{tabs.map((tab) => {
|
| 113 |
+
const Icon = tab.icon
|
| 114 |
+
return (
|
| 115 |
+
<button
|
| 116 |
+
key={tab.id}
|
| 117 |
+
onClick={() => setActiveTab(tab.id)}
|
| 118 |
+
className={`flex items-center space-x-reverse space-x-2 px-4 py-3 border-b-2 transition-all whitespace-nowrap ${
|
| 119 |
+
activeTab === tab.id
|
| 120 |
+
? 'border-primary-500 text-primary-400 bg-gray-700'
|
| 121 |
+
: 'border-transparent text-gray-400 hover:text-white hover:bg-gray-700'
|
| 122 |
+
}`}
|
| 123 |
+
>
|
| 124 |
+
<Icon className="w-4 h-4" />
|
| 125 |
+
<span className="text-sm font-medium">{tab.name}</span>
|
| 126 |
+
</button>
|
| 127 |
+
)
|
| 128 |
+
})}
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
{/* Main Content */}
|
| 134 |
+
<main className="container mx-auto px-4 py-6">
|
| 135 |
+
<AnimatePresence mode="wait">
|
| 136 |
+
<motion.div
|
| 137 |
+
key={activeTab}
|
| 138 |
+
initial={{ opacity: 0, y: 20 }}
|
| 139 |
+
animate={{ opacity: 1, y: 0 }}
|
| 140 |
+
exit={{ opacity: 0, y: -20 }}
|
| 141 |
+
transition={{ duration: 0.3 }}
|
| 142 |
+
>
|
| 143 |
+
{activeTab === 'chat' && <ChatInterface language={language} theme={theme} />}
|
| 144 |
+
{activeTab === 'code' && <CodeEditor language={language} theme={theme} />}
|
| 145 |
+
{activeTab === 'media' && <MediaStudio language={language} theme={theme} />}
|
| 146 |
+
{activeTab === 'voice' && <VoiceConsole language={language} theme={theme} />}
|
| 147 |
+
{activeTab === 'agent' && <AgentDashboard language={language} theme={theme} />}
|
| 148 |
+
{activeTab === 'files' && <FileExplorer language={language} theme={theme} />}
|
| 149 |
+
{activeTab === 'settings' && <SettingsPanel language={language} theme={theme} />}
|
| 150 |
+
</motion.div>
|
| 151 |
+
</AnimatePresence>
|
| 152 |
+
</main>
|
| 153 |
+
|
| 154 |
+
{/* Floating Action Button */}
|
| 155 |
+
<motion.button
|
| 156 |
+
whileHover={{ scale: 1.1 }}
|
| 157 |
+
whileTap={{ scale: 0.95 }}
|
| 158 |
+
onClick={() => setIsListening(!isListening)}
|
| 159 |
+
className={`fixed bottom-6 left-6 w-14 h-14 rounded-full shadow-lg flex items-center justify-center transition-all ${
|
| 160 |
+
isListening
|
| 161 |
+
? 'bg-red-500 hover:bg-red-600 animate-pulse'
|
| 162 |
+
: 'bg-primary-500 hover:bg-primary-600'
|
| 163 |
+
}`}
|
| 164 |
+
>
|
| 165 |
+
{isListening ? <FaStop className="w-6 h-6 text-white" /> : <FaMicrophone className="w-6 h-6 text-white" />}
|
| 166 |
+
</motion.button>
|
| 167 |
+
|
| 168 |
+
{/* Notifications */}
|
| 169 |
+
<div className="fixed top-20 left-4 z-50 space-y-2">
|
| 170 |
+
{notifications.map((notification) => (
|
| 171 |
+
<motion.div
|
| 172 |
+
key={notification.id}
|
| 173 |
+
initial={{ opacity: 0, x: 100 }}
|
| 174 |
+
animate={{ opacity: 1, x: 0 }}
|
| 175 |
+
exit={{ opacity: 0, x: 100 }}
|
| 176 |
+
className={`flex items-center space-x-reverse space-x-2 px-4 py-3 rounded-lg shadow-lg ${
|
| 177 |
+
notification.type === 'success' ? 'bg-green-500' :
|
| 178 |
+
notification.type === 'error' ? 'bg-red-500' :
|
| 179 |
+
notification.type === 'warning' ? 'bg-yellow-500' :
|
| 180 |
+
'bg-blue-500'
|
| 181 |
+
} text-white`}
|
| 182 |
+
>
|
| 183 |
+
{notification.type === 'success' && <FaCheckCircle className="w-5 h-5" />}
|
| 184 |
+
{notification.type === 'error' && <FaExclamationTriangle className="w-5 h-5" />}
|
| 185 |
+
{notification.type === 'warning' && <FaExclamationTriangle className="w-5 h-5" />}
|
| 186 |
+
{notification.type === 'info' && <FaInfoCircle className="w-5 h-5" />}
|
| 187 |
+
<span className="text-sm font-medium">{notification.message}</span>
|
| 188 |
+
</motion.div>
|
| 189 |
+
))}
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
{/* Footer */}
|
| 193 |
+
<footer className="mt-auto border-t border-gray-700 bg-gray-800 py-4">
|
| 194 |
+
<div className="container mx-auto px-4">
|
| 195 |
+
<div className="flex items-center justify-between">
|
| 196 |
+
<p className="text-sm text-gray-400">
|
| 197 |
+
{language === 'fa' ? 'ساخته شده با قدرت هوش مصنوعی' : 'Powered by AI'}
|
| 198 |
+
</p>
|
| 199 |
+
<a
|
| 200 |
+
href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 201 |
+
target="_blank"
|
| 202 |
+
rel="noopener noreferrer"
|
| 203 |
+
className="text-sm text-primary-400 hover:text-primary-300 transition-colors"
|
| 204 |
+
>
|
| 205 |
+
Built with anycoder
|
| 206 |
+
</a>
|
| 207 |
+
</div>
|
| 208 |
+
</div>
|
| 209 |
+
</footer>
|
| 210 |
+
</div>
|
| 211 |
+
)
|
| 212 |
+
}
|