import { c } from "../../chunks/runtime.js";
import { LitElement as a, createEvent as r } from "@arcgis/lumina";
import { css as o, html as s } from "lit";
import { createRef as u, ref as d } from "lit/directives/ref.js";
import { u as g } from "../../chunks/useT9n.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
const h = o`:host{max-height:calc(100vh - 150px);min-height:300px}.results-heading{display:flex;flex-direction:column;padding:var(--calcite-spacing-md);gap:var(--calcite-spacing-xs)}.results-heading .results-heading-title{font-weight:var(--calcite-font-weight-medium);font-size:var(--calcite-font-size-1)}.results-heading .results-heading-subtitle{font-size:var(--calcite-font-size--1);color:var(--calcite-color-text-3)}.no-results-landing{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:var(--calcite-spacing-xl);gap:var(--calcite-spacing-md)}.no-results-landing calcite-icon{margin-bottom:var(--calcite-spacing-sm);--calcite-icon-color: var(--calcite-color-text-3)}.no-results-landing .no-results-heading{font-size:var(--calcite-font-size-2)}.no-results-landing .no-results-description{color:var(--calcite-color-text-3)}`;
class m extends a {
  constructor() {
    super(...arguments), this._resultFeatureListRef = u(), this._messages = g({ blocking: !0 }), this._clearSelectedResultType = () => this._selectedResultType = void 0, this.layers = [], this.arcgisSelectedResultTypeChange = r(), this._renderResultListItems = (t) => {
      const { _messages: e } = this, { elements: i, globalFunctionResults: l } = t, n = [];
      return i && i.length > 0 && n.push(this._renderResultListItem(i.length, e.headings.features, e.labels.numFeatures, () => this._selectedResultType = "features")), l && l.length > 0 && n.push(this._renderResultListItem(
        l.length,
        e.headings.functions,
        e.labels.numFunctions,
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        () => {
        }
      )), n;
    }, this._renderResultListItem = (t, e, i, l) => s`<calcite-list-item .label=${e} @calciteListItemSelect=${l}><calcite-chip .label=${i} scale=s slot=content-end>${t}</calcite-chip><calcite-icon icon=chevron-right slot=content-end></calcite-icon></calcite-list-item>`;
  }
  static {
    this.properties = { _selectedResultType: 16, layers: 0, messageOverrides: 0, selectedResultType: 32, traceConfigTitle: 1, traceResult: 0, utilityNetwork: 0 };
  }
  static {
    this.styles = h;
  }
  get selectedResultType() {
    return this._selectedResultType;
  }
  willUpdate(t) {
    t.has("_selectedResultType") && this.arcgisSelectedResultTypeChange.emit(), t.has("traceResult") && this._clearSelectedResultType();
  }
  render() {
    const { _messages: t, traceResult: e } = this;
    if (e) {
      if (!e.elements?.length && !e.globalFunctionResults?.length)
        return s`<div>${this._renderTraceResultsHeading()}${this._renderNoResultsLanding()}</div>`;
    } else return s`<div>${this._renderTraceResultsHeading()}${this._renderNoTraceLanding()}</div>`;
    const { elements: i, globalFunctionResults: l } = e, n = i && i.length > 0 && (!l || l.length === 0);
    return s`<calcite-flow>${n ? null : s`<calcite-flow-item .selected=${this.selectedResultType === void 0}>${this._renderTraceResultsHeading()}<calcite-list .label=${t.headings.traceResultsGeneric}>${this._renderResultListItems(e)}</calcite-list></calcite-flow-item>`}${n || this.selectedResultType === "features" ? s`<calcite-flow-item .heading=${t.headings.features} .description=${t.headings.totalFeatures.replace("{number}", e.elements.length.toString())} selected @calciteFlowItemBack=${this._clearSelectedResultType}><arcgis-utility-network-result-feature-list .elements=${e.elements} .layers=${this.layers} .utilityNetwork=${this.utilityNetwork} ${d(this._resultFeatureListRef)}></arcgis-utility-network-result-feature-list></calcite-flow-item>` : null}</calcite-flow>`;
  }
  _renderTraceResultsHeading() {
    return s`<div class="results-heading"><div class="results-heading-title">${this._messages.headings.traceResultsGeneric}</div>${this.traceConfigTitle ? s`<div class="results-heading-subtitle">${this.traceConfigTitle}</div>` : null}</div>`;
  }
  _renderNoResultsLanding() {
    return s`<div class="no-results-landing"><calcite-icon icon=exclamation-mark-triangle scale=l></calcite-icon><div class="no-results-heading">${this._messages.noResultsHeading}</div><div class="no-results-description">${this._messages.noResultsDescription}</div></div>`;
  }
  _renderNoTraceLanding() {
    return s`<div class="no-results-landing"><calcite-icon icon=utility-network-trace scale=l></calcite-icon><div class="no-results-heading">${this._messages.noTraceConfigHeading}</div><div class="no-results-description">${this._messages.noTraceConfigDescription}</div></div>`;
  }
}
c("arcgis-utility-network-trace-results", m);
export {
  m as ArcgisUtilityNetworkTraceResults
};
