import type Collection from "../../core/Collection.js";
import type Extent from "../../geometry/Extent.js";
import type WMTSLayer from "../WMTSLayer.js";
import type TileMatrixSet from "./TileMatrixSet.js";
import type WMTSStyle from "./WMTSStyle.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { ExtentProperties } from "../../geometry/Extent.js";
import type { WMTSStyleProperties } from "./WMTSStyle.js";
import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";
import type { TileMatrixSetProperties } from "./TileMatrixSet.js";

export interface WMTSSublayerProperties extends Partial<Pick<WMTSSublayer, "description" | "id" | "imageFormat" | "imageFormats" | "layer" | "parent" | "styleId" | "tileMatrixSetId" | "title">> {
  /** The full extent of the layer. */
  fullExtent?: ExtentProperties | null;
  /** A collection of supported [WMTSStyle](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSStyle/)s as retrieved from the GetCapabilities request. */
  styles?: ReadonlyArrayOrCollection<WMTSStyleProperties> | null;
  /** A collection of supported [TileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TileMatrixSet/). */
  tileMatrixSets?: ReadonlyArrayOrCollection<TileMatrixSetProperties> | null;
}

/**
 * Represents a sublayer in a [WMTSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WMTSLayer/).
 *
 * @since 4.4
 */
export default class WMTSSublayer extends JSONSupport {
  constructor(properties?: WMTSSublayerProperties);
  /**
   * Description for the WMTS sublayer.
   * This defaults to the value of the Abstract property from the GetCapabilities request.
   */
  accessor description: string;
  /** The full extent of the layer. */
  get fullExtent(): Extent | null | undefined;
  set fullExtent(value: ExtentProperties | null | undefined);
  /**
   * The unique ID assigned to the sublayer.
   * If not set by the developer, it is automatically generated when the layer is loaded.
   */
  accessor id: string;
  /**
   * The map image format (MIME type) to request.
   * Defaults to the first item in [imageFormats](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#imageFormats).
   * Must be one of the supported [imageFormats](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#imageFormats).
   */
  accessor imageFormat: string;
  /** Supported image formats as retrieved from the GetCapabilities request. */
  accessor imageFormats: string[] | null | undefined;
  /** The [WMTSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WMTSLayer/) to which the sublayer belongs. */
  accessor layer: WMTSLayer | null | undefined;
  /**
   * The parent [WMTSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WMTSLayer/) to which the sublayer belongs.
   *
   * @since 4.27
   */
  accessor parent: WMTSLayer | null | undefined;
  /**
   * The [WMTSStyle](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSStyle/) to request.
   * Defaults to the id of the first item in [styles](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#styles).
   * Should be one of the supported [styles](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#styles).
   */
  accessor styleId: string;
  /** A collection of supported [WMTSStyle](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSStyle/)s as retrieved from the GetCapabilities request. */
  get styles(): Collection<WMTSStyle> | null | undefined;
  set styles(value: ReadonlyArrayOrCollection<WMTSStyleProperties> | null | undefined);
  /**
   * The [TileMatrixSet](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TileMatrixSet/) to request.
   * Defaults to the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#tileMatrixSet) that matches the spatialReference of the view.
   * Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#tileMatrixSet).
   */
  get tileMatrixSet(): TileMatrixSet | null | undefined;
  /**
   * The id of the [TileMatrixSet](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TileMatrixSet/) to request.
   * Defaults to the id of the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#tileMatrixSet) that matches the spatialReference of the view.
   * Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/WMTSSublayer/#tileMatrixSet).
   */
  accessor tileMatrixSetId: string;
  /** A collection of supported [TileMatrixSets](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TileMatrixSet/). */
  get tileMatrixSets(): Collection<TileMatrixSet> | null | undefined;
  set tileMatrixSets(value: ReadonlyArrayOrCollection<TileMatrixSetProperties> | null | undefined);
  /**
   * The title of the WMTS sublayer used to identify it in places such as the
   * [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/) and [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/).
   * This defaults to the value of the Title property from the WMTS GetCapabilities request.
   */
  accessor title: string | null | undefined;
  /**
   * Creates a deep clone of the WMTS sublayer.
   *
   * @returns A deep clone of the WMTS sublayer instance that invoked this method.
   */
  clone(): WMTSSublayer;
}