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 { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import { FORM_ELEMENT_VALUE_CHANGE } from '../../../../helpers/change-manager/subject/static-subject/static-subject-title';
import ChangeManager from '../../../../helpers/change-manager/change-manager';
/**
 * Input numeric value controller
 */
export class VegaInputNumericValueController extends VegaSlimmer {
  /**
   * The `watchValue` function emits a change event with the current value and notifies the
   * `ChangeManager` about a form element value change.
   */
  watchValue() {
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  /**
   * Sets a value based on the input and emits a change event with that value.
   *
   * @param {string} input - input value
   */
  updateValue(input) {
    this.value = input;
  }
}
__decorate([
  MapToComponentField()
], VegaInputNumericValueController.prototype, "host", void 0);
__decorate([
  MapToComponentField({ writable: true })
], VegaInputNumericValueController.prototype, "value", void 0);
__decorate([
  MapToComponentField()
], VegaInputNumericValueController.prototype, "changeEventEmitter", void 0);
__decorate([
  MapToComponentMethod('watchValue')
], VegaInputNumericValueController.prototype, "watchValue", null);
