import { bandAxisStyle } from "./bandAxisStyle.js";
import { createFormatterByDimension } from "../../../../utils/index.js";
const heatmapBandAxis = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed, vseed } = context;
    const { chartType } = vseed;
    const { dimensions = [], encoding } = advancedVSeed;
    const xAxisConfig = advancedVSeed.config?.[chartType]?.xAxis ?? {};
    const yAxisConfig = advancedVSeed.config?.[chartType]?.yAxis ?? {};
    const xBandAxis = bandAxisStyle(xAxisConfig);
    const yBandAxis = bandAxisStyle(yAxisConfig);
    xBandAxis.orient = 'bottom';
    xBandAxis.bandPadding = 0;
    yBandAxis.orient = 'left';
    yBandAxis.bandPadding = 0;
    const formatBandLabel = (axis)=>{
        const dimIds = ('x' === axis ? encoding.x : encoding.y) || [];
        const dimFormatter = dimIds.length ? createFormatterByDimension(dimensions.find((item)=>item.id === dimIds[0]), advancedVSeed.locale) : null;
        return (text)=>{
            if (Array.isArray(text)) return text;
            const rawText = String(text ?? '');
            if (!dimFormatter) return rawText;
            return dimFormatter(rawText);
        };
    };
    if (xBandAxis.label) xBandAxis.label.formatMethod = formatBandLabel('x');
    if (yBandAxis.label) yBandAxis.label.formatMethod = formatBandLabel('y');
    result.axes = [
        xBandAxis,
        yBandAxis
    ];
    return result;
};
export { heatmapBandAxis };

//# sourceMappingURL=heatmapBandAxis.js.map