import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { g as getIconPath } from './mer-animated-dots.js';
import 'lit';
import 'lit/directives/when.js';
import 'lit/directives/if-defined.js';
import { L as Locale } from './locale.js';
import { c as config } from './config.js';
import { h as hiChar, m as mapOptionsToComboBoxItemModel } from './helpers2.js';
import { f as formatDate } from './helpers.js';
import { d as defineCustomElement$4 } from './gx-ide-empty-state2.js';
import { d as defineCustomElement$3 } from './entity-selector.js';
import { d as defineCustomElement$2 } from './ide-loader.js';

const wwFilesCss = "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 __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _GxIdeWWFiles_componentLocale, _GxIdeWWFiles_ACCORDION_MODEL, _GxIdeWWFiles_nameValue, _GxIdeWWFiles_moduleValue, _GxIdeWWFiles_searchContentsValue, _GxIdeWWFiles_categoryValue, _GxIdeWWFiles_allDescendants, _GxIdeWWFiles_userValue, _GxIdeWWFiles_selectedObjectsIds, _GxIdeWWFiles_chGridEl, _GxIdeWWFiles_setFilterDefaultValues, _GxIdeWWFiles_allDescendantsCheckboxHandler, _GxIdeWWFiles_handleSelectionChanged, _GxIdeWWFiles_handleRowDoubleClicked, _GxIdeWWFiles_handleRowContextMenu, _GxIdeWWFiles_attachGridListeners, _GxIdeWWFiles_categoryInputHandler, _GxIdeWWFiles_clearDateTimeValue, _GxIdeWWFiles_dateTimeInputHandler, _GxIdeWWFiles_deleteSelectionCallbackHandler, _GxIdeWWFiles_deselectAll, _GxIdeWWFiles_evaluateModifiedDates, _GxIdeWWFiles_filterAfterTypeCallbackHandler, _GxIdeWWFiles_formatDate, _GxIdeWWFiles_getObjects, _GxIdeWWFiles_renderHeader, _GxIdeWWFiles_renderObjects, _GxIdeWWFiles_moduleValueChangedHandler, _GxIdeWWFiles_nameInputHandler, _GxIdeWWFiles_newFileCallbackHandler, _GxIdeWWFiles_openSelectionCallbackHandler, _GxIdeWWFiles_searchContentsInputHandler, _GxIdeWWFiles_setLoadingState, _GxIdeWWFiles_userInputHandler, _GxIdeWWFiles_showModifiedCheckboxHandler, _GxIdeWWFiles_selectAll;
const CSS_BUNDLES = [
    "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 CLEAR_ICON = getIconPath({
    category: "system",
    name: "close",
    colorType: "interactive"
});
const FILTER_ICON = getIconPath({
    category: "window-tools",
    name: "filter",
    colorType: "on-surface"
});
const INFO_ICON = getIconPath({
    category: "system",
    name: "information",
    colorType: "on-surface"
});
const ACCORDION_FILTER_ID = "advanced-filter";
const FILTER_AFTER_DATE_TIME = "afterDateTime";
const FILTER_AFTER_LAST_BUILD = "afterLastBuild";
const FILTER_AFTER_IMPORT = "afterImport";
const CHECKBOX_CHECKED_VALUE = "checked";
const CHECKBOX_UNCHECKED_VALUE = "unchecked";
const GxIdeWWFiles = /*@__PURE__*/ proxyCustomElement(class GxIdeWWFiles extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        _GxIdeWWFiles_componentLocale.set(this, void 0);
        _GxIdeWWFiles_ACCORDION_MODEL.set(this, []);
        // Filter Values
        _GxIdeWWFiles_nameValue.set(this, void 0);
        _GxIdeWWFiles_moduleValue.set(this, void 0);
        // Advanced Filter Values
        _GxIdeWWFiles_searchContentsValue.set(this, void 0);
        _GxIdeWWFiles_categoryValue.set(this, void 0);
        _GxIdeWWFiles_allDescendants.set(this, void 0);
        _GxIdeWWFiles_userValue.set(this, void 0);
        // Other
        _GxIdeWWFiles_selectedObjectsIds.set(this, []);
        _GxIdeWWFiles_chGridEl.set(this, void 0);
        _GxIdeWWFiles_setFilterDefaultValues.set(this, () => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_nameValue, "", "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_moduleValue, Object.assign({}, this.defaultModule), "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_searchContentsValue, "", "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_categoryValue, this.defaultCategory ||
                (this.categoriesComboBoxModel && this.categoriesComboBoxModel.length > 0
                    ? this.categoriesComboBoxModel[0].value
                    : ""), "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_allDescendants, CHECKBOX_UNCHECKED_VALUE, "f");
            this.afterValue =
                this.filterAfterComboBoxModel && this.filterAfterComboBoxModel.length > 0
                    ? this.filterAfterComboBoxModel[0].value
                    : FILTER_AFTER_DATE_TIME;
            __classPrivateFieldSet(this, _GxIdeWWFiles_userValue, "", "f");
            this.dateTimeValue = undefined;
        });
        _GxIdeWWFiles_allDescendantsCheckboxHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_allDescendants, event.detail === CHECKBOX_CHECKED_VALUE
                ? CHECKBOX_CHECKED_VALUE
                : CHECKBOX_UNCHECKED_VALUE, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_handleSelectionChanged.set(this, (ev) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_selectedObjectsIds, ev.detail.rowsId, "f");
            this.selectionChangeCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_handleRowDoubleClicked.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_openSelectionCallbackHandler, "f").call(this);
        });
        _GxIdeWWFiles_handleRowContextMenu.set(this, (ev) => {
            ev.preventDefault();
            ev.stopPropagation();
            this.contextMenuCallback({
                selection: ev.detail.selectedRowsId,
                clientX: ev.detail.clientX,
                clientY: ev.detail.clientY
            });
        });
        _GxIdeWWFiles_attachGridListeners.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("selectionChanged", __classPrivateFieldGet(this, _GxIdeWWFiles_handleSelectionChanged, "f"));
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("rowDoubleClicked", __classPrivateFieldGet(this, _GxIdeWWFiles_handleRowDoubleClicked, "f"));
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("rowContextMenu", __classPrivateFieldGet(this, _GxIdeWWFiles_handleRowContextMenu, "f"));
        });
        _GxIdeWWFiles_categoryInputHandler.set(this, async (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_categoryValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_clearDateTimeValue.set(this, () => {
            this.dateTimeValue = undefined;
        });
        _GxIdeWWFiles_dateTimeInputHandler.set(this, (event) => {
            this.dateTimeValue = event.detail;
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_deleteSelectionCallbackHandler.set(this, () => {
            this.deleteSelectionCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_deselectAll.set(this, () => {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f") &&
                typeof __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows ===
                    "function") {
                __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows(false);
            }
        });
        _GxIdeWWFiles_evaluateModifiedDates.set(this, (objectModifiedDate, filterSelectedModifiedDate) => {
            const filterSelectedModifiedDateAsDate = new Date(filterSelectedModifiedDate);
            if (filterSelectedModifiedDateAsDate >= objectModifiedDate) {
                // Object modifed date matches with filter date, or was modified after that date.
                // Highlight to show that it matches.
                return h("span", { class: "hiChar" }, __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, objectModifiedDate));
            }
            else {
                return __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, objectModifiedDate);
            }
        });
        _GxIdeWWFiles_filterAfterTypeCallbackHandler.set(this, (event) => {
            this.afterValue = event.detail;
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_formatDate.set(this, (date) => {
            return formatDate(date, "date-time-short");
        });
        _GxIdeWWFiles_getObjects.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_setLoadingState, "f").call(this);
            const parentId = __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f") ? __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f").id : "";
            const filtersValues = {
                name: __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"),
                searchContents: __classPrivateFieldGet(this, _GxIdeWWFiles_searchContentsValue, "f"),
                category: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryValue, "f"),
                parent: parentId,
                allDescendants: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendants, "f") === CHECKBOX_CHECKED_VALUE,
                modifiedAfter: this.showModified ? this.afterValue : undefined,
                modifiedBy: this.showModified ? __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f") : undefined,
                modifiedDate: this.showModified ? new Date(this.dateTimeValue) : undefined
            };
            this.loadCallback(filtersValues).then((items) => {
                this.objects = items;
                __classPrivateFieldSet(this, _GxIdeWWFiles_selectedObjectsIds, [], "f");
                if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f")) {
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deselectAll, "f").call(this);
                }
                this.isLoading = false;
            });
        });
        _GxIdeWWFiles_renderHeader.set(this, () => {
            return [
                h("div", {
                    // Name
                    class: "field field-block field-name"
                }, h("label", { class: "label", htmlFor: "name" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.name), h("ch-edit", { id: "name", class: "input", value: __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_nameInputHandler, "f"), part: "filter-files", debounce: config.inputDebounce, disabled: this.isLoading })),
                h("div", {
                    // Module
                    class: "field field-block field-module-folder"
                }, h("label", { class: "label", htmlFor: "module-folder" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.moduleFolder), h("gx-ide-entity-selector", { part: "filter-module-folder", id: "module/folder", labelPosition: "none", value: __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f"), defaultValue: this.defaultModule, selectEntityCallback: this.selectModuleCallback, onValueChanged: __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValueChangedHandler, "f"), disabled: this.isLoading })),
                h("ch-accordion-render", { class: "accordion-outlined advanced-filter", model: __classPrivateFieldGet(this, _GxIdeWWFiles_ACCORDION_MODEL, "f") }, h("div", { slot: ACCORDION_FILTER_ID, class: "spacing-body field-group advanced-filter__container" }, this.showSearchContents && (h("div", {
                    // Search contents
                    class: "field field-block field-search-contents"
                }, h("label", { class: "label", htmlFor: "filter-content" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.content), h("ch-edit", { id: "filter-content", class: "input", onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_searchContentsInputHandler, "f"), part: "filter-content" }))), h("div", { class: "field-group advanced-filter__first-row" }, h("div", {
                    // Category
                    class: "field field-block field-category"
                }, h("label", { class: "label", htmlFor: "filter-category" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.category), h("ch-combo-box-render", { id: "filter-category", class: "combo-box disabled", value: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryValue, "f"), disabled: !this.categories || this.isLoading, model: this.categoriesComboBoxModel, part: "filter-category", onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryInputHandler, "f") })), h("div", {
                    // All descendants / Modified
                    class: "all-descendants__modified field field-inline"
                }, h("ch-checkbox", {
                    // All descendants
                    class: "checkbox", caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.allDescendants, checkedValue: CHECKBOX_CHECKED_VALUE, unCheckedValue: CHECKBOX_UNCHECKED_VALUE, value: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendants, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendantsCheckboxHandler, "f"), part: "filter-all-descendants", disabled: this.isLoading
                }), h("ch-checkbox", {
                    // Modified
                    class: "checkbox align-center", caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.modified, checkedValue: CHECKBOX_CHECKED_VALUE, unCheckedValue: CHECKBOX_UNCHECKED_VALUE, value: this.showModified, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_showModifiedCheckboxHandler, "f"), part: "filter-modified"
                }))), this.showModified === CHECKBOX_CHECKED_VALUE && (h("div", { class: "field-group advanced-filter__second-row" }, h("div", {
                    // After
                    class: "field field-block field-after"
                }, h("label", { class: "label", htmlFor: "filter-after-type" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.after), h("ch-combo-box-render", { id: "filter-after-type", class: "combo-box", value: this.afterValue, model: this.filterAfterComboBoxModel, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_filterAfterTypeCallbackHandler, "f"), part: "filter-after-type", disabled: this.isLoading })), h("div", {
                    // User
                    class: "field field-block field-user"
                }, h("label", { class: "label", htmlFor: "filter-user" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.user), h("ch-edit", { id: "filter-user", class: "input", value: __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_userInputHandler, "f"), part: "filter-user", debounce: config.inputDebounce, disabled: this.isLoading })), this.afterValue === FILTER_AFTER_DATE_TIME && (h("div", {
                    // Date/Time
                    class: {
                        "field field-block field-date": true,
                        "hide": this.afterValue !== FILTER_AFTER_DATE_TIME
                    }
                }, h("label", { class: "label label-date-time", htmlFor: "filter-date-time" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.dateTime, h("ch-image", { class: "icon-s icon-clear-date-time", src: INFO_ICON }), h("ch-tooltip", { class: "tooltip", actionElement: null, blockAlign: "outside-start", inlineAlign: "inside-start", delay: config.tooltipSettings.delay }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.dateTimeTooltip)), h("ch-edit", { id: "filter-date-time", type: "datetime-local", class: "input input-date-time", value: this.dateTimeValue, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_dateTimeInputHandler, "f"), part: "filter-date-time", disabled: this.isLoading }), h("button", { class: "button-tertiary button-icon-only", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_clearDateTimeValue, "f"), disabled: this.isLoading }, h("ch-image", { class: "icon-m", src: CLEAR_ICON, type: "mask" }))))))))
            ];
        });
        _GxIdeWWFiles_renderObjects.set(this, () => {
            var _a;
            const gridIsEmpty = !this.objects.length;
            return (h("ch-tabular-grid", { ref: (el) => (__classPrivateFieldSet(this, _GxIdeWWFiles_chGridEl, el, "f")), class: {
                    "tabular-grid": true,
                    "loading": this.isLoading,
                    "empty": this.objects.length === 0
                }, rowSelectionMode: "multiple", part: "ch-grid-files" }, h("ch-tabular-grid-columnset", { class: "tabular-grid-column-set" }, h("ch-tabular-grid-column", { columnName: "", columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.name, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.module, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), this.gridColumnsVisibility.description && (h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.description, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.auto, class: "tabular-grid-column" })), this.gridColumnsVisibility.modifiedDate && (h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.modifiedDate, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.lastUser && (h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.lastUser, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.importDate && (h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.importDate, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.lastBuildDate && (h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.lastBuildDate, columnNameHidden: false, settingable: false, sortable: false, size: config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }))), !gridIsEmpty ? (h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, (_a = this.objects) === null || _a === void 0 ? void 0 : _a.map((object) => {
                var _a;
                return (h("ch-tabular-grid-row", { rowid: object.id, class: "tabular-grid-row" }, h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, h("ch-image", { src: object.icon })), h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, hiChar(object.name.toLowerCase(), __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f").toLowerCase())), h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, object.parent), this.gridColumnsVisibility.description && (h("ch-tabular-grid-cell", { class: "tabular-grid-cell tabular-grid-cell-description" }, object.description)), this.gridColumnsVisibility.modifiedDate && (h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, __classPrivateFieldGet(this, _GxIdeWWFiles_evaluateModifiedDates, "f").call(this, object.modifiedDate, this.dateTimeValue))), this.gridColumnsVisibility.lastUser && (h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, hiChar((_a = object.lastUser) === null || _a === void 0 ? void 0 : _a.toLowerCase(), __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f")))), this.gridColumnsVisibility.importDate && (h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, hiChar(object.importDate
                    ? __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, object.importDate)
                    : "", __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f")))), this.gridColumnsVisibility.lastBuildDate && (h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, hiChar(object.lastBuildDate
                    ? __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, object.lastBuildDate)
                    : "", __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"))))));
            }))) : (h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, h("ch-tabular-grid-rowset-empty", null, this.isLoading ? (h("gx-ide-loader", { loaderTitle: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").loader.title, description: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").loader.description, show: true })) : (h("gx-ide-empty-state", { isAnimated: true, stateIconSrc: FILTER_ICON, stateTitle: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").emptyState.title })))))));
        });
        _GxIdeWWFiles_moduleValueChangedHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_moduleValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_nameInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_nameValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_newFileCallbackHandler.set(this, () => {
            this.newFileCallback();
        });
        _GxIdeWWFiles_openSelectionCallbackHandler.set(this, () => {
            this.openSelectionCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_searchContentsInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_searchContentsValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_setLoadingState.set(this, () => {
            // Only clear if no objects or first load
            if (!this.objects || this.objects.length === 0) {
                this.objects = [];
            }
            this.isLoading = true;
        });
        _GxIdeWWFiles_userInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_userValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_showModifiedCheckboxHandler.set(this, (event) => {
            this.showModified = event.detail;
        });
        _GxIdeWWFiles_selectAll.set(this, () => {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f") &&
                typeof __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows ===
                    "function") {
                __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows();
            }
        });
        this.afterValue = undefined;
        this.categoriesComboBoxModel = [];
        this.dateTimeValue = undefined;
        this.isLoading = true;
        this.filterAfterComboBoxModel = undefined;
        this.showModified = CHECKBOX_CHECKED_VALUE;
        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() {
        __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
    }
    categoriesChanged(newCategories) {
        this.categoriesComboBoxModel = mapOptionsToComboBoxItemModel(newCategories);
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeWWFiles_componentLocale, await Locale.getComponentStrings(this.el), "f");
        // initialize combo-box models∂
        this.categoriesChanged(this.categories);
        // initialize "After" combo-box options
        this.filterAfterComboBoxModel = [
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_DATE_TIME],
                value: FILTER_AFTER_DATE_TIME
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_LAST_BUILD],
                value: FILTER_AFTER_LAST_BUILD
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_IMPORT],
                value: FILTER_AFTER_IMPORT
            }
        ];
        // initialize accordion model with proper configuration
        __classPrivateFieldSet(this, _GxIdeWWFiles_ACCORDION_MODEL, [
            {
                id: ACCORDION_FILTER_ID,
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.accordionCaption,
                expanded: false
            }
        ], "f");
        __classPrivateFieldGet(this, _GxIdeWWFiles_setFilterDefaultValues, "f").call(this);
    }
    componentDidLoad() {
        __classPrivateFieldGet(this, _GxIdeWWFiles_attachGridListeners, "f").call(this);
        __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
    }
    keyDownHandler(eventInfo) {
        if (document.activeElement === this.el) {
            switch (eventInfo.key) {
                case "Enter":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_openSelectionCallbackHandler, "f").call(this);
                    break;
                case "Delete":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deleteSelectionCallbackHandler, "f").call(this);
                    break;
                case "Escape":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deselectAll, "f").call(this);
                    break;
            }
        }
    }
    /**
     * Reloads the view, refreshing the filters and the table of files.
     */
    async reload() {
        try {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f") && this.filterAfterComboBoxModel) {
                __classPrivateFieldGet(this, _GxIdeWWFiles_setFilterDefaultValues, "f").call(this);
                __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
            }
        }
        catch (error) {
            console.error("Error in reload method:");
            // Fallback: try only getObjects if setFilterDefaultValues fails
            try {
                __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
            }
            catch (fallbackError) {
                console.error("Fallback also failed:");
            }
        }
    }
    render() {
        var _a;
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("section", { class: "section" }, h("header", { class: "header dialog-header-with-border spacing-body-inline spacing-body-block-start field-group" }, __classPrivateFieldGet(this, _GxIdeWWFiles_renderHeader, "f").call(this)), __classPrivateFieldGet(this, _GxIdeWWFiles_renderObjects, "f").call(this), h("footer", { class: "dialog-footer-with-border dialog-footer-space-between spacing-body" }, h("p", {
            // matching objects
            class: "text-body", part: "objects-matching"
        }, `${(_a = this.objects) === null || _a === void 0 ? void 0 : _a.length} ${__classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").objCount.matching}`), h("div", { class: "buttons-spacer" }, h("button", {
            // select all button
            id: "button-select-all", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_selectAll, "f"), part: "button button--select-all", disabled: this.isLoading
        }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").footer.btnSelectAll), h("button", {
            // new file button
            id: "button-new-file", class: "button-primary button-icon-and-text", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_newFileCallbackHandler, "f"), part: "button button--new-file", disabled: this.isLoading
        }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").footer.btnNew))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/ww-files"]; }
    get el() { return this; }
    static get watchers() { return {
        "dateTimeValue": ["dateTimeValueChanged"],
        "categories": ["categoriesChanged"]
    }; }
    static get style() { return wwFilesCss; }
}, [1, "gx-ide-ww-files", {
        "categories": [16],
        "contextMenuCallback": [16],
        "defaultCategory": [1, "default-category"],
        "defaultModule": [16],
        "deleteSelectionCallback": [16],
        "gridColumnsVisibility": [16],
        "loadCallback": [16],
        "newFileCallback": [16],
        "openSelectionCallback": [16],
        "selectModuleCallback": [16],
        "selectionChangeCallback": [16],
        "showSearchContents": [4, "show-search-contents"],
        "afterValue": [32],
        "categoriesComboBoxModel": [32],
        "dateTimeValue": [32],
        "isLoading": [32],
        "filterAfterComboBoxModel": [32],
        "showModified": [32],
        "objects": [32],
        "reload": [64]
    }, [[1, "keydown", "keyDownHandler"]], {
        "dateTimeValue": ["dateTimeValueChanged"],
        "categories": ["categoriesChanged"]
    }]);
_GxIdeWWFiles_componentLocale = new WeakMap(), _GxIdeWWFiles_ACCORDION_MODEL = new WeakMap(), _GxIdeWWFiles_nameValue = new WeakMap(), _GxIdeWWFiles_moduleValue = new WeakMap(), _GxIdeWWFiles_searchContentsValue = new WeakMap(), _GxIdeWWFiles_categoryValue = new WeakMap(), _GxIdeWWFiles_allDescendants = new WeakMap(), _GxIdeWWFiles_userValue = new WeakMap(), _GxIdeWWFiles_selectedObjectsIds = new WeakMap(), _GxIdeWWFiles_chGridEl = new WeakMap(), _GxIdeWWFiles_setFilterDefaultValues = new WeakMap(), _GxIdeWWFiles_allDescendantsCheckboxHandler = new WeakMap(), _GxIdeWWFiles_handleSelectionChanged = new WeakMap(), _GxIdeWWFiles_handleRowDoubleClicked = new WeakMap(), _GxIdeWWFiles_handleRowContextMenu = new WeakMap(), _GxIdeWWFiles_attachGridListeners = new WeakMap(), _GxIdeWWFiles_categoryInputHandler = new WeakMap(), _GxIdeWWFiles_clearDateTimeValue = new WeakMap(), _GxIdeWWFiles_dateTimeInputHandler = new WeakMap(), _GxIdeWWFiles_deleteSelectionCallbackHandler = new WeakMap(), _GxIdeWWFiles_deselectAll = new WeakMap(), _GxIdeWWFiles_evaluateModifiedDates = new WeakMap(), _GxIdeWWFiles_filterAfterTypeCallbackHandler = new WeakMap(), _GxIdeWWFiles_formatDate = new WeakMap(), _GxIdeWWFiles_getObjects = new WeakMap(), _GxIdeWWFiles_renderHeader = new WeakMap(), _GxIdeWWFiles_renderObjects = new WeakMap(), _GxIdeWWFiles_moduleValueChangedHandler = new WeakMap(), _GxIdeWWFiles_nameInputHandler = new WeakMap(), _GxIdeWWFiles_newFileCallbackHandler = new WeakMap(), _GxIdeWWFiles_openSelectionCallbackHandler = new WeakMap(), _GxIdeWWFiles_searchContentsInputHandler = new WeakMap(), _GxIdeWWFiles_setLoadingState = new WeakMap(), _GxIdeWWFiles_userInputHandler = new WeakMap(), _GxIdeWWFiles_showModifiedCheckboxHandler = new WeakMap(), _GxIdeWWFiles_selectAll = new WeakMap();
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-ww-files", "gx-ide-empty-state", "gx-ide-entity-selector", "gx-ide-loader"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-ww-files":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GxIdeWWFiles);
            }
            break;
        case "gx-ide-empty-state":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "gx-ide-entity-selector":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "gx-ide-loader":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const GxIdeWwFiles = GxIdeWWFiles;
const defineCustomElement = defineCustomElement$1;

export { GxIdeWwFiles, defineCustomElement };

//# sourceMappingURL=gx-ide-ww-files.js.map