text: import { Directive, ElementRef, forwardRef } from '@angular/core';
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
  /**
   * @element ons-checkbox
   * @directive OnsCheckbox
   * @selector ons-checkbox
   * @description
   *   [en]Angular directive for `<ons-checkbox>` component. You can use `[(ngModel)]` to synchronize the value of `[(ngModel)]` with the array of the selected values.[/en]
   *   [ja]`<ons-checkbox>`要素のAngularディレクティブです。 `[(ngModel)]` を使用すると、 `[(ngModel)]` の値を選択された値の配列と同期することができます。[/ja]
   * @example
   *   <ons-checkbox value="Item A" [(ngModel)]="selectedValues"></ons-checkbox>
   *   <ons-checkbox value="Item B" [(ngModel)]="selectedValues"></ons-checkbox>
   *   <ons-checkbox value="Item C" [(ngModel)]="selectedValues"></ons-checkbox>
   */
  var OnsCheckbox = (function () {
      function OnsCheckbox(_elementRef) {
          this._elementRef = _elementRef;
          this._propagateChange = function (_) { };
          this._boundOnChange = this._onChange.bind(this);
          this._element = _elementRef.nativeElement;
          this._element.addEventListener('change', this._boundOnChange);
      }
      OnsCheckbox.prototype._onChange = function (event) {
          var _a = event.target, value = _a.value, checked = _a.checked;
          var newValue;
          if (this._state instanceof Array) {
              // Is Array
              var index = this._state.indexOf(value);
              var included = index >= 0;
              if (included && !checked) {
                  newValue = this._state.slice(0, index).concat(this._state.slice(index + 1, this._state.length));
              }
              if (!included && checked) {
                  newValue = this._state.concat([value]);
              }
          }
          else {
              // Is Boolean
              newValue = checked;
          }
          // Emit if value changed
          if (newValue !== undefined) {
              this._state = newValue;
              this._propagateChange(this._state);
          }
      };
      Object.defineProperty(OnsCheckbox.prototype, "element", {
          get: function () {
              return this._element;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(OnsCheckbox.prototype, "nativeElement", {
          get: function () {
              return this._element;
          },
          enumerable: true,
          configurable: true
      });
      OnsCheckbox.prototype.ngOnDestroy = function () {
          this._element.removeEventListener('change', this._boundOnChange);
          this._element = null;
      };
      OnsCheckbox.prototype.writeValue = function (obj) {
          this._state = obj;
          if (obj instanceof Array) {
              this._element.checked = obj.indexOf(this._element.value) >= 0;
          }
          else {
              this._element.checked = obj;
          }
      };
      OnsCheckbox.prototype.registerOnChange = function (fn) {
          this._propagateChange = fn;
      };
      OnsCheckbox.prototype.registerOnTouched = function () { };
      return OnsCheckbox;
  }());
  export { OnsCheckbox };
  OnsCheckbox.decorators = [
      { type: Directive, args: [{
                  selector: 'ons-checkbox',
                  providers: [
                      {
                          provide: NG_VALUE_ACCESSOR,
                          useExisting: forwardRef(function () { return OnsCheckbox; }),
                          multi: true,
                      }
                  ]
              },] },
  ];
  /** @nocollapse */
  OnsCheckbox.ctorParameters = function () { return [
      { type: ElementRef, },
  ]; };
  //# sourceMappingURL=ons-checkbox.js.map