/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{property as s,subclass as r}from"../../../../core/accessorSupport/decorators.js";import t from"../../../Widget.js";import{css as i,legend as n}from"./css.js";import o from"./LegendElement.js";import{globalCss as l}from"../../../support/globalCss.js";import{Heading as a}from"../../../support/Heading.js";import{tsx as d,messageBundle as c}from"../../../support/widget.js";const p=`${n}__`;let g=class extends t{constructor(e,s){super(e,s),this.activeLayerInfos=null,this.headingLevel=3,this.messages=null,this.type="classic"}render(){const e=this.activeLayerInfos,s=e?.toArray().map(e=>this._renderLegendForLayer(e)).filter(Boolean);return s?.length?d("section",null,s):d("div",{class:i.message,key:"no-legend"},this.messages.noLegend)}_renderLegendForLayer(e,s){if(!e.ready)return null;const r=`${e.layer.uid}-version-${e.version}`,t=`${p}${s?`${s}-`:""}${r}`,n=e.title?a({level:this.headingLevel,class:this.classes(l.heading,i.label)},e.title):null;if(e.children.length){const s=e.children.toArray().map(e=>this._renderLegendForLayer(e,r));return d("section",{class:this.classes(i.service,i.groupLayer),key:t},n,s)}return this._renderLegendElementsForLayer(e,n,t)}_renderLegendElementsForLayer(e,s,r){const t=e.legendElements?.filter(Boolean);if(!t?.length)return null;const n=t.map(s=>d(o,{cssEffectFilter:e.cssEffectFilter,isChild:!1,key:`${r}-${s.type}`,layer:e.layer,legendElement:s,messages:this.messages})),l={[i.groupLayerChild]:!!e.parent};return d("section",{class:this.classes(i.service,l),key:r},s,d("div",{class:i.layer},n))}};e([s()],g.prototype,"activeLayerInfos",void 0),e([s()],g.prototype,"headingLevel",void 0),e([s(),c("esri/widgets/Legend/t9n/Legend")],g.prototype,"messages",void 0),e([s({readOnly:!0})],g.prototype,"type",void 0),g=e([r("esri.widgets.Legend.styles.classic.ClassicView")],g);export{g as default};
