/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as s,watch as i}from"../core/reactiveUtils.js";import{property as n,subclass as a}from"../core/accessorSupport/decorators.js";import{isIntegratedMesh3DTilesLayerView3D as o}from"./3d/layers/support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{toExtent as l}from"./3d/support/cameraUtils.js";import{GroundElevationSampler as p}from"./support/GroundElevationSampler.js";let d=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles([s(()=>this.view?.map?.ground,async e=>e.load()),i(()=>!this.hasTerrainReplacement,e=>{this.view?.basemapTerrain?.enable(e)},{sync:!0})])}get hasTerrainReplacement(){const{view:e}=this;if("3d"!==e?.type||!e.map?.basemap)return!1;return!!e.map.basemap.groundLayers.some(r=>(!!e.basemapView?.groundLayerViews.find(e=>o(e)&&e.ready&&(e.layer===r||e.canRecycleWith(r)))||e.layerViewManager.isRecyclingLayerViewForLayer(r))&&"replacesTerrain"in r&&r.replacesTerrain)}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null),this.layerViews.destroyAll()}get elevationSampler(){return"3d"===this.view.type?new p({view:this.view}):null}get extent(){const{view:e}=this;return e?.ready?l(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(({updating:e})=>e)}get suspended(){return this.view?.suspended??!0}};e([n()],d.prototype,"hasTerrainReplacement",null),e([n({readOnly:!0})],d.prototype,"elevationSampler",null),e([n({readOnly:!0})],d.prototype,"extent",null),e([n({type:Boolean,readOnly:!0})],d.prototype,"updating",null),e([n({constructOnly:!0})],d.prototype,"view",void 0),e([n({type:t,readOnly:!0})],d.prototype,"layerViews",void 0),e([n({readOnly:!0})],d.prototype,"suspended",null),d=e([a("esri.views.GroundView")],d);const u=d;export{u as default};
