// aerOS Guest v2 — Product detail sheet + Filter sheet + Waiter call sheet.
const { useState: _pr2S, useEffect: _pr2E } = React;
function G2ProductSheet({ product, C, t, lang, tw, onClose, onAdd, animate }) {
const [qty, setQty] = _pr2S(1);
const [portion, setPortion] = _pr2S(null);
const [mods, setMods] = _pr2S([]);
const [note, setNote] = _pr2S('');
const [allInfo, setAllInfo] = _pr2S(false);
_pr2E(() => { if (product) { setQty(1); setPortion(product.portions[0]?.id || null); setMods([]); setNote(''); setAllInfo(false); } }, [product]);
if (!product) return null;
const D = window.G2DATA;
const name = lang === 'en' ? product.en : product.name;
const desc = lang === 'en' ? product.en_desc : product.desc;
const portObj = product.portions.find(p => p.id === portion);
const modSum = product.mods.filter(m => mods.includes(m.id)).reduce((s, m) => s + (m.price || 0), 0);
const unit = product.price + (portObj?.price || 0) + modSum;
const toggleMod = id => setMods(m => m.includes(id) ? m.filter(x => x !== id) : [...m, id]);
const lbl = o => lang === 'en' ? (o.en || o.label) : o.label;
const optRow = (selected, isRadio, label, price, onClick) => (
);
return (
{tw.showBadge && product.badge &&
}
{name}
{tw.showPrice && {G2THEME.money(product.price, tw.currency)}}
{desc}
{/* meta row: diet + cal + prep */}
{tw.showDiet && }
{product.cal != null && {Icon.flame({ size: 15, style: { color: C.muted } })}{product.cal} {t.cal}}
{product.prep != null && {Icon.clock({ size: 15, style: { color: C.muted } })}{product.prep} {t.prepTime}}
{product.allergens.length > 0 && (
{t.allergens}
{product.allergens.map(a => )}
)}
{product.portions.length > 0 && (
{t.size}
{product.portions.map(p => optRow(portion === p.id, true, lbl(p), p.price, () => setPortion(p.id)))}
)}
{product.mods.length > 0 && (
{t.extras}
{product.mods.map(m => optRow(mods.includes(m.id), false, lbl(m), m.price, () => toggleMod(m.id)))}
)}
onAdd({ id: product.id + '-' + Date.now(), pid: product.id, name, qty, unit, portionLabel: portObj && lbl(portObj), modLabels: product.mods.filter(m => mods.includes(m.id)).map(lbl), note, color: product.color })}>
{tw.mode === 'view' ? t.add : t.addToCart} · {G2THEME.money(unit * qty, tw.currency)}
{/* allergen info popup */}
{allInfo && (
{ if (e.target === e.currentTarget) setAllInfo(false); }} style={{ position: 'absolute', inset: 0, background: 'rgba(8,6,4,0.6)', backdropFilter: 'blur(4px)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 22, zIndex: 90, animation: animate ? 'g2fade .2s ease' : 'none' }}>
{Icon.info({ size: 19 })}
{t.allergenInfo}
{product.allergens.map(a => { const ic = ALLERGEN_ICON[((window.G2DATA.ALLERGEN_ICOKEY || {})[a]) || a] || Icon.info; return (
{ic({ size: 21 })}
{D.ALLERGENS[a]}
{(D.ALLERGEN_DESC[lang] || D.ALLERGEN_DESC.tr)[a]}
); })}
{Icon.alert({ size: 15, style: { flexShrink: 0, marginTop: 1 } })}{t.allergenNote}
)}
);
}
function G2FilterSheet({ open, onClose, C, t, tw, diet, toggleDiet, counts, priceMax, setPriceMax, calMax, setCalMax, maxP, maxC, resultCount, onClear, animate }) {
const opts = [['veg', t.veg, 'leaf'], ['vegan', t.vegan, 'leaf'], ['gf', t.gf, 'shield'], ['spicy', t.spicy, 'flame']];
const slider = (val, set, min, max, step, fmt) => (
);
return (
{t.filters}
{t.diet}
{opts.map(([id, label, icon]) => { const on = diet.includes(id); const m = DIET_META[id]; return (
); })}
{t.priceRange}
{slider(priceMax, setPriceMax, 90, maxP, 10, v => G2THEME.money(v, tw.currency))}
{t.cal}
{slider(calMax, setCalMax, 100, maxC, 20, v => v + ' ' + t.cal)}
{t.apply}{resultCount != null ? ` · ${resultCount} ${t.items}` : ''}
);
}
function G2WaiterSheet({ open, onClose, C, t, lang, toast, tableLabel, animate }) {
const D = window.G2DATA;
return (
{Icon.headset({ size: 23 })}
{t.waiterTitle}
{tableLabel} · {t.waiterDesc}
{D.WAITER_ACTIONS.map(a => (
))}
{Icon.info({ size: 14 })}{t.onWay}
);
}
Object.assign(window, { G2ProductSheet, G2FilterSheet, G2WaiterSheet });