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 { Component, Host, h, Element, State } from '@stencil/core';
import InternalVegaZIndexManager from '../../../helpers/zindex/internal-vega-z-index-manager';
import { sanitizeVegaComponent } from '../../../utils/component';
import { VegaTableHeadStateController } from './slimmers/controllers/vega-table-head-state-controller';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer } from 'vega-slimmer/core';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../../helpers/slimmers/component-usage-runtime-metrics';
import { ChildNodesEventPreventSlimmer } from '../../../helpers/event-manager/slimmers/child-nodes-event-prevent-slimmer';
import { VegaChange } from '../../../helpers/event-manager/event-id/vega-event-id';
/**
 * @vegaVersion 1.44.0
 */
export class VegaTableHead {
  constructor() {
    this.globalSlimmers = {};
    this.vegaTableHeadStateController = new VegaTableHeadStateController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.headCellEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.host);
    /**
     * Indicates whether the table header is fixed.
     */
    this.fixed = false;
    this.handleTableHeadRefChange = (ref) => {
      if (this.tableHeadRef) {
        InternalVegaZIndexManager.removeZIndex(this.tableHeadRef, 'base');
      }
      if (this.fixed) {
        InternalVegaZIndexManager.setZIndex(ref, 'base');
      }
      this.tableHeadRef = ref;
    };
  }
  connectedCallback() {
    if (this.tableHeadRef && this.fixed) {
      InternalVegaZIndexManager.setZIndex(this.tableHeadRef, 'base');
    }
  }
  disconnectedCallback() {
    InternalVegaZIndexManager.removeZIndex(this.tableHeadRef, 'base');
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: {
        'fixed-header': this.fixed,
      }, ref: (ref) => this.handleTableHeadRefChange(ref) },
      h("thead", null,
        h("slot", null))), this.host);
  }
  static get is() { return "vega-table-head"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-table-head.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-table-head.css"]
  }; }
  static get states() { return {
    "fixed": {}
  }; }
  static get elementRef() { return "host"; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaTableHead.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTableHead.prototype, "vegaTableHeadStateController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTableHead.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTableHead.prototype, "headCellEventPrevent", void 0);
