import type Extent from "../../geometry/Extent.js";
import type SpatialReference from "../../geometry/SpatialReference.js";
import type { ExtentProperties } from "../../geometry/Extent.js";

export interface ArcGISMapServiceProperties extends Partial<Pick<ArcGISMapService, "copyright" | "legendEnabled">> {
  /**
   * The full extent of the layer as defined by the map service.
   *
   * @example
   * // zooms the view to the full extent of the layer
   * layer.when(function(){
   *   view.goTo(layer.fullExtent);
   * });
   */
  fullExtent?: ExtentProperties | null;
}

/**
 * Mixin for [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/) and
 * [TileLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/TileLayer/).
 */
export abstract class ArcGISMapService {
  constructor(...args: any[]);
  /**
   * Indicates the layer's supported capabilities.
   *
   * @since 4.8
   */
  get capabilities(): MapServiceCapabilities;
  /** The copyright text as defined by the service. */
  accessor copyright: string | null | undefined;
  /**
   * The full extent of the layer as defined by the map service.
   *
   * @example
   * // zooms the view to the full extent of the layer
   * layer.when(function(){
   *   view.goTo(layer.fullExtent);
   * });
   */
  get fullExtent(): Extent | null | undefined;
  set fullExtent(value: ExtentProperties | null | undefined);
  /**
   * Indicates whether the layer will be included in the legend.
   *
   * @default true
   */
  accessor legendEnabled: boolean;
  /** The spatial reference of the layer as defined by the service. */
  get spatialReference(): SpatialReference;
  /**
   * The version of ArcGIS Server in which the map service is published.
   *
   * @example
   * // Prints the version number to the console - e.g. 10.91, 11.2, 11.3.
   * console.log(layer.version);
   */
  get version(): number;
}

export interface MapServiceCapabilities {
  /** Indicates options supported by the exportMap operation. Will be `null` if the `supportsExportMap` is `false`. */
  exportMap?: MapServiceCapabilitiesExportMap | null;
  /** Indicates options supported by the exportTiles operation. Will be `null` if the `supportsExportTiles` is `false`. */
  exportTiles?: MapServiceCapabilitiesExportTiles | null;
  /** Indicates operations that can be performed on the service. */
  operations: MapServiceCapabilitiesOperations;
}

export interface MapServiceCapabilitiesExportMap {
  /** Indicates if sublayers support Arcade expressions for labeling. Only applies to [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/). */
  supportsArcadeExpressionForLabeling: boolean;
  /** Indicates if [CIMSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/CIMSymbol/) can be used in a sublayer's [Sublayer.renderer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#renderer). */
  supportsCIMSymbols: boolean;
  /** Indicates if sublayers rendering can be modified or added using dynamic layers. */
  supportsDynamicLayers: boolean;
  /** Indicates if sublayers can be added, or removed. `supportsDynamicLayers` must be `true` as well to be able to reorder sublayers. */
  supportsSublayersChanges: boolean;
  /** Indicates if sublayers [definition expression](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#definitionExpression) can be set. */
  supportsSublayerDefinitionExpression: boolean;
  /**
   * Indicates if sublayers can be reordered. `supportsDynamicLayers` must be `true` as well. Only applies to [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/).
   *
   * @since 4.32
   */
  supportsSublayerOrderBy: boolean;
  /** Indicates if sublayers [visibility](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#visible) can be changed. */
  supportsSublayerVisibility: boolean;
}

export interface MapServiceCapabilitiesExportTiles {
  /** Specifies the maximum number of tiles that can be exported to a cache dataset or a tile package. */
  maxExportTilesCount: number;
}

export interface MapServiceCapabilitiesOperations {
  /** Indicates if the service can generate images. */
  supportsExportMap: boolean;
  /** Indicates if the tiles from the service can be exported. */
  supportsExportTiles: boolean;
  /** Indicates if the service supports the [identify operation](https://developers.arcgis.com/javascript/latest/references/core/rest/identify/#identify). */
  supportsIdentify: boolean;
  /** Indicates if features in the sublayers can be [queried](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#queryFeatures). */
  supportsQuery: boolean;
  /** -Indicates if the service exposes a tile map that describes the presence of tiles. */
  supportsTileMap: boolean;
}