/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as i,subclass as s}from"../../core/accessorSupport/decorators.js";import"../../libs/maquette/projection.js";import{h as o}from"../../libs/maquette/h.js";import"../../libs/maquette/projector.js";let r=class extends e{get startPosition(){return[this.startX,this.startY]}set startPosition(t){this._set("startX",t[0]),this._set("startY",t[1])}get endPosition(){return[this.endX,this.endY]}set endPosition(t){this._set("endX",t[0]),this._set("endY",t[1])}constructor(t){super(t),this.startX=0,this.startY=0,this.endX=0,this.endY=0,this.width=1,this.color=[0,0,0,.5],this.visible=!0,this.isDecoration=!0}get _strokeStyle(){const t=this.color;return`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}get _lineCap(){return"round"}render(){const{height:t,left:e,top:i,width:s,x1:r,x2:n,y1:a,y2:l}=this._calculateCoordinates(h),d=`stroke: ${this._strokeStyle}; stroke-width: ${this.width}; stroke-linecap: ${this._lineCap};`;return o("div",{classes:{"esri-line-overlay-item":!0},styles:{left:e+"px",top:i+"px",width:s+"px",height:t+"px",visibility:this.visible?"visible":"hidden"}},[o("svg",{width:s,height:t},[o("line",{x1:r,y1:a,x2:n,y2:l,style:d})])])}renderCanvas(t){if(!this.visible)return;t.strokeStyle=this._strokeStyle,t.lineWidth=this.width,t.lineCap=this._lineCap;const e=this._calculateCoordinates(h);t.beginPath(),t.moveTo(e.left+e.x1,e.top+e.y1),t.lineTo(e.left+e.x2,e.top+e.y2),t.stroke()}_calculateCoordinates(t){const e=Math.min(this.startX,this.endX),i=Math.max(this.startX,this.endX),s=Math.min(this.startY,this.endY),o=Math.max(this.startY,this.endY),r=this.width;return t.left=e-r,t.top=s-r,t.width=i-e+2*r,t.height=Math.max(20,o-s+2*r),t.x1=this.startX-e+r,t.y1=this.startY-s+r,t.x2=this.endX-e+r,t.y2=this.endY-s+r,t}};t([i()],r.prototype,"startX",void 0),t([i()],r.prototype,"startY",void 0),t([i()],r.prototype,"endX",void 0),t([i()],r.prototype,"endY",void 0),t([i()],r.prototype,"startPosition",null),t([i()],r.prototype,"endPosition",null),t([i()],r.prototype,"width",void 0),t([i()],r.prototype,"color",void 0),t([i()],r.prototype,"visible",void 0),t([i()],r.prototype,"isDecoration",void 0),t([i({readOnly:!0})],r.prototype,"_strokeStyle",null),r=t([s("esri.views.overlay.LineOverlayItem")],r);const h={left:0,top:0,width:0,height:0,x1:0,y1:0,x2:0,y2:0};export{r as default};
