import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-d58ca1d0.js';
import { c as MapToComponentField, V as VegaSlimmer, M as MapToComponentMethod } from './global-slimmer-registry-0a7aa308.js';
import { I as InjectVegaSlimmer } from './inject-vega-slimmer-caffc2aa.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-4202784a.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-e5fd0fab.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-50d423c0.js';
import { h as VegaChange } from './vega-event-id-1b737ae8.js';
import { C as ChangeManager } from './change-manager-ecbd3a2a.js';
import { i as SELECTION_TILE_VALUE_CHANGE, C as CHECKBOX_VALUE_CHANGE, R as RADIO_VALUE_CHANGE, F as FORM_ELEMENT_VALUE_CHANGE } from './static-subject-title-52f93124.js';
import { S as SubStateObserverSlimmer } from './sub-state-observer-slimmer-884e6f43.js';
import { h as VegaInternalFieldErrorStateChange } from './vega-internal-event-id-a2d4c714.js';
import { f as findParent } from './ui-6dd51115.js';
import { O as Observer } from './observer-3959f9dd.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-factory-6894df15.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-08e29cdd.js';
import { C as ChildNodesNotifyObserverSlimmer } from './child-nodes-notify-observer-slimmer-d1cfd748.js';
import { c as createSubStateNotifySlimmer } from './sub-state-notify-slimmer-d9e93bd6.js';
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-1ff66f6c.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import './dynamic-slimmer-60d5da5a.js';
import './dom-node-subject-observer-factory-61fda003.js';
import './internal-vega-event-manager-a19d633d.js';
import './try-get-document-bef0f526.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-b7e7da75.js';
import './index-bfc6dfa2.js';
import './string-a953eafc.js';
import './misc-9fdbcfbb.js';
import './internal-translation-controller-0776fa78.js';
import './index-3b327f29.js';
import './page-resize-observer-slimmer-558308bc.js';
import './breakpoints-332702ed.js';
import './ui-93922c59.js';
import './breakpoints-d9faf11c.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
import './mutation-observer-slimmer-f6fcd32a.js';
import './mutation-observer-filters-1a054fb0.js';
import './array-7888f339.js';
import './number-4398f2e1.js';

var __decorate$8 = (undefined && undefined.__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;
};
class VegaSelectionTileRenderer extends VegaSlimmer {
  getSelectorContainerRef() {
    return this.selectorContainerRef;
  }
  render() {
    return (h("vega-flex", { "align-items": "start", "justify-content": "start", gap: "size-16", class: {
        'selection-tile': true,
        'disabled': this.disabled,
        'checked': this.checked,
        'error': this.showError,
      }, "aria-label": this.titleText || 'No label defined', tabIndex: this.disabled ? -1 : 0, 
      /* eslint-disable-next-line react/jsx-no-bind */
      onClick: () => {
        if (!(this.selectType === 'radio' && this.checked)) {
          this.checkedController.onCheck(!this.checked);
        }
      }, onKeyDown: createEnterKeyHandlerToTriggerClick() },
      h("div", { class: "vega-flex-grow" }, this.renderContent()),
      this.renderSelect()));
  }
  renderContent() {
    if (this.hasContentSlot()) {
      return h("slot", { name: "content" });
    }
    else {
      return (h("vega-flex", { gap: "size-12" },
        h("vega-flex", { class: "vega-flex-shrink-0" }, this.renderPrefixIcon()),
        h("div", { class: "vega-flex-grow" }, this.renderText())));
    }
  }
  renderPrefixIcon() {
    if (this.hasPrefixSlot()) {
      return h("slot", { name: "prefix" });
    }
    else if (this.prefixIcon) {
      return (h("vega-icon", { icon: this.prefixIcon, size: "size-16", color: this.disabled ? 'text-secondary' : 'text-primary', class: "selection-tile-icon" }));
    }
  }
  renderText() {
    return (h("vega-flex", { class: "vega-flex-grow", direction: "col", "align-items": "start", "justify-content": "start" },
      h("div", { class: "selection-tile-title" }, this.titleText),
      this.note && h("div", { class: "selection-tile-note" }, this.note)));
  }
  renderSelect() {
    return (h("vega-flex", { "align-items": "start", class: "vega-flex-shrink-0 selection-tile-select", ref: (ref) => (this.selectorContainerRef = ref) }, this.selectType === 'checkbox' ? this.renderCheckbox() : this.renderRadio()));
  }
  renderCheckbox() {
    return h("vega-checkbox", { size: "small", disabled: this.disabled, checked: this.checked });
  }
  renderRadio() {
    return h("vega-radio", { size: "small", disabled: this.disabled, checked: this.checked });
  }
  hasPrefixSlot() {
    return this.host.querySelector(`[slot=prefix]`) !== null;
  }
  hasContentSlot() {
    return this.host.querySelector(`[slot=content]`) !== null;
  }
}
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "host", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "prefixIcon", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "titleText", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "note", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "selectType", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "disabled", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "checked", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "showError", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionTileRenderer.prototype, "checkedController", void 0);

var __decorate$7 = (undefined && undefined.__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;
};
/**
 * The `VegaSelectionTileCheckedController` class in TypeScript manages the checked state of
 * a selection tile component.
 */
class VegaSelectionTileCheckedController extends VegaSlimmer {
  /**
   * The function `setChecked` in TypeScript sets the `checked` property to the specified boolean value.
   *
   * @param {boolean} checked - The `checked` parameter is a boolean value that determines whether an
   * item is selected or not. It is used in the `setChecked` method to update the `checked` property of
   * an object to the specified boolean value.
   */
  setChecked(checked) {
    this.checked = checked;
  }
  /**
   * The `onCheck` function in TypeScript updates the value, emits a change event, and notifies the
   * change manager based on the checked status.
   *
   * @param {boolean} checked - The `checked` parameter is a boolean value that indicates whether a
   * checkbox or a similar input element is checked or not.
   */
  onCheck(checked) {
    const value = checked ? this.value : '';
    this.checked = checked;
    this.changeEventEmitter.emit(value);
    ChangeManager.notify(SELECTION_TILE_VALUE_CHANGE, {
      host: this.host,
      detail: {
        checked: checked,
        value: this.value,
      },
    });
  }
}
__decorate$7([
  MapToComponentField()
], VegaSelectionTileCheckedController.prototype, "host", void 0);
__decorate$7([
  MapToComponentField({ writable: true })
], VegaSelectionTileCheckedController.prototype, "checked", void 0);
__decorate$7([
  MapToComponentField()
], VegaSelectionTileCheckedController.prototype, "changeEventEmitter", void 0);
__decorate$7([
  MapToComponentField()
], VegaSelectionTileCheckedController.prototype, "value", void 0);

var __decorate$6 = (undefined && undefined.__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;
};
/**
 * The `VegaSelectionTileStateController` class is a TypeScript class that observes and manages
 * the state of a `HTMLVegaSelectionTileElement` component.
 */
class VegaSelectionTileStateController extends SubStateObserverSlimmer {
  // eslint-disable-next-line jsdoc/require-jsdoc
  constructor() {
    super({
      parent: 'vega-selection-tile-group',
      subStates: [
        {
          subStateName: 'selectType',
          parentStateName: 'selectType',
        },
        {
          subStateName: 'disabled',
          parentStateName: 'disabled',
          /**
           * If group defined disabled property we should synchronize this value,
           * 		otherwise keep the disabled value in selection tile unchanged.
           *
           * @param {Nullable<boolean>} groupDisabled - Disabled value in parent selection tile group.
           */
          callback: (groupDisabled) => {
            if (typeof groupDisabled === 'boolean') {
              this.disabled = groupDisabled;
            }
          },
        },
        {
          subStateName: 'checked',
          parentStateName: 'value',
          /**
           * Synchronize checked status according by the value from parent selection tile group.
           *
           * @param {string | string[]} groupValue - The value from parent selection tile group.
           */
          callback: (groupValue) => {
            this.checkedController.setChecked(Array.isArray(groupValue)
              ? groupValue.includes(this.value)
              : groupValue === this.value);
          },
        },
        {
          subStateName: 'distributeEvenly',
          parentStateName: 'distributeEvenly',
        },
      ],
    });
  }
}
__decorate$6([
  MapToComponentField()
], VegaSelectionTileStateController.prototype, "host", void 0);
__decorate$6([
  MapToComponentField({ writable: true })
], VegaSelectionTileStateController.prototype, "selectType", void 0);
__decorate$6([
  MapToComponentField({ writable: true })
], VegaSelectionTileStateController.prototype, "disabled", void 0);
__decorate$6([
  MapToComponentField()
], VegaSelectionTileStateController.prototype, "checked", void 0);
__decorate$6([
  MapToComponentField()
], VegaSelectionTileStateController.prototype, "value", void 0);
__decorate$6([
  MapToComponentField()
], VegaSelectionTileStateController.prototype, "checkedController", void 0);
__decorate$6([
  MapToComponentField({ writable: true })
], VegaSelectionTileStateController.prototype, "distributeEvenly", void 0);

var __decorate$5 = (undefined && undefined.__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;
};
/**
 * The `VegaSelectionTileShowErrorController` class is responsible for managing
 * the display of error messages in Vega selection tiles based on field error observations.
 */
class VegaSelectionTileShowErrorController extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]{@link VegaSelectionTile.connectedCallback}
   */
  connectedCallback() {
    this.selectionTileGroup = findParent(this.host, 'vega-selection-tile-group');
    this.fieldErrorObserver = new Observer(this.canAcceptFieldErrorObserver.bind(this), this.fieldErrorObserverListener.bind(this));
    ChangeManager.register(domNodeSubjectFactory.getSubject(this.selectionTileGroup || this.host, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
  }
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaSelectionTile.disconnectedCallback}
   */
  disconnectedCallback() {
    ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.selectionTileGroup, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
  }
  /**
   * The function `canAcceptFieldErrorObserver` always returns `true`.
   *
   * @returns {boolean} a boolean value, which indicates the current host is a checkbox or checkbox group.
   */
  canAcceptFieldErrorObserver() {
    return true;
  }
  /**
   * The function listens to the showError property of the returned object.
   *
   * @param {FieldErrorPayload} payload - The payload parameter is of type FieldErrorPayload, which is an object containing information about field.
   */
  fieldErrorObserverListener(payload) {
    this.showError = payload.showError;
  }
}
__decorate$5([
  MapToComponentField({ writable: true })
], VegaSelectionTileShowErrorController.prototype, "showError", void 0);
__decorate$5([
  MapToComponentField()
], VegaSelectionTileShowErrorController.prototype, "host", void 0);
__decorate$5([
  MapToComponentMethod('connectedCallback')
], VegaSelectionTileShowErrorController.prototype, "connectedCallback", null);
__decorate$5([
  MapToComponentMethod('disconnectedCallback')
], VegaSelectionTileShowErrorController.prototype, "disconnectedCallback", null);

const vegaSelectionTileCss = ":host::not(.distribute-evenly){display:block}:host(.distribute-evenly){display:flex;width:100%}:host(.distribute-evenly) .selection-tile{flex:1}:host{display:block}:host .selection-tile{padding-left:16px;padding-right:16px;padding-top:12px;padding-bottom:12px;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));border-radius:8px;background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));color:rgba(var(--v-text-primary, 32, 54, 69, 1));cursor:pointer;margin:1px}:host .selection-tile:not(.disabled):hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1));background-color:rgba(var(--v-bg-tile-hover, 245, 247, 247, 1))}:host .selection-tile:not(.disabled):focus-visible{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px}:host .selection-tile:not(.disabled).checked{background-color:rgba(var(--v-bg-tile-selected, 242, 247, 255, 1));border:2px solid rgba(var(--v-border-tile-selected, 19, 98, 226, 1));margin:0px}:host .selection-tile:not(.disabled).checked:hover{border:2px solid rgba(var(--v-border-tile-selected-hover, 4, 112, 236, 1));background-color:rgba(var(--v-bg-tile-selected-hover, 229, 239, 255, 1))}:host .selection-tile:not(.disabled).checked:focus-visible{border:2px solid rgba(var(--v-border-tile-selected, 19, 98, 226, 1));background-color:rgba(var(--v-bg-tile-selected, 242, 247, 255, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px}:host .selection-tile:not(.disabled).error{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1))}:host .selection-tile:not(.disabled).error:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1));background-color:rgba(var(--v-bg-tile-hover, 245, 247, 247, 1))}:host .selection-tile:not(.disabled).error:focus-visible{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px}:host .selection-tile.disabled{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1));background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));pointer-events:none}:host .selection-tile.disabled .selection-tile-title,:host .selection-tile.disabled .selection-tile-note{color:rgba(var(--v-text-input-disabled, 107, 116, 125, 1))}:host .selection-tile .selection-tile-title{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .selection-tile .selection-tile-title{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .selection-tile .selection-tile-title{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .selection-tile .selection-tile-title{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}:host .selection-tile .selection-tile-note{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .selection-tile .selection-tile-note{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .selection-tile .selection-tile-note{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .selection-tile .selection-tile-note{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .selection-tile .selection-tile-icon{margin-top:4px;margin-bottom:4px}:host .selection-tile .selection-tile-select{height:24px}:host .selection-tile .selection-tile-select vega-checkbox,:host .selection-tile .selection-tile-select vega-radio{margin-top:4px}";

var __decorate$4 = (undefined && undefined.__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;
};
const VegaSelectionTile = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaSelectionTileRenderer();
    this.checkedController = new VegaSelectionTileCheckedController();
    this.stateController = new VegaSelectionTileStateController();
    this.showErrorController = new VegaSelectionTileShowErrorController();
    this.changeEventEmitter = createEventEmitSlimmer(VegaSelectionTile, VegaChange);
    this.checkboxEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.renderer.getSelectorContainerRef());
    this.checkboxValueChangeObserver = new ChildNodesNotifyObserverSlimmer(CHECKBOX_VALUE_CHANGE, (payload) => this.checkedController.onCheck(payload.detail));
    this.radioValueChangeObserver = new ChildNodesNotifyObserverSlimmer(RADIO_VALUE_CHANGE, (payload) => {
      if (payload.detail) {
        this.checkedController.onCheck(payload.detail);
      }
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Indicates whether the parent selection tile group shows error message.
     */
    this.showError = false;
    /**
     * Distribute vega-selection-tile components evenly to always cover the entire available width of the parent
     */
    this.distributeEvenly = false;
    /**
     * Specifies the text content of the title displayed
     *    within the selection tile.
     *
     * @vegaVersion 2.7.0
     */
    this.titleText = '';
    /**
     * Determines if the selection tile is disabled.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.disabled = false;
    /**
     * Determines the selection method for the tile. Options are:
     *
     * - `radio`:
     *      Displays a radio button for selection.
     * - `checkbox`:
     *      Displays a checkbox for selection.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.selectType = 'radio';
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: { 'distribute-evenly': this.distributeEvenly } }, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
};
__decorate$4([
  InjectVegaGlobalSlimmer()
], VegaSelectionTile.prototype, "globalSlimmers", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "renderer", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "checkedController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "stateController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "showErrorController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "changeEventEmitter", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "checkboxEventPrevent", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "checkboxValueChangeObserver", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "radioValueChangeObserver", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionTile.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaSelectionTile.style = vegaSelectionTileCss;

var __decorate$3 = (undefined && undefined.__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;
};
class VegaSelectionTileGroupRenderer extends VegaSlimmer {
  getGroupContainerRef() {
    return this.groupContainerRef;
  }
  render() {
    return (h("div", null,
      this.renderLabel(),
      this.renderContainer(),
      this.renderHint()));
  }
  renderLabel() {
    return (this.label && (h("div", { class: "vega-label" },
      h("label", { "aria-label": this.label },
        this.label,
        this.renderRequire()))));
  }
  renderRequire() {
    return this.required && h("span", { class: "vega-require" }, "*");
  }
  renderContainer() {
    return (h("div", { class: "container", ref: (e) => (this.groupContainerRef = e) },
      h("vega-flex", { direction: this.layout === 'horizontal' ? 'row' : 'col', gap: "size-12" },
        h("slot", { 
          /* eslint-disable-next-line react/jsx-no-bind */
          onSlotchange: 
          /**
           * The below method is e2e-test covered in
           * @see{module:vega-selection-tile-group-slot-change-e2e}
           */
          /* istanbul ignore next */
          () => this.itemsController.syncTileArrayAndValue() }))));
  }
  renderHint() {
    return (this.hint && (h("div", { class: "vega-hint" },
      h("label", null, this.hint))));
  }
}
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "host", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "label", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "required", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "hint", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "layout", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "selectType", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionTileGroupRenderer.prototype, "itemsController", void 0);

var __decorate$2 = (undefined && undefined.__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;
};
/**
 * The `VegaSelectionTileGroupValueController` class in TypeScript manages the value selection for
 * a group of checkboxes or radio buttons.
 */
class VegaSelectionTileGroupValueController extends VegaSlimmer {
  /**
   * The `watchValue` function emits a change event with the current value and notifies the
   * `ChangeManager` about a form element value change.
   */
  watchValue() {
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  /**
   * The function `onSelectionTilesChanged` determines whether to set the value from checkbox items or
   * radio items based on the selected type.
   */
  onSelectionTilesChanged() {
    this.selectType === 'checkbox' ? this.setValueFromCheckboxItems() : this.setValueFromRadioItems();
  }
  /**
   * The function `onSelectionTileChecked` checks the type of input and calls the appropriate function to set the value
   * based on the type (checkbox or radio).
   *
   * @param {VegaSelectionTileCheckedPayload} payload - The `value` parameter in the `onSelectionTileChecked` function is a string that represents
   * the value of the checkbox or radio button that was checked.
   */
  onSelectionTileChecked(payload) {
    this.selectType === 'checkbox' ? this.setValueFromCheckbox(payload) : this.setValueFromRadio(payload);
  }
  /**
   * The function `setValueFromCheckbox` updates the value array by adding or removing a specified value.
   *
   * @param {VegaSelectionTileCheckedPayload} payload - The `value` parameter in the `setValueFromCheckbox` function is a string
   * representing the value of a checkbox.
   */
  setValueFromCheckbox(payload) {
    if (payload.checked && !this.value.includes(payload.value)) {
      this.value = [...this.value, payload.value];
    }
    else if (!payload.checked && this.value.includes(payload.value)) {
      this.value = [...this.value.filter((value) => value !== payload.value)];
    }
  }
  /**
   * The function `setValueFromRadio` sets the value of a radio button in TypeScript.
   *
   * @param {VegaSelectionTileCheckedPayload} payload - The `value` parameter is a string that represents the value to be set for
   * the radio button.
   */
  setValueFromRadio(payload) {
    if (payload.checked) {
      this.value = payload.value;
    }
  }
  /**
   * The function `setValueFromCheckboxItems` sets the value of an element based on the checked items in
   * a selection tile array.
   */
  setValueFromCheckboxItems() {
    if (this.value.length === 0) {
      this.value = this.itemsController
        .getSelectionTileArray()
        .filter((tile) => tile.checked)
        .map((tile) => tile.value);
    }
  }
  /**
   * The function `setValueFromRadioItems` sets the value of a radio item based on the checked status of
   * the items.
   */
  setValueFromRadioItems() {
    if (!this.value) {
      const checkedItem = this.itemsController
        .getSelectionTileArray()
        .find((tile) => tile.checked);
      if (checkedItem) {
        this.value = checkedItem.value;
      }
    }
  }
}
__decorate$2([
  MapToComponentField()
], VegaSelectionTileGroupValueController.prototype, "host", void 0);
__decorate$2([
  MapToComponentField({ writable: true })
], VegaSelectionTileGroupValueController.prototype, "value", void 0);
__decorate$2([
  MapToComponentField()
], VegaSelectionTileGroupValueController.prototype, "selectType", void 0);
__decorate$2([
  MapToComponentField()
], VegaSelectionTileGroupValueController.prototype, "changeEventEmitter", void 0);
__decorate$2([
  MapToComponentField()
], VegaSelectionTileGroupValueController.prototype, "itemsController", void 0);
__decorate$2([
  MapToComponentMethod('watchValue')
], VegaSelectionTileGroupValueController.prototype, "watchValue", null);

var __decorate$1 = (undefined && undefined.__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;
};
/**
 * The `VegaSelectionTileGroupItemsController` class manages an array of selection tiles within a
 * Vega selection tile group component.
 */
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$1([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "host", void 0);
__decorate$1([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "selectType", void 0);
__decorate$1([
  MapToComponentField()
], VegaSelectionTileGroupItemsController.prototype, "valueController", void 0);
__decorate$1([
  MapToComponentMethod('componentWillLoad')
], VegaSelectionTileGroupItemsController.prototype, "initSelectionTileArray", null);

const vegaSelectionTileGroupCss = ":host{display:block;text-align:left;line-height:normal}:host .vega-error{display:block;margin-top:12px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-error, 189, 41, 71, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-hidden{display:none}:host .vega-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;margin-bottom:16px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-label label{color:rgba(var(--v-text-primary, 32, 54, 69, 1))}:host .vega-label .vega-require{color:rgba(var(--v-text-error, 189, 41, 71, 1));margin-left:4px}:host .vega-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1));padding-top:12px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}";

var __decorate = (undefined && undefined.__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;
};
const VegaSelectionTileGroup = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaSelectionTileGroupRenderer();
    this.itemsController = new VegaSelectionTileGroupItemsController();
    this.valueController = new VegaSelectionTileGroupValueController();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      inputContainerGetter: () => this.renderer.getGroupContainerRef(),
      touchableAreaGetter: () => this.itemsController.touchableAreaGetter(),
      defaultValue: (target) => (target.selectType === 'checkbox' ? [] : ''),
      attributeGetter: (propertyName) => this[propertyName],
    });
    this.changeEventEmitter = createEventEmitSlimmer(VegaSelectionTileGroup, VegaChange);
    this.checkboxEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.renderer.getGroupContainerRef());
    this.selectionTileChangeObserver = new ChildNodesNotifyObserverSlimmer(SELECTION_TILE_VALUE_CHANGE, (payload) => this.valueController.onSelectionTileChecked(payload.detail));
    this.selectTypeNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'selectType', 'watchSelectType');
    this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'disabled', 'watchDisabled');
    this.valueNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'value', 'watchValue');
    this.distributeEvenlyNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'distributeEvenly', 'watchDistributeEvenly');
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the label or title for the selection tile group.
     *    It provides descriptive text that helps identify
     *    the purpose of the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    this.label = '';
    /**
     * Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group
     *
     * @vegaVersion 2.58.0
     */
    this.distributeEvenly = false;
    /**
     * Determines the selection method for the tile group. Options are:
     *
     * - `radio`:
     *      Displays a radio button for selection.
     * - `checkbox`:
     *      Displays a checkbox for selection.
     *
     * @vegaVersion 2.7.0
     */
    this.selectType = 'radio';
    /**
     * Stores the selected values of the nested selection tiles
     *    within the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = this.selectType === 'checkbox' ? [] : '';
    /**
     * Controls the layout of the nested selection tiles
     *    within the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    this.layout = 'vertical';
    /**
     * Defines custom validation rules for the selection tile group field.
     *
     * @vegaVersion 2.7.0
     */
    this.validationRules = [];
    /**
     * Sets the validation status for the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
  }
  watchDistributeEvenly() {
  }
  watchSelectType() {
  }
  watchValue() {
  }
  watchDisabled() {
  }
  watchValidationRules() {
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "distributeEvenly": ["watchDistributeEvenly"],
    "selectType": ["watchSelectType"],
    "value": ["watchValue"],
    "disabled": ["watchDisabled"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaSelectionTileGroup.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "itemsController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "checkboxEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "selectionTileChangeObserver", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "selectTypeNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "disabledNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "valueNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "distributeEvenlyNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaSelectionTileGroup.style = vegaSelectionTileGroupCss;

export { VegaSelectionTile as vega_selection_tile, VegaSelectionTileGroup as vega_selection_tile_group };
