{"version":3,"file":"Combobox.mjs","names":[],"sources":["../../../src/combobox/Combobox.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n  FloatingFocusManager,\n  FloatingPortal,\n  useMergeRefs,\n} from '@floating-ui/react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport classNames from 'classnames';\nimport { Fragment, useEffect, useId, useMemo, useRef, useState } from 'react';\n\nimport {\n  FormFieldLabel,\n  FormFieldMessage,\n  type FormFieldState,\n  useFormField,\n} from '../_common/form-control';\nimport { type CommonProps } from '../_common/types';\nimport { useSemicontrolledState } from '../_common/use-semi-controlled-state';\nimport { needleWarningMessage } from '../_common/utils';\nimport { Checkbox } from '../checkbox';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { DismissibleTag } from '../dismissible-tag';\nimport { Divider } from '../divider';\nimport {\n  CheckIconOutline,\n  ChevronDownIconOutline,\n  MagnifyingGlassIconOutline,\n  PlusIconOutline,\n  XMarkIconOutline,\n} from '../icons/generated/heroIcons';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { ReadOnlyTag } from '../read-only-tag';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport {\n  type ComboboxControlProps,\n  type ComboboxEmptyStateProps,\n  type ComboboxFieldState,\n  type ComboboxGroupProps,\n  type ComboboxInputProps,\n  type ComboboxListBoxProps,\n  type ComboboxOption,\n  type ComboboxOptionContentProps,\n  type ComboboxOptionGroup,\n  type ComboboxOptionProps,\n  type ComboboxPanelProps,\n  type ComboboxProps,\n  type ComboboxTriggerProps,\n  type ComboboxTriggerState,\n} from './combobox-types';\nimport {\n  asActionRow,\n  asCreateOption,\n  buildCreateOption,\n  type ComboboxActionRow,\n  type ComboboxRow,\n  type ComboboxValue,\n  filterComboboxOptions,\n  flattenComboboxOptions,\n  formatCreateOptionLabel,\n  getAction,\n  getFirstOptionIndex,\n  getInitialValue,\n  getLastOptionIndex,\n  getNextOptionIndex,\n  isActionRow,\n  isCreateOption,\n  isOptionGroup,\n  isValidNewComboboxOption,\n} from './combobox-utils';\nimport {\n  formatOverflowCount,\n  getOverflowCounterMeasureTexts,\n  useComboboxMultiValueOverflow,\n} from './use-combobox-multi-value-overflow';\nimport { useComboboxPopover } from './use-combobox-popover';\n\nconst DEFAULT_SEARCH_PLACEHOLDER = 'Search';\nconst DEFAULT_PLACEHOLDER = 'Select...';\nconst DEFAULT_LOADING_MESSAGE = 'Loading...';\nconst NO_ACTIVE_INDEX = -1;\nconst OPENING_KEYS = ['ArrowDown', 'ArrowUp', 'Enter', ' '];\n// Above this many rendered rows - options and group headers - the listbox\n// switches to windowed rendering. Below it, the DOM, including the nested\n// group semantics, is exactly what it always was.\nconst VIRTUALIZATION_ROW_THRESHOLD = 100;\n// Starting guess only: every virtual row is measured once rendered.\nconst VIRTUAL_ROW_ESTIMATED_HEIGHT = 38;\n// With a row limit, at most this many candidate tags per permitted row are\n// rendered and measured; anything past them is overflowed arithmetically. Far\n// more than fit a row even with the narrowest plausible tags.\nconst TAG_CANDIDATES_PER_ROW = 50;\n// The counter's title and screen reader text name at most this many overflowed\n// options before summarizing the rest as a count.\nconst OVERFLOW_LABEL_LIMIT = 20;\n// The hidden form select mirrors the options so browser autofill can match\n// against them, but past this many the DOM cost outweighs an autofill list\n// nobody scrolls. Above it, only what submission, validation, and reset need\n// is mirrored: the selection and the default value. Matches the limit React\n// Aria's HiddenSelect uses for the same trade-off.\nconst FORM_OPTION_MIRROR_LIMIT = 300;\n\n/**\n * One row of the windowed listbox. Group headers become rows of their own,\n * since windowing cannot keep the nested group wrappers. Action rows are never\n * windowed: they are pinned below the listbox and always rendered.\n */\ntype ComboboxDisplayRow<TOption extends ComboboxOption> =\n  | { kind: 'group-header'; label: string }\n  | { kind: 'option'; row: TOption };\n\n/**\n * Flattens the grouped option items into display rows for the virtualizer,\n * along with a lookup from an option's flat index - the one behind option ids\n * and the active index - to its display row index. Pinned action rows sit at\n * the end of the flat indices but get no display row, so the lookup simply\n * misses for them.\n */\nconst buildComboboxDisplayRows = <TOption extends ComboboxOption>(\n  optionItems: (TOption | ComboboxOptionGroup<TOption>)[],\n) => {\n  const displayRows: ComboboxDisplayRow<TOption>[] = [];\n  const flatToDisplayIndex: number[] = [];\n  const pushOption = (row: TOption) => {\n    flatToDisplayIndex.push(displayRows.length);\n    displayRows.push({ kind: 'option', row });\n  };\n\n  optionItems.forEach((item) => {\n    if (isOptionGroup(item)) {\n      displayRows.push({ kind: 'group-header', label: item.label });\n      item.options.forEach(pushOption);\n      return;\n    }\n\n    pushOption(item);\n  });\n\n  return { displayRows, flatToDisplayIndex };\n};\n\nexport const Combobox = <TOption extends ComboboxOption = ComboboxOption>({\n  label,\n  name,\n  formId,\n  autoComplete,\n  triggerRef,\n  hasVisuallyHiddenLabel = false,\n  helpText,\n  errorText,\n  isRequired = false,\n  hasRequiredIndicator = false,\n  options,\n  value,\n  defaultValue,\n  onChange,\n  isMulti = false,\n  isSearchable = true,\n  searchValue,\n  defaultSearchValue,\n  onSearchChange,\n  filterOption,\n  searchPlaceholder = DEFAULT_SEARCH_PLACEHOLDER,\n  isLoading = false,\n  loadingMessage = DEFAULT_LOADING_MESSAGE,\n  isCreatable = false,\n  onCreateOption,\n  createOption = buildCreateOption,\n  formatCreateLabel = formatCreateOptionLabel,\n  isValidNewOption = isValidNewComboboxOption,\n  actions,\n  maxRows = 1,\n  isOpen,\n  onOpenChange,\n  isClearable = false,\n  placeholder = DEFAULT_PLACEHOLDER,\n  isDisabled = false,\n  size = 'medium',\n  isFluid = false,\n  isClean = false,\n  isPortaled,\n  portalTarget,\n  floatingStrategy,\n  renderTrigger,\n  components = {},\n  className,\n  style,\n  htmlAttributes,\n  ref,\n}: CommonProps<'div', ComboboxProps<TOption>>) => {\n  const baseId = useId();\n  const listboxId = `${baseId}-listbox`;\n  const panelId = `${baseId}-panel`;\n  const triggerId = `${baseId}-trigger`;\n  const initialValue = getInitialValue(value, defaultValue, isMulti);\n  const [selectedValue, setSelectedValue, resetSelectedValue] =\n    useSemicontrolledState<ComboboxValue<TOption>>({\n      isControlled: value !== undefined,\n      onChange: (nextValue) => {\n        if (isMulti) {\n          (onChange as ((value: TOption[]) => void) | undefined)?.(\n            Array.isArray(nextValue) ? nextValue : [],\n          );\n        } else if (!Array.isArray(nextValue)) {\n          (onChange as ((value: TOption | null) => void) | undefined)?.(\n            nextValue,\n          );\n        }\n      },\n      state: initialValue,\n    });\n\n  const [currentSearchValue, setCurrentSearchValue, resetSearchValue] =\n    useSemicontrolledState<string>({\n      isControlled: searchValue !== undefined,\n      onChange: onSearchChange,\n      state: searchValue ?? defaultSearchValue ?? '',\n    });\n\n  const [isPanelOpen, setIsPanelOpen, resetPanelOpen] =\n    useSemicontrolledState<boolean>({\n      isControlled: isOpen !== undefined,\n      onChange: onOpenChange,\n      state: isOpen ?? false,\n    });\n\n  const { themeClassName } = useNeedleTheme();\n  const internalTriggerRef = useRef<HTMLElement | null>(null);\n  const searchInputRef = useRef<HTMLInputElement | null>(null);\n  const {\n    context,\n    floatingStyles,\n    getFloatingProps,\n    getReferenceProps,\n    isPortaled: isPanelPortaled,\n    refs,\n  } = useComboboxPopover({\n    floatingStrategy,\n    isDisabled,\n    isOpen: isPanelOpen,\n    isPortaled,\n    onOpenChange: setIsPanelOpen,\n  });\n  const builtInTriggerRef = useMergeRefs([internalTriggerRef, triggerRef]);\n  const customTriggerRef = useMergeRefs([\n    refs.setReference,\n    internalTriggerRef,\n    triggerRef,\n  ]);\n\n  // Creating builds an option out of the search value, so there is nothing to\n  // create from without a search input.\n  const canCreate = isCreatable && isSearchable;\n\n  useEffect(() => {\n    if (isCreatable && !isSearchable) {\n      needleWarningMessage(\n        'A creatable Combobox also needs isSearchable, since a new option is built from the search value.',\n      );\n    }\n  }, [isCreatable, isSearchable]);\n\n  const selectedOptions = getSelectedOptions(selectedValue);\n  const resetValue = getInitialValue(undefined, defaultValue, isMulti);\n  const resetSelectedOptions = getSelectedOptions(resetValue);\n  const selectedValuesKey = selectedOptions\n    .map((option) => option.value)\n    .join('\\u0000');\n  // Selection checks run once per rendered option, so with large lists they\n  // must not scan the selection array each time.\n  const selectedValuesSet = useMemo(\n    () => new Set(getSelectedOptions(selectedValue).map(({ value }) => value)),\n    [selectedValue],\n  );\n  const allOptions = useMemo(() => flattenComboboxOptions(options), [options]);\n  const [nativeValidationMessage, setNativeValidationMessage] = useState<\n    string | undefined\n  >(undefined);\n  const formOptions = useMemo(() => {\n    const seenValues = new Set<string>();\n    // The default value options are mirrored even above the limit, since the\n    // native select can only reset to options it renders.\n    const mirroredOptions =\n      allOptions.length > FORM_OPTION_MIRROR_LIMIT\n        ? [\n            ...getSelectedOptions(selectedValue),\n            ...getSelectedOptions(\n              getInitialValue(undefined, defaultValue, isMulti),\n            ),\n          ]\n        : [...allOptions, ...getSelectedOptions(selectedValue)];\n\n    return mirroredOptions.filter((option) => {\n      if (seenValues.has(option.value)) {\n        return false;\n      }\n\n      seenValues.add(option.value);\n      return true;\n    });\n  }, [allOptions, selectedValue, defaultValue, isMulti]);\n\n  useEffect(() => {\n    setNativeValidationMessage(undefined);\n  }, [selectedValuesKey]);\n\n  const resetFromForm = () => {\n    resetSelectedValue(resetValue);\n    resetSearchValue(defaultSearchValue ?? '');\n    resetPanelOpen(false);\n    setNativeValidationMessage(undefined);\n  };\n  const filteredOptions = useMemo(\n    () =>\n      isSearchable\n        ? filterComboboxOptions(options, currentSearchValue, filterOption)\n        : options,\n    [isSearchable, options, currentSearchValue, filterOption],\n  );\n  // Created options are never added to `options`, so the selection is offered\n  // for deduplication as well.\n  const createRow =\n    canCreate &&\n    isValidNewOption(currentSearchValue, [...allOptions, ...selectedOptions])\n      ? asCreateOption(createOption(currentSearchValue))\n      : undefined;\n  // The create row is appended after any groups rather than inside one, since it\n  // belongs to the list as a whole.\n  const optionItems: (TOption | ComboboxOptionGroup<TOption>)[] =\n    createRow === undefined ? filteredOptions : [...filteredOptions, createRow];\n  // Actions are not data, so they survive filtering and close the list off at\n  // the end, after anything that selects.\n  const actionRows = (actions ?? []).map(asActionRow);\n  const flatOptions: ComboboxRow<TOption>[] = [\n    ...flattenComboboxOptions(optionItems),\n    ...actionRows,\n  ];\n  const optionsKey = flatOptions.map((option) => option.value).join('\\u0000');\n  // Ids and hover both need a row's index; one O(n) map build per render\n  // replaces an O(n) scan per rendered row.\n  const rowIndexes = new Map<ComboboxRow<TOption>, number>(\n    flatOptions.map((row, index) => [row, index]),\n  );\n  const getOptionId = (row: ComboboxRow<TOption>) =>\n    `${baseId}-option-${rowIndexes.get(row) ?? NO_ACTIVE_INDEX}`;\n  const groupHeaderCount = optionItems.reduce(\n    (count, item) => (isOptionGroup(item) ? count + 1 : count),\n    0,\n  );\n  // Only the options listbox is windowed; the pinned action rows below it\n  // are always rendered, so they do not count towards the threshold.\n  const displayRowCount =\n    flatOptions.length - actionRows.length + groupHeaderCount;\n  const isListVirtualized = displayRowCount > VIRTUALIZATION_ROW_THRESHOLD;\n  const virtualRows = isListVirtualized\n    ? buildComboboxDisplayRows(optionItems)\n    : undefined;\n  // Registered by the virtualized listbox while it is mounted, since scrolling\n  // a windowed list works by index rather than by element.\n  const scrollToActiveRowRef = useRef<((flatIndex: number) => void) | null>(\n    null,\n  );\n\n  // No option is active until the user navigates or hovers, so nothing is\n  // highlighted and Enter is inert before then.\n  const [activeIndex, setActiveIndex] = useState(NO_ACTIVE_INDEX);\n  const [renderedOptionsKey, setRenderedOptionsKey] = useState(optionsKey);\n  const wasActivatedByPointerRef = useRef(false);\n\n  // Indices change meaning when the list is filtered, so a stale one would\n  // point at the wrong option.\n  if (renderedOptionsKey !== optionsKey) {\n    setRenderedOptionsKey(optionsKey);\n    setActiveIndex(NO_ACTIVE_INDEX);\n  }\n\n  const activeOption = flatOptions[activeIndex];\n  const activeOptionId =\n    activeOption === undefined ? undefined : getOptionId(activeOption);\n\n  // The listbox scrolls, so keep the virtually focused option visible.\n  // Pointer activation is skipped, otherwise hovering a partially visible\n  // option would nudge the list out from under the cursor. Pinned action rows\n  // sit outside the scrolling listbox and are always visible, so scrolling\n  // for them is a harmless no-op in both paths.\n  useEffect(() => {\n    if (wasActivatedByPointerRef.current) {\n      wasActivatedByPointerRef.current = false;\n      return;\n    }\n\n    if (activeOptionId === undefined) {\n      return;\n    }\n\n    // A windowed listbox scrolls by index, since the active option's element\n    // may not be mounted yet. Scrolling is also what mounts it, keeping\n    // aria-activedescendant resolvable.\n    if (scrollToActiveRowRef.current !== null) {\n      scrollToActiveRowRef.current(activeIndex);\n      return;\n    }\n\n    document\n      .getElementById(activeOptionId)\n      ?.scrollIntoView({ block: 'nearest' });\n  }, [activeOptionId, activeIndex]);\n\n  // Reopening the panel starts with nothing highlighted, the same as the first\n  // open, so a stale active option can never be one Enter away from selection.\n  useEffect(() => {\n    if (!isPanelOpen) {\n      setActiveIndex(NO_ACTIVE_INDEX);\n    }\n  }, [isPanelOpen]);\n\n  const isOptionSelected = (option: TOption) =>\n    selectedValuesSet.has(option.value);\n\n  const selectOption = (option: TOption) => {\n    if (isMulti) {\n      const currentValue = Array.isArray(selectedValue) ? selectedValue : [];\n      const isSelected = selectedValuesSet.has(option.value);\n      const nextValue = isSelected\n        ? currentValue.filter((selected) => selected.value !== option.value)\n        : [...currentValue, option];\n\n      setSelectedValue(nextValue);\n      // Multi select keeps the panel open so several options can be picked in\n      // one pass, matching Select.\n      return;\n    }\n\n    if (Array.isArray(selectedValue) || selectedValue?.value !== option.value) {\n      setSelectedValue(option);\n    }\n\n    setIsPanelOpen(false);\n  };\n\n  const createFromSearch = () => {\n    const created = createOption(currentSearchValue);\n\n    selectOption(created);\n    onCreateOption?.(created);\n    // Multi select stays open, so the query is reset to leave the full list\n    // usable for the next pick.\n    setCurrentSearchValue('');\n  };\n\n  const handleOptionChange = (row: ComboboxRow<TOption>) => {\n    if (isDisabled || row.isDisabled) {\n      return;\n    }\n\n    // An action leaves the selection alone, so it only runs and closes.\n    if (isActionRow(row)) {\n      getAction(row).onSelect({ searchValue: currentSearchValue });\n      setIsPanelOpen(false);\n      return;\n    }\n\n    if (isCreateOption(row)) {\n      createFromSearch();\n      return;\n    }\n\n    selectOption(row);\n  };\n\n  const clearSelection = () => {\n    if (isDisabled) {\n      return;\n    }\n\n    setSelectedValue(isMulti ? [] : null);\n  };\n\n  const removeOption = (option: TOption) => {\n    if (isDisabled) {\n      return;\n    }\n\n    if (!isMulti) {\n      clearSelection();\n      return;\n    }\n\n    setSelectedValue(\n      selectedOptions.filter((selected) => selected.value !== option.value),\n    );\n  };\n\n  // Hover and the keyboard share one active option, so exactly one option is\n  // ever highlighted. Unlike the keyboard, hover skips disabled options: a\n  // pointer user sees the disabled state directly, so there is no\n  // discoverability to preserve.\n  const handleOptionHover = (row: ComboboxRow<TOption>) => {\n    if (row.isDisabled === true) {\n      return;\n    }\n\n    const index = rowIndexes.get(row) ?? NO_ACTIVE_INDEX;\n\n    if (index === activeIndex) {\n      return;\n    }\n\n    wasActivatedByPointerRef.current = true;\n    setActiveIndex(index);\n  };\n\n  // Disabled options are included so they stay discoverable to screen reader\n  // users, per the APG guidance on disabled controls in composite widgets.\n  // Activating one is a no-op.\n  const moveActiveIndex = (direction: 1 | -1) => {\n    if (activeIndex === NO_ACTIVE_INDEX) {\n      setActiveIndex(\n        direction === 1\n          ? getFirstOptionIndex(flatOptions)\n          : getLastOptionIndex(flatOptions),\n      );\n      return;\n    }\n\n    setActiveIndex(getNextOptionIndex(flatOptions, activeIndex, direction));\n  };\n\n  /**\n   * Shared by the search input and the select-only trigger, since both drive\n   * the same virtual focus. Returns whether the key was consumed.\n   */\n  const handleNavigationKeyDown = (event: React.KeyboardEvent) => {\n    switch (event.key) {\n      case 'ArrowDown':\n        event.preventDefault();\n        moveActiveIndex(1);\n        return true;\n      case 'ArrowUp':\n        event.preventDefault();\n        moveActiveIndex(-1);\n        return true;\n      case 'Home':\n        event.preventDefault();\n        setActiveIndex(getFirstOptionIndex(flatOptions));\n        return true;\n      case 'End':\n        event.preventDefault();\n        setActiveIndex(getLastOptionIndex(flatOptions));\n        return true;\n      case 'Enter':\n        if (activeOption === undefined) {\n          return false;\n        }\n        event.preventDefault();\n        handleOptionChange(activeOption);\n        return true;\n      default:\n        return false;\n    }\n  };\n\n  const handleSearchKeyDown = (\n    event: React.KeyboardEvent<HTMLInputElement>,\n  ) => {\n    // Home and End belong to the text cursor while typing.\n    if (event.key === 'Home' || event.key === 'End') {\n      return;\n    }\n\n    if (handleNavigationKeyDown(event)) {\n      return;\n    }\n\n    if (event.key === 'Escape') {\n      // Escape belongs to this combobox: close immediately and keep it from\n      // dismissing an enclosing dialog, popover, or other composite widget.\n      event.preventDefault();\n      event.stopPropagation();\n      if (currentSearchValue !== '') {\n        setCurrentSearchValue('');\n      }\n      setIsPanelOpen(false);\n    }\n  };\n\n  const handleTriggerKeyDown = (event: React.KeyboardEvent) => {\n    if (isDisabled) {\n      return;\n    }\n\n    if (!isPanelOpen) {\n      if (!OPENING_KEYS.includes(event.key)) {\n        return;\n      }\n\n      // Preventing the default keeps the button from synthesizing a click,\n      // which would let useClick toggle the panel straight back shut.\n      event.preventDefault();\n      setIsPanelOpen(true);\n\n      if (!isSearchable && event.key === 'ArrowDown') {\n        setActiveIndex(getFirstOptionIndex(flatOptions));\n      } else if (!isSearchable && event.key === 'ArrowUp') {\n        setActiveIndex(getLastOptionIndex(flatOptions));\n      }\n\n      return;\n    }\n\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      event.stopPropagation();\n      setIsPanelOpen(false);\n      return;\n    }\n\n    // A searchable panel holds DOM focus in its search input, so the trigger\n    // only ever sees keys while the panel is closed.\n    if (isSearchable) {\n      return;\n    }\n\n    if (event.key === ' ' && activeOption !== undefined) {\n      event.preventDefault();\n      handleOptionChange(activeOption);\n      return;\n    }\n\n    if (handleNavigationKeyDown(event)) {\n      return;\n    }\n\n    if (event.key === 'Enter' || event.key === ' ') {\n      event.preventDefault();\n      setIsPanelOpen(false);\n    }\n  };\n\n  // Actions are rows of the listbox but not results, so they keep the list\n  // rendered without hiding the message that nothing matched.\n  const hasRows = flatOptions.length > 0;\n  const hasOptionRows = flatOptions.length > actionRows.length;\n  // The pinned action rows live outside the scrolling listbox, so the listbox\n  // claims them through aria-owns to keep them its logical children.\n  const actionOwnsIds =\n    actionRows.length > 0\n      ? actionRows.map((row) => getOptionId(row)).join(' ')\n      : undefined;\n  const isDialogPanel = isSearchable;\n  // The shared form field resolves the ids and which message is displayed -\n  // an error always replaces the help text. A native validation failure\n  // reported by the hidden form control acts as the error while no errorText\n  // is set.\n  const { field: formField, controlProps: fieldControlProps } = useFormField({\n    baseId,\n    controlId: triggerId,\n    errorText: errorText ?? nativeValidationMessage,\n    hasRequiredIndicator,\n    hasVisuallyHiddenLabel,\n    helpText,\n    isRequired,\n    label,\n  });\n  const hasError = formField.hasError;\n  const labelId = formField.labelId;\n  const triggerAria = {\n    'aria-activedescendant':\n      isPanelOpen && !isSearchable ? activeOptionId : undefined,\n    'aria-controls': getTriggerControlsId({\n      hasRows,\n      isDialogPanel,\n      isPanelOpen,\n      listboxId,\n      panelId,\n    }),\n    'aria-describedby': fieldControlProps['aria-describedby'],\n    'aria-disabled': isDisabled ? true : undefined,\n    'aria-expanded': isPanelOpen,\n    'aria-haspopup': isDialogPanel ? ('dialog' as const) : ('listbox' as const),\n    'aria-invalid': fieldControlProps['aria-invalid'],\n    'aria-required': isRequired ? true : undefined,\n    // The label points at the trigger through `htmlFor`, so clicking it moves\n    // focus to the trigger.\n    id: triggerId,\n    onKeyDown: handleTriggerKeyDown,\n    role: 'combobox' as const,\n  };\n  // A custom trigger becomes the anchor itself, so it gets the reference props\n  // and the reference ref. The built-in trigger leaves both to its wrapper,\n  // which is what the panel should size to, and takes only the ARIA.\n  //\n  // It is also named by the label text itself rather than by a reference to it,\n  // since a custom trigger is free to leave the label unrendered.\n  const triggerProps: ComboboxTriggerProps = {\n    ...(getReferenceProps() as React.HTMLAttributes<HTMLElement>),\n    ...triggerAria,\n    'aria-label': label,\n    ref: customTriggerRef,\n  };\n  const builtInTriggerProps: ComboboxTriggerProps = {\n    ...triggerAria,\n    // The label row also holds the required indicator, so only the label text\n    // is referenced, keeping \"Optional\" out of the accessible name.\n    'aria-labelledby': labelId,\n    ref: builtInTriggerRef,\n  };\n  const field: ComboboxFieldState = {\n    errorText: formField.errorText,\n    errorTextId: formField.errorTextId,\n    hasError,\n    hasRequiredIndicator,\n    hasVisuallyHiddenLabel,\n    helpText,\n    helpTextId: formField.helpTextId,\n    isRequired,\n    label,\n    labelId,\n    triggerId,\n  };\n  const triggerState: ComboboxTriggerState<TOption> = {\n    clear: clearSelection,\n    field,\n    isDisabled,\n    isMulti,\n    isOpen: isPanelOpen,\n    remove: removeOption,\n    selectedOptions,\n  };\n\n  // While windowed, the DOM no longer holds every option, so each one carries\n  // its position in the full list for assistive technology.\n  const getSetPositionProps = (row: ComboboxRow<TOption>) =>\n    isListVirtualized\n      ? {\n          posInSet: (rowIndexes.get(row) ?? 0) + 1,\n          setSize: flatOptions.length,\n        }\n      : {};\n\n  const renderOption = (option: TOption) => {\n    const sharedProps = {\n      id: getOptionId(option),\n      isFocused: option === activeOption,\n      onClick: () => handleOptionChange(option),\n      onHover: () => handleOptionHover(option),\n      ...getSetPositionProps(option),\n    };\n\n    // The create row is never selected and shows the create text rather than\n    // the label of the option it would produce.\n    if (isCreateOption(option)) {\n      return (\n        <Option\n          key=\"ndl-combobox-create\"\n          {...sharedProps}\n          isCreate\n          isSelected={false}\n        >\n          <CreateOptionContent>\n            {formatCreateLabel(currentSearchValue)}\n          </CreateOptionContent>\n        </Option>\n      );\n    }\n\n    const { OptionLabel } = components;\n    const isSelected = isOptionSelected(option);\n\n    return (\n      <Option\n        key={option.value}\n        {...sharedProps}\n        isSelected={isSelected}\n        isDisabled={option.isDisabled}\n      >\n        <OptionContent\n          label={option.label}\n          customLabel={\n            OptionLabel === undefined ? undefined : (\n              <OptionLabel\n                option={option}\n                isSelected={isSelected}\n                isDisabled={option.isDisabled ?? false}\n                isFocused={option === activeOption}\n                isMulti={isMulti}\n                size={size}\n              />\n            )\n          }\n          description={option.description}\n          leadingVisual={option.leadingVisual}\n          isDisabled={option.isDisabled}\n          isSelected={isSelected}\n          isMulti={isMulti}\n        />\n      </Option>\n    );\n  };\n\n  // An action row shares the chrome of an option but never the selection, so it\n  // is rendered as a single select row: its own leading visual instead of a\n  // checkbox, and no selection indicator.\n  const renderAction = (row: ComboboxActionRow) => {\n    const action = getAction(row);\n\n    return (\n      <Option\n        key={row.value}\n        id={getOptionId(row)}\n        isAction\n        isDisabled={action.isDisabled}\n        isFocused={row === activeOption}\n        onClick={() => handleOptionChange(row)}\n        onHover={() => handleOptionHover(row)}\n        {...getSetPositionProps(row)}\n      >\n        <OptionContent\n          label={action.label}\n          description={action.description}\n          leadingVisual={action.leadingVisual}\n          isDisabled={action.isDisabled}\n        />\n      </Option>\n    );\n  };\n\n  const panel = (\n    <Panel\n      {...getFloatingProps()}\n      ref={refs.setFloating}\n      id={panelId}\n      ariaLabel={label}\n      isDialog={isDialogPanel}\n      className={themeClassName}\n      style={floatingStyles}\n    >\n      {isSearchable && (\n        <Input\n          ref={searchInputRef}\n          ariaLabel={searchPlaceholder}\n          value={currentSearchValue}\n          onValueChange={setCurrentSearchValue}\n          placeholder={searchPlaceholder}\n          listboxId={hasRows ? listboxId : undefined}\n          activeOptionId={hasRows ? activeOptionId : undefined}\n          onKeyDown={handleSearchKeyDown}\n        />\n      )}\n      {/* Actions keep the list rendered when nothing matched, so the message\n          sits above the list rather than replacing it. Loading replaces the\n          empty message while there are no options. */}\n      {!hasOptionRows &&\n        (isLoading ? (\n          <LoadingState>{loadingMessage}</LoadingState>\n        ) : (\n          <EmptyState />\n        ))}\n      {/* Actions sit below the scrolling listbox, pinned and always visible\n          rather than scrolling away with a long list. The listbox aria-owns\n          them, so they stay its logical children for aria-activedescendant\n          even though the scroll container leaves them behind. Keeping the\n          scroll on the listbox itself also keeps the scrollable element\n          recognizable as the combobox popup, which scrollable-region audits\n          exempt from needing focusable content. */}\n      {hasOptionRows &&\n        (virtualRows !== undefined ? (\n          <VirtualizedListBox\n            id={listboxId}\n            ariaLabel={label}\n            isMulti={isMulti}\n            ownsIds={actionOwnsIds}\n            rows={virtualRows.displayRows}\n            rowsKey={optionsKey}\n            flatToDisplayIndex={virtualRows.flatToDisplayIndex}\n            scrollToFlatIndexRef={scrollToActiveRowRef}\n            renderRow={renderOption}\n          />\n        ) : (\n          <ListBox\n            id={listboxId}\n            ariaLabel={label}\n            isMulti={isMulti}\n            ownsIds={actionOwnsIds}\n          >\n            {optionItems.map((item) =>\n              isOptionGroup(item) ? (\n                <Group key={item.label} label={item.label}>\n                  {item.options.map(renderOption)}\n                </Group>\n              ) : (\n                renderOption(item)\n              ),\n            )}\n          </ListBox>\n        ))}\n      {actionRows.length > 0 && (\n        <div\n          // Without any option rows there is no scrolling listbox, so the\n          // footer itself is the listbox the trigger controls and the actions\n          // are its direct children rather than aria-owned ones.\n          {...(hasOptionRows\n            ? { role: 'presentation' as const }\n            : {\n                'aria-label': label,\n                'aria-multiselectable': isMulti || undefined,\n                id: listboxId,\n                role: 'listbox' as const,\n              })}\n          className=\"ndl-combobox-actions\"\n        >\n          <Divider\n            className=\"ndl-combobox-action-divider\"\n            htmlAttributes={{ 'aria-hidden': true }}\n          />\n          {actionRows.map((row, index) => (\n            <Fragment key={row.value}>\n              {/* An extra divider only ever sits between two actions: the\n                  first action already sits below the actions divider. */}\n              {index > 0 && getAction(row).hasDivider === true && (\n                <Divider\n                  className=\"ndl-combobox-action-divider\"\n                  htmlAttributes={{ 'aria-hidden': true }}\n                />\n              )}\n              {renderAction(row)}\n            </Fragment>\n          ))}\n        </div>\n      )}\n    </Panel>\n  );\n\n  const formControl = name !== undefined && (\n    <ComboboxFormControl\n      ref={internalTriggerRef}\n      name={name}\n      form={formId}\n      autoComplete={autoComplete}\n      options={formOptions}\n      selectedOptions={selectedOptions}\n      resetSelectedOptions={resetSelectedOptions}\n      isMulti={isMulti}\n      isDisabled={isDisabled}\n      isRequired={isRequired}\n      isSelectionControlled={value !== undefined}\n      onValueChange={setSelectedValue}\n      onInvalid={setNativeValidationMessage}\n      onReset={resetFromForm}\n    />\n  );\n\n  const floatingPanel = context.open && (\n    <ConditionalWrap\n      shouldWrap={isPanelPortaled}\n      wrap={(wrapChildren) => (\n        <FloatingPortal root={portalTarget}>{wrapChildren}</FloatingPortal>\n      )}\n    >\n      <FloatingFocusManager\n        context={context}\n        modal={false}\n        // A select-only combobox keeps DOM focus on the trigger and speaks\n        // through aria-activedescendant, so nothing inside is focused.\n        initialFocus={isSearchable ? searchInputRef : -1}\n        returnFocus={internalTriggerRef}\n      >\n        {panel}\n      </FloatingFocusManager>\n    </ConditionalWrap>\n  );\n\n  // No root element around a custom trigger, so the trigger is a real child of\n  // whatever holds the combobox and sibling-based selectors there match it.\n  // The form control goes after the trigger to keep it out of leading\n  // positional slots.\n  if (renderTrigger !== undefined) {\n    return (\n      <>\n        {renderTrigger(triggerProps, triggerState)}\n        {formControl}\n        {floatingPanel}\n      </>\n    );\n  }\n\n  return (\n    <div\n      ref={ref}\n      style={style}\n      className={classNames(\n        'ndl-combobox ndl-combobox-field',\n        {\n          'ndl-clean': isClean,\n          'ndl-disabled': isDisabled,\n          'ndl-fluid': isFluid,\n          'ndl-has-error': hasError,\n          'ndl-large': size === 'large',\n          'ndl-medium': size === 'medium',\n          'ndl-small': size === 'small',\n        },\n        className,\n      )}\n      {...htmlAttributes}\n    >\n      {formControl}\n      <Control\n        triggerProps={builtInTriggerProps}\n        state={triggerState}\n        field={field}\n        placeholder={placeholder}\n        isClearable={isClearable}\n        isClean={isClean}\n        size={size}\n        maxRows={isMulti ? maxRows : undefined}\n        components={components}\n        referenceProps={getReferenceProps()}\n        referenceRef={refs.setReference}\n      />\n      {floatingPanel}\n    </div>\n  );\n};\n\nconst getTriggerControlsId = ({\n  isPanelOpen,\n  isDialogPanel,\n  hasRows,\n  panelId,\n  listboxId,\n}: {\n  isPanelOpen: boolean;\n  isDialogPanel: boolean;\n  hasRows: boolean;\n  panelId: string;\n  listboxId: string;\n}) => {\n  if (!isPanelOpen) {\n    return undefined;\n  }\n\n  if (isDialogPanel) {\n    return panelId;\n  }\n\n  // An expanded combobox must always control something, so fall back to the\n  // panel when the list is empty and only the status message is rendered.\n  return hasRows ? listboxId : panelId;\n};\n\nconst getSelectedOptions = <TOption extends ComboboxOption>(\n  value: ComboboxValue<TOption>,\n): TOption[] => {\n  if (Array.isArray(value)) {\n    return value;\n  }\n\n  return value === null ? [] : [value];\n};\n\n/**\n * The public `ComboboxFieldState` keeps its own shape - a custom trigger\n * renders from it - so the built-in field parts map it onto the shared form\n * field state (`_common/form-control`) instead of taking it directly.\n */\nconst toFormFieldState = (field: ComboboxFieldState): FormFieldState => {\n  const hasHelpText = Boolean(field.helpText) && !field.hasError;\n\n  return {\n    controlId: field.triggerId,\n    errorText: field.errorText,\n    errorTextId: field.errorTextId,\n    hasError: field.hasError,\n    hasRequiredIndicator: field.hasRequiredIndicator,\n    hasVisuallyHiddenLabel: field.hasVisuallyHiddenLabel,\n    helpText: field.helpText,\n    helpTextId: field.helpTextId,\n    isRequired: field.isRequired,\n    label: field.label,\n    labelId: field.labelId,\n    message: field.hasError\n      ? field.errorText\n      : hasHelpText\n        ? field.helpText\n        : undefined,\n    messageId: field.hasError\n      ? field.errorTextId\n      : hasHelpText\n        ? field.helpTextId\n        : undefined,\n    messageSeverity: field.hasError\n      ? 'error'\n      : hasHelpText\n        ? 'help'\n        : undefined,\n  };\n};\n\ntype ComboboxFormControlProps<TOption extends ComboboxOption> = {\n  ref: React.RefObject<HTMLElement | null>;\n  name: string;\n  form?: string;\n  autoComplete?: string;\n  options: TOption[];\n  selectedOptions: TOption[];\n  resetSelectedOptions: TOption[];\n  isMulti: boolean;\n  isDisabled: boolean;\n  isRequired: boolean;\n  isSelectionControlled: boolean;\n  onValueChange: (value: ComboboxValue<TOption>) => void;\n  onInvalid: (message: string) => void;\n  onReset: () => void;\n};\n\n/**\n * A native select mirrors the custom control for submission, autofill,\n * constraint validation, and reset. It is hidden from assistive technology\n * because the combobox trigger exposes the same field semantics.\n *\n * Above `FORM_OPTION_MIRROR_LIMIT` it receives only the selected and default\n * options rather than the full list, so autofill has nothing to offer but\n * everything else keeps working without thousands of mirrored options.\n */\nconst ComboboxFormControl = <TOption extends ComboboxOption>({\n  ref: triggerRef,\n  name,\n  form,\n  autoComplete,\n  options,\n  selectedOptions,\n  resetSelectedOptions,\n  isMulti,\n  isDisabled,\n  isRequired,\n  isSelectionControlled,\n  onValueChange,\n  onInvalid,\n  onReset,\n}: ComboboxFormControlProps<TOption>) => {\n  const selectRef = useRef<HTMLSelectElement | null>(null);\n  const isDispatchingChangeRef = useRef(false);\n  const isResettingRef = useRef(false);\n  const skipNextChangeRef = useRef(false);\n  const selectedValues = selectedOptions.map((option) => option.value);\n  const resetSelectedValues = resetSelectedOptions.map(\n    (option) => option.value,\n  );\n  const selectedValuesKey = selectedValues.join('\\u0000');\n  const previousValuesKeyRef = useRef(selectedValuesKey);\n  const valuesOnReset = isSelectionControlled\n    ? selectedValues\n    : resetSelectedValues;\n  const valuesOnResetKey = valuesOnReset.join('\\u0000');\n\n  useEffect(() => {\n    const select = selectRef.current;\n    if (select === null) {\n      return;\n    }\n\n    const resetValues = new Set(valuesOnReset);\n\n    Array.from(select.options).forEach((option) => {\n      option.defaultSelected = resetValues.has(option.value);\n    });\n    // valuesOnReset is rebuilt every render, so the effect keys on its content.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [valuesOnResetKey]);\n\n  useEffect(() => {\n    if (previousValuesKeyRef.current === selectedValuesKey) {\n      return;\n    }\n\n    previousValuesKeyRef.current = selectedValuesKey;\n    if (isResettingRef.current || skipNextChangeRef.current) {\n      skipNextChangeRef.current = false;\n      return;\n    }\n\n    const select = selectRef.current;\n    if (select === null) {\n      return;\n    }\n\n    isDispatchingChangeRef.current = true;\n    select.dispatchEvent(new Event('change', { bubbles: true }));\n    isDispatchingChangeRef.current = false;\n  }, [selectedValuesKey]);\n\n  useEffect(() => {\n    const select = selectRef.current;\n    const formElement = select?.form;\n    if (\n      select === null ||\n      select === undefined ||\n      formElement === null ||\n      formElement === undefined\n    ) {\n      return;\n    }\n\n    const handleReset = () => {\n      isResettingRef.current = true;\n      onReset();\n\n      window.setTimeout(() => {\n        isResettingRef.current = false;\n      });\n    };\n\n    formElement.addEventListener('reset', handleReset);\n    return () => formElement.removeEventListener('reset', handleReset);\n  }, [onReset]);\n\n  const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n    if (isDispatchingChangeRef.current) {\n      return;\n    }\n\n    const optionsByValue = new Map(\n      options.map((option) => [option.value, option]),\n    );\n    const nextOptions = Array.from(event.currentTarget.selectedOptions)\n      .map((selectedOption) => optionsByValue.get(selectedOption.value))\n      .filter((option): option is TOption => option !== undefined);\n    skipNextChangeRef.current =\n      nextOptions.map((option) => option.value).join('\\u0000') !==\n      selectedValuesKey;\n\n    onValueChange(isMulti ? nextOptions : (nextOptions[0] ?? null));\n  };\n\n  return (\n    <select\n      ref={selectRef}\n      className=\"ndl-combobox-form-control\"\n      aria-hidden=\"true\"\n      tabIndex={-1}\n      name={name}\n      form={form}\n      autoComplete={autoComplete}\n      disabled={isDisabled}\n      required={isRequired}\n      multiple={isMulti}\n      value={isMulti ? selectedValues : (selectedValues[0] ?? '')}\n      onChange={handleChange}\n      onInvalid={(event) => {\n        event.preventDefault();\n        onInvalid(event.currentTarget.validationMessage);\n        triggerRef.current?.focus();\n      }}\n    >\n      {!isMulti && <option value=\"\" />}\n      {options.map((option) => (\n        <option key={option.value} value={option.value}>\n          {option.label}\n        </option>\n      ))}\n    </select>\n  );\n};\n\nconst Control = <TOption extends ComboboxOption>({\n  triggerProps,\n  state,\n  field,\n  placeholder,\n  isClearable,\n  isClean,\n  size,\n  maxRows,\n  components,\n  referenceProps,\n  referenceRef,\n}: ComboboxControlProps<TOption>) => {\n  const { isOpen, isMulti, isDisabled, selectedOptions, clear, remove } = state;\n  const { MultiValue, SingleValue } = components;\n  const { ref: triggerRef, ...triggerAria } = triggerProps;\n  const sharedField = toFormFieldState(field);\n  const hasValue = selectedOptions.length > 0;\n  const singleValueOption = isMulti ? undefined : selectedOptions[0];\n  // Selected values are shown as tags, so the trigger renders nothing and is\n  // taken out of the wrapping flow rather than claiming a row of its own.\n  const isTriggerCollapsed = isMulti && hasValue;\n  const multiValueSize = size === 'large' ? 'small' : 'x-small';\n  // `null` opts out of the default row limit, so both it and a missing value\n  // resolve to unlimited, which the hook expresses as undefined.\n  const rowLimit =\n    isMulti && maxRows !== null && maxRows !== undefined ? maxRows : undefined;\n  // Under a row limit only the tags that could possibly be visible are\n  // rendered and measured; the rest of a huge selection is overflowed\n  // arithmetically without ever touching the DOM. Without a limit every tag\n  // renders, so unlimited rows with a huge selection is on the consumer.\n  const tagCandidateCap =\n    rowLimit === undefined\n      ? selectedOptions.length\n      : Math.max(1, Math.floor(rowLimit)) * TAG_CANDIDATES_PER_ROW;\n  const renderedOptions =\n    selectedOptions.length > tagCandidateCap\n      ? selectedOptions.slice(0, tagCandidateCap)\n      : selectedOptions;\n  const { containerRef: valueContainerRef, visibleCount } =\n    useComboboxMultiValueOverflow({\n      maxRows: rowLimit,\n      // Disabling swaps the dismissible tags for read-only ones, which have no\n      // remove button and are narrower. The total count is included since it\n      // sets the measure tag texts.\n      measureKey: [\n        size,\n        isDisabled,\n        selectedOptions.length,\n        ...renderedOptions.map((option) => `${option.value}:${option.label}`),\n      ].join('\\u0000'),\n      tagCount: renderedOptions.length,\n    });\n  const visibleTagCount = visibleCount ?? renderedOptions.length;\n  const overflowCount = selectedOptions.length - visibleTagCount;\n  const overflowedOptions = selectedOptions.slice(\n    visibleTagCount,\n    visibleTagCount + OVERFLOW_LABEL_LIMIT,\n  );\n  const unnamedOverflowCount = overflowCount - overflowedOptions.length;\n  const overflowedLabels =\n    overflowedOptions.map((option) => option.label).join(', ') +\n    (unnamedOverflowCount > 0 ? `, and ${unnamedOverflowCount} more` : '');\n  // \"+999\" is wider than \"+1K\", so each text the counter could show at its\n  // widest is measured; the hook reserves room for the widest of them.\n  const counterMeasureTexts = getOverflowCounterMeasureTexts(\n    selectedOptions.length,\n  );\n  const internalTriggerRef = useRef<HTMLButtonElement | null>(null);\n  const mergedTriggerRef = useMergeRefs([\n    triggerRef,\n    internalTriggerRef,\n  ]) as React.Ref<HTMLButtonElement>;\n\n  const handleAuxiliaryActionKeyDown = (\n    event: React.KeyboardEvent<HTMLElement>,\n  ) => {\n    if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n      event.preventDefault();\n      event.stopPropagation();\n      internalTriggerRef.current?.focus();\n      triggerAria.onKeyDown?.(event);\n    }\n  };\n\n  const handleTagRemove = (\n    event: React.MouseEvent<HTMLButtonElement>,\n    option: TOption,\n  ) => {\n    // Capture the following removal targets before React removes the current\n    // tag. With `maxRows`, the removal can promote a collapsed tag into view,\n    // so which of them is focusable is only known after the update.\n    const tag = event.currentTarget.closest('[data-ndl-combobox-multi-value]');\n    const followingRemoveButtons: HTMLButtonElement[] = [];\n    let sibling = tag?.nextElementSibling ?? null;\n\n    while (sibling !== null) {\n      const removeButton = sibling.querySelector<HTMLButtonElement>(\n        '[data-ndl-dismissible-tag-remove]',\n      );\n\n      if (removeButton !== null) {\n        followingRemoveButtons.push(removeButton);\n      }\n\n      sibling = sibling.nextElementSibling;\n    }\n\n    // Otherwise the click bubbles to the control and opens the panel.\n    event.stopPropagation();\n    remove(option);\n\n    requestAnimationFrame(() => {\n      // A tag collapsed into the overflow counter is invisible and cannot take\n      // focus, so it is passed over.\n      const nextRemoveButton = followingRemoveButtons.find(\n        (removeButton) =>\n          removeButton.isConnected &&\n          removeButton.closest('.ndl-overflowed') === null,\n      );\n\n      if (nextRemoveButton !== undefined) {\n        nextRemoveButton.focus();\n        return;\n      }\n\n      internalTriggerRef.current?.focus();\n    });\n  };\n\n  const handleClear = (event: React.MouseEvent<HTMLButtonElement>) => {\n    // Otherwise the click bubbles to the control and opens the panel.\n    event.stopPropagation();\n    clear();\n\n    // Clearing removes the focused clear button from the DOM. Restore focus to\n    // the combobox after React has committed that update.\n    requestAnimationFrame(() => {\n      internalTriggerRef.current?.focus();\n    });\n  };\n\n  // Clicking the label moves focus to the trigger without opening the panel,\n  // as with a native select. Preventing the default cancels the click the\n  // label would otherwise forward to the trigger button, which would toggle\n  // the panel.\n  const handleLabelClick = (event: React.MouseEvent<HTMLLabelElement>) => {\n    event.preventDefault();\n    internalTriggerRef.current?.focus();\n  };\n\n  return (\n    // A fragment, so the label, the control, and the message are rows of the\n    // combobox itself. A custom trigger replaces all three.\n    <>\n      {/* The trigger is a button with role=\"combobox\", which takes its\n          accessible name from the author rather than from its content, so the\n          label is referenced through aria-labelledby instead of wrapping the\n          control in a label element. The label still points at the trigger\n          through htmlFor, and clicking it moves focus to the trigger without\n          opening the panel, as with a native select. */}\n      <FormFieldLabel\n        field={sharedField}\n        size={size}\n        onLabelClick={handleLabelClick}\n      />\n      {/* The reference props carry the click handler that opens the panel. The\n          wrapper cannot be focusable itself, since it contains the tag remove\n          and clear buttons; the focusable role=\"combobox\" button is a sibling of\n          them. */}\n      <div\n        ref={referenceRef}\n        className={classNames('ndl-combobox-control', {\n          'ndl-clean': isClean,\n          'ndl-disabled': isDisabled,\n          'ndl-has-error': field.hasError,\n          'ndl-has-value': hasValue,\n          'ndl-is-multi': isMulti,\n          'ndl-large': size === 'large',\n          'ndl-medium': size === 'medium',\n          'ndl-small': size === 'small',\n        })}\n        {...referenceProps}\n      >\n        <div\n          ref={valueContainerRef}\n          className={classNames('ndl-combobox-value-container', {\n            // While a counter may be needed, every tag reserves room for it,\n            // so an extreme-width tag shrinks instead of collapsing entirely.\n            'ndl-counter-reserved':\n              rowLimit !== undefined && selectedOptions.length > 1,\n          })}\n        >\n          {/* Rendered before tag remove buttons so the combobox is the first\n              control reached by Tab. CSS keeps selected tags visually first. */}\n          <button\n            type=\"button\"\n            className={classNames('ndl-combobox-trigger', {\n              'ndl-collapsed': isTriggerCollapsed,\n              'ndl-disabled': isDisabled,\n            })}\n            {...triggerAria}\n            ref={mergedTriggerRef}\n          >\n            {singleValueOption !== undefined &&\n              (SingleValue === undefined ? (\n                <span className=\"ndl-combobox-single-value\">\n                  {singleValueOption.label}\n                </span>\n              ) : (\n                <SingleValue\n                  option={singleValueOption}\n                  isDisabled={isDisabled}\n                  size={size}\n                />\n              ))}\n            {!hasValue && (\n              <span className=\"ndl-combobox-placeholder\">{placeholder}</span>\n            )}\n          </button>\n          {isMulti &&\n            renderedOptions.map((option, index) => {\n              // Tags past the overflow cutoff stay rendered so they keep their\n              // measurements, but the stylesheet takes them out of the layout,\n              // out of the accessibility tree, and out of focus reach.\n              const multiValueClasses = classNames('ndl-combobox-multi-value', {\n                'ndl-overflowed': index >= visibleTagCount,\n              });\n\n              // A custom value owns its own presentation, so it is only given\n              // the wrapper the value container lays out, and no remove button.\n              if (MultiValue !== undefined) {\n                return (\n                  <span key={option.value} className={multiValueClasses}>\n                    <MultiValue\n                      option={option}\n                      index={index}\n                      isDisabled={isDisabled}\n                      size={size}\n                      remove={() => remove(option)}\n                    />\n                  </span>\n                );\n              }\n\n              return isDisabled ? (\n                <ReadOnlyTag\n                  key={option.value}\n                  className={multiValueClasses}\n                  size={multiValueSize}\n                >\n                  {option.label}\n                </ReadOnlyTag>\n              ) : (\n                <DismissibleTag\n                  key={option.value}\n                  className={multiValueClasses}\n                  size={multiValueSize}\n                  htmlAttributes={{\n                    'data-ndl-combobox-multi-value': '',\n                    onKeyDown: handleAuxiliaryActionKeyDown,\n                  }}\n                  onRemove={(event) => handleTagRemove(event, option)}\n                >\n                  {option.label}\n                </DismissibleTag>\n              );\n            })}\n          {overflowCount > 0 && (\n            <ReadOnlyTag\n              className=\"ndl-combobox-multi-value-counter\"\n              size={multiValueSize}\n              htmlAttributes={{\n                title: overflowedLabels,\n              }}\n            >\n              <span aria-hidden=\"true\">\n                +{formatOverflowCount(overflowCount)}\n              </span>\n              <span className=\"ndl-combobox-visually-hidden\">\n                {overflowCount} more selected: {overflowedLabels}\n              </span>\n            </ReadOnlyTag>\n          )}\n          {rowLimit !== undefined &&\n            hasValue &&\n            // Invisible and out of the layout, purely to measure the widest\n            // counter the current selection could need, so the fit computation\n            // can reserve room for it in a single deterministic pass.\n            counterMeasureTexts.map((text) => (\n              <ReadOnlyTag\n                key={text}\n                className=\"ndl-combobox-multi-value-measure\"\n                size={multiValueSize}\n                htmlAttributes={{ 'aria-hidden': true }}\n              >\n                +{text}\n              </ReadOnlyTag>\n            ))}\n        </div>\n        <div className=\"ndl-combobox-indicators-container\">\n          {isClearable && hasValue && !isDisabled && (\n            // The divider only separates the clear button from the chevron, so\n            // it is tied to the button rather than always rendered, as in\n            // Select.\n            <div className=\"ndl-combobox-clear\">\n              <button\n                type=\"button\"\n                className=\"ndl-combobox-clear-button\"\n                aria-label=\"Clear selection\"\n                onKeyDown={handleAuxiliaryActionKeyDown}\n                onClick={handleClear}\n              >\n                <XMarkIconOutline />\n              </button>\n              <div className=\"ndl-combobox-divider\" />\n            </div>\n          )}\n          <div\n            className={classNames('ndl-combobox-dropdown-indicator', {\n              'ndl-open': isOpen,\n            })}\n          >\n            <ChevronDownIconOutline\n              aria-hidden=\"true\"\n              className=\"ndl-combobox-icon\"\n            />\n          </div>\n        </div>\n      </div>\n      <FormFieldMessage field={sharedField} size={size} />\n    </>\n  );\n};\n\nconst Panel = ({\n  children,\n  ref,\n  id,\n  ariaLabel,\n  isDialog,\n  className,\n  style,\n  ...restProps\n}: ComboboxPanelProps) => {\n  return (\n    <div\n      ref={ref}\n      id={id}\n      role={isDialog === true ? 'dialog' : undefined}\n      aria-label={isDialog === true ? ariaLabel : undefined}\n      className={classNames('ndl-combobox-panel', className)}\n      style={style}\n      {...restProps}\n    >\n      {children}\n    </div>\n  );\n};\n\nconst Input = ({\n  ref,\n  ariaLabel,\n  value,\n  onValueChange,\n  placeholder,\n  listboxId,\n  activeOptionId,\n  onKeyDown,\n}: ComboboxInputProps) => {\n  return (\n    <label className=\"ndl-combobox-input-wrapper\">\n      <span className=\"ndl-combobox-input-label\">{ariaLabel}</span>\n      <MagnifyingGlassIconOutline className=\"ndl-combobox-input-leading\" />\n      <input\n        ref={ref}\n        type=\"text\"\n        role=\"combobox\"\n        autoComplete=\"off\"\n        aria-autocomplete=\"list\"\n        aria-haspopup=\"listbox\"\n        aria-expanded={listboxId !== undefined}\n        aria-controls={listboxId}\n        aria-activedescendant={activeOptionId}\n        className=\"ndl-combobox-input\"\n        placeholder={placeholder}\n        value={value}\n        onChange={(event) => onValueChange(event.target.value)}\n        onKeyDown={onKeyDown}\n      />\n    </label>\n  );\n};\n\nconst ListBox = ({\n  ariaLabel,\n  children,\n  isMulti,\n  id,\n  ownsIds,\n}: ComboboxListBoxProps) => {\n  return (\n    <div\n      id={id}\n      role=\"listbox\"\n      aria-label={ariaLabel}\n      aria-owns={ownsIds}\n      aria-multiselectable={isMulti || undefined}\n      className=\"ndl-combobox-listbox\"\n    >\n      {children}\n    </div>\n  );\n};\n\ntype ComboboxVirtualizedListBoxProps<TOption extends ComboboxOption> = {\n  id?: string;\n  ariaLabel: string;\n  isMulti?: boolean;\n  /** Ids of the pinned action rows the listbox owns without containing. */\n  ownsIds?: string;\n  rows: ComboboxDisplayRow<TOption>[];\n  /** Content identity of the rows, so a filtered list starts back at the top. */\n  rowsKey: string;\n  /** Display row index for each flat option index, for index-based scrolling. */\n  flatToDisplayIndex: number[];\n  /** Receives the scroll-to-row callback while this listbox is mounted. */\n  scrollToFlatIndexRef: React.RefObject<((flatIndex: number) => void) | null>;\n  renderRow: (row: TOption) => React.ReactNode;\n};\n\n/**\n * The windowed listbox used above the row threshold: only the visible slice of\n * rows is in the DOM, absolutely positioned inside one full-height spacer.\n * Group nesting cannot survive windowing, so headers render as presentational\n * rows of their own and options carry `aria-setsize`/`aria-posinset` instead.\n * Pinned action rows render outside, below the listbox, so they are never\n * windowed.\n */\nconst VirtualizedListBox = <TOption extends ComboboxOption>({\n  id,\n  ariaLabel,\n  isMulti,\n  ownsIds,\n  rows,\n  rowsKey,\n  flatToDisplayIndex,\n  scrollToFlatIndexRef,\n  renderRow,\n}: ComboboxVirtualizedListBoxProps<TOption>) => {\n  const scrollRef = useRef<HTMLDivElement | null>(null);\n  const virtualizer = useVirtualizer({\n    count: rows.length,\n    estimateSize: () => VIRTUAL_ROW_ESTIMATED_HEIGHT,\n    getScrollElement: () => scrollRef.current,\n    overscan: 10,\n  });\n  const pendingScrollIndexRef = useRef<number | null>(null);\n\n  useEffect(() => {\n    scrollToFlatIndexRef.current = (flatIndex: number) => {\n      const displayIndex = flatToDisplayIndex[flatIndex];\n\n      if (displayIndex !== undefined) {\n        pendingScrollIndexRef.current = displayIndex;\n        virtualizer.scrollToIndex(displayIndex);\n      }\n    };\n\n    return () => {\n      scrollToFlatIndexRef.current = null;\n    };\n  });\n\n  // A long jump scrolls to an offset built from estimated sizes, and the\n  // estimates only get corrected once the rows near the target render, so one\n  // scroll can land short. Each render after a scroll re-issues it until the\n  // target row is actually mounted, which is also what lets\n  // aria-activedescendant resolve.\n  useEffect(() => {\n    const target = pendingScrollIndexRef.current;\n\n    if (target === null) {\n      return;\n    }\n\n    const isRendered = virtualizer\n      .getVirtualItems()\n      .some((item) => item.index === target);\n\n    if (isRendered) {\n      pendingScrollIndexRef.current = null;\n      return;\n    }\n\n    virtualizer.scrollToIndex(target);\n  });\n\n  // A filtered list is a different list, so it starts at the top.\n  useEffect(() => {\n    virtualizer.scrollToOffset(0);\n    // The virtualizer is stable and scrolling must not rerun on its rerenders.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [rowsKey]);\n\n  return (\n    <div\n      ref={scrollRef}\n      id={id}\n      role=\"listbox\"\n      aria-label={ariaLabel}\n      aria-owns={ownsIds}\n      aria-multiselectable={isMulti === true || undefined}\n      className=\"ndl-combobox-listbox\"\n    >\n      <div\n        role=\"presentation\"\n        className=\"ndl-combobox-virtual-space\"\n        style={{ height: virtualizer.getTotalSize() }}\n      >\n        {virtualizer.getVirtualItems().map((item) => {\n          const row = rows[item.index];\n\n          return (\n            <div\n              key={item.key}\n              ref={virtualizer.measureElement}\n              data-index={item.index}\n              role=\"presentation\"\n              className=\"ndl-combobox-virtual-row\"\n              style={{ transform: `translateY(${item.start}px)` }}\n            >\n              {row.kind === 'group-header' ? (\n                <GroupHeader isPresentational label={row.label} />\n              ) : (\n                renderRow(row.row)\n              )}\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n};\n\nconst Option = ({\n  children,\n  id,\n  isSelected,\n  isDisabled,\n  isFocused,\n  isCreate,\n  isAction,\n  onClick,\n  onHover,\n  posInSet,\n  setSize,\n}: ComboboxOptionProps) => {\n  const classes = classNames('ndl-combobox-option', {\n    'ndl-combobox-option-action': isAction,\n    'ndl-combobox-option-create': isCreate,\n    'ndl-disabled': isDisabled,\n    'ndl-focused': isFocused,\n  });\n\n  return (\n    // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus -- options are never DOM focused; keyboard is handled on the search input or the listbox and exposed through aria-activedescendant\n    <div\n      id={id}\n      role=\"option\"\n      // Left off an action row, since it is not something that can be selected.\n      aria-selected={isSelected}\n      aria-disabled={isDisabled}\n      aria-posinset={posInSet}\n      aria-setsize={setSize}\n      className={classes}\n      onClick={onClick}\n      // Options are not focusable, so a plain mousedown would blur whatever\n      // holds DOM focus - the search input or the trigger - and drop the panel.\n      onMouseDown={(event) => event.preventDefault()}\n      // mouseover fires when the element under a stationary cursor changes\n      // because the list scrolled, which would let a rested mouse steal virtual\n      // focus back during keyboard navigation. mousemove needs real movement.\n      onMouseMove={onHover}\n    >\n      {children}\n    </div>\n  );\n};\n\nconst OptionContent = ({\n  label,\n  customLabel,\n  description,\n  leadingVisual,\n  isDisabled,\n  isSelected,\n  isMulti,\n}: ComboboxOptionContentProps) => {\n  return (\n    <div className=\"ndl-combobox-option-content\">\n      {isMulti ? (\n        <MultiSelectIndicator isDisabled={isDisabled} isSelected={isSelected} />\n      ) : (\n        leadingVisual && (\n          <LeadingVisual isDisabled={isDisabled}>{leadingVisual}</LeadingVisual>\n        )\n      )}\n      <div className=\"ndl-combobox-option-content-main\">\n        {customLabel ?? <Label isDisabled={isDisabled}>{label}</Label>}\n        {description && (\n          <Description isDisabled={isDisabled}>{description}</Description>\n        )}\n      </div>\n      {!isMulti && isSelected && <SelectionIndicator isDisabled={isDisabled} />}\n    </div>\n  );\n};\n\ntype OptionContentPartProps = {\n  children?: React.ReactNode;\n  isDisabled?: boolean;\n};\n\nconst CreateOptionContent = ({ children }: OptionContentPartProps) => {\n  return (\n    <div className=\"ndl-combobox-option-content\">\n      <LeadingVisual>\n        <PlusIconOutline />\n      </LeadingVisual>\n      <div className=\"ndl-combobox-option-content-main\">\n        <Label>{children}</Label>\n      </div>\n    </div>\n  );\n};\n\nconst LeadingVisual = ({ children, isDisabled }: OptionContentPartProps) => {\n  const classes = classNames('ndl-combobox-option-content-leading-visual', {\n    'ndl-disabled': isDisabled,\n  });\n\n  return <div className={classes}>{children}</div>;\n};\n\nconst Label = ({ children, isDisabled }: OptionContentPartProps) => {\n  const classes = classNames('ndl-combobox-option-content-label', {\n    'ndl-disabled': isDisabled,\n  });\n\n  return (\n    <Typography variant=\"body-medium\" className={classes}>\n      {children}\n    </Typography>\n  );\n};\n\nconst Description = ({ children, isDisabled }: OptionContentPartProps) => {\n  const classes = classNames('ndl-combobox-option-content-description', {\n    'ndl-disabled': isDisabled,\n  });\n\n  return (\n    <Typography variant=\"body-small\" className={classes}>\n      {children}\n    </Typography>\n  );\n};\n\nconst SelectionIndicator = ({\n  isDisabled,\n}: Pick<OptionContentPartProps, 'isDisabled'>) => {\n  const classes = classNames(\n    'ndl-combobox-option-content-selection-indicator',\n    {\n      'ndl-disabled': isDisabled,\n    },\n  );\n\n  return <CheckIconOutline className={classes} />;\n};\n\ntype MultiSelectIndicatorProps = {\n  isDisabled?: boolean;\n  isSelected?: boolean;\n};\n\n/**\n * The option itself owns selection through `aria-selected` and its click\n * handler, so the checkbox is decorative. `inert` keeps it out of the\n * accessibility tree and out of hit testing - without it the wrapping label\n * forwards a second click to the input, which bubbles back to the option and\n * undoes the toggle.\n */\nconst MultiSelectIndicator = ({\n  isDisabled,\n  isSelected,\n}: MultiSelectIndicatorProps) => {\n  return (\n    <span className=\"ndl-combobox-option-content-multi-select-indicator\" inert>\n      <Checkbox\n        ariaLabel=\"Select\"\n        isChecked={isSelected}\n        isDisabled={isDisabled}\n      />\n    </span>\n  );\n};\n\ntype ComboboxGroupHeaderProps = {\n  label: string;\n  /** Names the surrounding `role=\"group\"` when nested; absent when windowed. */\n  id?: string;\n  /** The windowed listbox keeps its headers out of the accessibility tree. */\n  isPresentational?: boolean;\n};\n\n/**\n * The visible group header text, shared by both listbox paths: nested inside a\n * `role=\"group\"` wrapper below the row threshold, or as a presentational row of\n * its own while windowed.\n */\nconst GroupHeader = ({\n  label,\n  id,\n  isPresentational,\n}: ComboboxGroupHeaderProps) => {\n  return (\n    <div\n      id={id}\n      role={isPresentational === true ? 'presentation' : undefined}\n      className=\"ndl-combobox-group-header\"\n    >\n      {label}\n    </div>\n  );\n};\n\nconst Group = ({ children, label }: ComboboxGroupProps) => {\n  const headerId = useId();\n\n  return (\n    <div role=\"group\" aria-labelledby={headerId} className=\"ndl-combobox-group\">\n      <GroupHeader id={headerId} label={label} />\n      {children}\n    </div>\n  );\n};\n\nconst EmptyState = ({ children }: ComboboxEmptyStateProps) => {\n  return (\n    <Typography\n      variant=\"body-medium\"\n      className=\"ndl-combobox-empty-state\"\n      htmlAttributes={{ role: 'status' }}\n    >\n      {children ?? 'No results found'}\n    </Typography>\n  );\n};\n\nconst LoadingState = ({ children }: ComboboxEmptyStateProps) => {\n  return (\n    <div\n      role=\"status\"\n      className=\"ndl-combobox-empty-state ndl-combobox-loading-state\"\n    >\n      <LoadingSpinner size=\"small\" htmlAttributes={{ 'aria-hidden': true }} />\n      <Typography variant=\"body-medium\">\n        {children ?? DEFAULT_LOADING_MESSAGE}\n      </Typography>\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmxCU,MAAA,YAAA,CAAA,KAAA;;CAiUR;CACA;CACA;CACA;CACA;CACA;CACA;;AAz/CF,MAAM,6BAA6B;AACnC,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,kBAAkB;AACxB,MAAM,eAAe;CAAC;CAAa;CAAW;CAAS;AAAG;AAI1D,MAAM,+BAA+B;AAErC,MAAM,+BAA+B;AAIrC,MAAM,yBAAyB;AAG/B,MAAM,uBAAuB;AAM7B,MAAM,2BAA2B;;;;;;;;AAkBjC,MAAM,4BACJ,gBACG;CACH,MAAM,cAA6C,CAAC;CACpD,MAAM,qBAA+B,CAAC;CACtC,MAAM,cAAc,QAAiB;EACnC,mBAAmB,KAAK,YAAY,MAAM;EAC1C,YAAY,KAAK;GAAE,MAAM;GAAU;EAAI,CAAC;CAC1C;CAEA,YAAY,SAAS,SAAS;EAC5B,IAAI,cAAc,IAAI,GAAG;GACvB,YAAY,KAAK;IAAE,MAAM;IAAgB,OAAO,KAAK;GAAM,CAAC;GAC5D,KAAK,QAAQ,QAAQ,UAAU;GAC/B;EACF;EAEA,WAAW,IAAI;CACjB,CAAC;CAED,OAAO;EAAE;EAAa;CAAmB;AAC3C;AAEA,MAAa,YAA6D,EACxE,OACA,MACA,QACA,cACA,YACA,yBAAy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