import { c as cc, S as S$1, p as Sr, l as le, f, b as ve, U as Ua, cp as od, v as vo, O as Oe, r as rd, h as We, a as Oa } from "./indexhtml-Kdz6Ae66.js";
import { r } from "./icons-mWh87_oB-BtdirGvB.js";
import "./commonjsHelpers-CUmg6egw.js";
var w = (e, n, a, r2) => {
  for (var s = n, p = e.length - 1, u; p >= 0; p--)
    (u = e[p]) && (s = u(s) || s);
  return s;
};
const S = "bg-[linear-gradient(to_right,var(--amber-3),var(--amber-5),var(--amber-3),var(--amber-6))] dark:bg-[linear-gradient(to_right,var(--amber-5),var(--amber-7),var(--amber-5),var(--amber-8))]", P = "bg-[linear-gradient(to_right,var(--blue-3),var(--blue-5),var(--blue-3),var(--blue-6))] dark:bg-[linear-gradient(to_right,var(--blue-4),var(--blue-6),var(--blue-4),var(--blue-7))]", E = "bg-[linear-gradient(to_right,var(--ruby-3),var(--ruby-5),var(--ruby-3),var(--ruby-6))] dark:bg-[linear-gradient(to_right,var(--ruby-4),var(--ruby-6),var(--ruby-4),var(--ruby-7))]", A = "bg-[linear-gradient(to_right,var(--teal-3),var(--teal-5),var(--teal-3),var(--teal-6))] dark:bg-[linear-gradient(to_right,var(--teal-4),var(--teal-6),var(--teal-4),var(--teal-7))]";
let g = class extends cc {
  createRenderRoot() {
    return this;
  }
  connectedCallback() {
    super.connectedCallback(), this.classList.add("flex", "flex-col");
  }
  render() {
    return le`
      <header class="flex items-center pe-2 ps-4 py-2">
        <h2 class="font-bold gap-1 me-auto my-0 text-xs uppercase">Vaadin Copilot</h2>
        <vaadin-button
          aria-label="Close"
          theme="icon tertiary"
          @click=${() => {
      this.closePopover();
    }}>
          <vaadin-icon .svg="${r.close}"></vaadin-icon>
          <vaadin-tooltip slot="tooltip" text="Close"></vaadin-tooltip>
        </vaadin-button>
      </header>
      <div class="flex flex-col gap-4 pb-4 px-4">
        ${this.renderUserButton()} ${this.renderDevelopmentWorkflow()} ${this.renderWelcomeToVersion()}
        <div class="bg-gray-3 dark:bg-gray-6 flex flex-col rounded-md">
          <vaadin-button
            @click="${this.handleAppInfoClick}"
            class="border-0 h-auto justify-start py-2"
            theme="tertiary">
            <vaadin-icon slot="prefix" .svg="${r.info}"></vaadin-icon>
            App Info
          </vaadin-button>
          <vaadin-button @click="${this.handleAppLogClick}" class="border-0 h-auto justify-start py-2" theme="tertiary">
            <vaadin-icon slot="prefix" .svg="${r.terminal}"></vaadin-icon>
            App Log
          </vaadin-button>
          <vaadin-button
            @click="${this.handleFeaturesClick}"
            class="border-0 h-auto justify-start py-2"
            theme="tertiary">
            <vaadin-icon slot="prefix" .svg="${r.listAlt}"></vaadin-icon>
            Features
          </vaadin-button>
          ${Sr.springSecurityEnabled ? le`
                <vaadin-button
                  @click="${this.handleImpersonateAppUserClick}"
                  class="border-0 h-auto justify-start py-2"
                  theme="tertiary">
                  <vaadin-icon slot="prefix" .svg="${r.accountCircle}"></vaadin-icon>
                  Impersonate App User
                </vaadin-button>
              ` : S$1}
        </div>
        <div class="bg-gray-3 dark:bg-gray-6 flex flex-col rounded-md">
          <vaadin-button
            @click="${this.handleHelpAndSupportClick}"
            class="border-0 h-auto justify-start py-2"
            theme="tertiary">
            <vaadin-icon slot="prefix" .svg="${r.help}"></vaadin-icon>
            Help & Support
          </vaadin-button>
          <vaadin-button
            @click="${this.handleSettingsClick}"
            class="border-0 h-auto justify-start py-2"
            theme="tertiary">
            <vaadin-icon slot="prefix" .svg="${r.settings}"></vaadin-icon>
            Settings
          </vaadin-button>
        </div>
      </div>
    `;
  }
  renderUserButton() {
    const e = f.userInfo?.validLicense, n = e ? S : P, a = e ? "text-amber-12 dark:text-amber-11" : "text-blue-12 dark:text-blue-11", r$1 = this.getUserName() !== "Log in";
    return le`
      <vaadin-button
        @click=${this.handleUserLoginClick}
        class="animate-gradient ${n} border-0 h-auto justify-start py-2 text-start ${r$1 ? "gap-3 px-3" : "items-start"}">
        ${r$1 ? this.renderUserImage() : le`<vaadin-icon
              class="text-blue-12 dark:text-blue-11"
              slot="prefix"
              .svg="${r.login}"></vaadin-icon>`}
        <span class="flex flex-col">
          <span>${this.getUserName()}</span>
          <span class="${a} text-xs">${this.getLicenseType()}</span>
        </span>
      </vaadin-button>
    `;
  }
  renderWelcomeToVersion() {
    const e = f.projectVersionReleaseNoteInfo;
    return e === null ? S$1 : ve.getMostRecentReleaseNoteDismissed() ? S$1 : e.mostRecentVersion ? e.url ? le`
      <vaadin-button
        id="release-note-btn"
        data-test-id="release-note-btn"
        class="border-0 h-auto justify-start py-2"
        @click="${(n) => {
      window.open(e.url, "_blank");
    }}">
        <vaadin-icon class="text-teal-11" slot="prefix" .svg="${r.info}"></vaadin-icon>
        <span class="flex flex-col items-start">
          <span>Welcome to Vaadin ${e.vaadinVersion}</span>
          <span class="text-teal-11">Click for release notes</span>
        </span>
        <vaadin-icon
          id="dismiss-release-note-item"
          class="text-teal-11"
          slot="suffix"
          @click="${(n) => {
      n.stopPropagation(), ve.setMostRecentReleaseNoteDismissed(true);
    }}"
          .svg="${r.close}"></vaadin-icon>
      </vaadin-button>
      <vaadin-tooltip for="dismiss-release-note-item" text="Dismiss"></vaadin-tooltip>
    ` : S$1 : S$1;
  }
  renderUserImage() {
    return f.userInfo?.portraitUrl ? le`<img
        alt="${this.getUserName()}"
        class="rounded-full size-8 object-cover"
        slot="prefix"
        src="https://vaadin.com${f.userInfo.portraitUrl}" />` : S$1;
  }
  renderDevelopmentWorkflow() {
    const e = Ua(), n = od(), a = this.getDevelopmentWorkflowConfig(e, n), r2 = a?.bgClass ?? "", s = a?.colorClass ?? "", p = this.resolveIcon(a), u = a?.rotateIcon ? `rotate-180 ${s}` : s, b = this.resolveTitle(a), f2 = a?.displayMessage ?? "";
    return le`
      <vaadin-button
        data-test-id="development-workflow-btn"
        @click="${this.handleDevelopmentWorkflowClick}"
        class="animation-delay-4000 animate-gradient ${r2} border-0 h-auto justify-start py-2 text-start">
        <vaadin-icon class="${u}" slot="prefix" .svg="${p}"></vaadin-icon>
        <span class="flex flex-col">
          <span>${b}</span>
          <span class="text-xs ${s}">${f2}</span>
        </span>
      </vaadin-button>
    `;
  }
  getDevelopmentWorkflowConfig(e, n) {
    const a = {
      bgClass: A,
      colorClass: "text-teal-11"
    };
    if (e === "warning" && n === "warning")
      return {
        ...a,
        icon: r.wbIncandescent,
        rotateIcon: true,
        title: "IDE plugin & Hotswap recommended",
        combinedTitle: true,
        displayMessage: "Enable both for optimal development workflow"
      };
    if (e === "warning")
      return {
        ...a,
        icon: r.wbIncandescent,
        rotateIcon: true,
        title: "Hotswap recommended",
        displayMessage: "Applies changes without restarting"
      };
    if (n === "warning")
      return {
        ...a,
        icon: r.code,
        getIcon: true,
        title: "IDE plugin recommended",
        getTitle: true,
        displayMessage: "Simplifies Hotswap setup & config"
      };
    if (e === "error")
      return {
        bgClass: E,
        colorClass: "text-ruby-11",
        icon: r.error,
        title: "Hotswap partially enabled",
        displayMessage: "View details"
      };
  }
  resolveIcon(e) {
    return e ? e.getIcon ? this.getIdeIcon() : e.icon : r.bolt;
  }
  resolveTitle(e) {
    return e ? e.combinedTitle ? this.getCombinedTitle() : e.getTitle ? this.getIdePluginName() : e.title : "Development Workflow";
  }
  getUserName() {
    return [f.userInfo?.firstName, f.userInfo?.lastName].filter(Boolean).join(" ") || "Log in";
  }
  getLicenseType() {
    return f.userInfo?.validLicense ? "" : "Unlock all Copilot features, including AI";
  }
  getIdeIcon() {
    switch (f.idePluginState?.ide) {
      case "intellij":
        return r.intelliJ;
      case "vscode":
        return r.vsCode;
      case "eclipse":
        return r.eclipse;
      default:
        return r.code;
    }
  }
  getIdePluginName() {
    switch (f.idePluginState?.ide) {
      case "intellij":
        return "Vaadin plugin for IntelliJ";
      case "vscode":
        return "Vaadin extension for VS Code";
      case "eclipse":
        return "Vaadin plugin for Eclipse";
      default:
        return "IDE plugin";
    }
  }
  getCombinedTitle() {
    switch (f.idePluginState?.ide) {
      case "intellij":
        return "IntelliJ plugin & Hotswap recommended";
      case "vscode":
        return "VS Code extension & Hotswap recommended";
      case "eclipse":
        return "Eclipse plugin & Hotswap recommended";
      default:
        return "IDE plugin & Hotswap recommended";
    }
  }
  closePopover() {
    const e = this.closest("vaadin-popover");
    e && (e.opened = false);
  }
  handleUserLoginClick() {
    if (f.userInfo?.validLicense) {
      window.open("https://vaadin.com/myaccount", "_blank", "noopener");
      return;
    }
    f.setLoginCheckActive(true);
  }
  handleDevelopmentWorkflowClick() {
    vo("use-dev-workflow-guide"), Oe.openPanel(rd), this.closePopover();
  }
  handleAppInfoClick() {
    Oe.openPanel(We.INFO), this.closePopover();
  }
  handleAppLogClick() {
    Oe.openPanel(We.LOG), this.closePopover();
  }
  handleFeaturesClick() {
    Oe.openPanel(We.FEATURES), this.closePopover();
  }
  handleImpersonateAppUserClick() {
    Oe.openPanel(We.IMPERSONATOR), this.closePopover();
  }
  handleSettingsClick() {
    Oe.openPanel(We.SETTINGS), this.closePopover();
  }
  handleHelpAndSupportClick() {
    Oe.openPanel(We.FEEDBACK), this.closePopover();
  }
};
g = w([
  Oa("copilot-devtools")
], g);
export {
  g as CopilotDevTools
};
