import { isNil } from "@visactor/vutils";
import { MeasureId } from "../../../../../dataReshape/index.js";
import { BAND_AXIS_INNER_OFFSET_IN_PIVOT, ChartTypeEnum } from "../../../../utils/constant.js";
const pivotAxisStyle = (axisStyle)=>(spec, context)=>{
        const result = axisStyle(spec, context);
        if (result.axes) {
            const { advancedVSeed } = context;
            const { config, chartType, encoding, reshapeMeasures, datasetReshapeInfo } = advancedVSeed;
            const themConfig = config?.[chartType]?.pivotGrid ?? {};
            result.axes.forEach((axis)=>{
                axis.domainLine = {
                    visible: false
                };
                if (themConfig.chartGridColor && axis.grid && axis.grid.visible && axis.grid.style) axis.grid.style.stroke = themConfig.chartGridColor;
                if (themConfig.axisLabelColor && axis.label && axis.label.visible && axis.label.style) axis.label.style.fill = themConfig.axisLabelColor;
                if (themConfig.axisLabelFontSize && axis.label && axis.label.visible && axis.label.style) axis.label.style.fontSize = themConfig.axisLabelFontSize;
                if ('band' === axis.type) {
                    if ('left' === axis.orient || 'right' === axis.orient) {
                        axis.innerOffset = {
                            top: BAND_AXIS_INNER_OFFSET_IN_PIVOT,
                            bottom: BAND_AXIS_INNER_OFFSET_IN_PIVOT
                        };
                        if (reshapeMeasures && reshapeMeasures.length > 1 && chartType === ChartTypeEnum.Heatmap && isNil(axis.title.text)) {
                            axis.title.visible = true;
                            axis.title.text = Object.values(datasetReshapeInfo[0].foldInfo.foldMap)[0];
                        }
                    } else if ('top' === axis.orient || 'bottom' === axis.orient) axis.innerOffset = {
                        left: BAND_AXIS_INNER_OFFSET_IN_PIVOT,
                        right: BAND_AXIS_INNER_OFFSET_IN_PIVOT
                    };
                } else if ('linear' === axis.type) {
                    if ('top' === axis.orient || 'bottom' === axis.orient) axis.label.flush = true;
                    if (reshapeMeasures && reshapeMeasures.length > 1 && axis.title.text && encoding.color && encoding.color.length && !encoding.color.includes(MeasureId)) axis.title.visible = true;
                }
            });
        }
        return result;
    };
export { pivotAxisStyle };

//# sourceMappingURL=pivotAxisStyle.js.map