/**
 * Provides utility functions for the [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/).
 *
 * @since 4.30
 * @see [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/)
 */
import type CatalogLayer from "../CatalogLayer.js";
import type Layer from "../Layer.js";

/**
 * Utility method to check if the layer is temporarily available in the map and can be removed at any time because it is part of a [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/).
 *
 * It recursively checks if the [layer's parent](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#parent) is [CatalogLayer.dynamicGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/#dynamicGroupLayer).
 *
 * Use this utility to selectively exclude layers from your user experience.
 * For example, to limit the options available for these layers in the [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/).
 *
 * @param layer - The layer to test.
 * @returns `true` if the layer or its parent is part of a catalog.
 * @example
 * // Get all layer not part of a catalog.
 * const layers = map.allLayers.filter((layer) => !isLayerFromCatalog(layer))
 */
export function isLayerFromCatalog(layer: Layer): boolean;

/**
 * Utility method to get the parent [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/) for a given layer in
 * [CatalogDynamicGroupLayer.layers](https://developers.arcgis.com/javascript/latest/references/core/layers/catalog/CatalogDynamicGroupLayer/#layers) collection.
 *
 * @param layer - The layer for which the [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/) is to be retrieved.
 * @returns The catalog for that layer when it can be found.
 * @example
 * // Highlight the footprint for a layer if it's part of a catalog dynamic grouplayer.
 * function highlightFootprintForLayer(view, layer) {
 *   const catalog = getCatalogLayerForLayer(layer);
 *
 *   if (catalog) {
 *     const footprint = catalog.createFootprintFromLayer(layer);
 *
 *     if (footprint) {
 *       const catalogLayerView = view.allLayerViews.find((layerView) => layerView.layer === catalog);
 *       return catalogLayerView?.footprintLayerView?.highlight(footprint);
 *     }
 *   }
 *
 *   return { remove() {} };
 * }
 */
export function getCatalogLayerForLayer(layer: Layer): CatalogLayer | null | undefined;