import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { c as config } from './config.js';
import { L as Locale } from './locale.js';
import { d as defineCustomElement$5 } from './bpm-objects-selector.js';
import { d as defineCustomElement$4 } from './container.js';
import { d as defineCustomElement$3 } from './list-selector.js';
import { d as defineCustomElement$2 } from './list-selector-item.js';

const bpmExportXpdlCss = ":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}.control-wrapper{display:flex;gap:var(--spacing-gap-m);align-items:center}.control-wrapper--vertical{flex-direction:column;align-items:start}.controls-wrapper{display:flex;gap:var(--spacing-gap-m)}.controls-wrapper--vertical{flex-direction:column;align-items:start}.input-text{box-sizing:border-box;background-color:transparent;border:1px solid var(--color-border-neutral-default);border-radius:4px;height:26px;color:var(--color-text-neutral-default);font-size:var(--font-size-body-xs)}.input-text--full-width{align-self:stretch}:host{display:block}.header{display:grid;grid-template-columns:1fr min-content min-content;grid-template-areas:\"label label label\" \"input cancel export\";grid-gap:var(--spacing-gap-l)}.header .label{grid-area:label}.header .input{grid-area:input}.header .cancel{grid-area:cancel}.header .export{grid-area:export}";

const GxIdeBpmExportXpdl$1 = /*@__PURE__*/ proxyCustomElement(class GxIdeBpmExportXpdl extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.componentDidRenderFirstTime = createEvent(this, "componentDidRenderFirstTime", 7);
        this.renderedFirstTime = false;
        // 7.LISTENERS //
        // 8.PUBLIC METHODS API //
        // 9.LOCAL METHODS //
        this.exportHandler = () => {
            var _a;
            if (this.exportCallback) {
                this.notExporting = false;
                const data = {
                    directoryName: this.exportInputEl.value,
                    Objects: (_a = this.bpmObjectSelectorEl.selection) !== null && _a !== void 0 ? _a : {
                        includeAll: false,
                        objectIds: []
                    }
                };
                this.exportCallback(data)
                    .then(() => {
                    this.notExporting = true;
                })
                    .catch(() => {
                    // error handling
                    this.notExporting = true;
                });
            }
        };
        this.inputHandle = async () => {
            var _a;
            this.emptyInput = !((_a = this.exportInputEl.value) === null || _a === void 0 ? void 0 : _a.length);
        };
        this.handleSelectionChanged = () => {
            this.emptyObjects = !this.bpmObjectSelectorEl.selection.objectIds.length;
        };
        this.emptyInput = true;
        this.emptyObjects = true;
        this.notExporting = true;
        this.displayTitle = false;
        this.exportCallback = undefined;
        this.cancelCallback = undefined;
        this.addCallback = undefined;
        this.referencesCallback = undefined;
    }
    // 6.COMPONENT LIFECYCLE METHODS //
    async componentWillLoad() {
        this._componentLocale = await Locale.getComponentStrings(this.el);
    }
    componentDidRender() {
        if (!this.renderedFirstTime) {
            this.componentDidRenderFirstTime.emit(this._componentLocale.componentName);
            this.renderedFirstTime = true;
        }
    }
    // 10.RENDER() FUNCTION //
    render() {
        return (h(Host, { class: "gx-ide-component" }, h("div", { class: "gx-ide-main-wrapper" }, h("gx-ide-container", { slimmerFooter: config.gxIdeContainer.slimmerFooter }, h("div", { class: "header" }, h("label", { htmlFor: "export-directory", class: "label" }, this._componentLocale.main.exportInputLabel), h("input", { type: "text", id: "export-directory", class: "input-text input", onInput: this.inputHandle, ref: el => (this.exportInputEl = el) }), h("button", { class: "export", disabled: this.emptyInput || this.emptyObjects, onClick: this.exportHandler }, this._componentLocale.main.exportButton), h("button", { class: "cancel", disabled: this.notExporting, onClick: this.cancelCallback }, this._componentLocale.main.cancelButton)), h("gx-ide-bpm-objects-selector", { id: "gx-ide-bpm-objects-selector", addCallback: this.addCallback, referencesCallback: this.referencesCallback, ref: el => (this.bpmObjectSelectorEl =
                el), onSelectionChanged: this.handleSelectionChanged })))));
    }
    static get assetsDirs() { return ["gx-ide-assets/bpm-export-xpdl"]; }
    get el() { return this; }
    static get style() { return bpmExportXpdlCss; }
}, [1, "gx-ide-bpm-export-xpdl", {
        "displayTitle": [4, "display-title"],
        "exportCallback": [16],
        "cancelCallback": [16],
        "addCallback": [16],
        "referencesCallback": [16],
        "emptyInput": [32],
        "emptyObjects": [32],
        "notExporting": [32]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-bpm-export-xpdl", "gx-ide-bpm-objects-selector", "gx-ide-container", "gx-ide-list-selector", "gx-ide-list-selector-item"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-bpm-export-xpdl":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GxIdeBpmExportXpdl$1);
            }
            break;
        case "gx-ide-bpm-objects-selector":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "gx-ide-container":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "gx-ide-list-selector":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "gx-ide-list-selector-item":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const GxIdeBpmExportXpdl = GxIdeBpmExportXpdl$1;
const defineCustomElement = defineCustomElement$1;

export { GxIdeBpmExportXpdl, defineCustomElement };

//# sourceMappingURL=gx-ide-bpm-export-xpdl.js.map