/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Accessor","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../libs/maquette/projection","../../libs/maquette/h","../../libs/maquette/projector"],(function(t,e,o,r,i,s,n,l,a,c,h){"use strict";const p={bottom:"esri-text-overlay-item-anchor-bottom","bottom-right":"esri-text-overlay-item-anchor-bottom-right","bottom-left":"esri-text-overlay-item-anchor-bottom-left",top:"esri-text-overlay-item-anchor-top","top-right":"esri-text-overlay-item-anchor-top-right","top-left":"esri-text-overlay-item-anchor-top-left",center:"esri-text-overlay-item-anchor-center",right:"esri-text-overlay-item-anchor-right",left:"esri-text-overlay-item-anchor-left"};let d=function(e){function o(t){var o;return(o=e.call(this,t)||this).x=0,o.y=0,o.text="-",o.fontSize=14,o.anchor="center",o.visible=!0,o._backgroundColor="rgba(0, 0, 0, 0.6)",o._textColor="white",o._textShadowColor=[0,0,0],o._textShadowSize=1,o}t._inheritsLoose(o,e);var r=o.prototype;return r.render=function(){return c.h("div",{classes:this._cssClasses(),styles:{left:Math.floor(this.x)+"px",top:Math.floor(this.y)+"px",visibility:this.visible?"visible":"hidden",fontSize:this.fontSize+"px",lineHeight:this.fontSize+"px",backgroundColor:this._backgroundColor,color:this._textColor,padding:this._padding+"px",borderRadius:this._borderRadius+"px",textShadow:this._textShadow}},[this.text])},r.renderCanvas=function(t){if(!this.visible)return;const e=t.font.replace(/^(.*?)px/,"");t.font=`${this.fontSize}px ${e}`;const o=this._padding,r=this._borderRadius,i=t.measureText(this.text).width,s=this.fontSize,n=x[this.anchor];t.textAlign="center",t.textBaseline="middle";const l=i+2*o,a=s+2*o,c=this.x+n.x*l,h=this.y+n.y*a;this._roundedRect(t,c,h,l,a,r),t.fillStyle=this._backgroundColor,t.fill();const p=this.x+(n.x+.5)*l,d=this.y+(n.y+.5)*a;this._renderTextShadow(t,this.text,p,d),t.fillStyle=this._textColor,t.fillText(this.text,p,d)},r._renderTextShadow=function(t,e,o,r){t.lineJoin="miter",t.fillStyle=`rgba(${this._textShadowColor[0]}, ${this._textShadowColor[1]}, ${this._textShadowColor[2]}, ${1/y.length})`;const i=this._textShadowSize;for(const[s,n]of y)t.fillText(e,o+i*s,r+i*n)},r._roundedRect=function(t,e,o,r,i,s){t.beginPath(),t.moveTo(e,o+s),t.arcTo(e,o,e+s,o,s),t.lineTo(e+r-s,o),t.arcTo(e+r,o,e+r,o+s,s),t.lineTo(e+r,o+i-s),t.arcTo(e+r,o+i,e+r-s,o+i,s),t.lineTo(e+s,o+i),t.arcTo(e,o+i,e,o+i-s,s),t.closePath()},r._cssClasses=function(){const t={"esri-text-overlay-item":!0};for(const e in p)t[p[e]]=this.anchor===e;return t},t._createClass(o,[{key:"position",get:function(){return[this.x,this.y]},set:function(t){this._set("x",t[0]),this._set("y",t[1])}},{key:"_textShadow",get:function(){const[t,e,o]=this._textColor;return`0 0 ${this._textShadowSize}px rgb(${t}, ${e}, ${o})`}},{key:"_padding",get:function(){return.5*this.fontSize}},{key:"_borderRadius",get:function(){return this._padding}}]),o}(o);e.__decorate([r.property()],d.prototype,"x",void 0),e.__decorate([r.property()],d.prototype,"y",void 0),e.__decorate([r.property()],d.prototype,"position",null),e.__decorate([r.property()],d.prototype,"text",void 0),e.__decorate([r.property()],d.prototype,"fontSize",void 0),e.__decorate([r.property()],d.prototype,"anchor",void 0),e.__decorate([r.property()],d.prototype,"visible",void 0),e.__decorate([r.property()],d.prototype,"_backgroundColor",void 0),e.__decorate([r.property()],d.prototype,"_textColor",void 0),e.__decorate([r.property()],d.prototype,"_textShadowColor",void 0),e.__decorate([r.property()],d.prototype,"_textShadowSize",void 0),e.__decorate([r.property()],d.prototype,"_textShadow",null),e.__decorate([r.property()],d.prototype,"_padding",null),e.__decorate([r.property()],d.prototype,"_borderRadius",null),d=e.__decorate([l.subclass("esri.views.overlay.TextOverlayItem")],d);const x={bottom:{x:-.5,y:-1,textAlign:"center",textBaseline:"bottom"},"bottom-left":{x:0,y:-1,textAlign:"left",textBaseline:"bottom"},"bottom-right":{x:-1,y:-1,textAlign:"right",textBaseline:"bottom"},center:{x:-.5,y:-.5,textAlign:"center",textBaseline:"middle"},left:{x:0,y:-.5,textAlign:"left",textBaseline:"middle"},right:{x:-1,y:-.5,textAlign:"right",textBaseline:"middle"},top:{x:-.5,y:0,textAlign:"center",textBaseline:"top"},"top-left":{x:0,y:0,textAlign:"left",textBaseline:"top"},"top-right":{x:-1,y:0,textAlign:"right",textBaseline:"top"}},y=[];{const t=16;for(let e=0;e<360;e+=360/t)y.push([Math.cos(Math.PI*e/180),Math.sin(Math.PI*e/180)])}return d}));
