/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import a from"./ZKOJATCN.js";import{a as u}from"./QN2RKJ33.js";import"./UN4CBUAO.js";import{a as w}from"./DHVEHATY.js";import{b as l}from"./ZNBKMZP7.js";import{O as _,P as r,Q as b,R as p,U as L,a as k,b as t}from"./IWZQMWZ5.js";import"./ALDX5YZO.js";export default $arcgis.t(([v,{a:f,b:z,d:F,g:$,h:x}])=>{var I=k`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.section{word-break:break-word;word-wrap:break-word;padding:var(--calcite-spacing-sm) var(--calcite-spacing-md);min-width:250px;max-width:500px;height:100%;height:-moz-available;height:-webkit-fill-available;height:fill-available;overflow:auto;font-size:var(--calcite-font-size-sm)}.carousel-title-container{margin-bottom:var(--calcite-spacing-sm)}.carousel-title{margin:0}.section-title{font-weight:var(--calcite-font-weight-normal)}.layer-caption{padding:var(--calcite-spacing-xs) 0;margin:0;font-weight:var(--calcite-font-weight-normal)}.imagery-layer-stretched-image{display:block;margin-bottom:-2px}.image-label{padding-right:var(--calcite-spacing-xs);padding-left:var(--calcite-spacing-xs)}.label-element{margin:.1em;padding:.5em 1em;min-width:2em;min-height:1em;text-align:center;display:flex;align-items:center;justify-content:center;flex:1}.layer-row{display:flex;align-items:center}.symbol{display:block;margin:auto}.pie-chart-ramp-preview{display:flex;justify-content:center}.relationship-container{display:flex;flex-direction:column}.relationship-container .layer-row{padding-bottom:.5em}.relationship-container .layer-row:last-child{padding-bottom:0}.container{display:flex;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.background-styles-container{display:flex;flex-wrap:wrap}:host([stacked]) .container{display:table}:host([stacked]) .symbol-row{display:table-row;width:100%}:host([stacked]) .label-cell{display:table-cell;vertical-align:middle;padding:var(--calcite-spacing-xxs)}:host([stacked]) .symbol-cell{display:table-cell;vertical-align:middle;text-align:center;padding:var(--calcite-spacing-xxs)}:host([stacked]) .symbol-cell div{display:flex;align-items:center;justify-content:center}`;function C(h){return h?h.r*.299+h.g*.587+h.b*.114>=127:void 0}var E=class extends _{constructor(){super(...arguments),this.stacked=!1,this.headingLevel=3}static{this.properties={cssEffectFilter:1,stacked:7,activeLayerInfo:0,headingLevel:9,layer:0,legendElement:0,messages:0}}static{this.styles=I}_getBackgroundStyles(e){let s=e.symbol,i=s.color,n=!!i?.a,a="outline"in s?s.outline:null,c=!!a?.color?.a,o=n&&i?new v([i.r,i.g,i.b,i.a*this.layer.opacity]):new v([255,255,255,0]),d=c&&a.color?new v([a.color.r,a.color.g,a.color.b,a.color.a*this.layer.opacity]):new v([255,255,255,0]),g=C(e.symbol.color)??!0,m=g?"black":"white",y=g?"rgba(255, 255, 255, .6)":"rgba(0, 0, 0, .6)";return{background:n?o.toCss(!0):"none",color:m,textShadow:`-1px -1px 0 ${y},
                  1px -1px 0 ${y},
                  -1px 1px 0 ${y},
                  1px 1px 0 ${y}`,border:c?`1px solid ${d.toCss(!0)}`:"none",filter:this.cssEffectFilter??""}}render(){let e=this._renderLegendElement(),s=z(this.legendElement,this.messages),i=this.stacked?t`<div class="carousel-title-container">${u({class:l("carousel-title",w.heading),level:this.headingLevel,children:this.activeLayerInfo.title})}${s?t`<p class="layer-caption">${s}</p>`:null}</div>`:s?u({class:l("section-title",w.heading),level:this.headingLevel,children:s}):null;return t`<section class="section" role=tabpanel tabindex=0>${i}${e}</section>`}_renderLegendElement(){switch(this.legendElement.type){case"symbol-table":return this._renderSymbolTable(this.legendElement);case"size-ramp":return t`<arcgis-legend-card-size-ramp .hasIndicators=${this.stacked} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-card-size-ramp>`;case"color-ramp":case"opacity-ramp":case"heatmap-ramp":case"stretch-ramp":return t`<arcgis-legend-card-color-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-card-color-ramp>`;case"relationship-ramp":return t`<arcgis-legend-relationship-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .opacity=${this.layer.opacity} .messages=${this.messages}></arcgis-legend-relationship-ramp>`;case"pie-chart-ramp":{let{preview:e}=this.legendElement;return x(e,this.messages.previewPieChartAriaLabel),t`<div class="pie-chart-ramp-preview">${e}</div>`}case"univariate-above-and-below-ramp":return t`<arcgis-legend-card-univariate-above-and-below-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-card-univariate-above-and-below-ramp>`;case"univariate-color-size-ramp":return t`<arcgis-legend-card-univariate-color-size-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-card-univariate-color-size-ramp>`;default:return null}}_renderSymbolTable(e){let s=e.infos.map(a=>this._renderElementInfo(a,e.legendType)).filter(Boolean);if(!s.length)return null;let i=e.infos.some(a=>"symbol"in a&&a.symbol?.type.includes("simple-fill")),n=this.activeLayerInfo.legendElements.some(({type:a})=>a==="relationship-ramp")?"relationship-container":i?"background-styles-container":"container";return t`<div class=${r(n)}>${s}</div>`}_renderElementInfo(e,s){let{layer:i}=this,n="label"in e?e.label:null;if("type"in e&&e.type)return t`<arcgis-legend-card-element .activeLayerInfo=${this.activeLayerInfo} .cssEffectFilter=${this.cssEffectFilter} .stacked=${this.stacked} .headingLevel=${this.headingLevel} .layer=${i} .legendElement=${e} .messages=${this.messages}></arcgis-legend-card-element>`;if(!("preview"in e&&e.preview)&&!("src"in e&&e.src))return null;let a=F(i,s),c=f(this.messages,n,!1)||"";if("src"in e&&e.src){let o={"symbol-cell":this.stacked};return t`<div class=${r(l("layer-row",{"symbol-row":this.stacked}))}><div class=${r(l(o))}>${this._renderImage(e,i,a)}</div><div class=${r(l("image-label",{"label-cell":this.stacked}))}>${c}</div></div>`}if("symbol"in e&&e.preview){if(!e.symbol?.type.includes("simple-fill")){if(!e.label)return t`<div>${e.preview}</div>`;let o={"symbol-cell":this.stacked},{preview:d}=e,g="previewAriaLabel"in e?e.previewAriaLabel:null,m="label"in e?f(this.messages,e.label,!1):null;return x(d,$(this.messages,g||m)),t`<div class=${r(l("layer-row",{"symbol-row":this.stacked}))}><div class=${r(l(o))}>${d}</div><div class=${r(l("image-label",{"label-cell":this.stacked}))}>${c}</div></div>`}return t`<div class="layer-row"><div class="label-element" style=${b(this._getBackgroundStyles(e))}>${c}</div></div>`}return null}_renderImage(e,s,i){let{previewAriaLabel:n,src:a,opacity:c}=e,o=f(this.messages,e.label,!1),d={"imagery-layer-stretched-image":i,symbol:!i},g={opacity:`${c??s.opacity}`},m=$(this.messages,n||o);return t`<img alt=${m??p} .ariaLabel=${m} class=${r(l(d))} height=${e.height??void 0??p} src=${a??p} style=${b(g)} width=${e.width??void 0??p}>`}};L("arcgis-legend-card-element",E);return E},"Color",a)