import type Extent from "../../../geometry/Extent.js";
import type Polygon from "../../../geometry/Polygon.js";
import type RasterFunction from "../../support/RasterFunction.js";
import type AlgorithmicColorRamp from "../../../rest/support/AlgorithmicColorRamp.js";
import type FeatureSet from "../../../rest/support/FeatureSet.js";
import type MultipartColorRamp from "../../../rest/support/MultipartColorRamp.js";
import type { RasterBandStatistics, RasterCommonPixelType, RasterHistogram } from "../types.js";
import type { RasterColormapName, RasterColorRampName } from "../../../renderers/support/raster/types.js";

/**
 * Raster argument used to specify raster(s) used in raster processing.
 *
 * @since 4.28
 */
export type RasterPrimaryArgument = string | RasterFunction;

/**
 * Raster argument used to specify raster(s) used in raster processing.
 * When the input raster is the image service itself and if the raster function takes:
 * * A single input raster: the raster parameter can be omitted.
 * * Multiple input rasters: the image service raster needs to be represented using [defaultRaster](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-rasterFunctionUtils.html#defaultRaster) as `("$$")`.
 *
 * When the input raster is the result of a another raster function processing:
 * * Set the raster parameter to a result of a raster function.
 *
 * When the raster function takes more than one input rasters:
 * * One of the input (usually the first) must be either another raster function or an image service raster
 * * Additional rasters can also be specified in the form of a scalar, e.g. 100.
 * When the function is applied on a dynamic image service:
 * * `$RasterId` (e.g. "$1") can be used to reference a raster by its objectId.
 *
 * @since 4.28
 */
export type RasterArgument = number | RasterPrimaryArgument;

/**
 * Input parameters for performing math operations on one input raster.
 *
 * @since 4.28
 */
export interface BaseRasterFunctionParameters {
  /**
   * The input raster. Default is the image service.
   *
   * @since 5.0
   */
  raster?: RasterPrimaryArgument;
  /**
   * The output pixel type, default is `unknown`.
   *
   * @default "unknown"
   * @since 5.0
   */
  outputPixelType?: RasterCommonPixelType;
}

/**
 * Input parameters for perform math operations between two rasters.
 *
 * @since 4.28
 */
export interface Base2RasterFunctionParameters {
  /**
   * The first raster (pre changes).
   *
   * @since 5.0
   */
  raster: RasterArgument;
  /**
   * The second raster (post changes).
   *
   * @since 5.0
   */
  raster2: RasterArgument;
  /**
   * The output pixel type, default is unknown.
   *
   * @since 5.0
   */
  outputPixelType?: RasterCommonPixelType;
}

/** @since 5.0 */
export interface BaseNRasterFunctionParameters {
  /**
   * The input raster. Default is the image service.
   *
   * @since 5.0
   */
  rasters: RasterArgument[];
  /**
   * The output pixel type, default is unknown.
   *
   * @default "unknown"
   * @since 5.0
   */
  outputPixelType?: RasterCommonPixelType;
}

/** @since 5.0 */
export type ConvolutionType = "user-defined" | "line-detection-horizontal" | "line-detection-vertical" | "line-detection-left-diagonal" | "line-detection-right-diagonal" | "gradient-north" | "gradient-west" | "gradient-east" | "gradient-south" | "gradient-north-east" | "gradient-north-west" | "smooth-arithmetic-mean" | "smoothing3x3" | "smoothing5x5" | "sharpening3x3" | "sharpening5x5" | "laplacian3x3" | "laplacian5x5" | "sobel-horizontal" | "sobel-vertical" | "sharpen" | "sharpen2" | "point-spread" | "none";

/** @since 4.28 */
export interface ConvolutionFunctionParameters extends BaseRasterFunctionParameters {
  /**
   * The convolution type.
   *
   * @since 5.0
   */
  convolutionType: Exclude<ConvolutionType, "user-defined">;
}

/** @since 4.28 */
export interface ConvolutionFunctionCustomParameters extends BaseRasterFunctionParameters {
  /**
   * The convolution type must be "user-defined".
   *
   * @since 5.0
   */
  convolutionType?: "user-defined";
  /**
   * The number of rows, only needed for user-defined kernel.
   *
   * @since 5.0
   */
  rows: number;
  /**
   * The number of columns, only needed for user-defined kernel
   *
   * @since 5.0
   */
  cols: number;
  /**
   * The kernel size of rows x columns arranged in row-major order.
   *
   * @since 5.0
   */
  kernel: number[];
}

/** @since 5.0 */
export interface ContrastBrightnessParameters extends BaseRasterFunctionParameters {
  /**
   * Contrast offset from -100 to 100.
   *
   * @since 5.0
   */
  contrastOffset: number;
  /**
   * Brightness offset from -100 to 100.
   *
   * @since 5.0
   */
  brightnessOffset: number;
}

/** @since 5.0 */
export interface BaseStretchParameters extends BaseRasterFunctionParameters {
  /**
   * When true, perform dynamic range adjustment (not supported on client side)
   *
   * @since 5.0
   */
  dynamicRangeAdjustment?: boolean;
  /**
   * The minimum output value. Default is 0.
   *
   * @since 5.0
   */
  outputMin?: number;
  /**
   * The maximum output value. Default is 255.
   *
   * @since 5.0
   */
  outputMax?: number;
  /**
   * When true, gamma stretch is applied.
   *
   * @since 5.0
   */
  useGamma?: boolean;
  /**
   * The gamma values used for each band, needed when useGamma is true.
   *
   * @since 5.0
   */
  gamma?: number[];
}

/** @since 5.0 */
export interface MinMaxStretchParameters extends BaseStretchParameters {
  /**
   * The avg and stddev in each band's statistics
   * is used along with numberOfStandardDeviations to calculate the cut off pixels values beling stretched. Default is the input data source's statistics.
   *
   * @since 5.0
   */
  statistics?: RasterBandStatistics[];
}

/** @since 5.0 */
export interface StddevStretchParameters extends MinMaxStretchParameters {
  /**
   * Values with in the given number of standard deviations are stretched to
   * [outputMin, outputMax], those fall outside are clamped.
   *
   * @since 5.0
   */
  numberOfStandardDeviations?: number;
}

/** @since 5.0 */
export interface PercentClipStretchParameters extends BaseStretchParameters {
  /**
   * Percentage of the lowest pixel values to be excluded.
   *
   * @since 5.0
   */
  minPercent?: number;
  /**
   * Percentage of the highest pixel values to be excluded.
   *
   * @since 5.0
   */
  maxPercent?: number;
}

/** @since 5.0 */
export interface NDVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * Output values are linearly scaled to 0 to 200 when scientificOutput is false. Default is true.
   *
   * @since 5.0
   */
  scientificOutput?: boolean;
}

/** @since 5.0 */
export interface SAVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The amount of green vegetation cover from 0 to 1. Default is 0.33.
   *
   * @since 5.0
   */
  factor?: number;
}

/** @since 5.0 */
export interface TSAVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The soil line slope. Default is 0.33.
   *
   * @since 5.0
   */
  slope?: number;
  /**
   * The soil line intercept. Default is 0.5.
   *
   * @since 5.0
   */
  intercept?: number;
  /**
   * The adjustment factor to minimize soil noise. Default is 1.5.
   *
   * @since 5.0
   */
  factor?: number;
}

/** @since 5.0 */
export interface MSAVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
}

/** @since 5.0 */
export interface GEMIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
}

/** @since 5.0 */
export interface PVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The soil line slope. Default is 0.3.
   *
   * @since 5.0
   */
  slope?: number;
  /**
   * The soil line gradient. Default is 0.5.
   *
   * @since 5.0
   */
  gradient?: number;
}

/** @since 5.0 */
export interface LandsatBandParameters extends BaseRasterFunctionParameters {
  /**
   * The bandIds array representing Landsat band 1, 2, 3, 4, 5, 7.
   *
   * @since 5.0
   */
  bandIds: [
      number,
      number,
      number,
      number,
      number,
      number
  ];
}

/** @since 5.0 */
export interface SultanParameters extends BaseRasterFunctionParameters {
  /**
   * The bandIds array representing band 1, 3, 4, 5, 6.
   *
   * @since 5.0
   */
  bandIds: [
      number,
      number,
      number,
      number,
      number
  ];
}

/** @since 5.0 */
export interface VARIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
  /**
   * The 0-based blue band id.
   *
   * @since 5.0
   */
  blueBandId: number;
}

/** @since 5.0 */
export interface GDNVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
}

/** @since 5.0 */
export interface SRBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
}

/** @since 5.0 */
export interface NDVIreBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red edge band id.
   *
   * @since 5.0
   */
  reBandId: number;
}

/** @since 5.0 */
export interface SRreBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red edge band id.
   *
   * @since 5.0
   */
  reBandId: number;
}

/** @since 5.0 */
export interface MTVI2BandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
}

/** @since 5.0 */
export interface RTVICoreBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red edge band id.
   *
   * @since 5.0
   */
  reBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
}

/** @since 5.0 */
export interface CIreBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red edge band id.
   *
   * @since 5.0
   */
  reBandId: number;
}

/** @since 5.0 */
export interface CIgBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
}

/** @since 5.0 */
export interface NDWIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
}

/** @since 5.0 */
export interface EVIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The 0-based blue band id.
   *
   * @since 5.0
   */
  blueBandId: number;
}

/** @since 5.0 */
export interface IronOxideBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The 0-based blue band id.
   *
   * @since 5.0
   */
  blueBandId: number;
}

/** @since 5.0 */
export interface FerrousMineralsBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
}

/** @since 5.0 */
export interface ClayMineralsBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based shortwave infrared band id centering around 1.5—1.75µm.
   *
   * @since 5.0
   */
  swir1BandId: number;
  /**
   * The 0-based shortwave infrared band id centering around 2.08—2.35µm.
   *
   * @since 5.0
   */
  swir2BandId: number;
}

/** @since 5.0 */
export interface WNDWIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
  /**
   * A weighted coefficient ranging from 0 to 1. Default is 0.5.
   *
   * @since 5.0
   */
  alpha?: number;
}

/** @since 5.0 */
export interface BAIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based red band id.
   *
   * @since 5.0
   */
  redBandId: number;
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
}

/** @since 5.0 */
export interface NBRBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
}

/** @since 5.0 */
export interface NDBIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
}

/** @since 5.0 */
export interface NDMIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based near infrared band id.
   *
   * @since 5.0
   */
  nirBandId: number;
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
}

/** @since 5.0 */
export interface NDSIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
}

/** @since 5.0 */
export interface MNDWIBandParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based green band id.
   *
   * @since 5.0
   */
  greenBandId: number;
  /**
   * The 0-based shortwave infrared band id.
   *
   * @since 5.0
   */
  swirBandId: number;
}

/** @since 5.0 */
export interface CustomBandParameters extends BaseRasterFunctionParameters {
  /**
   * The custom band index, e.g. (b1 - b0) / (b1 + b0)
   *
   * @since 5.0
   */
  bandIndexes: string;
}

/**
 * Change methods for compute change raster function.
 *
 * @since 5.0
 */
export type ChangeMethod = "difference" | "relative-difference" | "categorical" | "euclidean-distance" | "angle-difference" | "band-with-most-change";

/**
 * Change keep methods for compute change raster function.
 *
 * @since 5.0
 */
export type ChangeKeepMethod = "all" | "changed" | "unchanged";

/** @since 5.0 */
export interface ComputeChangeParameters extends Base2RasterFunctionParameters {
  /**
   * The method used to compute changes.
   *
   * @since 5.0
   */
  method: ChangeMethod;
  /**
   * Choose what to keep for categorical changes.
   *
   * @since 5.0
   */
  keepMethod?: ChangeKeepMethod;
}

/** @since 5.0 */
export interface GrayscaleParameters extends BaseRasterFunctionParameters {
  /**
   * The weights applied to each input band. Weights are often applied because some bands have variable importance depending on the application.
   *
   * @since 5.0
   */
  weights: number[];
}

/** @since 5.0 */
export interface ColorspaceConversionParameters extends BaseRasterFunctionParameters {
  /**
   * The conversion type.
   *
   * @since 5.0
   */
  conversionType: "rgb-to-hsv" | "hsv-to-rgb";
}

/** @since 5.0 */
export interface SpectralConversionParameters extends BaseRasterFunctionParameters {
  /**
   * The matrix used to convert the input raster arranged in row-major order.
   *
   * @since 5.0
   */
  conversionMatrix: number[] | number[][];
}

/**
 * Raster colormap input parameters specified using a colormap.
 *
 * @since 4.28
 */
export interface ColormapParameters extends BaseRasterFunctionParameters {
  /**
   * The colormap.
   *
   * @since 5.0
   */
  colormap: number[][] | PixelValueToColor[];
}

/**
 * A pixel value to color mapping.
 *
 * @since 4.28
 */
export interface PixelValueToColor {
  /**
   * Pixel value.
   *
   * @since 5.0
   */
  value: number;
  /**
   * Color represented using [r,g,b] or [r,g,b,a], or the color's name or hex string.
   *
   * @since 5.0
   */
  color: number[] | string;
}

/**
 * Raster colormap input parameters specified using colormap name.
 *
 * @since 4.28
 */
export interface ColormapByNameParameters extends BaseRasterFunctionParameters {
  /**
   * The name of a predefined colorramp or colormap.
   *
   * @since 5.0
   */
  colorRampName: RasterColorRampName | RasterColormapName;
}

/**
 * Raster colormap input parameters specified using a colorramp.
 *
 * @since 4.28
 */
export interface ColormapByRampParameters extends BaseRasterFunctionParameters {
  /**
   * A colorramp
   *
   * @since 5.0
   */
  colorRamp: AlgorithmicColorRamp | MultipartColorRamp;
}

/** @since 5.0 */
export interface StatisticsHistogramParameters extends BaseRasterFunctionParameters {
  /**
   * The statistics parameter.
   *
   * @since 5.0
   */
  statistics: RasterBandStatistics[];
  /**
   * The histogram parameter.
   *
   * @since 5.0
   */
  histograms?: RasterHistogram[];
}

/** @since 5.0 */
export interface TableParameters extends BaseRasterFunctionParameters {
  /**
   * The attribute table represented using a feature set.
   *
   * @since 5.0
   */
  attributeTable: FeatureSet;
}

/**
 * Extract bands parameters specified using band ids.
 *
 * @since 4.28
 */
export interface ExtractBandByIdParameters extends BaseRasterFunctionParameters {
  /**
   * The 0-based band ids.
   *
   * @since 5.0
   */
  bandIds: number[];
  /**
   * Indicate whether to use best possible matching band when the requested band is missing.
   *
   * @since 5.0
   */
  missingBandAction?: "fail" | "best-match";
}

/**
 * Extract bands parameters specified using band names.
 *
 * @since 4.28
 */
export interface ExtractBandByNameParameters extends BaseRasterFunctionParameters {
  /**
   * The band names.
   *
   * @since 5.0
   */
  bandNames: string[];
  /**
   * Indicate whether to use best possible matching band when the requested band is missing.
   *
   * @since 5.0
   */
  missingBandAction?: "fail" | "best-match";
}

/**
 * Extract bands parameters specified using band wavelengths.
 *
 * @since 4.28
 */
export interface ExtractBandByWavelengthParameters extends BaseRasterFunctionParameters {
  /**
   * The band wavelengths.
   *
   * @since 5.0
   */
  bandWavelengths: number[];
  /**
   * Indicate whether to use best possible matching band when the requested band is missing.
   *
   * @since 5.0
   */
  missingBandAction?: "fail" | "best-match";
}

/**
 * Create color composite input parameters using band ids.
 *
 * @since 4.32
 */
export interface ColorCompositeByIdParameters extends BaseRasterFunctionParameters {
  /**
   * Red band id.
   *
   * @since 5.0
   */
  redBand: number;
  /**
   * Green band id.
   *
   * @since 5.0
   */
  greenBand: number;
  /**
   * Blue band id.
   *
   * @since 5.0
   */
  blueBand: number;
  /**
   * The composition method.
   *
   * @since 5.0
   */
  method: "id";
}

/**
 * Create color composite input parameters using band names or expressions. The supported operators are unary: plus (+), minus (-), times (*), and divide (/).
 * Using B1 for the first band of the input raster, B2 for the second band, and so on.
 *
 * @since 4.32
 */
export interface ColorCompositeByNameParameters extends BaseRasterFunctionParameters {
  /**
   * Red band name or expression, e.g. "B1"
   *
   * @since 5.0
   */
  redBand: string;
  /**
   * Green band name or expression, e.g. "B2"
   *
   * @since 5.0
   */
  greenBand: string;
  /**
   * Blue band name or expression, e.g. "B1-B2"
   *
   * @since 5.0
   */
  blueBand: string;
  /**
   * The composition method.
   *
   * @since 5.0
   */
  method: "name";
}

/** @since 5.0 */
export interface RemapParameters extends BaseRasterFunctionParameters {
  /**
   * Range maps.
   *
   * @since 5.0
   */
  rangeMaps?: PixelValueRangeMap[];
  /**
   * When true, unmatched pixel values are passed through or replaced with a constant. When false, unmatched pixel values are set to NoData.
   *
   * @since 5.0
   */
  allowUnmatched?: boolean;
  /**
   * The value that will replace missing or unmatched values in the output when allowUnmatched is true.
   *
   * @since 5.0
   */
  replacementValue?: number;
}

/**
 * Range map pixel values.
 *
 * @since 4.28
 */
export interface PixelValueRangeMap {
  /**
   * The pixel value range.
   *
   * @since 5.0
   */
  range: [
      number,
      number
  ];
  /**
   * The mapped pixel value. Null or undefined will produce NoData as the output.
   *
   * @since 5.0
   */
  output?: number | null;
}

/** @since 5.0 */
export interface TransposeBitsParameters extends BaseRasterFunctionParameters {
  /**
   * The position of the input bits.
   *
   * @since 5.0
   */
  inputBitPositions: number[];
  /**
   * The position of the output bits.
   *
   * @since 5.0
   */
  outputBitPositions: number[];
  /**
   * Specify a raster to be used to fill in all bits that are not involved in the transpose.
   *
   * @since 5.0
   */
  fillRaster?: RasterArgument;
}

/** @since 5.0 */
export interface MaskParameters extends BaseRasterFunctionParameters {
  /**
   * The included values for each band. Each band is specified using a range [from, to].
   *
   * @since 5.0
   */
  includedRanges?: [
      number,
      number
  ][];
  /**
   * The nodata values for each band.
   *
   * @since 5.0
   */
  noDataValues?: number[][];
  /**
   * Result is no data if all bands are nodata when match-all is specified, any if any band is nodata when match-any is specified. Default is match-any.
   *
   * @since 5.0
   */
  noDataInterpretation?: "match-any" | "match-all";
}

/** @since 5.0 */
export interface ClipParameters extends BaseRasterFunctionParameters {
  /**
   * An extent or a polygon geometry to define the clip shape.
   *
   * @since 5.0
   */
  geometry: Extent | Polygon;
  /**
   * When `false`, the imagery within the clip geometry will be kept in the output. When `true`, imagery outside of the clip geometry will be kept and the imagery
   * inside the clip geometry will be discarded.
   *
   * @since 5.0
   */
  keepOutside?: boolean;
}

/**
 * SetNull parameters
 *
 * @since 4.28
 */
export interface SetNullParameters extends BaseRasterFunctionParameters {
  /**
   * The input raster.
   *
   * @since 5.0
   */
  raster: RasterPrimaryArgument;
  /**
   * The false raster.
   *
   * @since 5.0
   */
  falseRaster: RasterArgument;
}

/**
 * Conditional parameters
 *
 * @since 4.28
 */
export interface ConditionalParameters extends BaseRasterFunctionParameters {
  /**
   * The input raster.
   *
   * @since 5.0
   */
  raster: RasterPrimaryArgument;
  /**
   * The true raster.
   *
   * @since 5.0
   */
  trueRaster: RasterArgument;
  /**
   * The false raster.
   *
   * @since 5.0
   */
  falseRaster: RasterArgument;
}

/** @since 5.0 */
export type CellStatisticsType = "majority" | "max" | "mean" | "median" | "min" | "minority" | "range" | "stddev" | "sum" | "variety";

export interface CellStatisticsParameters extends BaseNRasterFunctionParameters {
  /** The true raster, if the first input is a raster. */
  statisticsType: CellStatisticsType;
  /** When true, process the single input raster as multiple bands. Default is true. */
  processAsMultiband?: boolean;
}

/** @since 5.0 */
export interface CalculatorParameters extends BaseNRasterFunctionParameters {
  /**
   * The input names.
   *
   * @since 5.0
   */
  inputNames: string[];
  /**
   * The expression.
   *
   * @since 5.0
   */
  expression: string;
}

/** @since 5.0 */
export interface WeightedSumParameters extends BaseNRasterFunctionParameters {
  /**
   * The weight for each raster.
   *
   * @since 5.0
   */
  weights: number[];
  /**
   * The field used to perform the weighted sum. Default is Value.
   *
   * @since 5.0
   */
  fields?: string[];
}

/** @since 5.0 */
export interface WeightedOverlayParameters extends BaseNRasterFunctionParameters {
  /**
   * The relative weight for each raster. This will be normalized internally to make the total weight 100%.
   *
   * @since 5.0
   */
  weights: number[];
  /**
   * The minimum scale of the mapped output
   *
   * @since 5.0
   */
  minScale: number;
  /**
   * The maximum scale of the mapped output.
   *
   * @since 5.0
   */
  maxScale: number;
  /**
   * The value to scale map for each input raster. Each raster's map is represented using an array of [fromValue, toScale].
   *
   * @since 5.0
   */
  valueToScaleMaps?: number[][][];
  /**
   * The nodata values for each input raster.
   *
   * @since 5.0
   */
  noDataValues?: number[][];
  /**
   * The restricted values for each input raster.
   *
   * @since 5.0
   */
  restrictedValues?: number[][];
  /**
   * The field used to perform the weighted sum. Default is Value.
   *
   * @since 5.0
   */
  fields?: string[];
}

/** @since 5.0 */
export type FocalStatisticsType = "min" | "max" | "mean" | "stddev" | "median" | "majority" | "minority";

/** @since 5.0 */
export interface StatisticsParameters extends BaseRasterFunctionParameters {
  /**
   * Number of rows.
   *
   * @since 5.0
   */
  rows: number;
  /**
   * Number of columns.
   *
   * @since 5.0
   */
  cols: number;
  /**
   * The statistics type
   *
   * @since 5.0
   */
  statisticsType: FocalStatisticsType;
  /**
   * When true only fills noData pixels
   *
   * @since 5.0
   */
  fillNoDataOnly?: boolean;
}

/**
 * Arg statistics input parameters for min, max, and median statistics type.
 *
 * @since 4.32
 */
export interface ArgStatisticsParameters extends BaseNRasterFunctionParameters {
  /**
   * A constant value that will be used when no definitive maximum or minimum can be attained.
   *
   * @default 100
   * @since 5.0
   */
  undefinedClass?: number;
  /**
   * The statistics type.
   *
   * @since 5.0
   */
  statisticsType: "max" | "min" | "median";
}

/**
 * Arg statistics input parameters for duration statistics type.
 *
 * @since 4.32
 */
export interface ArgStatisticsDurationParameters extends BaseNRasterFunctionParameters {
  /**
   * The lowest value equal to or greater than the beginning of the duration.
   *
   * @since 5.0
   */
  minValue: number;
  /**
   * The highest value equal to or less than the end of the duration.
   *
   * @since 5.0
   */
  maxValue: number;
  /**
   * The statistics type.
   *
   * @since 5.0
   */
  statisticsType: "duration";
}

/**
 * Raster slope type.
 *
 * @since 5.0
 */
export type RasterSlopeType = "degree" | "percent-rise" | "adjusted";

/** @since 5.0 */
export interface SlopeParameters extends BaseRasterFunctionParameters {
  /**
   * The slope type.
   *
   * @since 5.0
   */
  slopeType: RasterSlopeType;
  /**
   * The z factor.
   *
   * @since 5.0
   */
  zFactor: number;
  /**
   * Used for adjusted slope type. It is the exponent applied to the pixel size term in the equation
   * that controls the rate at which the Z Factor changes to avoid significant loss of relief.
   *
   * @since 5.0
   */
  pixelSizePower?: number;
  /**
   * Used for adjusted slope type. It controls the rate at which the Z Factor changes.
   *
   * @since 5.0
   */
  pixelSizeZFactor?: number;
  /**
   * When true, applies edge effect removal. This option is only supported on server side by [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) only.
   *
   * @since 5.0
   */
  removeEdgeEffect?: boolean;
}

/**
 * Raster curvature type.
 *
 * @since 5.0
 */
export type RasterCurvatureType = "standard" | "planform" | "profile";

/** @since 5.0 */
export interface CurvatureParameters extends BaseRasterFunctionParameters {
  /**
   * The curvature type.
   *
   * @since 5.0
   */
  curvatureType: RasterCurvatureType;
  /**
   * The z factor.
   *
   * @since 5.0
   */
  zFactor: number;
}

/** @since 5.0 */
export interface HillshadeParameters extends BaseRasterFunctionParameters {
  /**
   * The hillshade type.
   *
   * @since 5.0
   */
  hillshadeType: "traditional" | "multi-directional";
  /**
   * The z factor.
   *
   * @since 5.0
   */
  zFactor: number;
  /**
   * The altitude.
   *
   * @since 5.0
   */
  altitude?: number;
  /**
   * The azimuth.
   *
   * @since 5.0
   */
  azimuth?: number;
  /**
   * The scaling type.
   *
   * @since 5.0
   */
  scalingType?: "none" | "adjusted";
  /**
   * Used for adjusted scaling type. It is the exponent applied to the pixel size term in the equation
   * that controls the rate at which the Z Factor changes to avoid significant loss of relief.
   *
   * @since 5.0
   */
  pixelSizePower?: number;
  /**
   * Used for adjusted scaling type. It controls the rate at which the Z Factor changes.
   *
   * @since 5.0
   */
  pixelSizeZFactor?: number;
  /**
   * When true, applies edge effect removal. This option is only supported on server side by [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) only.
   *
   * @since 5.0
   */
  removeEdgeEffect?: boolean;
}

/** @since 4.31 */
export interface ShadedReliefWithColorRampParameters extends HillshadeParameters {
  /**
   * The color ramp used to tint the hillshade.
   *
   * @since 5.0
   */
  colorRamp: AlgorithmicColorRamp | MultipartColorRamp;
}

/** @since 4.31 */
export interface ShadedReliefWithColormapParameters extends HillshadeParameters {
  /**
   * The color map used to tint the hillshade.
   *
   * @since 5.0
   */
  colormap: number[][];
}

/** @since 4.31 */
export interface ShadedReliefWithColorRampNameParameters extends HillshadeParameters {
  /**
   * The name of the color ramp used to tint the hillshade.
   *
   * @since 5.0
   */
  colorRampName: RasterColorRampName;
}