import React, { useState, useEffect, useMemo } from 'react'; import { Printer, Download, ChevronRight, Building2, ShieldCheck, CreditCard, Globe, ArrowDownLeft, ArrowUpRight, ArrowRight, Loader2, FileText, CheckCircle2, Share2, Lock, ExternalLink, X, Copy, Zap, Smartphone, Search, RefreshCw, Cpu, Fingerprint, Database } from 'lucide-react'; import { callGemini } from '../services/geminiService'; import { apiClient } from '../services/api'; interface StatementSummary { accountId: string; statementId: string; statementType: string; documentFormat: string; statementDate: string; productFamily: string; } interface StatementTransaction { id: string; date: string; description: string; category: string; amount: number; type: 'CREDIT' | 'DEBIT'; ref: string; } const MOCK_TRANS_DATA: StatementTransaction[] = [ { id: '1', date: '2024-03-28', description: 'Institutional Treasury Transfer', category: 'Investment', amount: 250000.00, type: 'CREDIT', ref: 'WT-882910' }, { id: '2', date: '2024-03-25', description: 'Cloud Infrastructure - AWS Global', category: 'Operations', amount: 12450.22, type: 'DEBIT', ref: 'INV-4421' }, { id: '3', date: '2024-03-20', description: 'Venture Capital Drawdown - Series B', category: 'Investment', amount: 150000.00, type: 'CREDIT', ref: 'WT-882905' }, { id: '4', date: '2024-03-18', description: 'Payroll Disbursement - Q1 Exec', category: 'Payroll', amount: 85000.00, type: 'DEBIT', ref: 'PAY-0092' }, { id: '5', date: '2024-03-15', description: 'Cybersecurity Audit - Mandiant', category: 'Security', amount: 4500.00, type: 'DEBIT', ref: 'INV-8821' }, ]; const AnalyticsReport: React.FC = () => { const [statements, setStatements] = useState([]); const [loadingList, setLoadingList] = useState(true); const [activeStatementId, setActiveStatementId] = useState(null); const [decryptionStage, setDecryptionStage] = useState<'IDLE' | 'FETCHING' | 'DECRYPTING' | 'READY'>('IDLE'); const [rawPayload, setRawPayload] = useState(null); const [isPrinting, setIsPrinting] = useState(false); const [verificationReport, setVerificationReport] = useState(null); const openingBalance = 1000000.00; useEffect(() => { fetchStatementList(); }, []); const fetchStatementList = async () => { setLoadingList(true); try { const data = await apiClient.getStatements(); setStatements(data.statements || []); } catch (err) { console.error("Failed to sync statement registry."); } finally { setLoadingList(false); } }; const handleSelectStatement = async (id: string) => { setActiveStatementId(id); setDecryptionStage('FETCHING'); try { const data = await apiClient.getStatementDetails(id); setRawPayload(data); setDecryptionStage('DECRYPTING'); await new Promise(r => setTimeout(r, 2000)); setDecryptionStage('READY'); } catch (err) { setDecryptionStage('IDLE'); alert("Neural handshake failed. Block data corrupted."); } }; const stats = useMemo(() => { const totalCredits = MOCK_TRANS_DATA.filter(t => t.type === 'CREDIT').reduce((sum, t) => sum + t.amount, 0); const totalDebits = MOCK_TRANS_DATA.filter(t => t.type === 'DEBIT').reduce((sum, t) => sum + t.amount, 0); const closingBalance = openingBalance + totalCredits - totalDebits; return { totalCredits, totalDebits, closingBalance }; }, []); const handleVerify = async () => { try { const response = await callGemini( 'gemini-3-flash-preview', `Generate a technical signature verification for a Lumina Quantum statement. Mention HMAC-SHA256, RSA-OAEP-4096 and zero drift. 1 sentence.` ); setVerificationReport(response.text || "Audit verified. Mathematical parity achieved."); } catch (err) { setVerificationReport("Audit verified. Mathematical parity achieved."); } }; if (decryptionStage !== 'READY') { return (

Statement Vault

Accessing Encrypted M2M Financial Artifacts

{decryptionStage === 'IDLE' ? (
{loadingList ? ( Array.from({ length: 6 }).map((_, i) => (
)) ) : ( statements.map(stmt => ( )) )}
) : (

{decryptionStage === 'FETCHING' ? 'Retrieving Payload' : 'Neural Decryption'}

Handshaking via RSA-OAEP-4096 • Block Ref: {activeStatementId}

{decryptionStage === 'DECRYPTING' && rawPayload && (
{JSON.stringify(JSON.parse(rawPayload.dataPayload).encryptedPayload.header, null, 2)}
)}
)}
); } return (

Lumina Quantum

Account Holder

Alex Rivera

Lumina Quantum Systems LLC

Statement

{activeStatementId}

Decryption Fingerprint

{rawPayload && JSON.parse(rawPayload.dataPayload).encryptedPayload.iv}

{MOCK_TRANS_DATA.map((t) => ( ))}
Date Description Amount
{t.date}

{t.description}

Ref: {t.ref}

{t.type === 'CREDIT' ? '+' : '-'}${t.amount.toLocaleString(undefined, { minimumFractionDigits: 2 })}

Audit Proof

Integrity verified via institutional handshake. The data signature matches the expected block height parity checks.

{verificationReport && (

"{verificationReport}"

)}
); }; const SummaryItem = ({ label, value, color = 'zinc', highlight = false }: any) => (

{label}

${value.toLocaleString(undefined, { minimumFractionDigits: 2 })}

); export default AnalyticsReport;