/* eslint-disable @typescript-eslint/naming-convention */
// #region Imports
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { RendererServiceLocator } from '../../Dom/Renderer';
import { Attribute } from '../Decorators/AttributeDecorator';
import { Watch } from '../Decorators/WatchDecorator';
/**
 * @public
 */
export const Valueable = (base) => {
    class ValueableElement extends base {
        // #region Fields
        _value;
        // #endregion
        // #region Ctor
        /**
         * Constructs a new instance of the `ValueableElement` class.
         *
         * @public
         */
        constructor(...args) {
            super(args);
            this._value = undefined;
        }
        // #endregion
        // #region Properties
        /**
         * Gets or sets the `value` property.
         * The default value is `undefined`, which means the element has no value set.
         *
         * @public
         * @attr
         */
        get value() {
            return this._value;
        }
        set value(value) {
            if (this._value !== value) {
                this._value = value;
                this.requestUpdate('value');
            }
        }
        // #endregion
        // #region Methods
        /**
         * @protected
         */
        onValuePropertyChanged(_prev, next) {
            if (next !== undefined) {
                RendererServiceLocator.current.setAttribute(this, 'aria-value', String(next));
            }
            else {
                RendererServiceLocator.current.removeAttribute(this, 'aria-value');
            }
        }
    }
    __decorate([
        Attribute({
            type: Object,
            converter: {
                toAttribute: (value) => String(value)
            }
        }),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [Object])
    ], ValueableElement.prototype, "value", null);
    __decorate([
        Watch('value'),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", [Object, Object]),
        __metadata("design:returntype", void 0)
    ], ValueableElement.prototype, "onValuePropertyChanged", null);
    return ValueableElement;
};
//# sourceMappingURL=Valueable.js.map