SLG7VW6USOECVMYSDTUY6SJOAW6NMPTBP24CRDSHTCTTQ5PF35DQC // Process species data with Map for better performanceconst speciesMap = new Map<string, Array<{id: string;label: string;ebirdCode: string | null;description: string | null;}>>();
// Get the current species array for this fileconst fileSpecies = speciesMap.get(item.fileId)!;// Check if we already have this species (deduplication)const existingSpeciesIndex = fileSpecies.findIndex(s => s.id === item.speciesId);if (existingSpeciesIndex === -1) {// Add species if it doesn't already exist for this filefileSpecies.push({
// Find existing species entry or create new onelet existingSpecies = acc[item.fileId].find(s => s.id === item.speciesId);if (!existingSpecies) {existingSpecies = {
});
// Add call type if present and not already addedif (item.callTypeId && item.callTypeName) {const existingCallType = existingSpecies.callTypes.find(ct => ct.id === item.callTypeId);if (!existingCallType) {existingSpecies.callTypes.push({id: item.callTypeId,name: item.callTypeName});}}return acc;}, {} as Record<string, Array<{id: string;label: string;ebirdCode: string | null;description: string | null;callTypes: Array<{id: string;name: string;}>;}>>);