// #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 { Emit } from '../../../../Events/Decorators/EmitDecorator';
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Rangeable } from '../../../Behaviors/Rangeable';
import { Valueable } from '../../../Behaviors/Valueable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
// #endregion
/**
 * Range base - A range represents a control that enables users to select a value from a given minimum and maximum range.
 *
 * @fires valueChanged - Fired when the value is changed.
 *
 * @public
 * @abstract
 */
export class MultiRangeBaseElement extends Rangeable(Valueable(CustomElement)) {
    // #region Fields
    _valueChanged;
    _value;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `MultiRangeBaseElement` class.
     *
     * @remarks
     * This constructor must be public, otherwise it doesn't work with mixins/behaivors.
     *
     * @public
     */
    constructor() {
        super();
        this.min = 0;
        this.max = 1;
        this._value = 0;
        this._valueChanged = new HTMLElementEventEmitter(this, 'valueChanged');
    }
    // #endregion
    // #region Properties
    /**
     * Specifies the value of the `Range`.
     *
     * @public
     * @attr
     */
    get value() {
        return this._value;
    }
    set value(value) {
        if (this._value !== value) {
            this.onValueChanged(this._value, value);
        }
    }
    /**
     * Called when the value is changed.
     * Provides reference to the `IChangedEventDetail` with old and new value as event argument.
     *
     * @public
     * @eventProperty
     * @readonly
     */
    get valueChanged() {
        return this._valueChanged;
    }
    // #endregion
    // #region Methods
    /**
     * This method is invoked when the Value property changes.
     *
     * @protected
     */
    onValueChanged(prev, next) {
        this._value = next;
        this._valueChanged.emit({
            oldValue: prev,
            newValue: next
        });
        this.requestUpdate('value');
    }
}
__decorate([
    Attribute({ type: Object }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], MultiRangeBaseElement.prototype, "value", null);
__decorate([
    Emit(),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], MultiRangeBaseElement.prototype, "valueChanged", null);
//# sourceMappingURL=MultiRangeBaseElement.js.map