import type { SpriteInfo } from "./types.js";

/**
 * The sprite source returned from the [VectorTileLayer#setSpriteSource()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setSpriteSource) method.
 *
 * SpriteSource holds the resources needed to render patterned (textured) markers, lines and polygons. These resources are
 * both an image and metrics (JSON). Each element is identified by a unique name
 *
 * @since 4.0
 */
export default abstract class SpriteSource {
  /** The base URL to where the sprites are (both JSON and PNG) */
  baseURL?: string | null;
  /**
   * The device pixel ratio of the sprite source.
   *
   * @default 1
   */
  devicePixelRatio: number;
  /** The height in pixels of the sprite source. */
  readonly height: number;
  /** The sprite image data. */
  readonly image?: Uint8Array | null;
  /**
   * Indicates whether the sprite source is loaded successfully.
   *
   * @default "not-loaded"
   */
  loadStatus: "not-loaded" | "loading" | "failed" | "loaded";
  /** The width in pixels of the sprite source. */
  readonly width: number;
  /**
   * Returns the sprite info for the given sprite.
   *
   * @param name - Name of the sprite to get the information for.
   * @returns Sprite info containing the dimension and pixel ratio of the image and its location within the sprite image.
   * @since 4.25
   */
  getSpriteInfo(name: string): SpriteInfo | null | undefined;
}

/** @deprecated since 5.0. use [getSpriteInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-SpriteSource.html#getSpriteInfo) instead. */
export type GetSpriteInfo = SpriteSource["getSpriteInfo"];