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_LANGUAGE_ENTITY_TYPE } from '../entity.js';
import { UMB_EDIT_LANGUAGE_WORKSPACE_PATH_PATTERN } from '../paths.js';
import { customElement, html, ifDefined, nothing, property, state } from '../../../external/lit/index.js';
import { UmbLitElement } from '../../core/lit-element/index.js';
import { UmbModalRouteRegistrationController } from '../../core/router/index.js';
import { UMB_WORKSPACE_MODAL } from '../../core/workspace/index.js';
let UmbLanguageItemRefElement = class UmbLanguageItemRefElement extends UmbLitElement {
    constructor() {
        super();
        this.readonly = false;
        this.standalone = false;
        this._editPath = '';
        new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
            .addUniquePaths(['unique'])
            .onSetup(() => {
            return { data: { entityType: UMB_LANGUAGE_ENTITY_TYPE, preset: {} } };
        })
            .observeRouteBuilder((routeBuilder) => {
            this._editPath = routeBuilder({});
        });
    }
    #getHref() {
        if (!this.item?.unique)
            return;
        const path = UMB_EDIT_LANGUAGE_WORKSPACE_PATH_PATTERN.generateLocal({ unique: this.item.unique });
        return `${this._editPath}/${path}`;
    }
    render() {
        if (!this.item)
            return nothing;
        return html `
			<uui-ref-node
				name=${this.item.name}
				href=${ifDefined(this.#getHref())}
				?readonly=${this.readonly}
				?standalone=${this.standalone}>
				<slot name="actions" slot="actions"></slot>
				<umb-icon slot="icon" name="icon-globe"></umb-icon>
			</uui-ref-node>
		`;
    }
};
__decorate([
    property({ type: Object })
], UmbLanguageItemRefElement.prototype, "item", void 0);
__decorate([
    property({ type: Boolean })
], UmbLanguageItemRefElement.prototype, "readonly", void 0);
__decorate([
    property({ type: Boolean })
], UmbLanguageItemRefElement.prototype, "standalone", void 0);
__decorate([
    state()
], UmbLanguageItemRefElement.prototype, "_editPath", void 0);
UmbLanguageItemRefElement = __decorate([
    customElement('umb-language-item-ref')
], UmbLanguageItemRefElement);
export { UmbLanguageItemRefElement };
export { UmbLanguageItemRefElement as element };
