import type SpatialReference from "../geometry/SpatialReference.js";
import type ClassBreaksRenderer from "./ClassBreaksRenderer.js";
import type DictionaryRenderer from "./DictionaryRenderer.js";
import type DotDensityRenderer from "./DotDensityRenderer.js";
import type HeatmapRenderer from "./HeatmapRenderer.js";
import type PieChartRenderer from "./PieChartRenderer.js";
import type SimpleRenderer from "./SimpleRenderer.js";
import type UniqueValueRenderer from "./UniqueValueRenderer.js";
import type ColorVariable from "./visualVariables/ColorVariable.js";
import type OpacityVariable from "./visualVariables/OpacityVariable.js";
import type RotationVariable from "./visualVariables/RotationVariable.js";
import type SizeVariable from "./visualVariables/SizeVariable.js";
import type { AbortOptions } from "../core/promiseUtils.js";
import type { WebStyleAcceptedFormat } from "../symbols/support/types.js";

export type RendererType = RendererUnion["type"];

export type NormalizationType = "field" | "log" | "percent-of-total" | "natural-log" | "square-root";

export type ClassificationMethod = "equal-interval" | "manual" | "natural-breaks" | "quantile" | "standard-deviation" | "defined-interval";

export type SizeVariableAxis = "width" | "depth" | "height" | "width-and-depth" | "all";

export type SizeVariableRepresentation = "radius" | "diameter" | "area" | "width" | "distance";

export type SizeVariableUnit = "unknown" | "inches" | "feet" | "yards" | "miles" | "nautical-miles" | "millimeters" | "centimeters" | "decimeters" | "meters" | "kilometers";

export type VisualVariable = ColorVariable | SizeVariable | OpacityVariable | RotationVariable;

export type VisualVariableType = VisualVariable["type"];

export interface VisualVariableLegendOptions {
  /**
   * Indicates if the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-legend/) should display content
   *   describing the generated renderer.
   */
  showLegend?: boolean;
  /**
   * The title used to represent the age size ramp in the
   *   [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-legend/).
   */
  title?: string | null;
}

export interface GetSymbolOptions extends AbortOptions {
  /** The [view scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) at which the graphic is displayed. */
  scale?: number | null;
  /**
   * The spatial reference of the view in which the graphic
   *   is displayed.
   */
  spatialReference?: SpatialReference | null;
  /**
   * The [SceneView#viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) of the view, if the graphic
   *   is displayed in a SceneView.
   */
  viewingMode?: string | null;
}

export interface GetVisualVariableValuesOptions extends GetSymbolOptions {
  /**
   * The [MapView#resolution](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#resolution) of the view at which
   *   the graphic is displayed.
   */
  resolution?: number;
}

export interface GetDisplaySymbolOptions extends GetVisualVariableValuesOptions {
  /** The renderer of the layer associated with the `graphic`. */
  renderer?: RendererUnion;
  /**
   * A list of accepted formats when
   *   resolving web style symbols. The symbol will resolve to the first accepted format in the list.
   *
   * @default ["web", "cim"]
   */
  webStyleAcceptedFormats?: WebStyleAcceptedFormat[];
}

export type VectorFieldStyles = "beaufort-ft" | "beaufort-km" | "beaufort-kn" | "beaufort-m" | "beaufort-mi" | "classified-arrow" | "ocean-current-kn" | "ocean-current-m" | "simple-scalar" | "single-arrow" | "wind-barb";

export type RelationshipNumClasses = 2 | 3 | 4;

export type DictionaryUserConfig = Object;

export type DictionaryFieldMap = Record<string, string>;

/** Union of all renderers with visual variables. */
export type RendererWithVisualVariablesUnion = SimpleRenderer | ClassBreaksRenderer | UniqueValueRenderer | DotDensityRenderer | DictionaryRenderer | PieChartRenderer;

/** Union of renderers. */
export type RendererUnion = RendererWithVisualVariablesUnion | HeatmapRenderer;