
/** The time dimension interval. */
export interface DimensionInterval<T, K> {
  /** End of interval. */
  max: T;
  /** Start of interval. */
  min: T;
  /** Interval duration defined by the following properties. */
  resolution?: K;
}

export interface Duration {
  /** Number of days. */
  days: number;
  /** Number of hours. */
  hours: number;
  /** Number of minutes. */
  minutes: number;
  /** Number of months. */
  months: number;
  /** Number of seconds. */
  seconds: number;
  /** Number of years. */
  years: number;
}

export type DimensionExtent<T, K> = T[] | DimensionInterval<T, K>[];

export type GenericDimensionExtent = DimensionExtent<string, string>;

export type ElevationDimensionExtent = DimensionExtent<number, number>;

export type TimeDimensionExtent = DimensionExtent<Date, Duration | null | undefined>;

export interface Dimension<T> {
  /**
   * Default value(s) for the time dimension.
   * The default value will be used if the request does not include a value for the time dimension.
   */
  default?: T;
  /** Available value(s) for the time dimension. */
  extent: T;
  /** Indicates whether multiple values of the dimension may be requested. */
  multipleValues?: boolean;
  /** Indicates whether the nearest value of the dimension will be returned in response to a request for a nearby value. */
  nearestValue?: boolean;
}

/** Generic dimension information. */
export interface GenericDimension {
  /** Name of dimensional axis. */
  name: string;
}

/** Elevation dimension information. */
export interface ElevationDimension {
  /** Name of dimensional axis. */
  name: "elevation";
}

/**
 * Time dimension information. For example, the WMS service might be published to show hourly weather information.
 * The TimeDimension can be used to update [View#timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#timeExtent),
 * [WMSLayer#timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#timeExtent), or to configure a [TimeSlider](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-TimeSlider.html) widget.
 */
export interface TimeDimension extends Omit<Dimension<TimeDimensionExtent>, "unitSymbol"> {
  /** Name of dimensional axis. */
  name: "time";
  /** Units of dimensional axis. */
  units: "ISO8601";
}

export type WMSDimension = ElevationDimension | GenericDimension | TimeDimension;