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 { UMB_HELP_MENU_ALIAS } from '../menu/index.js';
import { css, customElement, html, nothing, state } from '../../../external/lit/index.js';
import { umbExtensionsRegistry } from '../../core/extension-registry/index.js';
import { UmbExtensionsManifestInitializer } from '../../../libs/extension-api/index.js';
import { UmbHeaderAppButtonElement } from '../../core/components/index.js';
let UmbHelpHeaderAppElement = class UmbHelpHeaderAppElement extends UmbHeaderAppButtonElement {
    constructor() {
        super();
        this._helpMenuHasMenuItems = false;
        new UmbExtensionsManifestInitializer(this, umbExtensionsRegistry, 'menuItem', (manifest) => manifest.meta.menus.includes(UMB_HELP_MENU_ALIAS), (menuItems) => {
            const manifests = menuItems.map((menuItem) => menuItem.manifest);
            this._helpMenuHasMenuItems = manifests.length > 0;
        });
    }
    render() {
        return html `${this.#renderButton()} ${this.#renderPopover()}`;
    }
    #renderButton() {
        if (!this._helpMenuHasMenuItems)
            return nothing;
        return html `
			<uui-button compact label=${this.localize.term('general_help')} look="primary" popovertarget="help-menu-popover">
				<uui-icon name="icon-help-alt"></uui-icon>
			</uui-button>
		`;
    }
    #renderPopover() {
        return html `
			<uui-popover-container id="help-menu-popover" placement="top-end">
				<umb-popover-layout>
					<uui-scroll-container>
						<umb-extension-slot
							type="menu"
							.filter=${(menu) => menu.alias === UMB_HELP_MENU_ALIAS}
							default-element="umb-menu"></umb-extension-slot>
					</uui-scroll-container>
				</umb-popover-layout>
			</uui-popover-container>
		`;
    }
    static { this.styles = [
        ...UmbHeaderAppButtonElement.styles,
        css `
			:host {
				--uui-menu-item-flat-structure: 1;
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbHelpHeaderAppElement.prototype, "_helpMenuHasMenuItems", void 0);
UmbHelpHeaderAppElement = __decorate([
    customElement('umb-help-header-app')
], UmbHelpHeaderAppElement);
export { UmbHelpHeaderAppElement };
export { UmbHelpHeaderAppElement as element };
