import { html, nothing } from 'lit';
import { query, state, property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
import { stopAnimations, animateTo } from '../../internal/animate.mjs';
import { boolean } from '../../internal/boolean.mjs';
import { getCssPropertyInPixels } from '../../internal/computed-style.mjs';
import { defaultValue } from '../../internal/default-value.mjs';
import { waitForEvent } from '../../internal/event.mjs';
import { FlowRdfFormControl } from '../../internal/flow-ui-rdf-element.mjs';
import { FormControlController } from '../../internal/form.mjs';
import { scrollIntoView } from '../../internal/scroll.mjs';
import { HasSlotController } from '../../internal/slot.mjs';
import { watch } from '../../internal/watch.mjs';
import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.mjs';
import { LocalizeController } from '../../utilities/localize.mjs';
import FlowUiIcon from '../icon/icon.component.mjs';
import FlowUiPopup from '../popup/popup.component.mjs';
import FlowUiTag from '../tag/tag.component.mjs';
import styles from './select.styles.mjs';

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result)
    __defProp(target, key, result);
  return result;
};
class FlowUiSelect extends FlowRdfFormControl {
  constructor() {
    super(...arguments);
    this.formControlController = new FormControlController(this, {
      assumeInteractionOn: ["flow-ui-blur", "flow-ui-input"]
    });
    this.hasSlotController = new HasSlotController(this, "help-text", "label");
    this.localize = new LocalizeController(this);
    this.typeToSelectString = "";
    this.mouseDownAt = 0;
    this.hasFocus = false;
    this.displayLabel = "";
    this.selectedOptions = [];
    this.name = "";
    this.value = "";
    this.defaultValue = "";
    this.size = "medium";
    this.placeholder = "";
    this.multiple = false;
    this.maxOptionsVisible = 4;
    this.disabled = false;
    this.clearable = false;
    this.open = false;
    this.filled = false;
    this.inline = false;
    this.hoist = false;
    this.pill = false;
    this.label = "";
    this.placement = "bottom";
    this.sync = "none";
    this.helpText = "";
    this.form = "";
    this.required = false;
    this.divider = false;
    this.getTag = (option) => {
      return html`
      <flow-ui-tag
        part="tag"
        exportparts="
              base:tag__base,
              content:tag__content,
              remove-button:tag__remove-button,
              remove-button__base:tag__remove-button__base
            "
        ?pill=${this.pill}
        size=${this.size}
        removable
        @flow-ui-remove=${(event) => this.handleTagRemove(event, option)}
      >
        ${option.getTextLabel()}
      </flow-ui-tag>
    `;
    };
    this.handleDocumentFocusIn = (event) => {
      const path = event.composedPath();
      if (this && !path.includes(this)) {
        this.hide();
      }
    };
    this.handleDocumentKeyDown = (event) => {
      const target = event.target;
      const isClearButton = target.closest(".select__clear") !== null;
      const isIconButton = target.closest("flow-ui-icon-button") !== null;
      if (isClearButton || isIconButton) {
        return;
      }
      if (event.key === "Escape" && this.open && !this.closeWatcher) {
        event.preventDefault();
        event.stopPropagation();
        this.hide();
        this.displayInput.focus({ preventScroll: true });
      }
      if (event.key === "Enter" || event.key === " " && this.typeToSelectString === "") {
        event.preventDefault();
        event.stopImmediatePropagation();
        if (!this.open) {
          this.show();
          return;
        }
        if (this.currentOption && !this.currentOption.disabled) {
          if (this.multiple) {
            this.toggleOptionSelection(this.currentOption);
          } else {
            this.setSelectedOptions(this.currentOption);
          }
          this.updateComplete.then(() => {
            this.emit("flow-ui-input");
            this.emit("flow-ui-change");
          });
          if (!this.multiple) {
            this.hide();
            this.displayInput.focus({ preventScroll: true });
          }
        }
        return;
      }
      if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
        const allOptions = this.getAllOptions();
        const currentIndex = allOptions.indexOf(this.currentOption);
        let newIndex = Math.max(0, currentIndex);
        event.preventDefault();
        if (!this.open) {
          this.show();
          if (this.currentOption) {
            return;
          }
        }
        if (event.key === "ArrowDown") {
          newIndex = currentIndex + 1;
          if (newIndex > allOptions.length - 1)
            newIndex = 0;
        } else if (event.key === "ArrowUp") {
          newIndex = currentIndex - 1;
          if (newIndex < 0)
            newIndex = allOptions.length - 1;
        } else if (event.key === "Home") {
          newIndex = 0;
        } else if (event.key === "End") {
          newIndex = allOptions.length - 1;
        }
        this.setCurrentOption(allOptions[newIndex]);
      }
      if (event.key.length === 1 || event.key === "Backspace") {
        const allOptions = this.getAllOptions();
        if (event.metaKey || event.ctrlKey || event.altKey) {
          return;
        }
        if (!this.open) {
          if (event.key === "Backspace") {
            return;
          }
          this.show();
        }
        event.stopPropagation();
        event.preventDefault();
        clearTimeout(this.typeToSelectTimeout);
        this.typeToSelectTimeout = window.setTimeout(() => this.typeToSelectString = "", 1e3);
        if (event.key === "Backspace") {
          this.typeToSelectString = this.typeToSelectString.slice(0, -1);
        } else {
          this.typeToSelectString += event.key.toLowerCase();
        }
        for (const option of allOptions) {
          const label = option.getTextLabel().toLowerCase();
          if (label.startsWith(this.typeToSelectString)) {
            this.setCurrentOption(option);
            break;
          }
        }
      }
    };
    this.handleDocumentMouseDown = (event) => {
      const path = event.composedPath();
      if (this && !path.includes(this)) {
        this.hide();
      }
    };
  }
  /** Gets the validity state object */
  get validity() {
    return this.valueInput.validity;
  }
  /** Gets the validation message */
  get validationMessage() {
    return this.valueInput.validationMessage;
  }
  connectedCallback() {
    super.connectedCallback();
    this.disabled = boolean(this.disabled, true);
    this.multiple = boolean(this.multiple, true);
    this.clearable = boolean(this.clearable, true);
    this.hoist = boolean(this.hoist, true);
    this.pill = boolean(this.pill, true);
    this.required = boolean(this.required, true);
    this.inline = boolean(this.inline, true);
    this.filled = boolean(this.filled, true);
    this.divider = boolean(this.divider, true);
    this.open = false;
  }
  disconnectedCallback() {
    super.disconnectedCallback();
    this.mutationObserver?.disconnect();
  }
  addOpenListeners() {
    document.addEventListener("focusin", this.handleDocumentFocusIn);
    document.addEventListener("keydown", this.handleDocumentKeyDown);
    document.addEventListener("mousedown", this.handleDocumentMouseDown);
    if (this.getRootNode() !== document) {
      this.getRootNode().addEventListener("focusin", this.handleDocumentFocusIn);
    }
    if ("CloseWatcher" in window) {
      this.closeWatcher?.destroy();
      this.closeWatcher = new CloseWatcher();
      this.closeWatcher.onclose = () => {
        if (this.open) {
          this.hide();
          this.displayInput.focus({ preventScroll: true });
        }
      };
    }
  }
  removeOpenListeners() {
    document.removeEventListener("focusin", this.handleDocumentFocusIn);
    document.removeEventListener("keydown", this.handleDocumentKeyDown);
    document.removeEventListener("mousedown", this.handleDocumentMouseDown);
    if (this.getRootNode() !== document) {
      this.getRootNode().removeEventListener("focusin", this.handleDocumentFocusIn);
    }
    this.closeWatcher?.destroy();
  }
  handleFocus() {
    this.hasFocus = true;
    this.displayInput.setSelectionRange(0, 0);
    this.emit("flow-ui-focus");
  }
  handleBlur() {
    this.hasFocus = false;
    this.emit("flow-ui-blur");
  }
  handleLabelClick() {
    this.displayInput.focus();
  }
  handleComboboxMouseDown(event) {
    const path = event.composedPath();
    const isIconButton = path.some((el) => el instanceof Element && el.tagName.toLowerCase() === "flow-ui-icon-button");
    this.mouseDownAt = Date.now();
    if (this.disabled || isIconButton) {
      return;
    }
    event.preventDefault();
    this.displayInput.focus({ preventScroll: true });
    this.open = !this.open;
  }
  handleComboboxKeyDown(event) {
    if (event.key === "Tab") {
      return;
    }
    event.stopPropagation();
    this.handleDocumentKeyDown(event);
  }
  handleClearClick(event) {
    event.stopPropagation();
    if (this.value !== "") {
      this.setSelectedOptions([]);
      this.displayInput.focus({ preventScroll: true });
      this.updateComplete.then(() => {
        this.emit("flow-ui-clear");
        this.emit("flow-ui-input");
        this.emit("flow-ui-change");
      });
    }
  }
  handleClearMouseDown(event) {
    event.stopPropagation();
    event.preventDefault();
  }
  handleOptionClick(event) {
    if (Date.now() - this.mouseDownAt < 200) {
      return;
    }
    const target = event.target;
    const option = target.closest("flow-ui-option");
    const oldValue = this.value;
    if (option && !option.disabled) {
      if (this.multiple) {
        this.toggleOptionSelection(option);
      } else {
        this.setSelectedOptions(option);
      }
      this.updateComplete.then(() => this.displayInput.focus({ preventScroll: true }));
      if (this.value !== oldValue) {
        this.updateComplete.then(() => {
          this.emit("flow-ui-input");
          this.emit("flow-ui-change");
        });
      }
      if (!this.multiple) {
        this.hide();
        this.displayInput.focus({ preventScroll: true });
      }
    }
  }
  handleDefaultSlotChange() {
    const allOptions = this.getAllOptions();
    const value = Array.isArray(this.value) ? this.value : [this.value];
    const values = [];
    this.syncOptions();
    if (customElements.get("flow-ui-option")) {
      allOptions.forEach((option) => values.push(option.value));
      this.setSelectedOptions(allOptions.filter((el) => value.includes(el.value)));
    } else {
      customElements.whenDefined("flow-ui-option").then(() => this.handleDefaultSlotChange());
    }
  }
  handleTagRemove(event, option) {
    event.stopPropagation();
    if (!this.disabled) {
      this.toggleOptionSelection(option, false);
      this.updateComplete.then(() => {
        this.emit("flow-ui-input");
        this.emit("flow-ui-change");
      });
    }
  }
  // Gets an array of all <flow-ui-option> elements
  getAllOptions() {
    return [...this.querySelectorAll("flow-ui-option")];
  }
  // Gets the first <flow-ui-option> element
  getFirstOption() {
    return this.querySelector("flow-ui-option");
  }
  // Sets the current option, which is the option the user is currently interacting with (e.g. via keyboard). Only one
  // option may be "current" at a time.
  setCurrentOption(option) {
    const allOptions = this.getAllOptions();
    allOptions.forEach((el) => {
      el.current = false;
      el.tabIndex = -1;
    });
    if (option) {
      this.currentOption = option;
      option.current = true;
      option.tabIndex = 0;
      option.focus();
    }
  }
  // Sets the selected option(s)
  setSelectedOptions(option) {
    const allOptions = this.getAllOptions();
    const newSelectedOptions = Array.isArray(option) ? option : [option];
    allOptions.forEach((el) => el.selected = false);
    if (newSelectedOptions.length) {
      newSelectedOptions.forEach((el) => el.selected = true);
    }
    this.selectionChanged();
  }
  // Toggles an option's selected state
  toggleOptionSelection(option, force) {
    if (force === true || force === false) {
      option.selected = force;
    } else {
      option.selected = !option.selected;
    }
    this.selectionChanged();
  }
  // This method must be called whenever the selection changes. It will update the selected options cache, the current
  // value, and the display value
  selectionChanged() {
    this.selectedOptions = this.getAllOptions().filter((el) => el.selected);
    if (this.multiple) {
      this.value = this.selectedOptions.map((el) => el.value);
      if (this.placeholder && this.value.length === 0) {
        this.displayLabel = "";
      } else {
        this.displayLabel = this.localize.term("numOptionsSelected", this.selectedOptions.length);
      }
    } else {
      this.value = this.selectedOptions[0]?.value ?? "";
      this.displayLabel = this.selectedOptions[0]?.getTextLabel() ?? "";
    }
    this.updateComplete.then(() => {
      this.formControlController.updateValidity();
    });
  }
  get tags() {
    return this.selectedOptions.map((option, index) => {
      if (index < this.maxOptionsVisible || this.maxOptionsVisible <= 0) {
        const tag = this.getTag(option, index);
        return html`
          <div @flow-ui-remove=${(e) => this.handleTagRemove(e, option)}>
            ${typeof tag === "string" ? unsafeHTML(tag) : tag}
          </div>
        `;
      } else if (index === this.maxOptionsVisible) {
        return html`
          <flow-ui-tag size=${this.size}>+${this.selectedOptions.length - index}</flow-ui-tag>
        `;
      }
      return html``;
    });
  }
  handleInvalid(event) {
    this.formControlController.setValidity(false);
    this.formControlController.emitInvalidEvent(event);
  }
  handleDisabledChange() {
    if (this.disabled) {
      this.open = false;
      this.handleOpenChange();
    }
  }
  handleValueChange() {
    const allOptions = this.getAllOptions();
    const value = Array.isArray(this.value) ? this.value : [this.value];
    this.setSelectedOptions(allOptions.filter((el) => value.includes(el.value)));
  }
  handleSizeChange() {
    this.syncOptions();
  }
  async handleOpenChange() {
    if (this.open && !this.disabled) {
      this.setCurrentOption(this.selectedOptions[0] || this.getFirstOption());
      this.emit("flow-ui-show");
      this.addOpenListeners();
      await stopAnimations(this);
      this.listbox.hidden = false;
      this.popup.active = true;
      requestAnimationFrame(() => {
        this.setCurrentOption(this.currentOption);
      });
      const { keyframes, options } = getAnimation(this, "select.show", { dir: this.localize.dir() });
      await animateTo(this.popup.popup, keyframes, options);
      if (this.currentOption) {
        scrollIntoView(this.currentOption, this.listbox, "vertical", "auto");
      }
      this.emit("flow-ui-after-show");
    } else {
      this.emit("flow-ui-hide");
      this.removeOpenListeners();
      await stopAnimations(this);
      const { keyframes, options } = getAnimation(this, "select.hide", { dir: this.localize.dir() });
      await animateTo(this.popup.popup, keyframes, options);
      this.listbox.hidden = true;
      this.popup.active = false;
      this.emit("flow-ui-after-hide");
    }
  }
  // Sync style options from parent select to child options
  syncOptions() {
    if (customElements.get("flow-ui-option")) {
      const options = this.getAllOptions();
      options.forEach((option) => {
        option.size = this.size;
      });
    } else {
      customElements.whenDefined("flow-ui-option").then(() => this.syncOptions());
    }
  }
  /** Shows the listbox. */
  async show() {
    if (this.open || this.disabled) {
      this.open = false;
      return void 0;
    }
    this.open = true;
    return waitForEvent(this, "flow-ui-after-show");
  }
  /** Hides the listbox. */
  async hide() {
    if (!this.open || this.disabled) {
      this.open = false;
      return void 0;
    }
    this.open = false;
    return waitForEvent(this, "flow-ui-after-hide");
  }
  /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
  checkValidity() {
    return this.valueInput.checkValidity();
  }
  /** Gets the associated form, if one exists. */
  getForm() {
    return this.formControlController.getForm();
  }
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
  reportValidity() {
    return this.valueInput.reportValidity();
  }
  /** Sets a custom validation message. Pass an empty string to restore validity. */
  setCustomValidity(message) {
    this.valueInput.setCustomValidity(message);
    this.formControlController.updateValidity();
  }
  /** Sets focus on the control. */
  focus(options) {
    this.displayInput.focus(options);
  }
  /** Removes focus from the control. */
  blur() {
    this.displayInput.blur();
  }
  render() {
    const hasLabelSlot = this.hasSlotController.test("label");
    const hasHelpTextSlot = this.hasSlotController.test("help-text");
    const hasLabel = this.label ? true : !!hasLabelSlot;
    const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
    const hasClearIcon = this.clearable && !this.disabled && this.value.length > 0;
    const isPlaceholderVisible = this.placeholder && this.value.length === 0;
    const horizontalPlacement = this.inline ? "end" : "start";
    const placement = `${this.placement}-${horizontalPlacement}`;
    const strategy = this.inline || this.hoist ? "fixed" : "absolute";
    const sync = this.sync === "width" ? "width" : void 0;
    const distance = this.inline ? -getCssPropertyInPixels(this, "--control-height") : 0;
    return html`
      <div
        part="form-control"
        class=${classMap({
      "form-control": true,
      "form-control--small": this.size === "small",
      "form-control--medium": this.size === "medium",
      "form-control--large": this.size === "large",
      "form-control--disabled": this.disabled,
      "form-control--focused": this.hasFocus,
      "form-control--inline": this.inline,
      "form-control--filled": this.filled,
      "form-control--open": this.open,
      "form-control--has-label": hasLabel,
      "form-control--has-help-text": hasHelpText,
      "form-control--has-divider": this.divider
    })}
      >
        <label
          id="label"
          part="label"
          class="form-control__label"
          aria-hidden=${hasLabel ? "false" : "true"}
          @click=${this.handleLabelClick}
        >
          <slot name="label">${this.label}</slot>
        </label>

        <div
          part="help-text"
          id="help-text"
          class="form-control__help-text"
          aria-hidden=${hasHelpText ? "false" : "true"}
        >
          <slot name="help-text">${this.helpText}</slot>
        </div>

        <div part="control" class="form-control__input">
          <flow-ui-popup
            class=${classMap({
      select: true,
      "select--standard": true,
      "select--pill": this.pill,
      "select--open": this.open,
      "select--disabled": this.disabled,
      "select--inline": this.inline,
      "select--multiple": this.multiple,
      "select--focused": this.hasFocus,
      "select--placeholder-visible": isPlaceholderVisible,
      "select--top": this.placement === "top",
      "select--bottom": this.placement === "bottom",
      "select--small": this.size === "small",
      "select--medium": this.size === "medium",
      "select--large": this.size === "large"
    })}
            .distance=${distance}
            placement=${ifDefined(placement)}
            strategy=${ifDefined(strategy)}
            flip
            shift
            sync=${ifDefined(sync)}
            auto-size="vertical"
            auto-size-padding="10"
          >
            <div
              part="combobox"
              class="select__combobox"
              slot="anchor"
              @keydown=${this.handleComboboxKeyDown}
              @mousedown=${this.handleComboboxMouseDown}
            >
              <slot part="prefix" name="prefix" class="select__prefix"></slot>

              <div class="select__display-input-wrapper">
                <input
                  part="display-input"
                  class="select__display-input"
                  type="text"
                  placeholder=${this.placeholder}
                  .disabled=${this.disabled}
                  .value=${this.displayLabel}
                  autocomplete="off"
                  spellcheck="false"
                  autocapitalize="off"
                  readonly
                  aria-controls="listbox"
                  aria-expanded=${this.open ? "true" : "false"}
                  aria-haspopup="listbox"
                  aria-labelledby="label"
                  aria-disabled=${this.disabled ? "true" : "false"}
                  aria-describedby="help-text"
                  role="combobox"
                  tabindex="0"
                  @focus=${this.handleFocus}
                  @blur=${this.handleBlur}
                />
                <span class="select__display-input-sizer">${this.displayLabel || this.placeholder}</span>
              </div>

              ${this.multiple ? html`
                    <div part="tags" class="select__tags">${this.tags}</div>
                  ` : ""}

              <input
                class="select__value-input"
                type="text"
                ?disabled=${this.disabled}
                ?required=${this.required}
                .value=${Array.isArray(this.value) ? this.value.join(", ") : this.value}
                tabindex="-1"
                aria-hidden="true"
                @focus=${() => this.focus()}
                @invalid=${this.handleInvalid}
              />

              ${hasClearIcon ? html`
                    <button
                      part="clear-button"
                      class="select__clear"
                      type="button"
                      aria-label=${this.localize.term("clearEntry")}
                      @mousedown=${this.handleClearMouseDown}
                      @click=${this.handleClearClick}
                      tabindex="-1"
                    >
                      <slot name="clear-icon">
                        <flow-ui-icon name="x-circle-fill" library="system"></flow-ui-icon>
                      </slot>
                    </button>
                  ` : ""}

              <slot name="suffix" part="suffix" class="select__suffix"></slot>

              <slot name="expand-icon" part="expand-icon" class="select__expand-icon">
                <flow-ui-icon library="system" name="chevron-down"></flow-ui-icon>
              </slot>
            </div>

            <div
              id="listbox"
              role="listbox"
              aria-expanded=${this.open ? "true" : "false"}
              aria-multiselectable=${this.multiple ? "true" : "false"}
              aria-labelledby="label"
              part="listbox"
              class="select__listbox"
              tabindex="-1"
              @mouseup=${this.handleOptionClick}
              @slotchange=${this.handleDefaultSlotChange}
            >
              <slot></slot>
            </div>
          </flow-ui-popup>
        </div>

        ${this.divider ? this.renderDivider() : nothing}
      </div>
    `;
  }
}
FlowUiSelect.styles = styles;
FlowUiSelect.dependencies = {
  "flow-icon": FlowUiIcon,
  "flow-popup": FlowUiPopup,
  "flow-tag": FlowUiTag
};
__decorateClass([
  query(".select")
], FlowUiSelect.prototype, "popup", 2);
__decorateClass([
  query(".select__display-input")
], FlowUiSelect.prototype, "displayInput", 2);
__decorateClass([
  query(".select__value-input")
], FlowUiSelect.prototype, "valueInput", 2);
__decorateClass([
  query(".select__listbox")
], FlowUiSelect.prototype, "listbox", 2);
__decorateClass([
  state()
], FlowUiSelect.prototype, "hasFocus", 2);
__decorateClass([
  state()
], FlowUiSelect.prototype, "displayLabel", 2);
__decorateClass([
  state()
], FlowUiSelect.prototype, "currentOption", 2);
__decorateClass([
  state()
], FlowUiSelect.prototype, "selectedOptions", 2);
__decorateClass([
  property()
], FlowUiSelect.prototype, "name", 2);
__decorateClass([
  property({
    converter: {
      fromAttribute: (value) => value.split(" "),
      toAttribute: (value) => value.join(" ")
    }
  })
], FlowUiSelect.prototype, "value", 2);
__decorateClass([
  defaultValue()
], FlowUiSelect.prototype, "defaultValue", 2);
__decorateClass([
  property({ reflect: true })
], FlowUiSelect.prototype, "size", 2);
__decorateClass([
  property()
], FlowUiSelect.prototype, "placeholder", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "multiple", 2);
__decorateClass([
  property({ attribute: "max-options-visible", type: Number })
], FlowUiSelect.prototype, "maxOptionsVisible", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "disabled", 2);
__decorateClass([
  property({ type: Boolean })
], FlowUiSelect.prototype, "clearable", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "open", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "filled", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "inline", 2);
__decorateClass([
  property({ type: Boolean })
], FlowUiSelect.prototype, "hoist", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "pill", 2);
__decorateClass([
  property()
], FlowUiSelect.prototype, "label", 2);
__decorateClass([
  property({ reflect: true })
], FlowUiSelect.prototype, "placement", 2);
__decorateClass([
  property()
], FlowUiSelect.prototype, "sync", 2);
__decorateClass([
  property({ attribute: "help-text" })
], FlowUiSelect.prototype, "helpText", 2);
__decorateClass([
  property({ reflect: true })
], FlowUiSelect.prototype, "form", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "required", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], FlowUiSelect.prototype, "divider", 2);
__decorateClass([
  property()
], FlowUiSelect.prototype, "getTag", 2);
__decorateClass([
  watch("disabled", { waitUntilFirstUpdate: true })
], FlowUiSelect.prototype, "handleDisabledChange", 1);
__decorateClass([
  watch("value", { waitUntilFirstUpdate: true })
], FlowUiSelect.prototype, "handleValueChange", 1);
__decorateClass([
  watch("size", { waitUntilFirstUpdate: true })
], FlowUiSelect.prototype, "handleSizeChange", 1);
__decorateClass([
  watch("open", { waitUntilFirstUpdate: true })
], FlowUiSelect.prototype, "handleOpenChange", 1);
setDefaultAnimation("select.show", {
  keyframes: [
    { opacity: 0, scale: 0.9 },
    { opacity: 1, scale: 1 }
  ],
  options: { duration: 100, easing: "ease" }
});
setDefaultAnimation("select.hide", {
  keyframes: [
    { opacity: 1, scale: 1 },
    { opacity: 0, scale: 0.9 }
  ],
  options: { duration: 100, easing: "ease" }
});

export { FlowUiSelect as default };
