"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getReferenceLineStyle = void 0;
const colors_1 = require("../../../utils/colors");
const themeColors_1 = require("./themeColors");
/**
 * Get reference line styling
 * @param lineColor Optional custom color for the line
 * @param backgroundColor Background color to ensure contrast against (required for color adjustment)
 */
const getReferenceLineStyle = (lineColor, backgroundColor) => {
    const defaultLineColor = lineColor || themeColors_1.GRAY_9;
    // Adjust color for visibility if background color is provided
    const adjustedLineColor = backgroundColor
        ? (0, colors_1.getReadableColor)(defaultLineColor, backgroundColor)
        : defaultLineColor;
    return {
        emphasis: {
            disabled: true,
        },
        lineStyle: {
            color: adjustedLineColor,
            type: [2, 3], // Dotted: 2px dash, 3px gap
            width: 2,
        },
        label: {
            show: true,
            position: 'start', // Start position (left side) to avoid right-edge clipping
            distance: -4, // Negative distance moves label into chart area
            formatter: (params) => {
                const text = params.name || String(params.value || '');
                // Simple truncation - ECharts doesn't handle wrapping well for mark line labels
                const maxChars = 15;
                return text.length > maxChars
                    ? `${text.substring(0, maxChars)}...`
                    : text;
            },
            backgroundColor: adjustedLineColor,
            color: (0, colors_1.getReadableTextColor)(adjustedLineColor),
            borderWidth: 1,
            borderColor: adjustedLineColor,
            padding: [2, 4],
            borderRadius: 4,
            fontSize: 11,
            fontWeight: 500,
        },
    };
};
exports.getReferenceLineStyle = getReferenceLineStyle;
//# sourceMappingURL=referenceLineStyles.js.map