import { make } from 'effect/unstable/reactivity/Atom'; import { ActiveBranch } from '../../ActiveBranch.ts'; export const activeBranchCustomMessagesByType = (branch: ActiveBranch.Value) => branch.entries .filter( (entry): entry is ActiveBranch.CustomMessageEntry => entry instanceof ActiveBranch.CustomMessageEntry ) .reduce< ReadonlyMap> >( (grouped, entry) => new Map(grouped).set(entry.customType, [ ...(grouped.get(entry.customType) ?? []), entry ]), new Map>() ); export const activeBranchCustomMessagesByTypeAtom = ( branch: ActiveBranch.Value ) => make(activeBranchCustomMessagesByType(branch));