// Polyfill for Object.groupBy (requires Node.js 21+, we're on 20) // This must be imported before any code that uses Object.groupBy if (typeof Object.groupBy === 'undefined') { Object.groupBy = (items, keyFn) => { const result = {} let index = 0 for (const item of items) { const key = keyFn(item, index++) ;(result[key] ??= []).push(item) } return result } }