/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as customElement } from "./runtime.js";
import { u as useT9n } from "./useT9n.js";
import { LitElement, createEvent, nothing } from "@arcgis/lumina";
import { css, html, svg } from "lit";
import { A as Auth } from "./Auth.js";
import { n as getEnvironment } from "./helpers.js";
import { T as TELEMETRY_CATEGORY } from "./interfaces.js";
import { createRef, ref } from "lit-html/directives/ref.js";
import { UserSession } from "@esri/solution-common";
import { i as isMobileContext } from "./deployAppContexts.js";
import { useContextConsumer } from "@arcgis/lumina/context";
class TelemetryManager {
  constructor() {
    this._telemetryInstance = void 0;
    this._logTelemetryEvents = false;
  }
  /**
   * Get the current telemetry instance
   */
  getInstance() {
    return this._telemetryInstance;
  }
  /**
   * Check if telemetry is enabled
   */
  isEnabled() {
    return this._logTelemetryEvents;
  }
  /**
   * Set the telemetry instance
   */
  setInstance(instance) {
    this._telemetryInstance = instance;
  }
  /**
   * Enable or disable telemetry event logging
   */
  setEnabled(enabled) {
    this._logTelemetryEvents = enabled;
  }
  /**
   * Map dimensions array to numbered dimension fields (dimension1-20)
   */
  _mapDimensions(dimensions) {
    const mapped = {};
    if (!dimensions) return mapped;
    dimensions.slice(0, 20).forEach((value, index) => {
      const key = `dimension${index + 1}`;
      mapped[key] = value;
    });
    return mapped;
  }
  /**
   * Map metrics array to numbered metric fields (metric1-20)
   */
  _mapMetrics(metrics) {
    const mapped = {};
    if (!metrics) return mapped;
    metrics.slice(0, 20).forEach((value, index) => {
      const key = `metric${index + 1}`;
      mapped[key] = value;
    });
    return mapped;
  }
  /**
   * Log an event using the telemetry instance
   *
   * @param options Event logging options
   * @param options.category The event category
   * @param options.action The event action name
   * @param options.label The label for this event (optional, defaults to empty string)
   * @param options.details Additional details to log with the event (optional, defaults to empty string)
   * @param options.dimensions Optional dimensions array (maps to dimension1-20)
   * @param options.metrics Optional metrics array (maps to metric1-20)
   */
  logEvent(options) {
    if (this._logTelemetryEvents && this._telemetryInstance) {
      const { category, action, dimensions, metrics, label = "", details = "" } = options;
      const mappedDimensions = this._mapDimensions(dimensions);
      const mappedMetrics = this._mapMetrics(metrics);
      this._telemetryInstance.logEvent({
        category,
        action,
        label,
        details,
        ...mappedDimensions,
        ...mappedMetrics
      });
    }
  }
  /**
   * Get the telemetry session object for use in configContext
   */
  getTelemetrySession() {
    return {
      instance: this._telemetryInstance,
      logEvent: (options) => this.logEvent(options),
      enabled: this._logTelemetryEvents
    };
  }
  /**
   * Get a disabled telemetry session that is safe to call but does nothing
   * Use this as a default when telemetry is not initialized
   */
  static getDisabledSession() {
    return {
      instance: void 0,
      logEvent: () => {
      },
      // No-op function
      enabled: false
    };
  }
  /**
   * Initialize telemetry with consent manager
   *
   * @param authentication The authentication object
   * @param appConfig The application configuration
   * @returns Promise that resolves to the telemetry session
   */
  async initializeTelemetry(authentication, appConfig) {
    const shouldEnable = TelemetryManager.shouldEnableTelemetry(authentication, appConfig);
    if (!shouldEnable) {
      return this.getTelemetrySession();
    }
    let consentManager = document.querySelector("consent-manager");
    if (!consentManager) {
      const isConsentManagerDefined = customElements.get("consent-manager");
      if (!isConsentManagerDefined) {
        return this.getTelemetrySession();
      }
      consentManager = document.createElement("consent-manager");
      consentManager.portal = authentication.Portal;
      consentManager.measurementIds = appConfig.measurementIds || [];
      consentManager.firstUseVar = appConfig.cookiesFirstUseVar;
      const envConfig = TelemetryManager.getEnvironmentConfig(appConfig, authentication);
      if (envConfig) {
        consentManager.amazonUserPoolID = envConfig?.amazon?.userPoolID;
        consentManager.amazonAppId = envConfig?.amazon?.app?.id;
        consentManager.amazonAppName = appConfig.telemetry?.name;
        consentManager.amazonVersion = appConfig.telemetry?.version;
      }
      const eueiEnabled = authentication.Portal?.eueiEnabled;
      const firstUseValue = localStorage.getItem(consentManager.firstUseVar);
      if (firstUseValue === "true" || eueiEnabled) {
        this.setEnabled(true);
        consentManager.classList.add("display-none");
      }
      document.body.appendChild(consentManager);
      if (!eueiEnabled) {
        window.addEventListener("consentGranted", (response) => {
          const detail = response.detail;
          if (detail?.granted) {
            this.setEnabled(true);
            void this._setInstanceFromConsentManager(consentManager);
          }
        });
      } else {
        await new Promise((resolve) => setTimeout(resolve, 100));
        await this._setInstanceFromConsentManager(consentManager);
      }
    }
    return this.getTelemetrySession();
  }
  /**
   * Set the telemetry instance from consent manager
   *
   * @param consentManager The consent manager element
   */
  async _setInstanceFromConsentManager(consentManager) {
    try {
      const timeoutPromise = new Promise(
        (_, reject) => setTimeout(() => reject(new Error("Timeout waiting for consent-manager instance")), 1e4)
      );
      const instance = await Promise.race([
        consentManager.getInstance(),
        timeoutPromise
      ]);
      this.setInstance(instance);
    } catch (error) {
    }
  }
  /**
   * Determine if telemetry should be enabled based on authentication and config
   *
   * @param authentication The current authentication object
   * @param appConfig The application configuration
   * @returns True if telemetry should be enabled
   */
  static shouldEnableTelemetry(authentication, appConfig) {
    const isEnterprise = authentication?.IsEnterprisePortal;
    const eueiEnabled = authentication?.Portal?.eueiEnabled;
    if (eueiEnabled === false || isEnterprise) {
      return false;
    }
    return !!((appConfig.measurementIds || appConfig.telemetry) && (appConfig.cookiesFirstUseVar || eueiEnabled));
  }
  /**
   * Get the environment-specific telemetry configuration
   *
   * @param appConfig The application configuration
   * @param authentication The current authentication object
   * @returns The telemetry options for the current environment, or undefined
   */
  static getEnvironmentConfig(appConfig, authentication) {
    if (!appConfig.telemetry) return void 0;
    const env = appConfig.forceTrackingEnv || getEnvironment(
      document.location.hostname,
      authentication?.Portal?.portalHostname || ""
    );
    return env && Object.keys(appConfig.telemetry).includes(env) ? appConfig.telemetry[env] : void 0;
  }
}
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.
 */

.esri-global-nav__title {
  margin-block-start: 0;
  position: relative;
  margin-bottom: 0;
  font-size: var(--calcite-font-size-xl);
  font-weight: var(--calcite-font-weight-medium);
  padding-inline-end: var(--calcite-spacing-xxl);
  align-self: center;
}

.esri-global-nav__logo-link {
  color: var(--calcite-color-text-1);
  text-decoration: unset;
  margin-block-start: 0px;
  position: relative;
  margin-bottom: 0px;
  align-self: center;
}

.cursor-pointer {
  cursor: pointer;
}

.side {
  border-right: solid 1px;
  color: var(--calcite-color-text-1);
}

.display-flex {
  display: flex;
}

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

.padding-top-1 {
  padding-top: var(--calcite-spacing-lg);
}

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

.padding-start-1 {
  padding-inline-start: var(--calcite-spacing-lg);
}

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

.margin-start-end-1 {
  margin-inline-start: var(--calcite-spacing-lg);
  margin-inline-end: var(--calcite-spacing-lg);
}

.margin-start-end-1-5 {
  margin-inline-start: var(--calcite-spacing-xxl);
  margin-inline-end: var(--calcite-spacing-xxl);
}

calcite-menu {
  --calcite-color-focus: transparent;
}

calcite-button {
  --calcite-color-focus: transparent;
}

.sign-in {
  display: flex;
  vertical-align: middle;
  align-items: center;
  height: 100%;
}

.height-full {
  height: 100%;
}

.user-label {
  --calcite-label-margin-bottom: 0px;
}

.font-bold {
  font-weight: var(--calcite-font-weight-bold);
}

.font-normal {
  font-weight: var(--calcite-font-weight-normal);
}

.logo-padding {
  padding-inline-start: var(--calcite-spacing-none);
}

@media (max-width: 800px) {
  .logo-padding {
    padding-inline-start: var(--calcite-spacing-lg);
  }
}

.signin-padding {
  padding-inline-end: var(--calcite-spacing-none);
}

@media (max-width: 800px) {
  .signin-padding {
    padding-inline-end: var(--calcite-spacing-lg);
  }
}

calcite-action {
  --calcite-font-size-0: var(--calcite-font-size--1);
  --calcite-internal-action-padding-inline: var(--calcite-spacing-lg);
}

calcite-navigation {
  --calcite-color-border-3: transparent;
}

.border-bottom {
  border-bottom-color: var(--calcite-color-border-1);
  border-bottom-width: var(--calcite-spacing-px);
  border-bottom-style: solid;
}

.border {
  height: var(--calcite-spacing-px);
  border-bottom-color: var(--calcite-color-border-3);
  border-bottom-style: solid;
  border-bottom-width: var(--calcite-border-width-sm);
  box-sizing: border-box;
  position: absolute;
  top: 65px;
  left: 0px;
  width: 100%;
  z-index: 1;
}

.height-65 {
  height: 65px;
}`;
class SolutionsDeployAppNav extends LitElement {
  constructor() {
    super();
    this._isMobile = false;
    this._logoFill = "";
    this._translations = useT9n({ name: "solutions-deploy-app-nav", blocking: true });
    this._activeTab = "all-solutions";
    this._authentication = void 0;
    this._cardType = "details";
    this._dropdownRef = createRef();
    this._dropdownItemAll = createRef();
    this._dropdownItemMy = createRef();
    this._dropdownItemMyContent = createRef();
    this._dropdownItemResources = createRef();
    this._isMobileContextConsumer = useContextConsumer({
      context: isMobileContext,
      subscribe: true,
      callback: (value) => this._isMobile = value
    });
    this._menuRef = createRef();
    this._menuItemAll = createRef();
    this._menuItemMy = createRef();
    this._menuItemResources = createRef();
    this.authInit = createEvent();
    this.navTabSelected = createEvent();
    this.tokenRefreshed = createEvent();
    this.listenOn(window, "deployedCardSelected", this._deployedCardSelected);
    this.listenOn(window, "detailsCardSelected", this._detailsCardSelected);
    this.listenOn(window, "deployAppTabSelected", this._deployAppTabSelected);
    this.listenOn(window, "popstate", this._handleUrlChange);
  }
  static {
    this.properties = { appConfig: 1, initTab: 1, _subNavigationCard: [16, {}, { state: true }], _isMobile: [16, {}, { state: true }], _logoFill: [16, {}, { state: true }], _translations: [16, {}, { state: true }] };
  }
  static {
    this.styles = styles;
  }
  get _telemetry() {
    return this._config?.telemetrySession;
  }
  clearMenuItems() {
    if (this._isMobile) {
      this._dropdownItemAll.value.selected = false;
      if (this._authentication?.IsSignedIn) {
        this._dropdownItemMy.value.selected = false;
      }
      this._dropdownItemResources.value.selected = false;
    } else {
      this._menuItemAll.value.active = false;
      if (this._authentication?.IsSignedIn) {
        this._menuItemMy.value.active = false;
      }
      this._menuItemResources.value.active = false;
    }
  }
  activateMenuItem(tab, emit = false) {
    let ref2;
    let disableRefs;
    switch (tab) {
      case "all-solutions":
        ref2 = this._isMobile ? this._dropdownItemAll : this._menuItemAll;
        disableRefs = this._isMobile ? [
          this._dropdownItemMy,
          this._dropdownItemResources
        ] : [
          this._menuItemMy,
          this._menuItemResources
        ];
        break;
      case "deployments":
        ref2 = this._isMobile ? this._dropdownItemMy : this._menuItemMy;
        disableRefs = this._isMobile ? [
          this._dropdownItemAll,
          this._dropdownItemResources
        ] : [
          this._menuItemAll,
          this._menuItemResources
        ];
        break;
      case "resources":
        ref2 = this._isMobile ? this._dropdownItemResources : this._menuItemResources;
        disableRefs = this._isMobile ? [
          this._dropdownItemAll,
          this._dropdownItemMy
        ] : [
          this._menuItemAll,
          this._menuItemMy
        ];
        break;
      case "my-content":
        if (this._isMobile) {
          ref2 = this._dropdownItemMyContent;
          disableRefs = [
            this._dropdownItemAll,
            this._dropdownItemMy,
            this._dropdownItemResources
          ];
        }
        break;
    }
    if (ref2 && disableRefs) {
      this._handleMenuClick(tab, ref2, disableRefs, emit);
    }
  }
  async connectedCallback() {
    super.connectedCallback();
    const userSession = new UserSession({
      username: "",
      password: ""
    });
    this._userSession = userSession;
  }
  async load() {
    const colorScheme = window.matchMedia("(prefers-color-scheme: dark)");
    colorScheme.addEventListener("change", (e) => this._logoFill = this._getLogoFill(e.matches));
    this._logoFill = this._getLogoFill(colorScheme.matches);
    if (this._isMobileContextConsumer.value) {
      this._isMobile = this._isMobileContextConsumer.value;
    }
    const locale = this.appConfig.locale || "en";
    const orgUrl = this.appConfig.authentication?.PortalSubset?.orgUrl || this.appConfig.orgURL || this.appConfig.portalURL;
    const portalUrl = this.appConfig.authentication?.PortalUrl || this.appConfig.portalURL;
    const primarySolutionsGroupId = this.appConfig.primarySolutionsGroupId;
    console.log(`orgUrl: ${orgUrl}`);
    console.log(`portalUrl: ${portalUrl}`);
    if (!this._authentication) {
      if (this.appConfig.authentication) {
        this._authentication = this.appConfig.authentication;
      } else {
        this._authentication = new Auth(this.appConfig.appId, this.appConfig.portalURL, this.appConfig.locale);
        await this._authentication.initialize();
      }
    }
    if (this._authentication.RestUserSession) {
      this._userSession = this._authentication.RestUserSession;
    }
    if (this.initTab) {
      this._activeTab = this.initTab;
      this.initTab = void 0;
    }
    this._setRefreshInterval();
    this._config = {
      anonAgolSession: void 0,
      agolPortalUrl: "",
      allCards: [],
      appId: this.appConfig.appId,
      authentication: this._authentication,
      agoBasedEnterpriseSolutionsGroupId: this.appConfig.agoBasedEnterpriseSolutionsGroupId,
      diagramKey: this.appConfig.diagramKey,
      isEnterprise: this.appConfig.isEnterprise,
      locale,
      orgUrl,
      portalURL: portalUrl,
      primarySolutionsGroupId,
      userSession: this._userSession,
      telemetrySession: TelemetryManager.getDisabledSession(),
      // Will be initialized after auth
      cookiesFirstUseVar: this.appConfig.cookiesFirstUseVar,
      trackingEnabled: this.appConfig.trackingEnabled,
      forceTrackingEnv: this.appConfig.forceTrackingEnv,
      telemetry: this.appConfig.telemetry,
      measurementIds: this.appConfig.measurementIds
    };
    this.authInit.emit(this._config);
    this._portal = await this._userSession?.getPortal();
  }
  render() {
    return html`<div><calcite-navigation>${this._getHeading()}${this._isMobile ? this._getDropdown() : this._getMenu()}${this._isMobile ? "" : this._getSignInOut()}</calcite-navigation><div class="border" slot=header></div>${this._getSubHeading()}</div>`;
  }
  updated(changes) {
    if (changes.has("_isMobile")) {
      this.activateMenuItem(this._activeTab, true);
    }
  }
  _getSignInOut() {
    return html`<div slot=user>${this._authentication?.IsSignedIn ? this._getUserAvatar() : html`<calcite-button appearance=transparent class="sign-in" kind=neutral scale=l @click=${this._handleSignIn}>${this._translations.signIn}</calcite-button>`}</div>`;
  }
  _getDropdown() {
    const signInOut = this._authentication?.IsSignedIn ? this._translations.signOut : this._translations.signIn;
    return html`<calcite-dropdown overlay-positioning=fixed slot=content-end width=m ${ref(this._dropdownRef)}><calcite-button appearance=transparent icon-start=hamburger kind=neutral slot=trigger scale=l></calcite-button><calcite-dropdown-group><calcite-dropdown-item @click=${() => this._handleMenuClick("all-solutions", this._dropdownItemAll, [this._dropdownItemMy, this._dropdownItemResources, this._dropdownItemMyContent], true)} ${ref(this._dropdownItemAll)}>${this._translations.allSolutions}</calcite-dropdown-item><calcite-dropdown-item @click=${() => this._handleMenuClick("deployments", this._dropdownItemMy, [this._dropdownItemAll, this._dropdownItemResources, this._dropdownItemMyContent], true)} ${ref(this._dropdownItemMy)}>${this._translations.myDeployments}</calcite-dropdown-item><calcite-dropdown-item @click=${() => this._handleMenuClick("resources", this._dropdownItemResources, [this._dropdownItemAll, this._dropdownItemMy, this._dropdownItemMyContent], true)} ${ref(this._dropdownItemResources)}>${this._translations.solutionResources}</calcite-dropdown-item><calcite-dropdown-item @click=${() => {
      const clickRef = this._activeTab === "all-solutions" ? this._dropdownItemAll : this._activeTab === "deployments" ? this._dropdownItemMy : this._activeTab === "resources" ? this._dropdownItemResources : void 0;
      setTimeout(() => this._handleMenuClick("my-content", clickRef, [this._dropdownItemAll, this._dropdownItemMy, this._dropdownItemResources, this._dropdownItemMyContent], false), 10);
    }} ${ref(this._dropdownItemMyContent)}>${this._translations.myContent}</calcite-dropdown-item><calcite-dropdown-item @click=${(evt) => {
      if (this._authentication?.IsSignedIn) {
        this._signOut();
      } else {
        this._handleSignIn(evt);
      }
    }}>${signInOut}</calcite-dropdown-item></calcite-dropdown-group></calcite-dropdown>`;
  }
  _getMenu() {
    return html`<calcite-menu label slot=content-start ${ref(this._menuRef)}><calcite-menu-item label @click=${() => this._handleMenuClick("all-solutions", this._menuItemAll, [this._menuItemMy, this._menuItemResources], true)} .text=${this._translations.allSolutions} ${ref(this._menuItemAll)}></calcite-menu-item><calcite-menu-item label @click=${() => this._handleMenuClick("deployments", this._menuItemMy, [this._menuItemAll, this._menuItemResources], true)} .text=${this._translations.myDeployments} ${ref(this._menuItemMy)}></calcite-menu-item><calcite-menu-item label @click=${() => this._handleMenuClick("resources", this._menuItemResources, [this._menuItemAll, this._menuItemMy], true)} .text=${this._translations.solutionResources} ${ref(this._menuItemResources)}></calcite-menu-item></calcite-menu>`;
  }
  _setRefreshInterval() {
  }
  _getHeading() {
    return html`<div class="align-self-center display-flex cursor-pointer logo-padding" slot=logo><a aria-label=${this._translations.linkToEsriHomePage ?? nothing} class="esri-global-nav__logo-link" href=https://www.esri.com @click=${() => this._logLinkClickTelemetry("Esri")} rel=noopener target=_blank title=${this._translations.linkToEsriHomePage ?? nothing}><svg height=30 viewBox="0 0 84 30" width=84 xmlns=http://www.w3.org/2000/svg>${svg`<path fill=${this._logoFill ?? nothing} d="M77.277.5c-1.48 0-2.554 1.175-2.554 2.488 0 1.314 1.074 2.49 2.554 2.49 1.48 0 2.622-1.071 2.622-2.49C79.899 1.572 78.756.5 77.277.5zm-1.913 23.426h3.891V8.353h-3.891v15.573zM40.515 7.965c-4.702 0-8.465 3.275-8.465 8.174 0 4.898 3.763 8.177 8.465 8.177 2.146 0 4.165-.667 5.852-2.31l-2.457-2.457c-.916.964-2.093 1.651-3.78 1.651-2.175 0-3.927-1.397-4.188-3.698h11.875v-1.07c0-5.42-2.95-8.467-7.302-8.467zm-4.573 6.617c.293-2.24 1.721-3.7 4.023-3.7 2.434 0 3.926 1.43 3.96 3.7h-7.983zm17.305-1.849c0-1.169 1.233-1.655 2.273-1.655 1.32 0 2.292.547 3.037 1.577l2.476-2.474c-1.282-1.6-3.407-2.216-5.418-2.216-3.147 0-6.262 1.555-6.262 5.028 0 5.938 8.403 3.406 8.403 6.617 0 1.233-1.46 1.784-2.595 1.784-1.65 0-2.687-.806-3.69-1.905l-2.515 2.514c1.58 1.711 3.62 2.313 5.978 2.313 3.179 0 6.717-1.299 6.717-4.998 0-6.067-8.404-3.795-8.404-6.585zm14.15-1.916h-.062V8.353h-3.892v15.573h3.892v-8.34c0-.842.518-3.925 4.185-3.925.564 0 1.127.112 1.718.253l.152-3.726c-.45-.127-.901-.223-1.382-.223-2.046 0-3.766 1.07-4.61 2.852zM14.683 2.766c-1.217-.037-1.932.12-2.651.26-.216-.056-.62.003-.643.472 0 .252.08.447.24.562.159.114 1.493 1.1 2.473 2.142-.47.052-.98.138-1.504.246-.585-1.264-2.465-.114-3.714-.064-.146.006-.286.025-.431.035-.137-1.056-.235-2.15-.21-2.92 1.618-.917 4.748-1.593 6.874-1.626l.373-.01c.312-.003.337-.251.043-.291-2.641-.361-4.929.173-7.279 1.145C5.808 3.748 2.696 6.12.8 10.596c-.444 1.247-2.219 7.195.935 12.3 2.56 4.142 5.855 6.113 9.887 6.676 4.024.561 6.207.075 8.752-1.055 5.951-2.642 10.496-12.559 5.95-19.747-1.794-3.319-6.495-6.229-11.641-6.004zm-2.259 4.647a17.754 17.754 0 0 1 2.362-.368 15.741 15.741 0 0 1 1.748 2.54c-.805.39-1.878.688-2.315 1.312-.181.26-.226.613-.232.995a23.59 23.59 0 0 0-3.877 1.286c-.453-1.332-.85-2.66-1.124-3.842 1.296-1.237 2.813-1.438 3.438-1.923zm6.61 15.88c-.354.038-.706.083-1.016.13-.77.121-1.762.379-2.685.723-.53-.843-1.95-2.891-2.667-4.437 1.442-.709 3.457-1.303 5.775-1.444.19.33.4.66.69.956.757.774-.44 1.883-.096 4.072zm-8.603-9.14c1.12-.53 2.3-.968 3.56-1.286-.008.333-.045.649-.182.903-.196.366-.106 1.428.134 1.775.755 1.099 2.008.488 2.951.883.433.181.721.482.964.84-1.974.124-3.91.584-5.706 1.41-.923-1.96-1.72-4.524-1.72-4.524zm.832 4.938c-.07.033-.145.074-.217.11a40.803 40.803 0 0 0-3.256-.78c-.995-.204-1.031-.15-2.151.175-.16.046-.313.088-.462.133a36.17 36.17 0 0 1-.445-1.202c1.436-1.106 2.884-2.034 4.821-2.985.5 1.491 1.215 3.483 1.71 4.549zm.768 4.528c.293-.765.521-1.331.605-1.89.569.958 1.248 2 1.774 2.815-.819.397-1.772 1.01-2.672 1.685.062-1.037.083-2.064.293-2.61zm5.334-14.636c-.01.014-.028.026-.04.04a23.057 23.057 0 0 0-1.376-2.111c1.007-.061 2.246-.008 3.374.108-1.014.363-1.461 1.254-1.958 1.963zm-9.028 1.094c.019-.026.039-.047.057-.072.234 1.182.513 2.16.886 3.518-1.402.618-3.881 2.148-4.976 2.972-.198-.502-.404-1.214-.589-1.946.249-.737.758-1.254 1.476-1.325 1.228-.123 2.28-1.95 3.146-3.147zm-5.41-1.784C4.24 6.455 6.023 4.666 7.65 3.773c-.016.4.086 1.567.218 2.693-.57.057-1.134.128-1.692.211a12.084 12.084 0 0 0-3.115 4.088c-.117-1.054-.178-1.933-.133-2.472zM2.07 9.731s.062 1.06.113 1.833c0 0-.781.886-1.18 1.59.159-1.443.498-2.187 1.067-3.423zm7.664 18.356C5.688 26.82 2.69 23.41 1.62 19.834a17.475 17.475 0 0 1-.651-6.473c.056.01.186.072.38.017.135-.093.616-.43.957-.728l.018.131c-.23.87-.371 1.775-.4 2.71.37.39.804 1.038 1.286 1.707-.31.23-.905.641-1.045.741-.41.292-.406.753-.114 1.015.161.144.492.084.613-.01.358-.285.656-.513 1.066-.77.15.393.292.748.43 1.086-.175.188-.3.436-.342.798-.135 1.172.979 2.092 1.918 2.36.035.01.06.014.094.023.05.076.095.147.148.224-.487.378-.82.765-1.049 1.063-.132.172-.28.43-.16.481.123.05.535 0 .719-.034.466-.09.826-.606 1.148-.796.387.534 1.017 1.22 1.672 1.88.029.12.055.246.088.351.125.403.293.804.495 1.196.471.22.962.402 1.464.561a8.344 8.344 0 0 0-.622.72zm.989.313c.155-.203.312-.454.505-.626.468.31.969.665 1.368.894-.615-.07-1.337-.085-1.873-.268zm3.113.31s-1.604-1.062-2.009-1.471c.803-.667 2.102-1.459 3.128-1.889.402.63 1.727 2.507 2.258 3.112-.963.168-2.31.294-3.377.248zM20.54 27.2c-.286.189-1.664.814-2.204.988a23.43 23.43 0 0 1-2.44-3.202c.844-.354 2.143-.67 3.346-.82.109.342.25.704.444 1.094.19.382.411.662.649.853.085-.053.164-.115.248-.17-.006.42-.018.846-.043 1.257zm-.33-21.477c-.27-.172-.607-.108-.467.193.053.117.259.314.427.512-.986-.272-3.608-.479-4.856-.364-.815-.916-1.744-2.028-2.861-2.765 4.999-.311 9.49 1.756 11.473 4.186-.661-.344-2.087-.834-2.667-.963-.313-.319-.708-.58-1.05-.8zm1.094 21.065c.023-.407.04-.922.053-1.396.487-.378.946-.79 1.37-1.238.547.063 1.094.156 1.427.24-.74.936-1.762 1.716-2.85 2.394zm3.825-3.724c-.12.253-.428.688-.633.894-.312-.126-.781-.258-1.272-.375.078-.094.163-.182.24-.279.268-1.796-.338-2.37.42-4.014l.172-.371c.418.118.812.247 1.153.386.043.616.04 2.728-.08 3.759zm-.708-4.917c.196-.407.412-.84.645-1.27.061.547.105 1.08.131 1.563a9.256 9.256 0 0 0-.776-.293zm2.218 1.126l-.194.756c-.137.515-.593 1.732-.832 2.223.091-.663.171-2.384.148-2.73.16.049.502-.147.559-.341.057-.195-.564-.495-.564-.495a20.742 20.742 0 0 0-.172-2.7c.142-.23.286-.452.434-.655a12.082 12.082 0 0 0-.186-1.575c.125.041.24.074.323.075.283.004.282-.19.192-.298-.058-.07-.328-.238-.643-.42a12.02 12.02 0 0 0-2.78-5.32c.533.202 1.214.48 1.754.774.41.516 1.585 1.675 2.212 4.92.564 2.922-.06 5.143-.251 5.786zM80.886 8.597v-.24h1.218v.24h-.468v1.191h-.283V8.597h-.467zm1.87-.24l.365 1.025.368-1.024h.406v1.43h-.262V8.634l-.396 1.154h-.229l-.4-1.154v1.154h-.261v-1.43h.409z" />`}</svg></a><div class="side margin-start-end-1-5" slot=logo></div><div class="esri-global-nav__title"><a aria-label=${this._translations.linkToArcGISSolutionsHomePage ?? nothing} class="esri-global-nav__logo-link" href=https://www.esri.com/en-us/arcgis/products/arcgis-solutions/overview @click=${() => this._logLinkClickTelemetry("ArcGIS Solutions")} rel=noopener target=_blank title=${this._translations.linkToArcGISSolutionsHomePage ?? nothing}>${this._translations.arcgisSolutions}</a></div></div>`;
  }
  _getSubHeading() {
    const typeString = this._cardType === "deployed" ? this._translations.myDeployments : this._translations.allSolutions;
    return this._subNavigationCard ? html`<calcite-navigation class="height-65" slot=navigation-secondary><calcite-menu class="height-65" label slot=content-start><calcite-menu-item breadcrumb .label=${typeString} @click=${this._navigateFromSubMenu} .text=${typeString} text-enabled></calcite-menu-item><calcite-menu-item label active .text=${this._subNavigationCard?.title} text-enabled></calcite-menu-item></calcite-menu></calcite-navigation>` : "";
  }
  _getLogoFill(isDarkMode) {
    return isDarkMode ? "#FFFFFF" : "#141414";
  }
  _handleMenuClick(tabType, clickRef, disableRefs, emit) {
    disableRefs.forEach((r) => {
      if (r.value) {
        if (this._isMobile) {
          r.value.selected = false;
        } else {
          r.value.active = false;
        }
      }
    });
    if (clickRef?.value) {
      if (this._isMobile) {
        clickRef.value.selected = true;
      } else {
        clickRef.value.active = true;
      }
    }
    if (tabType !== "my-content") {
      this._activeTab = tabType;
    } else {
      this._viewMyContent();
    }
    if (emit) {
      this._logNavClickTelemetry(tabType);
    }
    if (emit) {
      this.navTabSelected.emit({ tabType });
    }
  }
  _logNavClickTelemetry(tabType) {
    const navItemMap = {
      "all-solutions": "Solutions",
      "deployments": "Deployments",
      "my-content": "My Content",
      "resources": "Resources",
      "details": void 0,
      "deployed-card": void 0
    };
    const navItem = navItemMap[tabType];
    if (navItem) {
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.GLOBAL_NAVIGATION,
        action: "Navigate",
        dimensions: [navItem]
      });
    }
  }
  _logLinkClickTelemetry(linkName) {
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.GLOBAL_NAVIGATION,
      action: "Navigate",
      dimensions: [linkName]
    });
  }
  _getUserAvatar() {
    const user = this._portal.user;
    const _portalUserSubset = this._authentication?.PortalUserSubset;
    const userId = user?.id ?? user?.sourceJSON?.id;
    return html`<div class="height-full display-flex cursor-pointer signin-padding"><calcite-navigation-user class="height-full" full-name=${user?.fullName ?? nothing} id=instant-apps-sign-in-user-button slot=user .thumbnail=${user?.thumbnailUrl ?? _portalUserSubset?.thumbnailUrl ?? ""} .userId=${userId} .username=${user?.username}></calcite-navigation-user></div><calcite-popover placement=bottom-end scale=s reference-element=instant-apps-sign-in-user-button offset-distance=0 pointer-disabled focus-trap-disabled auto-close .label=${this._translations.userSettings}><calcite-action scale=l @click=${this._viewMyContent} .text=${this._translations.myContent} text-enabled></calcite-action><calcite-action scale=l @click=${this._signOut} .text=${this._translations.signOut} text-enabled></calcite-action></calcite-popover>`;
  }
  _viewMyContent() {
    const myContentUrl = `${this._config?.portalURL}/home/content.html#my`;
    window.open(myContentUrl, "_blank");
  }
  _signOut() {
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.GLOBAL_NAVIGATION,
      action: "Navigate",
      dimensions: ["Sign out"]
    });
    this._authentication?.signOut();
  }
  _handleSignIn(evt) {
    evt.preventDefault();
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.GLOBAL_NAVIGATION,
      action: "Navigate",
      dimensions: ["Sign in"]
    });
    this._authentication?.signIn().then(() => {
    }).catch((error) => {
      console.error("Error creating global nav header:", error);
    });
  }
  _deployedCardSelected(evt) {
    this._cardType = "deployed";
    this._subNavigationCard = evt.detail.card;
  }
  _detailsCardSelected(evt) {
    this._cardType = "details";
    this._subNavigationCard = evt.detail;
  }
  _deployAppTabSelected(evt) {
    console.log("_deployAppTabSelected");
    console.log(evt.detail);
    this._subNavigationCard = void 0;
  }
  _handleUrlChange() {
    console.log("_handleUrlChange");
    this._subNavigationCard = void 0;
  }
  _navigateFromSubMenu() {
    if (this._cardType === "details") {
      this._handleMenuClick("all-solutions", this._menuItemAll, [this._menuItemMy, this._menuItemResources], true);
    } else if (this._cardType === "deployed") {
      this._handleMenuClick("deployments", this._menuItemMy, [this._menuItemAll, this._menuItemResources], true);
    }
  }
}
customElement("solutions-deploy-app-nav", SolutionsDeployAppNav);
export {
  SolutionsDeployAppNav as S,
  TelemetryManager as T
};
