'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-75aef097.js');
const assetsManager = require('./assets-manager-089e91b1.js');
require('./mer-animated-dots-78490ca4.js');
require('lit');
require('lit/directives/when.js');
require('lit/directives/if-defined.js');
const config = require('./config-3bb95f39.js');
const locale = require('./locale-ff30a5f3.js');
const helpers = require('./helpers-bb6622f5.js');

const updatePartialSelectionCss = "button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;grid-template-rows:max-content 1fr max-content;overflow:auto}.section{display:contents}.header{justify-content:end}.tabular-grid-main{overflow:auto;block-size:100%}.tabular-grid-main ch-tabular-grid-cell:is(:nth-child(2),:nth-child(3),:nth-child(4)){align-items:start;justify-content:start;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-inline-size:0}";

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 __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 _GxIdeTeamDevUpdatePartialSelection__componentLocale, _GxIdeTeamDevUpdatePartialSelection_renderedFirstTime, _GxIdeTeamDevUpdatePartialSelection_shortcutsSrc, _GxIdeTeamDevUpdatePartialSelection_chGridEl, _GxIdeTeamDevUpdatePartialSelection_cancelHandler, _GxIdeTeamDevUpdatePartialSelection_confirmHandler, _GxIdeTeamDevUpdatePartialSelection_getObjectsHandler, _GxIdeTeamDevUpdatePartialSelection_listenChanges, _GxIdeTeamDevUpdatePartialSelection_removeAllHandler, _GxIdeTeamDevUpdatePartialSelection_removeSelectedObjectsHandler, _GxIdeTeamDevUpdatePartialSelection_renderObjects;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/edit",
    "components/icon",
    "components/radio-group",
    "components/tabular-grid",
    "utils/form",
    "utils/layout",
    "utils/spacing",
    "utils/typography"
];
const GEMINI_TOOLS_ADD_ICON = assetsManager.getIconPath({
    category: "gemini-tools",
    name: "add-circle",
    colorType: "primary"
});
const GxIdeTeamDevUpdatePartialSelection = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.componentDidLoadEvent = index.createEvent(this, "componentDidLoadEvent", 7);
        this.componentDidRenderFirstTime = index.createEvent(this, "componentDidRenderFirstTime", 7);
        _GxIdeTeamDevUpdatePartialSelection__componentLocale.set(this, void 0);
        _GxIdeTeamDevUpdatePartialSelection_renderedFirstTime.set(this, false);
        _GxIdeTeamDevUpdatePartialSelection_shortcutsSrc.set(this, index.getAssetPath(`./gx-ide-assets/team-dev-update-partial-selection/shortcuts.json`));
        _GxIdeTeamDevUpdatePartialSelection_chGridEl.set(this, void 0);
        _GxIdeTeamDevUpdatePartialSelection_cancelHandler.set(this, () => {
            this.cancelCallback();
        });
        _GxIdeTeamDevUpdatePartialSelection_confirmHandler.set(this, () => {
            if (this.confirmCallback) {
                const allRowsIds = [];
                this.selection.forEach(row => {
                    allRowsIds.push(row.id);
                });
                this.confirmCallback(allRowsIds);
            }
        });
        _GxIdeTeamDevUpdatePartialSelection_getObjectsHandler.set(this, () => {
            this.addCallback().then((items) => {
                if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
                    this.selection = [...this.selection, ...items];
                    this.selectedObjectsIds = [];
                }
            });
        });
        _GxIdeTeamDevUpdatePartialSelection_listenChanges.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_chGridEl, "f").addEventListener("selectionChanged", (ev) => {
                this.selectedObjectsIds = ev.detail.rowsId;
            });
        });
        _GxIdeTeamDevUpdatePartialSelection_removeAllHandler.set(this, () => {
            this.selection = [];
        });
        _GxIdeTeamDevUpdatePartialSelection_removeSelectedObjectsHandler.set(this, () => {
            const selection = this.selection.filter(item => !this.selectedObjectsIds.includes(item.id));
            this.selection = selection;
            this.selectedObjectsIds = [];
        });
        _GxIdeTeamDevUpdatePartialSelection_renderObjects.set(this, () => {
            return (index.h("ch-tabular-grid", { allowColumnReorder: false, columnResizeMode: "single", class: "tabular-grid tabular-grid-main", "row-selection-mode": "multiple", keyboardNavigationMode: "focus", ref: (el) => (__classPrivateFieldSet(this, _GxIdeTeamDevUpdatePartialSelection_chGridEl, el, "f")), part: "ch-grid-objects" }, index.h("ch-tabular-grid-columnset", { class: "tabular-grid-column-set" }, index.h("ch-tabular-grid-column", { columnName: "", settingable: false, sortable: false, size: config.config.tabularGrid.colSize.minContent, class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").tableHead.name, settingable: false, sortable: false, size: "1fr", class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").tableHead.type, settingable: false, sortable: false, size: "minmax(120px,auto)", class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").tableHead.description, settingable: false, sortable: false, size: "minmax(120px,auto)", class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").tableHead.modifiedOn, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.selection.map((obj) => (index.h("ch-tabular-grid-row", { rowid: obj.id, key: obj.id, class: "tabular-grid-row" }, index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, index.h("ch-image", { src: obj.typeIcon, class: "icon-s" })), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, obj.name), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, obj.type), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, obj.description), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, `${helpers.formatDate(obj.modifiedOn)}`))))));
        });
        this.selectedObjectsIds = [];
        this.addCallback = undefined;
        this.cancelCallback = undefined;
        this.confirmCallback = undefined;
        this.selection = [];
    }
    componentDidLoad() {
        __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_listenChanges, "f").call(this);
    }
    componentDidRender() {
        if (!__classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_renderedFirstTime, "f")) {
            this.componentDidRenderFirstTime.emit(__classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").componentName);
            __classPrivateFieldSet(this, _GxIdeTeamDevUpdatePartialSelection_renderedFirstTime, true, "f");
        }
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, await locale.Locale.getComponentStrings(this.el), "f");
        this.componentDidLoadEvent.emit(true);
    }
    /**
     * Validate necessary data input
     */
    async validate() {
        const isValid = true;
        return isValid;
    }
    render() {
        const buttonRemoveSelectedDisabled = !(this.selectedObjectsIds.length > 0);
        return (index.h(index.Host, { class: "widget" }, index.h("ch-theme", { model: CSS_BUNDLES }), index.h("ch-shortcuts", { src: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_shortcutsSrc, "f") }), index.h("section", { class: "section" }, index.h("header", { class: "header field-group dialog-header header header-two-cols spacing-body-block-start spacing-body-inline" }, index.h("div", { class: "buttons-spacer" }, index.h("button", {
            // remove selected button
            class: "button-secondary", onClick: !buttonRemoveSelectedDisabled &&
                __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_removeSelectedObjectsHandler, "f"), part: "remove", disabled: buttonRemoveSelectedDisabled
        }, __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").btnRemoveSelectedObjects), index.h("button", {
            // add button
            class: "button-secondary button-icon-and-text", onClick: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_getObjectsHandler, "f"), part: "add"
        }, index.h("ch-image", { class: "icon-m", src: GEMINI_TOOLS_ADD_ICON }), __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").btnAddObject))), __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_renderObjects, "f").call(this), index.h("footer", { class: "dialog-footer dialog-footer-space-between spacing-body-block-end spacing-body-inline" }, index.h("button", {
            // remove all button
            class: "button-tertiary", onClick: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_removeAllHandler, "f"), disabled: !(this.selection.length > 0), part: "clear"
        }, __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").footer.btnRemoveAll), index.h("div", { class: "buttons-spacer" }, index.h("button", {
            // cancel button
            class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_cancelHandler, "f"), part: "cancel"
        }, __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").footer.btnCancel), index.h("button", {
            // confirm button
            class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection_confirmHandler, "f"), part: "confirm"
        }, __classPrivateFieldGet(this, _GxIdeTeamDevUpdatePartialSelection__componentLocale, "f").footer.btnConfirm))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/team-dev-update-partial-selection"]; }
    get el() { return index.getElement(this); }
};
_GxIdeTeamDevUpdatePartialSelection__componentLocale = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_renderedFirstTime = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_shortcutsSrc = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_chGridEl = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_cancelHandler = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_confirmHandler = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_getObjectsHandler = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_listenChanges = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_removeAllHandler = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_removeSelectedObjectsHandler = new WeakMap(), _GxIdeTeamDevUpdatePartialSelection_renderObjects = new WeakMap();
GxIdeTeamDevUpdatePartialSelection.style = updatePartialSelectionCss;

exports.gx_ide_team_dev_update_partial_selection = GxIdeTeamDevUpdatePartialSelection;

//# sourceMappingURL=gx-ide-team-dev-update-partial-selection.cjs.entry.js.map