/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{eyeWithinExtent as o}from"../../camera/intersectionUtils.js";import{applySurfaceCollisionConstraint as s}from"../../camera/constraintUtils/surfaceCollision.js";import{CameraController as i}from"./CameraController.js";let a=class extends i{constructor(e){super(e)}set desiredCamera(e){this._set("desiredCamera",e.clone())}get canStop(){return!0}get constraintEnabled(){return this.view.state.constraints.collision.enabled}onControllerStart(){this.state=2,this.addHandles(this.view.elevationProvider.on("elevation-change",e=>this._elevationChangeEvent(e))),this._applyCorrection()}onControllerEnd(){this.removeAllHandles()}_elevationChangeEvent(e){null!=e.spatialReference&&!o(this.view,this.desiredCamera,e.extent,e.spatialReference)||"ground"!==e.context||this._applyCorrection()}_applyCorrection(){this.view.state.updateCamera(e=>{e.copyViewFrom(this.desiredCamera),s(this.view,e,1)||this.constraintEnabled||(this.state=3)})}};e([t({constructOnly:!0})],a.prototype,"desiredCamera",null),a=e([r("esri.views.3d.state.controllers.SurfaceCollisionCorrectionController")],a);export{a as SurfaceCollisionCorrectionController};
