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

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

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

import "lit";

import "lit/directives/when.js";

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

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

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

import { h as n, m as o } from "./p-9663f418.js";

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

const c = 'button.button-secondary{border-color:var(--color-border-neutral-default)}:host{container-type:inline-size;display:grid;block-size:100%;overflow:auto;grid-template-rows:max-content 1fr max-content}.section{display:contents}.header{grid-template-areas:"name module-folder" "advanced-filter advanced-filter";grid-template-columns:1fr 1fr;grid-auto-rows:max-content max-content}.name{grid-area:name}.module-folder{grid-area:module-folder}.advanced-filter{grid-area:advanced-filter}.advanced-filter__container{display:grid;grid-auto-rows:max-content}.advanced-filter__first-row{grid-template-columns:1fr 1fr}.advanced-filter__second-row{grid-template-columns:1fr 1fr 1fr}.advanced-filter .all-descendants__modified{display:flex;flex-direction:row;align-items:center;block-size:32px;gap:var(--spacing-gap-xl);align-self:self-end}.field-date{grid-template-areas:"label-date-time label-date-time" "input-date-time icon-clear-date-time";grid-template-columns:1fr max-content;column-gap:var(--spacing-gap-xs)}.label-date-time{display:flex;align-items:center;gap:var(--spacing-gap-m);grid-area:label-date-time}.input-date-time{block-size:32px;grid-area:input-date-time}.icon-clear-date-time{grid-area:icon-clear-date-time}.tabular-grid{overflow:auto;inline-size:100%;border-inline-end:var(--section-common-border)}.tabular-grid.empty::part(main),.tabular-grid.loading::part(main){overflow:hidden}ch-tabular-grid-rowset-empty{position:relative}.main__files-container{display:grid;grid-template-columns:repeat(4, 1fr);gap:var(--spacing-gap-m);position:relative;z-index:1}.hiChar{color:var(--color-text-primary-default);filter:brightness(1.3)}.tabular-grid ch-tabular-grid-cell:is(:nth-child(4)){align-items:start;justify-content:start;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-inline-size:0}.tabular-grid-cell-description{min-inline-size:max-content !important}.hiChar{color:var(--color-text-primary-default);filter:brightness(1.3)}';

var h = 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 f = 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 u, m, p, b, g, w, v, k, y, x, M, W, _, C, z, N, j, T, D, E, H, I, V, F, A, L, P, B, S, $, O, U, X, Y, q, G;

const J = [ "resets/box-sizing", "components/button", "components/checkbox", "components/combo-box", "components/accordion", "components/edit", "components/icon", "components/tooltip", "components/tabular-grid", "utils/form", "utils/layout", "utils/typography", "utils/spacing" ];

const K = a({
  category: "system",
  name: "close",
  colorType: "interactive"
});

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

const R = a({
  category: "system",
  name: "information",
  colorType: "on-surface"
});

const Z = "advanced-filter";

const tt = "afterDateTime";

const et = "afterLastBuild";

const it = "afterImport";

const st = "checked";

const at = "unchecked";

const lt = class {
  constructor(i) {
    t(this, i);
    u.set(this, void 0);
    m.set(this, []);
    // Filter Values
        p.set(this, void 0);
    b.set(this, void 0);
    // Advanced Filter Values
        g.set(this, void 0);
    w.set(this, void 0);
    v.set(this, void 0);
    k.set(this, void 0);
    // Other
        y.set(this, []);
    x.set(this, void 0);
    M.set(this, (() => {
      h(this, p, "", "f");
      h(this, b, Object.assign({}, this.defaultModule), "f");
      h(this, g, "", "f");
      h(this, w, this.defaultCategory || (this.categoriesComboBoxModel && this.categoriesComboBoxModel.length > 0 ? this.categoriesComboBoxModel[0].value : ""), "f");
      h(this, v, at, "f");
      this.afterValue = this.filterAfterComboBoxModel && this.filterAfterComboBoxModel.length > 0 ? this.filterAfterComboBoxModel[0].value : tt;
      h(this, k, "", "f");
      this.dateTimeValue = undefined;
    }));
    W.set(this, (t => {
      h(this, v, t.detail === st ? st : at, "f");
      f(this, A, "f").call(this);
    }));
    _.set(this, (t => {
      h(this, y, t.detail.rowsId, "f");
      this.selectionChangeCallback(f(this, y, "f"));
    }));
    C.set(this, (() => {
      f(this, O, "f").call(this);
    }));
    z.set(this, (t => {
      t.preventDefault();
      t.stopPropagation();
      this.contextMenuCallback({
        selection: t.detail.selectedRowsId,
        clientX: t.detail.clientX,
        clientY: t.detail.clientY
      });
    }));
    N.set(this, (() => {
      f(this, x, "f").addEventListener("selectionChanged", f(this, _, "f"));
      f(this, x, "f").addEventListener("rowDoubleClicked", f(this, C, "f"));
      f(this, x, "f").addEventListener("rowContextMenu", f(this, z, "f"));
    }));
    j.set(this, (async t => {
      h(this, w, t.detail, "f");
      f(this, A, "f").call(this);
    }));
    T.set(this, (() => {
      this.dateTimeValue = undefined;
    }));
    D.set(this, (t => {
      this.dateTimeValue = t.detail;
      f(this, A, "f").call(this);
    }));
    E.set(this, (() => {
      this.deleteSelectionCallback(f(this, y, "f"));
    }));
    H.set(this, (() => {
      if (f(this, x, "f") && typeof f(this, x, "f").selectAllRows === "function") {
        f(this, x, "f").selectAllRows(false);
      }
    }));
    I.set(this, ((t, i) => {
      const s = new Date(i);
      if (s >= t) {
        // Object modifed date matches with filter date, or was modified after that date.
        // Highlight to show that it matches.
        return e("span", {
          class: "hiChar"
        }, f(this, F, "f").call(this, t));
      } else {
        return f(this, F, "f").call(this, t);
      }
    }));
    V.set(this, (t => {
      this.afterValue = t.detail;
      f(this, A, "f").call(this);
    }));
    F.set(this, (t => d(t, "date-time-short")));
    A.set(this, (() => {
      f(this, X, "f").call(this);
      const t = f(this, b, "f") ? f(this, b, "f").id : "";
      const e = {
        name: f(this, p, "f"),
        searchContents: f(this, g, "f"),
        category: f(this, w, "f"),
        parent: t,
        allDescendants: f(this, v, "f") === st,
        modifiedAfter: this.showModified ? this.afterValue : undefined,
        modifiedBy: this.showModified ? f(this, k, "f") : undefined,
        modifiedDate: this.showModified ? new Date(this.dateTimeValue) : undefined
      };
      this.loadCallback(e).then((t => {
        this.objects = t;
        h(this, y, [], "f");
        if (f(this, x, "f")) {
          f(this, H, "f").call(this);
        }
        this.isLoading = false;
      }));
    }));
    L.set(this, (() => [ e("div", {
      // Name
      class: "field field-block field-name"
    }, e("label", {
      class: "label",
      htmlFor: "name"
    }, f(this, u, "f").filter.name), e("ch-edit", {
      id: "name",
      class: "input",
      value: f(this, p, "f"),
      onInput: f(this, S, "f"),
      part: "filter-files",
      debounce: r.inputDebounce,
      disabled: this.isLoading
    })), e("div", {
      // Module
      class: "field field-block field-module-folder"
    }, e("label", {
      class: "label",
      htmlFor: "module-folder"
    }, f(this, u, "f").filter.moduleFolder), e("gx-ide-entity-selector", {
      part: "filter-module-folder",
      id: "module/folder",
      labelPosition: "none",
      value: f(this, b, "f"),
      defaultValue: this.defaultModule,
      selectEntityCallback: this.selectModuleCallback,
      onValueChanged: f(this, B, "f"),
      disabled: this.isLoading
    })), e("ch-accordion-render", {
      class: "accordion-outlined advanced-filter",
      model: f(this, m, "f")
    }, e("div", {
      slot: Z,
      class: "spacing-body field-group advanced-filter__container"
    }, this.showSearchContents && e("div", {
      // Search contents
      class: "field field-block field-search-contents"
    }, e("label", {
      class: "label",
      htmlFor: "filter-content"
    }, f(this, u, "f").filter.content), e("ch-edit", {
      id: "filter-content",
      class: "input",
      onInput: f(this, U, "f"),
      part: "filter-content"
    })), e("div", {
      class: "field-group advanced-filter__first-row"
    }, e("div", {
      // Category
      class: "field field-block field-category"
    }, e("label", {
      class: "label",
      htmlFor: "filter-category"
    }, f(this, u, "f").filter.category), e("ch-combo-box-render", {
      id: "filter-category",
      class: "combo-box disabled",
      value: f(this, w, "f"),
      disabled: !this.categories || this.isLoading,
      model: this.categoriesComboBoxModel,
      part: "filter-category",
      onInput: f(this, j, "f")
    })), e("div", {
      // All descendants / Modified
      class: "all-descendants__modified field field-inline"
    }, e("ch-checkbox", {
      // All descendants
      class: "checkbox",
      caption: f(this, u, "f").filter.allDescendants,
      checkedValue: st,
      unCheckedValue: at,
      value: f(this, v, "f"),
      onInput: f(this, W, "f"),
      part: "filter-all-descendants",
      disabled: this.isLoading
    }), e("ch-checkbox", {
      // Modified
      class: "checkbox align-center",
      caption: f(this, u, "f").filter.modified,
      checkedValue: st,
      unCheckedValue: at,
      value: this.showModified,
      onInput: f(this, q, "f"),
      part: "filter-modified"
    }))), this.showModified === st && e("div", {
      class: "field-group advanced-filter__second-row"
    }, e("div", {
      // After
      class: "field field-block field-after"
    }, e("label", {
      class: "label",
      htmlFor: "filter-after-type"
    }, f(this, u, "f").filter.after), e("ch-combo-box-render", {
      id: "filter-after-type",
      class: "combo-box",
      value: this.afterValue,
      model: this.filterAfterComboBoxModel,
      onInput: f(this, V, "f"),
      part: "filter-after-type",
      disabled: this.isLoading
    })), e("div", {
      // User
      class: "field field-block field-user"
    }, e("label", {
      class: "label",
      htmlFor: "filter-user"
    }, f(this, u, "f").filter.user), e("ch-edit", {
      id: "filter-user",
      class: "input",
      value: f(this, k, "f"),
      onInput: f(this, Y, "f"),
      part: "filter-user",
      debounce: r.inputDebounce,
      disabled: this.isLoading
    })), this.afterValue === tt && e("div", {
      // Date/Time
      class: {
        "field field-block field-date": true,
        hide: this.afterValue !== tt
      }
    }, e("label", {
      class: "label label-date-time",
      htmlFor: "filter-date-time"
    }, f(this, u, "f").filter.dateTime, e("ch-image", {
      class: "icon-s icon-clear-date-time",
      src: R
    }), e("ch-tooltip", {
      class: "tooltip",
      actionElement: null,
      blockAlign: "outside-start",
      inlineAlign: "inside-start",
      delay: r.tooltipSettings.delay
    }, f(this, u, "f").filter.dateTimeTooltip)), e("ch-edit", {
      id: "filter-date-time",
      type: "datetime-local",
      class: "input input-date-time",
      value: this.dateTimeValue,
      onInput: f(this, D, "f"),
      part: "filter-date-time",
      disabled: this.isLoading
    }), e("button", {
      class: "button-tertiary button-icon-only",
      onClick: f(this, T, "f"),
      disabled: this.isLoading
    }, e("ch-image", {
      class: "icon-m",
      src: K,
      type: "mask"
    })))))) ]));
    P.set(this, (() => {
      var t;
      const i = !this.objects.length;
      return e("ch-tabular-grid", {
        ref: t => h(this, x, t, "f"),
        class: {
          "tabular-grid": true,
          loading: this.isLoading,
          empty: this.objects.length === 0
        },
        rowSelectionMode: "multiple",
        part: "ch-grid-files"
      }, e("ch-tabular-grid-columnset", {
        class: "tabular-grid-column-set"
      }, e("ch-tabular-grid-column", {
        columnName: "",
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.name,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.module,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), this.gridColumnsVisibility.description && e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.description,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.auto,
        class: "tabular-grid-column"
      }), this.gridColumnsVisibility.modifiedDate && e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.modifiedDate,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), this.gridColumnsVisibility.lastUser && e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.lastUser,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), this.gridColumnsVisibility.importDate && e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.importDate,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      }), this.gridColumnsVisibility.lastBuildDate && e("ch-tabular-grid-column", {
        columnName: f(this, u, "f").tableHead.lastBuildDate,
        columnNameHidden: false,
        settingable: false,
        sortable: false,
        size: r.tabularGrid.colSize.maxContent,
        class: "tabular-grid-column"
      })), !i ? e("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, (t = this.objects) === null || t === void 0 ? void 0 : t.map((t => {
        var i;
        return e("ch-tabular-grid-row", {
          rowid: t.id,
          class: "tabular-grid-row"
        }, e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, e("ch-image", {
          src: t.icon
        })), e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, n(t.name.toLowerCase(), f(this, p, "f").toLowerCase())), e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, t.parent), this.gridColumnsVisibility.description && e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell tabular-grid-cell-description"
        }, t.description), this.gridColumnsVisibility.modifiedDate && e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, f(this, I, "f").call(this, t.modifiedDate, this.dateTimeValue)), this.gridColumnsVisibility.lastUser && e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, n((i = t.lastUser) === null || i === void 0 ? void 0 : i.toLowerCase(), f(this, k, "f"))), this.gridColumnsVisibility.importDate && e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, n(t.importDate ? f(this, F, "f").call(this, t.importDate) : "", f(this, p, "f"))), this.gridColumnsVisibility.lastBuildDate && e("ch-tabular-grid-cell", {
          class: "tabular-grid-cell"
        }, n(t.lastBuildDate ? f(this, F, "f").call(this, t.lastBuildDate) : "", f(this, p, "f"))));
      }))) : e("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, e("ch-tabular-grid-rowset-empty", null, this.isLoading ? e("gx-ide-loader", {
        loaderTitle: f(this, u, "f").loader.title,
        description: f(this, u, "f").loader.description,
        show: true
      }) : e("gx-ide-empty-state", {
        isAnimated: true,
        stateIconSrc: Q,
        stateTitle: f(this, u, "f").emptyState.title
      }))));
    }));
    B.set(this, (t => {
      h(this, b, t.detail, "f");
      f(this, A, "f").call(this);
    }));
    S.set(this, (t => {
      h(this, p, t.detail, "f");
      f(this, A, "f").call(this);
    }));
    $.set(this, (() => {
      this.newFileCallback();
    }));
    O.set(this, (() => {
      this.openSelectionCallback(f(this, y, "f"));
    }));
    U.set(this, (t => {
      h(this, g, t.detail, "f");
      f(this, A, "f").call(this);
    }));
    X.set(this, (() => {
      // Only clear if no objects or first load
      if (!this.objects || this.objects.length === 0) {
        this.objects = [];
      }
      this.isLoading = true;
    }));
    Y.set(this, (t => {
      h(this, k, t.detail, "f");
      f(this, A, "f").call(this);
    }));
    q.set(this, (t => {
      this.showModified = t.detail;
    }));
    G.set(this, (() => {
      if (f(this, x, "f") && typeof f(this, x, "f").selectAllRows === "function") {
        f(this, x, "f").selectAllRows();
      }
    }));
    this.afterValue = undefined;
    this.categoriesComboBoxModel = [];
    this.dateTimeValue = undefined;
    this.isLoading = true;
    this.filterAfterComboBoxModel = undefined;
    this.showModified = st;
    this.objects = [];
    this.categories = undefined;
    this.contextMenuCallback = undefined;
    this.defaultCategory = undefined;
    this.defaultModule = undefined;
    this.deleteSelectionCallback = undefined;
    this.gridColumnsVisibility = {
      description: true,
      importDate: true,
      lastBuildDate: true,
      lastUser: true,
      modifiedDate: true
    };
    this.loadCallback = undefined;
    this.newFileCallback = undefined;
    this.openSelectionCallback = undefined;
    this.selectModuleCallback = undefined;
    this.selectionChangeCallback = undefined;
    this.showSearchContents = false;
  }
  dateTimeValueChanged() {
    f(this, A, "f").call(this);
  }
  categoriesChanged(t) {
    this.categoriesComboBoxModel = o(t);
  }
  async componentWillLoad() {
    h(this, u, await l.getComponentStrings(this.el), "f");
    // initialize combo-box models∂
        this.categoriesChanged(this.categories);
    // initialize "After" combo-box options
        this.filterAfterComboBoxModel = [ {
      caption: f(this, u, "f").filter[tt],
      value: tt
    }, {
      caption: f(this, u, "f").filter[et],
      value: et
    }, {
      caption: f(this, u, "f").filter[it],
      value: it
    } ];
    // initialize accordion model with proper configuration
        h(this, m, [ {
      id: Z,
      caption: f(this, u, "f").filter.accordionCaption,
      expanded: false
    } ], "f");
    f(this, M, "f").call(this);
  }
  componentDidLoad() {
    f(this, N, "f").call(this);
    f(this, A, "f").call(this);
  }
  keyDownHandler(t) {
    if (document.activeElement === this.el) {
      switch (t.key) {
       case "Enter":
        t.preventDefault();
        f(this, O, "f").call(this);
        break;

       case "Delete":
        t.preventDefault();
        f(this, E, "f").call(this);
        break;

       case "Escape":
        t.preventDefault();
        f(this, H, "f").call(this);
        break;
      }
    }
  }
  /**
     * Reloads the view, refreshing the filters and the table of files.
     */  async reload() {
    try {
      if (f(this, u, "f") && this.filterAfterComboBoxModel) {
        f(this, M, "f").call(this);
        f(this, A, "f").call(this);
      }
    } catch (t) {
      console.error("Error in reload method:");
      // Fallback: try only getObjects if setFilterDefaultValues fails
            try {
        f(this, A, "f").call(this);
      } catch (t) {
        console.error("Fallback also failed:");
      }
    }
  }
  render() {
    var t;
    return e(i, {
      class: "widget"
    }, e("ch-theme", {
      model: J
    }), e("section", {
      class: "section"
    }, e("header", {
      class: "header dialog-header-with-border spacing-body-inline spacing-body-block-start field-group"
    }, f(this, L, "f").call(this)), f(this, P, "f").call(this), e("footer", {
      class: "dialog-footer-with-border dialog-footer-space-between spacing-body"
    }, e("p", {
      // matching objects
      class: "text-body",
      part: "objects-matching"
    }, `${(t = this.objects) === null || t === void 0 ? void 0 : t.length} ${f(this, u, "f").objCount.matching}`), e("div", {
      class: "buttons-spacer"
    }, e("button", {
      // select all button
      id: "button-select-all",
      class: "button-secondary",
      onClick: f(this, G, "f"),
      part: "button button--select-all",
      disabled: this.isLoading
    }, f(this, u, "f").footer.btnSelectAll), e("button", {
      // new file button
      id: "button-new-file",
      class: "button-primary button-icon-and-text",
      onClick: f(this, $, "f"),
      part: "button button--new-file",
      disabled: this.isLoading
    }, f(this, u, "f").footer.btnNew)))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/ww-files" ];
  }
  get el() {
    return s(this);
  }
  static get watchers() {
    return {
      dateTimeValue: [ "dateTimeValueChanged" ],
      categories: [ "categoriesChanged" ]
    };
  }
};

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

lt.style = c;

export { lt as gx_ide_ww_files };
//# sourceMappingURL=p-7bdeae77.entry.js.map