/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{a as u}from"./H47NPYUM.js";import"./JCTU3MST.js";import"./BXKNMJRR.js";import"./IJQZON2Z.js";import{O as h,U as g,a as m,b as c,p as s,s as p}from"./IXZEUVT2.js";import"./H6RQVSYM.js";export default $arcgis.t(([v,{substitute:b}])=>{var $=m`:host{margin-block-start:0;padding:0 var(--calcite-spacing-sm) var(--calcite-spacing-sm) var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}calcite-list{border:solid 1px var(--calcite-color-border-3);border-radius:var(--calcite-corner-radius-sm);overflow:hidden}calcite-list-item[selected] [slot=content-bottom]{display:block}.warning{color:var(--calcite-color-status-danger)}.terminals{padding:var(--calcite-spacing-sm) var(--calcite-spacing-md);display:flex;flex-direction:column}.filter-barrier-container{display:flex;width:100%;calcite-label{width:100%}}.filter-barrier{display:flex;justify-content:space-between;align-items:center;width:100%}`,d=class extends h{constructor(){super(...arguments),this._messages=u({blocking:!0}),this.traceLocations=new v,this.traceLocationType="starting-point"}static{this.properties={traceLocations:0,traceLocationType:1,view:0}}static{this.styles=$}loaded(){this.traceLocations.length||s("warn",this,p("traceLocations"))}_handleTraceLocationItemRemoved(e){let{traceLocations:i,view:t}=this;e.spatialProperties.flagGraphic&&t&&t.graphics.remove(e.spatialProperties.flagGraphic),i?.remove(e)}_renderTerminal(e,i){let{flagProperties:t}=e,{selectedTerminals:r}=t;if(!e)return s("warn",this,"One or more elements in `traceLocations` are missing the required property `flag`."),null;let{name:a,id:n}=i,o=r?.has(n)??!1;return c`<calcite-label layout=inline><calcite-checkbox .value=${n} .checked=${o} @calciteCheckboxChange=${l=>{l.target.checked?r?.add(n):r?.delete(n),this.requestUpdate()}}></calcite-checkbox>${a}</calcite-label>`}_renderTerminalError(){let{_messages:e}=this;return c`<calcite-notice kind=danger open scale=s width=auto><div slot=message>${e.errors.noTerminalSelected}</div></calcite-notice>`}_renderFilterBarrier(e){let{_messages:i}=this,{traceLocation:t}=e;return c`<div class="filter-barrier-container"><calcite-label layout=inline><div class="filter-barrier">${i.labels.filterBarrier}<calcite-switch .checked=${t.isFilterBarrier} @calciteSwitchChange=${r=>{t.isFilterBarrier=r.target.checked}}></calcite-switch></div></calcite-label></div>`}_renderContents(e){let{flagProperties:i}=e,{terminalConfiguration:t,selectedTerminals:r}=i,a=e.traceLocation.type==="barrier",n=t&&t.terminals.length>0&&r?.size===0;return c`<calcite-action .icon=${i.expanded?"chevron-up":"chevron-down"} slot=actions-end scale=s text @click=${()=>{i.expanded=!i.expanded,this.requestUpdate()}}></calcite-action>${n&&c`<calcite-icon class="warning" icon=exclamation-mark-triangle scale=s slot=content-start></calcite-icon>`||""}${i.expanded&&c`<div class="terminals" slot=content-bottom>${a&&this._renderFilterBarrier(e)||""}${t&&this._renderTerminals(e)||""}${n&&this._renderTerminalError()||""}</div>`||""}`}_renderTerminals(e){let{flagProperties:i}=e,{terminalConfiguration:t}=i;if(!t)return s("warn",this,"One or more locations are missing the required flag property `terminalConfiguration`."),[];let r=t.terminals;return!r||r.length===0?(s("warn",this,"`terminalConfiguration.terminals` is required but either missing or empty.`"),[]):r.length===1?[]:r.map(a=>this._renderTerminal(e,a))}_renderListItem(e){let{flagProperties:i}=e,{terminalConfiguration:t,expanded:r,title:a}=i,n=t&&t.id!==0,o=e.traceLocation.type==="barrier",l=n||o,f=t?.name??void 0;return c`<calcite-list-item .label=${a} .description=${f} .value=${a} .expanded=${r}>${l?this._renderContents(e):c`<div slot=content-bottom></div>`}<calcite-action icon=x slot=actions-end scale=s text @click=${()=>this._handleTraceLocationItemRemoved(e)}></calcite-action></calcite-list-item>`}render(){let{_messages:e,traceLocationType:i}=this,t=b(e.labels.list,{traceLocationType:i}),r=this.traceLocations?.map(a=>this._renderListItem(a)).toArray()??[];return r.length===0?null:c`<div><calcite-list interaction-mode=static selection-mode=none .label=${t}>${r}</calcite-list></div>`}};g("arcgis-utility-network-trace-location-list",d);return d},"core/Collection","intl")