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

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

const stringIsNumber = t => {
  let e = false;
  e = !isNaN(+t) && t.toString().length !== 0;
  return e;
};

const a = 'button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;overflow:auto;grid-template-areas:"radio-group revision-number" "footer footer";grid-template-columns:max-content minmax(200px, 1fr);grid-template-rows:max-content max-content}.main{display:contents}.radio-group{grid-area:radio-group}.revision-number{grid-area:revision-number}.footer{grid-area:footer}';

var d = 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 h = 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 f, c, u, p, l, m, w, v, g, b, y, k, W;

const M = [ "resets/box-sizing", "utils/form", "utils/layout", "utils/spacing", "utils/typography", "components/radio-group", "components/button", "components/edit" ];

const x = "latestRevision";

const T = "updateToRevision";

const E = class {
  constructor(o) {
    t(this, o);
    this.componentDidLoadEvent = e(this, "componentDidLoadEvent", 7);
    this.componentDidRenderFirstTime = e(this, "componentDidRenderFirstTime", 7);
    f.set(this, void 0);
    c.set(this, void 0);
    u.set(this, [ {
      value: x,
      caption: ""
    }, {
      value: T,
      caption: ""
    } ]);
    p.set(this, false);
    l.set(this, i(`./gx-ide-assets/team-dev-update-to-revision/shortcuts.json`));
    m.set(this, void 0);
    w.set(this, void 0);
    v.set(this, (() => {
      this.cancelCallback();
    }));
    g.set(this, (() => {
      let t = undefined;
      if (d(this, m, "f").value === T) {
        t = d(this, w, "f").value;
      }
      this.confirmCallback(t);
    }));
    b.set(this, (t => {
      this.isValid = stringIsNumber(t.detail);
    }));
    y.set(this, (t => {
      d(this, w, "f").disabled = t.detail !== T;
      this.isValid = true;
      if (t.detail === x) {
        this.isValid = true;
      } else if (t.detail === T && !stringIsNumber(d(this, w, "f").value)) {
        this.isValid = false;
        setTimeout((() => {
          d(this, w, "f").focus();
        }), 2e3);
      }
    }));
    k.set(this, (() => s("footer", {
      class: "footer dialog-footer spacing-body-block-start"
    }, s("div", {
      class: "buttons-spacer"
    }, s("button", {
      class: "button-secondary",
      onClick: d(this, v, "f"),
      part: "button-cancel"
    }, d(this, f, "f").footer.btnCancel), s("button", {
      class: "button-primary",
      onClick: d(this, g, "f"),
      part: "button-update",
      disabled: !this.isValid
    }, d(this, f, "f").footer.btnUpdate)))));
    W.set(this, (() => {
      if (this.currentRevision === undefined) {
        d(this, m, "f").value = x;
        this.isValid = true;
        d(this, w, "f").disabled = true;
      } else {
        d(this, w, "f").disabled = false;
        d(this, w, "f").value = this.currentRevision;
        d(this, m, "f").value = T;
      }
    }));
    this.isValid = undefined;
    this.cancelCallback = undefined;
    this.confirmCallback = undefined;
    this.currentRevision = undefined;
  }
  componentDidLoad() {
    this.componentDidLoadEvent.emit(true);
    d(this, W, "f").call(this);
  }
  componentDidRender() {
    if (!d(this, p, "f")) {
      this.componentDidRenderFirstTime.emit(d(this, f, "f").componentName);
      h(this, p, true, "f");
    }
    d(this, u, "f").find((t => t.value === x)).caption = d(this, f, "f").options.updateToLatest;
    d(this, u, "f").find((t => t.value === T)).caption = d(this, f, "f").options.updateToRevision;
  }
  async componentWillLoad() {
    h(this, f, await n.getComponentStrings(this.el), "f");
    this.isValid = true;
  }
  /**
     * Validate necessary data input
     */  async validate() {
    const t = true;
    return t;
  }
  /**
     * Suspends or reactivates the shortcuts
     */  async suspendShortcuts(t) {
    if (t) {
      d(this, c, "f").suspend = true;
    } else {
      d(this, c, "f").suspend = false;
    }
  }
  render() {
    return s(o, {
      class: "widget scrollable field-group spacing-body"
    }, s("ch-theme", {
      model: M
    }), s("ch-shortcuts", {
      src: d(this, l, "f"),
      ref: t => h(this, c, t, "f")
    }), s("section", {
      class: "main"
    }, s("ch-radio-group-render", {
      class: "radio-group",
      model: d(this, u, "f"),
      direction: "horizontal",
      onChange: d(this, y, "f"),
      ref: t => {
        h(this, m, t, "f");
      }
    }), s("ch-edit", {
      autoFocus: true,
      class: "input revision-number",
      onInput: d(this, b, "f"),
      ref: t => h(this, w, t, "f")
    }), d(this, k, "f").call(this)));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/team-dev-update-to-revision" ];
  }
  get el() {
    return r(this);
  }
};

f = new WeakMap, c = new WeakMap, u = new WeakMap, p = new WeakMap, l = new WeakMap, 
m = new WeakMap, w = new WeakMap, v = new WeakMap, g = new WeakMap, b = new WeakMap, 
y = new WeakMap, k = new WeakMap, W = new WeakMap;

E.style = a;

export { E as gx_ide_team_dev_update_to_revision };
//# sourceMappingURL=p-4bafe061.entry.js.map