import { label as external_label_js_label } from "./label.js";
import { createFormatterByDimension } from "../../../../utils/index.js";
import { Separator } from "../../../../../dataReshape/index.js";
const labelCirclePacking = (spec, context)=>{
    const { advancedVSeed } = context;
    const { chartType, encoding, dimensions = [] } = advancedVSeed;
    const baseConfig = advancedVSeed.config[chartType];
    const { label } = baseConfig;
    const result = external_label_js_label(spec, context);
    if (label?.enable) {
        const labelSpec = result.label;
        const formatHierarchyName = (name)=>{
            const dimIds = encoding.hierarchy || [];
            if (!dimIds.length) return name;
            const dimFormatters = dimIds.map((id)=>{
                const dim = dimensions.find((item)=>item.id === id);
                return createFormatterByDimension(dim, advancedVSeed.locale);
            });
            const parts = String(name ?? '').split(Separator);
            const formatted = parts.map((part, index)=>{
                const formatter = dimFormatters[index] || ((v)=>v);
                return formatter(part);
            });
            return formatted.join(Separator);
        };
        result.label = {
            ...labelSpec,
            formatMethod: (_, datum)=>formatHierarchyName(String(datum?.name ?? '')),
            style: {
                ...labelSpec?.style,
                fontSize: 10,
                visible: (d)=>1 === d.depth
            }
        };
    }
    return result;
};
export { labelCirclePacking };

//# sourceMappingURL=labelCirclePacking.js.map