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 { html, customElement, state } from '../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../../core/lit-element/index.js';
import { UmbChangeEvent } from '../../../../core/event/index.js';
import { UmbFormControlMixin } from '../../../../core/validation/index.js';
import '../../components/input-upload-field/input-upload-field.element.js';
/**
 * @element umb-property-editor-ui-upload-field
 */
let UmbPropertyEditorUIUploadFieldElement = class UmbPropertyEditorUIUploadFieldElement extends UmbFormControlMixin(UmbLitElement) {
    set config(config) {
        if (!config)
            return;
        this._fileExtensions = config.getValueByAlias('fileExtensions');
        if (this._fileExtensions?.length) {
            this._fileExtensions = this._fileExtensions.map((ext) => ext.startsWith('.') ? ext : ext.includes('/') ? ext : `.${ext}`);
        }
    }
    firstUpdated() {
        this.addFormControlElement(this.shadowRoot.querySelector('umb-input-upload-field'));
    }
    #onChange(event) {
        this.value = event.target.value;
        this.dispatchEvent(new UmbChangeEvent());
    }
    render() {
        return html `
			<umb-input-upload-field
				.allowedFileExtensions=${this._fileExtensions}
				.value=${this.value}
				@change=${this.#onChange}>
			</umb-input-upload-field>
		`;
    }
};
__decorate([
    state()
], UmbPropertyEditorUIUploadFieldElement.prototype, "_fileExtensions", void 0);
UmbPropertyEditorUIUploadFieldElement = __decorate([
    customElement('umb-property-editor-ui-upload-field')
], UmbPropertyEditorUIUploadFieldElement);
export { UmbPropertyEditorUIUploadFieldElement };
export default UmbPropertyEditorUIUploadFieldElement;
