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_DATA_TYPE_WORKSPACE_CONTEXT } from '../../workspace/data-type-workspace.context-token.js';
import { html, customElement, state, ifDefined, repeat } from '../../../../external/lit/index.js';
import { UmbTextStyles } from '../../../core/style/index.js';
import { UmbLitElement } from '../../../core/lit-element/index.js';
import { UmbDataPathPropertyValueQuery } from '../../../core/validation/index.js';
/**
 * @element umb-property-editor-config
 * @description - Element for displaying the configuration for a Property Editor based on a Property Editor UI Alias and a Property Editor Model alias.
 * This element requires a UMB_DATA_TYPE_WORKSPACE_CONTEXT to be present.
 */
let UmbPropertyEditorConfigElement = class UmbPropertyEditorConfigElement extends UmbLitElement {
    // TODO: Make this element generic, so its not bound to DATA-TYPEs. This will require moving some functionality of Data-Type-Context to this. and this might need to self provide a variant Context for its inner property editor UIs. [NL]
    #workspaceContext;
    constructor() {
        super();
        this._properties = [];
        // This now connects to the workspace, as the variant does not know about the layout details.
        this.consumeContext(UMB_DATA_TYPE_WORKSPACE_CONTEXT, (instance) => {
            this.#workspaceContext = instance;
            this.#observeProperties();
        });
    }
    #observeProperties() {
        if (!this.#workspaceContext)
            return;
        this.observe(this.#workspaceContext.properties, (properties) => {
            this._properties = properties;
        }, 'observeProperties');
    }
    render() {
        return this._properties?.length > 0
            ? repeat(this._properties, (property) => property.alias, (property) => html `<umb-property
							data-path="$.values[${UmbDataPathPropertyValueQuery(property)}].value"
							label=${property.label}
							description=${ifDefined(property.description)}
							alias=${property.alias}
							property-editor-ui-alias=${property.propertyEditorUiAlias}
							property-editor-data-source-alias=${ifDefined(property.propertyEditorDataSourceAlias)}
							.config=${property.config}
							.validation=${property.validation}></umb-property>`)
            : html `<umb-localize key="editdatatype_noConfiguration"
					>There is no configuration for this property editor.</umb-localize
				>`;
    }
    static { this.styles = [UmbTextStyles]; }
};
__decorate([
    state()
], UmbPropertyEditorConfigElement.prototype, "_properties", void 0);
UmbPropertyEditorConfigElement = __decorate([
    customElement('umb-property-editor-config')
], UmbPropertyEditorConfigElement);
export { UmbPropertyEditorConfigElement };
export default UmbPropertyEditorConfigElement;
