/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import * as common from "@esri/solution-common";
import { c as customElement } from "./runtime.js";
import { u as useT9n } from "./useT9n.js";
import { LitElement, createEvent, nothing, safeClassMap } from "@arcgis/lumina";
import { useContextConsumer } from "@arcgis/lumina/context";
import { c as configContext } from "./deployAppContexts.js";
import { css, html, svg } from "lit";
import "@arcgis/lumina/controllers";
import "@arcgis/core/identity/IdentityManager.js";
import "@arcgis/core/identity/OAuthInfo.js";
import "@arcgis/core/portal/Portal.js";
import { createRef, ref } from "lit-html/directives/ref.js";
const styles = css`/** @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-card {
  height: 100%;
  padding-bottom: var(--calcite-spacing-base);
}

/* @media (max-width: 600px) {
  calcite-card {
    width: calc(100% / 2 - var(--calcite-spacing-sm));
  }
} */

@media (max-width: 400px) {
  calcite-card {
    width: 100%;
  }
}

calcite-card:hover img {
  /* TODO check in dark mode */
  -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: #ffffff;
}

calcite-card:hover {
  outline: var(--calcite-spacing-base) solid var(--calcite-color-brand);
  box-sizing: content-box;
  cursor: pointer;
}

.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 {
  flex: 0 0 auto;
}

.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;
}

.card-image {
  width: 100%;
  display: block;
}

video,
img {
  max-width: 100%;
  height: auto;
}

img {
  overflow-clip-margin: content-box;
  overflow: clip;
}

.width-full {
  width: 100%;
}

.deployed-label-override {
  --calcite-label-text-color: var(--calcite-color-text-3);
  --calcite-label-margin-bottom: var(--calcite-spacing-none);
}

.svg-color {
  fill: var(--calcite-color-text-3);
}

.padding-end-1-2 {
  padding-inline-end: var(--calcite-spacing-sm);
}

.padding-bottom-1-2 {
  padding-bottom: var(--calcite-spacing-sm);
}

.display-flex {
  display: flex;
}

.display-none {
  display: none;
}

.flex-direction-column {
  flex-direction: column;
}

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

.font-weight-400 {
  font-weight: 400;
}

.font-weight-normal {
  font-weight: normal;
}

.font-color-text-2 {
  --calcite-label-text-color: var(--calcite-color-text-2);
}

.font-line-height {
  line-height: 1.4;
}

.font-size-size--1 {
  font-size: var(--calcite-font-size--1);
}

.icon-brand-color {
  --calcite-icon-color: var(--calcite-color-brand);
}

.header-line-height {
  --calcite-label-margin-bottom: 0;
  margin-top: var(--calcite-spacing-sm);
  margin-bottom: 0.7rem;
}

.dialog-y-size {
  --calcite-dialog-size-y: 90%
}

.dialog-x-size {
  --calcite-dialog-size-x: 90%
}

.justify-content-space-between {
  justify-content: space-between;
}

.panel-bg-color {
  --calcite-panel-header-background-color: var(--calcite-color-foreground-1);
  --calcite-panel-background-color: var(--calcite-color-foreground-1);
}

.cursor-default {
  cursor: default;
}
`;
async function prepareDataForSolutionDisplay(solutionId, userSession) {
  const solutionData = await common.getItemDataAsJson(solutionId, userSession);
  if (!solutionData) {
    throw new Error(`Solution ${solutionId} was not found`);
  }
  const portalRoot = userSession?.portal.replace("/sharing/rest", "") ?? "https://www.arcgis.com";
  let collection = [];
  if (!solutionData.templates[0].item) {
    const itemFetchPromises = solutionData.templates.map((template) => {
      if (template.type === "Group") {
        return common.getGroupBase(template.itemId, userSession);
      } else {
        return common.getItemBase(template.itemId, userSession);
      }
    });
    const itemFetches = await Promise.allSettled(itemFetchPromises);
    const items = itemFetches.filter((item) => item.status === "fulfilled").map((item) => item.value);
    collection = items.map((item, index) => {
      const page = typeof item.type === "undefined" ? "group" : "item";
      return {
        id: item.id,
        title: item.title,
        type: item.type ?? "Group",
        typeKeywords: item.typeKeywords,
        dependencies: solutionData.templates[index].dependencies,
        snippet: item.snippet,
        url: `${portalRoot}/home/${page}.html?id=${item.id}`
      };
    });
  } else {
    collection = solutionData.templates.map((template) => {
      return {
        id: template.itemId,
        title: template.item.title,
        type: template.item.type,
        typeKeywords: template.item.typeKeywords,
        dependencies: template.dependencies,
        snippet: template.item.snippet
      };
    });
  }
  return collection;
}
function getRequiredSolutionPrivileges(solutionData, cardTypeKeywords, auth) {
  const templateTypeList = solutionData.templates.map((template) => template.type);
  const privilegeList = [];
  privilegeList.push(PORTAL_CREATE_ITEM);
  if (templateTypeList.indexOf("Group") >= 0) {
    privilegeList.push(PORTAL_CREATE_GROUP);
    privilegeList.push(PORTAL_SHARE_TO_GROUP);
  }
  if (templateTypeList.indexOf("Feature Service") >= 0) {
    privilegeList.push(PORTAL_PUBLISH_FEATURES);
  }
  const hasFeed = templateTypeList.indexOf("Feed") > -1;
  if (hasFeed) {
    privilegeList.push(PORTAL_PUBLISH_FEEDS);
  }
  const hasBigDataAnalytic = templateTypeList.indexOf("Big Data Analytic") > -1;
  if (hasBigDataAnalytic) {
    privilegeList.push(PORTAL_PUBLISH_BD_ANALYTICS);
  }
  const hasRealTimeAnalytic = templateTypeList.indexOf("Real Time Analytic") > -1;
  if (hasRealTimeAnalytic) {
    privilegeList.push(PORTAL_PUBLISH_RT_ANALYTICS);
  }
  if (hasFeed || hasBigDataAnalytic || hasRealTimeAnalytic) {
    privilegeList.push(SOLUTIONS_VELOCITY);
  }
  if (templateTypeList.indexOf("Workflow") > -1) {
    privilegeList.push(PORTAL_CREATE_GROUP);
    privilegeList.push(PORTAL_PUBLISH_FEATURES);
    privilegeList.push(PORTAL_SHARE_TO_GROUP);
    privilegeList.push(SOLUTIONS_WORKFLOW_MANAGER);
  }
  if (templateTypeList.indexOf("Geoprocessing Service") > -1) {
    privilegeList.push(PORTAL_PUBLISH_GP);
    if (auth.IsEnterprisePortal) {
      privilegeList.push(SOLUTIONS_NOTEBOOK);
    }
  }
  const templateTypeKeywords = solutionData.templates.reduce(
    (prev, cur) => {
      return prev.concat(cur.item.typeKeywords || []);
    },
    []
  );
  _updatePrivilegeListByTemplateTypeKeywords(privilegeList, templateTypeKeywords, auth);
  _updatePrivilegeListBySolutionTypeKeywords(privilegeList, cardTypeKeywords);
  _updatePrivilegeListByGroup(privilegeList, solutionData);
  return privilegeList;
}
function _updatePrivilegeListByGroup(privilegeList, data) {
  if (data.templates.some((t) => t.type === "Group" && t.item?.membershipAccess === "collaboration")) {
    privilegeList.push(PORTAL_ADD_MEMBERS_TO_GROUP);
  }
}
function _updatePrivilegeListByTemplateTypeKeywords(privilegeList, templateTypeKeywords, auth) {
  const userIsAdmin = getUserIsAdmin(auth);
  const locationTrackingEnabled = _isLocationTrackingEnabled(auth);
  const trackingKeywords = ["Location Tracking View"];
  if (trackingKeywords.some((t) => templateTypeKeywords.indexOf(t) > -1)) {
    if (!userIsAdmin && !locationTrackingEnabled) {
      privilegeList.push(SOLUTIONS_TRACKING_ADMIN_TRACKING);
    } else if (userIsAdmin && !locationTrackingEnabled) {
      privilegeList.push(SOLUTIONS_TRACKING);
    } else if (!userIsAdmin && locationTrackingEnabled) {
      privilegeList.push(SOLUTIONS_TRACKING_ADMIN);
    }
  }
}
function _updatePrivilegeListBySolutionTypeKeywords(privilegeList, solutionTypeKeywords) {
  const hubKeywords = ["HubPremium"];
  if (hubKeywords.some((t) => solutionTypeKeywords.indexOf(t) > -1)) {
    privilegeList.push(SOLUTIONS_HUB_PREMIUM);
  }
}
function getUserIsAdmin(auth) {
  const portalUserSubset = auth.PortalUserSubset;
  return portalUserSubset?.role === "org_admin" && !portalUserSubset?.hasOwnProperty("roleId");
}
function _isLocationTrackingEnabled(auth) {
  return auth.PortalSubset?.locationTrackingEnabled || false;
}
function getPrivilegeMessages(translations, missingPrivileges) {
  let userMessages = {
    leadingMessages: [],
    bulletedMessages: [],
    trailingMessages: []
  };
  const keyPrivileges = [
    ECustomPrivileges.NOTEBOOK,
    ECustomPrivileges.VELOCITY,
    ECustomPrivileges.HUBPREMIUM,
    ECustomPrivileges.WORKFLOW,
    ECustomPrivileges.TRACKINGBASE
  ];
  let velocityMessage = _getKeyMessage(
    translations,
    missingPrivileges,
    ECustomPrivileges.VELOCITY
  );
  if (velocityMessage) {
    userMessages.leadingMessages.push(velocityMessage);
  }
  let notebookMessage = _getKeyMessage(
    translations,
    missingPrivileges,
    ECustomPrivileges.NOTEBOOK
  );
  if (notebookMessage) {
    userMessages.leadingMessages.push(notebookMessage);
  }
  let hubMessage = _getKeyMessage(
    translations,
    missingPrivileges,
    ECustomPrivileges.HUBPREMIUM
  );
  if (hubMessage) {
    userMessages.leadingMessages.push(hubMessage);
  }
  let workflowManagerMessage = _getKeyMessage(
    translations,
    missingPrivileges,
    ECustomPrivileges.WORKFLOW
  );
  if (workflowManagerMessage) {
    userMessages.leadingMessages.push(workflowManagerMessage);
  }
  missingPrivileges = missingPrivileges.filter((p) => keyPrivileges.indexOf(p) < 0);
  missingPrivileges.forEach((p) => {
    userMessages.bulletedMessages.push(
      _getPrivilegeCodeDisplay(translations, p)
    );
  });
  let trackingMessage = _getKeyMessage(
    translations,
    missingPrivileges,
    ECustomPrivileges.TRACKINGBASE
  );
  if (trackingMessage) {
    userMessages.trailingMessages.push(trackingMessage);
  }
  const missingKeyPrivilege = userMessages.leadingMessages.length > 0 || userMessages.trailingMessages.length > 0 || userMessages.bulletedMessages.length > 0;
  if (missingKeyPrivilege) {
    userMessages.trailingMessages.push(
      translations.missingPrivilegesPopup.suggestedProblemRemedyMessage
    );
  }
  return userMessages;
}
function _getKeyMessage(translations, missingPrivileges, privilege) {
  const keyMessages = missingPrivileges.filter((p) => p.includes(privilege));
  return keyMessages.length > 0 ? _getPrivilegeCodeDisplay(translations, privilege) : "";
}
function _getPrivilegeCodeDisplay(translations, privilege) {
  const requiredPrivilegesList = translations.missingPrivilegesPopup.requiredPrivilegesList;
  let missingPrivilege = "";
  switch (privilege) {
    case "portal:user:createItem":
      missingPrivilege = requiredPrivilegesList.createItem;
      break;
    case "portal:publisher:publishFeatures":
      missingPrivilege = requiredPrivilegesList.publishFeatures;
      break;
    case "portal:user:createGroup":
      missingPrivilege = requiredPrivilegesList.createGroup;
      break;
    case "portal:user:shareToGroup":
      missingPrivilege = requiredPrivilegesList.shareToGroup;
      break;
    case "portal:user:addExternalMembersToGroup":
      missingPrivilege = requiredPrivilegesList.addMembers;
      break;
    case "portal:publisher:publishFeeds":
      missingPrivilege = requiredPrivilegesList.publishFeeds;
      break;
    case "portal:publisher:publishBigDataAnalytics":
      missingPrivilege = requiredPrivilegesList.publishBigDataAnalytics;
      break;
    case "portal:publisher:publishRealTimeAnalytics":
      missingPrivilege = requiredPrivilegesList.publishRealTimeAnalytics;
      break;
    case "solutions:locationtracking:admin:tracking":
      missingPrivilege = requiredPrivilegesList.requiresLocationTrackingAndAdmin;
      break;
    case "solutions:locationtracking:tracking":
      missingPrivilege = requiredPrivilegesList.requiresLocationTracking;
      break;
    case "solutions:locationtracking:admin":
      missingPrivilege = requiredPrivilegesList.requiresAdmin;
      break;
    case "solutions:hubPremium":
      missingPrivilege = requiredPrivilegesList.hubPremium;
      break;
    case "solutions:workflowManager":
      missingPrivilege = requiredPrivilegesList.workflowManager;
      break;
    case "solutions:velocity":
      missingPrivilege = requiredPrivilegesList.velocity;
      break;
    case "solutions:notebook":
      missingPrivilege = requiredPrivilegesList.requiresNotebookServer;
      break;
    case "portal:publisher:publishServerGPServices":
      missingPrivilege = requiredPrivilegesList.publishGPServices;
      break;
    case "writable:Enterprise":
      missingPrivilege = requiredPrivilegesList.writableEnterprise;
      break;
    case "writable:Online":
      missingPrivilege = requiredPrivilegesList.writableOnline.replace("{{url}}", "https://status.arcgis.com");
      break;
  }
  return missingPrivilege;
}
class SolutionDeployedCard extends LitElement {
  constructor() {
    super(...arguments);
    this.allowDelete = false;
    this.deployedDate = "";
    this.description = "";
    this.diagramKey = "";
    this.heading = "";
    this.itemId = "";
    this.owner = "";
    this.thumbnail = "";
    this.updateAvailable = false;
    this.templateInfos = [];
    this._isDeleteOpen = false;
    this._isDiagramOpen = false;
    this.templateInfoGraph = [];
    this._configureTitlesOpen = false;
    this._translations = useT9n({ name: "solution-deployed-card", blocking: true });
    this._configContextConsumer = useContextConsumer({
      context: configContext,
      subscribe: true,
      callback: async (evt) => {
        if (evt) {
          this._isOrgAdmin = evt.authentication?.PortalUserSubset?.role === "org_admin" || getUserIsAdmin(evt.authentication);
        }
      }
    });
    this._deleteDialogRef = createRef();
    this._diagramDialogRef = createRef();
    this._isOrgAdmin = false;
    this.deployedCardSelected = createEvent();
  }
  static {
    this.properties = { allowDelete: [5, {}, { type: Boolean }], card: [0, {}, { attribute: false }], deployedDate: 1, description: 1, diagramKey: 1, heading: 1, itemId: 1, owner: 1, thumbnail: 1, updateAvailable: [5, {}, { type: Boolean }], templateInfos: [0, {}, { attribute: false }], _isDeleteOpen: [16, {}, { state: true }], _isDiagramOpen: [16, {}, { state: true }], templateInfoGraph: [16, {}, { state: true }], _configureTitlesOpen: [16, {}, { state: true }], _translations: [16, {}, { state: true }] };
  }
  static {
    this.styles = styles;
  }
  get _telemetry() {
    return this._configContextConsumer.value?.telemetrySession;
  }
  async renderDeleteDialog() {
    this._isDeleteOpen = true;
    this._renderDeleteDialog();
    return this._deleteDialogRef.value;
  }
  async renderDiagramDialog(evt) {
    await this._viewDiagram(evt);
    await this._renderDiagramDialog();
    return this._diagramDialogRef.value;
  }
  async getTemplates() {
    return this._processTemplates(this.card);
  }
  willUpdate(changedProperties) {
    if (changedProperties.has("card")) {
      void this._processTemplates(this.card).then((templates) => {
        this.templateInfos = templates;
      });
    }
  }
  render() {
    return html`<calcite-card .label=${this.description} @click=${this._cardSelected}>${this._getImage()}${this._getHeader()}<p class="font-color-text-2 font-line-height font-size-size--1" slot=description>${this.description}</p><div class="width-full display-flex flex-direction-column" slot=footer-start><div class="padding-bottom-1-2">${this.owner !== "" && this._getOwnerLabel() || ""}${this._getDeployedDate()}</div>${this._getConfigureButton()}</div></calcite-card>${this._renderDeleteDialog()}${this._renderDiagramDialog()}${this._renderConfigureTitlesDialog()}`;
  }
  _getImage() {
    const userSession = this._configContextConsumer.value?.userSession;
    return html`<div class="card-image-wrap" slot=thumbnail><img alt=${this.heading ?? nothing} class="thumbnail card-image" src=${`${this.thumbnail}&token=${userSession?.token}`}><div class="hover-text">${this._translations.openSolution}</div></div>`;
  }
  _getHeader() {
    return html`<div class="display-flex justify-content-space-between header-line-height" slot=heading><calcite-label layout=inline-space-between scale=l>${this.heading}</calcite-label></div>`;
  }
  _getOwnerLabel() {
    return html`<calcite-label class="font-weight-400 padding-end-1-2" layout=inline scale=s>${`${this._translations.owner}:`}<calcite-link class="font-weight-normal" @click=${this._openUserProfile}>${this.owner}</calcite-link></calcite-label>`;
  }
  _getDeployedDate() {
    return html`<div class="display-flex align-items-center"><div class="padding-end-1-2"><svg height=16px viewBox="0 0 32 32" width=16px xmlns=http://www.w3.org/2000/svg>${svg`<path class="svg-color" d="M29.963 7.672a1.586 1.586 0 0 0-1.584-1.585h-5.274a.187.187 0 0 1-.188-.187V3.977A2 2 0 0 0 20.825 2h-9.672A2.095 2.095 0 0 0 9.06 4.093V5.9a.187.187 0 0 1-.187.187H3.598a1.586 1.586 0 0 0-1.584 1.585v4.016a.281.281 0 0 0 .281.28H4.9l.014-.013V9.153a.177.177 0 0 1 .177-.177h21.46a.456.456 0 0 1 .449.45v13.742A1.832 1.832 0 0 1 25.168 25h-8.892a.568.568 0 0 1-.534-.373 3.98 3.98 0 0 0-7.6.373H5.657a.757.757 0 0 1-.757-.757v-3.055A.188.188 0 0 0 4.714 21H2.028l-.014.014v4.58a2.35 2.35 0 0 0 2.347 2.346h4.161a3.963 3.963 0 0 0 6.8.256.569.569 0 0 1 .475-.256h12.065a2.102 2.102 0 0 0 2.101-2.101zM21 5.625a.375.375 0 0 1-.375.375h-9.25A.375.375 0 0 1 11 5.625V4.45a.456.456 0 0 1 .45-.45h9.1a.456.456 0 0 1 .45.45zM12 28a2 2 0 1 1 2-2 2 2 0 0 1-2 2z" /><path class="svg-color" d="M13.273 17.994a.57.57 0 0 1 .479.262A3.73 3.73 0 0 0 17 20a3.74 3.74 0 0 0 3.403-2.006h3.41a.188.188 0 0 0 .187-.188v-2.589a.187.187 0 0 0-.188-.188H20.8A3.8 3.8 0 0 0 17 12a4.058 4.058 0 0 0-3.69 2.647.568.568 0 0 1-.537.383H1.093a.094.094 0 0 0-.093.093V17.9a.094.094 0 0 0 .094.094zM17 13.9a2.1 2.1 0 1 1-2.1 2.1 2.1 2.1 0 0 1 2.1-2.1z" />`}</svg></div><calcite-label class="deployed-label-override" scale=s>${this._translations.deployedDate.replace("{{date}}", this.deployedDate)}</calcite-label></div>`;
  }
  _getConfigureButton() {
    const userName = this._configContextConsumer.value?.userSession?.username;
    const canEditTitles = this.card?.owner === userName || this._isOrgAdmin;
    const editTitlesTooltipClass = canEditTitles ? "display-none" : "";
    return html`<calcite-split-button appearance=outline aria-label=${this._translations.openSolution ?? nothing} dropdown-label=${this._translations.moreActions ?? nothing} kind=neutral @calciteSplitButtonPrimaryClick=${this._cardSelected} @click=${(evt) => evt.stopPropagation()} overlay-positioning=fixed primary-text=${this._translations.openSolution ?? nothing} width=full><calcite-dropdown-group selection-mode=none><calcite-dropdown-item icon-start=model @click=${this._viewDiagram}>${this._translations.viewDiagram}</calcite-dropdown-item><calcite-dropdown-item icon-start=file-text @click=${this._viewDocumentation}>${this._translations.documentation}</calcite-dropdown-item><calcite-dropdown-item icon-start=information @click=${this._viewItemDetails}>${this._translations.viewItemDetails}</calcite-dropdown-item><calcite-dropdown-item .disabled=${!canEditTitles} icon-start=edit-attributes id=solution-configure-titles-dropdown @click=${() => {
      this._configureTitlesOpen = true;
    }}>${this._translations.renameItems}</calcite-dropdown-item>${this.allowDelete && html`<calcite-dropdown-item icon-start=trash @click=${this._deleteSolution}>${this._translations.deleteSolution}</calcite-dropdown-item>` || ""}</calcite-dropdown-group><calcite-tooltip class=${safeClassMap(editTitlesTooltipClass)} overlay-positioning=fixed reference-element=solution-configure-titles-dropdown><span>${this._translations.mustOwnSolution}</span></calcite-tooltip></calcite-split-button>`;
  }
  _renderDeleteDialog() {
    return this._isDeleteOpen ? html`<solution-delete-dialog .card=${this.card} @solutionDeleteDialogOpen=${(_evt) => {
      this._isDeleteOpen = _evt.detail;
    }} .open=${this._isDeleteOpen} source="Card Dropdown" ${ref(this._deleteDialogRef)}></solution-delete-dialog>` : "";
  }
  _renderDiagramDialog() {
    return this._isDiagramOpen ? html`<calcite-dialog class="dialog-y-size dialog-x-size panel-bg-color" .heading=${this._translations.diagramTitle.replace("{{solution}}", this.card?.title ?? "")} id=${this._translations.diagramTitle.replace("{{solution}}", this.card?.title ?? "") ?? nothing} modal .open=${this._isDiagramOpen} @calciteDialogClose=${() => {
      this._isDiagramOpen = false;
    }} outside-close-disabled scale=m width=l ${ref(this._diagramDialogRef)}><solution-item-diagram .diagramKey=${this.diagramKey} .templateInfoGraph=${this.templateInfoGraph} .typeKeywords=${this.card?.typeKeywords}></solution-item-diagram></calcite-dialog>` : "";
  }
  _renderConfigureTitlesDialog() {
    return this._configureTitlesOpen ? html`<solution-configure-titles .card=${this.card} @solutionConfigureTitlesBeforeClose=${async () => {
      void this._processTemplates(this.card).then((templates) => {
        this.templateInfos = templates;
      });
      this._configureTitlesOpen = false;
    }} @solutionItemsTitlesChanged=${async () => {
      void this._processTemplates(this.card).then((templates) => {
        this.templateInfos = templates;
      });
    }} .open=${this._configureTitlesOpen} source="Card Dropdown" .templateInfos=${this.templateInfos}></solution-configure-titles>` : "";
  }
  _cardSelected() {
    this.deployedCardSelected.emit({
      card: this.card,
      cardRef: this.el
    });
  }
  async _viewDiagram(evt) {
    evt.stopPropagation();
    if (this.card) {
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.DEPLOYMENTS,
        action: "View Diagram",
        dimensions: [
          this.card.title || "",
          this.card.deployCommonId || "",
          this.card.deployVersion || "",
          "Card Dropdown"
        ]
      });
      this.templateInfoGraph = await this._processTemplates(this.card);
      this._isDiagramOpen = true;
    }
  }
  _viewDocumentation(evt) {
    evt.stopPropagation();
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.DEPLOYMENTS,
      action: "Open Help",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || "",
        "Card Dropdown"
      ]
    });
    window.open(this.card.learnMoreUrl, "_blank");
  }
  _viewItemDetails(evt) {
    evt.stopPropagation();
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.DEPLOYMENTS,
      action: "Open Item Details",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || "",
        "Card Dropdown"
      ]
    });
    window.open(this.card.itemUrl, "_blank");
  }
  _deleteSolution(_evt) {
    _evt.stopPropagation();
    this._isDeleteOpen = true;
  }
  _openUserProfile(evt) {
    evt.stopPropagation();
    const orgUrl = this._configContextConsumer.value?.authentication?.PortalSubset?.orgUrl;
    if (orgUrl) {
      window.open(`${orgUrl}/home/user.html?user=${this.owner}`, "_blank");
    }
  }
  async _processTemplates(card) {
    return await prepareDataForSolutionDisplay(card.id, this._configContextConsumer.value.userSession);
  }
}
customElement("solution-deployed-card", SolutionDeployedCard);
const BATCH_EDIT_LIMIT = 500;
const EIndustry = {
  AEC: "Architecture, Engineering, and Construction (AEC)",
  AIRPORTPORTRAIL: "Airports, Ports, and Rails",
  BUSINESS: "Business",
  CONSERVATION: "Conservation",
  DEFENSE: "Defense",
  FACILITIES: "Facilities",
  HEALTHANDHUMANSERVICES: "Health and Human Services",
  PIPELINE: "Pipeline",
  PUBLICSAFETY: "Public Safety",
  RENEWABLES: "Renewables",
  STATEANDLOCALGOVERNMENT: "State and Local Government",
  TELECOMMUNICATIONS: "Telecommunications",
  UTILITIES: "Utilities"
};
const EDomain = {
  AIRPORT: "Airports",
  AGRICULTURE: "Agriculture",
  ASSESSMENTANDTAXATION: "Assessment and Taxation",
  DISTRICTENERGY: "District Energy",
  ELECTIONS: "Elections",
  ELECTRIC: "Electric",
  EMERGENCYMANAGEMENT: "Emergency Management",
  ENVIRONMENTANDNATURALRESOURCES: "Environment and Natural Resources",
  FIRESERVICE: "Fire Service",
  FISHANDWILDLIFE: "Fish and Wildlife",
  GAS: "Gas",
  HEALTHANDHUMANSERVICES: "Health and Human Services",
  LAWENFORCEMENT: "Law Enforcement",
  NATURALRESOURCES: "Natural Resources",
  PARKS: "Parks",
  PLANNINGANDDEVELOPMENT: "Planning and Development",
  PROTECTEDAREAS: "Protected Areas",
  PUBLICWORKS: "Public Works",
  SEWER: "Sewer",
  STORMWATER: "Stormwater",
  TELECOMMUNICATIONS: "Telecommunications",
  TRANSPORTATION: "Transportation",
  WATER: "Water Distribution"
};
var ECustomPrivileges = /* @__PURE__ */ ((ECustomPrivileges2) => {
  ECustomPrivileges2["HUBPREMIUM"] = "solutions:hubPremium";
  ECustomPrivileges2["NOTEBOOK"] = "solutions:notebook";
  ECustomPrivileges2["TRACKINGBASE"] = "solutions:locationtracking";
  ECustomPrivileges2["TRACKING"] = "solutions:locationtracking:tracking";
  ECustomPrivileges2["TRACKINGADMIN"] = "solutions:locationtracking:admin";
  ECustomPrivileges2["TRACKINGADMINANDTRACKING"] = "solutions:locationtracking:admin:tracking";
  ECustomPrivileges2["VELOCITY"] = "solutions:velocity";
  ECustomPrivileges2["WORKFLOW"] = "solutions:workflowManager";
  return ECustomPrivileges2;
})(ECustomPrivileges || {});
var EPrivileges = /* @__PURE__ */ ((EPrivileges2) => {
  EPrivileges2["VELOCITYBIGDATA"] = "portal:publisher:publishBigDataAnalytics";
  EPrivileges2["VELOCITYFEEDS"] = "portal:publisher:publishFeeds";
  EPrivileges2["VELOCITYREALTIME"] = "portal:publisher:publishRealTimeAnalytics";
  return EPrivileges2;
})(EPrivileges || {});
const BASE_DEPLOYED_TERMS = '((typekeywords:Solution,Deployed,"ArcGIS Solution") OR ((typekeywords:Solution,Deployed) AND (created:[1577862000000 TO 1622576880000])))';
const BASE_SOLUTIONS_TERMS = "(typekeywords:Solution,Template)";
const PORTAL_ADD_MEMBERS_TO_GROUP = "portal:user:addExternalMembersToGroup";
const PORTAL_CREATE_ITEM = "portal:user:createItem";
const PORTAL_CREATE_GROUP = "portal:user:createGroup";
const PORTAL_PUBLISH_BD_ANALYTICS = "portal:publisher:publishBigDataAnalytics";
const PORTAL_PUBLISH_FEATURES = "portal:publisher:publishFeatures";
const PORTAL_PUBLISH_FEEDS = "portal:publisher:publishFeeds";
const PORTAL_PUBLISH_GP = "portal:publisher:publishServerGPServices";
const PORTAL_PUBLISH_RT_ANALYTICS = "portal:publisher:publishRealTimeAnalytics";
const PORTAL_SHARE_TO_GROUP = "portal:user:shareToGroup";
const SOLUTIONS_HUB_PREMIUM = "solutions:hubPremium";
const SOLUTIONS_NOTEBOOK = "solutions:notebook";
const SOLUTIONS_TRACKING_ADMIN_TRACKING = "solutions:locationtracking:admin:tracking";
const SOLUTIONS_TRACKING = "solutions:locationtracking:tracking";
const SOLUTIONS_TRACKING_ADMIN = "solutions:locationtracking:admin";
const SOLUTIONS_VELOCITY = "solutions:velocity";
const SOLUTIONS_WORKFLOW_MANAGER = "solutions:workflowManager";
const ITEM_TITLE_LENGTH = 250;
const TELEMETRY_CATEGORY = {
  SOLUTION_DETAILS: "Solution Details",
  GLOBAL_NAVIGATION: "Global Nav",
  ALL_SOLUTIONS: "Solutions",
  DEPLOYMENTS: "Deployments",
  ASSISTANT: "Assistant",
  RESOURCES: "Resources"
};
const EOfferType = {
  BOTH: "New,Suggested",
  NEW: "New",
  SUGGESTED: "Suggested"
};
const ESortField = {
  NEW: "new",
  NUMVIEWS: "views",
  RELEVANCE: "relevance",
  SUGGESTED: "suggested",
  TITLE: "title",
  UPDATED: "updated"
};
const ESignInParam = {
  DEPLOY: "deploy",
  AIOPEN: "aiOpen"
};
export {
  SolutionDeployedCard as A,
  BASE_DEPLOYED_TERMS as B,
  ECustomPrivileges as E,
  ITEM_TITLE_LENGTH as I,
  PORTAL_ADD_MEMBERS_TO_GROUP as P,
  SOLUTIONS_HUB_PREMIUM as S,
  TELEMETRY_CATEGORY as T,
  BASE_SOLUTIONS_TERMS as a,
  BATCH_EDIT_LIMIT as b,
  EDomain as c,
  EIndustry as d,
  EOfferType as e,
  EPrivileges as f,
  ESignInParam as g,
  ESortField as h,
  PORTAL_CREATE_GROUP as i,
  PORTAL_CREATE_ITEM as j,
  PORTAL_PUBLISH_BD_ANALYTICS as k,
  PORTAL_PUBLISH_FEATURES as l,
  PORTAL_PUBLISH_FEEDS as m,
  PORTAL_PUBLISH_GP as n,
  PORTAL_PUBLISH_RT_ANALYTICS as o,
  PORTAL_SHARE_TO_GROUP as p,
  SOLUTIONS_NOTEBOOK as q,
  SOLUTIONS_TRACKING as r,
  SOLUTIONS_TRACKING_ADMIN as s,
  SOLUTIONS_TRACKING_ADMIN_TRACKING as t,
  SOLUTIONS_VELOCITY as u,
  SOLUTIONS_WORKFLOW_MANAGER as v,
  prepareDataForSolutionDisplay as w,
  getUserIsAdmin as x,
  getRequiredSolutionPrivileges as y,
  getPrivilegeMessages as z
};
