import { r as e, h as t, H as n, a as i } from "./p-9b9ccd0c.js";

import { g as o } from "./p-d42e842b.js";

import "./p-6534555e.js";

import "lit";

import "lit/directives/when.js";

import "lit/directives/if-defined.js";

import { L as s } from "./p-311eedf3.js";

/**
 * Returns initials from the first two words of a name. Returns "X" for invalid input.
 *
 * @param name - The full name string.
 * @returns Initials of the first two words, or "X" if invalid.
 *
 * Example:
 * getInitialsFromName("John Doe") -> "JD"
 * getInitialsFromName("Jane") -> "J"
 * getInitialsFromName("") -> "X"
 */ const getInitialsFromName = e => {
  if (typeof e !== "string" || e.trim() === "") {
    return "X";
  }
  const t = e.split(" ").filter(Boolean);
 // Remove any empty strings from splitting
    if (t.length === 1) {
    return t[0][0].toUpperCase();
  } else {
    return `${t[0][0].toUpperCase()}${t[1][0].toUpperCase()}`;
  }
};

/**
 * Limits the full name to the first two words. Returns null for invalid input.
 *
 * @param fullName - The full name string to be limited.
 * @returns The first two words of the full name, or null if invalid.
 *
 * Example:
 * limitFullName("John Doe Smith") -> "John Doe"
 * limitFullName("Jane") -> "Jane"
 * limitFullName("") -> null
 */ const limitFullName = e => {
  if (typeof e !== "string" || e.trim() === "") {
    return null;
  }
  const t = e.split(" ").filter(Boolean);
 // Remove any empty strings from splitting
    if (t.length === 1) {
    return t[0];
  } else {
    return `${t[0]} ${t[1]}`;
  }
};

const r = ":host{display:inline-grid;justify-items:end;block-size:100%}.dropdown::part(expandable-button){display:grid;grid-template-columns:max-content max-content max-content;align-items:center;gap:var(--spacing-gap-l);block-size:auto;cursor:pointer}.user-login__details{display:grid;grid-template-rows:max-content max-content;gap:var(--spacing-gap-xs);justify-items:end}.user-login__name{font-weight:var(--font-style-semi-bold);font-size:var(--font-size-body-s);color:var(--color-text-neutral-default)}.user-login__name,.user-login__organization{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-inline-size:120px;display:inline-block;line-height:1 !important}.user-login__avatar{font-size:9px;flex:0 0 auto;display:flex;align-items:center;justify-content:center;block-size:24px;inline-size:24px;color:var(--color-text-neutral-default);border-radius:50%;background-color:var(--color-accent-neutral-contrast);border:1px solid var(--color-border-primary-on-default)}.user-login__footer{display:flex;flex-direction:column;gap:var(--spacing-gap-m)}.user-login__footer :where(button,a){all:unset;display:inline-flex;align-items:center;user-select:none;touch-action:manipulation;cursor:pointer}.user-login__footer button:disabled{pointer-events:none}.user-login__footer .agreement-link{text-decoration:underline;cursor:pointer;}";

var a = undefined && undefined.__classPrivateFieldSet || function(e, t, n, i, o) {
  if (i === "m") throw new TypeError("Private method is not writable");
  if (i === "a" && !o) throw new TypeError("Private accessor was defined without a setter");
  if (typeof t === "function" ? e !== t || !o : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return i === "a" ? o.call(e, n) : o ? o.value = n : t.set(e, n), n;
};

var l = undefined && undefined.__classPrivateFieldGet || function(e, t, n, i) {
  if (n === "a" && !i) throw new TypeError("Private accessor was defined without a getter");
  if (typeof t === "function" ? e !== t || !i : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return n === "m" ? i : n === "a" ? i.call(e) : i ? i.value : t.get(e);
};

var c, d, u, p, f;

const g = [ 
// TODO: review if "utils/form--full" is required.
"resets/box-sizing", "components/tooltip", "components/switch", "components/icon", "components/dropdown", "utils/layout", "utils/typography", "utils/spacing", "chameleon/scrollbar" ];

const h = o({
  category: "navigation",
  name: "chevron-down",
  colorType: "interactive"
});

const m = "my-account";

const v = "change-team";

const w = "sign-out";

const y = "language";

const _ = class {
  constructor(t) {
    e(this, t);
    c.set(this, void 0);
    d.set(this, "");
    // #mode: Mode;
        u.set(this, void 0);
    p.set(this, void 0);
    // #handleModeSwitch = () => {
    //   this.#mode = this.#mode === "dark" ? "light" : "dark";
    //   if (this.changeModeCallback) {
    //     this.changeModeCallback(this.#mode);
    //   }
    // };
        f.set(this, (e => {
      const t = e.detail.id;
      if (t === m) ; else if (t === v) {
        this.changeTeamCallback();
      } else if (t === w) {
        this.signOutCallback();
      } else if (t === y) {
        this.changeLanguageCallback();
      }
    }));
    this.showMenu = false;
    this.userInfo = undefined;
    this.myAccountCallback = undefined;
    this.changeTeamCallback = undefined;
    this.changeLanguageCallback = undefined;
    this.changeModeCallback = undefined;
    this.menuAlign = undefined;
    this.signOutCallback = undefined;
    this.termsCallback = undefined;
    this.privacyCallback = undefined;
  }
  async componentWillLoad() {
    a(this, c, await s.getComponentStrings(this.el), "f");
    a(this, d, getInitialsFromName(this.userInfo.name), "f");
    a(this, u, [ 
    // {
    //   id: MY_ACCOUNT_ID,
    //   caption: this.#componentLocale.myAccountLabel,
    //   showSeparator: false
    // },
    {
      id: v,
      caption: l(this, c, "f").changeTeamLabel
    }, {
      id: w,
      caption: l(this, c, "f").signOutLabel
    }, {
      type: "separator"
    }, {
      type: "slot",
      id: "agreement"
    } ], "f");
  }
  render() {
    var e, i;
    const o = limitFullName((e = this.userInfo) === null || e === void 0 ? void 0 : e.name);
    return t(n, {
      class: "widget"
    }, t("ch-theme", {
      model: g
    }), t("ch-action-menu-render", {
      class: "dropdown user-login__button",
      model: l(this, u, "f"),
      inlineAlign: "inside-end",
      blockAlign: "outside-end",
      onButtonClick: l(this, f, "f")
    }, t("div", {
      class: "user-login__details"
    }, o ? t("span", {
      class: "body-semi-bold-s user-login__name"
    }, o) : null, ((i = this.userInfo) === null || i === void 0 ? void 0 : i.team) ? t("span", {
      class: "body-regular-xs user-login__organization"
    }, this.userInfo.team) : null), t("div", {
      class: "user-login__avatar"
    }, l(this, d, "f")), t("ch-image", {
      src: h,
      class: "icon-m",
      containerRef: l(this, p, "f")
    }), t("div", {
      class: "user-login__footer footer-slot",
      slot: "agreement"
    }, t("button", {
      class: "body-regular-s agreement-link",
      onClick: this.termsCallback
    }, l(this, c, "f").termsAndConditionsCaption), t("button", {
      class: "body-regular-s\tagreement-link",
      onClick: this.privacyCallback
    }, l(this, c, "f").privacyPolicyCaption))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/current-user-info" ];
  }
  get el() {
    return i(this);
  }
};

c = new WeakMap, d = new WeakMap, u = new WeakMap, p = new WeakMap, f = new WeakMap;

_.style = r;

export { _ as gx_ide_current_user_info };
//# sourceMappingURL=p-86e95bc7.entry.js.map