/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import o from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../../core/accessorSupport/decorators.js";import{getConfig as d}from"./constants.js";import{AnchorElementViewModel as a}from"../../support/AnchorElementViewModel.js";let c=class extends o{constructor(e){super(e),this._hoveredPoints=new t}initialize(){this.addHandles(r(()=>this._hoveredPoints.toArray().map(({anchor:e,element:o})=>({screenLocation:e.screenLocation,element:o})),e=>{for(const{screenLocation:o,element:t}of e)o&&(t.style.transform=`translate(${o.x}px, ${o.y}px)`)},i))}destroy(){this._hoveredPoints.drain(e=>this._destroyHoveredPoint(e))}update(e){const o=this.view,t=this._hoveredPoints,r=e.length;for(;this._hoveredPoints.length>r;)this._destroyHoveredPoint(this._hoveredPoints.pop());for(;this._hoveredPoints.length<r;){const e=this._makeHoveredPoint();t.push(e),o.surface?.appendChild(e.element)}for(let i=0;i<r;++i){const o=t.at(r-1-i),s=e[i];this._updateHoveredPoint(o,s)}}_makeHoveredPoint(){const{size:e,borderStyle:o,borderColor:t,borderWidth:r,boxShadow:i}=d().hoveredPointsStyle,s=this.view,n=new a({view:s,screenLocationEnabled:!0}),c=document.createElement("div"),h=c.style;return h.position="absolute",h.top="0",h.left="0",h.contain="strict",h.boxSizing="border-box",h.width=`${e}px`,h.height=`${e}px`,h.marginTop=`-${e/2}px`,h.marginLeft=`-${e/2}px`,h.border=`${o} ${r}px ${t}`,h.borderRadius=`${e}px`,h.boxShadow=i,{anchor:n,element:c}}_updateHoveredPoint({anchor:e,element:o},t){e.screenLocationEnabled=!0,e.location=t.hoveredPoint;const r=o.style;r.display="block",r.background=t.color.toCss()}_destroyHoveredPoint({anchor:e,element:o}){e.destroy(),this.view.surface?.removeChild(o)}};e([s()],c.prototype,"view",void 0),e([s()],c.prototype,"_hoveredPoints",void 0),c=e([n("esri.widgets.ElevationProfile.support.HoveredPoints")],c);export{c as HoveredPoints};
