/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as a } from "../../chunks/runtime.js";
import { css as n, html as s } from "lit";
import { LitElement as l } from "@arcgis/lumina";
const o = n`:host{--arcgis-internal-legend-gap: var(--calcite-spacing-xxs);--arcgis-internal-legend-group-gap: var(--calcite-spacing-md);display:flex;flex-direction:column;gap:var(--arcgis-internal-legend-gap)}.group{display:flex;flex-direction:column;gap:var(--arcgis-internal-legend-gap)}.group+.group,.group+arcgis-elevation-profile-legend-item,arcgis-elevation-profile-legend-item+.group{margin-block-start:calc(var(--arcgis-internal-legend-group-gap) - var(--arcgis-internal-legend-gap))}.group-title{color:var(--calcite-color-text-2);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-medium);text-align:start}`;
class g extends l {
  constructor() {
    super(...arguments), this._expandedLine = void 0, this.featureSelected = !1;
  }
  static {
    this.properties = { _expandedLine: 16, effectiveDisplayUnits: 0, featureSelected: 5, messages: 0, profiles: 0, results: 0 };
  }
  static {
    this.styles = o;
  }
  async destroy() {
    await this.manager.destroy();
  }
  _onToggleExpand(e) {
    const t = e.detail;
    this._expandedLine = t === this._expandedLine ? void 0 : t;
  }
  render() {
    const e = this.profiles?.toArray() ?? [], t = this.results ?? [], r = new Map(t.map((i) => [i.profile.id, i]));
    return r.size === 0 ? s`<div></div>` : e?.map((i) => i.type === "group" ? this._renderGroup(i, r) : this._renderProfile(i, r));
  }
  _renderGroup(e, t) {
    return s`<div class="group">${e.title ? s`<div class="group-title">${e.title}</div>` : void 0}${e.profiles.toArray().map((r) => this._renderProfile(r, t))}</div>`;
  }
  _renderProfile(e, t) {
    return s`<arcgis-elevation-profile-legend-item .effectiveDisplayUnits=${this.effectiveDisplayUnits} .expanded=${e === this._expandedLine} .featureSelected=${this.featureSelected} .hideCheckbox=${(this.results?.length ?? 0) <= 1} .messages=${this.messages} @arcgisExpandedToggle=${this._onToggleExpand} .result=${t.get(e.id)}></arcgis-elevation-profile-legend-item>`;
  }
}
a("arcgis-elevation-profile-legend", g);
export {
  g as ArcgisElevationProfileLegend
};
