import { xMinMaxValues } from "../x/index.js";
/**
 * Filter an array x/y based on various criteria x points are expected to be sorted
 * @param data - object containing 2 properties x and y
 * @param minRelativeYValue - the minimum relative value compare to the Y max value
 * @returns filtered data
 */
export function xyFilterMinYValue(data, minRelativeYValue) {
    if (minRelativeYValue === undefined)
        return data;
    const { x, y } = data;
    const { min, max } = xMinMaxValues(y);
    const threshold = max * minRelativeYValue;
    if (min >= threshold)
        return data;
    const newX = [];
    const newY = [];
    for (let i = 0; i < x.length; i++) {
        if (y[i] >= threshold) {
            newX.push(x[i]);
            newY.push(y[i]);
        }
    }
    return {
        x: newX,
        y: newY,
    };
}
//# sourceMappingURL=xyFilterMinYValue.js.map