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 _GxIdeKbManagerImport_componentLocale, _GxIdeKbManagerImport_selectedObjectsInFileIds, _GxIdeKbManagerImport_fileInputEl, _GxIdeKbManagerImport_fileInputHiddenEl, _GxIdeKbManagerImport_objectsTreeEl, _GxIdeKbManagerImport_successItemsIds, _GxIdeKbManagerImport_warningItemsIds, _GxIdeKbManagerImport_errorItemsIds, _GxIdeKbManagerImport_categoryItemMap, _GxIdeKbManagerImport_objectCategoryItemMap, _GxIdeKbManagerImport_importedCategoryData, _GxIdeKbManagerImport_cancelImportHandler, _GxIdeKbManagerImport_clearStatusHandler, _GxIdeKbManagerImport_evaluateImport, _GxIdeKbManagerImport_evaluateImportStatusMessage, _GxIdeKbManagerImport_importObjectsHandler, _GxIdeKbManagerImport_loadFileHandler, _GxIdeKbManagerImport_lazyLoadTreeItems, _GxIdeKbManagerImport_objectsTreeCheckedItemsChangedHandler, _GxIdeKbManagerImport_objectsTreeContextMenuHandler, _GxIdeKbManagerImport_objectsTreeSelectedItemsChangedHandler, _GxIdeKbManagerImport_optionsHandler, _GxIdeKbManagerImport_removeFileSelection, _GxIdeKbManagerImport_selectFileInputHandler, _GxIdeKbManagerImport_selectFileInputChangedHandler, _GxIdeKbManagerImport_statusButtonsSelectionChangedHandler, _GxIdeKbManagerImport_toggleSelectionClickHandler, _GxIdeKbManagerImport_updateStatusItemsState;
import { Host, h } from "@stencil/core";
import { getIconPath } from "@genexus/mercury";
import { Locale } from "../../common/locale";
import { convertImportCategoryDataToTreeView, addImportItemResultDataItem, convertImportCategoryItemToTreeItem } from "./helpers";
import { KB_OBJECT, STATUS_REGEXP_KEY } from "./helpers";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/checkbox",
    "components/edit",
    "components/icon",
    "components/tree-view",
    "utils/form",
    "utils/layout",
    "utils/typography",
    "utils/spacing"
];
const NOTICE_ICON = getIconPath({
    category: "gemini-tools",
    name: "notice",
    colorType: "on-surface"
});
const FILE_ICON = getIconPath({
    category: "gemini-tools",
    name: "file",
    colorType: "primary"
});
const GEMINI_TOOLS_SETTINGS = getIconPath({
    category: "gemini-tools",
    name: "settings",
    colorType: "primary"
});
const MENU_DELETE = getIconPath({
    category: "menus",
    name: "delete",
    colorType: "primary"
});
const CHECKBOX_ALL_CHECKED_VALUE = "allChecked";
const CHECKBOX_ALL_UNCHECKED_VALUE = "allUnchecked";
export class GxIdeKbManagerImport {
    constructor() {
        /**
         * The component hard-coded strings translations.
         */
        // eslint-disable-next-line @stencil-community/own-props-must-be-private
        _GxIdeKbManagerImport_componentLocale.set(this, void 0);
        _GxIdeKbManagerImport_selectedObjectsInFileIds.set(this, []);
        _GxIdeKbManagerImport_fileInputEl.set(this, void 0);
        _GxIdeKbManagerImport_fileInputHiddenEl.set(this, void 0);
        _GxIdeKbManagerImport_objectsTreeEl.set(this, void 0);
        _GxIdeKbManagerImport_successItemsIds.set(this, new Set());
        _GxIdeKbManagerImport_warningItemsIds.set(this, new Set());
        _GxIdeKbManagerImport_errorItemsIds.set(this, new Set());
        // #categoryItemMap maps a category id, with the name and icon.
        // required for the "import status" tree.
        _GxIdeKbManagerImport_categoryItemMap.set(this, new Map());
        _GxIdeKbManagerImport_objectCategoryItemMap.set(this, new Map());
        _GxIdeKbManagerImport_importedCategoryData.set(this, void 0);
        _GxIdeKbManagerImport_cancelImportHandler.set(this, () => {
            this.cancelCallback();
        });
        _GxIdeKbManagerImport_clearStatusHandler.set(this, () => {
            this.importTreeState = [];
            this.statusInfo.error.number = 0;
            this.statusInfo.warning.number = 0;
            this.statusInfo.success.number = 0;
        });
        _GxIdeKbManagerImport_evaluateImport.set(this, () => {
            var _a;
            this.noImport = !!(((_a = this.importTreeState) === null || _a === void 0 ? void 0 : _a.length) === 0 || !this.importTreeState);
        });
        _GxIdeKbManagerImport_evaluateImportStatusMessage.set(this, () => {
            this.someStatusVisible =
                this.statusInfo.error.display ||
                    this.statusInfo.warning.display ||
                    this.statusInfo.success.display;
        });
        _GxIdeKbManagerImport_importObjectsHandler.set(this, async () => {
            var _a;
            /* first clear imported objects (this clears errors/warnings/success counts as well)*/
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_clearStatusHandler, "f").call(this);
            /* then do the import*/
            this.importingIsInProcess = true;
            /*
              Process checked objects manually, considering lazy loading.
              Example:
              1. The "Attributes" category is lazy-loaded and marked as checked.
              2. The user runs the import without expanding the node.
              3. No attribute objects appear as checked, since lazy load was not triggered.
              4. Still, all attribute objects must be included, because the category itself is checked.
        
              This avoids forcing users to expand nodes just to select objects.
              Large categories are not expanded by default to improve performance, which is crucial
              for very large imports (1000+ objects).
            */
            const checkedSet = new Set();
            for (const category of __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeEl, "f").model) {
                if (((_a = category.items) === null || _a === void 0 ? void 0 : _a.length) > 0) {
                    for (const obj of category.items) {
                        if (obj.checked) {
                            checkedSet.add(obj.id);
                        }
                    }
                }
                else if (category.lazy && category.checked) {
                    const categoryData = __classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f").find(cat => cat.id == category.id);
                    for (const obj of categoryData.items) {
                        checkedSet.add(obj.id);
                    }
                }
            }
            // Compute excluded ids against the full file contents so the server's importAll branch can be used without re-reading the tree.
            const excludedObjectIds = [];
            for (const category of __classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f")) {
                for (const obj of category.items) {
                    if (!checkedSet.has(obj.id)) {
                        excludedObjectIds.push(obj.id);
                    }
                }
            }
            const objectIds = Array.from(checkedSet);
            const importAll = excludedObjectIds.length <= objectIds.length;
            const importOptions = {
                importAll,
                objectIds: importAll ? [] : objectIds,
                excludedObjectIds: importAll ? excludedObjectIds : []
            };
            await this.importCallback(importOptions);
            this.importingIsInProcess = false;
        });
        _GxIdeKbManagerImport_loadFileHandler.set(this, async (file) => {
            __classPrivateFieldSet(this, _GxIdeKbManagerImport_importedCategoryData, await this.loadCallback(file), "f");
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_categoryItemMap, "f").clear();
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectCategoryItemMap, "f").clear();
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f").forEach(category => {
                __classPrivateFieldGet(this, _GxIdeKbManagerImport_categoryItemMap, "f").set(category.id, {
                    name: category.name,
                    icon: category.icon
                });
                category.items.forEach(object => {
                    __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectCategoryItemMap, "f").set(object.id, category.id);
                });
            });
            const importCategoryTreeData = convertImportCategoryDataToTreeView(__classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f"));
            this.objectsTreeModel = importCategoryTreeData;
            // Tree-view renders with `checked={true}` by default, so a freshly
            // loaded file starts with everything selected.
            this.hasSelection = importCategoryTreeData.length > 0;
        });
        _GxIdeKbManagerImport_lazyLoadTreeItems.set(this, async (treeItemId) => {
            const category = __classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f").find(cat => cat.id === treeItemId);
            return category && category.items.length > 0
                ? convertImportCategoryItemToTreeItem(category.icon, category.items)
                : [];
        });
        _GxIdeKbManagerImport_objectsTreeCheckedItemsChangedHandler.set(this, (event) => {
            const allItems = event.detail;
            const checkedItemIds = [];
            const pendingCheckedItemIds = [];
            const checkedObjectsIds = [];
            allItems.forEach(item => {
                if (item.item.checked) {
                    checkedItemIds.push(item.item.id);
                    if (item.item.lazy && !item.item.items)
                        pendingCheckedItemIds.push(item.item.id);
                }
                if (item.item.checked && item.item.metadata === KB_OBJECT) {
                    checkedObjectsIds.push(item.item.id);
                }
            });
            for (let pendingCheckedItemId of pendingCheckedItemIds) {
                const category = __classPrivateFieldGet(this, _GxIdeKbManagerImport_importedCategoryData, "f").find(cat => cat.id === pendingCheckedItemId);
                if (category) {
                    for (let item of category.items) {
                        if (checkedObjectsIds.indexOf(item.id) < 0)
                            checkedObjectsIds.push(item.id);
                    }
                }
            }
            // Evaluate "Select All / Unselect All" checkbox state
            if (allItems.size === checkedItemIds.length) {
                this.selectAllCheckboxValue = CHECKBOX_ALL_CHECKED_VALUE;
                this.selectAllCheckboxIndeterminate = false;
            }
            else if (checkedItemIds.length === 0) {
                this.selectAllCheckboxValue = CHECKBOX_ALL_UNCHECKED_VALUE;
                this.selectAllCheckboxIndeterminate = false;
            }
            else {
                this.selectAllCheckboxIndeterminate = true;
            }
            this.hasSelection = checkedItemIds.length > 0;
        });
        _GxIdeKbManagerImport_objectsTreeContextMenuHandler.set(this, (event) => {
            if (event.detail.metadata === KB_OBJECT) {
                this.objectContextMenuCallback("imported", {
                    selection: __classPrivateFieldGet(this, _GxIdeKbManagerImport_selectedObjectsInFileIds, "f"),
                    clientX: event.detail.contextmenuEvent.screenX,
                    clientY: event.detail.contextmenuEvent.screenY
                });
            }
        });
        _GxIdeKbManagerImport_objectsTreeSelectedItemsChangedHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeKbManagerImport_selectedObjectsInFileIds, event.detail.map(item => item.item.id), "f");
        });
        _GxIdeKbManagerImport_optionsHandler.set(this, () => {
            if (this.optionsCallback) {
                this.optionsCallback();
                // returns boolean
            }
        });
        _GxIdeKbManagerImport_removeFileSelection.set(this, () => {
            this.selectedFile = null;
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_fileInputHiddenEl, "f").value = null;
        });
        _GxIdeKbManagerImport_selectFileInputHandler.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_fileInputHiddenEl, "f").click();
        });
        _GxIdeKbManagerImport_selectFileInputChangedHandler.set(this, (event) => {
            var _a;
            const target = event.target;
            if (((_a = target.files) === null || _a === void 0 ? void 0 : _a.length) > 0) {
                this.selectedFile = target.files[0];
            }
        });
        _GxIdeKbManagerImport_statusButtonsSelectionChangedHandler.set(this, (event) => {
            const activeStates = event.detail;
            const statuses = [];
            const errorIndex = activeStates.findIndex(state => state.itemId === "errors");
            const warningIndex = activeStates.findIndex(state => state.itemId === "warnings");
            const successIndex = activeStates.findIndex(state => state.itemId === "successes");
            if (errorIndex !== -1) {
                statuses.push("error");
            }
            if (warningIndex !== -1) {
                statuses.push("warning");
            }
            if (successIndex !== -1) {
                statuses.push("success");
            }
            let pattern = `"${STATUS_REGEXP_KEY}":""`;
            if (statuses.length) {
                const statusOptions = statuses.join("|");
                pattern = `"${STATUS_REGEXP_KEY}":"(${statusOptions})"`;
            }
            this.importedTreeFilterRegExp = new RegExp(pattern, "i");
            // Update statusInfo for the status-buttons
            this.statusInfo = {
                error: {
                    display: errorIndex !== -1,
                    number: this.statusInfo.error.number
                },
                warning: {
                    display: warningIndex !== -1,
                    number: this.statusInfo.warning.number
                },
                success: {
                    display: successIndex !== -1,
                    number: this.statusInfo.success.number
                }
            };
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_evaluateImportStatusMessage, "f").call(this);
        });
        _GxIdeKbManagerImport_toggleSelectionClickHandler.set(this, (event) => {
            if (__classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeEl, "f")) {
                const checked = event.detail === CHECKBOX_ALL_CHECKED_VALUE;
                __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeEl, "f").updateAllItemsProperties({ checked: checked });
                // updateAllItemsProperties does not fire onCheckedItemsChange, so we
                // mirror the new selection state explicitly to keep the Import button
                // disabled when the user unchecks everything via this toggle.
                this.hasSelection = checked && this.objectsTreeModel.length > 0;
            }
        });
        _GxIdeKbManagerImport_updateStatusItemsState.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_errorItemsIds, "f").clear();
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_warningItemsIds, "f").clear();
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_successItemsIds, "f").clear();
            this.importTreeState.forEach(item => {
                const items = item.items;
                items.forEach(child => {
                    if (child.metadata === "error") {
                        __classPrivateFieldGet(this, _GxIdeKbManagerImport_errorItemsIds, "f").add(child.id);
                    }
                    if (child.metadata === "warning") {
                        __classPrivateFieldGet(this, _GxIdeKbManagerImport_warningItemsIds, "f").add(child.id);
                    }
                    if (child.metadata === "success") {
                        __classPrivateFieldGet(this, _GxIdeKbManagerImport_successItemsIds, "f").add(child.id);
                    }
                });
            });
        });
        this.selectAllCheckboxValue = undefined;
        this.selectAllCheckboxIndeterminate = false;
        this.hasSelection = false;
        this.importStatusMessage = undefined;
        this.importTreeState = [];
        this.importedTreeFilterRegExp = undefined;
        this.importingIsInProcess = false;
        this.importTreeFilterList = [];
        this.noImport = undefined;
        this.noObjects = true;
        this.objectsTreeModel = [];
        this.showHiddenImportsMessage = false;
        this.someStatusVisible = undefined;
        this.statusInfo = {
            error: {
                display: true,
                number: 0
            },
            warning: {
                display: true,
                number: 0
            },
            success: {
                display: true,
                number: 0
            }
        };
        this.cancelCallback = undefined;
        this.importCallback = undefined;
        this.loadCallback = undefined;
        this.objectContextMenuCallback = undefined;
        this.optionsCallback = undefined;
        this.selectedFile = undefined;
        this.statusMinimal = false;
    }
    importTreeStateChanged() {
        // this.#filterImportedHandler();
    }
    watchImportTreeStateHandler() {
        __classPrivateFieldGet(this, _GxIdeKbManagerImport_evaluateImport, "f").call(this);
        if (this.noImport) {
            this.importStatusMessage =
                __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.importStatus.noImportedFiles;
        }
        else {
            this.importStatusMessage =
                __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.importStatus.importedButHidden;
        }
    }
    watchObjectsTreeModelHandler(newState) {
        this.noObjects = !newState || newState.length === 0;
    }
    selectedFileChanged(newFile) {
        if (newFile) {
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_loadFileHandler, "f").call(this, newFile);
        }
    }
    componentDidLoad() {
        __classPrivateFieldGet(this, _GxIdeKbManagerImport_fileInputEl, "f").focus();
    }
    componentDidRender() { }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeKbManagerImport_componentLocale, await Locale.getComponentStrings(this.el), "f");
        this.componentDidLoadEvent.emit(true);
        // this.#evaluateObjects();
        __classPrivateFieldGet(this, _GxIdeKbManagerImport_evaluateImport, "f").call(this);
        this.importStatusMessage =
            __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.importStatus.noImportedFiles;
        __classPrivateFieldGet(this, _GxIdeKbManagerImport_evaluateImportStatusMessage, "f").call(this);
    }
    /**
     * Add the result of importing an item
     */
    async addResultItem(item) {
        this.importTreeState = addImportItemResultDataItem(item, __classPrivateFieldGet(this, _GxIdeKbManagerImport_categoryItemMap, "f"), __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectCategoryItemMap, "f"), this.importTreeState);
        this.statusInfo[item.status].number++;
        __classPrivateFieldGet(this, _GxIdeKbManagerImport_updateStatusItemsState, "f").call(this);
    }
    render() {
        var _a, _b;
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("section", { class: "section" }, h("header", {
            // header
            class: "field-group dialog-header-with-border header header-two-cols spacing-body-block-start spacing-body-inline", slot: "header"
        }, h("div", {
            // select a file
            class: "field field-inline"
        }, h("label", { class: "label", htmlFor: "file-name" }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").header.fileNameLabel), h("ch-edit", { autoFocus: true, id: "file-name", class: "input", part: "file-name", type: "text", readonly: true, value: (_a = this.selectedFile) === null || _a === void 0 ? void 0 : _a.name, placeholder: __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").header.fileNamePlaceholder, startImgSrc: FILE_ICON, ref: (el) => (__classPrivateFieldSet(this, _GxIdeKbManagerImport_fileInputEl, el, "f")) }), h("input", { hidden: true, type: "file", accept: ".xpz, .xml", onChange: __classPrivateFieldGet(this, _GxIdeKbManagerImport_selectFileInputChangedHandler, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeKbManagerImport_fileInputHiddenEl, el, "f")) })), h("div", { class: "buttons-spacer" }, h("button", { "aria-label": __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").header.removeFileSelection, title: __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").header.removeFileSelection, id: "reset-all-button", class: "button-tertiary button-icon-only", part: "reset-all-button", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_removeFileSelection, "f") }, h("ch-image", { class: "icon-m", src: MENU_DELETE })), h("button", {
            // select file
            id: "select-file-load-button", class: "button-primary", part: "select-file-load-button", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_selectFileInputHandler, "f"), disabled: this.importingIsInProcess
        }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").header.selectFileButton))), h("section", {
            // objects in file
            class: "objects-in-file__section"
        }, h("h2", { class: "dialog-header dialog-header-with-border dialog-header__objects-in-file subtitle-regular-xs\t text-align-center spacing-body-inline" }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.title), h("div", { class: "field-group objects-in-file__main" }, !this.noObjects ? (h("ch-tree-view-render", {
            // objects in file tree
            showLines: "last", class: "tree-view tree-view-import", model: this.objectsTreeModel, dragDisabled: true, dropDisabled: true, toggleCheckboxes: true, checkbox: true, checked: true, lazyLoadTreeItemsCallback: __classPrivateFieldGet(this, _GxIdeKbManagerImport_lazyLoadTreeItems, "f"), onCheckedItemsChange: __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeCheckedItemsChangedHandler, "f"), onSelectedItemsChange: __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeSelectedItemsChangedHandler, "f"), onItemContextmenu: __classPrivateFieldGet(this, _GxIdeKbManagerImport_objectsTreeContextMenuHandler, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeKbManagerImport_objectsTreeEl, el, "f"))
        })) : (h("gx-ide-empty-state", { isAnimated: false, stateTitle: __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.noObjects, key: "no-objects-empty-state" }, h("button", {
            // begin by selecting a file
            class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_selectFileInputHandler, "f")
        }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.selectFile))), h("footer", { class: "field-group objects-in-file__footer spacing-body-inline" }, h("ch-checkbox", {
            // select all / unselect all checkbox
            id: "select-all-checkbox", class: "checkbox create-data-in-kb", checkedValue: CHECKBOX_ALL_CHECKED_VALUE, unCheckedValue: CHECKBOX_ALL_UNCHECKED_VALUE, caption: __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.selectUnselect, value: this.selectAllCheckboxValue, onInput: __classPrivateFieldGet(this, _GxIdeKbManagerImport_toggleSelectionClickHandler, "f"), disabled: this.importingIsInProcess ||
                this.objectsTreeModel.length === 0, part: "select-all-checkbox"
        }), h("div", { class: "buttons-spacer" }, h("button", {
            // import objects button
            id: "import-btn", class: "button-primary ", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_importObjectsHandler, "f"), disabled: ((_b = this.objectsTreeModel) === null || _b === void 0 ? void 0 : _b.length) === 0 ||
                this.importingIsInProcess ||
                !this.hasSelection
        }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.importButton), h("button", {
            // cancel-import button
            id: "cancel-import-btn", class: "button-secondary ", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_cancelImportHandler, "f"), disabled: !this.importingIsInProcess, part: "cancel-import-button"
        }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.objectsInFile.cancelButton), h("button", {
            // settings/options button
            id: "select-kb-btn", class: "button-tertiary button-icon-only", part: "select-kb-btn", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_optionsHandler, "f")
        }, h("ch-image", { class: "icon-m", src: GEMINI_TOOLS_SETTINGS })))))), h("section", {
            // import status
            class: "import-status__section"
        }, h("h2", { class: "dialog-header dialog-header-with-border dialog-header__import-status subtitle-regular-xs\t text-align-center spacing-body-inline" }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.importStatus.title), h("div", { class: "field-group import-status__main" }, !this.noImport && this.someStatusVisible ? (h("ch-tree-view-render", {
            // import status tree
            model: this.importTreeState, toggleCheckboxes: true, showLines: "last", class: "tree-view tree-view-import", filter: this.importedTreeFilterRegExp, filterType: "metadata", filterOptions: {
                autoExpand: true,
                hideMatchesAndShowNonMatches: false
            }
        })) : (h("gx-ide-empty-state", { isAnimated: false, stateIconSrc: NOTICE_ICON, stateTitle: this.importStatusMessage, key: "no-objects-empty-state" })), h("footer", { class: "import-status__footer spacing-body-inline" }, h("button", {
            // clear status button
            class: "button-secondary import-clear-status-btn", onClick: __classPrivateFieldGet(this, _GxIdeKbManagerImport_clearStatusHandler, "f"), disabled: this.noImport || this.importingIsInProcess, part: "clear-status-btn"
        }, __classPrivateFieldGet(this, _GxIdeKbManagerImport_componentLocale, "f").main.importStatus.clearButton)))), h("footer", {
            // footer
            class: "footer"
        }, h("gx-ide-status-buttons", { errors: this.statusInfo.error.number, warnings: this.statusInfo.warning.number, successes: this.statusInfo.success.number, hideMessage: true, compact: true, minimal: this.statusMinimal, onSelectionChanged: __classPrivateFieldGet(this, _GxIdeKbManagerImport_statusButtonsSelectionChangedHandler, "f") })))));
    }
    static get is() { return "gx-ide-kb-manager-import"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["kb-manager-import.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["kb-manager-import.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/kb-manager-import"]; }
    static get properties() {
        return {
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "CancelCallback",
                    "resolved": "() => Promise<boolean>",
                    "references": {
                        "CancelCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/kb-manager-import/kb-manager-import.tsx",
                            "id": "src/components/kb-manager-import/kb-manager-import.tsx::CancelCallback"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user wants to cancel the export process."
                }
            },
            "importCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ImportCallback",
                    "resolved": "(importOptions: ImportOptions) => Promise<boolean>",
                    "references": {
                        "ImportCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/kb-manager-import/kb-manager-import.tsx",
                            "id": "src/components/kb-manager-import/kb-manager-import.tsx::ImportCallback"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user wants to initiate the import process."
                }
            },
            "loadCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LoadCallback",
                    "resolved": "(file: File) => Promise<ImportCategoryData[]>",
                    "references": {
                        "LoadCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/kb-manager-import/kb-manager-import.tsx",
                            "id": "src/components/kb-manager-import/kb-manager-import.tsx::LoadCallback"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user wants to load the xpz information"
                }
            },
            "objectContextMenuCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ObjectContextMenuCallback",
                    "resolved": "(tree: ObjectsSourceType, contextMenuInfo: ContextMenuInfo) => Promise<void>",
                    "references": {
                        "ObjectContextMenuCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/kb-manager-import/kb-manager-import.tsx",
                            "id": "src/components/kb-manager-import/kb-manager-import.tsx::ObjectContextMenuCallback"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Displays status buttons (errors, warning, succeeded) with minimal UI (no captions)"
                }
            },
            "optionsCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "OptionsCallback",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "OptionsCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/kb-manager-import/kb-manager-import.tsx",
                            "id": "src/components/kb-manager-import/kb-manager-import.tsx::OptionsCallback"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user wants to access the export options."
                }
            },
            "selectedFile": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "File",
                    "resolved": "File",
                    "references": {
                        "File": {
                            "location": "global",
                            "id": "global::File"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Imported xml or xps file name"
                }
            },
            "statusMinimal": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "false",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Displays status buttons (error, warning, success) with minimal UI (no captions)."
                },
                "attribute": "status-minimal",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "selectAllCheckboxValue": {},
            "selectAllCheckboxIndeterminate": {},
            "hasSelection": {},
            "importStatusMessage": {},
            "importTreeState": {},
            "importedTreeFilterRegExp": {},
            "importingIsInProcess": {},
            "importTreeFilterList": {},
            "noImport": {},
            "noObjects": {},
            "objectsTreeModel": {},
            "showHiddenImportsMessage": {},
            "someStatusVisible": {},
            "statusInfo": {}
        };
    }
    static get events() {
        return [{
                "method": "componentDidLoadEvent",
                "name": "componentDidLoadEvent",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emitted once just after the component is fully loaded."
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }, {
                "method": "componentDidRenderFirstTime",
                "name": "componentDidRenderFirstTime",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emitted once just after the component is fully loaded and the first render() occurs"
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }];
    }
    static get methods() {
        return {
            "addResultItem": {
                "complexType": {
                    "signature": "(item: ImportItemResultData) => Promise<void>",
                    "parameters": [{
                            "name": "item",
                            "type": "{ id: string; name: string; status: \"error\" | \"success\" | \"warning\"; messages?: string[]; }",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "ImportItemResultData": {
                            "location": "import",
                            "path": "../../common/types",
                            "id": "src/common/types.ts::ImportItemResultData"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Add the result of importing an item",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "importTreeState",
                "methodName": "importTreeStateChanged"
            }, {
                "propName": "importTreeState",
                "methodName": "watchImportTreeStateHandler"
            }, {
                "propName": "objectsTreeModel",
                "methodName": "watchObjectsTreeModelHandler"
            }, {
                "propName": "selectedFile",
                "methodName": "selectedFileChanged"
            }];
    }
}
_GxIdeKbManagerImport_componentLocale = new WeakMap(), _GxIdeKbManagerImport_selectedObjectsInFileIds = new WeakMap(), _GxIdeKbManagerImport_fileInputEl = new WeakMap(), _GxIdeKbManagerImport_fileInputHiddenEl = new WeakMap(), _GxIdeKbManagerImport_objectsTreeEl = new WeakMap(), _GxIdeKbManagerImport_successItemsIds = new WeakMap(), _GxIdeKbManagerImport_warningItemsIds = new WeakMap(), _GxIdeKbManagerImport_errorItemsIds = new WeakMap(), _GxIdeKbManagerImport_categoryItemMap = new WeakMap(), _GxIdeKbManagerImport_objectCategoryItemMap = new WeakMap(), _GxIdeKbManagerImport_importedCategoryData = new WeakMap(), _GxIdeKbManagerImport_cancelImportHandler = new WeakMap(), _GxIdeKbManagerImport_clearStatusHandler = new WeakMap(), _GxIdeKbManagerImport_evaluateImport = new WeakMap(), _GxIdeKbManagerImport_evaluateImportStatusMessage = new WeakMap(), _GxIdeKbManagerImport_importObjectsHandler = new WeakMap(), _GxIdeKbManagerImport_loadFileHandler = new WeakMap(), _GxIdeKbManagerImport_lazyLoadTreeItems = new WeakMap(), _GxIdeKbManagerImport_objectsTreeCheckedItemsChangedHandler = new WeakMap(), _GxIdeKbManagerImport_objectsTreeContextMenuHandler = new WeakMap(), _GxIdeKbManagerImport_objectsTreeSelectedItemsChangedHandler = new WeakMap(), _GxIdeKbManagerImport_optionsHandler = new WeakMap(), _GxIdeKbManagerImport_removeFileSelection = new WeakMap(), _GxIdeKbManagerImport_selectFileInputHandler = new WeakMap(), _GxIdeKbManagerImport_selectFileInputChangedHandler = new WeakMap(), _GxIdeKbManagerImport_statusButtonsSelectionChangedHandler = new WeakMap(), _GxIdeKbManagerImport_toggleSelectionClickHandler = new WeakMap(), _GxIdeKbManagerImport_updateStatusItemsState = new WeakMap();
//# sourceMappingURL=kb-manager-import.js.map
