import type DirectLineMeasurementAnalysis from "../../../analysis/DirectLineMeasurementAnalysis.js";
import type AnalysisView3D from "./AnalysisView3D.js";
import type { AbortOptions } from "../../../core/promiseUtils.js";
import type { DirectLineMeasurementAnalysisResult, DirectLineMeasurementPlacementResult } from "./DirectLineMeasurement/types.js";

/**
 * Represents the analysis view of a [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/)
 * after it has been added to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses).
 *
 * The DirectLineMeasurementAnalysisView3D is responsible for rendering a [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/)
 * using custom visualizations.
 *
 * It allows to create a new analysis interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/DirectLineMeasurementAnalysisView3D/#place) method, query the measured [result](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/DirectLineMeasurementAnalysisView3D/#result),
 * or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/DirectLineMeasurementAnalysisView3D/#interactive) property.
 *
 * The view for an analysis can be retrieved using [SceneView.whenAnalysisView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenAnalysisView)
 * similar to how layer views are retrieved for layers using [SceneView.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenLayerView).
 *
 * ```js
 * // retrieve analysis view for analysis
 * const analysis = new DirectLineMeasurementAnalysis();
 * view.analyses.add(analysis); // add to the scene view
 * const analysisView = await view.whenAnalysisView(analysis);
 * ```
 *
 * > [!WARNING]
 * >
 * > **Things to consider:**
 * > 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/references/core/layers/FeatureLayer/), [GraphicsLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GraphicsLayer/) (except Mesh geometries),
 * > [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/), [WFSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/), [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/),
 * > [3D Object SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/), and [BuildingSceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/BuildingSceneLayer/).
 *
 * @see [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/)
 * @see [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/)
 * @see [Sample - View themes](https://developers.arcgis.com/javascript/latest/sample-code/view-theme/)
 * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/)
 * @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/)
 */
export default abstract class DirectLineMeasurementAnalysisView3D extends AnalysisView3D {
  /**
   * The direct line measurement analysis object associated with the analysis view.
   *
   * @since 4.24
   */
  get analysis(): DirectLineMeasurementAnalysis;
  /**
   * Enables interactivity for the associated [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/DirectLineMeasurementAnalysisView3D/#analysis). When set to `true`, manipulators will be displayed,
   * allowing users to click and drag to edit the analysis if it has a valid
   * [DirectLineMeasurementAnalysis.startPoint](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/#startPoint) and
   * [DirectLineMeasurementAnalysis.endPoint](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/#endPoint).
   *
   * This property is automatically set to `true` when the analysis is assigned to a
   * [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/).
   *
   * @default false
   * @since 4.33
   */
  accessor interactive: boolean;
  /**
   * Result of the direct line measurement. Results are calculated asynchronously and should be
   * watched for changes.
   */
  accessor result: DirectLineMeasurementAnalysisResult | null | undefined;
  /**
   * The analysis view type.
   *
   * @since 4.24
   */
  get type(): "direct-line-measurement-view-3d";
  /**
   * When `true`, the analysis is visualized in the view.
   *
   * @since 4.24
   */
  get visible(): boolean;
  set visible(value: boolean | null | undefined);
  /**
   * Starts the interactive placement of a direct line measurement.
   *
   * If the analysis does not have a [DirectLineMeasurementAnalysis.startPoint](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/#startPoint)
   * and [DirectLineMeasurementAnalysis.endPoint](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/#endPoint) yet, the method allows placing
   * the start and end points interactively in the view. If the analysis already has a measurement, clicking in the view will remove it and
   * start the placement of new start and end points.
   *
   * 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/references/core/views/3d/analysis/DirectLineMeasurementAnalysisView3D/#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.33
   * @example
   * const abortController = new AbortController();
   *
   * try {
   *   await analysisView.place({ signal: abortController.signal });
   * } catch (error) {
   *   if (error.name === "AbortError") {
   *     console.log("Placement operation was cancelled.");
   *   }
   * }
   *
   * // cancel the placement operation at some later point
   * abortController.abort();
   */
  place(options?: AbortOptions | null | undefined): Promise<DirectLineMeasurementPlacementResult>;
}