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 _GxIdeGamInstallationSettings__componentLocale, _GxIdeGamInstallationSettings_futureUpgradesComboEl, _GxIdeGamInstallationSettings_panelsCheckboxEl, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, _GxIdeGamInstallationSettings_cancelCallbackHandler, _GxIdeGamInstallationSettings_checkboxChangeHandler, _GxIdeGamInstallationSettings_repairCallbackHandler, _GxIdeGamInstallationSettings_renderFilters, _GxIdeGamInstallationSettings_renderDescription, _GxIdeGamInstallationSettings_saveCallbackHandler;
/* eslint-disable @stencil-community/own-props-must-be-private */
/* STENCIL IMPORTS */
import { Host, h } from "@stencil/core";
import { Locale } from "../../common/locale";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/checkbox",
    "components/combo-box",
    "components/edit",
    "utils/form",
    "utils/layout",
    "utils/typography"
];
export class GxIdeGamInstallationSettings {
    constructor() {
        /**
         * The component hard-coded strings translations.
         */
        _GxIdeGamInstallationSettings__componentLocale.set(this, void 0);
        _GxIdeGamInstallationSettings_futureUpgradesComboEl.set(this, void 0);
        _GxIdeGamInstallationSettings_panelsCheckboxEl.set(this, void 0);
        _GxIdeGamInstallationSettings_webPanelsCheckboxEl.set(this, void 0);
        _GxIdeGamInstallationSettings_cancelCallbackHandler.set(this, () => {
            this.cancelCallback();
        });
        _GxIdeGamInstallationSettings_checkboxChangeHandler.set(this, () => {
            if (!__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, "f").value && !__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_panelsCheckboxEl, "f").value) {
                __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value = "never";
            }
            else if (__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value === "never") {
                __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value = "prompt";
            }
        });
        _GxIdeGamInstallationSettings_repairCallbackHandler.set(this, async () => {
            if (this.saveCallback) {
                const data = {
                    importWebPanels: !!__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, "f").value,
                    importPanels: !!__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_panelsCheckboxEl, "f").value,
                    futureUpgrades: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value
                        ? __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value
                        : null
                };
                await this.repairCallback(data);
            }
        });
        _GxIdeGamInstallationSettings_renderFilters.set(this, () => {
            var _a;
            return (h("div", { class: "field-group", role: "region", "aria-label": __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.filtersHeading }, h("h5", { class: "subtitle-regular-s margin-block-end-s" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.filtersHeading), h("div", { class: "filters__wrapper" }, h("div", { class: "field-group", role: "group", "aria-labelledby": "frontend-objects-label" }, h("div", { class: "field field-block" }, h("label", { id: "frontend-objects-label", class: "label" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.frontEndObjects), h("div", { class: "field-group-inline" }, h("ch-checkbox", { class: "checkbox", checkedValue: "webPanels", value: ((_a = this.defaultConfiguration) === null || _a === void 0 ? void 0 : _a.importWebPanels)
                    ? "webPanels"
                    : undefined, caption: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.webPanelsCheckbox, onInput: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_checkboxChangeHandler, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, el, "f")), part: "web-panels-checkbox" }), h("ch-checkbox", { class: "checkbox", checkedValue: "panels", value: this.defaultConfiguration.importPanels &&
                    this.canSelectPanels
                    ? "panels"
                    : undefined, caption: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.panelsCheckbox, disabled: !this.canSelectPanels, onInput: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_checkboxChangeHandler, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeGamInstallationSettings_panelsCheckboxEl, el, "f")), part: "panels-checkbox" }))), h("div", { class: "field field-block" }, h("label", { class: "label", htmlFor: "future-upgrades-combo" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").filters.futureUpgradesComboLabel), h("ch-combo-box-render", { id: "future-upgrades-combo", class: "combo-box", value: this.defaultConfiguration.futureUpgrades, ref: (el) => (__classPrivateFieldSet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, el, "f")), model: [
                    {
                        value: "automatic",
                        caption: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").manageFutureUpgrades
                            .installAutomatically
                    },
                    {
                        value: "prompt",
                        caption: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").manageFutureUpgrades.promptMe
                    },
                    {
                        value: "never",
                        caption: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").manageFutureUpgrades.neverUpdate
                    }
                ], part: "future-upgrades-combo" }))))));
        });
        _GxIdeGamInstallationSettings_renderDescription.set(this, () => {
            return (h("div", { class: "description" }, this.configurationType === "installation"
                ? [
                    h("p", { class: "text-body" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").header.headerTextInstallation
                        .firstSentence),
                    h("p", { class: "text-body" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").header.headerTextInstallation
                        .secondSentence),
                    h("p", { class: "text-body" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").header.headerTextInstallation
                        .thirdSentence)
                ]
                : [
                    h("p", { class: "text-body" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").header.headerTextUpdate.firstSentence),
                    h("p", { class: "text-body" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings__componentLocale, "f").header.headerTextUpdate.secondSentence)
                ]));
        });
        _GxIdeGamInstallationSettings_saveCallbackHandler.set(this, async () => {
            if (this.saveCallback) {
                const data = {
                    importWebPanels: !!__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, "f").value,
                    importPanels: !!__classPrivateFieldGet(this, _GxIdeGamInstallationSettings_panelsCheckboxEl, "f").value,
                    futureUpgrades: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value
                        ? __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_futureUpgradesComboEl, "f").value
                        : null
                };
                await this.saveCallback(data);
            }
        });
        this.cancelCallback = undefined;
        this.canSelectPanels = false;
        this.configurationType = "installation";
        this.defaultConfiguration = {
            importWebPanels: true,
            importPanels: false,
            futureUpgrades: "prompt"
        };
        this.repairCallback = undefined;
        this.saveCallback = undefined;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeGamInstallationSettings__componentLocale, await Locale.getComponentStrings(this.el), "f");
    }
    render() {
        return (h(Host, { class: "widget spacing-body" }, h("ch-theme", { model: CSS_BUNDLES }), h("div", { class: "dialog-header dialog-header-with-border" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_renderDescription, "f").call(this)), h("div", { class: "main-content field-group" }, __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_renderFilters, "f").call(this)), h("div", { class: "footer" }, this.configurationType === "update" && (h("div", { class: "footer-info" }, h("p", null, "Use Repair to import GAM components again"))), h("div", { class: "dialog-footer-with-border dialog-footer-space-between" }, this.configurationType === "update" && (h("button", { id: "repair-button", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_repairCallbackHandler, "f"), part: "button button--repair" }, "Repair")), h("div", { class: "buttons-spacer" }, h("button", { id: "cancel-button", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_cancelCallbackHandler, "f"), part: "button button--cancel" }, "Cancel"), h("button", { id: "confirm-button", class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeGamInstallationSettings_saveCallbackHandler, "f"), part: "button button--confirm" }, "Save"))))));
    }
    static get is() { return "gx-ide-gam-installation-settings"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["gam-installation-settings.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["gam-installation-settings.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/gam-installation-settings"]; }
    static get properties() {
        return {
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "CancelCallback",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "CancelCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/gam-installation-settings/gam-installation-settings.tsx",
                            "id": "src/components/gam-installation-settings/gam-installation-settings.tsx::CancelCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user wants to cancel the exportation process"
                }
            },
            "canSelectPanels": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines 'Panels' checkbox activation, enabled only if an SD generator is in the KB.\nOtherwise, the checkbox is disabled."
                },
                "attribute": "can-select-panels",
                "reflect": false,
                "defaultValue": "false"
            },
            "configurationType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "\"installation\" | \"update\"",
                    "resolved": "\"installation\" | \"update\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Specifies the configuration type to be used"
                },
                "attribute": "configuration-type",
                "reflect": false,
                "defaultValue": "\"installation\""
            },
            "defaultConfiguration": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "GamConfigData | undefined",
                    "resolved": "{ importWebPanels: boolean; importPanels: boolean; futureUpgrades: \"prompt\" | \"never\" | \"automatic\"; }",
                    "references": {
                        "GamConfigData": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/gam-installation-settings/gam-installation-settings.tsx",
                            "id": "src/components/gam-installation-settings/gam-installation-settings.tsx::GamConfigData"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines default config for initializing the dialog with stored gam config data"
                },
                "defaultValue": "{\n    importWebPanels: true,\n    importPanels: false,\n    futureUpgrades: \"prompt\"\n  }"
            },
            "repairCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "RepairCallback",
                    "resolved": "(config: GamConfigData) => Promise<void>",
                    "references": {
                        "RepairCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/gam-installation-settings/gam-installation-settings.tsx",
                            "id": "src/components/gam-installation-settings/gam-installation-settings.tsx::RepairCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user press repair button"
                }
            },
            "saveCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "SaveCallback",
                    "resolved": "(data: GamConfigData) => Promise<void>",
                    "references": {
                        "SaveCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/gam-installation-settings/gam-installation-settings.tsx",
                            "id": "src/components/gam-installation-settings/gam-installation-settings.tsx::SaveCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user initiates the export process"
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
_GxIdeGamInstallationSettings__componentLocale = new WeakMap(), _GxIdeGamInstallationSettings_futureUpgradesComboEl = new WeakMap(), _GxIdeGamInstallationSettings_panelsCheckboxEl = new WeakMap(), _GxIdeGamInstallationSettings_webPanelsCheckboxEl = new WeakMap(), _GxIdeGamInstallationSettings_cancelCallbackHandler = new WeakMap(), _GxIdeGamInstallationSettings_checkboxChangeHandler = new WeakMap(), _GxIdeGamInstallationSettings_repairCallbackHandler = new WeakMap(), _GxIdeGamInstallationSettings_renderFilters = new WeakMap(), _GxIdeGamInstallationSettings_renderDescription = new WeakMap(), _GxIdeGamInstallationSettings_saveCallbackHandler = new WeakMap();
//# sourceMappingURL=gam-installation-settings.js.map
