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

//# sourceMappingURL=reshapeWithEncoding.js.map