import type Accessor from "../../core/Accessor.js";
import type Collection from "../../core/Collection.js";
import type LinkChartView from "../../views/LinkChartView.js";
import type ActiveLayerInfo from "./support/ActiveLayerInfo.js";
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
import type { LayerInfo } from "../types.js";
import type { ActiveLayerInfoProperties } from "./support/ActiveLayerInfo.js";
import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";

export interface LegendViewModelProperties extends Partial<Pick<LegendViewModel, "basemapLegendVisible" | "hideLayersNotInCurrentView" | "layerInfos" | "respectLayerDefinitionExpression" | "respectLayerVisibility" | "view">> {
  /**
   * Collection of [ActiveLayerInfo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/) objects used by the legend view to
   * display data in the legend. Use this property to hide or display the layer's symbols in the legend when
   * an [ActiveLayerInfo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/) is removed from or added to this collection.
   */
  activeLayerInfos?: ReadonlyArrayOrCollection<ActiveLayerInfoProperties>;
}

/**
 * Represents the allowed values for the [state](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#state) property.
 *
 * @see [state](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#state)
 * @since 5.0
 */
export type LegendViewModelState = "ready" | "disabled";

/**
 * Provides the logic for the [Legend](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/),
 * which displays a label and symbol for interpreting the [Renderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/Renderer/)
 * of each layer in a map. This class may be used to create custom, interactive
 * Legends.
 *
 * @since 4.11
 * @see [Legend](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/) widget - _Deprecated since 4.34. Use the [Legend component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/) instead._
 * @see [Legend component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/)
 * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
 * @example
 * const legend = new Legend({
 *   view: view,
 *   viewModel: new LegendViewModel({
 *     view: view
 *   })
 * });
 * view.ui.add(legend, "bottom-left");
 */
export default class LegendViewModel extends Accessor {
  constructor(properties?: LegendViewModelProperties);
  /**
   * Collection of [ActiveLayerInfo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/) objects used by the legend view to
   * display data in the legend. Use this property to hide or display the layer's symbols in the legend when
   * an [ActiveLayerInfo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/) is removed from or added to this collection.
   */
  get activeLayerInfos(): Collection<ActiveLayerInfo>;
  set activeLayerInfos(value: ReadonlyArrayOrCollection<ActiveLayerInfoProperties>);
  /**
   * Indicates whether to show the [Basemap](https://developers.arcgis.com/javascript/latest/references/core/Basemap/) layers in the Legend.
   *
   * @default false
   * @example legend.viewModel.basemapLegendVisible = true;
   */
  accessor basemapLegendVisible: boolean;
  /**
   * When `true`, layers will only be shown in the legend if
   * they are visible in the view's extent. When data from a layer
   * is not visible in the view, the layer's legend information
   * will be hidden.
   *
   * To hide layers completely
   * from the legend, you should set the `legendEnabled` property of
   * the layer to `false`.
   *
   * @default false
   * @since 4.21
   * @see [respectLayerVisibility](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#respectLayerVisibility)
   * @example
   * // layers not displayed in the view
   * // will not be shown in the legend
   * legend.viewModel.hideLayersNotInCurrentView = true;
   */
  accessor hideLayersNotInCurrentView: boolean;
  /**
   * Defines which layers and sublayers are shown in the legend, including any [basemap layers](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#basemapLegendVisible) you want visible.
   * If not set, all layers in the map are displayed in the legend by default, including basemap layers when
   * [basemapLegendVisible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#basemapLegendVisible) is `true`.
   */
  accessor layerInfos: LayerInfo[];
  /**
   * Indicates whether the viewModel is currently loading.
   *
   * @default false
   * @since 4.34
   */
  get loading(): boolean;
  /**
   * If a layer uses a unique value render, only features that satisfy the layer's
   * [definition expression](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureLayerBase/#definitionExpression)
   * will be displayed in the legend when set to true.
   *
   * @default false
   * @since 4.34
   * @see [FeatureLayerBase.definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureLayerBase/#definitionExpression)
   */
  accessor respectLayerDefinitionExpression: boolean;
  /**
   * Determines whether to respect the properties of the layers in the map that
   * control the legend's visibility (`minScale`, `maxScale`, `legendEnabled`).
   * By default, a layer's legend elements **will
   * not render** in the legend given the following conditions:
   *
   * - The [FeatureLayer.legendEnabled](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#legendEnabled) property
   * is set to `false`.
   * - If the view's scale is outside the visibility range
   * defined by the [ScaleRangeLayer.minScale](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ScaleRangeLayer/#minScale) and
   * [ScaleRangeLayer.maxScale](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ScaleRangeLayer/#maxScale) properties.
   *
   * When the `respectLayerVisibility` property of the legend is set to `false`, the legend elements for each
   * layer in the map will always display, thus disregarding the `minScale`, `maxScale`,
   * and `legendEnabled` properties for each layer in the map.
   *
   * @default true
   * @since 4.13
   * @see [hideLayersNotInCurrentView](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/LegendViewModel/#hideLayersNotInCurrentView)
   * @example
   * // Always displays legend elements for the map's layers
   * // regardless of their minScale, maxScale, and legendEnabled properties
   * legend.respectLayerVisibility = false;
   */
  accessor respectLayerVisibility: boolean;
  /**
   * The view model's state.
   *
   * @default "disabled"
   */
  get state(): LegendViewModelState;
  /** The view from which the widget will operate. */
  accessor view: MapViewOrSceneView | LinkChartView | null | undefined;
}