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 { h, Host } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
import { arrayToClassString } from '../../../../utils/ui';
import ResponsiveFormatFacade from '../../../../helpers/formatter/responsive-map-formatter/responsive-format-facade';
import { sanitizeVegaComponent } from '../../../../utils/component';
export class VegaTableRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.renderInternalTable = () => {
      const tableLayoutFixed = this.columns.some((column) => column.overflow) ||
        Array.from(this.host.querySelectorAll('vega-table-cell')).some((cell) => cell.overflow);
      return (h("table", { class: {
          'v-table-fixed': tableLayoutFixed,
        } },
        this.columns.length > 0 && [
          this.vegaTableColGroupRenderer.render(),
          this.vegaTableHeaderRenderer.render(),
        ],
        (this.dataSource.length > 0 || this.editingRows.size > 0) &&
          this.vegaTableBodyRenderer.render(),
        this.isTemplateRenderMode && h("slot", null)));
    };
    this.renderEmpty = () => {
      return (this.vegaTableDataSourceController.isCurrentDataEmpty() &&
        this.emptyDescription && (h("div", { class: "vega-table-empty-description" }, this.translationSlimmer.t(this.emptyDescription))));
    };
  }
  render() {
    const hostClasses = arrayToClassString([
      this.rowDivider && 'row-divider',
      this.columnDivider && 'column-divider',
      `density-${ResponsiveFormatFacade.formatCustom(this.density)}`,
      this.striped && 'striped',
      this.columnStructureModel.hasGroupColumn() && 'is-group-table',
      (this.columnStructureModel.hasLeftPinnedColumn() ||
        this.columnStructureModel.hasRightPinnedColumn()) &&
        'is-pinned-table',
    ]);
    return sanitizeVegaComponent(h(Host, { class: hostClasses },
      this.vegaTableScrollContainerRenderer.render(this.renderInternalTable()),
      this.vegaTablePaginationRenderer.render(),
      this.renderEmpty()), this.host);
  }
}
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "columns", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "emptyDescription", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "rowDivider", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "columnDivider", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "density", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "dataSource", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "striped", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "columnStructureModel", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTableHeaderRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTableBodyRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTableColGroupRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTableScrollContainerRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTablePaginationRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "vegaTableDataSourceController", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "translationSlimmer", void 0);
__decorate([
  MapToComponentField({ writable: true })
], VegaTableRenderer.prototype, "vegaTableChildrenController", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "isTemplateRenderMode", void 0);
__decorate([
  MapToComponentField()
], VegaTableRenderer.prototype, "editingRows", void 0);
