import type Extent from "../../geometry/Extent.js";
import type Multipoint from "../../geometry/Multipoint.js";
import type Point from "../../geometry/Point.js";
import type Polygon from "../../geometry/Polygon.js";
import type Polyline from "../../geometry/Polyline.js";
import type MosaicRule from "../../layers/support/MosaicRule.js";
import type TimeExtent from "../../time/TimeExtent.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { RasterInterpolation } from "../../layers/raster/types.js";
import type { PolygonProperties } from "../../geometry/Polygon.js";
import type { ExtentProperties } from "../../geometry/Extent.js";
import type { PolylineProperties } from "../../geometry/Polyline.js";
import type { MultipointProperties } from "../../geometry/Multipoint.js";
import type { PointProperties } from "../../geometry/Point.js";
import type { MosaicRuleProperties } from "../../layers/support/MosaicRule.js";
import type { TimeExtentProperties } from "../../time/TimeExtent.js";

export interface ImageSampleParametersProperties extends Partial<Pick<ImageSampleParameters, "interpolation" | "outFields" | "returnFirstValueOnly" | "sampleCount" | "sampleDistance" | "sliceId">> {
  /**
   * Input geometry that defines the locations to be sampled.
   * The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/), [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/),
   * [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/), [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) or
   * a [Polygon](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polygon/).
   *
   * The [locations](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#locations) property can be used to set an array of [points](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) for convenience if the geometry is
   * a `multipoint`. If you set the `locations` property, the array of points will be converted to a `multipoint` geometry at runtime.
   */
  geometry?: (PointProperties & { type: "point" }) | (MultipointProperties & { type: "multipoint" }) | (PolylineProperties & { type: "polyline" }) | (ExtentProperties & { type: "extent" }) | (PolygonProperties & { type: "polygon" });
  /**
   * When sampling multiple locations, you can use an array of [points](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) instead of providing
   * a [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) for the [geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#geometry) property. The array of points will be converted
   * to a `multipoint` and used as the [geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#geometry) at runtime.
   * The first point's spatial reference is used in `getSamples` operation.
   */
  locations?: PointProperties[] | null;
  /**
   * Specifies the [mosaic rule](https://developers.arcgis.com/javascript/latest/references/core/layers/support/MosaicRule/) defining the image sort order and selection.
   * When a mosaic rule is not specified, the current settings on the [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/) will be used.
   */
  mosaicRule?: MosaicRuleProperties | null;
  /**
   * Specifies the pixel size (or the resolution) that will be used for the sampling. If pixel size is not specified, `pixelSize` will default to the base resolution of the image service.
   * The raster at the specified pixel size in the mosaic dataset will be used for this operation.
   */
  pixelSize?: PointProperties | null;
  /**
   * The [time extent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) for which to perform sampling.
   * This parameter is supported at ArcGIS Server 10.9 and later.
   */
  timeExtent?: TimeExtentProperties | null;
}

/**
 * Input parameters for the [ImageryLayer.getSamples()](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/#getSamples)
 * method on [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/).
 *
 * @since 4.20
 * @see [ImageryLayer.getSamples()](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/#getSamples)
 * @see [ImageSampleResult](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleResult/)
 */
export default class ImageSampleParameters extends JSONSupport {
  constructor(properties?: ImageSampleParametersProperties);
  /**
   * Input geometry that defines the locations to be sampled.
   * The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/), [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/),
   * [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/), [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) or
   * a [Polygon](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polygon/).
   *
   * The [locations](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#locations) property can be used to set an array of [points](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) for convenience if the geometry is
   * a `multipoint`. If you set the `locations` property, the array of points will be converted to a `multipoint` geometry at runtime.
   */
  get geometry(): Point | Multipoint | Polyline | Extent | Polygon;
  set geometry(value: (PointProperties & { type: "point" }) | (MultipointProperties & { type: "multipoint" }) | (PolylineProperties & { type: "polyline" }) | (ExtentProperties & { type: "extent" }) | (PolygonProperties & { type: "polygon" }));
  /**
   * Defines how to interpolate pixel values.
   *
   * @default "nearest"
   */
  accessor interpolation: RasterInterpolation;
  /**
   * When sampling multiple locations, you can use an array of [points](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) instead of providing
   * a [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) for the [geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#geometry) property. The array of points will be converted
   * to a `multipoint` and used as the [geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#geometry) at runtime.
   * The first point's spatial reference is used in `getSamples` operation.
   */
  get locations(): Point[] | null | undefined;
  set locations(value: PointProperties[] | null | undefined);
  /**
   * Specifies the [mosaic rule](https://developers.arcgis.com/javascript/latest/references/core/layers/support/MosaicRule/) defining the image sort order and selection.
   * When a mosaic rule is not specified, the current settings on the [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/) will be used.
   */
  get mosaicRule(): MosaicRule | null | undefined;
  set mosaicRule(value: MosaicRuleProperties | null | undefined);
  /** The list of fields associated with the rasters to be included in the response. */
  accessor outFields: string[] | null | undefined;
  /**
   * Specifies the pixel size (or the resolution) that will be used for the sampling. If pixel size is not specified, `pixelSize` will default to the base resolution of the image service.
   * The raster at the specified pixel size in the mosaic dataset will be used for this operation.
   */
  get pixelSize(): Point | null | undefined;
  set pixelSize(value: PointProperties | null | undefined);
  /**
   * When `true`, returns the first valid pixel value that meets specified conditions at each sampling point location.
   * When `false`, all pixel values are returned.
   *
   * @default true
   */
  accessor returnFirstValueOnly: boolean;
  /**
   * Specifies the approximate number of locations to sample from the provided geometry when the input geometry is [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/),
   * [Polygon](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polygon/) or [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/).
   *  Either `sampleDistance` or `sampleCount` is needed to perform densification on the input [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/) to sample points.
   * The unit of the geometry's spatial reference will be used for the densification.
   */
  accessor sampleCount: number | null | undefined;
  /**
   * Specifies the distance interval to sample points from the provided [geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ImageSampleParameters/#geometry) when input geometry is [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/).
   * Either `sampleDistance` or `sampleCount` is needed to perform densification on the input [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/) to sample points.
   * The unit of the geometry's spatial reference will be used for the densification.
   */
  accessor sampleDistance: number | null | undefined;
  /** Specifies the slice id of a multidimensional raster. This parameter is supported at ArcGIS Server 10.9 and later. */
  accessor sliceId: number | null | undefined;
  /**
   * The [time extent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) for which to perform sampling.
   * This parameter is supported at ArcGIS Server 10.9 and later.
   */
  get timeExtent(): TimeExtent | null | undefined;
  set timeExtent(value: TimeExtentProperties | null | undefined);
}