/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{a as h}from"./XN2LWKJE.js";import{b as p}from"./ODCCVHGI.js";import{H as d,h as a,i as n,l as c,r as l}from"./42WFQ3AX.js";var u=a`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

:host {
  display: block;
}

.padding-start-1 {
  padding-inline-start: 1rem;
}

.border-override {
  --calcite-accordion-border-color: var(--calcite-color-border-1) !important;
}

.display-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.solution-list-item-label {
  color: var(--calcite-color-text-1);
  font-size: var(--calcite-font-size--1);
}

.solution-list-item-label,
.solution-list-item-description {
  font-family: var(--calcite-font-family);
  font-weight: var(--calcite-font-weight-normal);
  overflow-wrap: break-word;
  word-break: break-word;
}

.solution-list-item-description {
  font-size: var(--calcite-font-size--2);
  margin-block-start: 0.125rem;
  color: var(--calcite-color-text-3);
}

.solution-list-item-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  line-height: 1.375;
}

.underline {
  text-decoration: underline;
}

div[slot="actions-end"] calcite-action[icon="launch"] {
  height: 100%;
}

div[slot="actions-end"]{
  height: 100%;
}

calcite-chip {
  --calcite-chip-icon-color: var(--calcite-color-brand);
}`,r=class extends d{constructor(){super(...arguments),this.itemRelationshipDependencies=[],this.linkType="item",this.listSelectionMode="none",this.reuseWarning="",this.templateInfos=[],this.typeKeywords=[],this._sortedTemplateInfos=[],this._translations=h({name:"solution-item-accordion",blocking:!0}),this._sortOrder=["Hub Site Application","Hub Page","Web Experience","Instant App","Web Mapping Application","Dashboard","StoryMap","Form","QuickCapture Project","Workflow","Big Data Analytic (hosted)","Real Time Analytic (hosted)","Feed (hosted)","Tool","Notebook","Data Pipeline","Project Package","Desktop Application Template","TypeNotFound","Web Map","Web Scene","Feature Layer (hosted, view)","Feature Layer (hosted)","Table (hosted, view)","Table (hosted)","Tile Layer","CSV","Microsoft Excel","Microsoft Word","Report Template","Rule Package","Group"],this.solutionItemHover=l(),this.solutionItemSelect=l(),this.solutionTypeHover=l()}static{this.properties={itemRelationshipDependencies:[0,{},{attribute:!1}],linkType:1,listSelectionMode:1,reuseWarning:1,templateInfos:[0,{},{attribute:!1}],typeKeywords:[0,{},{attribute:!1}],_sortedTemplateInfos:[16,{},{state:!0}],_translations:[16,{},{state:!0}]}}static{this.styles=u}willUpdate(e){e.has("templateInfos")&&(this.hasUpdated||this.templateInfos?.length>0)&&this.templateInfosWatchHandler()}async templateInfosWatchHandler(){this._sortedTemplateInfos=this._sortTemplates()}async collapseAll(){this.el?.shadowRoot?.querySelectorAll("calcite-accordion-item")?.forEach(i=>{i.expanded=!1})}async deselectAll(){(this.listSelectionMode==="single"||this.listSelectionMode==="single-persist")&&this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(i=>{i.selected&&(i.selected=!1),(i.parentElement?.parentElement).expanded&&((i.parentElement?.parentElement).expanded=!1)})}async expandItemById(e){this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(t=>{t.id===e&&((t.parentElement?.parentElement).expanded=!0)})}async expandFirstItem(){let e=this.el?.shadowRoot?.querySelectorAll("calcite-list-item");e?.length&&((e[0].parentElement?.parentElement).expanded=!0)}async expandItems(e){this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(t=>{e.indexOf(t.id)>-1&&((t.parentElement?.parentElement).expanded=!0)})}async selectItem(e){(this.listSelectionMode==="single"||this.listSelectionMode==="single-persist")&&this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(t=>{t.id===e&&(t.selected=!0,(t.parentElement?.parentElement).expanded=!0)})}async selectFirstItem(){let e=this.el?.shadowRoot?.querySelectorAll("calcite-list-item");e?.length&&(e[0].selected=!0,(e[0].parentElement?.parentElement).expanded=!0)}async selectItems(e){this.listSelectionMode==="multiple"&&this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(t=>{e.indexOf(t.id)>-1&&(t.selected=!0,(t.parentElement?.parentElement).expanded=!0)})}async load(){this._sortedTemplateInfos=this._sortTemplates()}render(){return this._getAccordion()}_deselectOthers(e){(this.listSelectionMode==="single"||this.listSelectionMode==="single-persist")&&this.el?.shadowRoot?.querySelectorAll("calcite-list-item")?.forEach(t=>{t.id!==e&&(t.selected=!1)})}_getAccordion(){let e=[],i=this._sortedTemplateInfos.reduce((t,s)=>{let o=this._getTypeForDisplay(s.type,s.typeKeywords);return e.indexOf(o)<0&&(e.push(o),t.push(this._getAccordionItem(s))),t},[]);return n`<calcite-accordion class="border-override" selection-mode=single>${i}</calcite-accordion>`}_getAccordionItem(e){let i=this._getTypeForDisplay(e.type,e.typeKeywords),t=this._sortedTemplateInfos.filter(s=>this._getTypeForDisplay(s.type,s.typeKeywords)===i);return n`<calcite-accordion-item .heading=${`${i} (${t.length})`} @mouseenter=${()=>this.solutionTypeHover.emit({itemType:i,entering:!0})} @mouseleave=${()=>this.solutionTypeHover.emit({itemType:i,entering:!1})}><solution-item-icon class="padding-start-1 display-flex align-center" slot=actions-start .type=${e.type} .typeKeywords=${e.typeKeywords}></solution-item-icon>${this._getList(t)}</calcite-accordion-item>`}_getList(e){let i=this._sortTemplatesByTitle(e);return n`<calcite-list .label=${this._translations.solutionsTemplates} selection-appearance=border .selectionMode=${this.listSelectionMode}>${i.map(t=>this._getListItem(t))}</calcite-list>`}_getListItem(e){let i=this.typeKeywords.includes("Deployed")&&e.url,t=this.linkType==="action";return n`<calcite-list-item id=${e.id??c} @mouseenter=${()=>this.solutionItemHover.emit({itemId:e.id,entering:!0})} @mouseleave=${()=>this.solutionItemHover.emit({itemId:e.id,entering:!1})} @calciteListItemSelect=${()=>{this._deselectOthers(e.id),this.solutionItemSelect.emit({itemId:e.id,selected:!0}),i&&!t&&window.open(e.url,"_blank")}} .value=${e.id}><div class="solution-list-item-content" slot=content><div class=${`solution-list-item-label ${i&&!t?"underline":""}`}>${e.title}</div><div class="solution-list-item-description">${e.snippet}</div></div>${this.itemRelationshipDependencies.length>0&&this.itemRelationshipDependencies.some(s=>s===e.id)&&this.reuseWarning&&this._getReuseWarningChip()||""}${i&&t?n`<div slot=actions-end><calcite-action appearance=solid icon=launch .id=${`${e.id}-launch`} @click=${()=>window.open(e.url,"_blank")} text></calcite-action><calcite-tooltip overlay-positioning=fixed .referenceElement=${`${e.id}-launch`}><span>${this._translations?.openDetails}</span></calcite-tooltip></div>`:null}</calcite-list-item>`}_sortTemplatesByTitle(e){return e.sort((i,t)=>i.title<t.title?-1:i.title>t.title?1:0)}_sortTemplates(){return this.templateInfos.sort((e,i)=>{let t=this._getTypeForSort(e),s=this._getTypeForSort(i),o=this._sortOrder.indexOf(t),m=this._sortOrder.indexOf(s);return o-m})}_getTypeForSort(e){let i=this._getTypeForDisplay(e.type,e.typeKeywords);return this._sortOrder.indexOf(i)<0&&(i="TypeNotFound"),i}_getTypeForDisplay(e,i){let t=e;if(e==="Feature Service"){let s=i.indexOf("View Service")>-1,o=i.indexOf("Table")>-1;t=s&&o?"Table (hosted, view)":o?"Table (hosted)":s?"Feature Layer (hosted, view)":"Feature Layer (hosted)"}return e==="Web Mapping Application"&&(t=i.indexOf("configurableApp")>-1?"Instant App":t),t=e==="Geoprocessing Service"?"Tool":t,t=e==="Feed"?"Feed (hosted)":t,t=e==="Real Time Analytic"?"Real Time Analytic (hosted)":t,t=e==="Big Data Analytic"?"Big Data Analytic (hosted)":t,t=e==="Vector Tile Service"?"Tile Layer":t,t}_getReuseWarningChip(){return n`<calcite-chip icon=information kind=neutral .label=${this.reuseWarning} scale=s slot=actions-end>${this.reuseWarning}</calcite-chip>`}};p("solution-item-accordion",r);export{r as a};
