text: 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 { Component, forwardRef, Input, ViewEncapsulation } from '@angular/core';
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
  var RatingInputComponent = /** @class */ (function () {
      function RatingInputComponent() {
          this.max = 5;
          this.readOnly = false;
          this.propagateChange = function () { }; // Noop function
      }
      RatingInputComponent_1 = RatingInputComponent;
      RatingInputComponent.prototype.ngOnInit = function () {
          var states = [];
          for (var i = 0; i < this.max; i++) {
              if (this.innerValue > i && this.innerValue < i + 1) {
                  states[i] = 2;
              }
              else if (this.innerValue > i) {
                  states[i] = 1;
              }
              else {
                  states[i] = 0;
              }
          }
          this.range = states;
      };
      Object.defineProperty(RatingInputComponent.prototype, "value", {
          get: function () {
              return this.innerValue;
          },
          set: function (val) {
              if (val !== this.innerValue) {
                  this.innerValue = val;
                  this.propagateChange(val);
              }
          },
          enumerable: true,
          configurable: true
      });
      RatingInputComponent.prototype.writeValue = function (value) {
          if (value !== this.innerValue) {
              this.innerValue = value;
          }
      };
      RatingInputComponent.prototype.registerOnChange = function (fn) {
          this.propagateChange = fn;
      };
      RatingInputComponent.prototype.registerOnTouched = function () { };
      RatingInputComponent.prototype.rate = function (amount) {
          if (!this.readOnly && amount >= 0 && amount <= this.range.length) {
              this.value = amount;
          }
      };
      var RatingInputComponent_1;
      __decorate([
          Input(),
          __metadata("design:type", Object)
      ], RatingInputComponent.prototype, "max", void 0);
      __decorate([
          Input(),
          __metadata("design:type", Object)
      ], RatingInputComponent.prototype, "readOnly", void 0);
      RatingInputComponent = RatingInputComponent_1 = __decorate([
          Component({
              selector: 'app-rating-input',
              templateUrl: './rating-input.component.html',
              styleUrls: ['./rating-input.component.scss'],
              providers: [
                  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return RatingInputComponent_1; }), multi: true }
              ],
              encapsulation: ViewEncapsulation.None
          })
      ], RatingInputComponent);
      return RatingInputComponent;
  }());
  export { RatingInputComponent };
  //# sourceMappingURL=rating-input.component.js.map