/*
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 t from"../../../../core/Accessor.js";import{watch as i,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{throttle as o}from"../../../../core/throttle.js";import{property as r,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fromValues as a,fromArray as n}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{absoluteHeightElevationInfo as p}from"../../../../support/elevationInfoUtils.js";import{OutlineVisualElement as m}from"../../interactive/visualElements/OutlineVisualElement.js";import{getConfig as c}from"../../../analysis/ElevationProfile/constants.js";import{ElevationProfileHoveredPointVisualization as f}from"../../../analysis/ElevationProfile/ElevationProfileHoveredPointVisualization.js";import{createLineGeometry as h}from"../../../analysis/ElevationProfile/elevationProfileVisualizationUtils.js";let u=class extends t{constructor(e){super(e),this._hasGeometry=!1,this._updateGeometryThrottled=o(e=>{e&&this._setGeometry(h(e.samples,e.spatialReference))},c().profileLinesUpdateThrottleMillis)}initialize(){this._indicatorVisualization=new f({analysisViewData:this.analysisViewData,line:this.line,view:this.view}),this._visualElement=new m({view:this.view,elevationInfo:p,innerWidth:0,innerColor:a(0,0,0,0),width:3,falloff:0,renderOccluded:16,isDecoration:!0}),this.addHandles([i(()=>this._effectiveLineVisible,e=>{this._visualElement.visible=e},s),i(()=>this._effectiveIndicatorVisible,e=>{this._indicatorVisualization.visible=e},s),i(()=>this._result?.computation.profile.color,e=>{e&&(this._visualElement.color=n(e.toUnitRGBA()))},s),i(()=>this.analysisViewData.analysis.geometry,()=>this._setGeometry(null),s),i(()=>this._geometryUpdateParameters,e=>this._updateGeometryThrottled(e),s),this._updateGeometryThrottled])}destroy(){this._visualElement.destroy(),this._indicatorVisualization.destroy()}get updating(){return this._updateGeometryThrottled.hasPendingUpdates()}get _result(){return this.analysisViewData.results.find(e=>e.computation.profile===this.line)}get _effectiveLineVisible(){return this.getEffectiveVisible("lineVisible")}get _effectiveIndicatorVisible(){const e=this.getEffectiveVisible("hoveredPointVisible");return this._effectiveLineVisible?e&&this._hasGeometry:e}getEffectiveVisible(e){const{analysisViewData:t,_result:i}=this;return t.visible&&!!i?.available&&i.computation.profile.viewOptions[e]}get _geometryUpdateParameters(){const e={samples:this._result?.samples,spatialReference:this.view.spatialReference};return e.samples&&this._effectiveLineVisible&&1!==this.analysisViewData.progress?null:e}_setGeometry(e){this._hasGeometry=null!=e,this._visualElement.geometry=e}};e([r({constructOnly:!0})],u.prototype,"view",void 0),e([r({constructOnly:!0})],u.prototype,"analysisViewData",void 0),e([r({constructOnly:!0})],u.prototype,"line",void 0),e([r()],u.prototype,"_hasGeometry",void 0),e([r()],u.prototype,"updating",null),e([r()],u.prototype,"_result",null),e([r()],u.prototype,"_effectiveLineVisible",null),e([r()],u.prototype,"_effectiveIndicatorVisible",null),e([r()],u.prototype,"_geometryUpdateParameters",null),u=e([l("esri.views.3d.analysis.ElevationProfile.ElevationProfileLineVisualization3D")],u);export{u as ElevationProfileLineVisualization3D};
