// aerOS Guest v3 — in-menu guest-facing Settings sheet. Lets guests change theme, currency, layout, catNav + content toggles.
function G3Seg({ value, onChange, options, C, cols }) {
return (
{options.map(([v, l]) => { const on = value === v; return (
onChange(v)} style={{ flex: cols ? undefined : 1, padding: '10px 8px', borderRadius: 10, border: 'none', background: on ? `linear-gradient(180deg, ${C.accent}, ${C.accentDark})` : 'transparent', color: on ? C.accentInk : C.ink2, fontSize: 13.5, fontWeight: 700, cursor: 'pointer', fontFamily: G2THEME.BODY_FONT, transition: 'all 150ms', boxShadow: on ? `0 4px 12px -5px ${C.accent}` : 'none' }}>{l}
); })}
);
}
function G3Toggle({ label, value, onChange, C }) {
return (
{label}
onChange(!value)} role="switch" aria-checked={value} style={{ position: 'relative', width: 46, height: 28, borderRadius: 999, border: 'none', background: value ? C.accent : (C.dark ? 'rgba(255,255,255,0.16)' : 'rgba(0,0,0,0.18)'), cursor: 'pointer', transition: 'background 180ms', flexShrink: 0 }}>
);
}
function G3SettingsSheet({ open, onClose, C, t, tw, setS, animate, lang }) {
const label = { display: 'flex', alignItems: 'center', gap: 7, fontSize: 12, fontWeight: 700, color: C.muted, textTransform: 'uppercase', letterSpacing: '0.05em', margin: '20px 0 11px' };
const en = lang === 'en';
const [iosHelp, setIosHelp] = React.useState(false);
const [pushMsg, setPushMsg] = React.useState(null);
const enablePush = async () => {
if (!window.G2PUSH || !window.G2PUSH.supported) { setPushMsg(en ? 'Notifications not supported on this device.' : 'Bu cihazda bildirim desteklenmiyor.'); return; }
const r = await window.G2PUSH.enable();
if (r.ok) setPushMsg(en ? 'Notifications enabled.' : 'Bildirimler açıldı.');
else if (r.reason === 'insecure') setPushMsg(en ? 'Needs HTTPS or an installed app.' : 'HTTPS ya da kurulu uygulama gerekir.');
else if (r.reason === 'denied') setPushMsg(en ? 'Permission denied.' : 'İzin verilmedi.');
else setPushMsg(en ? 'Could not enable notifications.' : 'Bildirimler açılamadı.');
};
const isStandalone = (typeof navigator !== 'undefined' && navigator.standalone) || (typeof matchMedia !== 'undefined' && matchMedia('(display-mode: standalone)').matches);
const isIOS = typeof navigator !== 'undefined' && /iphone|ipad|ipod/i.test(navigator.userAgent || '');
const addToHome = async () => {
if (isStandalone) { setIosHelp(false); return; }
const p = window.__a2hsPrompt;
if (p) { try { p.prompt(); await p.userChoice; window.__a2hsPrompt = null; } catch (e) {} return; }
setIosHelp(v => !v); // iOS Safari can't trigger programmatically — show how-to
};
return (
{Icon.settings({ size: 22 })}
{Icon.x({ size: 18 })}
{Icon.sun({ size: 14 })}{t.setTheme}
setS('theme', v)} C={C} options={[['dark', lang === 'en' ? 'Dark' : 'Koyu'], ['light', lang === 'en' ? 'Light' : 'Açık']]} />
{Icon.dollar({ size: 14 })}{t.setCurrency}
setS('currency', v)} C={C} options={[['₺', '₺ TL'], ['$', '$ USD'], ['€', '€ EUR']]} />
{Icon.grid({ size: 14 })}{t.setLayout}
setS('layout', v)} C={C} cols={2} options={[['gallery', t.layGallery], ['list', t.layList], ['magazine', t.layMagazine], ['text', t.layText]]} />
{Icon.menu({ size: 14 })}{t.setCatNav}
setS('catNav', v)} C={C} options={[['pills', t.navPills], ['tabs', t.navTabs]]} />
{Icon.layers({ size: 14 })}{t.setContent}
{[['featured', t.optFeatured], ['showBadge', t.optBadge], ['showDiet', t.optDiet], ['showCal', t.optCal], ['showPrice', t.optPrice], ['animate', t.optAnim]].map(([k, l], i, arr) => (
setS(k, v)} C={C} />
))}
{Icon.home({ size: 14 })}{en ? 'App' : 'Uygulama'}
{isStandalone ? (
{Icon.checkCircle ? Icon.checkCircle({ size: 16 }) : Icon.check({ size: 16 })}{en ? 'Running as an installed app.' : 'Uygulama olarak çalışıyor.'}
) : (
<>
{en ? 'Add to Home Screen' : 'Ana ekrana ekle'}
{iosHelp && isIOS && (
{en
? <>Tap the Share button below, then choose Add to Home Screen . The app opens full-screen, no browser bars.>
: <>Alttaki Paylaş butonuna dokun, sonra Ana Ekrana Ekle 'yi seç. Uygulama tam ekran açılır, tarayıcı çubukları olmaz.>}
)}
>
)}
{Icon.bell({ size: 14 })}{en ? 'Notifications' : 'Bildirimler'}
{en ? 'Enable notifications' : 'Bildirimleri aç'}
{pushMsg && {pushMsg}
}
{t.close}
);
}
window.G3SettingsSheet = G3SettingsSheet;