/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import e from"./TNKBHEPU.js";import d from"./MITVRON5.js";import b from"./U2FD6RFU.js";import a from"./YFLYHPA6.js";import{b as v}from"./W4YXXJAS.js";import{b as w}from"./77CU4WA2.js";import"./TRGFYBOH.js";import{a as C}from"./6S75SIVV.js";import"./5IZMQFRP.js";import"./FOQPGXXA.js";import"./ED6SUP22.js";import"./E6P6PYNW.js";import"./IKKBLHLZ.js";import"./CUA2IUXX.js";import"./4UZDZNJD.js";import"./KOTG6W5Z.js";import"./6SC7YR5Y.js";import"./Z6NOHRUL.js";import"./GVM4XYEI.js";import"./NGDVSE4Z.js";import"./BTNJZZQQ.js";import"./ZYQ4P2ON.js";import"./5MKH4QDV.js";import"./3GWWHA4S.js";import"./3YYHZQJB.js";import"./JEJ23R3P.js";import"./TONS7KZJ.js";import"./Q62UEPOL.js";import"./44A5XEM4.js";import{b as S}from"./ABSRNM72.js";import{H as y,h as _,i as n,j as f,r as c}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([{g:x,h:T,k:E,l:h,n:u},{p:I},{c:L},{a:g,b:A}])=>{var b=_`/** @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.
 */

calcite-panel {
  width: 100%;
  height: 100%;
  --calcite-panel-background-color: var(--calcite-color-foreground-2);
}

.card-group {
  overflow: hidden;
  padding: 0.2rem var(--calcite-spacing-md) var(--calcite-spacing-md);
}

solution-details-card {
  width: calc(25% - 0.6rem);
}

@media (max-width: 1234px) {
  solution-details-card {
    width: calc(33.333% - 0.6rem);
  }
}

@media (max-width: 1010px) {
  solution-details-card {
    width: calc(50% - 0.6rem);
  }
}

/* We go back to 3 cards below 800 because the filter tree on the left disappears */
/* See the solutions-all-shell.css for the filter disappearing selector */
@media (max-width: 800px) {
  solution-details-card {
    width: calc(33.33% - 0.6rem);
  }
}

@media (max-width: 680px) {
  solution-details-card {
    width: calc(50% - 0.6rem);
  }
}

@media (max-width: 440px) {
  solution-details-card {
    width: calc(100% - 0.75rem);
  }
}

.solutions-briefcase {
  margin: auto;
  padding-top: var(--calcite-spacing-xxxl);
}

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

.leader-1 {
  margin-top: var(--calcite-spacing-xxl);
}

.trailer-1 {
  margin-bottom: var(--calcite-spacing-xxl);
}

.warning-text {
  max-width: 35em;
  margin-left: auto;
  margin-right: auto;
  font-size: var(--calcite-font-size-md);
}

.no-solutions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100%;
  transform: translateY(50%);
}

.margin-top-half {
  margin-top: 0.5rem;
}

.margin-top-1 {
  margin-top: 1rem;
}

.no-solutions-prompt {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}`,D=5,m=class extends y{constructor(){super(),this.sortType="relevance",this._cards=[],this._isLoading=!0,this._modifiedCheckTry=0,this._translations=C({name:"solutions-all-panel",blocking:!0}),this._agoTerms=`${h}`,this._allCards=[],this._baseAgoTerms=h,this._categories=[],this._configContextConsumer=w({context:v,subscribe:!0,callback:async e=>{e&&(this._isDisconnectedEnvironment?this._isLoading=!1:await this._loadUpdateProcedures())}}),this._delay=!1,this._getSuggested=!1,this._relatedSolutions=new Set,this._sortField="relevance",this._sortOrder="desc",this.cardsFetched=c(),this.allCardsFetched=c(),this.searchTermSet=c(),this.sortTypeSet=c(),this.detailsCardSelected=c(),this._handleOpenAssistant=()=>{this._telemetry?.logEvent({category:u.ASSISTANT,action:"Open"}),window.dispatchEvent(new CustomEvent("openAssistant"))},this.listenOn(window,"deployProgressEnd",()=>{this._modifiedCheckTry=D,this._loadUpdateProcedures()}),this.listenOn(window,"solutionDeleted",()=>{this._modifiedCheckTry=D,this._loadUpdateProcedures()}),this.listenOn(window,"sortTypeChanged",e=>{e.detail&&e.detail.scope==="all-solutions"&&(this.sortType=e.detail.sortType,this._telemetry?.logEvent({category:u.ALL_SOLUTIONS,action:"Sort",dimensions:[I(e.detail.sortType)]}),this.sortType==="suggested"&&this._deployedSolutions?.cards.length===0?this._getDeployedSolutions().then(()=>{this.searchSolutions(e.detail)}):this.searchSolutions(e.detail))}),this.listenOn(window,"solutionIDFromAssistant",e=>{this._lookupSolutionById(e.detail)})}static{this.properties={sortType:1,_cards:[16,{},{state:!0}],_isLoading:[16,{},{state:!0}],_modifiedCheckTry:[16,{},{state:!0}],_translations:[16,{},{state:!0}]}}static{this.styles=b}get _telemetry(){return this._configContextConsumer.value?.telemetrySession}get _isDisconnectedEnvironment(){return this._configContextConsumer.value?.isEnterprise===!0&&this._configContextConsumer.value?.authentication?.CanSearchArcGISOnline===!1}async searchSolutions(e){this._isDisconnectedEnvironment||(e?"searchTerm"in e?this._textSearch(e.searchTerm):"sortType"in e?this._sortCards(e):this._filterCards(e):(this._agoTerms=this._baseAgoTerms,this._clearFilterCategories()),this._cards=await this._getSolutions())}async setSearchOptions(e){e&&("searchTerm"in e&&(this._textSearch(e.searchTerm),this.searchTermSet.emit({searchTerm:e.searchTerm,scope:"all-solutions"})),"sortType"in e&&(this._sortCards(e),this.sortTypeSet.emit({sortType:e.sortType,scope:"all-solutions"})))}render(){let e=this._configContextConsumer.value?.authentication?.IsSignedIn&&this._configContextConsumer.value?.authentication?.CanUseAI;return this._isDisconnectedEnvironment?n`<div class="no-solutions">${this._getMeridianSearch()}<div class="no-solutions-prompt"><div class="text-center leader-1 warning-text trailer-1"><div>${this._translations.disconnectedEnvironment}</div></div></div></div>`:this._isLoading||this._cards.length?n`<calcite-panel>${this._isLoading?n`<calcite-loader id=solutions-all-panel-loader .label=${this._translations.fetchingSolutions}></calcite-loader>`:n`<calcite-card-group class="card-group" .label=${this._translations.allSolutionCards}>${this._renderCards()}</calcite-card-group>`}</calcite-panel>`:n`<div class="no-solutions">${this._getMeridianSearch()}<div class="no-solutions-prompt"><div class="text-center leader-1 warning-text trailer-1"><div>${this._translations.noSolutionsFound}</div><div class="margin-top-half">${e?this._translations.assistantHelp:this._translations.changeSearchTerm}</div></div>${e&&n`<calcite-button appearance=outline icon-start=speech-bubbles @click=${this._handleOpenAssistant} scale=l>${this._translations.askAssistant}</calcite-button>`||""}</div></div>`}_renderCards(){return this._cards.map(e=>n`<solution-details-card .card=${e}></solution-details-card>`)}async _getSolutions(){if(this._isDisconnectedEnvironment)return this._isLoading=!1,[];if(this._configContextConsumer.value){this._isLoading=!0;let e=await this._cardsFetcher?.requestAvailableSolutionCards({q:this._agoTerms,filter:"type:Solution",sortField:this._sortField,sortOrder:this._sortOrder,nextStart:-1,categories:this._categories,delay:this._delay,getSuggested:this._getSuggested,num:100},this._configContextConsumer.value?.primarySolutionsGroupId,this._configContextConsumer.value?.agoBasedEnterpriseSolutionsGroupId,this._configContextConsumer.value?.userSession,this._configContextConsumer.value?.isEnterprise,{num:1e3}),t=e?.cards.length?e.cards:[];if(this.sortType==="new"||this.sortType==="updated"){let s="/Categories/New Release";this.sortType==="updated"&&(s="/Categories/Updated"),t.sort((l,d)=>l.categories.includes(s)&&!d.categories.includes(s)?-1:!l.categories.includes(s)&&d.categories.includes(s)?1:l.categories.includes(s)&&d.categories.includes(s)?l.categories.length-d.categories.length:0)}else if(this.sortType==="suggested"&&this._relatedSolutions.size>0&&this._deployedSolutions?.cards?.length){let s=new Map;for(let o of t){let r=s.get(o.deployCommonId),a=Number(o.deployVersion);(!r||a>r)&&s.set(o.deployCommonId,a)}let l=this._deployedSolutions.cards.filter(o=>{let r=s.get(o.deployCommonId);return r!==void 0&&Number(o.deployVersion)>=r}),d=new Set(l.map(o=>o.deployCommonId));this._relatedSolutions=new Set([...this._relatedSolutions].filter(o=>!d.has(o))),t.sort((o,r)=>{let a=this._relatedSolutions.has(o.deployCommonId),p=this._relatedSolutions.has(r.deployCommonId);return a&&!p?-1:!a&&p?1:0})}let i=t.map(s=>{let l=s.categories.indexOf("/Categories/New Release")>-1,d=s.categories.indexOf("/Categories/Updated")>-1,o=!1,r=!0;this._deployedSolutions&&(o=this._isSolutionDeployed(s.deployCommonId),r=this._isLatestVersion(s));let a=[];return l?a.push("new"):d&&a.push("updated"),o&&r&&a.push("deployed"),s.chips=a.length>0?a:void 0,s.supportReuse=o?!!(o&&!r):!0,s});return this._allCards.length===0&&e?.cards&&(this._allCards=e?.cards,this._deployedSolutions&&(this._relatedSolutions=L(this._deployedSolutions.cards,this._allCards))),this.cardsFetched.emit(i.length),this._isLoading=!1,i}else return this._isLoading=!1,[]}async _loadUpdateProcedures(){if(this._isDisconnectedEnvironment){this._isLoading=!1;return}this._isLoading=!0;let e=this._configContextConsumer.value;this._cardsFetcher=new g(e.locale,e.orgUrl,e.portalURL),this._cardsFetcherDeployed=new g(e.locale,e.orgUrl,e.portalURL),await this._getDeployedSolutions(),this._cards=await this._getSolutions(),this.allCardsFetched.emit(this._cards),this._isLoading=!1}async _getDeployedSolutions(){let e=this._configContextConsumer.value.authentication,t=this._configContextConsumer.value.userSession;if(e&&t&&e.IsSignedIn){let i=await A(e,t,this._cardsFetcher,this._cardsFetcherDeployed,E,"created");if(i){if(this._modifiedCheckTry>0){if(this._deployedSolutions?.cards.length===i?.cards.length)return this._modifiedCheckTry--,await this._getDeployedSolutions();this._modifiedCheckTry=0}this._deployedSolutions=i}}}_getMeridianSearch(){return n`<div class="solutions-briefcase"><svg viewBox="0 0 64 64" width=140 height=140 xmlns=http://www.w3.org/2000/svg fill=var(--calcite-color-text-3)>${f`<path d="M60.217 54.937l-15.77-15.77-1.414 1.415-3.801-3.8a19.94 19.94 0 1 0-2.451 2.45l3.802 3.802-1.413 1.415 15.767 15.767a1.739 1.739 0 0 0 2.459 0l2.82-2.821a1.742 1.742 0 0 0 0-2.458zM4.9 24A19.1 19.1 0 1 1 24 43.1 19.121 19.121 0 0 1 4.9 24zm32.474 14.693q.69-.63 1.32-1.32l3.774 3.775-1.32 1.32zM59.65 56.83l-2.82 2.82a.97.97 0 0 1-1.327 0L40.3 44.45l4.145-4.15L59.65 55.501a.939.939 0 0 1 0 1.328zM22.343 9.62l.097.795q-.31.038-.619.086a13.635 13.635 0 0 0-11.353 11.775l-.026.217-.795-.084.026-.228a14.44 14.44 0 0 1 12.022-12.47c.215-.034.431-.064.648-.09z" />`}</svg></div>`}_textSearch(e){this._agoTerms=this._baseAgoTerms+` ${e}`}_sortCards(e){let t=e.sortType;this._getSuggested=!1,this._sortOrder="desc",t==="suggested"?this._getSuggested=!0:t==="new"?this._sortField="relevance":t==="relevance"||t==="title"?(t==="title"&&(this._sortOrder="asc"),this._sortField=t):t==="updated"&&(this._sortField="relevance"),this.sortType=t}_filterCards(e){this._categories=[],e.forEach(t=>{if(t.industry){let i=this._getIndustryValue(t.industry);if(t.domain){let s=this._getDomainValue(t.domain);this._categories.push(`/Categories/${i}/${s}`)}else this._categories.push(`/Categories/${i}`)}})}_getDomainValue(e){return T[e]}_getIndustryValue(e){return e==="AEC"?"AEC":x[e]}_clearFilterCategories(){this._categories=[]}_isSolutionDeployed(e){return!!this._deployedSolutions?.cards?.some(t=>t?.typeKeywords?.some(i=>i.includes("solutionid")&&i.includes(e)))}_isLatestVersion(e){let t=this._deployedSolutions?.cards?.filter(i=>i?.typeKeywords?.some(s=>s.includes("solutionid")&&s.includes(e.deployCommonId)));return!(t&&t.length>0&&t[0].deployVersion!==e.deployVersion)}_lookupSolutionById(e){let t=this._allCards.filter(i=>i.deployCommonId===e);t.length>0&&this.detailsCardSelected.emit(t[0])}};S("solutions-all-panel",m);return m},a,b,d,e)