import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { L as Locale } from './locale.js';

const gamInstallationSettingsCss = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;grid-template-rows:max-content 1fr max-content;height:100%}.dialog-header{margin-block-end:16px}.main-content{grid-auto-rows:max-content}.footer-info{margin-bottom:12px}.description{display:grid;grid-auto-rows:max-content;gap:var(--spacing-gap-m)}";

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 _GxIdeGamInstallationSettings__componentLocale, _GxIdeGamInstallationSettings_futureUpgradesComboEl, _GxIdeGamInstallationSettings_panelsCheckboxEl, _GxIdeGamInstallationSettings_webPanelsCheckboxEl, _GxIdeGamInstallationSettings_cancelCallbackHandler, _GxIdeGamInstallationSettings_checkboxChangeHandler, _GxIdeGamInstallationSettings_repairCallbackHandler, _GxIdeGamInstallationSettings_renderFilters, _GxIdeGamInstallationSettings_renderDescription, _GxIdeGamInstallationSettings_saveCallbackHandler;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/checkbox",
    "components/combo-box",
    "components/edit",
    "utils/form",
    "utils/layout",
    "utils/typography"
];
const GxIdeGamInstallationSettings$1 = /*@__PURE__*/ proxyCustomElement(class GxIdeGamInstallationSettings extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        /**
         * 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 assetsDirs() { return ["gx-ide-assets/gam-installation-settings"]; }
    get el() { return this; }
    static get style() { return gamInstallationSettingsCss; }
}, [1, "gx-ide-gam-installation-settings", {
        "cancelCallback": [16],
        "canSelectPanels": [4, "can-select-panels"],
        "configurationType": [1, "configuration-type"],
        "defaultConfiguration": [16],
        "repairCallback": [16],
        "saveCallback": [16]
    }]);
_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();
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-gam-installation-settings"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-gam-installation-settings":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GxIdeGamInstallationSettings$1);
            }
            break;
    } });
}

const GxIdeGamInstallationSettings = GxIdeGamInstallationSettings$1;
const defineCustomElement = defineCustomElement$1;

export { GxIdeGamInstallationSettings, defineCustomElement };

//# sourceMappingURL=gx-ide-gam-installation-settings.js.map