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;0BACA;QACF,CAAA,GACA;QAAC;QAAY;QAAc,OAAO;KAAW;IAE/C,CAAA,GAAA,0BAAkB,EAAE,qBAAqB;IACzC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,UAAU;QACb,IAAI;QACJ,UAAU,KAAK,QAAQ;QACvB,kBAAkB;QAClB,QAAQ;IACV;IAEA,IAAI,cAAc;QAChB,uBAAuB;QACvB,UAAU;IAIZ;IAEA,qBACE,gFAGE,gCAAC;QAAI,OAAO;YAAC,UAAU;YAAY,OAAO;YAAG,QAAQ;QAAC;QAAG,OAAO,CAAA,GAAA,iBAAS,EAAE;qBACzE,gCAAC;QACC,eAAY;QACZ,KAAK;QACL,OAAO;YAAC,UAAU;YAAY,QAAQ;YAAG,OAAO;QAAC;SAGpD,aAAa,YAAY,QAAQ,kBAChC,gFAEE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,YAAY;QACjE,GAAG,WAAW;QACf,uEAAuE;QACvE,MAAK;QACL,KAAK;OACJ,YAAY,QAAQ;AAOjC","sources":["packages/react-aria-components/src/ListBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n  AriaListBoxOptions,\n  AriaListBoxProps,\n  useListBox,\n  useListBoxSection,\n  useOption\n} from 'react-aria/useListBox';\n\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  DEFAULT_SLOT,\n  dom,\n  DOMRenderProps,\n  PossibleLinkDOMRenderProps,\n  Provider,\n  RenderProps,\n  SlotProps,\n  StyleProps,\n  StyleRenderProps,\n  useContextProps,\n  useRenderProps,\n  useSlot\n} from './utils';\nimport {Collection} from 'react-aria/Collection';\nimport {\n  CollectionBuilder,\n  createBranchComponent,\n  createLeafComponent\n} from 'react-aria/CollectionBuilder';\nimport {\n  CollectionProps,\n  CollectionRendererContext,\n  ItemRenderProps,\n  SectionContext,\n  SectionProps\n} from './Collection';\nimport {\n  DragAndDropContext,\n  DropIndicatorContext,\n  DropIndicatorProps,\n  useDndPersistedKeys,\n  useRenderDropIndicator\n} from './DragAndDrop';\nimport {DragAndDropHooks} from './useDragAndDrop';\nimport {DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nimport {DraggableItemResult} from 'react-aria/useDraggableCollection';\nimport {DragPreviewRenderer} from '@react-types/shared';\nimport {DroppableCollectionResult, DroppableItemResult} from 'react-aria/useDroppableCollection';\nimport {DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {\n  FocusEvents,\n  forwardRefType,\n  GlobalDOMAttributes,\n  HoverEvents,\n  Key,\n  KeyboardEvents,\n  LinkDOMProps,\n  PressEvents,\n  RefObject\n} from '@react-types/shared';\nimport {FocusScope} from 'react-aria/FocusScope';\nimport {HeaderContext} from './Header';\nimport {inertValue} from 'react-aria/private/utils/inertValue';\nimport {ItemNode, LoaderNode, SectionNode} from 'react-aria/private/collections/BaseCollection';\nimport {ListKeyboardDelegate} from 'react-aria/ListKeyboardDelegate';\nimport {ListState, UNSTABLE_useFilteredListState, useListState} from 'react-stately/useListState';\nimport {\n  LoadMoreSentinelProps,\n  useLoadMoreSentinel\n} from 'react-aria/private/utils/useLoadMoreSentinel';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {Node, Orientation, SelectionBehavior} from '@react-types/shared';\nimport React, {\n  createContext,\n  ForwardedRef,\n  forwardRef,\n  JSX,\n  ReactNode,\n  useContext,\n  useEffect,\n  useMemo,\n  useRef\n} from 'react';\nimport {SelectableCollectionContext, SelectableCollectionContextValue} from './Autocomplete';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {SeparatorContext} from './Separator';\nimport {SharedElementTransition} from './SharedElementTransition';\nimport {TextContext} from './Text';\nimport {useCollator} from 'react-aria/useCollator';\nimport {useFocus} from 'react-aria/useFocus';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useKeyboard} from 'react-aria/useKeyboard';\nimport {useLocale} from 'react-aria/I18nProvider';\nimport {useObjectRef} from 'react-aria/useObjectRef';\n\nexport interface ListBoxRenderProps {\n  /**\n   * Whether the listbox has no items and should display its empty state.\n   *\n   * @selector [data-empty]\n   */\n  isEmpty: boolean;\n  /**\n   * Whether the listbox is currently focused.\n   *\n   * @selector [data-focused]\n   */\n  isFocused: boolean;\n  /**\n   * Whether the listbox is currently keyboard focused.\n   *\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean;\n  /**\n   * Whether the listbox is currently the active drop target.\n   *\n   * @selector [data-drop-target]\n   */\n  isDropTarget: boolean;\n  /**\n   * Whether the items are arranged in a stack or grid.\n   *\n   * @selector [data-layout=\"stack | grid\"]\n   */\n  layout: 'stack' | 'grid';\n  /**\n   * The primary orientation of the items.\n   *\n   * @selector [data-orientation=\"vertical | horizontal\"]\n   */\n  orientation: Orientation;\n  /**\n   * State of the listbox.\n   */\n  state: ListState<unknown>;\n}\n\nexport interface ListBoxProps<T>\n  extends\n    Omit<AriaListBoxProps<T>, 'children' | 'label'>,\n    CollectionProps<T>,\n    StyleRenderProps<ListBoxRenderProps>,\n    SlotProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-ListBox'\n   */\n  className?: ClassNameOrFunction<ListBoxRenderProps>;\n  /**\n   * How multiple selection should behave in the collection.\n   *\n   * @default 'toggle'\n   */\n  selectionBehavior?: SelectionBehavior;\n  /**\n   * The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for\n   * the ListBox.\n   */\n  dragAndDropHooks?: DragAndDropHooks<NoInfer<T>>;\n  /** Provides content to display when there are no items in the list. */\n  renderEmptyState?: (props: ListBoxRenderProps) => ReactNode;\n  /**\n   * Whether the items are arranged in a stack or grid.\n   *\n   * @default 'stack'\n   */\n  layout?: 'stack' | 'grid';\n  /**\n   * The primary orientation of the items. Usually this is the\n   * direction that the collection scrolls.\n   *\n   * @default 'vertical'\n   */\n  orientation?: Orientation;\n}\n\nexport const ListBoxContext = createContext<ContextValue<ListBoxProps<any>, HTMLDivElement>>(null);\nexport const ListStateContext = createContext<ListState<any> | null>(null);\n\n/**\n * A listbox displays a list of options and allows a user to select one or more of them.\n */\nexport const ListBox = /*#__PURE__*/ (forwardRef as forwardRefType)(function ListBox<T>(\n  props: ListBoxProps<T>,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  [props, ref] = useContextProps(props, ref, ListBoxContext);\n  let state = useContext(ListStateContext);\n\n  // The structure of ListBox is a bit strange because it needs to work inside other components like ComboBox and Select.\n  // Those components render two copies of their children so that the collection can be built even when the popover is closed.\n  // The first copy sends a collection document via context which we render the collection portal into.\n  // The second copy sends a ListState object via context which we use to render the ListBox without rebuilding the state.\n  // Otherwise, we have a standalone ListBox, so we need to create a collection and state ourselves.\n  if (state) {\n    return <ListBoxInner state={state} props={props} listBoxRef={ref} />;\n  }\n\n  return (\n    <CollectionBuilder content={<Collection {...props} />}>\n      {collection => <StandaloneListBox props={props} listBoxRef={ref} collection={collection} />}\n    </CollectionBuilder>\n  );\n});\n\nfunction StandaloneListBox({props, listBoxRef, collection}) {\n  props = {...props, collection, children: null, items: null};\n  let {layoutDelegate} = useContext(CollectionRendererContext);\n  let state = useListState({...props, layoutDelegate});\n  return <ListBoxInner state={state} props={props} listBoxRef={listBoxRef} />;\n}\n\ninterface ListBoxInnerProps<T> {\n  state: ListState<T>;\n  props: ListBoxProps<T> &\n    AriaListBoxOptions<T> & {filter?: SelectableCollectionContextValue<T>['filter']};\n  listBoxRef: RefObject<HTMLElement | null>;\n}\n\nfunction ListBoxInner<T>({state: inputState, props, listBoxRef}: ListBoxInnerProps<T>) {\n  [props, listBoxRef] = useContextProps(props, listBoxRef, SelectableCollectionContext);\n  let {dragAndDropHooks, layout = 'stack', orientation = 'vertical', filter} = props;\n  let state = UNSTABLE_useFilteredListState(inputState, filter);\n  let {collection, selectionManager} = state;\n  let isListDraggable = !!dragAndDropHooks?.useDraggableCollectionState;\n  let isListDroppable = !!dragAndDropHooks?.useDroppableCollectionState;\n  let {direction} = useLocale();\n  let {disabledBehavior, disabledKeys} = selectionManager;\n  let collator = useCollator({usage: 'search', sensitivity: 'base'});\n  let {\n    isVirtualized,\n    layoutDelegate,\n    dropTargetDelegate: ctxDropTargetDelegate,\n    CollectionRoot\n  } = useContext(CollectionRendererContext);\n  let keyboardDelegate = useMemo(\n    () =>\n      props.keyboardDelegate ||\n      new ListKeyboardDelegate({\n        collection,\n        collator,\n        ref: listBoxRef,\n        disabledKeys,\n        disabledBehavior,\n        layout,\n        orientation,\n        direction,\n        layoutDelegate\n      }),\n    [\n      collection,\n      collator,\n      listBoxRef,\n      disabledBehavior,\n      disabledKeys,\n      orientation,\n      direction,\n      props.keyboardDelegate,\n      layout,\n      layoutDelegate\n    ]\n  );\n\n  let {listBoxProps} = useListBox(\n    {\n      ...props,\n      shouldSelectOnPressUp: isListDraggable || props.shouldSelectOnPressUp,\n      keyboardDelegate,\n      isVirtualized\n    },\n    state,\n    listBoxRef\n  );\n\n  let dragHooksProvided = useRef(isListDraggable);\n  let dropHooksProvided = useRef(isListDroppable);\n  useEffect(() => {\n    if (process.env.NODE_ENV === 'production') {\n      return;\n    }\n    if (dragHooksProvided.current !== isListDraggable) {\n      console.warn(\n        'Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.'\n      );\n    }\n    if (dropHooksProvided.current !== isListDroppable) {\n      console.warn(\n        'Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.'\n      );\n    }\n  }, [isListDraggable, isListDroppable]);\n\n  let dragState: DraggableCollectionState | undefined = undefined;\n  let dropState: DroppableCollectionState | undefined = undefined;\n  let droppableCollection: DroppableCollectionResult | undefined = undefined;\n  let isRootDropTarget = false;\n  let dragPreview: JSX.Element | null = null;\n  let preview = useRef<DragPreviewRenderer>(null);\n\n  if (isListDraggable && dragAndDropHooks) {\n    dragState = dragAndDropHooks.useDraggableCollectionState!({\n      collection,\n      selectionManager,\n      preview: dragAndDropHooks.renderDragPreview ? preview : undefined\n    });\n    dragAndDropHooks.useDraggableCollection!({}, dragState, listBoxRef);\n\n    let DragPreview = dragAndDropHooks.DragPreview!;\n    dragPreview = dragAndDropHooks.renderDragPreview ? (\n      <DragPreview ref={preview}>{dragAndDropHooks.renderDragPreview}</DragPreview>\n    ) : null;\n  }\n\n  if (isListDroppable && dragAndDropHooks) {\n    dropState = dragAndDropHooks.useDroppableCollectionState!({\n      collection,\n      selectionManager\n    });\n\n    let dropTargetDelegate =\n      dragAndDropHooks.dropTargetDelegate ||\n      ctxDropTargetDelegate ||\n      new dragAndDropHooks.ListDropTargetDelegate(collection, listBoxRef, {\n        orientation,\n        layout,\n        direction\n      });\n    droppableCollection = dragAndDropHooks.useDroppableCollection!(\n      {\n        keyboardDelegate,\n        dropTargetDelegate\n      },\n      dropState,\n      listBoxRef\n    );\n\n    isRootDropTarget = dropState.isDropTarget({type: 'root'});\n  }\n\n  let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n  let isEmpty = state.collection.size === 0;\n  let renderValues = {\n    isDropTarget: isRootDropTarget,\n    isEmpty,\n    isFocused,\n    isFocusVisible,\n    layout: props.layout || 'stack',\n    orientation,\n    state\n  };\n  let renderProps = useRenderProps({\n    ...props,\n    children: undefined,\n    defaultClassName: 'react-aria-ListBox',\n    values: renderValues\n  });\n\n  let emptyState: JSX.Element | null = null;\n  if (isEmpty && props.renderEmptyState) {\n    emptyState = (\n      <div\n        // eslint-disable-next-line\n        role=\"option\"\n        style={{display: 'contents'}}>\n        {props.renderEmptyState(renderValues)}\n      </div>\n    );\n  }\n\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <FocusScope>\n      <dom.div\n        {...mergeProps(\n          DOMProps,\n          renderProps,\n          listBoxProps,\n          focusProps,\n          droppableCollection?.collectionProps\n        )}\n        ref={listBoxRef as RefObject<HTMLDivElement>}\n        slot={props.slot || undefined}\n        onScroll={props.onScroll}\n        data-drop-target={isRootDropTarget || undefined}\n        data-empty={isEmpty || undefined}\n        data-focused={isFocused || undefined}\n        data-focus-visible={isFocusVisible || undefined}\n        data-layout={props.layout || 'stack'}\n        data-orientation={orientation}>\n        <Provider\n          values={[\n            [ListBoxContext, props],\n            [ListStateContext, state],\n            [DragAndDropContext, {dragAndDropHooks, dragState, dropState}],\n            [SeparatorContext, {elementType: 'div'}],\n            [DropIndicatorContext, {render: ListBoxDropIndicatorWrapper}],\n            [SectionContext, {name: 'ListBoxSection', render: ListBoxSectionInner}]\n          ]}>\n          <SharedElementTransition>\n            <CollectionRoot\n              collection={collection}\n              scrollRef={listBoxRef}\n              persistedKeys={useDndPersistedKeys(selectionManager, dragAndDropHooks, dropState)}\n              renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)}\n            />\n          </SharedElementTransition>\n        </Provider>\n        {emptyState}\n        {dragPreview}\n      </dom.div>\n    </FocusScope>\n  );\n}\n\nexport interface ListBoxSectionProps<T>\n  extends SectionProps<T>, DOMRenderProps<'section', undefined> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element.\n   *\n   * @default 'react-aria-ListBoxSection'\n   */\n  className?: string;\n}\n\nfunction ListBoxSectionInner<T>(\n  props: ListBoxSectionProps<T>,\n  ref: ForwardedRef<HTMLElement>,\n  section: Node<T>,\n  className = 'react-aria-ListBoxSection'\n) {\n  let state = useContext(ListStateContext)!;\n  let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n  let {CollectionBranch} = useContext(CollectionRendererContext);\n  let [headingRef, heading] = useSlot();\n  let {headingProps, groupProps} = useListBoxSection({\n    heading,\n    'aria-label': props['aria-label'] ?? undefined\n  });\n  let renderProps = useRenderProps({\n    ...props,\n    id: undefined,\n    children: undefined,\n    defaultClassName: className,\n    values: undefined\n  });\n\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <dom.section {...mergeProps(DOMProps, renderProps, groupProps)} ref={ref}>\n      <HeaderContext.Provider value={{...headingProps, ref: headingRef}}>\n        <CollectionBranch\n          collection={state.collection}\n          parent={section}\n          renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)}\n        />\n      </HeaderContext.Provider>\n    </dom.section>\n  );\n}\n\n/**\n * A ListBoxSection represents a section within a ListBox.\n */\nexport const ListBoxSection = /*#__PURE__*/ createBranchComponent(SectionNode, ListBoxSectionInner);\n\nexport interface ListBoxItemRenderProps extends ItemRenderProps {}\n\nexport interface ListBoxItemProps<T = object>\n  extends\n    Omit<RenderProps<ListBoxItemRenderProps>, 'render'>,\n    PossibleLinkDOMRenderProps<'div', ListBoxItemRenderProps>,\n    LinkDOMProps,\n    HoverEvents,\n    PressEvents,\n    KeyboardEvents,\n    FocusEvents<HTMLDivElement>,\n    Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-ListBoxItem'\n   */\n  className?: ClassNameOrFunction<ListBoxItemRenderProps>;\n  /** The unique id of the item. */\n  id?: Key;\n  /**\n   * The object value that this item represents. When using dynamic collections, this is set\n   * automatically.\n   */\n  value?: T;\n  /** A string representation of the item's contents, used for features like typeahead. */\n  textValue?: string;\n  /** An accessibility label for this item. */\n  'aria-label'?: string;\n  /** Whether the item is disabled. */\n  isDisabled?: boolean;\n  /**\n   * Handler that is called when a user performs an action on the item. The exact user event depends\n   * on the collection's `selectionBehavior` prop and the interaction modality.\n   */\n  onAction?: () => void;\n}\n\n/**\n * A ListBoxItem represents an individual option in a ListBox.\n */\nexport const ListBoxItem = /*#__PURE__*/ createLeafComponent(ItemNode, function ListBoxItem<\n  T\n>(props: ListBoxItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n  let ref = useObjectRef<any>(forwardedRef);\n  let state = useContext(ListStateContext)!;\n  let {dragAndDropHooks, dragState, dropState} = useContext(DragAndDropContext)!;\n  let isDraggable =\n    dragState && !(dragState.isDisabled || dragState.selectionManager.isDisabled(item.key));\n  let {optionProps, labelProps, descriptionProps, ...states} = useOption(\n    {key: item.key, 'aria-label': props?.['aria-label']},\n    state,\n    ref\n  );\n\n  let {hoverProps, isHovered} = useHover({\n    isDisabled: !states.allowsSelection && !states.hasAction && !isDraggable,\n    onHoverStart: item.props.onHoverStart,\n    onHoverChange: item.props.onHoverChange,\n    onHoverEnd: item.props.onHoverEnd\n  });\n\n  let {keyboardProps} = useKeyboard(props);\n  let {focusProps} = useFocus(props);\n\n  let draggableItem: DraggableItemResult | null = null;\n  if (dragState && dragAndDropHooks) {\n    draggableItem = dragAndDropHooks.useDraggableItem!(\n      {key: item.key, hasAction: states.hasAction},\n      dragState\n    );\n  }\n\n  let droppableItem: DroppableItemResult | null = null;\n  if (dropState && dragAndDropHooks) {\n    droppableItem = dragAndDropHooks.useDroppableItem!(\n      {\n        target: {type: 'item', key: item.key, dropPosition: 'on'}\n      },\n      dropState,\n      ref\n    );\n  }\n\n  let isDragging = dragState && dragState.isDragging(item.key);\n  let renderProps = useRenderProps<ListBoxItemRenderProps, any>({\n    ...props,\n    id: undefined,\n    children: props.children,\n    defaultClassName: 'react-aria-ListBoxItem',\n    values: {\n      ...states,\n      isHovered,\n      selectionMode: state.selectionManager.selectionMode,\n      selectionBehavior: state.selectionManager.selectionBehavior,\n      allowsDragging: !!dragState,\n      isDragging,\n      isDropTarget: droppableItem?.isDropTarget\n    }\n  });\n\n  useEffect(() => {\n    if (!item.textValue && process.env.NODE_ENV !== 'production') {\n      console.warn(\n        'A `textValue` prop is required for <ListBoxItem> elements with non-plain text children in order to support accessibility features such as type to select.'\n      );\n    }\n  }, [item.textValue]);\n\n  let ElementType = props.href ? dom.a : dom.div;\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n  delete DOMProps.onClick;\n\n  if (props.href && optionProps.tabIndex == null) {\n    optionProps.tabIndex = -1;\n  }\n\n  return (\n    <ElementType\n      {...mergeProps(\n        DOMProps,\n        renderProps,\n        optionProps,\n        hoverProps,\n        keyboardProps,\n        focusProps,\n        draggableItem?.dragProps,\n        droppableItem?.dropProps\n      )}\n      ref={ref}\n      data-allows-dragging={!!dragState || undefined}\n      data-selected={states.isSelected || undefined}\n      data-disabled={states.isDisabled || undefined}\n      data-hovered={isHovered || undefined}\n      data-focused={states.isFocused || undefined}\n      data-focus-visible={states.isFocusVisible || undefined}\n      data-pressed={states.isPressed || undefined}\n      data-dragging={isDragging || undefined}\n      data-drop-target={droppableItem?.isDropTarget || undefined}\n      data-selection-mode={\n        state.selectionManager.selectionMode === 'none'\n          ? undefined\n          : state.selectionManager.selectionMode\n      }>\n      <Provider\n        values={[\n          [\n            TextContext,\n            {\n              slots: {\n                [DEFAULT_SLOT]: labelProps,\n                label: labelProps,\n                description: descriptionProps\n              }\n            }\n          ],\n          [SelectionIndicatorContext, {isSelected: states.isSelected}]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </ElementType>\n  );\n});\n\nfunction ListBoxDropIndicatorWrapper(props: DropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n  ref = useObjectRef(ref);\n  let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n  let {dropIndicatorProps, isHidden, isDropTarget} = dragAndDropHooks!.useDropIndicator!(\n    props,\n    dropState!,\n    ref\n  );\n\n  if (isHidden) {\n    return null;\n  }\n\n  return (\n    <ListBoxDropIndicatorForwardRef\n      {...props}\n      dropIndicatorProps={dropIndicatorProps}\n      isDropTarget={isDropTarget}\n      ref={ref}\n    />\n  );\n}\n\ninterface ListBoxDropIndicatorProps extends DropIndicatorProps {\n  dropIndicatorProps: React.HTMLAttributes<HTMLElement>;\n  isDropTarget: boolean;\n}\n\nfunction ListBoxDropIndicator(props: ListBoxDropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n  let {dropIndicatorProps, isDropTarget, ...otherProps} = props;\n\n  let renderProps = useRenderProps({\n    ...otherProps,\n    defaultClassName: 'react-aria-DropIndicator',\n    values: {\n      isDropTarget\n    }\n  });\n\n  return (\n    <>\n      {/* oxlint-disable jsx-a11y/role-has-required-aria-props -- drop indicator is not selectable */}\n      <dom.div\n        {...dropIndicatorProps}\n        {...renderProps}\n        role=\"option\"\n        ref={ref as RefObject<HTMLDivElement | null>}\n        data-drop-target={isDropTarget || undefined}\n      />\n      {/* oxlint-enable jsx-a11y/role-has-required-aria-props */}\n    </>\n  );\n}\n\nconst ListBoxDropIndicatorForwardRef = forwardRef(ListBoxDropIndicator);\n\nexport interface ListBoxLoadMoreItemProps\n  extends\n    Omit<LoadMoreSentinelProps, 'collection'>,\n    StyleProps,\n    DOMRenderProps<'div', undefined>,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element.\n   *\n   * @default 'react-aria-ListBoxLoadMoreItem'\n   */\n  className?: string;\n  /**\n   * The load more spinner to render when loading additional items.\n   */\n  children?: ReactNode;\n  /**\n   * Whether or not the loading spinner should be rendered or not.\n   */\n  isLoading?: boolean;\n}\n\nexport const ListBoxLoadMoreItem = createLeafComponent(\n  LoaderNode,\n  function ListBoxLoadingIndicator(\n    props: ListBoxLoadMoreItemProps,\n    ref: ForwardedRef<HTMLDivElement>,\n    item: Node<object>\n  ) {\n    let state = useContext(ListStateContext)!;\n    let {isLoading, onLoadMore, scrollOffset, ...otherProps} = props;\n\n    let sentinelRef = useRef<HTMLDivElement>(null);\n    let memoedLoadMoreProps = useMemo(\n      () => ({\n        onLoadMore,\n        collection: state?.collection,\n        sentinelRef,\n        scrollOffset\n      }),\n      [onLoadMore, scrollOffset, state?.collection]\n    );\n    useLoadMoreSentinel(memoedLoadMoreProps, sentinelRef);\n    let renderProps = useRenderProps({\n      ...otherProps,\n      id: undefined,\n      children: item.rendered,\n      defaultClassName: 'react-aria-ListBoxLoadingIndicator',\n      values: undefined\n    });\n\n    let optionProps = {\n      // For Android talkback\n      tabIndex: -1\n      // For now don't include aria-posinset and aria-setsize on loader since they aren't keyboard focusable\n      // Arguably shouldn't include them ever since it might be confusing to the user to include the loaders as part of the\n      // item count\n    };\n\n    return (\n      <>\n        {/* Alway render the sentinel. For now onus is on the user for styling when using flex + gap (this would introduce a gap even though it doesn't take room) */}\n        {/* @ts-ignore - compatibility with React < 19 */}\n        <div style={{position: 'relative', width: 0, height: 0}} inert={inertValue(true)}>\n          <div\n            data-testid=\"loadMoreSentinel\"\n            ref={sentinelRef}\n            style={{position: 'absolute', height: 1, width: 1}}\n          />\n        </div>\n        {isLoading && renderProps.children && (\n          <>\n            {/* oxlint-disable jsx-a11y/role-has-required-aria-props -- loader row is not selectable */}\n            <dom.div\n              {...mergeProps(filterDOMProps(props, {global: true}), optionProps)}\n              {...renderProps}\n              // aria-selected isn't needed here since this option is not selectable.\n              role=\"option\"\n              ref={ref as ForwardedRef<HTMLDivElement>}>\n              {renderProps.children}\n            </dom.div>\n            {/* oxlint-enable jsx-a11y/role-has-required-aria-props */}\n          </>\n        )}\n      </>\n    );\n  }\n);\n"],"names":[],"version":3,"file":"ListBox.mjs.map"}