import { type ActionMenuItem } from "./ActionMenu"; /** One menu from its groups, a rule between each two that are not empty: the first row of every * group but the first carries `separatorBefore`. An empty group leaves no rule behind, so a row * that a job's kind or state takes out cannot strand a divider at the top or doubled in the middle. */ export function menuGroups(...groups: readonly (readonly ActionMenuItem[])[]): ActionMenuItem[] { return groups .filter((g) => g.length > 0) .flatMap((g, gi) => g.map((it, i) => (i === 0 && gi > 0 ? { ...it, separatorBefore: true } : it)), ); }