/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import has from"../../../../core/has.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{PointVisualElement as s}from"../../interactive/visualElements/PointVisualElement.js";let r=class extends t{constructor(e){super(e),this.elevationInfo=null,this._active=!1,this._visuals=new Map}destroy(){for(const e of this._visuals.keys())this.removeVisual(e)}activate(){this._active=!0,this._refreshVisuals()}refresh(){this._refreshVisuals()}deactivate(){this._active=!1;for(const{element:e}of this._visuals.values())e.attached=!1}addOrUpdateGraphic(e,t){}addOrUpdateVisual(e,t){if(!has("enable-feature:analysis-drawtool-line-of-sight-placement-visuals"))return;const i=this._visuals.get(e),o=u(t,i?.props);if(!n(o))return void this.removeVisual(e);if(i)return i.props=o,void this._applyVisual(i.element,o);const r=new s({view:this.view,attached:!1,isDecoration:!0,outlineSize:1,pixelSnappingEnabled:!1,primitive:"circle",size:8});this._visuals.set(e,{element:r,props:o}),this._applyVisual(r,o)}removeGraphic(e){}removeVisual(e){const t=this._visuals.get(e);t&&(t.element.destroy(),this._visuals.delete(e))}hitTestVisualDistance(e,t){return null}_refreshVisuals(){for(const{element:e,props:t}of this._visuals.values())this._applyVisual(e,t)}_applyVisual(e,t){const i=l(t.geometry);if(!i)return void(e.attached=!1);e.geometry=i,e.elevationInfo=this.elevationInfo,e.attached=this._active;const{color:o,outlineColor:s,size:r}=c(this.view,t.role,t.state);e.color=o,e.outlineColor=s,e.size=r}};function n(e){return null!=l(e.geometry)&&("cursor"===e.role||"controlPoint"===e.role)}function l(e){if(!e)return null;switch(e.type){case"point":return e;case"multipoint":return a(e);default:return null}}function a(e){return 0===e.points.length?null:e.getPoint(e.points.length-1)}function u(e,t={geometry:null,role:"outputGeometry",state:"idle"}){return{...t,...e}}function c(e,t,i){const o=e.effectiveTheme.accentColor.toUnitRGBA(),s="active"===i?1:"focused"===i?.95:.85,r="controlPoint"===t?7:"active"===i?10:8;return{color:[o[0],o[1],o[2],s],outlineColor:[0,0,0,.45],size:r}}e([i({constructOnly:!0})],r.prototype,"view",void 0),e([i()],r.prototype,"elevationInfo",void 0),e([i()],r.prototype,"_active",void 0),r=e([o("esri.views.3d.analysis.LineOfSight.LineOfSightDrawToolRenderer")],r);export{r as LineOfSightDrawToolRenderer};
