/**
 * Adapts new backend (v2) response formats to the legacy format
 * expected by existing frontend components.
 */
/**
 * Adapts a v2 `complete` event payload to the legacy `end_response` format.
 *
 * v2 format:  { content, conversation_id, tokens }
 * Legacy format: { answer, conversationId, insightId, controlData, controlType, controls, ... }
 */
export function adaptCompleteToLegacy(data) {
    return {
        answer: data.content || "",
        conversationId: data.conversation_id || "",
        insightId: data.insight_id || null,
        controlData: data.control_data || null,
        controlType: data.control_type || null,
        controls: data.controls || [],
        relevanceScore: data.relevance_score || null,
        context: data.context || [],
        didAnswer: !!data.content,
        sender: data.sender || null,
        tokens: data.tokens || null,
    };
}
/**
 * Adapts a v2 `chunk` event payload to the legacy `response` format.
 *
 * v2 format:  { content: "partial text" }
 * Legacy format: { data: "partial text" }
 */
export function adaptChunkToLegacy(data) {
    return {
        data: data.content || "",
    };
}
