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

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

const n = "status";

const o = "caption";

const mapNavigationDataToTreeView = e => e.map(((e, t) => ({
  id: e.id,
  selected: t === 0,
  caption: e.name,
  startImgSrc: e.icon,
  parts: `tree-view-item tree-view-item--status tree-view-item--${e.result}`,
  leaf: true,
  metadata: JSON.stringify({
    [n]: e.result.toString(),
    [o]: e.name
  })
})));

const d = 'button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;overflow:auto;grid-template-areas:"aside main" "footer footer";grid-template-rows:1fr max-content;grid-template-columns:240px 1fr}:host(.display-header-type){grid-template-areas:"header header" "aside main" "footer footer";grid-template-rows:max-content 1fr max-content;grid-template-columns:240px 1fr}.section{display:contents}.header{grid-area:header;display:grid;grid-template-columns:1fr max-content}.header__description{display:grid;gap:var(--spacing-gap-m)}.header__description-p{max-inline-size:460px}.header__actions{flex-shrink:0}.aside{grid-area:aside;overflow:auto;border-inline-end:var(--section-common-border);display:grid;grid-template-rows:max-content 1fr}.main{grid-area:main;overflow:auto}.footer{grid-area:footer;justify-content:flex-start}.tree-view::part(item__action tree-view-item--success),.tree-view::part(item__action tree-view-item--warning),.tree-view::part(item__action tree-view-item--error){padding-inline-start:24px}.tree-view::part(item__action tree-view-item--success){background:var(--icon__states_pill-filled_success--enabled) no-repeat;background-position-y:center}.tree-view::part(item__action tree-view-item--warning){background:var(--icon__states_pill-filled_warning--enabled) no-repeat;background-position-y:center}.tree-view::part(item__action tree-view-item--error){background:var(--icon__states_pill-filled_error--enabled) no-repeat;background-position-y:center}';

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

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

var h, p, u, g, f, m, w, v;

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

const y = class {
  constructor(i) {
    e(this, i);
    this.componentDidRenderEvent = t(this, "componentDidRenderEvent", 7);
    /**
         * The component hard-coded strings translations.
         */
    // eslint-disable-next-line @stencil-community/own-props-must-be-private
        h.set(this, void 0);
    p.set(this, []);
    u.set(this, (() => {
      const e = this.navigationItemsStatusRegExpString || "";
      const t = this.navigationItemsCaptionRegExpString || "";
      // Create a RegExp that combines the values from the buttons statues and the filer value.
            const i = `${e && `(${e})`}${e && t ? ".*" : ""}${t && `(${t})`}`;
      this.navigationItemsRegExp = new RegExp(i, "i");
    }));
    g.set(this, (e => {
      var t;
      const i = (t = e.detail[0]) === null || t === void 0 ? void 0 : t.item.id;
      if (i) {
        this.itemSelectedCallback(i);
      }
    }));
    f.set(this, (e => e.sort(((e, t) => e.caption.localeCompare(t.caption)))));
    m.set(this, (e => {
      const t = e.detail;
      const i = [];
      const s = t.findIndex((e => e.itemId === "errors"));
      const a = t.findIndex((e => e.itemId === "warnings"));
      const r = t.findIndex((e => e.itemId === "successes"));
      if (s !== -1) {
        i.push("error");
      }
      if (a !== -1) {
        i.push("warning");
      }
      if (r !== -1) {
        i.push("success");
      }
      if (i.length) {
        const e = i.join("|");
        this.navigationItemsStatusRegExpString = `"${n}":"(${e})"`;
      } else {
        this.navigationItemsStatusRegExpString = `"${n}":""`;
      }
      // Update statusInfo for the status-buttons
            this.statusInfo = {
        error: {
          display: s !== -1,
          number: this.statusInfo.error.number
        },
        warning: {
          display: a !== -1,
          number: this.statusInfo.warning.number
        },
        success: {
          display: r !== -1,
          number: this.statusInfo.success.number
        }
      };
    }));
    w.set(this, (e => {
      const t = e.detail;
      this.navigationItemsCaptionRegExpString = `"${o}":".*${t}.*"`;
    }));
    v.set(this, (e => {
      c(this, p, e, "f");
      this.reportTreeItems = mapNavigationDataToTreeView(e);
      let t = 0;
      let i = 0;
      let s = 0;
      this.reportTreeItems.forEach((e => {
        const a = JSON.parse(e.metadata);
        let r;
        if (n in a) {
          r = a[n];
        }
        if (r && r === "error") {
          t++;
        } else if (r && r === "warning") {
          i++;
        } else if (r && r === "success") {
          s++;
        }
      }));
      this.statusInfo["error"].number = t;
      this.statusInfo["warning"].number = i;
      this.statusInfo["success"].number = s;
    }));
    this.reportTreeItems = [];
    this.navigationItemsStatusRegExpString = "";
    this.navigationItemsCaptionRegExpString = "";
    this.navigationItemsRegExp = undefined;
    this.confirmed = false;
    this.headerState = "none";
    this.statusInfo = {
      error: {
        display: true,
        number: 0
      },
      warning: {
        display: true,
        number: 0
      },
      success: {
        display: true,
        number: 0
      }
    };
    this.someStatusVisible = undefined;
    this.headerData = undefined;
    this.confirmCallback = undefined;
    this.cancelCallback = undefined;
    this.closeCallback = undefined;
    this.itemSelectedCallback = undefined;
  }
  navigationItemsStatusRegExpStringChanged() {
    l(this, u, "f").call(this);
  }
  navigationItemsCaptionRegExpStringChanged() {
    l(this, u, "f").call(this);
  }
  /**
     * Add a new item
     */  async addItem(e) {
    l(this, v, "f").call(this, l(this, p, "f").concat([ e ]));
  }
  /**
     * Clear items
     */  async clearItems() {
    l(this, v, "f").call(this, []);
  }
  async componentWillLoad() {
    c(this, h, await r.getComponentStrings(this.el), "f");
  }
  render() {
    var e;
    return i(s, {
      class: {
        widget: true,
        "display-header-type": !!this.headerData
      }
    }, i("ch-theme", {
      model: b
    }), i("section", {
      class: "section"
    }, this.headerData && i("header", {
      class: "header dialog-header-with-border spacing-body-inline spacing-body-block-start"
    }, i("div", {
      class: "header__description"
    }, i("h3", {
      class: "subtitle-regular-s"
    }, this.headerData.title), i("p", {
      class: "body-regular-s header__description-p"
    }, this.headerData.description)), i("div", {
      class: "header__actions"
    }, i("div", {
      class: "buttons-spacer header__actions"
    }, (e = this.headerData.buttons) === null || e === void 0 ? void 0 : e.map((e => {
      var t;
      const s = e.icon;
      const a = (t = e.type) !== null && t !== void 0 ? t : "button-primary";
      return i("button", {
        class: {
          [a]: true,
          "button-icon-and-text": !!s
        },
        onClick: e.callback
      }, s && i("ch-image", {
        class: "icon-m",
        src: s
      }), e.caption);
    }))))), i("section", {
      class: "aside field-group"
    }, i("header", {
      class: "aside__header spacing-body-inline spacing-body-block-start"
    }, i("div", {
      class: "field field-block"
    }, i("label", {
      class: "label",
      htmlFor: "pattern"
    }, l(this, h, "f").aside.filterLabel), i("ch-edit", {
      id: "pattern",
      class: "input",
      placeholder: l(this, h, "f").aside.filterPlaceholder,
      onInput: l(this, w, "f")
    }))), i("ch-tree-view-render", {
      class: "tree-view",
      "show-lines": "last",
      filter: this.navigationItemsRegExp,
      filterType: "metadata",
      model: this.reportTreeItems,
      onSelectedItemsChange: l(this, g, "f"),
      sortItemsCallback: l(this, f, "f"),
      filterOptions: {
        autoExpand: true,
        hideMatchesAndShowNonMatches: false
      }
    })), i("section", {
      class: "main spacing-body"
    }, i("slot", null)), i("footer", {
      class: "footer dialog-footer-with-border dialog-footer-start spacing-body-inline spacing-body-block-end"
    }, i("gx-ide-status-buttons", {
      errors: this.statusInfo.error.number,
      warnings: this.statusInfo.warning.number,
      successes: this.statusInfo.success.number,
      hideMessage: true,
      compact: true,
      onSelectionChanged: l(this, m, "f")
    }))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/navigation-report" ];
  }
  get el() {
    return a(this);
  }
  static get watchers() {
    return {
      navigationItemsStatusRegExpString: [ "navigationItemsStatusRegExpStringChanged" ],
      navigationItemsCaptionRegExpString: [ "navigationItemsCaptionRegExpStringChanged" ]
    };
  }
};

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

y.style = d;

export { y as gx_ide_navigation_report };
//# sourceMappingURL=p-37812762.entry.js.map