// aerOS — admin app shell: sidebar + topbar + theme/lang hook. Exports to window. const { useState: _hS, useEffect: _hE, useCallback: _hC } = React; /* persisted theme + language (single localStorage key) */ function useUI(storeKey = 'aeros-ui') { const [ui, setUi] = _hS(() => { try { return { theme: 'light', lang: 'tr', ...JSON.parse(localStorage.getItem(storeKey) || '{}') }; } catch { return { theme: 'light', lang: 'tr' }; } }); _hE(() => { document.documentElement.setAttribute('data-theme', ui.theme); document.documentElement.setAttribute('lang', ui.lang); try { localStorage.setItem(storeKey, JSON.stringify(ui)); } catch {} }, [ui, storeKey]); const setTheme = t => setUi(s => ({ ...s, theme: t })); const setLang = l => setUi(s => ({ ...s, lang: l })); return { theme: ui.theme, lang: ui.lang, setTheme, setLang, toggleTheme: () => setUi(s => ({ ...s, theme: s.theme === 'light' ? 'dark' : 'light' })) }; } /* compact lang + theme controls for topbars */ function LangThemeControls({ ui, langs = [['tr', 'TR'], ['en', 'EN']] }) { const [open, setOpen] = _hS(false); return (
{open && (
{langs.map(([code, label]) => ( ))}
)}
); } /* AppShell: responsive sidebar + topbar. props: brand {name, sub, logo, color}, nav [{section, items:[{id,label,icon,badge}]}], active, onNav, topRight, title, ui, banner */ function AppShell({ brand, nav, active, onNav, topRight, title, subtitle, children, banner, footer }) { const [mobileOpen, setMobileOpen] = _hS(false); const [narrow, setNarrow] = _hS(typeof window !== 'undefined' && window.innerWidth < 980); _hE(() => { const onR = () => setNarrow(window.innerWidth < 980); window.addEventListener('resize', onR); return () => window.removeEventListener('resize', onR); }, []); const SIDEBAR_W = 250; const Sidebar = ( ); return (
{!narrow && Sidebar} {narrow && mobileOpen && (
{ if (e.target === e.currentTarget) setMobileOpen(false); }} style={{ position: 'fixed', inset: 0, background: 'rgba(15,23,42,0.5)', zIndex: 500, display: 'flex' }}>
{Sidebar}
)}
{narrow && setMobileOpen(true)} />}
{title &&

{title}

} {subtitle &&
{subtitle}
}
{topRight}
{banner}
{children}
); } Object.assign(window, { useUI, LangThemeControls, AppShell });