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

import { c as o } from "./p-c5196b3b.js";

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

import { v as a } from "./p-b32b6b1f.js";

const l = 'button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;grid-template-rows:max-content 1fr max-content;block-size:100%;overflow:auto}.section{display:contents}.main{display:grid;overflow:auto}.field-group-name-description-module{align-items:center;grid-template-areas:"name-label name-input" "description-label description-input" "module-label module-entity-selector";grid-template-columns:max-content 1fr}.name-label{grid-area:name-label}.name-input{grid-area:name-input}.description-label{grid-area:description-label}.description-input{grid-area:description-input}.module-label{grid-area:module-label}.module-entity-selector{grid-area:module-entity-selector}.tooltip{height:0}';

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

var d = undefined && undefined.__classPrivateFieldSet || function(t, i, e, 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 i === "function" ? t !== i || !o : !i.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return s === "a" ? o.call(t, e) : o ? o.value = e : i.set(t, e), e;
};

var h, c, f, u, p, m, b, v, g, w, y, k, M, W;

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

const E = class {
  constructor(e) {
    t(this, e);
    h.set(this, void 0);
    c.set(this, void 0);
    f.set(this, void 0);
    u.set(this, void 0);
    p.set(this, void 0);
    m.set(this, void 0);
    b.set(this, void 0);
    v.set(this, void 0);
    g.set(this, (() => {
      const t = [ r(this, p, "f"), r(this, u, "f") ];
      t.forEach((t => {
        if (t.id) {
          this.validatableControls.set(t.id, {
            reference: t,
            hasError: false,
            message: undefined
          });
        }
      }));
    }));
    w.set(this, (t => {
      var e, s, n;
      return ((s = (e = this.validatableControls) === null || e === void 0 ? void 0 : e.get(t === null || t === void 0 ? void 0 : t.id)) === null || s === void 0 ? void 0 : s.hasError) && ((n = this.validatableControls.get(t.id)) === null || n === void 0 ? void 0 : n.message) && i("ch-tooltip", {
        class: "tooltip",
        actionElement: t,
        blockAlign: o.tooltipSettings.blockAlign,
        inlineAlign: o.tooltipSettings.inlineAlign,
        delay: o.tooltipSettings.delay
      }, this.validatableControls.get(t.id).message);
    }));
    y.set(this, (() => {
      var t, i, e, s, o;
      const n = ((i = (t = r(this, p, "f")) === null || t === void 0 ? void 0 : t.value) === null || i === void 0 ? void 0 : i.trim()) || "";
      const a = ((s = (e = r(this, u, "f")) === null || e === void 0 ? void 0 : e.value) === null || s === void 0 ? void 0 : s.id) || "";
      const l = ((o = this.curlContent) === null || o === void 0 ? void 0 : o.trim()) || "";
      const d = this.validateNameCallback ? this.validateNameCallback(n) : Boolean(n);
      const h = Boolean(a);
      const c = Boolean(l);
      this.isFormValid = d && h && c;
    }));
    k.set(this, (() => {
      if (r(this, m, "f")) {
        this.curlContent = r(this, m, "f").text;
        r(this, y, "f").call(this);
      }
    }));
    M.set(this, (t => {
      const i = t.target.assignedElements();
      if (i.length) {
        d(this, m, i[0], "f");
        r(this, m, "f").addEventListener("input", r(this, k, "f"));
        d(this, b, (t => {
          this.curlContent = t.detail.content;
          r(this, k, "f").call(this);
        }), "f");
        r(this, m, "f").addEventListener("curl-content-change", r(this, b, "f"));
        d(this, v, (t => {
          if ((t.ctrlKey || t.metaKey) && t.key === "v") {
            setTimeout((() => {
              r(this, k, "f").call(this);
            }), 0);
          }
        }), "f");
        r(this, m, "f").addEventListener("keydown", r(this, v, "f"));
        this.curlContent = r(this, m, "f").text;
        r(this, y, "f").call(this);
      }
    }));
    W.set(this, (() => {
      var t;
      const i = {
        name: r(this, p, "f").value,
        description: r(this, f, "f").value,
        parentId: (t = r(this, u, "f").value) === null || t === void 0 ? void 0 : t.id,
        curl: this.curlContent
      };
      this.confirmCallback(i).then((t => {
        this.validatableControls = a(t, this.validatableControls);
      }));
    }));
    this.showTooltipError = false;
    this.isFormValid = false;
    this.curlContent = "";
    this.validatableControls = new Map;
    this.cancelCallback = undefined;
    this.confirmCallback = undefined;
    this.defaultParent = undefined;
    this.parent = undefined;
    this.selectModuleCallback = undefined;
    this.validateNameCallback = undefined;
  }
  async componentWillLoad() {
    d(this, h, await n.getComponentStrings(this.el), "f");
  }
  componentDidLoad() {
    r(this, g, "f").call(this);
  }
  disconnectedCallback() {
    if (r(this, m, "f") && r(this, m, "f").removeEventListener) {
      r(this, m, "f").removeEventListener("input", r(this, k, "f"));
      r(this, m, "f").removeEventListener("curl-content-change", r(this, b, "f"));
      r(this, m, "f").removeEventListener("keydown", r(this, v, "f"));
    }
  }
  /**
     * Suspends or reactivates the shortcuts
     */  async suspendShortcuts(t) {
    r(this, c, "f").suspend = t;
  }
  render() {
    return i(e, {
      class: "widget"
    }, i("ch-theme", {
      model: x
    }), i("ch-shortcuts", {
      src: "./gx-ide-assets/curl-inspector/shortcuts.json",
      ref: t => d(this, c, t, "f")
    }), i("section", {
      class: "section"
    }, i("header", {
      class: "header field-group spacing-body dialog-header"
    }, i("div", {
      class: "field-group field-group-name-description-module"
    }, i("label", {
      class: "label name-label",
      htmlFor: "input-name"
    }, r(this, h, "f").header.nameFieldLabel), i("ch-edit", {
      class: "input name-input",
      id: "input-name",
      ref: t => d(this, p, t, "f"),
      onInput: r(this, y, "f")
    }), r(this, w, "f").call(this, r(this, p, "f")), i("label", {
      class: "label description-label",
      htmlFor: "input-description"
    }, r(this, h, "f").header.descriptionFieldLabel), i("ch-edit", {
      class: "input description-input",
      id: "input-description",
      ref: t => d(this, f, t, "f")
    }), i("label", {
      class: "label module-label",
      htmlFor: "input-module"
    }, r(this, h, "f").header.moduleFolderLabel), i("gx-ide-entity-selector", {
      class: "module module-entity-selector",
      id: "module",
      value: this.defaultParent,
      ref: t => d(this, u, t, "f"),
      labelPosition: "none",
      defaultValue: this.defaultParent,
      selectEntityCallback: this.selectModuleCallback
    }), r(this, w, "f").call(this, r(this, u, "f")))), i("div", {
      class: "main field-group scrollable"
    }, i("slot", {
      name: "CurlTextEditor",
      onSlotchange: r(this, M, "f")
    })), i("footer", {
      class: "dialog-footer dialog-footer spacing-body-block-end spacing-body-inline"
    }, i("div", {
      class: "buttons-spacer"
    }, i("button", {
      class: "button-secondary",
      id: "button-cancel",
      onClick: this.cancelCallback,
      part: "button-cancel"
    }, r(this, h, "f").footer.btnCancel), i("button", {
      class: "button-primary",
      id: "button-ok",
      onClick: r(this, W, "f"),
      part: "button-ok",
      disabled: !this.isFormValid
    }, r(this, h, "f").footer.btnCreate)))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/curl-inspector" ];
  }
  get el() {
    return s(this);
  }
};

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

E.style = l;

export { E as gx_ide_curl_inspector };
//# sourceMappingURL=p-5864a82d.entry.js.map