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 { customElement, html, property, when } 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';
let UmbInputEyeDropperElement = class UmbInputEyeDropperElement extends UmbFormControlMixin(UmbLitElement) {
    getFormElement() {
        return undefined;
    }
    #onChange(e) {
        e.stopPropagation();
        this.value = e.target.value;
        this.dispatchEvent(new UmbChangeEvent());
    }
    constructor() {
        super();
        this.readonly = false;
        this.required = false;
        this.requiredMessage = UMB_VALIDATION_EMPTY_LOCALIZATION_KEY;
        this.opacity = false;
        this.showPalette = false;
        this.addValidator('valueMissing', () => this.requiredMessage, () => !this.readonly && this.required && (!this.value || this.value === ''));
    }
    // HACK: Since `uui-color-picker` doesn't have an option to hide the swatches, we had to get creative.
    // Based on UUI v1.8.0-rc3, the value of `swatches` must be a falsey value to hide them.
    // https://github.com/umbraco/Umbraco.UI/blob/v1.8.0-rc.3/packages/uui-color-picker/lib/uui-color-picker.element.ts#L517
    // However, the object-type for `swatches` is a `string[]` (non-nullable).
    // https://github.com/umbraco/Umbraco.UI/blob/v1.8.0-rc.3/packages/uui-color-picker/lib/uui-color-picker.element.ts#L157
    // To do this, we must omit the `.swatches` attribute, otherwise the default swatches can't be used.
    // So, we've use a `when()` render both configurations. [LK]
    render() {
        const swatches = this.showPalette ? this.swatches : undefined;
        return when(this.showPalette && !swatches, () => html `
				<uui-color-picker
					label="Eye dropper"
					.opacity=${this.opacity}
					.value=${this.value}
					@change=${this.#onChange}>
				</uui-color-picker>
			`, () => html `
				<uui-color-picker
					label="Eye dropper"
					.opacity=${this.opacity}
					.swatches=${swatches}
					.value=${this.value}
					@change=${this.#onChange}>
				</uui-color-picker>
			`);
    }
};
__decorate([
    property({ type: Boolean, reflect: true })
], UmbInputEyeDropperElement.prototype, "readonly", void 0);
__decorate([
    property({ type: Boolean })
], UmbInputEyeDropperElement.prototype, "required", void 0);
__decorate([
    property({ type: String })
], UmbInputEyeDropperElement.prototype, "requiredMessage", void 0);
__decorate([
    property({ type: Boolean })
], UmbInputEyeDropperElement.prototype, "opacity", void 0);
__decorate([
    property({ type: Boolean })
], UmbInputEyeDropperElement.prototype, "showPalette", void 0);
__decorate([
    property({ type: Array })
], UmbInputEyeDropperElement.prototype, "swatches", void 0);
UmbInputEyeDropperElement = __decorate([
    customElement('umb-input-eye-dropper')
], UmbInputEyeDropperElement);
export { UmbInputEyeDropperElement };
export default UmbInputEyeDropperElement;
