import type TimeInfo from "../support/TimeInfo.js";
import type TimeExtent from "../../time/TimeExtent.js";
import type TimeInterval from "../../time/TimeInterval.js";
import type { TimeInfoProperties } from "../support/TimeInfo.js";
import type { TimeExtentProperties } from "../../time/TimeExtent.js";
import type { TimeIntervalProperties } from "../../time/TimeInterval.js";

export interface TemporalLayerProperties extends Partial<Pick<TemporalLayer, "useViewTime">> {
  /**
   * The layer's time extent. When the layer's [useViewTime](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#useViewTime) is `false`, the layer
   * instructs the view to show data from the layer based on this time extent.
   * If the `useViewTime` is `true`, and both layer and view time extents are set, then features that fall within
   * the intersection of the view and layer time extents will be displayed.
   * For example, if the layer's time extent is set to display features between 1970 and 1975 and
   * the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975.
   *
   * @since 4.14
   * @example
   * if (!layer.useViewTime) {
   *   if (layer.timeExtent) {
   *     console.log("Current timeExtent:", layer.timeExtent.start, " - ", layer.timeExtent.end}
   *   } else {
   *     console.log("The layer will display data within the view's timeExtent.");
   *     console.log("Current view.timeExtent:", view.timeExtent.start, " - ", view.timeExtent.end}
   *   }
   * }
   * @example
   * // set the timeExtent on the layer and useViewTime false
   * // In this case, the layer will honor its timeExtent and ignore
   * // the view's timeExtent
   * const layer = new ImageryLayer({
   *   url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer",
   *   timeExtent: {
   *     start: new Date(2014, 4, 18),
   *     end: new Date(2014, 4, 19)
   *   },
   *   useViewTime: false
   * });
   * @example
   * // timeExtent is set on the layer and the view
   * // In this case, the layer will display features that fall
   * // within the intersection of view and layer time extents
   * // features within Jan 1, 1976 - Jan 1, 1981 will be displayed
   * const view = new MapView({
   *   timeExtent: {
   *     start: new Date(1976, 0, 1),
   *     end: new Date(2002, 0, 1)
   *   }
   * });
   * const layer = new FeatureLayer({
   *   url: myUrl,
   *   timeExtent: {
   *     start: new Date(1974, 0, 1),
   *     end: new Date(1981, 0, 1)
   *   }
   * });
   */
  timeExtent?: TimeExtentProperties | null;
  /**
   * TimeInfo provides information such as date fields that store
   * [start](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField)
   * and [end](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#endField) time
   * for each feature and the [fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent)
   * for the layer. The `timeInfo` property, along with its `startField` and `endField` properties, must be set at the
   * time of layer initialization if it is being set for a
   * [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/),
   * [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/) or
   * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
   * initialized from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#creating-a-featurelayer).
   * The [fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent) for `timeInfo` is
   * automatically calculated based on its `startField` and `endField` properties.
   * The timeInfo parameters cannot be changed after the layer is [loaded](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#load).
   *
   * TimeInfo's [TimeInfo.startField](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField) and [endField](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField)
   * can be `date`, `date-only` or `timestamp-offset` [field type](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#type) for [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
   * and [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/).
   *
   * @since 4.11
   * @example
   * // create geojson layer from usgs earthquakes geojson feed
   * const geojsonLayer = new GeoJSONLayer({
   *   url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
   *   copyright: "USGS Earthquakes",
   *   fields: [
   *     { "name": "mag", "type": "double" },
   *     { "name": "place", "type": "string" },
   *     { "name": "time", "type": "date" }, // date field
   *     { "name": "depth", "type": "double" }
   *   ],
   *   // timeInfo can be used to do temporal queries
   *   // set the startField and endField.
   *   // timeExtent is automatically calculated from the
   *   // the start and end date fields
   *   // The date values must be in milliseconds number from the UNIX epoch specified in UTC.
   *   timeInfo: {
   *     startField: "time"
   *   }
   * });
   */
  timeInfo?: TimeInfoProperties | null;
  /**
   * A temporary offset of the time data based on a certain [TimeInterval](https://developers.arcgis.com/javascript/latest/references/core/time/TimeInterval/). This allows
   * users to overlay features from two or more time-aware layers with different time extents.
   * For example, if a layer has data recorded for the year 1970, an offset value of 2 years would temporarily shift the data to
   * 1972. You can then overlay this data with data recorded in 1972.
   * A time offset can be used for display purposes only. The query and selection are not affected by the offset.
   *
   * @since 4.14
   * @example
   * // Offset a CSV Layer containing hurricanes from 2015 so that they appear in 2019 (+4 years).
   * let layer = new CSVLayer({
   *   url: `hurricanes-and-storms-2015.csv`,
   *   timeOffset: {
   *     value: 4,
   *     unit: "years"
   *   },
   *   timeInfo: {
   *     startField: "ISO_time"
   *   },
   *   renderer: {
   *     type: "simple",
   *     symbol: {
   *       type: "simple-marker",
   *       size: 6,
   *       color: "red",
   *       outline: {
   *         width: 0.5,
   *         color: "black"
   *       }
   *     }
   *   }
   * });
   */
  timeOffset?: TimeIntervalProperties | null;
}

/**
 * TemporalLayer is a mixin that adds [timeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#timeExtent), [timeInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#timeInfo),
 * [timeOffset](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#timeOffset) and [useViewTime](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#useViewTime) properties to layers that support temporal data.
 *
 * @since 4.11
 */
export abstract class TemporalLayer {
  constructor(...args: any[]);
  /**
   * The layer's time extent. When the layer's [useViewTime](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#useViewTime) is `false`, the layer
   * instructs the view to show data from the layer based on this time extent.
   * If the `useViewTime` is `true`, and both layer and view time extents are set, then features that fall within
   * the intersection of the view and layer time extents will be displayed.
   * For example, if the layer's time extent is set to display features between 1970 and 1975 and
   * the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975.
   *
   * @since 4.14
   * @example
   * if (!layer.useViewTime) {
   *   if (layer.timeExtent) {
   *     console.log("Current timeExtent:", layer.timeExtent.start, " - ", layer.timeExtent.end}
   *   } else {
   *     console.log("The layer will display data within the view's timeExtent.");
   *     console.log("Current view.timeExtent:", view.timeExtent.start, " - ", view.timeExtent.end}
   *   }
   * }
   * @example
   * // set the timeExtent on the layer and useViewTime false
   * // In this case, the layer will honor its timeExtent and ignore
   * // the view's timeExtent
   * const layer = new ImageryLayer({
   *   url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer",
   *   timeExtent: {
   *     start: new Date(2014, 4, 18),
   *     end: new Date(2014, 4, 19)
   *   },
   *   useViewTime: false
   * });
   * @example
   * // timeExtent is set on the layer and the view
   * // In this case, the layer will display features that fall
   * // within the intersection of view and layer time extents
   * // features within Jan 1, 1976 - Jan 1, 1981 will be displayed
   * const view = new MapView({
   *   timeExtent: {
   *     start: new Date(1976, 0, 1),
   *     end: new Date(2002, 0, 1)
   *   }
   * });
   * const layer = new FeatureLayer({
   *   url: myUrl,
   *   timeExtent: {
   *     start: new Date(1974, 0, 1),
   *     end: new Date(1981, 0, 1)
   *   }
   * });
   */
  get timeExtent(): TimeExtent | null | undefined;
  set timeExtent(value: TimeExtentProperties | null | undefined);
  /**
   * TimeInfo provides information such as date fields that store
   * [start](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField)
   * and [end](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#endField) time
   * for each feature and the [fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent)
   * for the layer. The `timeInfo` property, along with its `startField` and `endField` properties, must be set at the
   * time of layer initialization if it is being set for a
   * [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/),
   * [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/) or
   * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
   * initialized from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#creating-a-featurelayer).
   * The [fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent) for `timeInfo` is
   * automatically calculated based on its `startField` and `endField` properties.
   * The timeInfo parameters cannot be changed after the layer is [loaded](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#load).
   *
   * TimeInfo's [TimeInfo.startField](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField) and [endField](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField)
   * can be `date`, `date-only` or `timestamp-offset` [field type](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#type) for [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
   * and [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/).
   *
   * @since 4.11
   * @example
   * // create geojson layer from usgs earthquakes geojson feed
   * const geojsonLayer = new GeoJSONLayer({
   *   url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
   *   copyright: "USGS Earthquakes",
   *   fields: [
   *     { "name": "mag", "type": "double" },
   *     { "name": "place", "type": "string" },
   *     { "name": "time", "type": "date" }, // date field
   *     { "name": "depth", "type": "double" }
   *   ],
   *   // timeInfo can be used to do temporal queries
   *   // set the startField and endField.
   *   // timeExtent is automatically calculated from the
   *   // the start and end date fields
   *   // The date values must be in milliseconds number from the UNIX epoch specified in UTC.
   *   timeInfo: {
   *     startField: "time"
   *   }
   * });
   */
  get timeInfo(): TimeInfo | null | undefined;
  set timeInfo(value: TimeInfoProperties | null | undefined);
  /**
   * A temporary offset of the time data based on a certain [TimeInterval](https://developers.arcgis.com/javascript/latest/references/core/time/TimeInterval/). This allows
   * users to overlay features from two or more time-aware layers with different time extents.
   * For example, if a layer has data recorded for the year 1970, an offset value of 2 years would temporarily shift the data to
   * 1972. You can then overlay this data with data recorded in 1972.
   * A time offset can be used for display purposes only. The query and selection are not affected by the offset.
   *
   * @since 4.14
   * @example
   * // Offset a CSV Layer containing hurricanes from 2015 so that they appear in 2019 (+4 years).
   * let layer = new CSVLayer({
   *   url: `hurricanes-and-storms-2015.csv`,
   *   timeOffset: {
   *     value: 4,
   *     unit: "years"
   *   },
   *   timeInfo: {
   *     startField: "ISO_time"
   *   },
   *   renderer: {
   *     type: "simple",
   *     symbol: {
   *       type: "simple-marker",
   *       size: 6,
   *       color: "red",
   *       outline: {
   *         width: 0.5,
   *         color: "black"
   *       }
   *     }
   *   }
   * });
   */
  get timeOffset(): TimeInterval | null | undefined;
  set timeOffset(value: TimeIntervalProperties | null | undefined);
  /**
   * Determines if the time enabled layer will update its temporal data based on the view's
   * [timeExtent](https://developers.arcgis.com/javascript/latest/references/core/views/View/#timeExtent). When `false`, the layer will display its temporal
   * data based on the layer's [timeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/TemporalLayer/#timeExtent), regardless of changes to the view.
   * If both view and layer time extents are set while this property is `true`, then the features that fall within
   * the intersection of the view and layer time extents will be displayed.
   * For example, if a layer's time extent is set to display features between 1970 and 1975 and
   * the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975.
   *
   * Changing `useViewTime` to `false` does not affect layer's [visibilityTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#visibilityTimeExtent).
   *
   * @default true
   * @since 4.14
   * @example
   * if (featureLayer.useViewTime) {
   *   console.log("Displaying data between:", view.timeExtent.start, " - ", view.timeExtent.end);
   * }
   */
  accessor useViewTime: boolean;
}