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 { MapToComponentMethod, MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
import ChangeManager from '../../../../../helpers/change-manager/change-manager';
import { TABLE_ROW_SELECTION } from '../../../../../helpers/change-manager/subject/static-subject/static-subject-title';
import { Observer } from '../../../../../helpers/change-manager/observer/observer';
import { isAcceptableTableRowObserver } from '../../../type-guard';
/**
 * The row selection controller for the expand row.
 */
export class VegaTableExpandRowSelectionController extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]{@link VegaTableExpandRow.connectedCallback}
   */
  connectedCallback() {
    this.rowSelectionObserver = new Observer(isAcceptableTableRowObserver.bind(this), (payload) => {
      if (payload.rowKey === this.rowKey) {
        this.checked = payload.checked;
      }
    });
    ChangeManager.register(TABLE_ROW_SELECTION, this.rowSelectionObserver);
  }
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaTableExpandRow.disconnectedCallback}
   */
  disconnectedCallback() {
    ChangeManager.unregister(TABLE_ROW_SELECTION, this.rowSelectionObserver);
  }
}
__decorate([
  MapToComponentField({ writable: true })
], VegaTableExpandRowSelectionController.prototype, "checked", void 0);
__decorate([
  MapToComponentField()
], VegaTableExpandRowSelectionController.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaTableExpandRowSelectionController.prototype, "rowKey", void 0);
__decorate([
  MapToComponentMethod('connectedCallback')
], VegaTableExpandRowSelectionController.prototype, "connectedCallback", null);
__decorate([
  MapToComponentMethod('disconnectedCallback')
], VegaTableExpandRowSelectionController.prototype, "disconnectedCallback", null);
