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

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

import { f as r } from "./p-4d330836.js";

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

import { r as n, a as o, I as c } from "./p-2eae8843.js";

import "./p-d42e842b.js";

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

import "lit";

import "lit/directives/when.js";

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

const mapObjectTypeToComboBoxItemModel = t => t.map((t => ({
  value: t.id,
  caption: t.name,
  startImgSrc: t.icon
})));

const d = '.custom-icon-text-wrapper{display:flex;align-items:center;gap:var(--spacing-gap-m)}.warning-error-description{display:flex;align-items:center;gap:var(--spacing-gap-m);padding:var(--spacing-padding-m);max-inline-size:800px;line-height:var(--line-height-spacious)}.warning-error-icon{flex-shrink:0}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;grid-template-columns:max-content 1fr;block-size:100%;overflow:auto}.sidebar{background-color:transparent !important;border-inline-end:var(--section-common-border)}.sidebar::part(expand-button){border-radius:var(--control-border-radius)}gx-ide-select-kb-items{--search-input-max-inline-size:300px;opacity:0;transition:opacity var(--timing-fast)}gx-ide-select-kb-items.sidebar-expanded{opacity:1}ch-tabular-grid.tabular-grid--empty::part(main){overflow:hidden}ch-tabular-grid-rowset-empty{position:relative}.main{display:grid;grid-template-rows:max-content 1fr;grid-row-gap:var(--spacing-gap-l);overflow:auto}.main__header{display:grid}.main__content{position:relative;overflow:auto;display:grid;grid-template-rows:1fr max-content 2fr;grid-row-gap:var(--spacing-gap-l)}.tabular-grid{overflow:auto}.search-filter{display:grid;grid-template-columns:1fr max-content max-content;gap:var(--spacing-gap-l)}.action-buttons{justify-self:flex-end}.filters-grid{display:grid;grid-template-columns:repeat(6, 1fr);grid-template-areas:"from from to to type type" "user user user revision revision revision";padding-block-start:var(--spacing-gap-l)}.filters-container{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--timing-fast)}.filters-container-visible{grid-template-rows:1fr}.filters-container>div{overflow:hidden}.field-from{grid-area:from}.field-to{grid-area:to}.field-type{grid-area:type}.field-user{grid-area:user}.field-revision{grid-area:revision}.commits-grid ch-tabular-grid-cell:is(:nth-child(2)){align-items:start;justify-content:start;min-inline-size:200px}.affected-objects-grid ch-tabular-grid-cell:is(:nth-child(5)){align-items:start;justify-content:start;min-inline-size:200px}';

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

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

var f, m, p, g, b, v, w, y, x, k, M, W, j, z, _, C, T, E, F, D, I, A;

const S = [ "resets/box-sizing", "utils/form--full", "utils/layout", "utils/spacing", "utils/typography", "chameleon/scrollbar", "components/tabular-grid", "components/accordion", "components/sidebar" ];

const $ = class {
  constructor(e) {
    t(this, e);
    f.set(this, void 0);
    m.set(this, []);
    p.set(this, void 0);
    g.set(this, void 0);
    b.set(this, void 0);
    v.set(this, void 0);
    w.set(this, void 0);
    y.set(this, void 0);
    x.set(this, void 0);
    k.set(this, void 0);
    M.set(this, void 0);
    W.set(this, (async t => {
      if (this.selectedVersionChangeCallback) {
        await this.selectedVersionChangeCallback(t);
      }
      await h(this, j, "f").call(this, t[0], true);
    }));
    j.set(this, (async (t, i) => {
      var e;
      this.loading = true;
      const a = {
        search: h(this, b, "f").value ? h(this, b, "f").value : "",
        from: h(this, p, "f").value ? new Date(h(this, p, "f").value) : null,
        to: h(this, v, "f").value ? new Date(h(this, v, "f").value) : null,
        revision: h(this, g, "f").value ? h(this, g, "f").value : "",
        user: h(this, y, "f").value ? h(this, y, "f").value : "",
        type: h(this, w, "f").value === "all" ? "" : h(this, w, "f").value
      };
      try {
        this.objects = await this.loadCallback(a, t, i);
        await h(this, z, "f").call(this, (e = this.objects[0]) === null || e === void 0 ? void 0 : e.id);
      } catch (t) {
        this.objects = [];
        this.historyDetail = null;
        this.selectedRevisionId = null;
      } finally {
        this.loading = false;
      }
    }));
    z.set(this, (async t => {
      if (t) {
        this.historyDetail = await this.loadDetailCallback(t);
        this.historyDetail.title = h(this, I, "f").call(this, this.historyDetail.title);
        this.selectedRevisionId = t;
      } else {
        this.historyDetail = null;
      }
    }));
    _.set(this, (() => {
      if (h(this, k, "f")) {
        h(this, k, "f").addEventListener("contextmenu", (t => {
          t.preventDefault();
          t.stopPropagation();
          h(this, C, "f").call(this, t);
        }));
      }
    }));
    C.set(this, (async t => {
      this.gridContextMenuCallback({
        selection: [ this.selectedRevisionId ],
        clientX: t.clientX,
        clientY: t.clientY
      });
    }));
    T.set(this, (() => {
      this.filtersHidden = !this.filtersHidden;
    }));
    E.set(this, (() => {
      var t;
      const e = ((t = this.objects) === null || t === void 0 ? void 0 : t.length) === 0 || !this.objects;
      return i("ch-tabular-grid", {
        class: {
          "commits-grid": true,
          "tabular-grid": true,
          "tabular-grid--empty": e
        },
        onSelectionChanged: t => {
          this.objects.length > 0 && h(this, z, "f").call(this, t.detail.rowsId[0]);
        },
        ref: t => {
          var i;
          if (t && h(this, k, "f") !== t) {
            u(this, k, t, "f");
            h(this, _, "f").call(this);
            if (this.objects.length > 0) {
              h(this, k, "f").selectRow((i = this.objects[0]) === null || i === void 0 ? void 0 : i.id, true);
            }
          }
        }
      }, i("ch-tabular-grid-columnset", {
        class: "tabular-grid-column-set"
      }, i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").mainGrid.columns.id,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: "max-content"
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").mainGrid.columns.comment,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: "1fr"
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").mainGrid.columns.user,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: "max-content"
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").mainGrid.columns.commitDate,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: "max-content"
      })), this.objects.length > 0 ? i("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, this.objects.map((t => i("ch-tabular-grid-row", {
        rowid: t.id,
        key: t.id,
        class: "tabular-grid-row"
      }, i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, t.id), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, t.comment), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, t.user), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, `${r(t.commitDate, "date-time")}`))))) : i("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, i("ch-tabular-grid-rowset-empty", null, i("gx-ide-empty-state", {
        stateTitle: h(this, f, "f").emptyRevisionsText,
        isAnimated: true
      }))), i("ch-tabular-grid-row", {
        class: "tabular-grid-row"
      }));
    }));
    F.set(this, (() => {
      var t, e;
      const a = this.historyDetail ? this.historyDetail.objects : [];
      const r = ((e = (t = this.historyDetail) === null || t === void 0 ? void 0 : t.objects) === null || e === void 0 ? void 0 : e.length) === 0 || !this.historyDetail;
      return i("ch-tabular-grid", {
        class: {
          "affected-objects-grid": true,
          "tabular-grid": true,
          "tabular-grid--empty": r
        }
      }, i("ch-tabular-grid-columnset", {
        class: "tabular-grid-column-set"
      }, i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").affectedObjectsGrid.columns.name,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: s.tabularGrid.colSize.maxContent
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").affectedObjectsGrid.columns.types,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: s.tabularGrid.colSize.maxContent
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").affectedObjectsGrid.columns.description,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: s.tabularGrid.colSize.auto
      }), i("ch-tabular-grid-column", {
        "column-name": h(this, f, "f").affectedObjectsGrid.columns.action,
        "column-name-position": "text",
        class: "tabular-grid-column",
        settingable: false,
        size: s.tabularGrid.colSize.maxContent
      })), this.historyDetail && this.historyDetail.objects.length > 0 ? i("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, a.map((t => i("ch-tabular-grid-row", {
        class: "tabular-grid-row"
      }, i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, t.name), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, n(t.type)), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, t.description), i("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, o(t.state)))))) : i("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, i("ch-tabular-grid-rowset-empty", null, i("gx-ide-empty-state", {
        stateIconSrc: c.filter,
        stateTitle: h(this, f, "f").emptyHistoryDetailText,
        isAnimated: true
      }))), i("ch-tabular-grid-row", {
        class: "tabular-grid-row"
      }));
    }));
    D.set(this, (() => this.loading && i("div", {
      class: "main__content scrollable"
    }, i("gx-ide-loader", {
      loaderTitle: h(this, f, "f").loader.title,
      show: true,
      description: h(this, f, "f").loader.description
    }))));
    I.set(this, (t => {
      const i = t.split(" - ");
      const e = new Date(i[1]);
      const a = r(e, "date-time");
      return `${i[0]} - ${a} - ${i[2]}`;
    }));
    A.set(this, (async () => {
      this.loading = true;
      await h(this, M, "f").reloadItems();
    }));
    this.historyDetail = undefined;
    this.objects = [];
    this.sidebarExpanded = true;
    this.filtersHidden = true;
    this.loading = true;
    this.selectedRevisionId = undefined;
    this.hasActiveVersion = false;
    this.types = undefined;
    this.itemContextMenuCallback = undefined;
    this.gridContextMenuCallback = undefined;
    this.loadVersionsCallback = undefined;
    this.loadCallback = undefined;
    this.loadDetailCallback = undefined;
    this.selectedVersionChangeCallback = undefined;
  }
  async componentWillLoad() {
    u(this, f, await l.getComponentStrings(this.el), "f");
    u(this, m, mapObjectTypeToComboBoxItemModel(this.types), "f");
  }
  async componentDidLoad() {
    h(this, x, "f").addEventListener("expandedChange", (t => {
      this.sidebarExpanded = t.detail;
    }));
  }
  async reload() {
    await h(this, A, "f").call(this);
  }
  render() {
    var t;
    return i(e, {
      class: "widget"
    }, i("ch-theme", {
      model: S
    }), i("ch-sidebar", {
      ref: t => u(this, x, t, "f"),
      class: "sidebar",
      expanded: this.sidebarExpanded,
      expandButtonCollapseAccessibleName: h(this, f, "f").sidebar.collapseAriaLabel,
      expandButtonExpandAccessibleName: h(this, f, "f").sidebar.expandAriaLabel,
      showExpandButton: true
    }, i("gx-ide-select-kb-items", {
      class: {
        "sidebar-expanded": this.sidebarExpanded,
        "has-active-version": this.hasActiveVersion
      },
      checkboxType: "none",
      loadItemsCallback: () => this.loadVersionsCallback(),
      expandOnClick: false,
      selectionChanged: h(this, W, "f"),
      itemContextMenuCallback: t => this.itemContextMenuCallback(t),
      ref: t => u(this, M, t, "f")
    })), i("main", {
      class: "main spacing-body-block-start spacing-body-inline"
    }, i("div", {
      class: "main__header"
    }, i("div", {
      class: "search-filter"
    }, i("div", {
      class: "field field-inline"
    }, i("label", {
      class: "label",
      htmlFor: "search"
    }, h(this, f, "f").filters.search), i("ch-edit", {
      value: "",
      class: "input",
      startImgSrc: c.search,
      part: "search",
      id: "search",
      ref: t => u(this, b, t, "f")
    })), i("button", {
      id: "filter-toggle-button",
      class: "button-secondary button-icon-only",
      "aria-label": h(this, f, "f").searchFilter.filterAriaLabel,
      "aria-expanded": this.filtersHidden ? "false" : "true",
      "aria-controls": "filters-container",
      onClick: () => h(this, T, "f").call(this)
    }, i("ch-image", {
      class: "icon-m",
      src: c.filter
    })), i("button", {
      class: "button-secondary button-icon-only",
      "aria-label": h(this, f, "f").searchFilter.reloadAriaLabel,
      onClick: () => h(this, A, "f").call(this),
      part: h(this, f, "f").searchFilter.reloadAriaLabel
    }, i("ch-image", {
      class: "icon-m",
      src: c.refresh
    }))), i("div", {
      id: "filters-container",
      "aria-labelledby": "filter-toggle-button",
      class: {
        "filters-container-visible": !this.filtersHidden,
        "filters-container": true
      },
      inert: this.filtersHidden,
      hidden: this.filtersHidden
    }, i("div", null, i("div", {
      class: "filters-grid field-group"
    }, i("div", {
      class: "field field-block field-from"
    }, i("label", {
      class: "label",
      htmlFor: "from"
    }, h(this, f, "f").filters.from), i("ch-edit", {
      value: "",
      class: "input",
      type: "date",
      part: "from",
      id: "from",
      ref: t => u(this, p, t, "f")
    })), i("div", {
      class: "field field-block field-to"
    }, i("label", {
      class: "label",
      htmlFor: "to"
    }, h(this, f, "f").filters.to), i("ch-edit", {
      value: "",
      class: "input",
      type: "date",
      id: "to",
      ref: t => u(this, v, t, "f")
    })), i("div", {
      class: "field field-block field-type"
    }, i("label", {
      class: "label",
      htmlFor: "type"
    }, h(this, f, "f").filters.type), i("ch-combo-box-render", {
      accessibleName: "types",
      class: "combo-box",
      part: "type",
      model: h(this, m, "f"),
      value: (t = h(this, m, "f")[0]) === null || t === void 0 ? void 0 : t.value,
      ref: t => u(this, w, t, "f")
    })), i("div", {
      class: "field field-block field-user"
    }, i("label", {
      class: "label",
      htmlFor: "user"
    }, h(this, f, "f").filters.user), i("ch-edit", {
      value: "",
      part: "user",
      class: "input",
      id: "user",
      ref: t => u(this, y, t, "f")
    })), i("div", {
      class: "field field-block field-revision"
    }, i("label", {
      class: "label",
      htmlFor: "revision"
    }, h(this, f, "f").filters.revision), i("ch-edit", {
      value: "",
      part: "revision",
      class: "input",
      id: "revision",
      ref: t => u(this, g, t, "f")
    })))))), h(this, D, "f").call(this), !this.loading && i("div", {
      class: "main__content scrollable"
    }, h(this, E, "f").call(this), i("div", {
      class: "field field-block"
    }, i("label", {
      class: "label",
      htmlFor: "comment-area"
    }, this.historyDetail ? this.historyDetail.title : null), i("ch-edit", {
      class: "input comment-text-area",
      value: this.historyDetail ? this.historyDetail.comment : null,
      multiline: true,
      autoGrow: true,
      readonly: true,
      part: "comment-area",
      id: "comment-area"
    })), h(this, F, "f").call(this))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/team-dev-history" ];
  }
  get el() {
    return a(this);
  }
};

f = new WeakMap, m = new WeakMap, p = new WeakMap, g = new WeakMap, b = new WeakMap, 
v = new WeakMap, w = new WeakMap, y = new WeakMap, x = new WeakMap, k = new WeakMap, 
M = new WeakMap, W = new WeakMap, j = new WeakMap, z = new WeakMap, _ = new WeakMap, 
C = new WeakMap, T = new WeakMap, E = new WeakMap, F = new WeakMap, D = new WeakMap, 
I = new WeakMap, A = new WeakMap;

$.style = d;

export { $ as gx_ide_team_dev_history };
//# sourceMappingURL=p-c2f2d79f.entry.js.map