// A product's allergens for staff and guests (plan step 6.3): one small chip each, what it // contains first (warning tone), then what it may contain (outlined), under a title. Styled with // the @xenia/ui tokens inline, so every app (waiter, terminal, manager) shows it the same way. // Nothing when none are declared, unless `showNone`. import { useTranslation } from '@xenia/i18n' import { allergenList } from './allergens.js' const chip = level => ({ display: 'inline-flex', alignItems: 'center', gap: 4, padding: '2px 8px', borderRadius: 999, fontSize: 'var(--x-text-caption)', fontWeight: 600, lineHeight: 1.6, ...(level === 'contains' ? { background: 'var(--x-warning-soft)', color: 'var(--x-warning-ink)', border: '1px solid transparent' } : { background: 'transparent', color: 'var(--x-ink-2)', border: '1px dashed var(--x-line-strong)' }), }) export function Allergens({ allergens, showNone = false, title = true, className, style }) { const { t } = useTranslation('common') const items = allergenList(allergens) if (items.length === 0 && !showNone) return null const groups = ['contains', 'may_contain'].map(level => [level, items.filter(i => i.level === level)]).filter(([, list]) => list.length) return (