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

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

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

import "lit";

import "lit/directives/when.js";

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

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

const r = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;grid-template-rows:1fr max-content}.main-container{display:grid;grid-template-rows:max-content max-content max-content;gap:var(--spacing-gap-xl)}.versions-container{display:grid;grid-template-columns:1fr max-content;gap:var(--spacing-gap-m)}";

var c = undefined && undefined.__classPrivateFieldGet || function(t, e, i, s) {
  if (i === "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 i === "m" ? s : i === "a" ? s.call(t) : s ? s.value : e.get(t);
};

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

var d, h, p, f, u, m, g, b, v;

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

const w = n({
  category: "gemini-tools",
  name: "show-more-horizontal",
  colorType: "interactive"
});

const x = n({
  category: "objects",
  name: "version-frozen"
});

const k = n({
  category: "objects",
  name: "version"
});

const _ = n({
  category: "system",
  name: "version",
  colorType: "on-surface"
});

const j = class {
  constructor(s) {
    t(this, s);
    d.set(this, void 0);
    h.set(this, void 0);
    p.set(this, e(`./gx-ide-assets/restore-version/shortcuts.json`));
    f.set(this, (async () => {
      const t = {
        toVersionGuid: this.toVersionInfo.guid,
        toVersionName: this.toVersionInfo.name,
        fromVersionGuid: this.versions.find((t => t.name === this.selectedSourceVersionName)).guid,
        fromVersionName: this.selectedSourceVersionName,
        syncEnvironments: this.syncEnvironments
      };
      await this.confirmCallback(t);
    }));
    u.set(this, (async () => {
      await this.cancelCallback();
    }));
    m.set(this, (t => {
      this.versionsComboBoxModel = t.map((t => ({
        caption: t.name,
        value: t.guid,
        startImgSrc: t.isFrozen ? x : k
      })));
    }));
    g.set(this, (t => {
      this.selectedSourceVersionName = t.detail;
    }));
    // Uncomment this when the sync environments feature is available
    // #handleCheckBoxValueChange = (
    //   event: ChCheckboxCustomEvent<any> | InputEvent
    // ) => {
    //   this.syncEnvironments = event.detail === CHECKBOX_CHECKED_VALUE;
    // };
        b.set(this, (async () => {
      this.selectedSourceVersion = await this.selectSourceVersionCallback();
      this.selectedSourceVersionName = this.selectedSourceVersion[0].name;
    }));
    v.set(this, (() => {
      const t = !this.selectedSourceVersionName || !this.versionsComboBoxModel.some((t => t.caption === this.selectedSourceVersionName));
      return i("footer", {
        class: "footer dialog-footer dialog-footer-with-border spacing-body"
      }, i("div", {
        class: "buttons-spacer"
      }, i("button", {
        id: "cancel-button",
        class: "button-secondary",
        onClick: c(this, u, "f")
      }, c(this, d, "f").footer.cancel), i("button", {
        id: "confirm-button",
        class: "button-primary",
        onClick: c(this, f, "f"),
        disabled: t
      }, c(this, d, "f").footer.confirm)));
    }));
    this.syncEnvironments = false;
    this.selectedSourceVersionName = "";
    this.selectedSourceVersion = [];
    this.versionsComboBoxModel = [];
    this.selectSourceVersionCallback = undefined;
    this.confirmCallback = undefined;
    this.cancelCallback = undefined;
    this.toVersionInfo = undefined;
    this.versions = undefined;
  }
  versionsChanged() {
    c(this, m, "f").call(this, this.versions);
  }
  async componentWillLoad() {
    l(this, d, await a.getComponentStrings(this.el), "f");
    c(this, m, "f").call(this, this.versions || []);
  }
  /**
     * Suspends or reactivates the shortcuts
     */  async suspendShortcuts(t) {
    if (t) {
      c(this, h, "f").suspend = true;
    } else {
      c(this, h, "f").suspend = false;
    }
  }
  render() {
    return i(s, {
      class: "widget"
    }, i("ch-theme", {
      model: y
    }), i("ch-shortcuts", {
      src: c(this, p, "f"),
      ref: t => l(this, h, t, "f")
    }), i("div", {
      class: "main-container spacing-body"
    }, i("p", {
      class: "giu-static-pill-icon-and-text elevation-2"
    }, i("ch-image", {
      class: "icon-m",
      type: "mask",
      src: _
    }), i("span", null, `${c(this, d, "f").descriptions.pill} - ${this.toVersionInfo.name}`)), i("p", {
      class: "body-regular-m"
    }, c(this, d, "f").descriptions.summary), i("div", {
      class: "field field-block"
    }, i("label", {
      class: "label",
      htmlFor: "versions-combo-box"
    }, c(this, d, "f").labels.fromVersion), i("div", {
      class: "versions-container"
    }, i("ch-combo-box-render", {
      class: "combo-box",
      id: "versions-combo-box",
      model: this.versionsComboBoxModel,
      placeholder: c(this, d, "f").placeHolders.fromVersion,
      value: this.selectedSourceVersionName,
      suggest: true,
      onInput: c(this, g, "f")
    }), i("button", {
      id: "select-version-button",
      class: "button-secondary button-icon-only",
      onClick: c(this, b, "f")
    }, i("ch-image", {
      src: w,
      class: "icon-m"
    }))))), c(this, v, "f").call(this));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/restore-version" ];
  }
  get el() {
    return o(this);
  }
  static get watchers() {
    return {
      versions: [ "versionsChanged" ]
    };
  }
};

d = new WeakMap, h = new WeakMap, p = new WeakMap, f = new WeakMap, u = new WeakMap, 
m = new WeakMap, g = new WeakMap, b = new WeakMap, v = new WeakMap;

j.style = r;

export { j as gx_ide_restore_version };
//# sourceMappingURL=p-fb64e0b1.entry.js.map