import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-090d31ca.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-e5fd0fab.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { C as CheckBoxRequiredRule } from './check-box-required-rule-cb0aa339.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { C as CHECKBOX_VALUE_CHANGE, F as FORM_ELEMENT_VALUE_CHANGE, g as CHECKBOX_GROUP_DISABLED_CHANGE } from './static-subject-title-52f93124.js';
import { O as Observer } from './observer-3959f9dd.js';
import { f as findParent, a as arrayToClassString } from './ui-b7600a48.js';
import { c as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-899864a8.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-32da9d90.js';
import { h as VegaChange } from './vega-event-id-4ede557a.js';
import { h as VegaInternalFieldErrorStateChange } from './vega-internal-event-id-194bac82.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-observer-factory-aca0116e.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-9c24d4fc.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import { C as ComponentLoadRequired } from './component-load-required-db42032a.js';
import { C as ChildNodesNotifyObserverSlimmer } from './child-nodes-notify-observer-slimmer-a8cb19cf.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
import './string-a953eafc.js';
import './misc-9fdbcfbb.js';
import './dynamic-slimmer-90b8af32.js';
import './internal-translation-controller-4fb104b2.js';
import './index-3b327f29.js';
import './try-get-document-bef0f526.js';
import './page-resize-observer-slimmer-e24d36c5.js';
import './breakpoints-332702ed.js';
import './ui-93922c59.js';
import './breakpoints-d9faf11c.js';
import './mutation-observer-slimmer-58ebc13c.js';
import './mutation-observer-filters-1a054fb0.js';
import './array-7888f339.js';
import './number-4398f2e1.js';
import './sub-state-observer-slimmer-090c500a.js';
import './internal-vega-event-manager-8a657bac.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';

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 checkbox show error controller slimmer */
class VegaCheckboxShowErrorController extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]{@link VegaCheckbox.connectedCallback}
   */
  connectedCallback() {
    this.checkboxGroup =
      findParent(this.host, 'vega-checkbox-group') ||
        findParent(this.host, 'vega-selection-tile-group');
    this.fieldErrorObserver = new Observer(this.canAcceptFieldErrorObserver.bind(this), this.fieldErrorObserverListener.bind(this));
    ChangeManager.register(domNodeSubjectFactory.getSubject(this.checkboxGroup || this.host, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
  }
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaCheckbox.disconnectedCallback}
   */
  disconnectedCallback() {
    ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.checkboxGroup || this.host, 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$2([
  MapToComponentField({ writable: true })
], VegaCheckboxShowErrorController.prototype, "showError", void 0);
__decorate$2([
  MapToComponentField()
], VegaCheckboxShowErrorController.prototype, "host", void 0);
__decorate$2([
  MapToComponentMethod('connectedCallback')
], VegaCheckboxShowErrorController.prototype, "connectedCallback", null);
__decorate$2([
  MapToComponentMethod('disconnectedCallback')
], VegaCheckboxShowErrorController.prototype, "disconnectedCallback", null);

const vegaCheckboxCss = ":host{display:inline-block;vertical-align:middle}.vega-checkbox-container{position:relative;display:flex;-webkit-tap-highlight-color:transparent}.vega-checkbox-container>input[type=checkbox]{position:absolute;left:0px;top:0px;opacity:0;width:24px;height:24px;padding:0px;margin:0px}.vega-checkbox-container>.vega-checkbox-icon{display:inline-block;box-sizing:border-box;width:24px;height:24px;border-style:solid;border-width:2px;border-color:rgba(var(--v-border-color-action-active, 29, 65, 195, 1));position:relative;left:0px;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));border-radius:4px;min-width:24px;color:rgba(var(--v-text-inverted-primary, 252, 252, 252, 1))}.vega-checkbox-container>.vega-checkbox-icon:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}:host(.checked) .vega-checkbox-container>.vega-checkbox-icon,:host(.indeterminate) .vega-checkbox-container>.vega-checkbox-icon{background-color:rgba(var(--v-bg-action, 19, 98, 226, 1));display:inline-flex;align-items:center;justify-content:center}:host(.checked) .vega-checkbox-container>.vega-checkbox-icon:hover,:host(.indeterminate) .vega-checkbox-container>.vega-checkbox-icon:hover{background-color:rgba(var(--v-bg-action-hover, 4, 112, 236, 1))}.vega-checkbox-container>input[type=checkbox]:focus-visible+.vega-checkbox-icon{outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:3px}.vega-checkbox-container>.vega-checkbox-icon:active{border-width:1px;border-style:solid;border-color:rgba(var(--v-border-color-action-active, 29, 65, 195, 1))}:host(.checked) .vega-checkbox-container>.vega-checkbox-icon:active,:host(.indeterminate) .vega-checkbox-container>.vega-checkbox-icon:active{background-color:rgba(var(--v-bg-action-active, 29, 65, 195, 1))}:host(.disabled) .vega-checkbox-container{cursor:not-allowed}:host(:not(.disabled)) .vega-checkbox-container{cursor:pointer}.vega-checkbox-container .vega-require{color:rgba(var(--v-text-error, 189, 41, 71, 1));margin-left:4px;vertical-align:middle}.vega-checkbox-container.error>.vega-checkbox-icon{background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}:host(.checked) .vega-checkbox-container.error>.vega-checkbox-icon,:host(.indeterminate) .vega-checkbox-container.error>.vega-checkbox-icon{background-color:rgba(var(--v-bg-danger, 189, 41, 71, 1))}.vega-checkbox-container.error>.vega-checkbox-icon:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}:host(.checked) .vega-checkbox-container.error>.vega-checkbox-icon:hover,:host(.indeterminate) .vega-checkbox-container.error>.vega-checkbox-icon:hover{background-color:rgba(var(--v-bg-danger-hover, 233, 71, 104, 1))}.vega-checkbox-container.error>input[type=checkbox]:focus-visible+.vega-checkbox-icon{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:3px}:host(.checked) .vega-checkbox-container.error>.vega-checkbox-icon:active,:host(.indeterminate) .vega-checkbox-container.error>.vega-checkbox-icon:active{background-color:rgba(var(--v-bg-danger-active, 230, 50, 87, 1))}.vega-checkbox-container.error>.vega-checkbox-icon:active{border-width:1px;border-style:solid;border-color:rgba(var(--v-border-color-danger-active, 189, 41, 71, 1))}:host(.disabled) .vega-checkbox-container>.vega-checkbox-icon{background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host(.checked.disabled) .vega-checkbox-container>.vega-checkbox-icon,:host(.indeterminate.disabled) .vega-checkbox-container>.vega-checkbox-icon{background-color:rgba(var(--v-bg-disabled, 176, 180, 181, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host(.checked.disabled) .vega-checkbox-container>.vega-checkbox-icon>vega-icon,:host(.indeterminate.disabled) .vega-checkbox-container>.vega-checkbox-icon>vega-icon{color:rgba(var(--v-text-inverted-primary, 252, 252, 252, 1))}.vega-checkbox-container>.vega-checkbox-label-container{display:inline-block;margin-left:12px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-checkbox-container>.vega-checkbox-label-container{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){.vega-checkbox-container>.vega-checkbox-label-container{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){.vega-checkbox-container>.vega-checkbox-label-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}:host(.disabled) .vega-checkbox-container>.vega-checkbox-label-container{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}.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){.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){.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){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-checkbox-label-container.vega-hidden{display:none}.vega-hidden{display:none}.size-default input[type=checkbox]{width:24px;height:24px}.size-default .vega-checkbox-icon{width:24px;height:24px;min-width:24px;border-radius:4px}.size-default .vega-checkbox-label-container{margin-left:12px;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){.size-default .vega-checkbox-label-container{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){.size-default .vega-checkbox-label-container{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){.size-default .vega-checkbox-label-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}.size-small input[type=checkbox]{width:16px;height:16px}.size-small .vega-checkbox-icon{width:16px;height:16px;min-width:16px;border-radius:2px}.size-small .vega-checkbox-label-container{margin-left:8px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}@media screen and (min-width: 768px) and (max-width: 1023px){.size-small .vega-checkbox-label-container{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.size-small .vega-checkbox-label-container{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.size-small .vega-checkbox-label-container{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}";

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;
};
const VegaCheckbox = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.vegaCheckboxShowErrorController = new VegaCheckboxShowErrorController();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new CheckBoxRequiredRule() : null),
        },
      ],
      defaultValue: (target) => (target.identifier === '' ? false : ''),
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.inputContainerRef,
      touchableAreaGetter: () => [this.inputRef],
    });
    this.changeEventEmitter = createEventEmitSlimmer(VegaCheckbox, VegaChange);
    this.dropdownEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.host, {
      customPreventHandle: (e) => {
        e.stopPropagation();
      },
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Indicates whether the parent checkbox group is disabled.
     */
    this.groupDisabled = false;
    /**
     * Indicates whether the parent checkbox group show error message.
     */
    this.showError = false;
    /**
     * Sets a unique identifier for the checkbox.
     *
     * Refer to the `value` property for detailed information on
     *    how to use this property during form validation.
     *
     * @vegaVersion 1.10.0
     */
    this.identifier = '';
    /**
     * Determines the value that is associated with the checkbox
     *    when it is checked or unchecked.
     *
     * When the `identifier` property is set, the `value` property will
     *    return the value of the `identifier` when the checkbox is checked.
     *    When the checkbox is unchecked, the `value` property will
     *    return an empty string ''.
     *
     * If the `identifier` property is not set, the `value` property behaves
     *    as a boolean and returns `true` when the checkbox is checked,
     *    and `false` when it is unchecked.
     *
     * @vegaVersion 1.0.7
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = this.identifier !== '' ? '' : false;
    /**
     * Specifies whether the checkbox should be pre-checked.
     *
     * Use the `value` property to retrieve the current status of the checkbox.
     *
     * @vegaVersion 1.0.7
     */
    this.checked = false;
    /**
     * Specifies whether the checkbox is in an indeterminate state.
     *
     * The indeterminate state is a visual-only state typically used to represent
     *    a checkbox whose value is neither fully checked nor fully unchecked,
     *    such as a "select all" control where only some children are selected.
     *
     * Setting this property does not affect the `checked` or `value` properties.
     *    User interaction (clicking) will clear the indeterminate state and
     *    toggle `checked` as usual.
     *
     * @vegaVersion 2.83.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.indeterminate = false;
    /**
     * Specifies whether the checkbox element is disabled.
     *
     * @vegaVersion 1.3.0
     */
    this.disabled = false;
    /**
     * Specifies the size of the checkbox.
     *
     * @vegaVersion 1.3.0
     */
    this.size = 'default';
    /**
     * Specifies whether the checkbox must be checked
     *    to pass form validation.
     *
     * @vegaVersion 1.3.0
     */
    this.required = false;
    /**
     * Specifies the validation status of the checkbox component.
     *
     * @vegaVersion 1.10.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Indeterminate-clearing behavior is unit-tested.
     * The checked-state side of this method is e2e-test covered in
     * @see{module:vega-checkbox-change}
     */
    this.onCheckBoxChange = (e) => {
      if (this.indeterminate) {
        this.indeterminate = false;
      }
      this.checked = e.currentTarget.checked;
    };
    this.onSelectedIconClick = (e) => {
      e.stopPropagation();
    };
  }
  /* The below method is e2e-test covered in
   * @see{module:vega-checkbox-value-sync}
   */
  watchValueChange(newValue) {
    this.checked = this.identifier !== '' ? newValue === this.identifier : newValue === true;
  }
  watchCheckedChange() {
    this.initValue();
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(CHECKBOX_VALUE_CHANGE, { host: this.host, detail: this.value });
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  disconnectedCallback() {
    this.unRegisterGroupDisabledObserver();
  }
  componentWillLoad() {
    // Handle pre-set value (e.g., Angular writeValue before hydration, or HTML attribute)
    const shouldBeChecked = this.identifier !== ''
      ? this.value === this.identifier
      : this.value === true || this.value === 'true';
    if (!this.checked && shouldBeChecked) {
      this.checked = true;
    }
    this.initValue();
    this.initAndRegisterGroupDisabledObserver();
  }
  componentDidRender() {
    if (this.host.innerHTML.trim() === '') {
      this.labelElement.classList.add('vega-hidden');
    }
    this.syncNativeIndeterminate();
  }
  /**
   * Invoke this method to set the value of the checkbox.
   *
   * It is recommended to use this method instead of directly modifying the `value` property.
   *
   * @vegaVersion 1.16.0
   */
  async setValue(value) {
    this.checked = this.identifier ? value === this.identifier : value === true;
  }
  render() {
    var _a;
    /* istanbul ignore next */
    const isInsideCheckboxGroup = ((_a = this.host.parentElement) === null || _a === void 0 ? void 0 : _a.nodeName) == 'VEGA-CHECKBOX-GROUP';
    return sanitizeVegaComponent(h(Host, { class: {
        'vega-flex-shrink-0 v-min-w-min': isInsideCheckboxGroup,
        'checked': this.checked,
        'indeterminate': this.indeterminate,
        'disabled': this.isDisabled(),
      } }, h("label", { class: arrayToClassString([
        'vega-checkbox-container',
        this.showError && 'error',
        this.size && `size-${this.size}`,
      ]), ref: (e) => (this.inputContainerRef = e) }, h("input", { ref: (e) => (this.inputRef = e), type: "checkbox", checked: this.checked, value: this.identifier, onChange: this.onCheckBoxChange, "aria-label": this.identifier || 'No label defined', "aria-checked": this.indeterminate ? 'mixed' : undefined, disabled: this.isDisabled(), tabIndex: 0, onKeyDown: createEnterKeyHandlerToTriggerClick() }), h("span", { class: "vega-checkbox-icon", onClick: this.onSelectedIconClick, tabIndex: -1 }, this.renderIconDom()), h("div", { class: "vega-checkbox-label-container", ref: (el) => (this.labelElement = el) }, this.renderLabelDom(), this.renderRequireDom()))), this.host);
  }
  renderIconDom() {
    if (this.indeterminate) {
      return h("vega-icon", { icon: "minus-sign", size: this.size === 'small' ? 'size-12' : 'size-16' });
    }
    return this.checked ? (h("vega-icon", { icon: "checkmark", size: this.size === 'small' ? 'size-12' : 'size-16' })) : null;
  }
  renderLabelDom() {
    return (h("span", { class: "vega-checkbox-label" }, h("slot", null)));
  }
  renderRequireDom() {
    return (h("span", { class: {
        'vega-require': this.required,
      } }, this.required ? '*' : ''));
  }
  initValue() {
    this.value = this.identifier !== '' ? (this.checked ? this.identifier : '') : this.checked;
  }
  /**
   * Syncs the indeterminate property to the native input element.
   * The HTML `indeterminate` attribute can only be set via JavaScript,
   *    so it must be applied imperatively after each render.
   */
  syncNativeIndeterminate() {
    if (this.inputRef) {
      this.inputRef.indeterminate = this.indeterminate;
    }
  }
  /**
   * indicating whether the component is disabled or not, single checkbox will take the self disabled value and the checkbox in group will take the self disabled and group disabled value
   *
   * @returns {boolean} the checkbox disabled or not
   */
  isDisabled() {
    return this.disabled || this.groupDisabled;
  }
  /**
   * The function checks if a checkbox button element can accept a disabled state from a group.
   *
   * @param {GroupDisabledPayload} input - The input parameter is of type GroupDisabledPayload, which is an object containing information about a disabled checkbox button group.
   * @returns {boolean} a boolean value, which indicates whether the input element (this.el) is present in a group  of checkbox buttons (vega-checkbox) or not.
   */
  canAcceptGroupDisabledObserver(input) {
    return findParent(this.host, 'vega-checkbox-group') === input.host;
  }
  /**
   * This function listens for changes in the disabled state of a group and updates the `groupDisabled` variable accordingly.
   *
   * @param {GroupDisabledPayload} input - The input parameter is of type GroupDisabledPayload, which is likely an object containing information about a disabled group.
   */
  groupDisabledObserverListener(input) {
    this.groupDisabled = input.host.disabled;
  }
  /**
   * This function initializes an observer for changes in the disabled state of a checkbox group.
   */
  initAndRegisterGroupDisabledObserver() {
    if (findParent(this.host, 'vega-checkbox-group')) {
      this.groupDisabledObserver = new Observer(this.canAcceptGroupDisabledObserver.bind(this), this.groupDisabledObserverListener.bind(this));
      ChangeManager.register(CHECKBOX_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  /**
   * This function unregister a group disabled observer if it exists.
   */
  unRegisterGroupDisabledObserver() {
    if (this.groupDisabledObserver) {
      ChangeManager.unregister(CHECKBOX_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "value": ["watchValueChange"],
    "checked": ["watchCheckedChange"]
  }; }
};
__decorate$1([
  InjectVegaGlobalSlimmer()
], VegaCheckbox.prototype, "globalSlimmers", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaCheckbox.prototype, "vegaCheckboxShowErrorController", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaCheckbox.prototype, "formFieldController", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaCheckbox.prototype, "changeEventEmitter", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaCheckbox.prototype, "dropdownEventPrevent", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaCheckbox.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaCheckbox.style = vegaCheckboxCss;

const vegaCheckboxGroupCss = ":host{display:block;text-align:left;line-height:normal}.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){.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){.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){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-hidden{display:none}.vega-label{margin-bottom:16px}.vega-label label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:500;line-height:30px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}.vega-require{color:rgba(var(--v-text-error, 189, 41, 71, 1));margin-left:4px}.vega-hint{padding-top:12px}.vega-hint>label{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){.vega-hint>label{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){.vega-hint>label{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){.vega-hint>label{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 VegaCheckboxGroup = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      defaultValue: [],
      validationRulesName: 'validationRules',
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.inputContainerRef,
      touchableAreaGetter: () => this.touchableAreaGetter(),
    });
    this.checkboxValueChangeObserver = new ChildNodesNotifyObserverSlimmer(CHECKBOX_VALUE_CHANGE, (input) => this.childCheckboxValueChange(input));
    this.checkboxEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.vegaFlexElement);
    this.changeEventEmitter = createEventEmitSlimmer(VegaCheckboxGroup, VegaChange);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the label or title for the checkbox group.
     *    It provides descriptive text that helps identify
     *    the purpose of the checkbox group.
     *
     * @vegaVersion 1.3.0
     */
    this.label = '';
    /**
     * Stores the selected values of the nested checkboxes
     *    within the checkbox group.
     *
     * @vegaVersion 1.0.7
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = [];
    /**
     * Specifies all properties of a `vega-flex` component,
     *    accessible as an object.
     *
     * @vegaVersion 1.3.0
     */
    this.vegaFlexProp = {};
    /**
     * Indicates if the checkbox group is disabled.
     *
     * @vegaVersion 1.3.0
     */
    this.disabled = false;
    /**
     * Indicates whether at least one checkbox in the
     *    checkbox group must be checked to pass
     *    form validation.
     *
     * @vegaVersion 1.3.0
     */
    this.required = false;
    /**
     * Provides a supplementary prompt message that
     *    assists users in selecting the appropriate
     *    value for the checkbox group.
     *
     * @vegaVersion 1.3.0
     */
    this.hint = '';
    /** Specifies the validation status of the
     *    checkbox group component.
     *
     * @vegaVersion 1.3.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether automatic validation should be implemented for
     *    the checkbox group upon selection.
     *
     * @vegaVersion 2.6.0
     */
    this.autoValidation = true;
    /**
     * Defines custom validation rules for the checkbox group.
     *
     * @vegaVersion 2.6.0
     */
    this.validationRules = [];
    /**
     * Update checkbox group value when child checkbox is changed.
     *
     * @param {NotifyObserverPayload<boolean>} input change payload from child checkbox
     */
    this.childCheckboxValueChange = (input) => {
      this.syncCheckboxItemsValue(input.detail, input.host.identifier);
    };
    this.touchableAreaGetter = () => {
      const inputArray = [];
      this.vegaCheckboxArray &&
        this.vegaCheckboxArray.forEach(async (vegaCheckbox) => {
          inputArray.push(vegaCheckbox.shadowRoot.querySelector('input'));
        });
      return inputArray;
    };
  }
  async watchValue() {
    this.initCheckboxArray();
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  watchVegaFlexProp() {
    this.setVegaFlexProperty();
  }
  async watchDisabled() {
    this.notifyGroupDisabledChange();
  }
  watchValidationRules() {
  }
  componentDidLoad() {
    this.setVegaFlexProperty();
    this.initCheckboxArray();
    this.notifyGroupDisabledChange();
  }
  /**
   * The below method is e2e-test covered in
   * @see{module:vega-checkbox-group-dark-change-background-color }
   */
  /* istanbul ignore next */
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderLabelDom(), h("div", { class: "vega-checkbox-group-container", ref: (e) => (this.inputContainerRef = e) }, h("vega-flex", { ref: (el) => {
        this.vegaFlexElement = el;
      } }, h("slot", null))), this.renderHintDom()), this.host);
  }
  renderLabelDom() {
    return (this.label && (h("div", { class: "vega-label" }, h("label", { "aria-label": this.label }, this.label, this.renderRequireDom()))));
  }
  renderRequireDom() {
    return this.required ? h("span", { class: "vega-require" }, "*") : null;
  }
  renderHintDom() {
    return (this.hint && (h("div", { class: "vega-hint" }, h("label", null, this.hint))));
  }
  setVegaFlexProperty() {
    if (this.vegaFlexProp) {
      Object.assign(this.vegaFlexElement, {
        gap: 'size-16',
        direction: 'col',
      }, this.vegaFlexProp);
    }
  }
  /**
   * 1. If the checkbox is checked, the value of checkbox group doesn't contain the value of the selected checkbox and needs to be added
   * 2. If the checkbox isn't checked, the value of checkbox group contains the value of the selected checkbox and needs to be deleted
   * @see{module:vega-checkbox-group-with-listen-vega-change-event-e2e}
   */
  /* istanbul ignore next */
  syncCheckboxItemsValue(checked, checkboxValue) {
    if (checked && !this.value.includes(checkboxValue)) {
      this.value = [...this.value, checkboxValue];
    }
    else if (!checked && this.value.includes(checkboxValue)) {
      this.value = [...this.value.filter((value) => value !== checkboxValue)];
    }
  }
  initCheckboxArray() {
    this.vegaCheckboxArray = Array.from(this.host.querySelectorAll('vega-checkbox'));
    this.vegaCheckboxArray.forEach((vegaCheckbox) => {
      if (this.value && this.value.length > 0) {
        vegaCheckbox.checked = this.value.includes(vegaCheckbox.identifier);
      }
      else {
        vegaCheckbox.checked = false;
      }
    });
  }
  /**
   * This function notifies a change in the disabled state of a checkbox group component.
   */
  notifyGroupDisabledChange() {
    ChangeManager.notify(CHECKBOX_GROUP_DISABLED_CHANGE, { host: this.host });
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "value": ["watchValue"],
    "vegaFlexProp": ["watchVegaFlexProp"],
    "disabled": ["watchDisabled"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaCheckboxGroup.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaCheckboxGroup.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaCheckboxGroup.prototype, "checkboxValueChangeObserver", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaCheckboxGroup.prototype, "checkboxEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaCheckboxGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaCheckboxGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  ComponentLoadRequired()
], VegaCheckboxGroup.prototype, "watchVegaFlexProp", null);
VegaCheckboxGroup.style = vegaCheckboxGroupCss;

export { VegaCheckbox as vega_checkbox, VegaCheckboxGroup as vega_checkbox_group };
