/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/tslib.es6","../../../../core/Handles","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../camera/constraintUtils","../../camera/intersectionUtils","./CameraController","../../camera/constraintUtils/surfaceCollision"],(function(e,t,r,o,n,i,s,a,l,c,u,C,p){"use strict";e.SurfaceCollisionCorrectionController=function(e){function r(t){var r;return(r=e.call(this,t)||this).handles=new o,r}t._inheritsLoose(r,e);var n=r.prototype;return n.onControllerStart=function(){this.state=C.State.Running,this.handles.add(this.view.basemapTerrain.on("elevation-change",(e=>this._handleElevationChangeEvent(e)))),this._applyCorrection()},n.onControllerEnd=function(){this.handles.removeAll()},n.stepController=function(){},n._handleElevationChangeEvent=function(e){u.eyeWithinExtent(this.view,this.desiredCamera,e.extent,e.spatialReference)&&this._applyCorrection()},n._applyCorrection=function(){this.view.state.updateCamera((e=>{e.copyViewFrom(this.desiredCamera),p.applySurfaceCollisionConstraint(this.view,e,p.Mode.EYE_AND_CENTER)||this.constraintEnabled||(this.state=C.State.Stopped)}))},t._createClass(r,[{key:"desiredCamera",set:function(e){this._set("desiredCamera",e.clone())}},{key:"canStop",get:function(){return!0}},{key:"constraintEnabled",get:function(){return this.view.state.constraints.collision.enabled}}]),r}(C.CameraController),r.__decorate([n.property({constructOnly:!0})],e.SurfaceCollisionCorrectionController.prototype,"view",void 0),r.__decorate([n.property({constructOnly:!0})],e.SurfaceCollisionCorrectionController.prototype,"desiredCamera",null),e.SurfaceCollisionCorrectionController=r.__decorate([l.subclass("esri.views.3d.state.controllers.SurfaceCollisionCorrectionController")],e.SurfaceCollisionCorrectionController),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
