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, VegaSlimmer } from 'vega-slimmer/core';
/** The VegaTabGroupSelectedTargetController class is responsible for handling the selected data target in a VegaTabGroup component and emitting a click event. */
export class VegaTabGroupSelectedTargetController extends VegaSlimmer {
  /**
   * The function sets the selectedTabDataTarget property to the provided dataTarget value.
   *
   * @param {string} dataTarget - The dataTarget parameter is a string that represents the target data for the selected tab.
   */
  setSelectedDataTarget(dataTarget) {
    this.selectedTabDataTarget = dataTarget;
  }
  /**
   * The function emits click event and checks for prevent default then sets the selectedTabDataTarget property to the provided dataTarget value.
   *
   * @param {string} dataTarget - The dataTarget parameter is a string that represents the target data for the selected tab.
   */
  handleTabItemClick(dataTarget) {
    const clickEvent = this.clickEventEmitter.emit(dataTarget);
    if (clickEvent && !clickEvent.defaultPrevented) {
      if (dataTarget === this.selectedTabDataTarget) {
        this.vegaTabGroupPageIndexController.setCurrentPageIndexBySelectedTab(dataTarget);
      }
      else {
        this.setSelectedDataTarget(dataTarget);
      }
    }
  }
}
__decorate([
  MapToComponentField()
], VegaTabGroupSelectedTargetController.prototype, "clickEventEmitter", void 0);
__decorate([
  MapToComponentField({ writable: true })
], VegaTabGroupSelectedTargetController.prototype, "selectedTabDataTarget", void 0);
__decorate([
  MapToComponentField()
], VegaTabGroupSelectedTargetController.prototype, "vegaTabGroupPageIndexController", void 0);
