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

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

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

import "lit";

import "lit/directives/when.js";

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

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

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

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

import { F as c } from "./p-13feb5cf.js";

// - - - - - - - - - - - -
// Data Mappings
// - - - - - - - - - - - -
// ch-combo-box-render
const mapObjectTypeToComboBoxItemModel = t => t.map((t => ({
  value: t.id,
  caption: t.name
})));

const mapCategoryToComboBoxItemModel = t => t.map((t => ({
  value: t.id,
  caption: t.label
})));

const d = 'button.button-secondary{border-color:var(--color-border-neutral-default)}:host{block-size:100%;display:grid;grid-template-rows:auto 1fr auto;overflow:auto}.section{display:contents}.filter-layout{grid-template:"pattern type" "category module" "modified modified";grid-template-columns:1fr 1fr}.pattern{grid-area:pattern}.type{grid-area:type}.category{grid-area:category}.module{grid-area:module}.modified-accordion{grid-area:modified;display:flex;flex-direction:column}.field-group-modified{grid-template-columns:1fr 1fr 1fr}gx-ide-container::part(content){display:grid}ch-tabular-grid{overflow:auto}.tabular-grid-object-selector ch-tabular-grid-cell:is(:nth-child(5)){align-items:start;justify-content:start;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-inline-size:0}.objects-count{display:grid;grid-template-columns:1fr 1fr;border-block-start:1px solid var(--color-border-surface-on-elevation-3)}.objects-selected,.objects-matching{padding-block-end:8px}ch-tabular-grid-rowset-empty{position:relative}ch-tabular-grid.empty-result::part(main){overflow:hidden}input::-webkit-datetime-edit-fields-wrapper{padding:none}';

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

var u, p, b, m, g, w, y, v, k, M, W, x, j, T, C, D, z, $, E, F, I, P, S, N, L, _, K, V, A, B;

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

const R = l({
  category: "window-tools",
  name: "filter",
  colorType: "on-surface"
});

const q = l({
  category: "system",
  name: "user",
  colorType: "on-surface"
});

const G = [ {
  id: "modified",
  caption: "Modified",
  expanded: false
} ];

let J = null;

const O = class {
  constructor(s) {
    t(this, s);
    u.set(this, void 0);
    p.set(this, e(`./gx-ide-assets/object-selector/shortcuts.json`));
    b.set(this, null);
    /* References needed to collect data */    m.set(this, void 0);
    g.set(this, void 0);
    w.set(this, void 0);
    y.set(this, void 0);
    v.set(this, void 0);
    k.set(this, void 0);
    M.set(this, void 0);
    W.set(this, void 0);
    x.set(this, void 0);
    j.set(this, (() => {
      this.cancelCallback();
    }));
    T.set(this, (t => {
      if (t.key === "Enter") {
        h(this, P, "f").call(this, t);
      }
    }));
    C.set(this, (() => {
      h(this, W, "f").selectAllRows(false);
    }));
    D.set(this, (t => {
      const e = h(this, u, "f");
      if (t === "selected") {
        if (this.selectedObjectsIdsArray.length === 0) {
          return e.objCount.selected.none;
        }
        if (this.selectedObjectsIdsArray.length === 1) {
          return `1 ${e.objCount.selected.one}`;
        }
        return `${this.selectedObjectsIdsArray.length} ${e.objCount.selected.many}`;
      }
      // type === "matching"
            if (this.objects.length === 0) {
        return e.objCount.matching.none;
      }
      if (this.objects.length === 1) {
        return `1 ${e.objCount.matching.one}`;
      }
      return `${this.objects.length} ${e.objCount.matching.many}`;
    }));
    z.set(this, (() => {
      const t = new Date;
      const e = t.toISOString().split("T")[0];
      const i = t.toISOString().split("T")[1].slice(0, 5);
 // Only take 'HH:MM' part
            return `${e}T${i}`;
    }));
    $.set(this, (t => {
      this.modifiedAfterValue = t.detail;
      if (this.modifiedAfterValue !== c.DATE_TIME || this.modifiedAfterValue === c.DATE_TIME && h(this, M, "f").value) {
        // if "modified" is "after date/time" only refresh ui if date/time is valid.
        h(this, S, "f").call(this);
      }
    }));
    E.set(this, (t => {
      this.selectedObjectsIdsArray = t.detail.rowsId;
    }));
    F.set(this, (t => {
      // just prevent keypress propagation
      if (t.key === "Enter") {
        t.stopPropagation();
      }
    }));
    I.set(this, (() => {
      this.newObjectCallback();
    }));
    P.set(this, (t => {
      t.stopPropagation();
      this.openSelectionCallback(this.selectedObjectsIdsArray);
    }));
    S.set(this, (() => {
      var t, e, i, s, a, l;
      /* 'modified' checkbox, should only be considered if 'date' || 'user' */      const o = h(this, v, "f").value;
      const r = (e = (t = h(this, k, "f")) === null || t === void 0 ? void 0 : t.value) === null || e === void 0 ? void 0 : e.trim();
      const n = {
        pattern: (i = h(this, m, "f")) === null || i === void 0 ? void 0 : i.value,
        type: h(this, g, "f").value,
        category: h(this, w, "f").value,
        module: (a = (s = h(this, y, "f")) === null || s === void 0 ? void 0 : s.value) === null || a === void 0 ? void 0 : a.id,
        modifiedAfter: o ? o : null,
        modifiedBy: r ? r : null,
        modifiedDate: o === c.DATE_TIME ? new Date((l = h(this, M, "f")) === null || l === void 0 ? void 0 : l.value) : null
      };
      this.loading = true;
      this.objects = [];
      this.loadCallback(n).then((t => {
        if (t) {
          this.objects = h(this, B, "f").call(this, t);
        }
        this.selectedObjectsIdsArray = [];
        h(this, C, "f").call(this);
        this.loading = false;
      }));
    }));
    N.set(this, (() => i("header", {
      class: "dialog-header spacing-body-inline spacing-body-block-start"
    }, i("form", {
      class: "field-group filter-layout"
    }, i("div", {
      class: "field field-block pattern"
    }, i("label", {
      // pattern
      class: "label",
      htmlFor: "pattern"
    }, h(this, u, "f").filter.pattern), i("ch-edit", {
      accessibleName: h(this, u, "f").filter.pattern,
      debounce: r.inputDebounce,
      class: "input",
      part: "filter-pattern",
      id: "pattern",
      name: "pattern",
      value: this.patternValue,
      mode: "text",
      ref: t => f(this, m, t, "f"),
      onInput: h(this, S, "f")
    })), i("div", {
      class: "field field-block type"
    }, i("label", {
      // type
      class: "label",
      htmlFor: "type"
    }, h(this, u, "f").filter.type), i("ch-combo-box-render", {
      accessibleName: h(this, u, "f").filter.type,
      class: "combo-box",
      disabled: !this.types,
      value: this.defaultType,
      part: "filter-type",
      id: "type",
      model: mapObjectTypeToComboBoxItemModel(this.types),
      ref: t => f(this, g, t, "f"),
      onInput: h(this, S, "f")
    })), i("div", {
      class: "field field-block category"
    }, i("label", {
      // category
      class: "label",
      htmlFor: "category"
    }, h(this, u, "f").filter.category), i("ch-combo-box-render", {
      id: "category",
      class: "combo-box",
      accessibleName: h(this, u, "f").filter.category,
      disabled: !this.categories,
      model: mapCategoryToComboBoxItemModel(this.categories),
      value: this.defaultCategory,
      part: "filter-category",
      onInput: this.categories && h(this, S, "f"),
      ref: t => f(this, w, t, "f")
    })), i("gx-ide-entity-selector", {
      // module
      class: "module",
      id: "module",
      value: this.defaultModule,
      ref: t => f(this, y, t, "f"),
      labelCaption: h(this, u, "f").filter.module,
      labelPosition: "block-start",
      onValueChanged: h(this, S, "f"),
      defaultValue: this.defaultModule,
      selectEntityCallback: this.selectModuleCallback
    }), i("ch-accordion-render", {
      // modified
      class: "accordion-outlined modified-accordion",
      model: G
    }, i("div", {
      slot: "modified",
      class: "spacing-body"
    }, i("div", {
      class: "field-group field-group-modified"
    }, i("div", {
      class: "field field-block after"
    }, i("label", {
      // after
      class: "label",
      htmlFor: "after-type"
    }, h(this, u, "f").filter.after), i("ch-combo-box-render", {
      class: "combo-box",
      value: this.modifiedAfterValue,
      part: "filter-after-type",
      id: "after-type",
      model: h(this, b, "f"),
      ref: t => f(this, v, t, "f"),
      onInput: h(this, $, "f")
    })), i("div", {
      class: "field field-block"
    }, i("label", {
      // user
      class: "label",
      htmlFor: "user-name"
    }, h(this, u, "f").filter.user), i("ch-edit", {
      class: "input",
      part: "filter-user",
      value: this.patternValue,
      ref: t => f(this, k, t, "f"),
      id: "user-name",
      name: "userName",
      startImgSrc: q,
      onInput: h(this, S, "f")
    })), i("div", {
      class: "field field-block"
    }, i("label", {
      // date
      class: {
        label: true,
        "label--disabled": this.modifiedAfterValue !== "afterDateTime"
      },
      htmlFor: "modified-date"
    }, h(this, u, "f").filter.dateTime), i("input", {
      type: "datetime-local",
      class: "input input-date-time",
      id: "modified-date",
      name: "modifiedDate",
      part: "filter-pattern",
      value: this.patternValue,
      max: J,
      ref: t => f(this, M, t, "f"),
      disabled: this.modifiedAfterValue !== "afterDateTime",
      onInput: h(this, S, "f")
    })))))))));
    L.set(this, (() => i("footer", {
      class: "footer dialog-footer-space-between"
    }, i("div", {
      class: "dialog-footer dialog-footer-space-between objects-count spacing-body-inline",
      slot: "footer-above"
    }, i("p", {
      class: "body-regular-s objects-selected",
      part: "objects-selected"
    }, h(this, D, "f").call(this, "selected")), i("p", {
      class: "body-regular-s objects-matching",
      part: "objects-matching"
    }, h(this, D, "f").call(this, "matching"))), i("div", {
      class: "dialog-footer-with-border dialog-footer-space-between spacing-body-inline spacing-body-block-end"
    }, i("button", {
      // button new object
      class: "button-secondary",
      part: "button button-new",
      onClick: !this.loading ? h(this, I, "f") : undefined,
      disabled: this.loading
    }, h(this, u, "f").footer.btnNew), i("div", {
      class: "end buttons-spacer"
    }, i("button", {
      // button cancel
      class: "button-secondary",
      part: "button button-cancel",
      onClick: h(this, j, "f")
    }, h(this, u, "f").footer.btnCancel), this.multiSelection ? i("button", {
      class: "button-secondary",
      onClick: h(this, K, "f"),
      part: "button button-select-all"
    }, h(this, u, "f").footer.btnSelectAll) : null, i("button", {
      // button confirm
      class: "button-primary",
      part: "button button-confirm",
      onClick: h(this, P, "f"),
      disabled: this.loading
    }, h(this, u, "f").footer.btnConfirm))))));
    _.set(this, (() => i("ch-tabular-grid", {
      class: {
        "tabular-grid": true,
        "tabular-grid-object-selector": true,
        "empty-result": this.objects.length === 0
      },
      rowSelectionMode: this.multiSelection ? "multiple" : "single",
      ref: t => f(this, W, t, "f"),
      part: "ch-grid-objects",
      onKeyDown: h(this, T, "f"),
      onSelectionChanged: h(this, E, "f"),
      onDblClick: h(this, P, "f")
    }, i("ch-tabular-grid-columnset", {
      class: "tabular-grid-column-set"
    }, i("ch-tabular-grid-column", {
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.name,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.type,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.module,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.description,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.commonDouble,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.modifiedDate,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    }), i("ch-tabular-grid-column", {
      "column-name": h(this, u, "f").tableHead.importDate,
      "column-name-position": "text",
      settingable: false,
      sortable: false,
      size: r.tabularGrid.colSize.maxContent,
      class: "tabular-grid-column"
    })), this.objects.length ? 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"
    }, i("ch-image", {
      src: t.icon,
      class: "icon-s"
    })), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t.name), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t.type), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t.module), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t.description), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, `${n(t.modifiedDate, "date-time")}`), i("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, `${n(t.importDate, "date-time")}`))))) : i("ch-tabular-grid-rowset", {
      class: "tabular-grid-rowset"
    }, i("ch-tabular-grid-rowset-empty", null, this.loader && this.loading ? i("gx-ide-loader", {
      loaderTitle: h(this, u, "f").loader.title,
      show: true
    }) : i("gx-ide-empty-state", {
      stateIconSrc: R,
      stateTitle: h(this, u, "f").emptyState.title
    }))))));
    K.set(this, (() => {
      h(this, W, "f").selectAllRows();
    }));
    V.set(this, (() => {
      this.modifiedAfterValue = c.NONE;
    }));
    A.set(this, (() => {
      f(this, b, [ {
        caption: h(this, u, "f").filter.afterNone,
        value: c.NONE
      }, {
        caption: h(this, u, "f").filter[c.DATE_TIME],
        value: c.DATE_TIME
      }, {
        caption: h(this, u, "f").filter[c.IMPORT],
        value: c.IMPORT
      }, {
        caption: h(this, u, "f").filter[c.LAST_BUILD],
        value: c.LAST_BUILD
      } ], "f");
    }));
    B.set(this, (t => t.sort(((t, e) => {
      const i = t.name.toLowerCase(), s = e.name.toLowerCase();
      if (i < s) {
        return -1;
      }
      if (i > s) {
        return 1;
      }
      return 0;
    }))));
    this.filterModified = false;
    this.loading = false;
    this.modifiedAfterValue = undefined;
    this.objects = [];
    this.selectedObjectsIdsArray = [];
    this.cancelCallback = undefined;
    this.categories = undefined;
    this.defaultCategory = undefined;
    this.defaultModule = undefined;
    this.defaultType = undefined;
    this.loader = false;
    this.loadCallback = undefined;
    this.multiSelection = false;
    this.newObjectCallback = undefined;
    this.openSelectionCallback = undefined;
    this.patternValue = undefined;
    this.selectModuleCallback = undefined;
    this.types = undefined;
  }
  async connectedCallback() {
    J = h(this, z, "f").call(this);
  }
  async componentWillLoad() {
    f(this, u, await o.getComponentStrings(this.el), "f");
    h(this, A, "f").call(this);
    h(this, V, "f").call(this);
  }
  componentDidLoad() {
    h(this, S, "f").call(this);
    h(this, m, "f").focus();
  }
  componentDidRender() {}
  /**
     * Suspends or reactivates the shortcuts
     */  async suspendShortcuts(t) {
    if (t) {
      h(this, x, "f").suspend = true;
    } else {
      h(this, x, "f").suspend = false;
    }
  }
  /**
     * Validate necessary data input
     */  async validate() {
    const t = true;
    return t;
  }
  render() {
    return i(s, {
      onKeyPress: h(this, F, "f"),
      class: "widget"
    }, i("ch-theme", {
      model: H
    }), i("ch-shortcuts", {
      src: h(this, p, "f"),
      ref: t => f(this, x, t, "f")
    }), i("section", {
      class: "section"
    }, h(this, N, "f").call(this), h(this, _, "f").call(this), h(this, L, "f").call(this)));
  }
  static get delegatesFocus() {
    return true;
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/object-selector" ];
  }
  get el() {
    return a(this);
  }
};

u = new WeakMap, p = new WeakMap, b = new WeakMap, m = new WeakMap, g = new WeakMap, 
w = new WeakMap, y = new WeakMap, v = new WeakMap, k = new WeakMap, M = new WeakMap, 
W = new WeakMap, x = new WeakMap, j = new WeakMap, T = new WeakMap, C = new WeakMap, 
D = new WeakMap, z = new WeakMap, $ = new WeakMap, E = new WeakMap, F = new WeakMap, 
I = new WeakMap, P = new WeakMap, S = new WeakMap, N = new WeakMap, L = new WeakMap, 
_ = new WeakMap, K = new WeakMap, V = new WeakMap, A = new WeakMap, B = new WeakMap;

O.style = d;

export { O as gx_ide_object_selector };
//# sourceMappingURL=p-00705e1c.entry.js.map