/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as k } from "../../chunks/runtime.js";
import { u as M } from "../../chunks/useT9n.js";
import { createRef as d, ref as h } from "lit-html/directives/ref.js";
import { LitElement as I, createEvent as f, safeClassMap as p, nothing as u, safeStyleMap as D } from "@arcgis/lumina";
import { useContextConsumer as w } from "@arcgis/lumina/context";
import { c as T, i as L } from "../../chunks/deployAppContexts.js";
import { css as E, html as l } from "lit";
import * as x from "@esri/solution-common";
import { sanitizeHTML as y, getItemDataAsJson as R, getItem as P, getPropWithDefault as C, getProp as _, setCreateProp as A } from "@esri/solution-common";
import { T as g, C as $, F as O, G as F, z as U } from "../../chunks/interfaces.js";
import { _findExistingItem as V } from "@esri/solution-deployer";
import { m as v, j as m, n as H, i as b, s as N, l as B } from "../../chunks/helpers.js";
import { D as z } from "../../chunks/deployFlowController.js";
import "../../chunks/solution-deploy-dialog.js";
import "../solution-snapshot-gallery/customElement.js";
import "../solution-deploying-dialog/customElement.js";
const Y = E`.display-flex{display:flex}.flex-direction-row{flex-direction:row}.flex-direction-column{flex-direction:column}.flex-1{flex:1}.cursor-default{cursor:default}solution-details-card[id*=you-may-also-like]{width:240px}.border-bottom{border-bottom-color:var(--calcite-color-border-1);border-bottom-width:var(--calcite-spacing-px);border-bottom-style:solid}ul{list-style-type:disc;margin-block-start:var(--calcite-spacing-none);margin-block-end:var(--calcite-spacing-none)}ul ul{list-style-type:circle}li{margin:var(--calcite-spacing-sm) var(--calcite-spacing-none)}calcite-label{--calcite-label-margin-bottom: var(--calcite-spacing-none)}.padding-1{padding:var(--calcite-spacing-lg)}.padding-1-5{padding:var(--calcite-spacing-xl)}.padding-2px{padding:var(--calcite-spacing-base)}.padding-bottom-xxl{padding-bottom:var(--calcite-spacing-xxl)}.padding-bottom-1{padding-bottom:var(--calcite-spacing-lg)}.padding-bottom-sm{padding-bottom:var(--calcite-spacing-sm)}.padding-top-md{padding-top:var(--calcite-spacing-md)}.padding-top-sm{padding-top:var(--calcite-spacing-sm)}.padding-top-xs{padding-top:.25rem}.padding-bottom-1-5{padding-bottom:var(--calcite-spacing-xxl)}.padding-top-1{padding-top:var(--calcite-spacing-lg)}.padding-top-1-5{padding-top:var(--calcite-spacing-xxl)}.padding-top-1-2{padding-top:var(--calcite-spacing-sm)}.padding-end-1{padding-inline-end:var(--calcite-spacing-lg)}.padding-end-1-75{padding-inline-end:1.75rem}.padding-end-2{padding-inline-end:var(--calcite-spacing-xxxl)}.padding-start-1{padding-inline-start:var(--calcite-spacing-lg)}.margin-bottom-1{margin-bottom:var(--calcite-spacing-lg)}.margin-bottom-1-5{margin-bottom:var(--calcite-spacing-xxl)}.margin-end-1{margin-inline-end:var(--calcite-spacing-lg)}.margin-top-0{margin-top:var(--calcite-spacing-none)}.margin-top-1{margin-top:var(--calcite-spacing-lg)}.margin-top-875{margin-top:.875rem}.margin-top-1-5{margin-top:var(--calcite-spacing-xxl)}.margin-sides-0-5{margin-left:var(--calcite-spacing-sm);margin-right:var(--calcite-spacing-sm)}.margin-sides-1{margin-left:var(--calcite-spacing-lg);margin-right:var(--calcite-spacing-lg)}.margin-block-start-end-0{margin-block-start:var(--calcite-spacing-none);margin-block-end:var(--calcite-spacing-none)}.align-self-center{align-self:center;padding:5px;--calcite-fab-shadow: #FFFFFF00}.align-items-center{align-items:center}.align-items-baseline{align-items:baseline}.button-width{width:260px;flex-grow:0;flex-shrink:0;align-self:flex-start}@container (max-width: 1050px){.button-width{width:auto}}.image-width{width:300px;flex-grow:0;flex-shrink:0}@container (max-width: 1050px){.image-width{flex-grow:0;flex-shrink:1}}.width-full{width:100%}@container (max-width: 800px){.width-full{flex-direction:column}.width-full>.display-flex{flex-direction:column}.image-width{width:100%;max-width:100%;margin:0;padding-bottom:0}.image-width img{width:100%;max-width:100%}.title-font{padding-inline-end:var(--calcite-spacing-lg);padding-top:var(--calcite-spacing-lg)}.button-width{width:100%;margin-top:var(--calcite-spacing-lg)}}.card-group{overflow:hidden;padding:.25rem var(--calcite-spacing-sm) var(--calcite-spacing-md)}#screenshots-subsection calcite-card{width:calc(33.333% - .5rem)}calcite-card{width:450px;--calcite-card-border-color: transparent}@container (max-width: 1496px){calcite-card{width:calc(100% / 3 - .5rem)}#screenshots-subsection calcite-card{width:calc(33.333% - .5rem)}}@container (max-width: 1100px){calcite-card{width:calc(50% - .5rem)}#screenshots-subsection calcite-card{width:calc(50% - .5rem)}}@container (max-width: 550px){calcite-card{width:100%}#screenshots-subsection calcite-card{width:100%}}.max-height-300{max-height:300px}.display-none{display:none}.cursor-pointer{cursor:pointer}calcite-card:hover img{-webkit-filter:brightness(30%);filter:brightness(30%);-webkit-transition:all .1s ease;-moz-transition:all .1s ease;-o-transition:all .1s ease;-ms-transition:all .1s ease;transition:all .1s ease}calcite-card:hover .hover-text{opacity:1;color:#fff}calcite-card:hover{border:var(--calcite-spacing-base) solid var(--calcite-color-brand);box-sizing:border-box;cursor:pointer;padding:var(--calcite-spacing-base)}calcite-card.is-mobile:hover img{cursor:default;-webkit-filter:brightness(100%);filter:brightness(100%);transition:all .1s ease}calcite-card{border:var(--calcite-spacing-base) solid transparent;box-sizing:border-box;padding:var(--calcite-spacing-base)}.hover-text{transition:.1s ease;opacity:0;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);text-align:center;display:flex;flex-direction:row;align-items:center;height:100%;font-size:var(--calcite-spacing-xl)}.card-image-wrap{width:100%;position:relative;margin-bottom:0;-webkit-box-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto}#screenshots-subsection .card-image{background-color:var(--calcite-color-surface-2)}.card-image{width:100%;display:block}video,img{max-width:100%;height:auto}img{overflow-clip-margin:content-box;overflow:clip;display:block}.margin-inline-unset{margin-inline:unset}.collapsible-div{overflow:hidden;transition:max-height .3s ease-in-out}.collapsible-div.expanded{max-height:100%}.back-color-override{--calcite-panel-background-color: var(--calcite-color-surface-3)}.back-color-override-1{background-color:var(--calcite-color-surface-2)}.title-font{font-size:1.8rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1)}.heading-font{font-size:var(--calcite-font-size-0);font-weight:var(--calcite-font-weight-medium)}.line-height-xxl{line-height:var(--calcite-spacing-xxl)}.line-height-1{line-height:1.1}.font-1{font-size:var(--calcite-spacing-lg)}.font-color-1{color:var(--calcite-color-text-1)}.font-color-2{color:var(--calcite-color-text-2)}h1{font-weight:unset;margin:var(--calcite-spacing-none);padding:var(--calcite-spacing-none)}.item-padding{--calcite-internal-accordion-item-padding: var(--calcite-spacing-xl)}.accordion-bg{--calcite-accordion-background-color: var(--calcite-color-surface-2)}.table-cell{font-size:var(--calcite-spacing-lg);color:var(--calcite-color-text-2);margin:0}.table-cell p{margin:0}calcite-table-header{font-weight:var(--calcite-font-weight-medium);--calcite-internal-table-cell-font-size: var(--calcite-font-size-md)}.position-relative{position:relative}.background-color-2{background-color:var(--calcite-color-surface-3)}.panel-background-2{--calcite-panel-background-color: var(--calcite-color-surface-3);background-color:var(--calcite-color-surface-3)}.border-none{border:none}.padding-end-xxl{padding-inline-end:var(--calcite-spacing-xxl)}calcite-shell{block-size:unset}.solution-detail-action{--calcite-color-focus: initial}a{color:var(--calcite-link-text-color, var(--calcite-color-text-link));cursor:pointer;text-decoration:none;line-height:inherit;background-image:linear-gradient(currentColor,currentColor),linear-gradient(var(--calcite-color-brand-underline),var(--calcite-color-brand-underline));background-position-x:0%,100%;background-position-y:min(1.5em,100%);background-repeat:no-repeat,no-repeat;background-size:0% 1px,100% 1px;transition-property:background-size,color;transition-duration:var(--calcite-animation-timing, .15s);transition-timing-function:ease-in-out;outline-color:transparent;position:relative}a:hover{background-size:100% 1px,100% 1px}a:focus{outline:2px solid var(--calcite-color-brand);outline-offset:2px;outline-color:var(--calcite-color-brand)}a:active{color:var(--calcite-color-brand-press)}*[tabindex]:focus-visible{outline:2px solid var(--calcite-color-brand);outline-offset:2px}.chip-status{--calcite-chip-icon-color: var(--calcite-color-brand);cursor:pointer}.chip-deployed{--calcite-chip-icon-color: var(--calcite-color-status-success)}.chip-deployed-warn{--calcite-chip-icon-color: var(--calcite-color-status-warning)}`;
class G extends I {
  constructor() {
    super(), this.readOnlyNotice = "", this._deployedTooltipContent = "", this._isDeployDisabled = !1, this._isLoaded = !1, this._itemFetched = !1, this._showScreenshotsShowMore = !1, this._showYouMayAlsoLikeShowMore = !1, this.isMobile = !1, this._isScreenshotsRowExpanded = !1, this._isYouMayAlsoLikeRowExpanded = !1, this._screenshotsRowBaseHeight = 340, this._showLoader = !1, this._templates = [], this._translations = M({ name: "solution-details-panel", blocking: !0 }), this._youMayAlsoLikeBaseHeight = 340, this._allCards = [], this._configContextConsumer = w({
      context: T,
      subscribe: !0
    }), this._configureLearnMore = "", this._customDeploymentMappings = {}, this._deployDialogRef = d(), this._deployingDialogRef = d(), this._deployFlow = new z({
      deployDialogRef: this._deployDialogRef,
      deployingDialogRef: this._deployingDialogRef,
      getCard: () => this.card,
      onDeployStarted: () => {
        this._deploymentStartTime = Date.now(), this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Started",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            "",
            m(this.card?.typeKeywords)
          ]
        });
      },
      onDeployCancelled: () => {
        this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Dialog Canceled",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            "",
            m(this.card?.typeKeywords)
          ]
        });
      },
      onDeploySuccess: () => {
        const e = v(this._deploymentStartTime);
        this._deploymentStartTime = null, this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Success",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            "",
            m(this.card?.typeKeywords)
          ],
          metrics: [e]
        });
      },
      onDeployFailedReal: (e) => {
        const t = v(this._deploymentStartTime);
        this._deploymentStartTime = null;
        const i = H(e), a = i.length > 200 ? i.slice(-200) : i;
        console.error("Deployment failed:", e), this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Failure",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            a,
            m(this.card?.typeKeywords)
          ],
          metrics: [t]
        });
      },
      onDeploymentProcessCancelled: () => {
        this._cancellationStartTime = Date.now(), this._deployToCancelDuration = v(this._deploymentStartTime), this._deploymentStartTime = null;
      },
      onCloseAfterCancel: () => {
        const e = v(this._cancellationStartTime);
        this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Canceled",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            "",
            m(this.card?.typeKeywords)
          ],
          metrics: [this._deployToCancelDuration, e]
        }), this._cancellationStartTime = null, this._deployToCancelDuration = 0;
      },
      onDeployedCardReady: (e) => {
        window.dispatchEvent(new CustomEvent("displayDeployedCard", { detail: e }));
      },
      onDeploymentFallback: () => {
        console.warn("Deployment completed but unable to navigate to deployed card - closing dialogs"), window.dispatchEvent(new CustomEvent("navTabSelected", { detail: "deployments" }));
      }
    }), this._isMobileContextConsumer = w({
      context: L,
      subscribe: !0,
      callback: (e) => this.isMobile = e
    }), this._overviewAccordionItemElement = d(), this._privilegePopoverRef = d(), this._privileges = [], this._regexFsUrl = "https?:\\/\\/.+FeatureServer\\b", this._regexID = "\\b[0-9A-F]{32}\\b", this._releaseNotesAccordionItemElement = d(), this._relatedResourcesAccordionItemElement = d(), this._screenshotsAccordionItemElement = d(), this._screenshotsDialogRef = d(), this._screenshotsElement = d(), this._screenshotsCardGroupElement = d(), this._termsOfUseAccordionItemElement = d(), this._userOptions = [], this._youMayAlsoLikeAccordionItemElement = d(), this._youMayAlsoLikeElement = d(), this._signInParamValue = null, this._deploymentStartTime = null, this._cancellationStartTime = null, this._deployToCancelDuration = 0, this.templatesFetched = f(), this.itemPropertiesFetched = f(), this.sortTypeChanged = f(), this.tokenRefreshed = f(), this._handleDeployCancelled = () => {
      this._deployFlow.handleDeployCancelled();
    }, this._deployProgressStart = (e) => {
      this._deployFlow.deployProgressStart(e);
    }, this._deployProgessUpdated = (e) => {
      this._deployFlow.deployProgressUpdated(e);
    }, this._handleDeploySuccess = (e) => {
      this._deployFlow.handleDeploySuccess(e);
    }, this._handleDeployedCardReady = (e) => this._deployFlow.handleDeployedCardReady(e), this._handleDeploymentFallback = (e) => {
      this._deployFlow.handleDeploymentFallback(e);
    }, this._handleDeploymentProcessCancelled = () => {
      this._deployFlow.handleDeploymentProcessCancelled();
    }, this._handleDeployFailed = (e) => {
      this._deployFlow.handleDeployFailed(e);
    }, this.listenOn(window, "detailsCardSelected", this._detailsCardSelected), this.listenOn(window, "allCardsFetched", this._allCardsFetched), this.listenOn(window, "deployAppTabSelected", this._handleDeployAppTabSelected), this.listenOn(window, "deployedCardReady", this._handleDeployedCardReady), this.listenOn(window, "deploymentCompletedWithoutNav", this._handleDeploymentFallback);
  }
  static {
    this.properties = { card: 0, readOnlyNotice: 1, _deployedTooltipContent: 16, _deployedChipType: 16, _isDeployDisabled: 16, _isLoaded: 16, _itemFetched: 16, _showScreenshotsShowMore: 16, _showYouMayAlsoLikeShowMore: 16, isMobile: 16, _isScreenshotsRowExpanded: 16, _isYouMayAlsoLikeRowExpanded: 16, _itemProperties: 16, _missingPrivilegeMessages: 16, _screenshotsRowBaseHeight: 16, _showLoader: 16, _templates: 16, _translations: 16, _youMayAlsoLikeBaseHeight: 16 };
  }
  static {
    this.styles = Y;
  }
  get _telemetry() {
    return this._configContextConsumer.value?.telemetrySession;
  }
  async connectedCallback() {
    super.connectedCallback(), this.listenOn(window, "calciteTabChange", this._cleanupPanel);
  }
  async load() {
    this._isMobileContextConsumer.value && (this.isMobile = this._isMobileContextConsumer.value);
  }
  willUpdate(e) {
    e.has("card") && (this._deployedTooltipContent = "", this._isDeployDisabled = !1, this._isLoaded = !1, this._showLoader = !1, this._deployedChipType = void 0, this._resolveDeployedStatus(), this._signInParamValue === "deploy" && (this._showLoader = !0, this._signInParamValue = null));
  }
  loaded() {
    this._signInParamValue === null && this._configContextConsumer.value?.authentication?.SignInParam && (this._signInParamValue = this._configContextConsumer.value.authentication.SignInParam), this._resizeObserver = new ResizeObserver(async () => {
      this._onResize();
    });
    const e = this._screenshotsCardGroupElement.value ?? this._screenshotsElement.value;
    e && this._resizeObserver.observe(e);
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this._resizeObserver?.disconnect();
  }
  render() {
    const e = "padding-bottom-1-5", t = this._getRelatedResources(), i = this._getYouMayAlsoLikeCards();
    return l`<calcite-shell class="position-relative background-color-2"><calcite-panel class="panel-background-2 border-none" slot=panel-bottom><div class="margin-top-875 padding-1-5 back-color-override-1 margin-bottom-1-5" id=solution-details-row>${this._getSolutionRow()}</div><div class=${p(e)}>${this._getScreenshotsRow()}</div><div class=${p(e)}>${this._getOverviewRow()}</div><div class=${p(e)}>${this._getReleaseNotesRow()}</div>${t.length > 0 ? l`<div class=${p(e)}>${this._getRelatedResourcesRow(t)}</div>` : ""}${i.length > 0 ? l`<div class=${p(e)}>${this._getYouMayAlsoLikeRow(i)}</div>` : ""}<div class=${p(e)}>${this._getTermsOfUseRow()}</div>${this.isMobile ? "" : l`<solution-deploy-dialog .card=${this.card} @deployCancelled=${this._handleDeployCancelled} @deployFailed=${this._handleDeployFailed} @deployProgressEnd=${this._handleDeploySuccess} @deployProgressStart=${this._deployProgressStart} @deployProgressUpdated=${this._deployProgessUpdated} id=solutionDeployDialog .userOptions=${this._userOptions} ${h(this._deployDialogRef)}></solution-deploy-dialog>`}<solution-snapshot-gallery .card=${this.card} id=solutionSnapshotGallery .itemProperties=${this._itemProperties} ${h(this._screenshotsDialogRef)}></solution-snapshot-gallery><solution-deploying-dialog .card=${this.card} @deploymentProcessCancelled=${this._handleDeploymentProcessCancelled} ${h(this._deployingDialogRef)}></solution-deploying-dialog></calcite-panel></calcite-shell>`;
  }
  updated() {
    setTimeout(() => {
      const e = this._getYouMayAlsoLikeCards();
      let t = 340;
      for (let i = 0; i < e.length; i++) {
        const a = this.el.shadowRoot?.getElementById(`you-may-also-like-${i}`), s = a?.offsetHeight ? a.offsetHeight + 40 : 0;
        s > t && (t = s);
      }
      this._youMayAlsoLikeBaseHeight = t, this._showYouMayAlsoLikeShowMore = (this._youMayAlsoLikeElement.value?.scrollHeight || 0) > this._youMayAlsoLikeBaseHeight, this._showScreenshotsShowMore = (this._screenshotsElement.value?.scrollHeight || 0) > this._screenshotsRowBaseHeight + 2;
    }, 100);
  }
  _checkUrlParametersForAutoDeployment() {
    if (this._signInParamValue === "deploy") {
      const t = this._missingPrivilegeMessages && (this._missingPrivilegeMessages.leadingMessages.length > 0 || this._missingPrivilegeMessages.bulletedMessages.length > 0 || this._missingPrivilegeMessages.trailingMessages.length > 0);
      this._configContextConsumer.value?.authentication?.IsSignedIn && this.card && this._deployDialogRef.value && !t && !b(this._configContextConsumer.value) && (this._signInParamValue = null, this._openDeploy());
    }
  }
  _getSolutionRow() {
    const e = this.card?.thumbnailUrl.replace(/w=\d+/, "w=400"), t = this._missingPrivilegeMessages?.leadingMessages || [], i = t.length > 0, a = this._missingPrivilegeMessages?.bulletedMessages || [], s = a.length > 0, o = this._missingPrivilegeMessages?.trailingMessages || [], r = o.length > 0;
    return l`<div class="display-flex flex-direction-row width-full"><div class="padding-end-1-75 image-width"><img alt=${this.card?.title ?? u} src=${e ?? u}></div><div class="display-flex flex-direction-row flex-1">${this._getTextSection(i, s, r, t, a, o)}${this._getButtons()}</div></div>`;
  }
  _getTextSection(e, t, i, a, s, o) {
    return l`<div class="display-flex flex-direction-column padding-end-1 flex-1"><div class="display-flex flex-direction-row align-items-baseline"><h1 class="padding-top-xs title-font margin-top-0 margin-bottom-1-5 line-height-1" tabindex=0>${this.card?.title}</h1>${this._renderChips(this._getChips())}</div><div class="font-1 padding-end-1 line-height-xxl" tabindex=0>${this.card?.snippet}</div>${this.isMobile ? "" : b(this._configContextConsumer.value) ? l`<div class="display-flex flex-direction-row padding-top-1">${this._getReadOnlyNotice()}</div>` : e || t || i ? l`<div class="display-flex flex-direction-row padding-top-1">${this._getMissingPrivilegesNotice(a, s, o)}</div>` : ""}</div>`;
  }
  _getChips() {
    const e = [...this.card?.chips ?? []];
    return !e.some((i) => i === "deployed" || i === "deployedOlderVersion") && this._deployedChipType && e.push(this._deployedChipType), e;
  }
  async _resolveDeployedStatus() {
    const e = this.card;
    if (!e?.deployCommonId || e.chips?.some((a) => a === "deployed" || a === "deployedOlderVersion"))
      return;
    const t = this._configContextConsumer.value?.userSession, i = t?.username;
    if (!(!t || !i))
      try {
        const s = (await x.searchItems({
          q: `${e.deployCommonId} and owner:${i}`,
          authentication: t,
          pagingParam: { start: 1, num: 100 }
        }))?.results ?? [];
        if (s.length === 0) {
          this._deployedChipType = void 0;
          return;
        }
        const o = N(s)[0]?.typeKeywords?.find((c) => c.startsWith("solutionversion-"))?.split("-")[1], r = e.deployVersion;
        this._deployedChipType = r && o && o !== r ? "deployedOlderVersion" : "deployed";
      } catch {
        this._deployedChipType = void 0;
      }
  }
  _renderChips(e) {
    const t = e.filter((s) => s === "deployed" || s === "deployedOlderVersion"), i = e.filter((s) => s !== "deployed" && s !== "deployedOlderVersion"), a = [];
    if (i.forEach((s) => {
      const o = "margin-bottom-1-5 margin-sides-1 chip-status", r = `solution-details-card-chip-${s}`, c = s === "new" ? "star" : "mega-phone", n = s === "new" ? this._translations.newChip : this._translations.updatedChip;
      a.push(l`<calcite-chip class=${p(o)} .icon=${c} id=${r ?? u} .label=${n} .value=${n} scale=s></calcite-chip><calcite-tooltip .referenceElement=${r}><span>${n}</span></calcite-tooltip>`);
    }), t.length > 0) {
      let s = "margin-bottom-1-5 margin-sides-1 chip-status";
      i.length > 0 ? s = t[0] === "deployedOlderVersion" ? "chip-deployed-warn" : "chip-deployed" : s += t[0] === "deployedOlderVersion" ? " chip-deployed-warn" : " chip-deployed", a.push(l`<calcite-chip class=${p(s)} .icon=${t[0] === "deployedOlderVersion" ? "recent" : "check-circle"} id=solution-details-card-chip-deployed .label=${this._translations.deployedChip} .value=${this._translations.deployedChip} scale=s></calcite-chip><calcite-tooltip placement=bottom reference-element=solution-details-card-chip-deployed @calciteTooltipBeforeOpen=${async () => {
        const o = {
          q: `${this.card?.deployCommonId} and owner:${this._configContextConsumer.value?.userSession?.username}`,
          authentication: this._configContextConsumer.value?.userSession,
          pagingParam: { start: 1, num: 100 }
        }, r = await x.searchItems(o);
        this._deployedTooltipContent = l`<solutions-deployed-list .results=${r} has-links .listTitle=${t[0] === "deployedOlderVersion" ? this._translations.deployedPreviousTitle : this._translations.deployedTitle}></solutions-deployed-list>`;
      }} @calciteTooltipBeforeClose=${() => {
      }}>${this._deployedTooltipContent}</calcite-tooltip>`);
    }
    return a;
  }
  _getButtons() {
    const e = this._itemProperties?.demoURL || "", t = b(this._configContextConsumer.value);
    return l`<div class="display-flex flex-direction-column button-width">${!this.isMobile && l`<calcite-button class="padding-bottom-1 solution-detail-action" .disabled=${this._isDeployDisabled || t} icon-flip-rtl=end @click=${() => this._checkPermissionsBeforeDeploy()} scale=m width=full>${this._showLoader ? l`<calcite-loader inline label></calcite-loader>` : this._translations.deployButton}</calcite-button>` || ""}${!this._configContextConsumer.value?.isEnterprise && e && l`<calcite-button appearance=outline-fill kind=neutral class="padding-bottom-1 solution-detail-action" @click=${() => this._handleWatchDemoClick(e)} scale=m width=full>${this._translations.watchDemo}</calcite-button>` || ""}<calcite-button appearance=outline-fill kind=neutral class="padding-bottom-1 solution-detail-action" @click=${() => this._handleLearnMoreClick()} scale=m width=full>${this._translations.openHelp}</calcite-button>${!this._configContextConsumer.value?.isEnterprise && l`<solution-social-share button-appearance=outline-fill class="padding-bottom-1" share-button-kind=neutral .shareButtonText=${this._translations.share} share-button-scale=m .solutionId=${this.card?.deployCommonId || ""} .solutionTitle=${this.card?.title || ""} .solutionVersion=${this.card?.deployVersion || ""}></solution-social-share>` || ""}</div>`;
  }
  _getReadOnlyNotice() {
    return l`<calcite-notice class="margin-inline-unset" icon=exclamation-mark-triangle kind=warning open scale=s><div slot=message .innerHTML=${this.readOnlyNotice ?? ""}></div></calcite-notice>`;
  }
  _getMissingPrivilegesNotice(e, t, i) {
    const a = "solutions-missing-privileges-notice", s = this._translations.missingPrivilegesPopup.missingLicensingOrPrivileges, o = t.length > 0 ? "" : "display-none", r = t.length > 0 ? "padding-top-sm" : "";
    return l`<div><calcite-notice class="margin-inline-unset" kind=info open><div slot=message>${`${s}`}</div><calcite-action icon=information id=${a} slot=actions-end .text=${s}></calcite-action></calcite-notice><calcite-popover closable label overlay-positioning=fixed placement=bottom reference-element=solutions-missing-privileges-notice ${h(this._privilegePopoverRef)}><div class="padding-1 display-flex flex-direction-column">${// Leading messages
    this._getSpanMessages(e, "padding-bottom-1")}<span class=${`padding-bottom-1-2 ${o}`}>${this._translations.missingPrivilegesPopup.missingPrivilegesListHeading}</span>${// Bulleted messages
    this._getBulletedMessages(t)}${// Trailing messages
    this._getSpanMessages(i, r)}</div></calcite-popover></div>`;
  }
  _getSpanMessages(e, t) {
    return e.length > 0 ? e.map((i) => l`<span class=${p(t)}>${i}</span>`) : "";
  }
  _getBulletedMessages(e) {
    return e.length > 0 ? l`<ul>${e.map((t) => l`<li>${t}</li>`)}</ul>` : "";
  }
  _getScreenshotsRow() {
    const e = this._isScreenshotsRowExpanded ? this._translations.showLess : this._translations.showMore, t = this._isScreenshotsRowExpanded ? "arrow-up" : "arrow-down", i = this._showScreenshotsShowMore ? "" : "display-none";
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._screenshotsAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.solutionOverview}</div><calcite-panel><div class="display-flex flex-direction-column back-color-override-1"><div class="collapsible-div max-height-300" id=screenshots-subsection ${h(this._screenshotsElement)}>${this._getScreenshots()}</div><calcite-fab appearance=outline-fill class=${`align-self-center ${i}`} .icon=${t} kind=neutral @click=${() => {
      this._screenshotsElement.value?.classList.toggle("expanded"), this._isScreenshotsRowExpanded = this._screenshotsElement.value.classList.contains("expanded");
    }} .text=${e} text-enabled></calcite-fab></div></calcite-panel></calcite-accordion-item></calcite-accordion>`;
  }
  _getScreenshots() {
    const e = this._itemProperties?.preview.filter((s) => s.format === "image") || [], t = this._configContextConsumer.value, i = this._itemFetched ? "" : "display-none", a = this._itemFetched ? "display-none" : "";
    return l`<calcite-loader class=${p(a)} label></calcite-loader><calcite-card-group class=${`card-group ${i}`} .label=${this._translations.solutionOverview} ${h(this._screenshotsCardGroupElement)}>${e.reduce((s, o) => {
      const r = $(this.card?.id || "", o.name, t.authentication);
      let c;
      return t.agoBasedEnterpriseSolutionsGroupId && t.isEnterprise && (c = $(this.card?.id || "", o.name, void 0, t.agolPortalUrl)), this.card?.id ? s.push(l`<calcite-card class=${`${this.isMobile ? "is-mobile" : "cursor-pointer not-mobile"}`} .label=${o.alt} @click=${() => this._openScreenshotGallery(o)} @keydown=${(n) => B(n, () => this._openScreenshotGallery(o))}><div class="card-image-wrap" slot=thumbnail><img alt=${o.alt ?? u} class="thumbnail card-image" slot=thumbnail src=${(c || r) ?? u}>${!this.isMobile && l`<div class="hover-text">${this._translations.openInGallery}</div>` || ""}</div></calcite-card>`) : s.push(""), s;
    }, [])}</calcite-card-group>`;
  }
  _openScreenshotGallery(e) {
    if (!this.isMobile) {
      this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Screenshot Gallery",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ]
      });
      const t = this._screenshotsDialogRef.value;
      t && (t.screenshot = e, t.open = !0);
    }
  }
  _getOverviewRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._overviewAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.solutionDetails}</div>${this._getDescriptionRow()}${this._getInformationProductsRow()}</calcite-accordion-item></calcite-accordion>`;
  }
  _getDescriptionRow() {
    return l`<div class="display-flex flex-direction-column"><div class="font-color-2 font-1 margin-top-0 line-height-xxl padding-bottom-xxl" tabindex=0>${this.card?.snippet}</div><div class="font-color-2 font-1 margin-top-0 line-height-xxl padding-bottom-xxl" .innerHTML=${this.card?.description ?? ""} tabindex=0></div></div>`;
  }
  _getInformationProductsRow() {
    return l`<div class="display-flex flex-direction-column font-1 line-height-xxl font-color-2"><span tabindex=0>${this.card?.title ? this._translations.informationProductsSubText.replace("{{solutionTitle}}", this.card.title) : ""}</span><calcite-table bordered caption class="padding-top-1">${this._getInformationTableHeaderRow()}${this._getInformationTableRows()}</calcite-table><p tabindex=0>${this._translations.informationProductsFooterText}</p></div>`;
  }
  _getInformationTableHeaderRow() {
    return l`<calcite-table-row slot=table-header><calcite-table-header .heading=${this._translations.solutionItem}></calcite-table-header><calcite-table-header .heading=${this._translations.description}></calcite-table-header><calcite-table-header .heading=${this._translations.minimumUserType}></calcite-table-header></calcite-table-row>`;
  }
  _getInformationTableRows() {
    return (this._itemProperties?.infoProducts || []).map((t) => l`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${y(t.item) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${y(t.description) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${y(t.userType) ?? ""}></p></calcite-table-cell></calcite-table-row>`);
  }
  _getReleaseNotesRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._releaseNotesAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.releaseNotes}</div><div class="display-flex flex-direction-column"><calcite-table bordered caption>${this._getReleaseNotesTableHeaderRow()}${this._getReleaseNotesTableRows()}</calcite-table></div></calcite-accordion-item></calcite-accordion>`;
  }
  _getReleaseNotesTableHeaderRow() {
    return l`<calcite-table-row slot=table-header><calcite-table-header .heading=${this._translations.version}></calcite-table-header><calcite-table-header .heading=${this._translations.description}></calcite-table-header></calcite-table-row>`;
  }
  _getReleaseNotesTableRows() {
    return (this._itemProperties?.releaseNotes || [])?.map((t) => l`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${y(t.version) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${y(t.description) ?? ""}></p></calcite-table-cell></calcite-table-row>`);
  }
  _getRelatedResourcesRow(e) {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._relatedResourcesAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.relatedResources}</div><div class="display-flex flex-direction-row">${e.map(() => {
      l`<solution-resource-card></solution-resource-card>`;
    })}</div></calcite-accordion-item></calcite-accordion>`;
  }
  _getRelatedResources() {
    return [];
  }
  _getYouMayAlsoLikeRow(e) {
    const t = this._showYouMayAlsoLikeShowMore ? "" : "display-none", i = this._isYouMayAlsoLikeRowExpanded ? this._translations.showLess : this._translations.showMore, a = this._isYouMayAlsoLikeRowExpanded ? "arrow-up" : "arrow-down", s = this._isYouMayAlsoLikeRowExpanded ? "" : { height: `${this._youMayAlsoLikeBaseHeight}px` };
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._youMayAlsoLikeAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.youMayAlsoLike}</div><div class="display-flex flex-direction-column"><div class="collapsible-div" id=you-may-also-like-subsection style=${D(s)} ${h(this._youMayAlsoLikeElement)}><div class="display-flex flex-direction-row"><calcite-card-group class="card-group" .label=${this._translations.youMayAlsoLike}>${e.map((o, r) => l`<solution-details-card .id=${`you-may-also-like-${r}`} .card=${o} class="padding-2px" source=you-may-also-like .referrerSolutionId=${this.card?.deployCommonId || ""} .referrerSolutionTitle=${this.card?.title || ""} .referrerSolutionVersion=${this.card?.deployVersion || ""}></solution-details-card>`)}</calcite-card-group></div></div><calcite-fab appearance=outline-fill class=${`align-self-center ${t}`} .icon=${a} kind=inverse @click=${() => {
      this._youMayAlsoLikeElement.value?.classList.toggle("expanded"), this._isYouMayAlsoLikeRowExpanded = this._youMayAlsoLikeElement.value.classList.contains("expanded");
    }} .text=${i} text-enabled></calcite-fab></div></calcite-accordion-item></calcite-accordion>`;
  }
  _getYouMayAlsoLikeCards() {
    const e = this._itemProperties?.relatedSolutions || [];
    return this._allCards.filter((t) => e.indexOf(t.deployCommonId) > -1);
  }
  _getTermsOfUseRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._termsOfUseAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.termsOfUse}</div><div class="font-color-2" .innerHTML=${(this.card?.licenseInfo || "") ?? ""} tabindex=0></div></calcite-accordion-item></calcite-accordion>`;
  }
  _openDeploy() {
    if (this._configContextConsumer.value.authentication.IsSignedIn) {
      const e = this._deployDialogRef.value;
      if (e) {
        const t = m(this.card?.typeKeywords);
        this._telemetry?.logEvent({
          category: g.SOLUTION_DETAILS,
          action: "Deploy Dialog Opened",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || "",
            "",
            t
          ]
        }), e.userOptions = this._userOptions, e.open = !0;
      }
    } else
      this._configContextConsumer.value.authentication.signIn("deploy");
  }
  _openUrl(e) {
    window.open(e, "_blank");
  }
  _handleWatchDemoClick(e) {
    this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Watch Demo",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    }), this._openUrl(e);
  }
  _handleLearnMoreClick() {
    this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Open Help",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    }), this._openUrl(this.card?.learnMoreUrl || "");
  }
  async _detailsCardSelected(e) {
    this.card = e.detail, this.el.scrollIntoView(!0), this._onResize(), this._missingPrivilegeMessages = void 0, await this._getItemData(), this._expandAccordions();
  }
  _expandAccordions() {
    this._overviewAccordionItemElement.value && (this._overviewAccordionItemElement.value.expanded = !0), this._releaseNotesAccordionItemElement.value && (this._releaseNotesAccordionItemElement.value.expanded = !0), this._relatedResourcesAccordionItemElement.value && (this._relatedResourcesAccordionItemElement.value.expanded = !0), this._screenshotsAccordionItemElement.value && (this._screenshotsAccordionItemElement.value.expanded = !0), this._termsOfUseAccordionItemElement.value && (this._termsOfUseAccordionItemElement.value.expanded = !0), this._youMayAlsoLikeAccordionItemElement.value && (this._youMayAlsoLikeAccordionItemElement.value.expanded = !0);
  }
  async _getItemData() {
    this._itemFetched = !1;
    const e = this._configContextConsumer.value, t = e?.agoBasedEnterpriseSolutionsGroupId && e?.isEnterprise ? e.anonAgolSession : e?.userSession, i = await R(this.card.id, t), a = await P(this.card.id, t);
    this._itemFetched = !0, this._itemProperties = a.properties, this.itemPropertiesFetched.emit(this._itemProperties);
    const s = O(i, this.card.typeKeywords, e?.authentication);
    this._privileges = t.username ? s : [], this._userPrivileges = e?.authentication ? e.authentication.PortalUserEnrichedPrivileges : [];
    const o = this._privileges.filter((c) => !this._userPrivileges.includes(c));
    this._missingPrivilegeMessages = F(this._translations, o), this._isDeployDisabled = this._missingPrivilegeMessages && (this._missingPrivilegeMessages.leadingMessages.length > 0 || this._missingPrivilegeMessages.bulletedMessages.length > 0 || this._missingPrivilegeMessages.trailingMessages.length > 0);
    const r = i.params ? await this.formatParams(i.params) : [];
    this._userOptions = r, this._templates = i.templates, this.templatesFetched.emit(i.templates), this._checkUrlParametersForAutoDeployment(), this._isLoaded = !0, this._showLoader && (this._showLoader = !1, this._isDeployDisabled || this._openDeploy());
  }
  formatParams(e) {
    const t = this._configContextConsumer.value.userSession, i = [], a = e ? Object.keys(e) : [], s = {
      id: "",
      props: [],
      accordionDisplay: !1
    };
    if (a.length > 0) {
      const o = [];
      return a.forEach((r) => {
        const c = e[r];
        c.valueType && c.valueType.toLowerCase() === "itemid" && o.push(this._findExistingItem(r, "Feature Service", t.username || ""));
      }), Promise.all(o).then((r) => {
        const c = {};
        return r.forEach((n) => {
          if (n.query && n.results && n.results.length > 0) {
            const S = n.query.split(" ")[0].replace("typekeywords:source-", "");
            c[S] = {
              resultId: n.results[0].id,
              response: n.results[0]
            };
          }
        }), a.forEach((n) => {
          if (n === "serviceLearnMore") {
            this._configureLearnMore = e[n], alert(this._configureLearnMore), delete e[n];
            return;
          }
          e[n].enterpriseIDMapping && (this._customDeploymentMappings[n] = e[n].enterpriseIDMapping), s.id = n, c[n] && (e[n].existingItemId = c[n].resultId, this.updateUserProp(e[n], c[n].response)), this.updateOption(e[n], s, n);
        }), i.push(s), Promise.resolve(i);
      }).catch(() => Promise.resolve([]));
    } else
      return Promise.resolve([]);
  }
  _findExistingItem(e, t, i) {
    const a = this._configContextConsumer.value.userSession;
    return V(`typekeywords:source-${e} type:${t} owner:${i}`, a);
  }
  updateUserProp(e, t) {
    const i = e.itemType?.toLowerCase() === "feature service", a = new RegExp(i ? this._regexFsUrl : e.itemType, "iu"), s = C(t, i ? "url" : "type", "") || "", o = s !== "" && a.test(s);
    return e.responseValue = o ? s : "", e.name = o && _(t, "name") || "", e.title = o && _(t, "title") || "", e.itemType = o ? _(t, "type") : e.itemType, e.validId = o, e.itemUrl = U(t.id, this._configContextConsumer.value.authentication), o;
  }
  updateOption(e, t, i) {
    const a = e.default || "", s = typeof a, o = a.toString();
    this._setFeatureServiceProps(e);
    const r = this.getValidation(e, o);
    t.props.push({
      id: i,
      outType: s,
      prop: i,
      itemType: e.itemType || "",
      responseValue: e.responseValue || "",
      label: e.label || "",
      choices: e.choices || [],
      valueType: e.valueType.toLowerCase(),
      attributes: e.attributes || {},
      value: e.existingItemId && e.valueType.toLowerCase() === "itemid" ? e.existingItemId : o,
      default: o,
      srSearchText: o,
      autoSelect: o !== "",
      ...r,
      loading: !1,
      validId: !0,
      tooltip: e.tooltip || "",
      name: e.name || "",
      title: e.title || "",
      itemUrl: e.itemUrl || ""
    });
  }
  _setFeatureServiceProps(e) {
    e.valueType && e.valueType.toLowerCase() === "itemid" && A(e, "attributes.required", "true");
  }
  getValidation(e, t) {
    let i = "", a = _(e, "validation.message") || "", s = !0;
    return _(e, "attributes.required") === "true" && (i = C(e, "validation.expression", "\\S{1,}"), s = new RegExp(i).test(t)), e.valueType && e.valueType.toLowerCase() === "itemid" && (i = this._regexID, a = this._translations.configure.invalidID), {
      valid: s,
      validation: {
        expression: i,
        message: a
      }
    };
  }
  _allCardsFetched(e) {
    this._allCards = e.detail;
  }
  _onResize() {
    this._showYouMayAlsoLikeShowMore = (this._youMayAlsoLikeElement.value?.scrollHeight || 0) > this._youMayAlsoLikeBaseHeight, this._showScreenshotsShowMore = (this._screenshotsElement.value?.scrollHeight || 0) > this._screenshotsRowBaseHeight + 2;
  }
  _cleanupPanel() {
    this.el.scrollIntoView(!0), this._isScreenshotsRowExpanded = !1, this._showScreenshotsShowMore = !1, this._screenshotsElement.value?.classList.remove("expanded"), this._isYouMayAlsoLikeRowExpanded = !1, this._showYouMayAlsoLikeShowMore = !1, this._youMayAlsoLikeElement.value?.classList.remove("expanded"), this._privilegePopoverRef.value?.open && (this._privilegePopoverRef.value.open = !1), this._isDeployDisabled = !1, this._isLoaded = !1, this._itemFetched = !1, this._showLoader = !1, this._expandAccordions();
  }
  _handleDeployAppTabSelected(e) {
    e.detail === "details" && this.sortTypeChanged.emit("");
  }
  _checkPermissionsBeforeDeploy() {
    b(this._configContextConsumer.value) || (this._isLoaded ? this._openDeploy() : this._configContextConsumer.value.authentication?.IsSignedIn ? this._showLoader = !0 : this._openDeploy());
  }
}
k("solution-details-panel", G);
export {
  G as SolutionDetailsPanel
};
