import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom/client'
import maplibregl from 'maplibre-gl'
import App from './App.tsx'
import CompareView from './pages/CompareView'
import IntelligenceDashboard from './pages/IntelligenceDashboard'
import { ExecutiveShowcase } from './pages/ExecutiveShowcase'
import { TacticalDefenseView } from './pages/TacticalDefenseView'
import './index.css'
maplibregl.setRTLTextPlugin(
'https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js',
(err) => { if (err) console.error(err); },
true
);
// Lightweight hash router with Sovereign Executive Styling
const NAV = [
{ hash: '#tactical', label: 'المنظومة التكتيكية العسكرية', icon: '🎖️' },
{ hash: '#map', label: 'الخريطة والطقس والملاحة', icon: '🗺️' },
{ hash: '#compare', label: 'مقارنة العمالقة والأسعار', icon: '⚖️' },
{ hash: '#review', label: 'تدقيق الطرق الذكي', icon: '🔍' },
]
function MasterHeader({ hash }: { hash: string }) {
const currentHash = hash || '#tactical'
const [isFullscreen, setIsFullscreen] = useState(false);
const toggleFullscreen = () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {});
setIsFullscreen(true);
} else {
document.exitFullscreen().catch(() => {});
setIsFullscreen(false);
}
};
return (
{/* Right Section: Brand & Sovereign Security Clearance */}
{/* Center Section: Master Navigation Segmented Controller */}
{/* Left Section: Live Sovereign Telemetry & Fullscreen */}
السحابة السيادية متصلة
)
}
class ErrorBoundary extends React.Component<{ children: React.ReactNode }, { hasError: boolean; error: any }> {
constructor(props: any) {
super(props);
this.state = { hasError: false, error: null };
}
static getDerivedStateFromError(error: any) {
return { hasError: true, error };
}
componentDidCatch(error: any, errorInfo: any) {
console.error('App UI Error:', error, errorInfo);
}
render() {
if (this.state.hasError) {
return (
⚠️
حدث خطأ أثناء تحميل الواجهة
{this.state.error?.message || 'تعذر تحميل أحد مكونات الخريطة'}
);
}
return this.props.children;
}
}
function Root() {
const [hash, setHash] = useState(window.location.hash || '#tactical');
useEffect(() => {
const on = () => {
const h = window.location.hash || '#tactical';
setHash(h);
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 50);
};
window.addEventListener('hashchange', on);
return () => window.removeEventListener('hashchange', on);
}, []);
const isTactical = hash === '#tactical' || hash === '#military' || hash === '' || hash === '#siro';
const isExecutive = hash === '#showcase' || hash === '#pitch';
const isCompare = hash === '#compare';
const isReview = hash === '#review';
const isMap = hash === '#map';
return (
{isTactical && (
)}
{isExecutive && (
)}
{isCompare && (
)}
{isReview && (
)}
{isMap && (
)}
);
}
ReactDOM.createRoot(document.getElementById('root')!).render();