/**
 * Facet generation for query results
 */
/**
 * Generate facets (counts by category) for filtered log entries
 */
export function generateFacets(entries) {
    const facets = {
        levels: {},
        sources: {},
        tags: {},
        errorTypes: {},
        hours: {},
    };
    for (const entry of entries) {
        // Level facet
        facets.levels[entry.level] = (facets.levels[entry.level] || 0) + 1;
        // Source facet
        if (entry.source) {
            facets.sources[entry.source] = (facets.sources[entry.source] || 0) + 1;
        }
        // Tags facet
        if (entry.tags) {
            for (const tag of entry.tags) {
                facets.tags[tag] = (facets.tags[tag] || 0) + 1;
            }
        }
        // Error type facet
        if (entry.error?.type) {
            facets.errorTypes[entry.error.type] =
                (facets.errorTypes[entry.error.type] || 0) + 1;
        }
        // Hour facet
        const hour = new Date(entry.timestamp).toISOString().substring(0, 13);
        facets.hours[hour] = (facets.hours[hour] || 0) + 1;
    }
    return facets;
}
//# sourceMappingURL=facet-generator.js.map