import { createDimensionContent, createMarkContent } from "./tooltip.js";
import { getTooltipStyle } from "./tooltipStyle.js";
import { updateTooltipElement } from "./tooltipElement.js";
import { createFormatterByDimension } from "../../../../utils/index.js";
import { Separator } from "../../../../../dataReshape/index.js";
const tooltipOfDualAxisSeries = (options)=>(spec, context)=>{
        const result = {
            ...spec
        };
        const { advancedVSeed, vseed } = context;
        const { measures = [], datasetReshapeInfo, chartType, dimensions = [], encoding, reshapeMeasures = [] } = advancedVSeed;
        const baseConfig = advancedVSeed.config[chartType];
        const { tooltip = {
            enable: true
        } } = baseConfig;
        const { enable } = tooltip;
        const unfoldInfo = datasetReshapeInfo[0].unfoldInfo;
        result.tooltip = {
            visible: enable,
            mark: {
                title: {
                    visible: false
                },
                content: createMarkContent(encoding.tooltip || [], dimensions, vseed.measures, options.foldInfo, unfoldInfo, advancedVSeed.locale)
            },
            dimension: {
                title: {
                    visible: true,
                    value: (datum)=>{
                        if (!datum) return '';
                        const dimIds = encoding.x || [];
                        const formatted = dimIds.map((id)=>{
                            const dim = dimensions.find((item)=>item.id === id);
                            if (!dim) return datum?.[id];
                            const formatter = createFormatterByDimension(dim, advancedVSeed.locale);
                            return formatter(datum?.[id]);
                        });
                        return formatted.join(Separator);
                    }
                },
                content: createDimensionContent(encoding.tooltip || [], encoding.color || [], measures, options.foldInfo, unfoldInfo, reshapeMeasures.length > 1)
            }
        };
        return result;
    };
const tooltipDualAxis = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed } = context;
    const { chartType } = advancedVSeed;
    const baseConfig = advancedVSeed.config[chartType];
    const { tooltip = {
        enable: true
    } } = baseConfig;
    result.tooltip = {
        style: getTooltipStyle(tooltip),
        updateElement: updateTooltipElement
    };
    return result;
};
export { tooltipDualAxis, tooltipOfDualAxisSeries };

//# sourceMappingURL=tooltipDualAxis.js.map