import { clone } from "remeda";
import { findAllMeasures, isDimension, preorderTraverse } from "../../../../utils/index.js";
const defaultDimensions = (advancedVSeed, context)=>{
    const result = {
        ...advancedVSeed
    };
    const { vseed } = context;
    const { dimensions, dataset } = vseed;
    if (dimensions && dimensions.length > 0) {
        const clonedDimensions = clone(dimensions);
        preorderTraverse(clonedDimensions, (node)=>{
            if (isDimension(node)) node.alias = node.alias || node.id;
            return false;
        });
        return {
            ...advancedVSeed,
            dimensionTree: clonedDimensions
        };
    }
    const measures = findAllMeasures(advancedVSeed.measureTree);
    const top100dataset = dataset.slice(0, 100);
    const sample = top100dataset.reduce((prev, cur)=>({
            ...prev,
            ...cur
        }), {});
    const newDimensions = Object.keys(sample).filter((key)=>top100dataset.some((item)=>'string' == typeof item[key]) && ![
            '',
            null,
            void 0
        ].includes(key) && !measures.some((measure)=>measure.id === key)).map((dim)=>({
            id: dim,
            alias: dim
        }));
    return {
        ...result,
        dimensionTree: newDimensions
    };
};
export { defaultDimensions };

//# sourceMappingURL=defaultDimensions.js.map