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 { ColumnStructureModel } from './dto/column-structure-model';
/**
 * Controller responsible for building and keeping the ColumnStructureModel in sync
 * with the component's `columns` and `groupColumns` properties.
 *
 * This slimmer maps relevant component fields and lifecycle/watch hooks to
 * automatically rebuild the column structure when inputs change.
 */
export class VegaTableColumnStructureModelController extends VegaSlimmer {
  /**
   * Component lifecycle hook mapped to the host's componentWillLoad.
   * Initializes the ColumnStructureModel prior to initial render.
   */
  componentWillLoad() {
    this.setColumnStructureModel();
  }
  /**
   * Watch handler mapped to the host's watchColumns.
   * Rebuilds the ColumnStructureModel when `columns` changes.
   */
  watchColumns() {
    this.setColumnStructureModel();
  }
  /**
   * Watch handler mapped to the host's watchGroupColumns.
   * Rebuilds the ColumnStructureModel when `groupColumns` changes.
   */
  watchGroupColumns() {
    this.setColumnStructureModel();
  }
  /**
   * Build and assign the ColumnStructureModel from current `columns` and `groupColumns`.
   * Uses `ColumnStructureModel.from` which returns a root model representing the column tree.
   */
  setColumnStructureModel() {
    this.columnStructureModel = ColumnStructureModel.from(this.columns, this.groupColumns);
  }
}
__decorate([
  MapToComponentField()
], VegaTableColumnStructureModelController.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaTableColumnStructureModelController.prototype, "columns", void 0);
__decorate([
  MapToComponentField()
], VegaTableColumnStructureModelController.prototype, "groupColumns", void 0);
__decorate([
  MapToComponentField({ writable: true })
], VegaTableColumnStructureModelController.prototype, "columnStructureModel", void 0);
__decorate([
  MapToComponentMethod('componentWillLoad')
], VegaTableColumnStructureModelController.prototype, "componentWillLoad", null);
__decorate([
  MapToComponentMethod('watchColumns')
], VegaTableColumnStructureModelController.prototype, "watchColumns", null);
__decorate([
  MapToComponentMethod('watchGroupColumns')
], VegaTableColumnStructureModelController.prototype, "watchGroupColumns", null);
