import { h, F as Fragment, H as Host, r as registerInstance, c as createEvent, g as getElement } from './index-090d31ca.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import { g as getActiveElement, s as sanitizeVegaComponent } from './component-7d906393.js';
import { Z as isArrayOfType, _ as isDropdownSourceItemType } from './type-guard-ed1004cc.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-9e70a18d.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-2fcba81b.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-697ad0b7.js';
import { q as VegaCreate, w as VegaDropdownHide, V as VegaDropdownClick, g as VegaClose, i as VegaChange, r as VegaSearch } from './vega-event-id-578c6c6d.js';
import { F as FORM_ELEMENT_VALUE_CHANGE } from './static-subject-title-52f93124.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-524cabd2.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-3897e95b.js';
import { l as VegaInternalDropdownTemplateItemsChange } from './vega-internal-event-id-913e8be6.js';
import { h as htmlSanitizer, l as labelSanitizeStrategy } from './index-3b327f29.js';
import { K as KeyboardManagerSlimmer } from './keyboard-manager-slimmer-012a9a9b.js';
import { f as findParent } from './ui-64815a12.js';
import { M as MutationObserverSlimmer } from './mutation-observer-slimmer-58ebc13c.js';
import { T as TagNameMutationFilter } from './mutation-observer-filters-1a054fb0.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
import './breakpoints-d9faf11c.js';
import './ui-93922c59.js';
import './typography-396de03f.js';
import './internal-translation-controller-d8217d93.js';
import './string-a953eafc.js';
import './observer-3959f9dd.js';
import './misc-9fdbcfbb.js';
import './dynamic-slimmer-90b8af32.js';
import './page-resize-observer-slimmer-e24d36c5.js';
import './breakpoints-332702ed.js';
import './try-get-document-bef0f526.js';
import './array-7888f339.js';
import './number-4398f2e1.js';
import './sub-state-observer-slimmer-81538a8c.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';
import './keyboard-manager-26e2fc32.js';

const VegaComboBoxRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'AUTO_VALIDATION_IS_TRUE',
    payloadDescription: 'Determines whether automatic validation should be implemented when a value is edited in the combo box',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'true'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === true,
  },
  {
    payloadKey: 'AUTO_VALIDATION_IS_FALSE',
    payloadDescription: 'Determines whether automatic validation should be implemented when a value is edited in the combo box',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'false'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === false,
  },
];

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;
};
class VegaComboBoxDropdownRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.onItemClick = async () => {
      this.valueController.setValue((await this.dropdownRef.getSelection()));
      await this.clearInput();
    };
    this.onDropdownHide = async () => {
      await this.clearInput();
    };
    this.onDropdownCreate = async (searchString) => {
      this.createEventEmit.emit(searchString);
      await this.clearInput();
    };
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-search-input}
     * @see{module:vega-combo-box-vega-search-event-e2e}
     */
    /* istanbul ignore next */
    this.onInputChange = async (e) => {
      const value = e.target.value;
      if (this.useDefaultFilter || this.vegaDropdownProps.dynamicOption) {
        await this.dropdownRef.show();
        await this.dropdownRef.search(value);
      }
      if (this.isTemplateMode || !this.useDefaultFilter) {
        this.searchEventEmit.emit(value);
      }
    };
  }
  connectedCallback() {
    this.isTemplateMode = this.host.querySelector('[slot=items]') !== null;
  }
  getDropdownRef() {
    return this.dropdownRef;
  }
  getSearchInputRef() {
    return this.searchInputRef;
  }
  /**
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-focus-by-label-e2e}
   */
  /* istanbul ignore next */
  focusInput() {
    this.searchInputRef.focus();
  }
  async hide() {
    await this.dropdownRef.hide();
  }
  async show() {
    await this.dropdownRef.show();
  }
  replaceItemsSlot(itemsSlot) {
    if (itemsSlot && this.itemsSlotRef) {
      this.itemsSlotRef.remove();
      this.dropdownRef.append(itemsSlot);
    }
  }
  renderDropdown() {
    return (h("vega-dropdown", Object.assign({ trigger: this.disabled ? 'none' : 'click', source: this.source, selectType: "multiple", selectedSourceKey: this.value, matchTargetWidth: true, useDefaultFilter: this.useDefaultFilter }, this.vegaDropdownProps, { ref: (ref) => {
        this.dropdownRef = ref;
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaCreate, async (payload) => {
          await this.onDropdownCreate(payload.detail);
        });
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaDropdownHide, async () => {
          await this.onDropdownHide();
        });
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaDropdownClick, async () => {
          await this.onItemClick();
        });
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaInternalDropdownTemplateItemsChange, 
        /*
         * The below method is e2e-test covered in
         * @see{module:vega-combo-box-template-select-e2e}
         */
        /* istanbul ignore next */
        (payload) => {
          const addedItems = Array.from(payload)
            .filter((item) => !this.source.find((sourceItem) => sourceItem.key === item.itemKey))
            .map((item) => ({
            key: item.itemKey,
            label: item.label,
          }));
          this.sourceController.setSource([...this.source, ...addedItems]);
        });
      } }),
      this.renderContainer(),
      this.renderItemsSlot()));
  }
  renderContainer() {
    return (h("div", { class: {
        'vega-combo-box-container': true,
        [`vega-combo-box-size-${this.size}`]: true,
      } },
      this.renderSelectedContainer(),
      this.renderInputContainer()));
  }
  renderItemsSlot() {
    return (this.isTemplateMode && (h("div", { slot: "items", ref: (ref) => {
        this.itemsSlotRef = ref;
      } })));
  }
  renderSelectedContainer() {
    const selected = this.value
      .map((key) => this.source.find((item) => item.key === key))
      .filter((item) => item);
    return (h(Fragment, null, selected.map((item) => {
      return this.renderSelectedChip(item);
    })));
  }
  renderSelectedChip(item) {
    return (h("vega-chip", { 
      //TODO: the key property test will add in https://gethired.atlassian.net/browse/VD-883
      key: item.key, text: htmlSanitizer.sanitize(item.label, labelSanitizeStrategy), variant: "outlined", showCloseIcon: !this.disabled, size: "small", ref: (ref) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaClose, async () => {
          await this.onChipClose(item.key);
        });
      } }));
  }
  renderInputContainer() {
    return (h("div", { class: "vega-combo-box-input-container" },
      h("input", { onInput: this.onInputChange, "aria-label": this.label || 'No label defined', placeholder: this.value.length === 0 ? this.placeholder : '', ref: (e) => (this.searchInputRef = e), onKeyDown: createEnterKeyHandlerToTriggerClick(), disabled: this.disabled })));
  }
  async onChipClose(key) {
    this.valueController.setValue([...this.value.filter((value) => value !== key)]);
    await this.dropdownRef.hide();
  }
  async clearInput() {
    this.searchInputRef.value = '';
    await this.dropdownRef.search('');
  }
}
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "host", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "value", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "source", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "disabled", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "size", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "vegaDropdownProps", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "label", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "placeholder", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "useDefaultFilter", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "createEventEmit", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "searchEventEmit", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "valueController", void 0);
__decorate$6([
  MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "sourceController", void 0);
__decorate$6([
  MapToComponentMethod('connectedCallback')
], VegaComboBoxDropdownRenderer.prototype, "connectedCallback", null);

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 value controller of `VegaComboBox` component.
 */
class VegaComboBoxValueController extends VegaSlimmer {
  /**
   * The function `setValue` sets the value of a VegaComboBox component.
   *
   * @param {string[]} value - value
   */
  setValue(value) {
    this.value = value;
  }
}
__decorate$5([
  MapToComponentField({ writable: true })
], VegaComboBoxValueController.prototype, "value", void 0);

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;
};
class VegaComboBoxRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-focus-by-label-e2e}
     */
    /* istanbul ignore next */
    this.onLabelClick = () => {
      this.dropdownRenderer.focusInput();
    };
  }
  render() {
    return (h(Host, { class: {
        'vega-combo-box-disabled': this.disabled,
      } },
      this.renderLabel(),
      this.dropdownRenderer.renderDropdown(),
      this.renderHint()));
  }
  renderLabel() {
    return (h("vega-field-label", { onClick: this.onLabelClick, "is-field-required": this.required, disabled: this.disabled, label: this.label }));
  }
  renderHint() {
    return h("div", { class: "vega-combo-box-hint" }, this.hint);
  }
}
__decorate$4([
  MapToComponentField()
], VegaComboBoxRenderer.prototype, "required", void 0);
__decorate$4([
  MapToComponentField()
], VegaComboBoxRenderer.prototype, "hint", void 0);
__decorate$4([
  MapToComponentField()
], VegaComboBoxRenderer.prototype, "disabled", void 0);
__decorate$4([
  MapToComponentField()
], VegaComboBoxRenderer.prototype, "dropdownRenderer", void 0);
__decorate$4([
  MapToComponentField()
], VegaComboBoxRenderer.prototype, "label", void 0);

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;
};
/**
 * Keyboard controller for vega-combo-box
 */
class VegaComboBoxKeyboardController extends KeyboardManagerSlimmer {
  /** The function sets up the functionality of key board control */
  constructor() {
    super((target) => [
      {
        keyCode: 'Backspace',
        activeElementInScope: [target.dropdownRenderer.getSearchInputRef()],
        eventName: 'keydown',
        callback: target.deleteLastSelectedItem,
      },
      {
        keyCode: 'ArrowLeft',
        activeElementInScope: [target.host],
        callback: 
        /* istanbul ignore next */
        /* eslint-disable jsdoc/require-jsdoc */
        () => target.controlDirectionByKeyboard('ArrowLeft'),
      },
      {
        keyCode: 'ArrowRight',
        activeElementInScope: [target.host],
        callback: 
        /* istanbul ignore next */
        /* eslint-disable jsdoc/require-jsdoc */
        () => target.controlDirectionByKeyboard('ArrowRight'),
      },
    ]);
    /*
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-keyboard-control-e2e}
     * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
     */
    /* istanbul ignore next */
    /**
     * Delete last item when press `Backspace` key
     */
    this.deleteLastSelectedItem = () => {
      if (this.dropdownRenderer.getSearchInputRef().value === '') {
        this.value.pop();
        this.valueController.setValue([...this.value]);
      }
    };
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-keyboard-control-e2e}
   * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
   */
  /* istanbul ignore next */
  /**
   * Handles keyboard input to navigate between elements, focusing on the previous or next element based on the key pressed.
   *
   * @param {KeyboardCodeType} code - code
   */
  controlDirectionByKeyboard(code) {
    const activeElement = getActiveElement();
    if (activeElement && activeElement.classList.contains('vega-chip-close-icon')) {
      const currentChip = findParent(activeElement, 'vega-chip');
      if (code === 'ArrowLeft')
        this.focusItemByKeyboard(currentChip.previousSibling);
      if (code === 'ArrowRight')
        this.focusItemByKeyboard(currentChip.nextSibling);
    }
    else if (code === 'ArrowLeft' && this.dropdownRenderer.getSearchInputRef().selectionStart === 0) {
      this.focusItemByKeyboard(this.host.shadowRoot.querySelector('vega-chip:last-of-type'));
    }
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-keyboard-control-e2e}
   * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
   */
  /* istanbul ignore next */
  /**
   * The function is used to focus on a specific element based on its class name.
   *
   * @param {HTMLElement} item - item
   */
  focusItemByKeyboard(item) {
    if (item) {
      if (item.classList.contains('vega-combo-box-input-container')) {
        item.querySelector('input').focus();
      }
      else {
        item.shadowRoot.querySelector('.vega-chip-close-icon').focus();
      }
    }
  }
}
__decorate$3([
  MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "host", void 0);
__decorate$3([
  MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "value", void 0);
__decorate$3([
  MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "dropdownRenderer", void 0);
__decorate$3([
  MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "valueController", 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 class `VegaInputSelectItemsSlotController` extends `VegaSlimmer` and manages
 * appending host items to a dropdown element.
 */
class VegaComboBoxItemsSlotController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.mutationObserver = new MutationObserverSlimmer({
      mutationFilter: TagNameMutationFilter('VEGA-DROPDOWN-ITEM'),
      options: {
        childList: true,
        subtree: true,
      },
      callback: 
      /*
       * The below method is e2e-test covered in
       * @see{module:vega-combo-box-template-slot-change-e2e}
       */
      /* istanbul ignore next */
      // eslint-disable-next-line jsdoc/require-jsdoc
      () => this.appendHostItemsToDropdown(),
    });
  }
  /**
   * Component lifecycle - [componentDidLoad]
   */
  componentDidLoad() {
    this.appendHostItemsToDropdown();
  }
  /**
   * The function appends host items to a dropdown element.
   */
  appendHostItemsToDropdown() {
    this.dropdownRenderer.replaceItemsSlot(this.host.querySelector('[slot=items]'));
  }
}
__decorate$2([
  InjectVegaSlimmer()
], VegaComboBoxItemsSlotController.prototype, "mutationObserver", void 0);
__decorate$2([
  MapToComponentField()
], VegaComboBoxItemsSlotController.prototype, "host", void 0);
__decorate$2([
  MapToComponentField()
], VegaComboBoxItemsSlotController.prototype, "dropdownRenderer", void 0);
__decorate$2([
  MapToComponentMethod('componentDidLoad')
], VegaComboBoxItemsSlotController.prototype, "componentDidLoad", 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 source controller of `VegaComboBox` component.
 */
class VegaComboBoxSourceController extends VegaSlimmer {
  /**
   * The function `setSource` sets the source of a VegaComboBox component.
   *
   * @param {string[]} source - source
   */
  setSource(source) {
    this.source = source;
  }
}
__decorate$1([
  MapToComponentField({ writable: true })
], VegaComboBoxSourceController.prototype, "source", void 0);

const vegaComboBoxCss = ":host{display:inline-block;width:100%;min-width:0px;text-align:left;line-height:normal}.vega-combo-box-container{border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));padding-left:16px;padding-right:16px;padding-top:12px;padding-bottom:12px;border-radius:8px;gap:8px;display:block;display:flex;flex-wrap:wrap;align-items:center;cursor:pointer}.vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}.vega-combo-box-container:focus-within{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px}.vega-combo-box-container .vega-combo-box-input-container{width:-webkit-min-content;width:-moz-min-content;width:min-content;flex-grow:1}.vega-combo-box-container input{border-style:none;background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0));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));width:100%}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-combo-box-container input{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-combo-box-container input{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-combo-box-container input{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}.vega-combo-box-container input:focus{outline:2px solid transparent;outline-offset:2px}.vega-combo-box-size-medium{padding-left:12px;padding-right:12px;padding-top:11px;padding-bottom:11px}.vega-combo-box-size-small{padding-left:12px;padding-right:12px;padding-top:7px;padding-bottom:7px}.vega-combo-box-container:focus{outline:none}vega-field-label{margin-bottom:8px}.error .vega-combo-box-container{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}.error .vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}.error .vega-combo-box-container:focus-within{border:1px solid rgba(var(--v-border-input-field-danger-focus, 233, 71, 104, 1));outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px}:host(.vega-combo-box-disabled) .vega-combo-box-container{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));--tw-shadow:0 0 #0000;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px}:host(.vega-combo-box-disabled) .vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host(.vega-combo-box-disabled) vega-icon{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}.vega-combo-box-container input::placeholder{color:rgba(var(--v-text-input-placeholder, 176, 180, 181, 1))}.vega-error{display:inline-block;padding-left:8px;padding-right:8px;padding-top:8px;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-combo-box-hint{padding-left:8px;padding-right:8px;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:8px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-combo-box-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){.vega-combo-box-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){.vega-combo-box-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-error:not(.vega-hidden)+.vega-combo-box-hint{padding-top:4px}vega-dropdown{display:block}";

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 VegaComboBox = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.vegaCreate = createEvent(this, "vegaCreate", 7);
    this.create = createEvent(this, "create", 7);
    this.vegaSearch = createEvent(this, "vegaSearch", 7);
    this.search = createEvent(this, "search", 7);
    this.globalSlimmers = {};
    this.itemsSlotController = new VegaComboBoxItemsSlotController();
    this.keyboardController = new VegaComboBoxKeyboardController();
    this.valueController = new VegaComboBoxValueController();
    this.sourceController = new VegaComboBoxSourceController();
    this.renderer = new VegaComboBoxRenderer();
    this.dropdownRenderer = new VegaComboBoxDropdownRenderer();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: [],
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.dropdownRenderer.getDropdownRef(),
      touchableAreaGetter: () => [this.dropdownRenderer.getSearchInputRef()],
    });
    this.changeEventEmit = createEventEmitSlimmer(VegaComboBox, VegaChange);
    this.createEventEmit = createEventEmitSlimmer(VegaComboBox, VegaCreate);
    this.searchEventEmit = createEventEmitSlimmer(VegaComboBox, VegaSearch);
    this.dropdownEventPrevent = new ChildNodesEventPreventSlimmer([VegaCreate, VegaSearch], () => this.dropdownRenderer.getDropdownRef(), {
      customPreventHandle: (e) => {
        e.stopImmediatePropagation();
      },
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaComboBoxRuntimeMetricsPayloadDefinition);
    /**
     * Specifies the label or title for the combo box.
     *
     * It provides descriptive text that helps identify the
     *    purpose or content expected in the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.label = '';
    /**
     * Specifies whether a value must be entered for the
     *    combo box to pass form validation.
     *
     * @vegaVersion 1.11.0
     */
    this.required = false;
    /**
     * Specifies the source data used to populate the
     *    dropdown menu associated with the combo box.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.source = [];
    /**
     * Sets the initial or preset values of the combo box.
     *
     * It should be an array of strings representing the selected values.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = [];
    /**
     * Specifies the validation status of the combo box component.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether automatic validation should be implemented
     *    when a value is edited in the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.autoValidation = true;
    /**
     * Specifies custom validation rules for the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.validationRules = [];
    /**
     * Specifies whether the combo box element is disabled.
     *
     * @vegaVersion 1.11.0
     */
    this.disabled = false;
    /**
     * Sets a placeholder string that provides a temporary hint
     *    or example inside the combo box input field.
     *
     * It indicates the expected format or pattern of the input.
     *
     * @vegaVersion 1.11.0
     */
    this.placeholder = '';
    /**
     * Provides a supplementary prompt message that is displayed
     *    alongside the combo box input field.
     *
     * @vegaVersion 1.11.0
     */
    this.hint = '';
    /**
     * Specifies the size of the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.size = 'medium';
    /**
     * Specifies partial properties of the `vega-dropdown` component
     *    that are used to configure the dropdown menu
     *    associated with the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.vegaDropdownProps = {};
    /**
     * Determines whether to display the associated dropdown menu and
     *    filter its options based on the text entered into the combo box.
     *
     * Setting this property to `false` enables custom text input handling
     *    by listening for the `vegaSearch` event.
     *
     * @vegaVersion 1.24.0
     */
    this.useDefaultFilter = true;
  }
  watchSource() {
    this.source = isArrayOfType(this.source, isDropdownSourceItemType)
      ? this.source
      : [];
  }
  watchValue() {
    this.changeEventEmit.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  watchValidationRules() {
  }
  /**
   * Invoke this method to close the dropdown menu associated with the combo box.
   *
   * @vegaVersion 1.11.0
   */
  async close() {
    if (!this.disabled) {
      await this.dropdownRenderer.hide();
    }
  }
  /**
   * Invoke this method to open the dropdown menu associated with the combo box.
   *
   * @vegaVersion 1.11.0
   */
  async open() {
    if (!this.disabled) {
      await this.dropdownRenderer.show();
    }
  }
  render() {
    return sanitizeVegaComponent(this.renderer.render(), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "source": ["watchSource"],
    "value": ["watchValue"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaComboBox.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "itemsSlotController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "keyboardController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "sourceController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "dropdownRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "changeEventEmit", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "createEventEmit", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "searchEventEmit", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "dropdownEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaComboBox.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaComboBox.style = vegaComboBoxCss;

export { VegaComboBox as vega_combo_box };
