import { z } from 'zod';
import { queryContextInputParser } from './utils.js';
import { getChangeLoadTimeGraph, getCycleTimeGraph, getFlowEfficiencyGraph, getNewGraph, getVelocityGraph, getWipGraph, } from './workitems2.js';
const projectOverViewStatsInputParser = z.object({
    queryContext: queryContextInputParser,
    filters: z
        .array(z.object({ label: z.string(), values: z.array(z.string()) }))
        .optional(),
});
export const getProjectOverviewStatsAsChunks = async ({ queryContext, filters }, onChunk) => {
    const sendChunk = (key) => (data) => {
        onChunk({ [key]: data });
    };
    await Promise.all([
        // getWorkItemsOverview(queryContext).then(sendChunk('workItems')),
        getNewGraph({ queryContext, filters }).then(sendChunk('newWorkItems')),
        getVelocityGraph({ queryContext, filters }).then(sendChunk('velocityWorkItems')),
        getChangeLoadTimeGraph({ queryContext, filters }).then(sendChunk('cltWorkItems')),
        getFlowEfficiencyGraph({ queryContext, filters }).then(sendChunk('flowEfficiencyWorkItems')),
        getCycleTimeGraph({ queryContext, filters }).then(sendChunk('cycleTimeWorkItems')),
        getWipGraph({ queryContext, filters }).then(sendChunk('wipTrendWorkItems')),
    ]);
};
export const getProjectOverviewStats = async ({ queryContext, filters, }) => {
    let mergedChunks = {};
    await getProjectOverviewStatsAsChunks({ queryContext, filters }, x => {
        mergedChunks = { ...mergedChunks, ...x };
    });
    return mergedChunks;
};
