import type Viewshed from "../../../analysis/Viewshed.js";
import type ViewshedAnalysis from "../../../analysis/ViewshedAnalysis.js";
import type AnalysisView3D from "./AnalysisView3D.js";
import type { AbortOptions } from "../../../core/promiseUtils.js";
import type { ViewshedPlacementResult } from "./Viewshed/types.js";

/**
 * Represents the analysis view of a [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ViewshedAnalysis.html)
 * after it has been added to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#analyses).
 *
 * The ViewshedAnalysisView3D is responsible for rendering a [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ViewshedAnalysis.html)
 * using custom visualizations.
 *
 * It allows to create new viewsheds interactively using the [place()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#place) method,
 * or to make existing viewsheds selectable and editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#interactive) property.
 * To select a viewshed, hover and click on its field-of-view manipulators.
 *
 * 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
 * // create new analysis and add it to the view
 * const viewshedAnalysis = new ViewshedAnalysis();
 * view.analyses.add(viewshedAnalysis);
 *
 * // retrieve analysis view
 * const viewshedAnalysisView = await view.whenAnalysisView(viewshedAnalysis);
 * ```
 *
 * @since 4.30
 * @see [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ViewshedAnalysis.html)
 * @see [Viewshed](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-Viewshed.html)
 * @see [ViewshedLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ViewshedLayer.html)
 * @see [ViewshedLayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ViewshedLayerView.html)
 * @see [Sample - Interactive viewshed analysis](https://developers.arcgis.com/javascript/latest/sample-code/analysis-viewshed/)
 * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/)
 * @see [3D viewshed overview](https://developers.arcgis.com/documentation/spatial-analysis-services/3d-visual/3d-viewshed/)
 */
export default abstract class ViewshedAnalysisView3D extends AnalysisView3D {
  /** The viewshed analysis object associated with the analysis view. */
  get analysis(): ViewshedAnalysis;
  /**
   * Enables interactivity for the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#analysis). When set to `true` and the analysis includes any
   * valid [ViewshedAnalysis.viewsheds](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ViewshedAnalysis.html#viewsheds), they become selectable and editable.
   *
   * @default false
   */
  accessor interactive: boolean;
  /**
   * The selected viewshed. If [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#interactive) is `true`, any viewshed in the
   * [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#analysis) can be selected by clicking on it in the view. As long as [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#interactive)
   * remains `true`, the properties of the selected viewshed can be edited by interacting with
   * manipulators in the view.
   */
  accessor selectedViewshed: Viewshed | null | undefined;
  /** The analysis view type. */
  get type(): "viewshed-view-3d";
  /** When `true`, the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#analysis) is visualized in the view. */
  get visible(): boolean;
  set visible(value: boolean | null | undefined);
  /**
   * Starts the interactive creation of new viewsheds and adds them to the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#analysis).
   *
   * The first click in the scene places the observer point and the second sets the viewshed's orientation and distance.
   *
   * The creation process will finish when the user double-clicks the mouse or presses the escape key.
   * To stop the creation programmatically, pass an abort signal as an argument when calling the method.
   *
   * This method is similar to the [place()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#place) method, but it allows to create multiple viewsheds in a row.
   *
   * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#interactive) to `true`.
   *
   * > [!WARNING]
   * >
   * > Note that when placing viewsheds interactively, the viewshed is created with a 1.5 meter vertical offset from the scene.
   * > _This behavior is subject to change in a future release._
   *
   * @param options - An object specifying additional options.
   * @returns A promise which resolves when creation is completed successfully or rejected if it is
   * canceled.
   * @example
   * const abortController = new AbortController();
   *
   * try {
   *   await viewshedAnalysisView.createViewsheds({ signal: abortController.signal });
   * } catch (error) {
   *   if (error.name === "AbortError") {
   *     console.log("Creation operation was cancelled.");
   *   }
   * }
   *
   * // cancel the placement operation at some later point
   * abortController.abort();
   */
  createViewsheds(options?: AbortOptions | null | undefined): Promise<void>;
  /**
   * Starts the interactive placement of a single viewshed, adding it to the [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ViewshedAnalysisView3D.html#analysis).
   *
   * The first click in the scene places the observer point and the second sets the viewshed's orientation.
   *
   * 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-ViewshedAnalysisView3D.html#interactive) to `true`.
   *
   * > [!WARNING]
   * >
   * > Note that when placing viewsheds interactively, the viewshed is created with a 1.5 meter vertical offset from the scene.
   * > _This behavior is subject to change in a future release._
   *
   * @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<ViewshedPlacementResult>;
}