import type Color from "../../../Color.js";
import type ChartMediaInfoValueSeries from "./ChartMediaInfoValueSeries.js";
import type { JSONSupport } from "../../../core/JSONSupport.js";
import type { ColorLike } from "../../../Color.js";
import type { ChartMediaInfoValueSeriesProperties } from "./ChartMediaInfoValueSeries.js";

export interface ChartMediaInfoValueProperties extends Partial<Pick<ChartMediaInfoValue, "fields" | "normalizeField" | "tooltipField">> {
  /**
   * An optional array of [colors](https://developers.arcgis.com/javascript/latest/references/core/Color/) where each color corresponds respectively to a field in the [fields](https://developers.arcgis.com/javascript/latest/references/core/popup/content/support/ChartMediaInfoValue/#fields).
   * When utilized with [line charts](https://developers.arcgis.com/javascript/latest/references/core/popup/content/LineChartMediaInfo/), the first color in the array drives the line color.
   * If there are less colors specified than fields or this property is not set, the default color ramp is applied.
   */
  colors?: ColorLike[] | null;
  /**
   * An array of [ChartMediaInfoValueSeries](https://developers.arcgis.com/javascript/latest/references/core/popup/content/support/ChartMediaInfoValueSeries/) objects which provide
   * information of x/y data that is plotted in a chart.
   */
  series?: ChartMediaInfoValueSeriesProperties[];
}

/**
 * The `ChartMediaInfoValue` class contains information for popups regarding how charts should be constructed.
 *
 * @since 4.11
 * @see [BarChartMediaInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/content/BarChartMediaInfo/)
 * @see [ColumnChartMediaInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/content/ColumnChartMediaInfo/)
 * @see [LineChartMediaInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/content/LineChartMediaInfo/)
 * @see [PieChartMediaInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/content/PieChartMediaInfo/)
 * @see [ChartMediaInfoValueSeries](https://developers.arcgis.com/javascript/latest/references/core/popup/content/support/ChartMediaInfoValueSeries/)
 * @example
 * // Create a ChartMediaInfoValue that customizes the colors of each
 * // field that will be represented in the chart.
 * let pieChartValue = new ChartMediaInfoValue({
 *   colors: [
 *     new Color([254, 235, 226, 1]),
 *     new Color([250, 164, 180, 1]),
 *     new Color([248, 116, 165, 1]),
 *     new Color([204, 39, 141, 1])
 *   ],
 *   fields: [
 *     "B12001_calc_pctMarriedE",
 *     "B12001_calc_numMarriedE",
 *     "B12001_calc_numNeverE",
 *     "B12001_calc_numDivorcedE"
 *   ],
 *   normalizeField: null
 * });
 * @example
 * // Create a ChartMediaInfoValue that customizes the colors of each
 * // field that will be represented in the chart.
 * let pieChartValue = new ChartMediaInfoValue({
 *   // Autocasts each item to a new Color object.
 *   colors: ["red", "yellow", "green", "blue"],
 *   fields: [
 *     "B12001_calc_pctMarriedE",
 *     "B12001_calc_numMarriedE",
 *     "B12001_calc_numNeverE",
 *     "B12001_calc_numDivorcedE"
 *   ],
 * });
 */
export default class ChartMediaInfoValue extends JSONSupport {
  constructor(properties?: ChartMediaInfoValueProperties);
  /**
   * An optional array of [colors](https://developers.arcgis.com/javascript/latest/references/core/Color/) where each color corresponds respectively to a field in the [fields](https://developers.arcgis.com/javascript/latest/references/core/popup/content/support/ChartMediaInfoValue/#fields).
   * When utilized with [line charts](https://developers.arcgis.com/javascript/latest/references/core/popup/content/LineChartMediaInfo/), the first color in the array drives the line color.
   * If there are less colors specified than fields or this property is not set, the default color ramp is applied.
   */
  get colors(): Color[] | null | undefined;
  set colors(value: ColorLike[] | null | undefined);
  /**
   * An array of strings, with each string containing the name of a field to display in the chart.
   *
   * > [!WARNING]
   * >
   * > In order to work with related fields within a chart, the fields must either be set
   * > as a [fields](https://developers.arcgis.com/javascript/latest/references/core/popup/FieldInfo/) element in the [PopupTemplate's content](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#content)
   * > or as [PopupTemplate.fieldInfos](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#fieldInfos) property outside of the PopupTemplate's content.
   *
   * > [!WARNING]
   * >
   * > Set the [PopupTemplate.fieldInfos](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#fieldInfos) property for any
   * > fields that need to have number formatting for chart/text elements.
   */
  accessor fields: string[];
  /**
   * A string containing the name of a field. The values of all fields in the
   * chart will be normalized (divided) by the value of this field.
   */
  accessor normalizeField: string | null | undefined;
  /**
   * An array of [ChartMediaInfoValueSeries](https://developers.arcgis.com/javascript/latest/references/core/popup/content/support/ChartMediaInfoValueSeries/) objects which provide
   * information of x/y data that is plotted in a chart.
   */
  get series(): ChartMediaInfoValueSeries[];
  set series(value: ChartMediaInfoValueSeriesProperties[]);
  /**
   * String value indicating the tooltip for a chart specified from another field.
   * It is used for showing tooltips from another field in the same layer or related layer/table.
   */
  accessor tooltipField: string | null | undefined;
  /** Creates a deep clone of the ChartMediaInfoValue class. */
  clone(): ChartMediaInfoValue;
}