/**
 * This annotation allows drawing a horizontal line on a chart.
 *
 * It accepts either pixel coordinates or data values for positioning.
 *
 * In case it receives pixel coordinates, it uses a line SVG element.
 * If data values are provided, it uses a ReferenceLine component.
 */
import React from 'react';
import { ReferenceLine } from 'recharts';
export function HorizontalLine({ annotation }) {
    const { pointA, positionType, label, style } = annotation;
    const { color = '#ccc', strokeWidth = 1, strokeDasharray, opacity = 1 } = style;
    if (positionType === 'data') {
        // Use ReferenceLine for data-based positioning
        return (React.createElement(ReferenceLine, { y: String(pointA.dataPoint?.y), stroke: color, strokeWidth: strokeWidth, strokeDasharray: strokeDasharray, strokeOpacity: opacity, label: label, tabIndex: -1, focusable: false }));
    }
    // For pixel-based positioning, use raw SVG line
    const yPixel = pointA.interactionCoordinate.y;
    return (React.createElement("g", null,
        React.createElement("line", { x1: 0, y1: yPixel, x2: "100%", y2: yPixel, stroke: color, strokeWidth: strokeWidth, strokeDasharray: strokeDasharray, opacity: opacity, pointerEvents: "none", tabIndex: -1, focusable: false }),
        label && (React.createElement("text", { x: 5, y: yPixel - 5, fill: label.style?.fill ?? color, fontSize: label.style?.fontSize ?? 10, fontWeight: label.style?.fontWeight ?? 'normal', pointerEvents: "none" }, label.value))));
}
