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 { customElement, html, ifDefined, property, state, when } from '../../../../../../external/lit/index.js';
import { UmbActionExecutedEvent } from '../../../../event/index.js';
import { UmbLitElement } from '../../../../lit-element/index.js';
let UmbWorkspaceActionMenuItemElement = class UmbWorkspaceActionMenuItemElement extends UmbLitElement {
    #api;
    set api(api) {
        this.#api = api;
        // TODO: Fix so when we use a HREF it does not refresh the page?
        this.#api?.getHref?.().then((href) => {
            this._href = href;
            // TODO: Do we need to update the component here? [NL]
        });
    }
    async #onClickLabel(event) {
        if (!this._href) {
            event.stopPropagation();
            await this.#api?.execute().catch(() => { });
        }
        this.dispatchEvent(new UmbActionExecutedEvent());
    }
    // TODO: we need to stop the regular click event from bubbling up to the table so it doesn't select the row.
    // This should probably be handled in the UUI Menu item component. so we don't dispatch a label-click event and click event at the same time.
    #onClick(event) {
        event.stopPropagation();
    }
    render() {
        return html `
			<uui-menu-item
				label=${ifDefined(this.localize.string(this.manifest?.meta.label ?? this.manifest?.name))}
				href=${ifDefined(this._href)}
				@click=${this.#onClick}
				@click-label=${this.#onClickLabel}>
				${when(this.manifest?.meta.icon, (icon) => html `<umb-icon slot="icon" name=${icon}></umb-icon>`)}
			</uui-menu-item>
		`;
    }
};
__decorate([
    state()
], UmbWorkspaceActionMenuItemElement.prototype, "_href", void 0);
__decorate([
    property({ attribute: false })
], UmbWorkspaceActionMenuItemElement.prototype, "manifest", void 0);
UmbWorkspaceActionMenuItemElement = __decorate([
    customElement('umb-workspace-action-menu-item')
], UmbWorkspaceActionMenuItemElement);
export { UmbWorkspaceActionMenuItemElement };
export default UmbWorkspaceActionMenuItemElement;
