var __classPrivateFieldGet = (this && this.__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 __classPrivateFieldSet = (this && this.__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 _GxIdeSelectKbItems_instances, _GxIdeSelectKbItems__componentLocale, _GxIdeSelectKbItems_chShortcutsEl, _GxIdeSelectKbItems_selectedNodesIds, _GxIdeSelectKbItems_shortcutsSrc, _GxIdeSelectKbItems_updatedModelList, _GxIdeSelectKbItems_viewItemsAsModel, _GxIdeSelectKbItems_treeViewRenderEl, _GxIdeSelectKbItems_loadItems, _GxIdeSelectKbItems_cancelHandler, _GxIdeSelectKbItems_checkedItemsChangeHandler, _GxIdeSelectKbItems_confirmHandler, _GxIdeSelectKbItems_contextMenuHandler, _GxIdeSelectKbItems_executeDialogAction, _GxIdeSelectKbItems_patternSearchValueChangedHandler, _GxIdeSelectKbItems_renderActionButtons, _GxIdeSelectKbItems_renderFooter, _GxIdeSelectKbItems_selectedItemsChangeHandler, _GxIdeSelectKbItems_toggleAndSelectNodesInModelItems, _GxIdeSelectKbItems_toggleCheckedNodesInModelItems, _GxIdeSelectKbItems_updateViews, _GxIdeSelectKbItems_viewItemsAsChangedHandler, _GxIdeSelectKbItems_toggleCheckboxesChangedHandler, _GxIdeSelectKbItems_scrollIntoActiveVersionNode;
import { getAssetPath, Host, h } from "@stencil/core";
import { checkItems, convertItemsListToTreeViewModel, convertItemsNodeListToFlattenedTreeViewModel, expandItems, searchParentsItems, selectItems, unselectAllNodes, findFirstActiveNode } from "./helpers";
import { getIconPath } from "@genexus/mercury";
import { Locale } from "../../common/locale";
import { ACTIVE_ITEM_DEFAULT_ICON } from "./helpers";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "chameleon/scrollbar",
    "components/tooltip",
    "components/tree-view",
    "utils/form--full",
    "utils/layout",
    "utils/spacing",
    "utils/typography"
];
const SYSTEM_SEARCH_ICON = getIconPath({
    category: "system",
    name: "search",
    colorType: "on-surface"
});
const VIEW_AS_TREE_ID = "tree";
const VIEW_AS_LIST_ID = "list";
const TOGGLE_CHECKBOXES_CHECKED_VALUE = "on";
export class GxIdeSelectKbItems {
    constructor() {
        _GxIdeSelectKbItems_instances.add(this);
        _GxIdeSelectKbItems__componentLocale.set(this, void 0);
        _GxIdeSelectKbItems_chShortcutsEl.set(this, void 0);
        _GxIdeSelectKbItems_selectedNodesIds.set(this, []);
        _GxIdeSelectKbItems_shortcutsSrc.set(this, getAssetPath(`./gx-ide-assets/select-kb-items/shortcuts.json`));
        _GxIdeSelectKbItems_updatedModelList.set(this, []);
        _GxIdeSelectKbItems_viewItemsAsModel.set(this, void 0);
        _GxIdeSelectKbItems_treeViewRenderEl.set(this, void 0);
        _GxIdeSelectKbItems_cancelHandler.set(this, () => {
            if (this.cancelCallback) {
                this.cancelCallback();
            }
        });
        _GxIdeSelectKbItems_checkedItemsChangeHandler.set(this, async (e) => {
            let checkedNodesIds = [];
            e.detail.forEach(node => {
                if (node.item.checked) {
                    checkedNodesIds.push(node.item.id);
                }
            });
            if (this.singleChecks) {
                // Detect the last change by comparing previous and new state
                let lastCheckedId = null;
                // If there are more in the new state, it was a check; if less, it was an uncheck
                if (checkedNodesIds.length > this.checkedNodesIds.length) {
                    // Find the newly checked item
                    lastCheckedId =
                        checkedNodesIds.find(id => !this.checkedNodesIds.includes(id)) ||
                            null;
                }
                else if (checkedNodesIds.length < this.checkedNodesIds.length) {
                    // Find the unchecked item (not used in single check, but kept for clarity)
                    lastCheckedId =
                        this.checkedNodesIds.find(id => !checkedNodesIds.includes(id)) ||
                            null;
                }
                // Only allow one if multiChecks is false
                if (this.singleChecks && checkedNodesIds.length > 1) {
                    // If we detected the last checked, keep it; otherwise, keep the first
                    checkedNodesIds = lastCheckedId
                        ? [lastCheckedId]
                        : [checkedNodesIds[0]];
                    // Uncheck the others
                    __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(Array.from(e.detail.keys()).filter(id => id !== checkedNodesIds[0]), { checked: false });
                }
            }
            this.checkedNodesIds = checkedNodesIds;
            __classPrivateFieldSet(this, _GxIdeSelectKbItems_updatedModelList, checkItems(this.itemsList, this.checkedNodesIds), "f");
            if (this.checkedChanged) {
                this.checkedChanged(this.checkedNodesIds);
            }
        });
        _GxIdeSelectKbItems_confirmHandler.set(this, () => {
            if (this.confirmCallback) {
                this.confirmCallback(this.checkedNodesIds);
            }
        });
        _GxIdeSelectKbItems_contextMenuHandler.set(this, async (e) => {
            if (this.itemContextMenuCallback) {
                let info;
                const isSelected = __classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f").find(id => id === e.detail.id);
                if (!__classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f").length || !isSelected) {
                    await __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(__classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f"), { selected: false });
                    await __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties([e.detail.id], {
                        selected: true
                    });
                    info = {
                        clientX: e.detail.contextmenuEvent.clientX,
                        clientY: e.detail.contextmenuEvent.clientY,
                        selection: [e.detail.id]
                    };
                }
                else {
                    info = {
                        clientX: e.detail.contextmenuEvent.clientX,
                        clientY: e.detail.contextmenuEvent.clientY,
                        selection: __classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f")
                    };
                }
                this.itemContextMenuCallback(info);
            }
        });
        _GxIdeSelectKbItems_executeDialogAction.set(this, (callback) => {
            return () => {
                callback(this.checkedNodesIds, __classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f"));
            };
        });
        _GxIdeSelectKbItems_patternSearchValueChangedHandler.set(this, (event) => {
            this.searchPatternValue = event.detail.toString();
        });
        _GxIdeSelectKbItems_renderActionButtons.set(this, () => {
            return (h("div", null, this.dialogActions.map(action => {
                return (h("button", { class: "button-tertiary", part: `button button-${action.name}`, onClick: __classPrivateFieldGet(this, _GxIdeSelectKbItems_executeDialogAction, "f").call(this, action.callback), disabled: this.loading }, action.name));
            })));
        });
        _GxIdeSelectKbItems_renderFooter.set(this, () => {
            var _a;
            return (h("footer", { class: "footer dialog-footer-with-border spacing-body-inline spacing-body-block-end dialog-footer-space-between" }, __classPrivateFieldGet(this, _GxIdeSelectKbItems_renderActionButtons, "f").call(this), h("div", { class: "buttons-spacer " }, this.cancelCallback && (h("button", { class: "button-secondary", part: "cancel-button", onClick: __classPrivateFieldGet(this, _GxIdeSelectKbItems_cancelHandler, "f") }, __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").footer.cancel)), this.confirmCallback && (h("button", { class: "button-primary", part: "confirm-button", onClick: __classPrivateFieldGet(this, _GxIdeSelectKbItems_confirmHandler, "f"), disabled: this.loading || ((_a = this.checkedNodesIds) === null || _a === void 0 ? void 0 : _a.length) === 0 }, __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").footer.select)))));
        });
        _GxIdeSelectKbItems_selectedItemsChangeHandler.set(this, (e) => {
            const selectedNodesIds = [];
            unselectAllNodes(this.itemsList);
            e.detail.forEach(node => {
                selectedNodesIds.push(node.item.id);
            });
            __classPrivateFieldSet(this, _GxIdeSelectKbItems_selectedNodesIds, selectedNodesIds, "f");
            if (this.selectionChanged) {
                this.selectionChanged(__classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f"));
            }
            __classPrivateFieldSet(this, _GxIdeSelectKbItems_updatedModelList, selectItems(this.itemsList, selectedNodesIds), "f");
        });
        _GxIdeSelectKbItems_toggleAndSelectNodesInModelItems.set(this, async (selectedItemsIds) => {
            const nodesToToggle = searchParentsItems(this.itemsList, selectedItemsIds);
            const newItemsSelected = selectItems(this.itemsList, selectedItemsIds);
            const newItemsExpanded = expandItems(newItemsSelected, nodesToToggle);
            __classPrivateFieldGet(this, _GxIdeSelectKbItems_updateViews, "f").call(this, newItemsExpanded);
        });
        _GxIdeSelectKbItems_toggleCheckedNodesInModelItems.set(this, async (selectedItemsIds) => {
            const nodesToToggle = searchParentsItems(this.itemsList, selectedItemsIds);
            const newItemsExpanded = expandItems(this.itemsList, nodesToToggle);
            __classPrivateFieldGet(this, _GxIdeSelectKbItems_updateViews, "f").call(this, newItemsExpanded);
        });
        _GxIdeSelectKbItems_updateViews.set(this, (newItemsList) => {
            this.nodeVersionsListTreeModel = convertItemsListToTreeViewModel(newItemsList, this.checkboxType);
            this.nodeListFlattenedTreeModel =
                convertItemsNodeListToFlattenedTreeViewModel(newItemsList, this.checkboxType);
        });
        _GxIdeSelectKbItems_viewItemsAsChangedHandler.set(this, async (event) => {
            const selectedViewType = event.detail;
            this.nodesVersionsViewType = selectedViewType;
            if (this.nodesVersionsViewType === "tree") {
                await __classPrivateFieldGet(this, _GxIdeSelectKbItems_toggleAndSelectNodesInModelItems, "f").call(this, __classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f"));
                await __classPrivateFieldGet(this, _GxIdeSelectKbItems_toggleCheckedNodesInModelItems, "f").call(this, this.checkedNodesIds);
            }
            __classPrivateFieldGet(this, _GxIdeSelectKbItems_updateViews, "f").call(this, __classPrivateFieldGet(this, _GxIdeSelectKbItems_updatedModelList, "f"));
        });
        _GxIdeSelectKbItems_toggleCheckboxesChangedHandler.set(this, (event) => {
            this.toggleCheckboxes = event.detail === TOGGLE_CHECKBOXES_CHECKED_VALUE;
        });
        _GxIdeSelectKbItems_scrollIntoActiveVersionNode.set(this, async () => {
            var _a;
            const doScrollIntoView = __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f") && ((_a = this.activeItemNode) === null || _a === void 0 ? void 0 : _a.path);
            if (doScrollIntoView) {
                await __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").scrollIntoVisible(this.activeItemNode.path);
            }
            if (this.activeItemCallback) {
                await this.activeItemCallback();
            }
        });
        this.activeItemNode = undefined;
        this.checkedNodesIds = [];
        this.renderFooter = false;
        this.nodeListFlattenedTreeModel = [];
        this.loading = true;
        this.nodesVersionsViewType = "tree";
        this.nodeVersionsListTreeModel = [];
        this.searchPatternValue = null;
        this.toggleCheckboxes = undefined;
        this.itemsList = [];
        this.activeItemCallback = undefined;
        this.cancelCallback = undefined;
        this.checkboxType = undefined;
        this.expandOnClick = true;
        this.checkedChanged = undefined;
        this.confirmCallback = undefined;
        this.dialogActions = [];
        this.itemContextMenuCallback = undefined;
        this.loadItemsCallback = undefined;
        this.showToggleCheckboxes = true;
        this.multiSelection = false;
        this.singleChecks = false;
        this.showActiveItemLink = false;
        this.useLoader = true;
        this.selectionChanged = undefined;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeSelectKbItems__componentLocale, await Locale.getComponentStrings(this.el), "f");
        this.toggleCheckboxes = this.showToggleCheckboxes;
        __classPrivateFieldSet(this, _GxIdeSelectKbItems_viewItemsAsModel, [
            { value: VIEW_AS_TREE_ID, caption: __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").main.tree },
            { value: VIEW_AS_LIST_ID, caption: "List" }
        ], "f");
        this.renderFooter =
            this.dialogActions.length > 0 ||
                !!this.cancelCallback ||
                !!this.confirmCallback;
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_instances, "m", _GxIdeSelectKbItems_loadItems).call(this);
    }
    async reloadItems() {
        await __classPrivateFieldGet(this, _GxIdeSelectKbItems_instances, "m", _GxIdeSelectKbItems_loadItems).call(this);
    }
    /**
     * Suspends or reactivates the shortcuts
     */
    async suspendShortcuts(suspendShortcuts) {
        if (suspendShortcuts) {
            __classPrivateFieldGet(this, _GxIdeSelectKbItems_chShortcutsEl, "f").suspend = true;
        }
        else {
            __classPrivateFieldGet(this, _GxIdeSelectKbItems_chShortcutsEl, "f").suspend = false;
        }
    }
    /**
     * Allow to update the selected items
     */
    async updateSelection(selectedItemsIds) {
        // first clear selected
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(__classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedNodesIds, "f"), {
            selected: false
        });
        // then select
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(selectedItemsIds, {
            selected: true
        });
    }
    /**
     * Allow to update the checked items
     */
    async updateCheckedItems(checkedItemsIds) {
        // first clear checks
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(this.checkedNodesIds, {
            checked: false
        });
        // then select
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_treeViewRenderEl, "f").updateItemsProperties(checkedItemsIds, {
            checked: true
        });
        this.checkedNodesIds = checkedItemsIds;
    }
    render() {
        return (h(Host, { class: { "widget": true, "has-footer": this.renderFooter } }, h("ch-theme", { model: CSS_BUNDLES }), h("ch-shortcuts", { src: __classPrivateFieldGet(this, _GxIdeSelectKbItems_shortcutsSrc, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeSelectKbItems_chShortcutsEl, el, "f")) }), h("section", { class: "section" }, h("header", { part: "header", class: "header dialog-header field-group spacing-body-block-start spacing-body-inline" }, h("div", { class: "header__first-row field-group" }, h("div", { class: "field field-inline" }, h("span", null, h("label", { class: "label", htmlFor: "view-mode" }, "Select view mode:")), h("ch-radio-group-render", { class: "radio-group dummy-control-block-size", id: "view-mode", model: __classPrivateFieldGet(this, _GxIdeSelectKbItems_viewItemsAsModel, "f"), onChange: __classPrivateFieldGet(this, _GxIdeSelectKbItems_viewItemsAsChangedHandler, "f"), value: __classPrivateFieldGet(this, _GxIdeSelectKbItems_viewItemsAsModel, "f")[0].value })), this.checkboxType !== "none" && this.showToggleCheckboxes && (h("ch-checkbox", { class: "checkbox dummy-control-block-size", caption: "Toggle Checkboxes", id: "toggle-checkboxes", checkedValue: TOGGLE_CHECKBOXES_CHECKED_VALUE, value: TOGGLE_CHECKBOXES_CHECKED_VALUE, onInput: __classPrivateFieldGet(this, _GxIdeSelectKbItems_toggleCheckboxesChangedHandler, "f") }))), h("div", { class: {
                "field-group": true,
                "header__second-row": true,
                "header__second-row--one-row": !this.showActiveItemLink
            } }, h("ch-edit", { class: "input", placeholder: __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").header.searchPatternPlaceholder, startImgSrc: SYSTEM_SEARCH_ICON, onInput: __classPrivateFieldGet(this, _GxIdeSelectKbItems_patternSearchValueChangedHandler, "f"), accessibleName: "search pattern" }), this.activeItemNode && this.showActiveItemLink && (h("div", { class: "active-item" }, h("span", { class: "active-item__icon-container" }, h("ch-image", { class: "icon-m active-item__icon", src: this.activeItemNode.iconStart ||
                ACTIVE_ITEM_DEFAULT_ICON, containerRef: null })), __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").header.activeItem, h("button", { class: "active-item__link", onClick: __classPrivateFieldGet(this, _GxIdeSelectKbItems_scrollIntoActiveVersionNode, "f") }, this.activeItemNode.caption))))), h("div", { class: "spacing-body-inline-start trees" }, this.useLoader && this.loading ? (h("gx-ide-loader", { loaderTitle: __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").loader.title, description: __classPrivateFieldGet(this, _GxIdeSelectKbItems__componentLocale, "f").loader.description, show: true })) : (h("ch-tree-view-render", { class: "tree-view", model: this.nodesVersionsViewType === "tree"
                ? this.nodeVersionsListTreeModel
                : this.nodeListFlattenedTreeModel, "show-lines": this.nodesVersionsViewType === "tree" ? "all" : "none", expandableButton: this.nodesVersionsViewType === "tree" ? "decorative" : "no", onItemContextmenu: __classPrivateFieldGet(this, _GxIdeSelectKbItems_contextMenuHandler, "f"), onCheckedItemsChange: __classPrivateFieldGet(this, _GxIdeSelectKbItems_checkedItemsChangeHandler, "f"), onSelectedItemsChange: __classPrivateFieldGet(this, _GxIdeSelectKbItems_selectedItemsChangeHandler, "f"), expandOnClick: this.expandOnClick, multiSelection: this.multiSelection, filter: this.searchPatternValue, filterType: "caption", toggleCheckboxes: this.toggleCheckboxes, ref: (el) => {
                __classPrivateFieldSet(this, _GxIdeSelectKbItems_treeViewRenderEl, el, "f");
            } }))), this.renderFooter && __classPrivateFieldGet(this, _GxIdeSelectKbItems_renderFooter, "f").call(this))));
    }
    static get is() { return "gx-ide-select-kb-items"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["select-kb-items.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["select-kb-items.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/select-kb-items"]; }
    static get properties() {
        return {
            "activeItemCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the user clicks on the \"Active item\""
                }
            },
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the 'cancel' button is pressed"
                }
            },
            "checkboxType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "CheckboxType",
                    "resolved": "\"all\" | \"custom\" | \"leaf\" | \"none\"",
                    "references": {
                        "CheckboxType": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/select-kb-items/select-kb-items.tsx",
                            "id": "src/components/select-kb-items/select-kb-items.tsx::CheckboxType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines which nodes of the component have checkboxes."
                },
                "attribute": "checkbox-type",
                "reflect": false
            },
            "expandOnClick": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Define if a item node is expanded on click interaction. If false item-node will only be expanded on double click."
                },
                "attribute": "expand-on-click",
                "reflect": false,
                "defaultValue": "true"
            },
            "checkedChanged": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(checkedItems: string[]) => Promise<void>",
                    "resolved": "(checkedItems: string[]) => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the items checked items change"
                }
            },
            "confirmCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(checkedItems: string[]) => Promise<void>",
                    "resolved": "(checkedItems: string[]) => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the 'select' button is pressed"
                }
            },
            "dialogActions": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "DialogAction[]",
                    "resolved": "DialogAction[]",
                    "references": {
                        "DialogAction": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/select-kb-items/select-kb-items.tsx",
                            "id": "src/components/select-kb-items/select-kb-items.tsx::DialogAction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set of additional actions (callbacks) to those already provided by default by the selector (cancelCallback and selectCallback)"
                },
                "defaultValue": "[]"
            },
            "itemContextMenuCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(\n    info: ContextMenuInfo\n  ) => Promise<void>",
                    "resolved": "(info: ContextMenuInfo) => Promise<void>",
                    "references": {
                        "ContextMenuInfo": {
                            "location": "import",
                            "path": "../../common/types",
                            "id": "src/common/types.ts::ContextMenuInfo"
                        },
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the user right click on an item"
                }
            },
            "loadItemsCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<ItemNode[]>",
                    "resolved": "() => Promise<ItemNode[]>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "ItemNode": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/select-kb-items/select-kb-items.tsx",
                            "id": "src/components/select-kb-items/select-kb-items.tsx::ItemNode"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback to load the items list model"
                }
            },
            "showToggleCheckboxes": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Used to define if the component must show the \"Toggle Checkboxes\" option or not"
                },
                "attribute": "show-toggle-checkboxes",
                "reflect": false,
                "defaultValue": "true"
            },
            "multiSelection": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "This define if the selection is unique or not"
                },
                "attribute": "multi-selection",
                "reflect": false,
                "defaultValue": "false"
            },
            "singleChecks": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "This define if the checks are unique or not"
                },
                "attribute": "single-checks",
                "reflect": false,
                "defaultValue": "false"
            },
            "showActiveItemLink": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Used to define if the component must show the \"Active item\" link or not"
                },
                "attribute": "show-active-item-link",
                "reflect": false,
                "defaultValue": "false"
            },
            "useLoader": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Defines whether to show a loader while loading items"
                },
                "attribute": "use-loader",
                "reflect": false,
                "defaultValue": "true"
            },
            "selectionChanged": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(selectedItem: string[]) => Promise<void>",
                    "resolved": "(selectedItem: string[]) => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback emitted when the items selection change"
                }
            }
        };
    }
    static get states() {
        return {
            "activeItemNode": {},
            "checkedNodesIds": {},
            "renderFooter": {},
            "nodeListFlattenedTreeModel": {},
            "loading": {},
            "nodesVersionsViewType": {},
            "nodeVersionsListTreeModel": {},
            "searchPatternValue": {},
            "toggleCheckboxes": {},
            "itemsList": {}
        };
    }
    static get methods() {
        return {
            "reloadItems": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            },
            "suspendShortcuts": {
                "complexType": {
                    "signature": "(suspendShortcuts: boolean) => Promise<void>",
                    "parameters": [{
                            "name": "suspendShortcuts",
                            "type": "boolean",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Suspends or reactivates the shortcuts",
                    "tags": []
                }
            },
            "updateSelection": {
                "complexType": {
                    "signature": "(selectedItemsIds: string[]) => Promise<void>",
                    "parameters": [{
                            "name": "selectedItemsIds",
                            "type": "string[]",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Allow to update the selected items",
                    "tags": []
                }
            },
            "updateCheckedItems": {
                "complexType": {
                    "signature": "(checkedItemsIds: string[]) => Promise<void>",
                    "parameters": [{
                            "name": "checkedItemsIds",
                            "type": "string[]",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Allow to update the checked items",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
_GxIdeSelectKbItems__componentLocale = new WeakMap(), _GxIdeSelectKbItems_chShortcutsEl = new WeakMap(), _GxIdeSelectKbItems_selectedNodesIds = new WeakMap(), _GxIdeSelectKbItems_shortcutsSrc = new WeakMap(), _GxIdeSelectKbItems_updatedModelList = new WeakMap(), _GxIdeSelectKbItems_viewItemsAsModel = new WeakMap(), _GxIdeSelectKbItems_treeViewRenderEl = new WeakMap(), _GxIdeSelectKbItems_cancelHandler = new WeakMap(), _GxIdeSelectKbItems_checkedItemsChangeHandler = new WeakMap(), _GxIdeSelectKbItems_confirmHandler = new WeakMap(), _GxIdeSelectKbItems_contextMenuHandler = new WeakMap(), _GxIdeSelectKbItems_executeDialogAction = new WeakMap(), _GxIdeSelectKbItems_patternSearchValueChangedHandler = new WeakMap(), _GxIdeSelectKbItems_renderActionButtons = new WeakMap(), _GxIdeSelectKbItems_renderFooter = new WeakMap(), _GxIdeSelectKbItems_selectedItemsChangeHandler = new WeakMap(), _GxIdeSelectKbItems_toggleAndSelectNodesInModelItems = new WeakMap(), _GxIdeSelectKbItems_toggleCheckedNodesInModelItems = new WeakMap(), _GxIdeSelectKbItems_updateViews = new WeakMap(), _GxIdeSelectKbItems_viewItemsAsChangedHandler = new WeakMap(), _GxIdeSelectKbItems_toggleCheckboxesChangedHandler = new WeakMap(), _GxIdeSelectKbItems_scrollIntoActiveVersionNode = new WeakMap(), _GxIdeSelectKbItems_instances = new WeakSet(), _GxIdeSelectKbItems_loadItems = async function _GxIdeSelectKbItems_loadItems() {
    try {
        this.loading = true;
        this.itemsList = await this.loadItemsCallback();
        __classPrivateFieldGet(this, _GxIdeSelectKbItems_updateViews, "f").call(this, this.itemsList);
        // Check and update activeItem
        this.activeItemNode = findFirstActiveNode(this.itemsList);
    }
    catch (error) {
        console.error("Error loading items:", error);
    }
    finally {
        this.loading = false;
    }
};
//# sourceMappingURL=select-kb-items.js.map
