import type { ChartSubType } from "../misc/interfaces.js";
import type { BoxPlotYValueProps, DataMinMax, BoxPlotYFieldKeys } from "./interfaces.js";
import type { WebChart, WebChartSeriesType, WebGaugeChart } from "../../spec/web-chart.js";
import type { WebChartBin, WebChartDataItem, WebChartDataTypes } from "../../spec/data-source.js";

/**
 * Generates the y field names for box plot
 *
 * @param y
 * @internal
 */
export function getBoxPlotStatisticFieldNames(y?: string): Record<BoxPlotYFieldKeys, string>;

/**
 * Check the `subType` in the chart config to determine whether the chart is a gauge by feature.
 * If `subType` is not defined, the chart is defaulted to be a statistic gauge.
 *
 * @param config - the chart config
 * @internal
 */
export function isGaugeByFeature(config: WebChart): boolean;

/**
 * From fetched data (type: WebChartDataTypes) returns the part containing the data that
 * is to be assigned to the chart (WebChartDataItem[] | WebChartBin[])
 *
 * @param fetchedData - The fetched finished data
 * @internal
 */
export function extractChartDataFromFetchedData(fetchedData?: WebChartDataTypes): WebChartBin[] | WebChartDataItem[] | undefined;

/**
 * Determine whether the current box plot has multi-fields or not based on its query type
 *
 * @param chartSubType - Box plot sub type
 * @internal
 */
export function isMultiFieldsBoxPlot(chartSubType?: ChartSubType): boolean;

/**
 * Compute Y value for given Box Plot Y field key based on the provided config
 *
 * @param props - The BoxPlotYFieldKeys related to the stat
 * @internal
 */
export function getBoxPlotYValue(props: BoxPlotYValueProps): string;

/**
 * Check if the Box-plot data item has valid open or close (first quartile/third quartile) values since those values are considered as necessary.
 *
 * @param props - The WebChartDataItem to check for valid values
 * @internal
 */
export function doesBoxPlotItemHaveValidQuartiles(props: {
    dataItem: WebChartDataItem;
    y?: string;
    splitBy?: string;
    showOutliers?: boolean;
}): boolean;

/**
 * Gathers the list of `y` values used by a chart from the series configs.
 * For non-aggregated split-by bar/line charts, the y values are constructed from the series's where clauses.
 *
 * Notes:
 * 1. If the list of visible series id is provided it will be used to filter out the series, otherwise they will all be considered.
 * 2. The returned y list should be independently from any prefix or suffix that are used for other features like
 * color match, selection, tooltips, etc.
 *
 * @param seriesConfig - The array of configs for the chart series.
 * @param filteredSeriesIds - List of series ids to use as a filter.
 * @internal
 */
export function getYList(seriesConfig: WebChartSeriesType[], filteredSeriesIds?: string[]): string[];

/**
 * Gathers the list of `y` values used by a box plot from the series configs.
 *
 * @param props - Whether the box plot mean lines are shown
 * @internal
 */
export function getBoxPlotYList(props: {
    showMean?: boolean;
    seriesConfig: WebChartSeriesType[];
    filteredSeriesIds?: string[];
}): string[];

/**
 * validate the individual bar chart data item using its x and y values
 *
 * @param props - The bar/line chart data item
 * @internal
 */
export function validateBarNLineChartDataItem(props: {
    dataItem: WebChartDataItem;
    x: string;
    y: string;
    nullAsValid?: boolean;
}): boolean;

/**
 * Indicates whether a data set is empty (no bar, no slice, etc.) and contains at least one valid item.
 *
 * @param props - The chart's config
 * @returns A boolean
 * @internal
 */
export function isEmptyDataset(props: {
    chartConfig?: WebChart | WebGaugeChart;
    nullAsValid?: boolean;
    dataSet?: WebChartDataItem[];
}): boolean;

/**
 * Gets the data min and max values for a stacked series; also an indicator whether the data has negative values.
 *
 * @param props - The config for the series
 * @internal
 */
export function getDataMinMaxFromStackedSeries(props: {
    seriesConfig: WebChartSeriesType[];
    filteredSeriesIds?: string[];
    filteredData: WebChartDataItem[];
}): {
    stackedMinY: number;
    stackedMaxY: number;
    dataHasNegativeValues: boolean;
};

/**
 * Looks for the min and max values from a data set, considering only the visible series.
 *
 * @param props - The chart config
 * @internal
 */
export function getDataMinMaxFromSeries(props: {
    chartConfig: WebChart;
    chartData: WebChartDataItem[];
    filteredSeriesIds?: string[];
}): DataMinMax;

/**
 * Rounds a number to a given number of decimals
 *
 * @param num - The number to round
 * @param dec - The number of decimals
 * @internal
 */
export function roundToDecimals(num: number, dec: number): number;