import { clone } from "remeda";
import { isMeasure, preorderTraverse } from "../../../../utils/index.js";
const defaultMeasures_defaultMeasures = (advancedVSeed, context)=>{
    const { vseed } = context;
    const { measures, dataset } = vseed;
    if (measures && measures.length > 0) {
        const clonedMeasures = clone(measures);
        preorderTraverse(clonedMeasures, (node)=>{
            if (isMeasure(node)) node.alias = node.alias || node.id;
            return false;
        });
        return {
            ...advancedVSeed,
            measureTree: clonedMeasures
        };
    }
    const top100dataset = dataset.slice(0, 100);
    const sample = top100dataset.reduce((prev, cur)=>({
            ...prev,
            ...cur
        }), {});
    const defaultMeasures = Object.keys(sample).filter((key)=>top100dataset.some((item)=>'number' == typeof item[key]) && ![
            '',
            null,
            void 0
        ].includes(key)).map((measure)=>({
            id: measure,
            alias: measure
        }));
    return {
        ...advancedVSeed,
        measureTree: defaultMeasures
    };
};
export { defaultMeasures_defaultMeasures as defaultMeasures };

//# sourceMappingURL=defaultMeasures.js.map