import { uniqueBy } from "remeda";
import { dataReshapeByEncoding } from "../../../../../dataReshape/index.js";
import { getColorMeasureId } from "../../../../spec/chart/pipes/index.js";
import { findAllMeasures } from "../../../../utils/index.js";
const reshapeWithEncoding = (advancedVSeed, context)=>{
    const result = {
        ...advancedVSeed
    };
    const { vseed } = context;
    const { dataset, chartType } = vseed;
    const { encoding } = advancedVSeed;
    const colorMeasureId = getColorMeasureId(advancedVSeed, vseed);
    const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, uniqueBy(advancedVSeed.reshapeDimensions ?? advancedVSeed.dimensions ?? [], (item)=>item.id), uniqueBy(advancedVSeed.reshapeMeasures ?? findAllMeasures(advancedVSeed.measures), (item)=>item.id), encoding, {
        colorItemAsId: false,
        colorMeasureId
    });
    return {
        ...result,
        dataset: newDatasets,
        datasetReshapeInfo: [
            {
                id: String(chartType),
                index: 0,
                foldInfo,
                unfoldInfo
            }
        ]
    };
};
export { reshapeWithEncoding };

//# sourceMappingURL=reshapeWithEncoding.js.map