import type { Group, Space } from "@rakazo/contracts"; /** Project-scoped group chats in a space (excludes the main conversation). */ export function projectGroupChatsInSpace( groups: readonly Pick[], spaceId: string, ): readonly Pick[] { return groups.filter((group) => group.spaceId === spaceId && group.kind !== "main"); } /** Non-default project space with no project group conversations yet. */ export function isEmptyProjectSpace( spaceId: string | null | undefined, spaces: readonly Pick[], groups: readonly Pick[], homeSpaceId: string | undefined, ): boolean { if (!spaceId || !homeSpaceId || spaceId === homeSpaceId) return false; const space = spaces.find((item) => item.id === spaceId); if (!space || space.isDefault) return false; return projectGroupChatsInSpace(groups, spaceId).length === 0; }