import type Accessor from "../../core/Accessor.js";
import type FeatureLayer from "../../layers/FeatureLayer.js";
import type { AbortOptions } from "../../core/promiseUtils.js";

export interface NetworkSystemLayersProperties {
  /** @since 4.29 */
  associationsTableId?: number | null;
  /** @since 4.29 */
  associationsTableUrl?: string | null;
  /**
   * The layer ID of the service containing the utility network's [dirty areas](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/dirty-areas-in-a-utility-network.htm).
   *
   * @since 4.25
   */
  dirtyAreasLayerId?: number | null;
  /**
   * The service url containing the utility network's [dirty areas](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/dirty-areas-in-a-utility-network.htm).
   *
   * @since 4.25
   */
  dirtyAreasLayerUrl?: string | null;
  /**
   * The layer ID of the service containing the network rules table.
   *
   * @since 4.25
   */
  rulesTableId?: number | null;
  /**
   * The service url containing the network rules table.
   *
   * @since 4.25
   */
  rulesTableUrl?: string | null;
  /**
   * The layer ID of the service containing the utility network's [Subnetworks table](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/subnetworks-table.htm).
   * The Subnetworks table contains the information about all the existing and deleted subnetworks in a utility network.
   *
   * @since 4.25
   */
  subnetworksTableId?: number | null;
  /**
   * The service url containing the utility network's [Subnetworks table](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/subnetworks-table.htm).
   *
   * @since 4.25
   */
  subnetworksTableUrl?: string | null;
}

/**
 * The NetworkSystemLayers contains the url and IDs of the utility network rules, subnetworks, and dirty areas tables or layers.
 *
 * @since 4.25
 * @see [Network](https://developers.arcgis.com/javascript/latest/references/core/networks/Network/)
 * @see [UtilityNetwork](https://developers.arcgis.com/javascript/latest/references/core/networks/UtilityNetwork/)
 * @example
 * const [WebMap, MapView, esriConfig] = await $arcgis.import([
 *   "@arcgis/core/WebMap.js",
 *   "@arcgis/core/views/MapView.js",
 *   "@arcgis/core/config.js"
 * ]);
 * let utilityNetwork;
 *
 * // set the hostname to the portal instance
 * esriConfig.portalUrl = "https://myHostName.domain.com/arcgis";
 *
 * const webMap = new WebMap({
 *   portalItem: {
 *     id: "webmapID"
 *   }
 * });
 *
 * const mapView = new MapView({
 *   map: webMap
 * });
 *
 * webMap.when(async () => {
 *   // check if webMap contains utility networks
 *   if (webMap.utilityNetworks.length > 0) {
 *     // assign the utility network at index 0
 *     utilityNetwork = webMap.utilityNetworks.at(0);
 *
 *     // trigger the loading of the UtilityNetwork instance
 *     await utilityNetwork.load();
 *
 *     // Print the subnetworks table service url and id
 *     console.log(`Dirty areas layer id: ${utilityNetwork.networkSystemLayers.subnetworksTableId}`);
 *     console.log(`Dirty areas layer url: ${utilityNetwork.networkSystemLayers.subnetworksTableUrl}`);
 *   }
 * });
 */
export default class NetworkSystemLayers extends Accessor {
  constructor(properties?: NetworkSystemLayersProperties);
  /**
   * A [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) representing the associations
   * table. This layer is only loaded as needed, so the property has a default
   * value of `null`. It can be set by calling the
   * [loadAssociationsTable()](https://developers.arcgis.com/javascript/latest/references/core/networks/support/NetworkSystemLayers/#loadAssociationsTable) method.
   *
   * @since 4.32
   */
  get associationsTable(): FeatureLayer | null | undefined;
  /** @since 4.29 */
  get associationsTableId(): number | null | undefined;
  /** @since 4.29 */
  get associationsTableUrl(): string | null | undefined;
  /**
   * The layer ID of the service containing the utility network's [dirty areas](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/dirty-areas-in-a-utility-network.htm).
   *
   * @since 4.25
   */
  get dirtyAreasLayerId(): number | null | undefined;
  /**
   * The service url containing the utility network's [dirty areas](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/dirty-areas-in-a-utility-network.htm).
   *
   * @since 4.25
   */
  get dirtyAreasLayerUrl(): string | null | undefined;
  /**
   * The layer ID of the service containing the network rules table.
   *
   * @since 4.25
   */
  get rulesTableId(): number | null | undefined;
  /**
   * The service url containing the network rules table.
   *
   * @since 4.25
   */
  get rulesTableUrl(): string | null | undefined;
  /**
   * A [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) representing the subnetworks
   * table. This layer is only loaded as needed, so the property has a default
   * value of `null`. It can be set by calling the
   * [loadSubnetworksTable()](https://developers.arcgis.com/javascript/latest/references/core/networks/support/NetworkSystemLayers/#loadSubnetworksTable) method.
   *
   * @since 4.34
   */
  get subnetworksTable(): FeatureLayer | null | undefined;
  /**
   * The layer ID of the service containing the utility network's [Subnetworks table](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/subnetworks-table.htm).
   * The Subnetworks table contains the information about all the existing and deleted subnetworks in a utility network.
   *
   * @since 4.25
   */
  get subnetworksTableId(): number | null | undefined;
  /**
   * The service url containing the utility network's [Subnetworks table](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/subnetworks-table.htm).
   *
   * @since 4.25
   */
  get subnetworksTableUrl(): string | null | undefined;
  /**
   * Loads the layer identified by the `associationsTableUrl` property.
   *
   * @param options - An object containing an optional `signal` property that can be used to cancel the request.
   * @returns Resolves to a loaded instance of [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) representing the associations table.
   * @since 4.32
   */
  loadAssociationsTable(options?: AbortOptions | null | undefined): Promise<FeatureLayer>;
  /**
   * Loads the layer identified by the `subnetworksTableUrl` property.
   *
   * @param options - An object containing an optional `signal` property that can be used to cancel the request.
   * @returns Resolves to a loaded instance of [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) representing the subnetworks table.
   * @since 4.34
   */
  loadSubnetworksTable(options?: AbortOptions | null | undefined): Promise<FeatureLayer>;
}