"use strict";
/**
 * ChromaDB vector DB RAG parser.
 * Detects Chroma spans (db.system, service.name, or span name) and returns standard RAGCall[].
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.chromaDbRagParser = void 0;
const utils_1 = require("../utils");
const SYSTEM_NAME = 'chromadb';
const DB_SYSTEM = 'db.system';
const DB_SYSTEM_NAME = 'db.system.name';
function isChromaSpan(span) {
    const attrs = span.attributes ?? {};
    const res = span.resourceAttributes ?? {};
    const sys = attrs[DB_SYSTEM_NAME] ?? attrs[DB_SYSTEM] ?? res[DB_SYSTEM_NAME] ?? res[DB_SYSTEM];
    if (sys != null && String(sys).toLowerCase().includes('chroma'))
        return true;
    const name = (span.name ?? '').toLowerCase();
    const svc = (span.serviceName ?? '').toLowerCase();
    return name.includes('chroma') || svc.includes('chroma');
}
exports.chromaDbRagParser = {
    name: 'chromadb',
    canParse(spans) {
        return (spans ?? []).some(isChromaSpan);
    },
    parse(spans) {
        return (spans ?? [])
            .filter(isChromaSpan)
            .map((span) => (0, utils_1.buildRAGCall)(span, { systemName: SYSTEM_NAME }));
    },
};
//# sourceMappingURL=chromaDb.js.map