/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{renderSVG as s}from"../../../../symbols/support/svgUtils.js";import o from"../../../Widget.js";import{css as i}from"./css.js";import{getRampStopLabel as l}from"../support/utils.js";import{tsx as a}from"../../../support/widget.js";const p=25,n=25,d=100;let c=class extends o{constructor(e,t){super(e,t),this.cssEffectFilter=null,this.legendElement=null,this.opacity=1}render(){const e=this.legendElement.infos.slice().reverse();return a("div",{class:this.classes(i.layerRow,i.colorRampContainer)},this._renderRampLabel(e[0]),a("div",{class:i.symbolContainer},this._renderPreview(e),this._renderMiddleStopRampLabel(e)),this._renderRampLabel(e.at(-1)))}_renderPreview(e){const{opacity:t}=this,r="heatmap-ramp"===this.legendElement.type,o=e.length-1,i=n,l=o>2&&!r?p*o:d,c=l+20,m=10,h=[[{shape:{type:"path",path:`M0 ${i/2} L${m} 0 L${m} ${i} Z`},fill:e[0].color,stroke:{width:0}},{shape:{type:"rect",x:m,y:0,width:l,height:i},fill:{type:"linear",x1:m,y1:0,x2:l+m,y2:0,colors:e.map((e,t)=>({color:e.color,offset:r&&"ratio"in e?e.ratio:t/o}))},stroke:{width:0}},{shape:{type:"path",path:`M${l+m} 0 L${c} ${i/2} L${l+m} ${i} Z`},fill:e[e.length-1].color,stroke:{width:0}}]],y=s(h,c,i),f={filter:this.cssEffectFilter??void 0,opacity:null==t?void 0:`${t}`};return a("div",{styles:f},y)}_renderMiddleStopRampLabel(e){const t=e.length%2!=0?e[e.length/2|0]:null;return t?a("div",{class:i.intervalSeparatorsContainer},a("div",{class:i.intervalSeparator},"|"),this._renderRampLabel(t)):null}_renderRampLabel(e){return a("div",{class:i.rampLabel},l(e,this.legendElement.type,this.messages))}};e([t()],c.prototype,"cssEffectFilter",void 0),e([t()],c.prototype,"legendElement",void 0),e([t()],c.prototype,"messages",void 0),e([t()],c.prototype,"opacity",void 0),c=e([r("esri.widgets.Legend.styles.card.ColorRamp")],c);export{c as default};
