import React, { useMemo, useState, useEffect } from 'react'; /* Fix: react-router-dom exports may be flaky in this environment, using standard v6 imports */ import { useNavigate } from 'react-router-dom'; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'; import { ArrowUpRight, ArrowDownRight, Wallet, Zap, Activity, Globe, ShieldCheck, ChevronRight, Terminal, ShieldAlert, Building2, RefreshCw, Sparkles, TrendingUp, Shield, Loader2 } from 'lucide-react'; /* Fix: removed .ts extensions from imports */ import { getSystemIntelligenceFeed, getPortfolioSuggestions } from '../services/geminiService'; import { apiClient } from '../services/api'; import { cryptoService } from '../services/cryptoService'; import { InternalAccount, AIInsight } from '../types/index'; import { CardSkeleton, Skeleton } from '../components/Skeleton'; const MOCK_BALANCE_HISTORY = { '24H': [ { time: '00:00', balance: 1245000 }, { time: '04:00', balance: 1247000 }, { time: '08:00', balance: 1246000 }, { time: '12:00', balance: 1248000 }, { time: '16:00', balance: 1249103 }, { time: '20:00', balance: 1251200 }, ], '7D': [ { time: 'Mon', balance: 1100000 }, { time: 'Tue', balance: 1150000 }, { time: 'Wed', balance: 1240000 }, { time: 'Thu', balance: 1220000 }, { time: 'Fri', balance: 1250000 }, { time: 'Sat', balance: 1260000 }, { time: 'Sun', balance: 1251200 }, ] }; const StatCard = ({ label, value, trend, icon: Icon, color, subValue, onClick, loading }: any) => { if (loading) return ; return (
= 0 ? 'bg-emerald-500/10 text-emerald-500' : 'bg-rose-500/10 text-rose-500'} text-[10px] font-black uppercase tracking-widest`}> {trend >= 0 ? : } {Math.abs(trend)}%

{label}

{value}

{subValue &&

{subValue}

}
); }; const RecommendationCard = ({ suggestion, loading }: any) => { if (loading) return ; const icons = { ALPHA: , RISK: , LIQUIDITY: }; const borderColors = { ALPHA: 'hover:border-blue-500/40', RISK: 'hover:border-rose-500/40', LIQUIDITY: 'hover:border-emerald-500/40' }; return (
{icons[suggestion.type as keyof typeof icons]}
{suggestion.type}

{suggestion.title}

"{suggestion.description}"

); }; const Overview: React.FC = () => { const navigate = useNavigate(); const [activeRange, setActiveRange] = useState('24H'); const [intelFeed, setIntelFeed] = useState([]); const [bankingAccounts, setBankingAccounts] = useState([]); const [suggestions, setSuggestions] = useState([]); const [isLoading, setIsLoading] = useState(true); const [loadingSuggestions, setLoadingSuggestions] = useState(true); const [error, setError] = useState(null); const loadData = async () => { setIsLoading(true); setError(null); try { const [accounts, intel, globalMarket] = await Promise.all([ apiClient.getRegistryNodes(), getSystemIntelligenceFeed(), cryptoService.getGlobal() ]); setBankingAccounts(accounts); setIntelFeed(intel); // Trigger proactive suggestions based on gathered context refreshSuggestions(accounts, globalMarket); } catch (e: any) { console.error(e); setError("Synchronous parity check failed. Using fallback node."); setBankingAccounts([{ id: 'fallback_01', productName: 'Emergency Parity Node', displayAccountNumber: '•••• 0000', currency: 'USD', status: 'ACTIVE', currentBalance: 0, availableBalance: 0, institutionName: 'Local Ledger', connectionId: 'LOC-001' }]); } finally { setIsLoading(false); } }; const refreshSuggestions = async (accounts: InternalAccount[], globalMarket: any) => { setLoadingSuggestions(true); try { const context = { totalLiquidity: accounts.reduce((s, a) => s + a.availableBalance, 0), activeNodes: accounts.length, globalMarketCap: globalMarket?.total_market_cap?.usd }; const strategicRecs = await getPortfolioSuggestions(context); setSuggestions(strategicRecs); } catch (err) { console.error("Neural strategist link failure."); } finally { setLoadingSuggestions(false); } }; useEffect(() => { loadData(); }, []); const totalLiquidity = useMemo(() => { return bankingAccounts.reduce((sum, acc) => sum + acc.availableBalance, 0); }, [bankingAccounts]); return (
{error && (
{error}
)}
navigate('/registry')} />
{/* Neural Strategy Center Section */}

Neural Strategy Center

Actionable alpha derived from treasury mesh telemetry

{loadingSuggestions ? ( Array.from({ length: 3 }).map((_, i) => ) ) : ( suggestions.map((s, idx) => ( )) )}

Aggregate Cash Curve

Live Node Trace

{(Object.keys(MOCK_BALANCE_HISTORY) as Array).map(t => ( ))}
{isLoading ? : ( `$${v/1000}k`} tick={{ fontWeight: 800 }} /> )}

Registry Nodes

{isLoading ? ( <> ) : ( bankingAccounts.map(acc => (
Active Node

{acc.productName}

{acc.displayAccountNumber}

Liquidity

${acc.availableBalance.toLocaleString()}

)) )}

Quantum Intel

Neural Feedback Stream

{isLoading ? ( Array.from({ length: 4 }).map((_, i) => ) ) : ( intelFeed.map((intel, idx) => (
{intel.severity === 'CRITICAL' ? : }

{intel.title}

{intel.description}

)) )}
); }; export default Overview;