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 { VegaTableScrollableContainer } from '../../internal/vega-table-scrollable-container';
import { h } from '@stencil/core';
import ChangeManager from '../../../../helpers/change-manager/change-manager';
import { SHADOW_ROOT_ELEMENT_SCROLLING } from '../../../../helpers/change-manager/subject/static-subject/static-subject-title';
export class VegaTableScrollContainerRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.scrollContainerToTop = () => {
      if (this.tableScrollContainerRef) {
        this.tableScrollContainerRef.scrollTop = 0;
      }
    };
    this.notifyContentScrolling = () => {
      this.isTemplateRenderMode &&
        ChangeManager.notify(SHADOW_ROOT_ELEMENT_SCROLLING, {
          host: this.host,
        });
    };
  }
  watchCurrentPage() {
    this.scrollContainerToTop();
  }
  render(children) {
    return (h(VegaTableScrollableContainer, { scrollConfig: this.scrollConfig, ref: (ref) => this.setTableScrollContainerRef(ref), 
      /* eslint-disable-next-line react/jsx-no-bind */
      onScroll: () => this.notifyContentScrolling() }, children));
  }
  setTableScrollContainerRef(ref) {
    this.tableScrollContainerRef = ref;
  }
}
__decorate([
  MapToComponentField()
], VegaTableScrollContainerRenderer.prototype, "scrollConfig", void 0);
__decorate([
  MapToComponentField()
], VegaTableScrollContainerRenderer.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaTableScrollContainerRenderer.prototype, "isTemplateRenderMode", void 0);
__decorate([
  MapToComponentMethod('watchCurrentPage')
], VegaTableScrollContainerRenderer.prototype, "watchCurrentPage", null);
