import type Layer from "../layers/Layer.js";
import type Collection from "../core/Collection.js";
import type { ReadonlyArrayOrCollection } from "../core/Collection.js";

export interface LayersMixinProperties {
  /**
   * A collection of operational [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). This property
   * contains the operational layers, such as [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html),
   * [WebTileLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and [GraphicsLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html)  that may be queried, assigned different renderers, analyzed, etc. It does not include
   * [basemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html).
   *
   * A [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) is a collection of one or more features, or [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), that represent real-world phenomena. Each feature contains a [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html)  and [geographic data](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that allows it to be rendered on the map as a
   * graphic with spatial context. Features within the layer may also contain data attributes that provide
   * additional information that may be viewed in [popup windows](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) and used for [rendering the layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html).
   *
   * Layers may be added in the [constructor](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#LayersMixinProperties), with the [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#addMany) methods,
   * or directly to the layers
   * collection using [Collection.add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add) or [Collection.addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#addMany).
   *
   * In 3D, for layers that are rendered on the terrain, the order of the layers also depends on the
   * type of layer. Tiled layers ([BaseTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html), [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html),
   * [OpenStreetMapLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OpenStreetMapLayer.html), [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html), [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html), [WCSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WCSLayer.html),
   * [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and [WMTSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html)) are always drawn first in the same order as specified in the layer collection.
   * Dynamic layers ([MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html), [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html), and
   * feature based layers with [elevation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) `on-the-ground`) are rendered
   * on top using the order from the layer collection.
   *
   * > [!WARNING]
   * >
   * > A [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) may only be added to one parent. Adding the
   * > same layer to multiple [Maps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) or
   * > [GroupLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) is not possible.
   * > If you attempt to do so, the layer will automatically be removed
   * > from its current parent and placed in the new parent.
   * >
   * > ```js
   * > let layer = new GraphicsLayer();
   * > // The layer belongs to map1
   * > map1.layers.add(layer);
   * > // The layer now belongs to map2
   * > // and implicitly does: map1.layers.remove(layer)
   * > map2.layers.add(layer);
   * > ```
   *
   * > [!WARNING]
   * >
   * > To access tables from [feature layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), use
   * > the `tables` property in either [Map.tables](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#tables) or [WebMap.tables](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#tables) classes.
   *
   * @example
   * // Add layers in the constructor of Map using an array
   * let fl = new FeatureLayer(url);
   * let gl = new GraphicsLayer();
   * let map = new Map({
   *   layers: [fl, gl]
   * });
   *
   * // Add layers using add()
   * map.addMany([fl, gl]);
   *
   * // Add layers using layers collection
   * map.layers.addMany([fl, gl]);
   *
   * // Add layers using layers collection's push method
   * map.layers.push(fl, gl);
   */
  layers?: ReadonlyArrayOrCollection<Layer>;
}

/**
 * Mixin for [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html).
 *
 * @since 4.0
 */
export abstract class LayersMixin {
  constructor(...args: any[]);
  /**
   * A collection of operational [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). This property
   * contains the operational layers, such as [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html),
   * [WebTileLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and [GraphicsLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html)  that may be queried, assigned different renderers, analyzed, etc. It does not include
   * [basemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html).
   *
   * A [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) is a collection of one or more features, or [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), that represent real-world phenomena. Each feature contains a [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html)  and [geographic data](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that allows it to be rendered on the map as a
   * graphic with spatial context. Features within the layer may also contain data attributes that provide
   * additional information that may be viewed in [popup windows](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) and used for [rendering the layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html).
   *
   * Layers may be added in the [constructor](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#LayersMixinProperties), with the [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#addMany) methods,
   * or directly to the layers
   * collection using [Collection.add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add) or [Collection.addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#addMany).
   *
   * In 3D, for layers that are rendered on the terrain, the order of the layers also depends on the
   * type of layer. Tiled layers ([BaseTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html), [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html),
   * [OpenStreetMapLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OpenStreetMapLayer.html), [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html), [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html), [WCSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WCSLayer.html),
   * [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and [WMTSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html)) are always drawn first in the same order as specified in the layer collection.
   * Dynamic layers ([MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html), [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html), and
   * feature based layers with [elevation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) `on-the-ground`) are rendered
   * on top using the order from the layer collection.
   *
   * > [!WARNING]
   * >
   * > A [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) may only be added to one parent. Adding the
   * > same layer to multiple [Maps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) or
   * > [GroupLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) is not possible.
   * > If you attempt to do so, the layer will automatically be removed
   * > from its current parent and placed in the new parent.
   * >
   * > ```js
   * > let layer = new GraphicsLayer();
   * > // The layer belongs to map1
   * > map1.layers.add(layer);
   * > // The layer now belongs to map2
   * > // and implicitly does: map1.layers.remove(layer)
   * > map2.layers.add(layer);
   * > ```
   *
   * > [!WARNING]
   * >
   * > To access tables from [feature layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), use
   * > the `tables` property in either [Map.tables](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#tables) or [WebMap.tables](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#tables) classes.
   *
   * @example
   * // Add layers in the constructor of Map using an array
   * let fl = new FeatureLayer(url);
   * let gl = new GraphicsLayer();
   * let map = new Map({
   *   layers: [fl, gl]
   * });
   *
   * // Add layers using add()
   * map.addMany([fl, gl]);
   *
   * // Add layers using layers collection
   * map.layers.addMany([fl, gl]);
   *
   * // Add layers using layers collection's push method
   * map.layers.push(fl, gl);
   */
  get layers(): Collection<Layer>;
  set layers(value: ReadonlyArrayOrCollection<Layer>);
  /**
   * Adds a layer to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). The [Collection.@before-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-changes),
   * [Collection.@before-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-add), [Collection.@after-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-add),
   * [Collection.@after-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-changes) and [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * events will be emitted when this method is called.
   *
   * @param layer - Layer or a promise that resolves to a layer to add to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers).
   * @param index - A layer can be added at a specified index in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers).
   *                         If no index is specified or the index specified is greater
   *                         than the current number of layers, the layer is automatically
   *                         appended to the list of layers in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) and the index is
   *                         normalized.
   * @see [layer collection's push() method](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#push)
   * @example
   * // add() and push methods can be used
   * // to add a layer to layers collection
   *
   * // add a layer to layers collection using add
   * map.add(layer);
   *
   * // add a layer at the end of layers collection
   * map.layers.push(layer);
   */
  add(layer: Layer | PromiseLike<Layer>, index?: number): void;
  /**
   * Adds a layer or an array of layers to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). The [Collection.@before-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-changes),
   * [Collection.@before-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-add), [Collection.@after-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-add),
   * [Collection.@after-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-changes) and [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * events will be emitted when this method is called.
   *
   * The [Collection.push()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#push) method on the layers collection also can be used to add a layer or layers.
   *
   * @param layers - Layer(s) to be added to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers).
   * @param index - A layer can be added at a specified index in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers).
   *                         If no index is specified or the index specified is greater
   *                         than the current number of layers, the layer is automatically
   *                         appended to the list of layers in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) and the index is
   *                         normalized.
   * @see [layer collection's push() method](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#push)
   * @example
   * // addMany and push methods can be used
   * // to add layers to layers collection
   *
   * // add an array of layers to layers collection using addMany
   * map.addMany([layer, layer2]);
   *
   * // add layers to layers collection using push method
   * map.layers.push(layer, layer2);
   */
  addMany(layers: Layer[], index?: number): void;
  /**
   * Returns a layer based on the given layer ID.
   *
   * @param layerId - The ID assigned to the layer.
   * @returns Returns the requested layer object.
   */
  findLayerById(layerId: string): Layer | null | undefined;
  /**
   * Removes the specified layer from the layers collection. The [Collection.@before-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-changes),
   * [Collection.@before-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-remove), [Collection.@after-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-remove),
   * [Collection.@after-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-changes) and [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * events will be emitted when this method is called.
   *
   * @param layer - Layer to remove from the layers collection.
   * @returns Returns the layer removed from the layers collection.
   */
  remove(layer: Layer): Layer | null | undefined;
  /**
   * Removes all layers. The [Collection.@before-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-changes),
   * [Collection.@before-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-remove), [Collection.@after-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-remove),
   * [Collection.@after-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-changes) and [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * events will be emitted when this method is called.
   *
   * @returns Returns the layers removed from the layers collection.
   */
  removeAll(): Layer[];
  /**
   * Removes the specified layers. The [Collection.@before-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-changes),
   * [Collection.@before-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-before-remove), [Collection.@after-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-remove),
   * [Collection.@after-changes](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-after-changes) and [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * events will be emitted when this method is called.
   *
   * @param layers - Array of layers to remove from the layers collection.
   * @returns Returns the layers removed from the layers collection.
   */
  removeMany(layers: Layer[]): Layer[];
  /**
   * Changes the layer order. The first layer added is always the base layer,
   * even if its order is changed. The [Collection.@change](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#event-change)
   * event will be emitted when this method is called.
   *
   * In 3D, for layers that are rendered on the terrain, the order of the layers also depends on the
   * type of layer. Tiled layers ([BaseTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html), [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html),
   * [OpenStreetMapLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OpenStreetMapLayer.html), [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html), [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html), [WCSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WCSLayer.html),
   * [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and [WMTSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html)) are always drawn first in the same order as specified in the layer collection.
   * Dynamic layers ([MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html), [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html), and
   * feature based layers with [elevation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) `on-the-ground`) are rendered
   * on top using the order from the layer collection.
   *
   * @param layer - The layer to be moved.
   * @param index - The index location for placing the layer. The bottom-most
   *                         layer has an index of `0`.
   * @returns Returns the layer that was moved.
   */
  reorder(layer: Layer, index?: number): Layer | null | undefined;
}