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';
/**
 * The `VegaSelectionTileGroupItemsController` class manages an array of selection tiles within a
 * Vega selection tile group component.
 */
export class VegaSelectionTileGroupItemsController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.selectionTileArray = [];
  }
  /**
   * The function initializes an array of selection tiles by querying the host element for elements with
   * the tag 'vega-selection-tile'.
   */
  initSelectionTileArray() {
    this.syncTileArrayAndValue();
  }
  /**
   * The function `getSelectionTileArray` returns an array of HTMLVegaSelectionTileElement elements.
   *
   * @returns {HTMLVegaSelectionTileElement[]} An array of HTMLVegaSelectionTileElement elements is being returned.
   */
  getSelectionTileArray() {
    return this.selectionTileArray;
  }
  /**
   * The function syncTileArrayAndValue() populates an array with elements selected by a querySelectorAll
   * method and triggers a callback function on a value controller.
   */
  syncTileArrayAndValue() {
    this.selectionTileArray = Array.from(this.host.querySelectorAll('vega-selection-tile'));
    this.valueController.onSelectionTilesChanged();
  }
  /**
   * This function returns an array of HTML input elements based on the type of selection tile.
   *
   * @returns {HTMLInputElement[]} An array of HTMLInputElement elements is being returned.
   */
  touchableAreaGetter() {
    const selector = this.selectType === 'checkbox' ? 'vega-checkbox' : 'vega-radio';
    return this.selectionTileArray.map((tile) => tile.shadowRoot.querySelector(selector).shadowRoot.querySelector('input'));
  }
}
__decorate([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "selectType", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "valueController", void 0);
__decorate([
  MapToComponentMethod('componentWillLoad')
], VegaSelectionTileGroupItemsController.prototype, "initSelectionTileArray", null);
