Elffuss BraidHub

kikocis/osiris public

master · 61.2 KiBRawPermalink
1'use client';
2
3import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
4import dynamic from 'next/dynamic';
5import { motion, AnimatePresence } from 'framer-motion';
6import { Layers, BarChart3, Newspaper, Search, X, Globe, MapPinned, Radar, Satellite, Moon, ExternalLink, AlertTriangle, Activity, Database, Wifi } from 'lucide-react';
7import IntelFeed from '@/components/IntelFeed';
8import MarketsPanel from '@/components/MarketsPanel';
9import ScmPanel from '@/components/ScmPanel';
10import SearchBar from '@/components/SearchBar';
11import ScaleBar from '@/components/ScaleBar';
12import ErrorBoundary from '@/components/ErrorBoundary';
13import SharePanel from '@/components/SharePanel';
14import ViewPresets from '@/components/ViewPresets';
15import KeyboardShortcuts from '@/components/KeyboardShortcuts';
16import GlobalStatusBar from '@/components/GlobalStatusBar';
17import LiveAlerts from '@/components/LiveAlerts';
18
19const OsirisMap = dynamic(() => import('@/components/OsirisMap'), { ssr: false });
20const LayerPanel = dynamic(() => import('@/components/LayerPanel'));
21const CameraViewer = dynamic(() => import('@/components/CameraViewer'));
22const OsintPanel = dynamic(() => import('@/components/OsintPanel'));
23
24function useIsMobile() {
25 const [isMobile, setIsMobile] = useState(false);
26 useEffect(() => {
27 const check = () => {
28 const w = window.innerWidth;
29 const h = window.innerHeight;
30 // Mobile if narrow, OR landscape phone (short height + moderate width)
31 setIsMobile(w < 768 || (h < 500 && w < 1024));
32 };
33 check();
34 window.addEventListener('resize', check);
35 window.addEventListener('orientationchange', check);
36 return () => {
37 window.removeEventListener('resize', check);
38 window.removeEventListener('orientationchange', check);
39 };
40 }, []);
41 return isMobile;
42}
43const UptimeClock = () => {
44 const [uptime, setUptime] = useState('00:00:00');
45 const startTime = useRef(Date.now());
46 useEffect(() => {
47 const iv = setInterval(() => {
48 const e = Math.floor((Date.now() - startTime.current) / 1000);
49 setUptime(`${String(Math.floor(e/3600)).padStart(2,'0')}:${String(Math.floor((e%3600)/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`);
50 }, 1000);
51 return () => clearInterval(iv);
52 }, []);
53 return <span className="hidden lg:inline">UPTIME: <span className="text-[var(--gold-primary)]">{uptime}</span></span>;
54};
55
56const ZuluClock = () => {
57 const [time, setTime] = useState('');
58 useEffect(() => {
59 const iv = setInterval(() => {
60 const now = new Date();
61 setTime(`ZULU ${String(now.getUTCHours()).padStart(2,'0')}:${String(now.getUTCMinutes()).padStart(2,'0')}:${String(now.getUTCSeconds()).padStart(2,'0')}Z`);
62 }, 1000);
63 return () => clearInterval(iv);
64 }, []);
65 return <span className="text-[var(--cyan-primary)] font-bold tabular-nums">{time || 'ZULU --:--:--Z'}</span>;
66};
67
68/** Real entity count — no fake throughput metrics */
69const ActiveEntityCount = ({ data }: { data: Record<string, unknown[]> }) => {
70 const count = useMemo(() => {
71 if (!data) return 0;
72 return Object.values(data).reduce((sum, v) => sum + (Array.isArray(v) ? v.length : 0), 0);
73 }, [data]);
74 return <span className="text-[var(--alert-green)] font-bold tabular-nums">{count.toLocaleString()}</span>;
75};
76
77/** Extracts a watchable YouTube URL from embed/channel URLs */
78function getYouTubeWatchUrl(url: string): string {
79 if (url.includes('channel=')) return `https://www.youtube.com/channel/${url.split('channel=')[1].split('&')[0]}/live`;
80 if (url.includes('/embed/')) return `https://www.youtube.com/watch?v=${url.split('/embed/')[1].split('?')[0]}`;
81 return url;
82}
83
84export default function Dashboard() {
85 const dataRef = useRef<any>({});
86 const [dataVersion, setDataVersion] = useState(0);
87 const data = dataRef.current;
88
89 const [backendStatus, setBackendStatus] = useState<'connecting' | 'connected' | 'error'>('connecting');
90 const [mapView, setMapView] = useState({ zoom: 2.5, latitude: 20 });
91 const [flyToLocation, setFlyToLocation] = useState<{ lat: number; lng: number; ts: number } | null>(null);
92 const [globalStats, setGlobalStats] = useState<any>(null);
93 const mouseCoordsRef = useRef<{ lat: number; lng: number } | null>(null);
94 const coordsDisplayRef = useRef<HTMLDivElement>(null);
95 const [locationLabel, setLocationLabel] = useState('');
96 const [regionDossier, setRegionDossier] = useState<any>(null);
97 const [dossierLoading, setDossierLoading] = useState(false);
98 const [showSplash, setShowSplash] = useState(true);
99 const [activeCamera, setActiveCamera] = useState<any>(null);
100 const [spaceWeather, setSpaceWeather] = useState<any>(null);
101 const [showLayers, setShowLayers] = useState(true);
102 const [showMarkets, setShowMarkets] = useState(true);
103 const [showScmPanel, setShowScmPanel] = useState(true);
104 const [showIntel, setShowIntel] = useState(true);
105 const [isFullscreen, setIsFullscreen] = useState(false);
106 const [mobilePanel, setMobilePanel] = useState<'layers'|'markets'|'intel'|'search'|'recon'|null>(null);
107 const [mapProjection, setMapProjection] = useState<'globe'|'mercator'>('globe');
108 const [mapStyle, setMapStyle] = useState<'dark'|'satellite'>('dark');
109 const [sweepData, setSweepData] = useState<any>(null);
110 const [scanTargets, setScanTargets] = useState<any[]>([]);
111
112 const isMobile = useIsMobile();
113 const startTime = useRef(Date.now());
114 const geocodeCache = useRef<Map<string, string>>(new Map());
115 const geocodeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
116 const lastGeocodedPos = useRef<{ lat: number; lng: number } | null>(null);
117
118 // ── DEFAULT: Most layers OFF — fast initial load ──
119 const [activeLayers, setActiveLayers] = useState({
120 flights: false,
121 private: false,
122 jets: false,
123 military: false,
124 maritime: true,
125 satellites: false,
126 balloons: false,
127 cctv: true,
128 live_news: true,
129 news_intel: true,
130 earthquakes: true,
131 fires: false,
132 weather: false,
133 radiation: false,
134 infrastructure: false,
135 global_incidents: true,
136 war_alerts: false,
137 gps_jamming: false,
138 day_night: true,
139 sdk_stream: true,
140 });
141 const [liveFeedUrl, setLiveFeedUrl] = useState<string | null>(null);
142 const [liveFeedName, setLiveFeedName] = useState('');
143 const [liveFeedEmbedAllowed, setLiveFeedEmbedAllowed] = useState(true);
144
145 // Splash screen
146 useEffect(() => {
147 const splashTimer = setTimeout(() => setShowSplash(false), 2500);
148 return () => clearTimeout(splashTimer);
149 }, []);
150
151 // URL state: parse on mount
152 useEffect(() => {
153 if (typeof window === 'undefined') return;
154 const p = new URLSearchParams(window.location.search);
155 const lat = parseFloat(p.get('lat') || '');
156 const lon = parseFloat(p.get('lon') || '');
157 const zoom = parseFloat(p.get('zoom') || '');
158 if (!isNaN(lat) && !isNaN(lon)) {
159 setFlyToLocation({ lat, lng: lon, ts: Date.now() });
160 if (!isNaN(zoom)) setMapView(v => ({ ...v, zoom }));
161 }
162 const layers = p.get('layers');
163 if (layers) {
164 const active = layers.split(',');
165 setActiveLayers(prev => {
166 const next = { ...prev };
167 Object.keys(next).forEach(k => { (next as any)[k] = active.includes(k); });
168 return next;
169 });
170 }
171 }, []);
172
173 // URL state: update URL on view change (debounced)
174 const urlTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
175 useEffect(() => {
176 if (typeof window === 'undefined') return;
177 if (urlTimer.current) clearTimeout(urlTimer.current);
178 urlTimer.current = setTimeout(() => {
179 const p = new URLSearchParams();
180 p.set('lat', (mapView.latitude ?? 20).toFixed(4));
181 p.set('lon', '0');
182 p.set('zoom', mapView.zoom.toFixed(2));
183 const active = Object.entries(activeLayers).filter(([,v]) => v).map(([k]) => k).join(',');
184 p.set('layers', active);
185 const url = `${window.location.pathname}?${p.toString()}`;
186 window.history.replaceState(null, '', url);
187 }, 1500);
188 }, [mapView, activeLayers]);
189
190 // Global Stats Fetch
191 useEffect(() => {
192 fetch('/api/stats')
193 .then(res => res.json())
194 .then(d => {
195 if (d.stats) setGlobalStats(d.stats);
196 })
197 .catch(console.error);
198 }, []);
199
200 // Keyboard shortcuts
201 useEffect(() => {
202 const handler = (e: KeyboardEvent) => {
203 if (['INPUT', 'TEXTAREA'].includes((e.target as Element)?.tagName)) return;
204 if (e.key === 'f' && !e.ctrlKey) {
205 if (document.fullscreenElement) document.exitFullscreen();
206 else document.documentElement.requestFullscreen();
207 }
208 if (e.key === 'l') setShowLayers(p => !p);
209 if (e.key === 'm') setShowMarkets(p => !p);
210 if (e.key === 'c') setShowScmPanel(p => !p);
211 if (e.key === 'i') setShowIntel(p => !p);
212 if (e.key === 'r') setFlyToLocation({ lat: 20, lng: 0, ts: Date.now() });
213 if (e.key === 'g') setMapProjection(p => p === 'globe' ? 'mercator' : 'globe');
214 };
215 const fsHandler = () => setIsFullscreen(!!document.fullscreenElement);
216 window.addEventListener('keydown', handler);
217 document.addEventListener('fullscreenchange', fsHandler);
218 return () => { window.removeEventListener('keydown', handler); document.removeEventListener('fullscreenchange', fsHandler); };
219 }, []);
220
221 // Mouse coords + reverse geocode (Zero-Render)
222 const handleMouseCoords = useCallback((coords: { lat: number; lng: number }) => {
223 mouseCoordsRef.current = coords;
224 if (coordsDisplayRef.current) {
225 coordsDisplayRef.current.innerText = `${coords.lat.toFixed(4)}, ${coords.lng.toFixed(4)}`;
226 }
227 if (geocodeTimer.current) clearTimeout(geocodeTimer.current);
228 geocodeTimer.current = setTimeout(async () => {
229 if (lastGeocodedPos.current) {
230 const d = Math.abs(coords.lat - lastGeocodedPos.current.lat) + Math.abs(coords.lng - lastGeocodedPos.current.lng);
231 if (d < 0.5) return; // increased threshold — fewer geocode calls
232 }
233 const gk = `${coords.lat.toFixed(1)},${coords.lng.toFixed(1)}`; // coarser grid = more cache hits
234 if (geocodeCache.current.has(gk)) { setLocationLabel(geocodeCache.current.get(gk)!); lastGeocodedPos.current = coords; return; }
235 try {
236 const res = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${coords.lat}&lon=${coords.lng}&format=json&zoom=10&addressdetails=1`, { headers: { 'Accept-Language': 'en' } });
237 if (res.ok) {
238 const d = await res.json();
239 const a = d.address || {};
240 const label = [a.city||a.town||a.village||a.county, a.state||a.region, a.country].filter(Boolean).join(', ') || 'Unknown';
241 if (geocodeCache.current.size > 500) { const it = geocodeCache.current.keys(); for (let i=0;i<100;i++) { const k = it.next().value; if(k) geocodeCache.current.delete(k); }}
242 geocodeCache.current.set(gk, label);
243 setLocationLabel(label);
244 lastGeocodedPos.current = coords;
245 }
246 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); }
247 }, 3000); // 3s debounce (was 1.5s)
248 }, []);
249
250 // Region dossier (right-click)
251 const handleRightClick = useCallback(async (coords: { lat: number; lng: number }) => {
252 setDossierLoading(true); setRegionDossier(null);
253 try {
254 const res = await fetch(`/api/region-dossier?lat=${coords.lat}&lng=${coords.lng}`);
255 if (res.ok) setRegionDossier(await res.json());
256 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); } finally { setDossierLoading(false); }
257 }, []);
258
259 // Entity click handler (hoisted from JSX to comply with Rules of Hooks — Fixes #113)
260 const handleEntityClick = useCallback((entity: any) => {
261 if (entity?.type === 'cctv') setActiveCamera(entity);
262 if (entity?.type === 'live_news' && entity.url) {
263 setLiveFeedUrl(entity.url);
264 setLiveFeedName(entity.name);
265 setLiveFeedEmbedAllowed(entity.embed_allowed !== false);
266 }
267 }, []);
268
269 // ── SHARED FETCH UTILITY (Fixes #107 — single definition, not 3 copies) ──
270 const fetchEndpoint = useCallback(async (url: string, transform?: (d: any) => any, options?: RequestInit) => {
271 if (typeof document !== 'undefined' && document.hidden) return;
272 try {
273 const res = await fetch(url, options);
274 if (res.ok) {
275 const json = await res.json();
276 const d = transform ? transform(json) : json;
277 dataRef.current = { ...dataRef.current, ...d };
278 setDataVersion(v => v + 1);
279 setBackendStatus('connected');
280 }
281 } catch (e) {
282 console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e);
283 setBackendStatus('error');
284 }
285 }, []);
286
287 // ── PROGRESSIVE DATA LOADING (request-optimized) ──
288 useEffect(() => {
289 // Priority 1: Core feeds (always needed for panels)
290 fetchEndpoint('/api/earthquakes');
291 fetchEndpoint('/api/news');
292 const marketTimer = setTimeout(() => fetchEndpoint('/api/markets', d => ({ markets: d })), 800);
293
294 // Priority 2: Space Weather (needed for MarketsPanel)
295 const spaceTimer = setTimeout(async () => {
296 try {
297 const r = await fetch('/api/space-weather');
298 if (r.ok) setSpaceWeather(await r.json());
299 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); }
300 }, 5000);
301
302 // Polling — OPTIMIZED intervals to minimize edge requests
303 const intervals = [
304 setInterval(() => fetchEndpoint('/api/earthquakes'), 900000), // 15 min (was 5)
305 setInterval(() => fetchEndpoint('/api/news'), 1800000), // 30 min (was 10)
306 setInterval(() => fetchEndpoint('/api/markets', d => ({ markets: d })), 900000), // 15 min (was 5)
307 ];
308 return () => {
309 clearTimeout(marketTimer);
310 clearTimeout(spaceTimer);
311 intervals.forEach(clearInterval);
312 };
313 }, [fetchEndpoint]);
314
315 // ── LAYER-AWARE DATA LOADING — only fetch when layer is toggled ON ──
316 const layerFetchedRef = useRef<Set<string>>(new Set());
317 useEffect(() => {
318
319 // Flights
320 if (activeLayers.flights || activeLayers.military || activeLayers.jets || activeLayers.private) {
321 if (!layerFetchedRef.current.has('flights')) {
322 fetchEndpoint('/api/flights');
323 layerFetchedRef.current.add('flights');
324 }
325 }
326 // Satellites
327 if (activeLayers.satellites && !layerFetchedRef.current.has('satellites')) {
328 fetchEndpoint('/api/satellites');
329 layerFetchedRef.current.add('satellites');
330 }
331 // Fires
332 if (activeLayers.fires && !layerFetchedRef.current.has('fires')) {
333 fetchEndpoint('/api/fires');
334 layerFetchedRef.current.add('fires');
335 }
336 // CCTV
337 if (activeLayers.cctv && !layerFetchedRef.current.has('cctv')) {
338 fetchEndpoint('/api/cctv?region=all&v=2');
339 layerFetchedRef.current.add('cctv');
340 }
341 // Maritime
342 if (activeLayers.maritime && !layerFetchedRef.current.has('maritime')) {
343 fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships }));
344 layerFetchedRef.current.add('maritime');
345 }
346 // Balloons
347 if (activeLayers.balloons && !layerFetchedRef.current.has('balloons')) {
348 fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons }));
349 layerFetchedRef.current.add('balloons');
350 }
351 // Radiation
352 if (activeLayers.radiation && !layerFetchedRef.current.has('radiation')) {
353 fetchEndpoint('/api/radiation', d => ({ radiation: d.stations }));
354 layerFetchedRef.current.add('radiation');
355 }
356 // Live News
357 if (activeLayers.live_news && !layerFetchedRef.current.has('live_news')) {
358 fetchEndpoint('/api/live-news', d => ({ live_feeds: d.feeds }));
359 layerFetchedRef.current.add('live_news');
360 }
361 // Weather
362 if (activeLayers.weather && !layerFetchedRef.current.has('weather')) {
363 fetchEndpoint('/api/weather', d => ({ weather_events: d.events }));
364 layerFetchedRef.current.add('weather');
365 }
366 // Infrastructure
367 if (activeLayers.infrastructure && !layerFetchedRef.current.has('infrastructure')) {
368 fetchEndpoint('/api/infrastructure', d => ({ infrastructure: d.infrastructure }));
369 layerFetchedRef.current.add('infrastructure');
370 }
371 // Global Incidents (GDELT)
372 if (activeLayers.global_incidents && !layerFetchedRef.current.has('gdelt')) {
373 fetchEndpoint('/api/gdelt', d => ({ gdelt: d.events }));
374 layerFetchedRef.current.add('gdelt');
375 }
376
377 }, [activeLayers]);
378
379 // ── LAYER-AWARE POLLING — only poll data for active layers ──
380 useEffect(() => {
381 const intervals: ReturnType<typeof setInterval>[] = [];
382 if (activeLayers.flights || activeLayers.military || activeLayers.jets || activeLayers.private) {
383 intervals.push(setInterval(() => fetchEndpoint('/api/flights'), 300000)); // 5 min (was 2 min)
384 }
385
386 if (activeLayers.balloons) {
387 intervals.push(setInterval(() => fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons })), 300000)); // 5m
388 }
389 if (activeLayers.radiation) {
390 intervals.push(setInterval(() => fetchEndpoint('/api/radiation', d => ({ radiation: d.stations })), 300000)); // 5m
391 }
392 if (activeLayers.maritime) {
393 intervals.push(setInterval(() => fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships })), 10000)); // 10s
394 }
395 return () => intervals.forEach(clearInterval);
396 }, [activeLayers, fetchEndpoint]);
397
398 // CCTV: loaded once on layer toggle via layerFetchedRef (no viewport polling)
399
400 // Reactive layer fetch: handled by layerFetchedRef above (no duplicate)
401
402 // ── OSIRIS SDK — Intelligence Fusion Layer ──
403 // Produces node coordinates for the SDK network mesh visualization.
404 // Does NOT duplicate existing layer visuals — SDK layer is LINES ONLY.
405 // Cameras are excluded — they have their own dedicated layer.
406 useEffect(() => {
407 if (!activeLayers.sdk_stream) {
408 dataRef.current = { ...dataRef.current, sdk_entities: [] };
409 return;
410 }
411
412 const sdkEntities: any[] = [];
413
414 // Air domain (nodes only — no visual duplication)
415 const allFlights = [
416 ...(data.commercial_flights || []),
417 ...(data.private_flights || []),
418 ...(data.private_jets || []),
419 ...(data.military_flights || []),
420 ];
421 // Sample flights to keep it clean (every Nth)
422 const flightStep = Math.max(1, Math.floor(allFlights.length / 60));
423 for (let i = 0; i < allFlights.length; i += flightStep) {
424 const f = allFlights[i];
425 if (!f.lat || !f.lng) continue;
426 sdkEntities.push({
427 type: 'Feature', geometry: { type: 'Point', coordinates: [f.lng, f.lat] },
428 properties: { domain: 'AIR', name: f.callsign?.trim() || 'TRACK', source: 'ADS-B / OpenSky' },
429 });
430 }
431
432 // Sea domain
433 const ships = data.maritime_ships || [];
434 const shipStep = Math.max(1, Math.floor(ships.length / 60));
435 for (let i = 0; i < ships.length; i += shipStep) {
436 const s = ships[i];
437 if (!s.lat || !s.lng) continue;
438 sdkEntities.push({
439 type: 'Feature', geometry: { type: 'Point', coordinates: [s.lng, s.lat] },
440 properties: { domain: 'SEA', name: s.name || `MMSI-${s.mmsi}`, source: 'AIS Stream' },
441 });
442 }
443
444 // Events — Earthquakes
445 if (data.earthquakes?.length) {
446 for (const eq of data.earthquakes) {
447 if (!eq.lat || !eq.lng) continue;
448 sdkEntities.push({
449 type: 'Feature', geometry: { type: 'Point', coordinates: [eq.lng, eq.lat] },
450 properties: { domain: 'LAND', name: `M${eq.magnitude} ${eq.place || ''}`, source: 'USGS' },
451 });
452 }
453 }
454
455 // GDELT events
456 if (data.gdelt?.length) {
457 for (const g of data.gdelt) {
458 if (!g.lat || !g.lng) continue;
459 sdkEntities.push({
460 type: 'Feature', geometry: { type: 'Point', coordinates: [g.lng, g.lat] },
461 properties: { domain: 'INTEL', name: g.name || 'GDELT Event', source: 'GDELT Project' },
462 });
463 }
464 }
465
466 // News intel
467 if (data.news?.length) {
468 for (const n of data.news) {
469 if (!n.coords || n.coords.length < 2) continue;
470 sdkEntities.push({
471 type: 'Feature', geometry: { type: 'Point', coordinates: [n.coords[1], n.coords[0]] },
472 properties: { domain: 'INTEL', name: n.title || 'SIGINT', source: n.source || 'RSS Feed' },
473 });
474 }
475 }
476
477 dataRef.current = { ...dataRef.current, sdk_entities: sdkEntities };
478 }, [dataVersion, activeLayers.sdk_stream]);
479
480 const totalFlights = useMemo(() => (
481 (data.commercial_flights?.length||0)+(data.private_flights?.length||0)+(data.private_jets?.length||0)+(data.military_flights?.length||0)
482 ), [data.commercial_flights, data.private_flights, data.private_jets, data.military_flights]);
483
484
485 return (
486 <main className="fixed inset-0 w-full h-full bg-[var(--bg-void)] overflow-hidden">
487
488 {/* ── SPLASH ── */}
489 <AnimatePresence>
490 {showSplash && (
491 <motion.div
492 initial={{ opacity: 1 }}
493 exit={{ opacity: 0 }}
494 transition={{ duration: 0.8, ease: 'easeInOut' }}
495 className="absolute inset-0 z-[999] flex flex-col items-center justify-center overflow-hidden"
496 style={{ background: 'radial-gradient(ellipse at center, #0a0a14 0%, var(--bg-void) 70%)' }}
497 >
498 {/* ── Scanline CRT overlay ── */}
499 <div className="absolute inset-0 pointer-events-none z-[1]" style={{
500 backgroundImage: 'repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(212,175,55,0.015) 2px, rgba(212,175,55,0.015) 4px)',
501 animation: 'splashScanDrift 8s linear infinite',
502 }} />
503
504 {/* ── V4.2 badge — top-left ── */}
505 <motion.div
506 initial={{ opacity: 0 }}
507 animate={{ opacity: 0.6 }}
508 transition={{ delay: 0.8, duration: 0.5 }}
509 className="absolute top-6 left-6 z-[2] font-mono text-[10px] tracking-[0.3em] text-[var(--gold-primary)]"
510 >
511 V4.2
512 </motion.div>
513
514
515
516 {/* ── Geometric tactical logo ── */}
517 <div className="relative w-40 h-40 mb-8 flex items-center justify-center z-[2]">
518 {/* Outer ring — slow clockwise */}
519 <motion.div
520 initial={{ opacity: 0, scale: 0.6, rotate: 0 }}
521 animate={{ opacity: 1, scale: 1, rotate: 360 }}
522 transition={{ opacity: { duration: 0.6 }, scale: { duration: 0.8, ease: 'easeOut' }, rotate: { duration: 20, repeat: Infinity, ease: 'linear' } }}
523 className="absolute inset-0 rounded-full"
524 style={{ border: '1px solid rgba(212,175,55,0.2)' }}
525 >
526 <div className="absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 w-2 h-2 rounded-full" style={{ background: 'var(--gold-primary)', boxShadow: '0 0 12px var(--gold-primary), 0 0 24px rgba(212,175,55,0.3)' }} />
527 <div className="absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 w-1 h-1 rounded-full" style={{ background: 'rgba(212,175,55,0.5)', boxShadow: '0 0 6px rgba(212,175,55,0.3)' }} />
528 </motion.div>
529
530 {/* Middle ring — faster counter-clockwise */}
531 <motion.div
532 initial={{ opacity: 0, scale: 0.4, rotate: 0 }}
533 animate={{ opacity: 1, scale: 1, rotate: -360 }}
534 transition={{ opacity: { duration: 0.6, delay: 0.15 }, scale: { duration: 0.8, delay: 0.15, ease: 'easeOut' }, rotate: { duration: 12, repeat: Infinity, ease: 'linear' } }}
535 className="absolute rounded-full"
536 style={{ inset: '18px', border: '1px solid rgba(0,229,255,0.15)' }}
537 >
538 <div className="absolute top-1/2 right-0 translate-x-1/2 -translate-y-1/2 w-1.5 h-1.5 rounded-full" style={{ background: 'var(--cyan-primary)', boxShadow: '0 0 10px var(--cyan-primary), 0 0 20px rgba(0,229,255,0.2)' }} />
539 <div className="absolute bottom-0 left-1/4 translate-y-1/2 w-1 h-1 rounded-full" style={{ background: 'rgba(0,229,255,0.4)' }} />
540 </motion.div>
541
542 {/* Inner ring — fastest clockwise */}
543 <motion.div
544 initial={{ opacity: 0, scale: 0.2, rotate: 0 }}
545 animate={{ opacity: 1, scale: 1, rotate: 360 }}
546 transition={{ opacity: { duration: 0.6, delay: 0.3 }, scale: { duration: 0.8, delay: 0.3, ease: 'easeOut' }, rotate: { duration: 7, repeat: Infinity, ease: 'linear' } }}
547 className="absolute rounded-full"
548 style={{ inset: '40px', border: '1px solid rgba(212,175,55,0.25)' }}
549 >
550 <div className="absolute top-0 left-1/4 -translate-y-1/2 w-1.5 h-1.5 rounded-full" style={{ background: 'var(--gold-primary)', boxShadow: '0 0 8px var(--gold-primary)' }} />
551 </motion.div>
552
553 {/* Core circle + crosshair */}
554 <motion.div
555 initial={{ opacity: 0, scale: 0 }}
556 animate={{ opacity: 1, scale: 1 }}
557 transition={{ delay: 0.4, duration: 0.6, ease: [0.34, 1.56, 0.64, 1] }}
558 className="relative w-12 h-12 rounded-full flex items-center justify-center"
559 style={{ border: '2px solid var(--gold-primary)', boxShadow: '0 0 20px rgba(212,175,55,0.15), inset 0 0 20px rgba(212,175,55,0.05)' }}
560 >
561 <motion.div
562 animate={{ opacity: [0.3, 0.8, 0.3] }}
563 transition={{ duration: 2, repeat: Infinity, ease: 'easeInOut' }}
564 className="w-5 h-5 rounded-full"
565 style={{ background: 'radial-gradient(circle, rgba(212,175,55,0.4) 0%, rgba(212,175,55,0.05) 70%)' }}
566 />
567 {/* Crosshair lines */}
568 <div className="absolute w-[1px] h-full" style={{ background: 'linear-gradient(to bottom, transparent, rgba(212,175,55,0.3), transparent)' }} />
569 <div className="absolute w-full h-[1px]" style={{ background: 'linear-gradient(to right, transparent, rgba(212,175,55,0.3), transparent)' }} />
570 </motion.div>
571
572 {/* Faint pulsing radar sweep */}
573 <motion.div
574 initial={{ opacity: 0 }}
575 animate={{ opacity: [0, 0.15, 0], rotate: [0, 360] }}
576 transition={{ opacity: { duration: 3, repeat: Infinity }, rotate: { duration: 3, repeat: Infinity, ease: 'linear' }, delay: 0.6 }}
577 className="absolute inset-[10px] rounded-full"
578 style={{ background: 'conic-gradient(from 0deg, transparent 0deg, rgba(212,175,55,0.15) 40deg, transparent 80deg)' }}
579 />
580 </div>
581
582 {/* ── OSIRIS title — letter-by-letter stagger ── */}
583 <div className="flex items-center gap-[2px] mb-3 z-[2]">
584 {'OSIRIS'.split('').map((letter, i) => (
585 <motion.span
586 key={i}
587 initial={{ opacity: 0, y: 20, filter: 'blur(8px)' }}
588 animate={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
589 transition={{ delay: 0.5 + i * 0.08, duration: 0.5, ease: 'easeOut' }}
590 className="text-4xl md:text-5xl font-bold tracking-[0.5em] font-mono"
591 style={{ color: 'var(--text-heading)', textShadow: '0 0 30px rgba(212,175,55,0.2)' }}
592 >
593 {letter}
594 </motion.span>
595 ))}
596 </div>
597
598 {/* ── Subtitle — typewriter reveal ── */}
599 <div className="overflow-hidden mb-8 z-[2]">
600 <motion.div
601 initial={{ width: 0 }}
602 animate={{ width: '100%' }}
603 transition={{ delay: 1.2, duration: 0.8, ease: 'easeInOut' }}
604 className="overflow-hidden whitespace-nowrap"
605 >
606 <p className="text-[10px] md:text-[11px] font-mono tracking-[0.5em] text-[var(--gold-primary)]" style={{ opacity: 0.8 }}>
607 GLOBAL INTELLIGENCE PLATFORM
608 </p>
609 </motion.div>
610 </div>
611
612 {/* ── Multi-stage progress bar ── */}
613 <div className="w-64 md:w-80 z-[2]">
614 {/* Thin progress track */}
615 <div className="relative w-full h-[2px] rounded-full overflow-hidden" style={{ background: 'rgba(212,175,55,0.1)' }}>
616 <motion.div
617 initial={{ width: '0%' }}
618 animate={{ width: ['0%', '25%', '50%', '78%', '100%'] }}
619 transition={{ duration: 2.2, delay: 0.5, times: [0, 0.25, 0.5, 0.75, 1], ease: 'easeInOut' }}
620 className="absolute inset-y-0 left-0 rounded-full"
621 style={{ background: 'linear-gradient(90deg, var(--gold-primary), var(--cyan-primary), var(--gold-primary))', boxShadow: '0 0 12px rgba(212,175,55,0.4)' }}
622 />
623 </div>
624
625 {/* Status messages — cycling */}
626 <div className="mt-3 h-4 flex items-center justify-center">
627 {[
628 { text: 'ESTABLISHING SECURE CONNECTION...', delay: 0.5 },
629 { text: 'INITIALIZING FEEDS...', delay: 1.1 },
630 { text: 'CALIBRATING SENSORS...', delay: 1.7 },
631 { text: 'SYSTEM READY', delay: 2.2 },
632 ].map((stage, i) => (
633 <motion.span
634 key={i}
635 initial={{ opacity: 0 }}
636 animate={{ opacity: [0, 1, 1, 0] }}
637 transition={{ delay: stage.delay, duration: 0.6, times: [0, 0.1, 0.7, 1] }}
638 className="absolute text-[9px] font-mono tracking-[0.25em]"
639 style={{ color: i === 3 ? 'var(--cyan-primary)' : 'var(--text-muted)' }}
640 >
641 {stage.text}
642 </motion.span>
643 ))}
644 </div>
645 </div>
646
647 {/* ── Decorative grid lines ── */}
648 <div className="absolute inset-0 pointer-events-none z-[0]" style={{ opacity: 0.03 }}>
649 <div className="absolute inset-0" style={{
650 backgroundImage: 'linear-gradient(rgba(212,175,55,0.5) 1px, transparent 1px), linear-gradient(90deg, rgba(212,175,55,0.5) 1px, transparent 1px)',
651 backgroundSize: '60px 60px',
652 }} />
653 </div>
654
655 {/* ── Corner frame accents ── */}
656 {[
657 { t: '10px', l: '10px', bw: '2px 0 0 2px' },
658 { t: '10px', r: '10px', bw: '2px 2px 0 0' },
659 { b: '10px', l: '10px', bw: '0 0 2px 2px' },
660 { b: '10px', r: '10px', bw: '0 2px 2px 0' },
661 ].map((pos, i) => (
662 <motion.div
663 key={i}
664 initial={{ opacity: 0 }}
665 animate={{ opacity: 0.3 }}
666 transition={{ delay: 0.8 + i * 0.1, duration: 0.5 }}
667 className="absolute w-8 h-8 z-[2]"
668 style={{ top: pos.t, bottom: pos.b, left: pos.l, right: pos.r, borderWidth: pos.bw, borderStyle: 'solid', borderColor: 'var(--gold-primary)' }}
669 />
670 ))}
671
672
673
674 {/* ── Inline keyframe for scanline drift ── */}
675
676 </motion.div>
677 )}
678 </AnimatePresence>
679
680
681
682 {/* ── MAP ── */}
683 <ErrorBoundary name="Map">
684 <OsirisMap
685 data={data}
686 activeLayers={activeLayers}
687 projection={mapProjection}
688 mapStyle={mapStyle === 'satellite' ? 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' : 'dark'}
689 onEntityClick={handleEntityClick}
690 onMouseCoords={handleMouseCoords}
691 onRightClick={handleRightClick}
692 onViewStateChange={setMapView}
693 flyToLocation={flyToLocation}
694 sweepData={sweepData}
695 scanTargets={scanTargets}
696 />
697 </ErrorBoundary>
698
699
700 {/* ── MAP VIEW CONTROLS (3D/2D + SATELLITE TOGGLE) ── */}
701 <motion.div
702 initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: 3.5 }}
703 className="absolute bottom-[75px] md:bottom-6 left-3 md:left-[315px] z-[200] flex items-center gap-2 pointer-events-none"
704 >
705 {/* 3D/2D Toggle */}
706 <button
707 onClick={() => setMapProjection(p => p === 'globe' ? 'mercator' : 'globe')}
708 className="glass-panel p-2.5 pointer-events-auto hover:border-[var(--gold-primary)]/40 transition-colors group relative"
709 title={mapProjection === 'globe' ? 'Switch to 2D Map' : 'Switch to 3D Globe'}
710 >
711 {mapProjection === 'globe' ? (
712 <MapPinned className="w-4 h-4 text-[var(--gold-primary)] group-hover:scale-110 transition-transform" />
713 ) : (
714 <Globe className="w-4 h-4 text-[var(--cyan-primary)] group-hover:scale-110 transition-transform" />
715 )}
716 <span className="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 text-[9px] font-mono text-[var(--text-muted)] whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity glass-panel px-2 py-1 z-[300]">
717 {mapProjection === 'globe' ? '2D MAP' : '3D GLOBE'}
718 </span>
719 </button>
720
721 {/* Map Style Toggle */}
722 <button
723 onClick={() => setMapStyle(s => s === 'dark' ? 'satellite' : 'dark')}
724 className="glass-panel p-2.5 pointer-events-auto hover:border-[var(--gold-primary)]/40 transition-colors group relative"
725 title={mapStyle === 'dark' ? 'Satellite View' : 'Night View'}
726 >
727 {mapStyle === 'dark' ? (
728 <Satellite className="w-4 h-4 text-[var(--alert-green)] group-hover:scale-110 transition-transform" />
729 ) : (
730 <Moon className="w-4 h-4 text-[var(--cyan-primary)] group-hover:scale-110 transition-transform" />
731 )}
732 <span className="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 text-[9px] font-mono text-[var(--text-muted)] whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity glass-panel px-2 py-1 z-[300]">
733 {mapStyle === 'dark' ? 'SATELLITE' : 'NIGHT MODE'}
734 </span>
735 </button>
736 </motion.div>
737
738 {/* ── HEADER ── */}
739 <motion.div initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 1, delay: 2.5 }} className={`absolute top-3 left-3 md:top-5 md:left-5 z-[200] pointer-events-none flex items-center gap-2 md:gap-3`}>
740 <div className="w-7 h-7 md:w-9 md:h-9 flex items-center justify-center relative">
741 {/* Ambient glow ring — slow rotating */}
742 <div className="absolute inset-[-4px] md:inset-[-5px] rounded-full border border-[var(--gold-primary)]/20" style={{ animation: 'osiris-rotate 12s linear infinite' }}>
743 <div className="absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-1 rounded-full bg-[var(--gold-primary)] shadow-[0_0_6px_var(--gold-primary)]" />
744 </div>
745 <div className="absolute inset-[-8px] md:inset-[-10px] rounded-full border border-[var(--gold-primary)]/10" style={{ animation: 'osiris-rotate 20s linear infinite reverse' }}>
746 <div className="absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 w-0.5 h-0.5 rounded-full bg-[var(--gold-primary)]/60" />
747 </div>
748 <div className="w-5 h-5 md:w-7 md:h-7 rounded-full border-2 border-[var(--gold-primary)] flex items-center justify-center animate-glow-pulse">
749 <div className="w-2.5 h-2.5 md:w-3.5 md:h-3.5 rounded-full bg-[var(--gold-primary)]/30 border border-[var(--gold-primary)]/60" />
750 </div>
751 <div className="absolute w-[1px] h-full bg-[var(--gold-primary)]/30" />
752 <div className="absolute w-full h-[1px] bg-[var(--gold-primary)]/30" />
753 </div>
754 {/* Horizontal rule extending from logo */}
755 <div className="hidden md:block absolute top-1/2 left-[52px] w-[200px] h-[1px] bg-gradient-to-r from-[var(--gold-primary)]/40 via-[var(--gold-primary)]/15 to-transparent" />
756 <div className="flex flex-col">
757 <div className="flex items-center gap-2">
758 <h1 className="text-base md:text-xl font-bold tracking-[0.4em] md:tracking-[0.5em] text-[var(--text-heading)] font-mono">OSIRIS</h1>
759 <span className="hidden md:inline-flex items-center gap-1 px-1.5 py-[1px] rounded-sm border border-[var(--cyan-primary)]/40 bg-[var(--cyan-primary)]/10 text-[7px] font-mono font-bold tracking-[0.15em] text-[var(--cyan-primary)] uppercase" style={{ lineHeight: '1.4' }}>
760 <Globe className="w-2.5 h-2.5" />
761 OPEN SOURCE
762 </span>
763 </div>
764 <span className="text-[8px] md:text-[9px] text-[var(--gold-primary)] font-mono tracking-[0.2em] md:tracking-[0.3em] opacity-80">GLOBAL INTELLIGENCE COMMAND</span>
765 </div>
766 </motion.div>
767
768 {/* ── TOP-RIGHT STATUS (desktop) — C2 DISPLAY ── */}
769 <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 3 }} className="status-bar-desktop absolute top-3 right-3 md:top-4 md:right-5 z-[200] pointer-events-none flex items-center gap-1.5 md:gap-3 text-[9px] md:text-[10px] font-mono tracking-widest text-[var(--text-muted)]">
770
771 {/* Zulu Clock */}
772 <span className="hidden lg:inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm border border-[var(--border-primary)] bg-black/30">
773 <ZuluClock />
774 </span>
775
776 <span className="hidden lg:inline text-[var(--border-primary)]">│</span>
777
778 <span className="flex items-center gap-1">SYS: <span className={backendStatus === 'connected' ? 'text-[var(--alert-green)]' : 'text-[var(--alert-red)]'}>{backendStatus.toUpperCase()}</span></span>
779
780 {spaceWeather && <span className="hidden lg:inline">SOLAR: <span style={{ color: spaceWeather.storm_color, fontWeight: 700 }}>Kp{spaceWeather.kp_index}</span></span>}
781
782 {/* Active Data Feeds */}
783 <span className="hidden lg:inline-flex items-center gap-1">
784 <Wifi className="w-3 h-3 text-[var(--cyan-primary)]" />
785 <span className="text-[var(--cyan-primary)] font-bold">{Object.values(activeLayers).filter(Boolean).length}</span>
786 <span className="text-[var(--text-muted)]/60">FEEDS</span>
787 </span>
788
789 <UptimeClock />
790
791 <a href='https://ko-fi.com/M8D41ZYW4Z' target='_blank' className="pointer-events-auto hover:opacity-80 transition-opacity ml-1 flex items-center">
792 <span className="px-3 py-1 rounded-sm border border-[var(--gold-primary)]/40 bg-[var(--gold-primary)]/10 text-[var(--gold-primary)] text-[11px] font-bold tracking-[0.2em]">SUPPORT PROJECT</span>
793 </a>
794 </motion.div>
795
796 {/* ── MOBILE: Compact top status ── */}
797 {isMobile && (
798 <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 2.5 }} className="absolute top-3 right-3 z-[200] pointer-events-auto flex items-center gap-2">
799 <a href='https://ko-fi.com/M8D41ZYW4Z' target='_blank' className="glass-panel px-2 py-1 flex items-center gap-1.5 text-[7px] font-mono tracking-widest hover:opacity-80 transition-opacity border-[var(--gold-primary)]/40 bg-[var(--gold-primary)]/10">
800 <div className="w-1 h-1 rounded-full bg-[var(--gold-primary)] animate-osiris-pulse" />
801 <span className="text-[var(--gold-primary)] font-bold">SUPPORT PROJECT</span>
802 </a>
803 </motion.div>
804 )}
805
806
807
808 {/* ── LEFT HUD (desktop): Layers + Stats + Markets + Intel ── */}
809 <div className="desktop-panel absolute left-5 top-20 bottom-24 w-72 flex flex-col gap-3 z-[200] pointer-events-none overflow-y-auto styled-scrollbar pr-1">
810 {showLayers && (
811 <>
812 <LayerPanel data={data} activeLayers={activeLayers} setActiveLayers={setActiveLayers} />
813 <motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.5 }} className="glass-panel px-3 py-2.5 pointer-events-auto">
814 <div className="grid grid-cols-5 gap-2 text-center">
815 <div><div className="hud-label">AIRCRAFT</div><div className="hud-value text-[10px] animate-data-pulse">{globalStats ? globalStats.flights.toLocaleString() : '0'}</div></div>
816 <div><div className="hud-label">SATS</div><div className="hud-value text-[10px]">{globalStats ? globalStats.sats.toLocaleString() : '0'}</div></div>
817 <div><div className="hud-label">CCTV</div><div className="hud-value text-[10px]">{globalStats ? globalStats.cctv.toLocaleString() : '0'}</div></div>
818 <div><div className="hud-label">WEATHER</div><div className="hud-value text-[10px]" style={{ color: 'var(--accent-weather)' }}>{globalStats ? globalStats.weather.toLocaleString() : '0'}</div></div>
819 <div><div className="hud-label">NUCLEAR</div><div className="hud-value text-[10px]" style={{ color: 'var(--accent-nuclear)' }}>{globalStats ? globalStats.nuclear.toLocaleString() : '0'}</div></div>
820 </div>
821 </motion.div>
822 <ViewPresets onNavigate={(lat, lng, zoom) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMapView(v => ({ ...v, zoom })); }} />
823 </>
824 )}
825 {showScmPanel && <ScmPanel data={data} />}
826 {showMarkets && <MarketsPanel data={data} spaceWeather={spaceWeather} />}
827 {showIntel && <IntelFeed data={data} onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} />}
828 </div>
829
830 {/* ── RIGHT HUD (desktop): Search + RECON + Live Alerts ── */}
831 <div className="desktop-panel absolute right-5 top-20 bottom-24 w-80 flex flex-col gap-3 z-[200] pointer-events-auto overflow-y-auto styled-scrollbar pr-1">
832 <div className="flex gap-2 items-start">
833 <div className="flex-1"><SearchBar onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} /></div>
834 <div className="relative"><SharePanel mapView={mapView} activeLayers={activeLayers} mouseCoords={null} /></div>
835 </div>
836 <OsintPanel onSweepVisualize={setSweepData} onScanGeolocate={(target, data) => {
837 setScanTargets(prev => {
838 const existing = prev.filter(t => t.id !== target);
839 return [{ id: target, timestamp: Date.now(), ...data }, ...existing].slice(0, 10);
840 });
841 setFlyToLocation({ lat: data.lat, lng: data.lng, ts: Date.now() });
842 }} />
843 <LiveAlerts data={data} onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} onWatchFeed={(url, name) => { setLiveFeedUrl(url); setLiveFeedName(name); }} />
844 </div>
845
846 {/* ── LIVE FEED VIEWER OVERLAY ── */}
847 <AnimatePresence>
848 {liveFeedUrl && (
849 <motion.div
850 initial={{ opacity: 0, scale: 0.9 }}
851 animate={{ opacity: 1, scale: 1 }}
852 exit={{ opacity: 0, scale: 0.9 }}
853 className="fixed inset-0 z-[500] flex items-center justify-center bg-black/70 backdrop-blur-sm"
854 onClick={() => setLiveFeedUrl(null)}
855 >
856 <motion.div
857 initial={{ y: 20 }}
858 animate={{ y: 0 }}
859 className="w-[90vw] max-w-[900px] flex flex-col relative rounded-xl overflow-hidden border border-[var(--border-primary)] shadow-2xl bg-black"
860 onClick={e => e.stopPropagation()}
861 >
862 {/* Header */}
863 <div className="flex items-center justify-between px-4 py-2.5 bg-[#111] border-b border-[var(--border-primary)]">
864 <div className="flex items-center gap-2">
865 <div className="w-2 h-2 rounded-full bg-[#FF4081] animate-osiris-pulse" />
866 <span className="text-[12px] font-mono font-bold text-white tracking-wider">{liveFeedName}</span>
867 <span className="px-1.5 py-0.5 rounded bg-red-500/20 text-red-400 font-mono text-[9px] font-bold">LIVE STREAM</span>
868 {!liveFeedEmbedAllowed && (
869 <span className="px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 font-mono text-[9px]">EXTERNAL ONLY</span>
870 )}
871 </div>
872 <div className="flex items-center gap-3">
873 <a
874 href={getYouTubeWatchUrl(liveFeedUrl)}
875 target="_blank"
876 rel="noopener noreferrer"
877 className="flex items-center gap-1.5 px-2.5 py-1 rounded bg-[var(--border-primary)] hover:bg-[var(--gold-primary)] hover:text-black text-white transition-colors text-[11px] font-mono"
878 >
879 <span>Open in YouTube</span>
880 <ExternalLink className="w-3 h-3" />
881 </a>
882 <button onClick={() => setLiveFeedUrl(null)} className="text-white/70 hover:text-white transition-colors p-1">
883 <X className="w-5 h-5" />
884 </button>
885 </div>
886 </div>
887
888 {/* Body — iframe or external card */}
889 {liveFeedEmbedAllowed ? (
890 <div className="w-full aspect-video relative bg-black">
891 <iframe
892 src={liveFeedUrl}
893 className="w-full h-full absolute inset-0"
894 allow="autoplay; encrypted-media"
895 allowFullScreen
896 />
897 </div>
898 ) : (
899 <div className="w-full aspect-video flex items-center justify-center bg-black/95">
900 <div className="text-center px-8">
901 <div className="w-14 h-14 rounded-full bg-[#39FF14]/10 border border-[#39FF14]/20 flex items-center justify-center mx-auto mb-4">
902 <ExternalLink className="w-6 h-6 text-[#39FF14]" />
903 </div>
904 <p className="text-[13px] font-mono font-bold text-white tracking-widest mb-2">EMBED RESTRICTED</p>
905 <p className="text-[11px] font-mono text-white/50 mb-6 max-w-xs">
906 {liveFeedName} does not allow third-party embedding. Click below to open the live stream directly.
907 </p>
908 <a
909 href={getYouTubeWatchUrl(liveFeedUrl)}
910 target="_blank"
911 rel="noopener noreferrer"
912 className="inline-flex items-center gap-2 px-6 py-2.5 rounded border border-[#39FF14]/40 text-[#39FF14] font-mono text-[12px] hover:bg-[#39FF14]/10 transition-colors tracking-wider"
913 >
914 <ExternalLink className="w-4 h-4" />
915 OPEN LIVE STREAM
916 </a>
917 </div>
918 </div>
919 )}
920
921 {/* Footer — only show for embeddable feeds */}
922 {liveFeedEmbedAllowed && (
923 <div className="bg-[#111]/90 px-4 py-2.5 border-t border-[var(--border-primary)] flex items-center gap-2.5">
924 <AlertTriangle className="w-4 h-4 text-[var(--gold-primary)] shrink-0" />
925 <span className="text-[11px] font-mono text-white/70 leading-relaxed">
926 If you see &ldquo;Video unavailable&rdquo;, use <strong className="text-[var(--gold-primary)]">Open in YouTube</strong> above.
927 </span>
928 </div>
929 )}
930 </motion.div>
931 </motion.div>
932 )}
933 </AnimatePresence>
934
935 {/* ═══ MOBILE UI ═══ */}
936 {isMobile && (
937 <>
938 {/* Mobile Bottom Navigation */}
939 <div className="mobile-nav">
940 <div className="glass-panel mobile-nav-inner">
941 {[
942 { id: 'layers' as const, icon: Layers, label: 'LAYERS' },
943 { id: 'markets' as const, icon: BarChart3, label: 'MARKETS' },
944 { id: 'intel' as const, icon: Newspaper, label: 'INTEL' },
945 { id: 'recon' as const, icon: Radar, label: 'RECON' },
946 { id: 'search' as const, icon: Search, label: 'SEARCH' },
947 ].map(tab => (
948 <button key={tab.id} onClick={() => setMobilePanel(mobilePanel === tab.id ? null : tab.id)}
949 className={`mobile-nav-btn ${mobilePanel === tab.id ? 'active' : ''}`}>
950 <tab.icon className={`w-4 h-4 ${tab.id === 'recon' ? 'text-[var(--cyan-primary)]' : ''}`} />
951 <span className={tab.id === 'recon' ? 'text-[var(--cyan-primary)]' : ''}>{tab.label}</span>
952 </button>
953 ))}
954 </div>
955 </div>
956
957 {/* Mobile Drawer */}
958 <AnimatePresence>
959 {mobilePanel && (
960 <motion.div
961 initial={{ y: '100%' }} animate={{ y: 0 }} exit={{ y: '100%' }}
962 transition={{ type: 'spring', damping: 30, stiffness: 300 }}
963 className="fixed bottom-[52px] left-0 right-0 z-[400] glass-panel rounded-b-none overflow-y-auto styled-scrollbar"
964 style={{ maxHeight: 'min(55vh, calc(100dvh - 100px))', paddingBottom: 'env(safe-area-inset-bottom, 4px)' }}
965 >
966 <div className="mobile-drawer-handle" />
967 <div className="px-3 pb-3">
968 <div className="flex items-center justify-between mb-2">
969 <span className="hud-text text-[9px] text-[var(--text-primary)]">
970 {mobilePanel === 'layers' ? 'LAYERS & STATS' : mobilePanel === 'markets' ? 'MARKETS & INTEL' : mobilePanel === 'intel' ? 'INTEL FEED' : mobilePanel === 'recon' ? 'OSIRIS RECON' : 'SEARCH'}
971 </span>
972 <button onClick={() => setMobilePanel(null)} className="text-[var(--text-muted)] p-1"><X className="w-4 h-4" /></button>
973 </div>
974 {mobilePanel === 'layers' && (
975 <>
976 <div className="glass-panel-sm p-2 mb-2">
977 <div className="grid grid-cols-5 gap-1 text-center">
978 <div><div className="hud-label" style={{fontSize:'6px'}}>AIR</div><div className="hud-value text-[9px]">{totalFlights.toLocaleString()}</div></div>
979 <div><div className="hud-label" style={{fontSize:'6px'}}>SAT</div><div className="hud-value text-[9px]">{(data.satellites?.length||0)}</div></div>
980 <div><div className="hud-label" style={{fontSize:'6px'}}>CAM</div><div className="hud-value text-[9px]">{(data.cameras?.length||0)}</div></div>
981 <div><div className="hud-label" style={{fontSize:'6px'}}>WX</div><div className="hud-value text-[9px]" style={{color:'var(--accent-weather)'}}>{(data.weather_events?.length||0)}</div></div>
982 <div><div className="hud-label" style={{fontSize:'6px'}}>NUC</div><div className="hud-value text-[9px]" style={{color:'var(--accent-nuclear)'}}>{(data.infrastructure?.length||0)}</div></div>
983 </div>
984 </div>
985 <LayerPanel data={data} activeLayers={activeLayers} setActiveLayers={setActiveLayers} />
986 <div className="mt-2">
987 <ViewPresets onNavigate={(lat, lng, zoom) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMapView(v => ({ ...v, zoom })); setMobilePanel(null); }} />
988 </div>
989 </>
990 )}
991 {mobilePanel === 'markets' && <MarketsPanel data={data} spaceWeather={spaceWeather} />}
992 {mobilePanel === 'intel' && <IntelFeed data={data} onLocate={(lat, lng) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMobilePanel(null); }} />}
993 {mobilePanel === 'search' && (
994 <div className="space-y-2">
995 <SearchBar onLocate={(lat, lng) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMobilePanel(null); }} />
996 <SharePanel mapView={mapView} activeLayers={activeLayers} mouseCoords={null} />
997 </div>
998 )}
999 {mobilePanel === 'recon' && (
1000 <div className="space-y-2">
1001 <OsintPanel isOpen={true} onClose={() => setMobilePanel(null)} isMobile={true} onSweepVisualize={setSweepData} />
1002 </div>
1003 )}
1004 </div>
1005 </motion.div>
1006 )}
1007 </AnimatePresence>
1008 </>
1009 )}
1010
1011 {/* ── BOTTOM CENTER (desktop) ── */}
1012 {!isMobile && (
1013 <motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: 3, duration: 0.8 }} className="desktop-only absolute bottom-5 left-1/2 -translate-x-1/2 z-[200] pointer-events-auto">
1014 <div className="glass-panel px-5 py-2.5 flex items-center gap-0 osiris-glow relative overflow-hidden" style={{ borderImage: 'linear-gradient(90deg, rgba(212,175,55,0.05), rgba(212,175,55,0.2), rgba(212,175,55,0.05)) 1', borderImageSlice: 1, borderWidth: '1px', borderStyle: 'solid' }}>
1015
1016 {/* Animated scan line sweeping across the bar */}
1017 <div className="absolute inset-0 pointer-events-none overflow-hidden" aria-hidden="true">
1018 <div className="absolute top-0 bottom-0 w-[60px] bg-gradient-to-r from-transparent via-[var(--gold-primary)]/[0.07] to-transparent" style={{ animation: 'hud-scanline 4s ease-in-out infinite' }} />
1019 </div>
1020
1021 {/* COORDINATES */}
1022 <div className="flex flex-col items-center min-w-[110px] px-3">
1023 <div className="hud-label">COORDINATES</div>
1024 <div ref={coordsDisplayRef} className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tracking-wide tabular-nums">—</div>
1025 </div>
1026
1027 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1028
1029 {/* LOCATION */}
1030 <div className="flex flex-col items-center min-w-[160px] max-w-[280px] px-3">
1031 <div className="hud-label">LOCATION</div>
1032 <div className="text-[9px] text-[var(--text-secondary)] font-mono truncate max-w-[280px]">{locationLabel || 'Hover over map...'}</div>
1033 </div>
1034
1035 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1036
1037 {/* ZOOM */}
1038 <div className="flex flex-col items-center px-3">
1039 <div className="hud-label">ZOOM</div>
1040 <div className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tabular-nums">{mapView.zoom.toFixed(1)}</div>
1041 </div>
1042
1043 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1044
1045 {/* ACTIVE LAYERS */}
1046 <div className="flex flex-col items-center px-3 min-w-[60px]">
1047 <div className="hud-label">ACTIVE LAYERS</div>
1048 <div className="flex items-center gap-1">
1049 <Layers className="w-3 h-3 text-[var(--gold-primary)]" />
1050 <span className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tabular-nums">{Object.values(activeLayers).filter(Boolean).length}</span>
1051 </div>
1052 </div>
1053
1054 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1055
1056 {/* DATA FEEDS */}
1057 <div className="flex flex-col items-center px-3 min-w-[60px]">
1058 <div className="hud-label">FEEDS</div>
1059 <div className="flex items-center gap-1">
1060 <Activity className="w-3 h-3 text-[var(--cyan-primary)]" />
1061 <span className="text-[10px] font-mono font-bold text-[var(--cyan-primary)] tabular-nums">{Object.values(activeLayers).filter(Boolean).length}</span>
1062 </div>
1063 </div>
1064
1065 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1066
1067 {/* ENTITIES */}
1068 <div className="flex flex-col items-center px-3 min-w-[70px]">
1069 <div className="hud-label">ENTITIES</div>
1070 <div className="flex items-center gap-1">
1071 <Database className="w-3 h-3 text-[var(--alert-green)]" />
1072 <ActiveEntityCount data={data} />
1073 </div>
1074 </div>
1075
1076 </div>
1077 </motion.div>
1078 )}
1079
1080 {/* ── Scale Bar (desktop) ── */}
1081 <div className="desktop-only absolute bottom-[4.5rem] left-[20rem] z-[201] pointer-events-none">
1082 <ScaleBar zoom={mapView.zoom} latitude={mapView.latitude} />
1083 </div>
1084
1085 {/* ── Region Dossier ── */}
1086 {(regionDossier || dossierLoading) && (
1087 <motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} className="absolute top-16 md:top-20 left-2 right-2 md:left-1/2 md:right-auto md:-translate-x-1/2 z-[300] md:w-[480px] max-h-[65vh] overflow-y-auto styled-scrollbar">
1088 <div className="glass-panel p-5 osiris-glow">
1089 <div className="flex items-center justify-between mb-3">
1090 <h2 className="text-sm font-mono font-bold text-[var(--gold-primary)] tracking-wider">REGION DOSSIER</h2>
1091 <button onClick={() => { setRegionDossier(null); setDossierLoading(false); }} className="text-[var(--text-muted)] hover:text-[var(--text-primary)] text-xs">✕</button>
1092 </div>
1093 {dossierLoading ? (
1094 <div className="text-center py-8">
1095 <div className="w-5 h-5 border-2 border-[var(--gold-primary)] border-t-transparent rounded-full animate-spin mx-auto mb-2" />
1096 <span className="text-[8px] font-mono text-[var(--text-muted)] tracking-widest">COMPILING INTEL...</span>
1097 </div>
1098 ) : regionDossier && (
1099 <div className="space-y-3">
1100 <div><div className="hud-label mb-0.5">LOCATION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.location?.display_name}</div></div>
1101 {regionDossier.country && (
1102 <div className="grid grid-cols-2 gap-2">
1103 <div><div className="hud-label mb-0.5">COUNTRY</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.flag} {regionDossier.country.name}</div></div>
1104 <div><div className="hud-label mb-0.5">CAPITAL</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.capital}</div></div>
1105 <div><div className="hud-label mb-0.5">POPULATION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.population?.toLocaleString()}</div></div>
1106 <div><div className="hud-label mb-0.5">REGION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.subregion || regionDossier.country.region}</div></div>
1107 <div><div className="hud-label mb-0.5">LANGUAGES</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.languages?.join(', ')}</div></div>
1108 <div><div className="hud-label mb-0.5">AREA</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.area?.toLocaleString()} km²</div></div>
1109 </div>
1110 )}
1111 {regionDossier.head_of_state && (<div><div className="hud-label mb-0.5">HEAD OF STATE</div><div className="text-xs text-[var(--gold-primary)]">{regionDossier.head_of_state.name}</div><div className="text-[8px] text-[var(--text-muted)]">{regionDossier.head_of_state.position}</div></div>)}
1112 {regionDossier.wikipedia && (<div><div className="hud-label mb-1">INTELLIGENCE BRIEF</div><div className="flex gap-3">{regionDossier.wikipedia.thumbnail && <img src={regionDossier.wikipedia.thumbnail} alt="" className="w-14 h-14 rounded object-cover flex-shrink-0" />}<p className="text-[8px] text-[var(--text-secondary)] leading-relaxed">{regionDossier.wikipedia.extract}</p></div></div>)}
1113 </div>
1114 )}
1115 </div>
1116 </motion.div>
1117 )}
1118
1119 {/* ── Camera Viewer ── */}
1120 <CameraViewer
1121 camera={activeCamera}
1122 onClose={() => setActiveCamera(null)}
1123 onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })}
1124 />
1125
1126
1127 {/* ── OVERLAYS ── */}
1128 <div className="vignette absolute inset-0 pointer-events-none z-[2]" />
1129 <div className="crt-scanlines absolute inset-0 pointer-events-none z-[3] opacity-[0.02]" />
1130 {/* Corner frames — using explicit classes for Tailwind JIT compatibility */}
1131 {[
1132 { pos: 'top-0 left-0', vAnchor: 'top-0', hAnchor: 'left-0', hGrad: 'bg-gradient-to-r', vGrad: 'bg-gradient-to-b' },
1133 { pos: 'top-0 right-0', vAnchor: 'top-0', hAnchor: 'right-0', hGrad: 'bg-gradient-to-l', vGrad: 'bg-gradient-to-b' },
1134 { pos: 'bottom-0 left-0', vAnchor: 'bottom-0', hAnchor: 'left-0', hGrad: 'bg-gradient-to-r', vGrad: 'bg-gradient-to-t' },
1135 { pos: 'bottom-0 right-0', vAnchor: 'bottom-0', hAnchor: 'right-0', hGrad: 'bg-gradient-to-l', vGrad: 'bg-gradient-to-t' },
1136 ].map((c, i) => (
1137 <div key={i} className={`absolute ${c.pos} w-16 h-16 pointer-events-none z-[1]`}>
1138 <div className={`absolute ${c.vAnchor} ${c.hAnchor} w-full h-[1px] ${c.hGrad} from-[var(--gold-primary)]/30 to-transparent`} />
1139 <div className={`absolute ${c.vAnchor} ${c.hAnchor} w-[1px] h-full ${c.vGrad} from-[var(--gold-primary)]/30 to-transparent`} />
1140 </div>
1141 ))}
1142
1143 {/* Keyboard Shortcuts Overlay */}
1144 <KeyboardShortcuts />
1145
1146 {/* ── GLOBAL STATUS TICKER (bottom) ── */}
1147 <GlobalStatusBar />
1148
1149 {/* Shortcut hint */}
1150 <div className="desktop-only absolute bottom-[26px] right-5 z-[200] pointer-events-none text-[6px] font-mono text-[var(--text-muted)]/40 tracking-widest">
1151 [?] SHORTCUTS · [F] FULLSCREEN · [S] SHARE · [R] RESET VIEW
1152 </div>
1153
1154
1155 </main>
1156 );
1157}