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_USER_GROUP_WORKSPACE_CONTEXT } from '../user-group-workspace.context-token.js';
import { UmbTextStyles } from '../../../../../core/style/index.js';
import { html, customElement, state, nothing, property } from '../../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../../../core/lit-element/index.js';
let UmbUserGroupEntityTypePermissionsElement = class UmbUserGroupEntityTypePermissionsElement extends UmbLitElement {
    #userGroupWorkspaceContext;
    constructor() {
        super();
        this.consumeContext(UMB_USER_GROUP_WORKSPACE_CONTEXT, (instance) => {
            this.#userGroupWorkspaceContext = instance;
            this.observe(this.#userGroupWorkspaceContext?.fallbackPermissions, (fallbackPermissions) => {
                this._fallBackPermissions = fallbackPermissions;
            }, 'umbUserGroupEntityUserPermissionsObserver');
        });
    }
    #onPermissionChange(event) {
        event.stopPropagation();
        const target = event.target;
        const verbs = target.allowedVerbs;
        if (verbs === undefined || verbs === null)
            throw new Error('The verbs are not defined');
        this.#userGroupWorkspaceContext?.setFallbackPermissions(verbs);
    }
    render() {
        return this.entityType
            ? html `
					<umb-input-entity-user-permission
						.entityType=${this.entityType}
						.allowedVerbs=${this._fallBackPermissions || []}
						@change=${this.#onPermissionChange}></umb-input-entity-user-permission>
				`
            : nothing;
    }
    static { this.styles = [UmbTextStyles]; }
};
__decorate([
    property()
], UmbUserGroupEntityTypePermissionsElement.prototype, "entityType", void 0);
__decorate([
    state()
], UmbUserGroupEntityTypePermissionsElement.prototype, "_fallBackPermissions", void 0);
UmbUserGroupEntityTypePermissionsElement = __decorate([
    customElement('umb-user-group-entity-type-permissions')
], UmbUserGroupEntityTypePermissionsElement);
export { UmbUserGroupEntityTypePermissionsElement };
export default UmbUserGroupEntityTypePermissionsElement;
