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

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

const r = "ch-tab-render.tab{background-color:transparent;border-color:transparent}ch-tab-render.tab::part(tab-list block-start){border-block-end:none}ch-tab-render.tab::part(tab block closable),ch-tab-render.tab::part(tab block not-closable){background-color:transparent}:host{display:grid;block-size:100%;overflow:auto;grid-template-rows:1fr}.web-apps,.native-apps,.apis{padding-block-start:16px;overflow:auto;block-size:100%}.tab::part(page){scrollbar-width:thin}.spacing-body>ch-tab-render>.tab-slot-spacing-body,:host(.spacing-body)>ch-tab-render>.tab-slot-spacing-body{padding-block:var(--spacing-body-block-start) var(--spacing-body-block-end);padding-inline:var(--spacing-body-inline-start) var(--spacing-body-inline-end)}";

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

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

var p;

const d = [ "resets/box-sizing", "components/tab", "utils/form--full", "utils/layout", "utils/typography", "utils/spacing", "chameleon/scrollbar" ];

const l = "main";

const h = "web-apps";

const b = "native-apps";

const u = "apis";

// Temporary WA (Read WA in launchpad.scss)
const f = "tab-slot-spacing-body";

const v = class {
  constructor(a) {
    t(this, a);
    this.objectSelected = e(this, "objectSelected", 7);
    this.copyToClipboard = e(this, "copyToClipboard", 7);
    this.openOnTheAppStore = e(this, "openOnTheAppStore", 7);
    p.set(this, void 0);
    this.data = undefined;
    this.isStandalone = true;
    this.sections = [];
    this.tabModel = [];
  }
  watchDataHandler(t) {
    if (t !== undefined) {
      this.organizeData();
    }
  }
  async componentWillLoad() {
    try {
      n(this, p, await o.getComponentStrings(this.el), "f");
    } catch (t) {
      console.error("Error loading locale:", t);
      n(this, p, {
        tabs: {
          webApps: "WEB APPS",
          nativeApps: "NATIVE APPS",
          apis: "APIS"
        }
      }, "f");
    }
    if (this.data) {
      this.organizeData();
    }
  }
  componentDidLoad() {}
  /**
     * Organizes received data and builds tab model
     */  organizeData() {
    if (this.data) {
      try {
        const t = typeof this.data === "string" ? JSON.parse(this.data) : this.data;
        this.sections = t.sections || [];
        this.buildTabModel();
      } catch (t) {
        console.error("Error parsing launchpad data:", t);
        this.sections = [];
        this.tabModel = [];
      }
    }
  }
  /**
     * Builds tab model based on sections
     */  buildTabModel() {
    if (this.sections && this.sections.length > 0) {
      this.tabModel = this.sections.map((t => ({
        id: t.id,
        name: this.getLocalizedTabName(t.id)
      })));
    }
  }
  /**
     * Gets localized tab name based on section ID
     */  getLocalizedTabName(t) {
    var e;
    const a = ((e = c(this, p, "f")) === null || e === void 0 ? void 0 : e.tabs) || {};
    switch (t) {
     case "web-apps":
      return a.webApps || "WEB APPS";

     case "native-apps":
      return a.nativeApps || "NATIVE APPS";

     case "apis":
      return a.apis || "APIS";

     default:
      return t.toUpperCase().replace(/-/g, " ");
    }
  }
  /**
     * Handles object selection from subcomponents
     */  handleObjectSelection(t) {
    let e = t.detail.key;
    // Convert string format "type|id" to object format
        if (typeof e === "string" && e.includes("|")) {
      const t = e.split("|");
      if (t.length === 2) {
        e = {
          type: t[0],
          id: t[1]
        };
      }
    }
    this.objectSelected.emit({
      key: e
    });
  }
  /**
     * Handles copy to clipboard from subcomponents
     */  handleCopyToClipboard(t) {
    this.copyToClipboard.emit({
      url: t.detail.url
    });
  }
  /**
     * Handles open app store from subcomponents
     */  handleOpenAppStore(t) {
    this.openOnTheAppStore.emit({
      url: t.detail.url
    });
  }
  render() {
    var t, e, i;
    if (!this.data || !this.sections || this.sections.length === 0) {
      return null;
    }
    // TODO: Revisit re-enabling keyboard shortcuts 1, 2, 3 for switching launchpad tabs (Web Apps, Native Apps, APIs)
        return a(s, null, a("ch-theme", {
      model: d
    }), a("ch-tab-render", {
      class: {
        scrollable: true,
        tab: true,
        [l]: true
      },
      tabListPosition: "block-start",
      model: this.tabModel,
      selectedId: h,
      overflow: "auto",
      contain: "size"
    }, a("div", {
      slot: h,
      class: {
        "web-apps": true,
        [f]: true
      },
      part: "tab-button-web-apps"
    }, a("gx-ide-launchpad-web-apps", Object.assign({
      objects: ((t = this.sections.find((t => t.id === "web-apps"))) === null || t === void 0 ? void 0 : t.objects) || []
    }, {
      onObjectSelected: t => this.handleObjectSelection(t)
    }, {
      onCopyToClipboard: t => this.handleCopyToClipboard(t)
    }))), a("div", {
      slot: b,
      class: {
        "native-apps": true,
        [f]: true
      },
      part: "tab-button-native-apps"
    }, a("gx-ide-launchpad-native-apps", Object.assign({
      objects: ((e = this.sections.find((t => t.id === "native-apps"))) === null || e === void 0 ? void 0 : e.objects) || []
    }, {
      onObjectSelected: t => this.handleObjectSelection(t)
    }, {
      onCopyToClipboard: t => this.handleCopyToClipboard(t)
    }, {
      onOpenOnTheAppStore: t => this.handleOpenAppStore(t)
    }))), a("div", {
      slot: u,
      class: {
        apis: true,
        [f]: true
      },
      part: "tab-button-apis"
    }, a("gx-ide-launchpad-apis", Object.assign({
      apis: ((i = this.sections.find((t => t.id === "apis"))) === null || i === void 0 ? void 0 : i.apis) || []
    }, {
      onObjectSelected: t => this.handleObjectSelection(t)
    }, {
      onCopyToClipboard: t => this.handleCopyToClipboard(t)
    })))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/launchpad" ];
  }
  get el() {
    return i(this);
  }
  static get watchers() {
    return {
      data: [ "watchDataHandler" ]
    };
  }
};

p = new WeakMap;

v.style = r;

export { v as gx_ide_launchpad };
//# sourceMappingURL=p-25e749c7.entry.js.map