import { defaultTitleText } from "./title/defaultTitleText.js";
import { AXIS_LABEL_SPACE } from "../../../../utils/index.js";
const xBand = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed, vseed } = context;
    const { chartType } = vseed;
    const { measures, dimensions, encoding } = advancedVSeed;
    const config = advancedVSeed.config?.[chartType]?.xAxis;
    if (!result.axes) result.axes = [];
    const { visible = true, label, tick, title, grid, line, labelAutoHide, labelAutoHideGap, labelAutoLimit, labelAutoLimitLength = 80, labelAutoRotate, labelAutoRotateAngleRange } = config;
    const sampling = !(labelAutoHide || labelAutoRotate || labelAutoLimit);
    const bandAxis = {
        visible,
        type: 'band',
        orient: 'bottom',
        maxHeight: labelAutoLimitLength + 60,
        sampling,
        hover: true,
        label: {
            visible: label?.visible,
            flush: true,
            space: AXIS_LABEL_SPACE,
            style: {
                maxLineWidth: labelAutoLimitLength,
                fill: label?.labelColor,
                angle: label?.labelAngle,
                fontSize: label?.labelFontSize,
                fontWeight: label?.labelFontWeight
            },
            minGap: labelAutoHideGap,
            autoHide: labelAutoHide,
            autoHideMethod: 'greedy',
            autoHideSeparation: labelAutoHideGap,
            autoLimit: labelAutoLimit,
            autoRotate: labelAutoRotate,
            autoRotateAngle: labelAutoRotateAngleRange,
            lastVisible: true
        },
        title: {
            visible: title?.visible,
            text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x),
            style: {
                fill: title?.titleColor,
                fontSize: title?.titleFontSize,
                fontWeight: title?.titleFontWeight
            }
        },
        tick: {
            visible: tick?.visible,
            tickSize: tick?.tickSize,
            inside: tick?.tickInside,
            style: {
                stroke: tick?.tickColor
            }
        },
        grid: {
            visible: grid?.visible,
            style: {
                lineWidth: grid?.gridWidth,
                stroke: grid?.gridColor,
                lineDash: grid?.gridLineDash
            }
        },
        domainLine: {
            visible: line?.visible,
            style: {
                lineWidth: line?.lineWidth,
                stroke: line?.lineColor
            }
        },
        paddingInner: [
            0.15,
            0.1
        ],
        paddingOuter: [
            0.075,
            0.1
        ]
    };
    result.axes = [
        ...result.axes,
        bandAxis
    ];
    return result;
};
export { xBand };

//# sourceMappingURL=xBand.js.map