import type VolumeMeasurementAnalysis from "../../../analysis/VolumeMeasurementAnalysis.js";
import type AnalysisView3D from "./AnalysisView3D.js";
import type VolumeMeasurementError from "./VolumeMeasurement/VolumeMeasurementError.js";
import type VolumeMeasurementResult from "./VolumeMeasurement/VolumeMeasurementResult.js";
import type { AbortOptions } from "../../../core/promiseUtils.js";
import type { VolumeMeasurementPlacementResult } from "./VolumeMeasurement/types.js";

/**
 * Represents the analysis view of a [VolumeMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-VolumeMeasurementAnalysis.html)
 * after it has been added to [SceneView#analyses](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#analyses).
 *
 * The VolumeMeasurementAnalysisView3D is responsible for rendering a [VolumeMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-VolumeMeasurementAnalysis.html)
 * using custom visualizations. The properties
 * on the analysis view provide developers with the ability to query measured results. If the result is unavailable, the [error](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurementAnalysisView3D.html#error) property provides the details on the cause.
 *
 * The view for an analysis can be retrieved using [SceneView#whenAnalysisView()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#whenAnalysisView)
 * similar to how layer views are retrieved for layers using [SceneView#whenLayerView()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#whenLayerView).
 * ```js
 * // retrieve analysis view for analysis
 * const analysis = new VolumeMeasurementAnalysis();
 * view.analyses.add(analysis); // add to the scene view
 * const analysisView = await view.whenAnalysisView(analysis);
 * ```
 *
 * > [!WARNING]
 * >
 * > **Things to consider:**
 * > When using the "cut-fill" [VolumeMeasurementAnalysis#measureType](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-VolumeMeasurementAnalysis.html#measureType) in [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurementAnalysisView3D.html#interactive) mode, hover over the shift manipulator, press `Tab` to activate the tooltip input mode, and enter the elevation of the target surface.
 * > Snapping is enabled by default. This can be temporarily disabled by holding the `CTRL` key.
 * > Layer types currently supported for snapping are: [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) (except Mesh geometries),
 * > [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html), [WFSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WFSLayer.html), [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html),
 * > [3D Object SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html), and [BuildingSceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BuildingSceneLayer.html).
 *
 * @beta
 * @since 4.34
 * @see [VolumeMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-VolumeMeasurementAnalysis.html)
 * @see [VolumeMeasurementResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurement-VolumeMeasurementResult.html)
 * @see [VolumeMeasurementError](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurement-VolumeMeasurementError.html)
 * @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/)
 * @see [Sample - Volume measurement analysis object](https://developers.arcgis.com/javascript/latest/sample-code/analysis-volume-measurement/)
 */
export default abstract class VolumeMeasurementAnalysisView3D extends AnalysisView3D {
  /** The volume measurement analysis object associated with the analysis view. */
  get analysis(): VolumeMeasurementAnalysis;
  /**
   * Error encountered while calculating the analysis result. The error has well defined names that can be used
   * to provide specific error feedback to the user. See [VolumeMeasurementError](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurement-VolumeMeasurementError.html) for the list of possible error names.
   */
  get error(): VolumeMeasurementError | null | undefined;
  /**
   * Enables interactivity for the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurementAnalysisView3D.html#analysis). When set to `true` the input geometry can be edited
   * interactively.
   *
   * @default false
   */
  accessor interactive: boolean;
  /**
   * Result of the volume measurement. Results are calculated asynchronously and should be
   * watched for changes.
   */
  get result(): VolumeMeasurementResult | null | undefined;
  /** The analysis view type. */
  get type(): "volume-measurement-view-3d";
  /** When `true`, the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurementAnalysisView3D.html#analysis) is visualized in the view. */
  get visible(): boolean;
  set visible(value: boolean | null | undefined);
  /**
   * Starts the interactive placement of a new polygon for the volume measurement analysis.
   *
   * If the analysis does not have a [VolumeMeasurementAnalysis#geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-VolumeMeasurementAnalysis.html#geometry) yet, the method
   * allows drawing it interactively in the view. Otherwise, clicking in the view will remove the previous geometry and
   * start a new placement operation.
   *
   * The placement operation will finish when the user presses the escape key.
   * To stop the placing programmatically, pass an abort signal as an argument when calling the method.
   *
   * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-VolumeMeasurementAnalysisView3D.html#interactive) to `true`.
   *
   * @param options - An object specifying additional options.
   * @returns A promise which resolves when the operation is completed successfully or rejected if it is canceled.
   * @since 4.34
   * @example
   * // cancel the placement operation at some later point
   * // by calling abortController.abort()
   * const abortController = new AbortController();
   *
   * try {
   *   await analysisView.place({ signal: abortController.signal });
   * } catch (error) {
   *   if (error.name === "AbortError") {
   *     console.log("Placement operation was cancelled.");
   *   }
   * }
   */
  place(options?: AbortOptions | null | undefined): Promise<VolumeMeasurementPlacementResult>;
}