/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{getContrast as i}from"../../../core/colorUtils.js";import{watch as o,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{throttle as a}from"../../../core/throttle.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import n from"../../../layers/GraphicsLayer.js";import p from"../../../symbols/CIMSymbol.js";import{getConfig as h}from"./constants.js";import{createLineGeometry as m}from"./visualizationUtils.js";let d=class extends r{constructor(t){super(t),this._chartData=null,this._graphic=new e,this._layer=new n({listMode:"hide",internal:!0,title:"Profile line"}),this._update=t=>{const{chartData:e}=t;if(null==e)return this.remove();if(!e.refined)return;const r=e.lines.find(t=>t.viewVisualizationEnabled);if(!r)return;this._graphic.geometry=m(r,t.spatialReference),this._graphic.symbol=new p({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,10],lineDashEnding:"HalfPattern",controlPointEnding:"HalfPattern"}],capStyle:"Butt",width:1.5,color:r.color.toArray()},{type:"CIMSolidStroke",capStyle:"Butt",width:2,color:i(r.color).toArray()}]}}});const o=this.view?.map?.layers;o&&!o.includes(this._layer)&&o.add(this._layer)}}initialize(){this._layer.add(this._graphic);const t=h().profileLinesUpdateThrottleMillis;let e=this._update;if(t>0){const r=a(this._update,t);this.addHandles(r),e=r}this.addHandles(o(()=>({spatialReference:this.view.spatialReference,chartData:this._chartData}),e,s))}destroy(){this.remove()}remove(){this.view?.map?.remove(this._layer)}update(t){this._chartData=t}};t([l()],d.prototype,"view",void 0),t([l()],d.prototype,"_chartData",void 0),d=t([c("esri.widgets.ElevationProfile.support.ProfileLine2D")],d);export{d as ProfileLine2D};
