/*
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 r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as i,watch as n}from"../core/reactiveUtils.js";import{property as s,subclass as a}from"../core/accessorSupport/decorators.js";import o from"./3d/layers/IntegratedMesh3DTilesLayerView3D.js";import{toExtent as l}from"./3d/support/cameraUtils.js";import{GroundElevationSampler as p}from"./support/GroundElevationSampler.js";import{IntegratedMeshElevationSampler as d}from"./support/IntegratedMeshElevationSampler.js";let u=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles([i(()=>this.view?.map?.ground,async e=>e.load()),n(()=>!this.hasTerrainReplacement,e=>{this.view?.basemapTerrain?.enable(e)})])}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=>e instanceof o&&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 integratedMeshElevationSampler(){return this.view?new d({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([s()],u.prototype,"hasTerrainReplacement",null),e([s({readOnly:!0})],u.prototype,"elevationSampler",null),e([s({readOnly:!0})],u.prototype,"integratedMeshElevationSampler",null),e([s({readOnly:!0})],u.prototype,"extent",null),e([s({type:Boolean,readOnly:!0})],u.prototype,"updating",null),e([s({constructOnly:!0})],u.prototype,"view",void 0),e([s({type:t,readOnly:!0})],u.prototype,"layerViews",void 0),e([s({readOnly:!0})],u.prototype,"suspended",null),u=e([a("esri.views.GroundView")],u);const m=u;export{m as default};
