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, property, map, nothing } from '../../../../external/lit/index.js';
import { UmbChangeEvent } from '../../event/index.js';
import { UmbLitElement } from '../../lit-element/index.js';
import { UMB_VALIDATION_EMPTY_LOCALIZATION_KEY, UmbFormControlMixin } from '../../validation/index.js';
/*
 * This wraps the UUI library uui-color-swatches component
 * @element umb-input-color
 */
let UmbInputColorElement = class UmbInputColorElement extends UmbFormControlMixin(UmbLitElement) {
    getFormElement() {
        return undefined;
    }
    constructor() {
        super();
        /**
         * Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
         * @attr
         * @default false
         */
        this.readonly = false;
        this.required = false;
        this.requiredMessage = UMB_VALIDATION_EMPTY_LOCALIZATION_KEY;
        this.showLabels = false;
        this.addValidator('valueMissing', () => this.requiredMessage ?? UMB_VALIDATION_EMPTY_LOCALIZATION_KEY, () => !!this.required && !this.value && !this.readonly);
    }
    #onChange(event) {
        this.value = event.target.value;
        this.dispatchEvent(new UmbChangeEvent());
    }
    render() {
        return html `
			<uui-color-swatches
				?readonly=${this.readonly}
				label="Color picker"
				value=${this.value ?? ''}
				@change=${this.#onChange}>
				${this.#renderColors()}
			</uui-color-swatches>
		`;
    }
    #renderColors() {
        if (!this.swatches)
            return nothing;
        return map(this.swatches, (swatch) => html `
				<uui-color-swatch label=${swatch.label} value=${swatch.value} .showLabel=${this.showLabels}></uui-color-swatch>
			`);
    }
};
__decorate([
    property({ type: Boolean, reflect: true })
], UmbInputColorElement.prototype, "readonly", void 0);
__decorate([
    property({ type: Boolean })
], UmbInputColorElement.prototype, "required", void 0);
__decorate([
    property({ type: String })
], UmbInputColorElement.prototype, "requiredMessage", void 0);
__decorate([
    property({ type: Boolean })
], UmbInputColorElement.prototype, "showLabels", void 0);
__decorate([
    property({ type: Array })
], UmbInputColorElement.prototype, "swatches", void 0);
UmbInputColorElement = __decorate([
    customElement('umb-input-color')
], UmbInputColorElement);
export { UmbInputColorElement };
export default UmbInputColorElement;
