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_MEDIA_TYPE_ENTITY_TYPE } from '../entity.js';
import { UMB_EDIT_MEDIA_TYPE_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 UmbMediaTypePropertyTypeItemRefElement = class UmbMediaTypePropertyTypeItemRefElement 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_MEDIA_TYPE_ENTITY_TYPE, preset: {} } };
        })
            .observeRouteBuilder((routeBuilder) => {
            this._editPath = routeBuilder({});
        });
    }
    #getHref() {
        if (!this.item?.unique)
            return;
        const path = UMB_EDIT_MEDIA_TYPE_WORKSPACE_PATH_PATTERN.generateLocal({ unique: this.item.mediaType.unique });
        return `${this._editPath}/${path}`;
    }
    #getName() {
        const mediaTypeName = this.item?.mediaType.name ?? 'Unknown';
        return `Media Type: ${mediaTypeName}`;
    }
    #getDetail() {
        const propertyTypeDetails = this.item?.name ? this.item.name + ' (' + this.item.alias + ')' : 'Unknown';
        return `Property Type: ${propertyTypeDetails}`;
    }
    render() {
        if (!this.item)
            return nothing;
        return html `
			<uui-ref-node
				name=${this.#getName()}
				detail=${this.#getDetail()}
				href=${ifDefined(this.#getHref())}
				?readonly=${this.readonly}
				?standalone=${this.standalone}>
				<slot name="actions" slot="actions"></slot>
				${this.#renderIcon()}
			</uui-ref-node>
		`;
    }
    #renderIcon() {
        if (!this.item?.mediaType.icon)
            return nothing;
        return html `<umb-icon slot="icon" name=${this.item.mediaType.icon}></umb-icon>`;
    }
};
__decorate([
    property({ type: Object })
], UmbMediaTypePropertyTypeItemRefElement.prototype, "item", void 0);
__decorate([
    property({ type: Boolean })
], UmbMediaTypePropertyTypeItemRefElement.prototype, "readonly", void 0);
__decorate([
    property({ type: Boolean })
], UmbMediaTypePropertyTypeItemRefElement.prototype, "standalone", void 0);
__decorate([
    state()
], UmbMediaTypePropertyTypeItemRefElement.prototype, "_editPath", void 0);
UmbMediaTypePropertyTypeItemRefElement = __decorate([
    customElement('umb-media-type-property-type-item-ref')
], UmbMediaTypePropertyTypeItemRefElement);
export { UmbMediaTypePropertyTypeItemRefElement };
export { UmbMediaTypePropertyTypeItemRefElement as element };
