import type Extent from "../../geometry/Extent.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { ExtentProperties } from "../../geometry/Extent.js";

/** @since 5.0 */
export interface QuantizationParametersProperties extends Partial<Pick<QuantizationParameters, "originPosition" | "tolerance">> {
  /**
   * An extent defining the quantization grid bounds. Its
   * [SpatialReference](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/) matches the input geometry spatial reference if one is
   * specified for the query. Otherwise, the extent will be in the layer's spatial reference.
   *
   * @since 5.0
   */
  extent?: ExtentProperties | null;
}

/**
 * QuantizationParameters define how geometries are to be quantized (converted to integers) in the response from a [Query](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/) operation.
 * Used to project the geometry onto a virtual grid, likely representing pixels on the screen. Geometry coordinates are converted to integers by building a grid
 * with a resolution matching the [tolerance](https://developers.arcgis.com/javascript/latest/references/core/rest/support/QuantizationParameters/#tolerance). Each coordinate is then snapped to one pixel on the grid.
 *
 * @see [Query.quantizationParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#quantizationParameters)
 * @since 5.0
 */
export default class QuantizationParameters extends JSONSupport {
  constructor(properties?: QuantizationParametersProperties);
  /**
   * An extent defining the quantization grid bounds. Its
   * [SpatialReference](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/) matches the input geometry spatial reference if one is
   * specified for the query. Otherwise, the extent will be in the layer's spatial reference.
   *
   * @since 5.0
   */
  get extent(): Extent | null | undefined;
  set extent(value: ExtentProperties | null | undefined);
  /**
   * Geometry coordinates are optimized for viewing and displaying of data.
   *
   * @default "view"
   * @since 5.0
   */
  get mode(): "view" | "edit";
  /**
   * The integer's coordinates will be returned
   * relative to the origin position defined by this property value.
   *
   * @default "upper-left"
   * @since 5.0
   */
  accessor originPosition: "upper-left" | "lower-left";
  /**
   * The size of one pixel in the units of the [outSpatialReference](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outSpatialReference).
   * This number is used to convert coordinates to integers by building a grid with a resolution matching the tolerance.
   * Each coordinate is then snapped to one pixel on the grid. Consecutive coordinates snapped to the same pixel are removed
   * for reducing the overall response size. The units of tolerance will match the units of [outSpatialReference](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outSpatialReference).
   * If `outSpatialReference` is not specified, then tolerance is assumed to be in the units of the spatial
   * reference of the layer. If tolerance is not specified, the [maxAllowableOffset](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#maxAllowableOffset) is used.
   * If tolerance and `maxAllowableOffset` are not specified, a grid of 10,000 * 10,000 grid is used by default.
   *
   * @default 1
   * @since 5.0
   */
  accessor tolerance: number;
}