1/**
 2 * Utility functions for conversation data manipulation
 3 */
 4
 5/**
 6 * Creates a map of conversation IDs to their message counts from exported conversation data
 7 * @param exportedData - Array of exported conversations with their messages
 8 * @returns Map of conversation ID to message count
 9 */
10export function createMessageCountMap(
11	exportedData: Array<{ conv: DatabaseConversation; messages: DatabaseMessage[] }>
12): Map<string, number> {
13	const countMap = new Map<string, number>();
14
15	for (const item of exportedData) {
16		countMap.set(item.conv.id, item.messages.length);
17	}
18
19	return countMap;
20}
21
22/**
23 * Gets the message count for a specific conversation from the count map
24 * @param conversationId - The ID of the conversation
25 * @param countMap - Map of conversation IDs to message counts
26 * @returns The message count, or 0 if not found
27 */
28export function getMessageCount(conversationId: string, countMap: Map<string, number>): number {
29	return countMap.get(conversationId) ?? 0;
30}