var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { css, html, customElement, property, state, nothing, repeat } from '../../../../../external/lit/index.js';
import { UmbTextStyles } from '../../../style/index.js';
import { UmbLitElement } from '../../../lit-element/index.js';
let UmbWorkspaceActionMenuElement = class UmbWorkspaceActionMenuElement extends UmbLitElement {
    constructor() {
        super(...arguments);
        this.look = 'secondary';
        this.color = 'default';
        this.items = [];
        this._popoverOpen = false;
    }
    #onPopoverToggle(event) {
        // TODO: This ignorer is just neede for JSON SCHEMA TO WORK, As its not updated with latest TS jet.
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        // @ts-ignore
        this._popoverOpen = event.newState === 'open';
    }
    render() {
        if (!this.items?.length)
            return nothing;
        return html `
			<uui-button
				id="popover-trigger"
				popovertarget="workspace-action-popover"
				look="${this.look}"
				color="${this.color}"
				label=${this.localize.term('visuallyHiddenTexts_tabExpand')}
				compact>
				<uui-symbol-expand id="expand-symbol" .open=${this._popoverOpen}></uui-symbol-expand>
			</uui-button>
			<uui-popover-container
				id="workspace-action-popover"
				margin="6"
				placement="top-end"
				@toggle=${this.#onPopoverToggle}>
				<umb-popover-layout id="workspace-action-popover-layout">
					<uui-scroll-container>
						${repeat(this.items, (ext) => ext.alias, (ext) => ext.component)}
					</uui-scroll-container>
				</umb-popover-layout>
			</uui-popover-container>
		`;
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			:host {
				--uui-menu-item-flat-structure: 1;
			}

			#expand-symbol {
				/* TODO: remove this hack and use a proper UUI symbol for this */
				transform: rotate(-90deg);
			}

			#expand-symbol[open] {
				transform: rotate(0deg);
			}

			#workspace-action-popover {
				min-width: 200px;
			}

			#popover-trigger {
				--uui-button-padding-top-factor: 0;
				--uui-button-padding-bottom-factor: 0.125;
			}

			#workspace-action-popover-layout {
				overflow: visible;
			}
		`,
    ]; }
};
__decorate([
    property()
], UmbWorkspaceActionMenuElement.prototype, "look", void 0);
__decorate([
    property()
], UmbWorkspaceActionMenuElement.prototype, "color", void 0);
__decorate([
    property({ type: Array, attribute: false })
], UmbWorkspaceActionMenuElement.prototype, "items", void 0);
__decorate([
    state()
], UmbWorkspaceActionMenuElement.prototype, "_popoverOpen", void 0);
UmbWorkspaceActionMenuElement = __decorate([
    customElement('umb-workspace-action-menu')
], UmbWorkspaceActionMenuElement);
export { UmbWorkspaceActionMenuElement };
