import { AiResultType } from '../../types';
import { getVerticalBarChartEchartsConfig } from './generateBarVizConfigTool/getVerticalBarChartEchartsConfig';
import { getTimeSeriesChartEchartsConfig } from './generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig';
import { getRunQueryEchartsConfig } from './runQueryTool/getRunQueryEchartsConfig';
/**
 * Main function to generate echarts config for Slack AI agents
 * Decides which specific echarts config function to use based on the tool type
 *
 * @param toolArgs - Discriminated union of tool arguments with type
 * @param queryResults - Query results from running the query
 * @param getPivotedResults - Function to pivot data (backend dependency)
 * @returns EChartsOption | null
 */
export const getSlackAiEchartsConfig = async ({ toolArgs, queryResults, getPivotedResults, }) => {
    // Empty data - don't render
    if (queryResults.rows.length === 0) {
        return null;
    }
    switch (toolArgs.type) {
        case AiResultType.QUERY_RESULT:
            return getRunQueryEchartsConfig(toolArgs.tool, queryResults, getPivotedResults);
        case AiResultType.TIME_SERIES_RESULT:
            return getTimeSeriesChartEchartsConfig(toolArgs.tool, queryResults.rows, queryResults.fields, toolArgs.tool.vizConfig.sorts, getPivotedResults);
        case AiResultType.VERTICAL_BAR_RESULT:
            return getVerticalBarChartEchartsConfig(toolArgs.tool, queryResults.rows, queryResults.fields, toolArgs.tool.vizConfig.sorts, getPivotedResults);
        case AiResultType.TABLE_RESULT:
            // Tables don't render as echarts images
            return null;
        default:
            return null;
    }
};
//# sourceMappingURL=getSlackAiEchartsConfig.js.map