import type { JSONSupport, JSONSupportMixinProperties } from "../../../core/JSONSupport.js";

export interface MapLayerSourceProperties extends JSONSupportMixinProperties, Partial<Pick<MapLayerSource, "gdbVersion" | "mapLayerId">> {}

/**
 * A dynamic map layer refers to a layer published in a map service that has
 * dynamic layers enabled.
 * This layer type may be used to create multiple [Sublayer#sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#sublayers)
 * that point to the same service layer, but are assigned different definition
 * expressions, renderers, and other properties.
 *
 * @see [Sample - MapImageLayer: create dynamic map layers](https://developers.arcgis.com/javascript/latest/sample-code/layers-dynamicmaplayer/)
 * @see [ArcGIS REST API - Layer source object](https://developers.arcgis.com/documentation/common-data-types/layer-source-object.htm)
 * @example
 * // Creates two sublayers that point to the same map service layer.
 * // Each layer presents different features in the data using
 * // definition expressions and renderers.
 * let mapImageLayer = new MapImageLayer({
 *   sublayers: [{
 *     id: 10,
 *     definitionExpression: "POP < 50000",
 *     renderer: {
 *       type: "class-breaks"  // autocasts as new ClassBreaksRenderer()
 *       // set renderer properties here
 *     },
 *     source: {
 *       type: "map-layer",
 *       mapLayerId: 0
 *     }
 *   }, {
 *     id: 11,
 *     definitionExpression: "GRADUATED_HS > 0.449",
 *     renderer: {
 *       type: "class-breaks"  // autocasts as new ClassBreaksRenderer()
 *       // set renderer properties here
 *     },
 *     source: {
 *       type: "map-layer",
 *       mapLayerId: 0
 *     }
 *   }]
 * });
 */
export default abstract class MapLayerSource extends JSONSupport {
  /** An optional property for specifying the GDB version. */
  accessor gdbVersion: string;
  /** The [Sublayer#id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) of the service sublayer. */
  accessor mapLayerId: number;
  /**
   * This value is always `map-layer` and is inferred when
   * the `mapLayerId` property is set.
   */
  get type(): "map-layer";
}