/** * Provides utility method for getting the title of the layer or sublayer a graphic came from. * * @since 5.2 */ import type GraphicOrigin from "./GraphicOrigin.js"; /** * Returns a title that identifies the [origin](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#origin) of a graphic. * Use the returned title to show users which layer or sublayer a graphic came from when displaying query or hitTest results. * * If the origin's sublayer has a `title` property, the function returns that value. Otherwise, it returns the origin's layer title if the layer has a `title` property. * For example, for a graphic from a sublayer titled "Roads" in a layer titled "Transportation", the function returns "Roads". * * @param origin - The origin information associated with a graphic. See [Graphic.origin](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#origin). * @returns The sublayer's title if it has a `title` property, otherwise the layer's title * if it has a `title` property, or `undefined` if neither has one. * @since 5.2 * @example * Get the origin title of a graphic returned by a hit test or query. * ```js * if (graphic.origin) { * const title = getGraphicOriginTitle(graphic.origin); * console.log(title); * } * ``` */ export function getGraphicOriginTitle(origin: GraphicOrigin): string | null | undefined;