import type ControlPointsGeoreference from "../support/ControlPointsGeoreference.js";
import type CornersGeoreference from "../support/CornersGeoreference.js";
import type ExtentAndRotationGeoreference from "../support/ExtentAndRotationGeoreference.js";
import type ImageElement from "../support/ImageElement.js";
import type VideoElement from "../support/VideoElement.js";

/**
 * Represents animation options, a collection of properties that apply when the [ImageElement.image](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageElement.html#image) is an animated GIF or APNG.
 *
 * @since 4.28
 */
export interface AnimationOptions {
  /**
   * Indicates whether the animated image should play its animation.
   *
   * @since 5.0
   */
  playing?: boolean;
  /**
   * Represents the number of seconds it takes to play through the layer's animation once.
   *
   * @since 5.0
   */
  duration?: number;
  /**
   * Determines how to repeat the animation of a layer when the animation cycle ends.
   *
   * @since 5.0
   */
  repeatType?: "none" | "loop" | "oscillate";
  /**
   * Represents the number of seconds to delay before repeating an animation cycle.
   *
   * @since 5.0
   */
  repeatDelay?: number;
}

/**
 * Image and video elements referenced in the MediaLayer.
 *
 * @since 4.24
 * @see [LocalMediaElementSource.elements](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LocalMediaElementSource.html#elements)
 */
export type MediaElement = ImageElement | VideoElement;

/**
 * Describes the georeferencing information for a media layer element.
 * This type allows specifying how an image or video is positioned and oriented in map coordinates.
 * Supported georeferencing types include:
 * - [CornersGeoreference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CornersGeoreference.html): Uses the coordinates of the four corners of the media.
 * - [ExtentAndRotationGeoreference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ExtentAndRotationGeoreference.html): Uses an extent and a rotation angle.
 * - [ControlPointsGeoreference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ControlPointsGeoreference.html): Uses a set of control points for more complex transformations.
 *
 * @since 5.0
 */
export type Georeference = CornersGeoreference | ExtentAndRotationGeoreference | ControlPointsGeoreference;

/**
 * Represents HTML elements that can supply image content for media layers.
 *
 * @since 5.0
 */
export type HTMLImageContainer = HTMLImageElement | HTMLCanvasElement;

/**
 * Represents binary image inputs that can be used as sources for media layers.
 * Accepts either DOM-based images/canvas elements or raw `ImageData`.
 *
 * @since 5.0
 */
export type ImageBinarySource = HTMLImageContainer | ImageData;

/**
 * Represents image sources accepted by media layers, either a URL/string reference or binary image content.
 *
 * @since 5.0
 */
export type ImageSource = string | ImageBinarySource;

/**
 * Represents video sources accepted by media layers, either a URL/string reference, an `HTMLVideoElement`, or `null`.
 *
 * @since 5.0
 */
export type VideoSource = string | HTMLVideoElement | null | undefined;