@bazza-ui/react 0.0.0 → 0.1.0-canary.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/ListboxStore-BYBpGrOz.d.ts +453 -0
  2. package/dist/ListboxStore-nmorsoqX.d.cts +453 -0
  3. package/dist/chunk-4C666HHU.js +2 -0
  4. package/dist/chunk-4C666HHU.js.map +1 -0
  5. package/dist/chunk-5T5B5SPR.cjs +2 -0
  6. package/dist/chunk-5T5B5SPR.cjs.map +1 -0
  7. package/dist/chunk-A4Z5BY7H.js +2 -0
  8. package/dist/chunk-A4Z5BY7H.js.map +1 -0
  9. package/dist/chunk-BFOY762U.js +2 -0
  10. package/dist/chunk-BFOY762U.js.map +1 -0
  11. package/dist/chunk-IT372NHF.js +2 -0
  12. package/dist/chunk-IT372NHF.js.map +1 -0
  13. package/dist/chunk-JFEVUUPC.cjs +2 -0
  14. package/dist/chunk-JFEVUUPC.cjs.map +1 -0
  15. package/dist/chunk-KO3DXT3Y.js +2 -0
  16. package/dist/chunk-KO3DXT3Y.js.map +1 -0
  17. package/dist/chunk-LXXK4S4Q.js +2 -0
  18. package/dist/chunk-LXXK4S4Q.js.map +1 -0
  19. package/dist/chunk-M4G6J7DP.cjs +2 -0
  20. package/dist/chunk-M4G6J7DP.cjs.map +1 -0
  21. package/dist/chunk-SCDHQZFI.cjs +2 -0
  22. package/dist/chunk-SCDHQZFI.cjs.map +1 -0
  23. package/dist/chunk-W4ACKMIZ.cjs +2 -0
  24. package/dist/chunk-W4ACKMIZ.cjs.map +1 -0
  25. package/dist/chunk-XMZZ62VJ.cjs +2 -0
  26. package/dist/chunk-XMZZ62VJ.cjs.map +1 -0
  27. package/dist/combobox/index.cjs +2 -0
  28. package/dist/combobox/index.cjs.map +1 -0
  29. package/dist/combobox/index.d.cts +1066 -0
  30. package/dist/combobox/index.d.ts +1066 -0
  31. package/dist/combobox/index.js +2 -0
  32. package/dist/combobox/index.js.map +1 -0
  33. package/dist/command-menu/index.cjs +2 -0
  34. package/dist/command-menu/index.cjs.map +1 -0
  35. package/dist/command-menu/index.d.cts +154 -0
  36. package/dist/command-menu/index.d.ts +154 -0
  37. package/dist/command-menu/index.js +2 -0
  38. package/dist/command-menu/index.js.map +1 -0
  39. package/dist/command-score-CTJ9NV6n.d.cts +23 -0
  40. package/dist/command-score-CTJ9NV6n.d.ts +23 -0
  41. package/dist/context-menu/index.cjs +2 -0
  42. package/dist/context-menu/index.cjs.map +1 -0
  43. package/dist/context-menu/index.d.cts +672 -0
  44. package/dist/context-menu/index.d.ts +672 -0
  45. package/dist/context-menu/index.js +2 -0
  46. package/dist/context-menu/index.js.map +1 -0
  47. package/dist/dropdown-menu/index.cjs +2 -0
  48. package/dist/dropdown-menu/index.cjs.map +1 -0
  49. package/dist/dropdown-menu/index.d.cts +699 -0
  50. package/dist/dropdown-menu/index.d.ts +699 -0
  51. package/dist/dropdown-menu/index.js +2 -0
  52. package/dist/dropdown-menu/index.js.map +1 -0
  53. package/dist/events-DOGItflK.d.ts +1776 -0
  54. package/dist/events-DPsuhBln.d.cts +1776 -0
  55. package/dist/input-C95v6jB0.d.cts +46 -0
  56. package/dist/input-CYweYB_i.d.ts +46 -0
  57. package/dist/internal/listbox/index.cjs +2 -0
  58. package/dist/internal/listbox/index.cjs.map +1 -0
  59. package/dist/internal/listbox/index.d.cts +272 -0
  60. package/dist/internal/listbox/index.d.ts +272 -0
  61. package/dist/internal/listbox/index.js +2 -0
  62. package/dist/internal/listbox/index.js.map +1 -0
  63. package/dist/internal/popup-menu/index.cjs +2 -0
  64. package/dist/internal/popup-menu/index.cjs.map +1 -0
  65. package/dist/internal/popup-menu/index.d.cts +238 -0
  66. package/dist/internal/popup-menu/index.d.ts +238 -0
  67. package/dist/internal/popup-menu/index.js +2 -0
  68. package/dist/internal/popup-menu/index.js.map +1 -0
  69. package/dist/items-B6HeFO_8.d.cts +37 -0
  70. package/dist/items-B6HeFO_8.d.ts +37 -0
  71. package/dist/kbd/index.cjs +2 -0
  72. package/dist/kbd/index.cjs.map +1 -0
  73. package/dist/kbd/index.d.cts +61 -0
  74. package/dist/kbd/index.d.ts +61 -0
  75. package/dist/kbd/index.js +2 -0
  76. package/dist/kbd/index.js.map +1 -0
  77. package/dist/loaders/index.cjs +2 -0
  78. package/dist/loaders/index.cjs.map +1 -0
  79. package/dist/loaders/index.d.cts +363 -0
  80. package/dist/loaders/index.d.ts +363 -0
  81. package/dist/loaders/index.js +2 -0
  82. package/dist/loaders/index.js.map +1 -0
  83. package/dist/loading-C6WZGUc3.d.cts +29 -0
  84. package/dist/loading-CC4n55sR.d.ts +29 -0
  85. package/dist/resolve-BYm41YfG.d.ts +406 -0
  86. package/dist/resolve-Dk_fAKb2.d.cts +406 -0
  87. package/dist/scroll-arrow-B81wZTZ2.d.cts +544 -0
  88. package/dist/scroll-arrow-CNd0tgME.d.ts +544 -0
  89. package/dist/select/index.cjs +2 -0
  90. package/dist/select/index.cjs.map +1 -0
  91. package/dist/select/index.d.cts +985 -0
  92. package/dist/select/index.d.ts +985 -0
  93. package/dist/select/index.js +2 -0
  94. package/dist/select/index.js.map +1 -0
  95. package/dist/separator-BiySI623.d.cts +275 -0
  96. package/dist/separator-De8l8DKO.d.ts +275 -0
  97. package/dist/surface-context-ClmxshBW.d.ts +14 -0
  98. package/dist/surface-context-DF-L-30G.d.cts +14 -0
  99. package/dist/type-guards-BC2B6bVi.d.cts +350 -0
  100. package/dist/type-guards-ybcHBB3C.d.ts +350 -0
  101. package/dist/types-DT4FOOa2.d.cts +51 -0
  102. package/dist/types-DT4FOOa2.d.ts +51 -0
  103. package/dist/use-listbox-item-NzZuY34-.d.cts +212 -0
  104. package/dist/use-listbox-item-NzZuY34-.d.ts +212 -0
  105. package/dist/video-player/index.cjs +3 -0
  106. package/dist/video-player/index.cjs.map +1 -0
  107. package/dist/video-player/index.d.cts +1391 -0
  108. package/dist/video-player/index.d.ts +1391 -0
  109. package/dist/video-player/index.js +3 -0
  110. package/dist/video-player/index.js.map +1 -0
  111. package/package.json +66 -12
  112. package/dist/index.d.ts +0 -2
  113. package/dist/index.js +0 -2
@@ -0,0 +1,453 @@
1
+ import { ReactStore } from '@base-ui/utils/store';
2
+ import { aW as PopupMenuOpenChangeEventDetails, aS as HighlightChangeEventDetails, aU as PopupMenuOpenChangeReason } from './events-DPsuhBln.cjs';
3
+
4
+ /**
5
+ * How a popup/menu was opened. Mirrors Base UI's `openMethod`.
6
+ * `'keyboard'` covers any non-pointer activation.
7
+ */
8
+ type OpenMethod = 'mouse' | 'touch' | 'pen' | 'keyboard';
9
+
10
+ type FilterFn = (value: string, search: string, keywords?: string[]) => number;
11
+ type SearchNormalizer = (search: string) => string;
12
+ interface ItemRegistration {
13
+ value: string;
14
+ keywords?: string[];
15
+ groupId?: string;
16
+ disabled?: boolean;
17
+ /** Lower values are sorted earlier in score-based lists. */
18
+ forceOrder?: number;
19
+ /** Overrides computed fuzzy score in score-based lists. */
20
+ forceScore?: number;
21
+ /** Whether this item is a submenu trigger */
22
+ isSubmenuTrigger?: boolean;
23
+ /** Single character keyboard shortcut to trigger this item */
24
+ shortcut?: string;
25
+ /** Whether selecting this item should close the menu (default: true) */
26
+ closeOnClick?: boolean;
27
+ /** Whether this item can be activated via Enter/click (default: true). Non-activatable items remain highlightable. */
28
+ activatable?: boolean;
29
+ }
30
+ /** Kinds of rows that participate in positional attributes. */
31
+ type ListboxRowKind = 'item' | 'group' | 'separator' | 'empty' | 'loading';
32
+ /** A mounted row tracked for positional attributes, in DOM order. */
33
+ interface ListboxOrderedRow {
34
+ /** Unique row id (stable per component instance). */
35
+ id: string;
36
+ kind: ListboxRowKind;
37
+ /** Set for option-like rows rendered inside a Group/RadioGroup. */
38
+ groupId?: string;
39
+ }
40
+ /**
41
+ * Pre-registered item for virtualization.
42
+ * This allows the store to know about all items even when they're not mounted.
43
+ * The `value` field serves as both the unique identifier and the filtering value.
44
+ */
45
+ interface VirtualItem {
46
+ /** Value used as unique identifier and for filtering/matching */
47
+ value: string;
48
+ /** Additional keywords for filtering */
49
+ keywords?: string[];
50
+ /** Whether the item is disabled */
51
+ disabled?: boolean;
52
+ }
53
+ type HighlightSource = 'keyboard' | 'pointer' | 'auto' | null;
54
+ /**
55
+ * Describes why the consumer updated ordered items when filter={false}.
56
+ * - `replace`: list was re-ordered/replaced (default)
57
+ * - `append`: new items were appended to the end while preserving existing order
58
+ */
59
+ type OrderedItemsUpdateReason = 'replace' | 'append';
60
+ interface SetOrderedItemsOptions {
61
+ /** Why ordered items were updated. @default 'replace' */
62
+ reason?: OrderedItemsUpdateReason;
63
+ }
64
+ /**
65
+ * Refs for DOM elements used for scroll behavior.
66
+ * These are stored outside of reactive state to avoid unnecessary re-renders.
67
+ */
68
+ interface DOMRefs {
69
+ /** Ref to the semantic listbox element */
70
+ listRef: React.RefObject<HTMLElement | null>;
71
+ /** Ref to the element that owns the list's scroll position */
72
+ listScrollContainerRef: React.RefObject<HTMLElement | null>;
73
+ /** Ref to the popup (visual container) element */
74
+ popupRef: React.RefObject<HTMLElement | null>;
75
+ /** Map of item ID to ref for the item's DOM element */
76
+ itemRefs: Map<string, React.RefObject<HTMLElement | null>>;
77
+ /** Map of group ID to ref for the group's DOM element */
78
+ groupRefs: Map<string, React.RefObject<HTMLElement | null>>;
79
+ }
80
+ interface ListboxState {
81
+ /** Whether the listbox is open internally when uncontrolled */
82
+ open: boolean;
83
+ /** Controlled open prop. When defined, selectors resolve this over `open`. */
84
+ openProp: boolean | undefined;
85
+ /**
86
+ * How the listbox was most recently opened (`mouse`/`touch`/`pen`/`keyboard`).
87
+ * `null` until first opened. Retained after close (only updated on open).
88
+ */
89
+ openMethod: OpenMethod | null;
90
+ /** Current internal search query when uncontrolled */
91
+ search: string;
92
+ /** Controlled search prop. When defined, selectors resolve this over `search`. */
93
+ searchProp: string | undefined;
94
+ /** Normalized search query used for filtering and visibility checks */
95
+ normalizedSearch: string;
96
+ /** Currently highlighted item ID */
97
+ highlightedId: string | null;
98
+ /** Source of the current highlight (keyboard or pointer) */
99
+ highlightSource: HighlightSource;
100
+ /** Whether an Input is present in the Surface */
101
+ hasInput: boolean;
102
+ /** Whether the input is currently active (rendered) when hideUntilActive mode is used */
103
+ inputActive: boolean;
104
+ /** Pending search character typed before input was active */
105
+ pendingSearch: string;
106
+ /** Filtered results: item ID to score */
107
+ filteredItems: Map<string, number>;
108
+ /** Groups that have at least one visible item */
109
+ visibleGroups: Set<string>;
110
+ /** Count of visible items */
111
+ filteredCount: number;
112
+ /** Counter to trigger re-filtering when items change */
113
+ filterTrigger: number;
114
+ /** Whether virtualization mode is enabled */
115
+ virtualized: boolean;
116
+ /** Count of virtual items (from items prop) */
117
+ virtualItemsCount: number;
118
+ /**
119
+ * Rows currently mounted in the DOM, sorted by document position.
120
+ * Mounted ⇔ visible, so this is the list of visible rows.
121
+ * Immutable: replaced wholesale on every registry change so selectors recompute.
122
+ */
123
+ orderedRows: readonly ListboxOrderedRow[];
124
+ }
125
+ interface ListboxContext {
126
+ /** Filter function or false to disable filtering */
127
+ filter: FilterFn | false;
128
+ /** Function used to normalize search before filtering. */
129
+ normalizeSearch: SearchNormalizer;
130
+ /** Whether to loop navigation */
131
+ loop: boolean;
132
+ /**
133
+ * Controls auto-highlighting behavior when the menu opens.
134
+ * - `true`: highlight the first item (default)
135
+ * - `false`: don't auto-highlight any item
136
+ * - `string`: highlight the item with this specific value
137
+ */
138
+ autoHighlightFirst: boolean | string;
139
+ /**
140
+ * Whether to clear search on close.
141
+ * - `true`: clear immediately when menu closes (default)
142
+ * - `false`: preserve search when menu closes
143
+ * - `'after-exit'`: clear after exit animation completes (requires Surface to call clearSearch)
144
+ */
145
+ clearSearchOnClose: boolean | 'after-exit';
146
+ /** Whether to reset list scroll position when search changes. */
147
+ resetScrollOnSearch: boolean;
148
+ /** Whether hideUntilActive mode is enabled */
149
+ hideUntilActive: boolean;
150
+ /** ID for the list element (for aria-activedescendant) */
151
+ listId: string;
152
+ /** ID for the input element */
153
+ inputId: string;
154
+ /** Map of item ID to registration data */
155
+ readonly items: Map<string, ItemRegistration>;
156
+ /** Map of group ID to set of item IDs */
157
+ readonly groups: Map<string, Set<string>>;
158
+ /** Map of item ID to onSelect callback */
159
+ readonly itemSelects: Map<string, () => void>;
160
+ /** Map of submenu trigger ID to open callback */
161
+ readonly submenuOpens: Map<string, () => void>;
162
+ /** Map of submenu trigger ID to close callback */
163
+ readonly submenuCloses: Map<string, () => void>;
164
+ /** Map of shortcut key to item ID */
165
+ readonly shortcuts: Map<string, string>;
166
+ /** Map of row ID to its mounted DOM element (positional registry). */
167
+ readonly rowElements: Map<string, HTMLElement>;
168
+ /**
169
+ * Callback when open state changes.
170
+ * The second parameter contains event details including the reason for the change.
171
+ */
172
+ onOpenChange: (open: boolean, eventDetails: PopupMenuOpenChangeEventDetails) => void;
173
+ /** Callback when search state changes */
174
+ onSearchChange: ((search: string) => void) | undefined;
175
+ /**
176
+ * Pre-registered items for virtualization.
177
+ * When provided, navigation uses this array order instead of DOM registration order.
178
+ */
179
+ virtualItems: VirtualItem[];
180
+ /**
181
+ * Consumer-provided ordered list of item values when filter={false}.
182
+ * Used to determine correct navigation/highlight order when consumer handles filtering externally.
183
+ * Must always be provided when filter={false}.
184
+ */
185
+ orderedItems: string[];
186
+ /**
187
+ * Callback when highlighted item changes.
188
+ * Useful for synchronizing with virtualizers (scrollToIndex) and other UI state.
189
+ * The third parameter contains event details including the reason for the change.
190
+ */
191
+ onHighlightChange: ((id: string | null, index: number, eventDetails: HighlightChangeEventDetails) => void) | undefined;
192
+ /**
193
+ * DOM refs for scroll behavior.
194
+ * Stored in context (not state) to avoid re-renders.
195
+ */
196
+ refs: DOMRefs;
197
+ /**
198
+ * Callback when menu close animation completes.
199
+ * Used for resetting row width measurements.
200
+ */
201
+ onCloseComplete?: () => void;
202
+ /**
203
+ * Callback when popup close transition completes.
204
+ * Used by popup-layer features that should reset only after exit animations.
205
+ */
206
+ onPopupCloseComplete?: () => void;
207
+ /**
208
+ * Last known pointer position for detecting actual pointer movement.
209
+ * Used to prevent "phantom" highlights when content shifts under a stationary pointer.
210
+ */
211
+ lastPointerPosition: {
212
+ x: number;
213
+ y: number;
214
+ } | null;
215
+ }
216
+ declare const selectors: {
217
+ open: (state: ListboxState) => boolean;
218
+ openMethod: (state: ListboxState) => OpenMethod | null;
219
+ search: (state: ListboxState) => string;
220
+ normalizedSearch: (state: ListboxState) => string;
221
+ highlightedId: (state: ListboxState) => string | null;
222
+ highlightSource: (state: ListboxState) => HighlightSource;
223
+ hasInput: (state: ListboxState) => boolean;
224
+ inputActive: (state: ListboxState) => boolean;
225
+ pendingSearch: (state: ListboxState) => string;
226
+ filteredCount: (state: ListboxState) => number;
227
+ filteredItems: (state: ListboxState) => Map<string, number>;
228
+ visibleGroups: (state: ListboxState) => Set<string>;
229
+ virtualized: (state: ListboxState) => boolean;
230
+ isHighlighted: (state: ListboxState, itemId: string) => boolean;
231
+ isGroupVisible: (state: ListboxState, groupId: string) => boolean;
232
+ isFirstRow: (state: ListboxState, rowId: string) => boolean;
233
+ isLastRow: (state: ListboxState, rowId: string) => boolean;
234
+ isFirstGroup: (state: ListboxState, rowId: string) => boolean;
235
+ isLastGroup: (state: ListboxState, rowId: string) => boolean;
236
+ isFirstInGroup: (state: ListboxState, rowId: string) => boolean;
237
+ isLastInGroup: (state: ListboxState, rowId: string) => boolean;
238
+ getItemScore: (state: ListboxState, itemId: string) => number;
239
+ hasSearchWithNoResults: (state: ListboxState) => boolean;
240
+ };
241
+ /**
242
+ * Core store for listbox-like components.
243
+ * Handles item registration, filtering, navigation, and highlight state.
244
+ *
245
+ * Used by: DropdownMenu, ContextMenu, Select, CommandMenu
246
+ */
247
+ declare class ListboxStore extends ReactStore<ListboxState, ListboxContext, typeof selectors> {
248
+ constructor(initialState?: Partial<ListboxState>, context?: Partial<ListboxContext>);
249
+ /**
250
+ * Set the open state with event details.
251
+ *
252
+ * @param open - The new open state
253
+ * @param reason - The reason for the state change (default: 'none')
254
+ * @param event - The native DOM event that triggered the change (optional)
255
+ */
256
+ setOpen(open: boolean, reason?: PopupMenuOpenChangeReason, event?: Event): void;
257
+ setSearch(search: string): void;
258
+ setSearchNormalizer(normalizeSearch: SearchNormalizer): void;
259
+ private syncNormalizedSearch;
260
+ private defaultSearchInitialized;
261
+ initializeDefaultSearch(defaultSearch: string): void;
262
+ setHighlightedId(id: string | null, cause?: HighlightSource): void;
263
+ /**
264
+ * Notify listeners about highlight changes.
265
+ * Called whenever highlightedId changes, regardless of virtualization or DOM state.
266
+ * Useful for virtualization scroll sync, analytics, or any other tracking needs.
267
+ *
268
+ * @param id - The newly highlighted item ID (or null if cleared)
269
+ * @param cause - What caused the highlight change
270
+ */
271
+ private notifyHighlightChange;
272
+ /**
273
+ * Scroll the highlighted item into view.
274
+ * Uses native scrollIntoView if the element is in the DOM.
275
+ * For virtualized lists, the onHighlightChange callback (called from setHighlightedId)
276
+ * should handle scrolling via the virtualizer.
277
+ *
278
+ * @param id - The item ID to scroll into view
279
+ */
280
+ private scrollItemIntoView;
281
+ /**
282
+ * Reveal the top of an item's group after the item has been scrolled into
283
+ * view. When keyboard navigation lands on the first visible item of a
284
+ * group, aligning the viewport to the item alone leaves the group's label
285
+ * clipped just above the viewport (e.g. when navigating upward or wrapping
286
+ * around). Scrolling up by the clipped amount aligns the viewport top with
287
+ * the group's top edge so the label is visible.
288
+ *
289
+ * No-ops when the item is not the first visible item of its group, when the
290
+ * group element is unknown or outside the list, or when the group's top is
291
+ * already visible (e.g. when navigating downward).
292
+ */
293
+ private maybeRevealGroupTop;
294
+ private scrollListToTop;
295
+ private getScrollResetElement;
296
+ private isScrollableElement;
297
+ setHasInput(hasInput: boolean): void;
298
+ setInputActive(active: boolean): void;
299
+ setPendingSearch(search: string): void;
300
+ setHideUntilActive(enabled: boolean): void;
301
+ setVirtualized(virtualized: boolean): void;
302
+ setVirtualItems(items: VirtualItem[]): void;
303
+ /**
304
+ * Set the consumer-provided ordered items.
305
+ * Used when filter={false} and consumer controls item order/visibility.
306
+ * Must always be provided when filter={false}.
307
+ *
308
+ * @param items - Array of item IDs in display order
309
+ */
310
+ setOrderedItems(items: string[], options?: SetOrderedItemsOptions): void;
311
+ /**
312
+ * Try to auto-highlight when an item registers.
313
+ * This handles the case where orderedItems was set before items mounted.
314
+ * Only highlights if:
315
+ * - filter={false} (using orderedItems)
316
+ * - Menu is open
317
+ * - No item is currently highlighted
318
+ * - autoHighlightFirst is enabled
319
+ * - The registering item is the first in orderedItems
320
+ */
321
+ private maybeAutoHighlightOnRegister;
322
+ setOnHighlightChange(callback: ((id: string | null, index: number, eventDetails: HighlightChangeEventDetails) => void) | undefined): void;
323
+ /**
324
+ * Set the list element ref for scroll container detection.
325
+ */
326
+ setListRef(ref: React.RefObject<HTMLElement | null>): void;
327
+ /**
328
+ * Set the list scroll container ref for scroll position management.
329
+ * Use this when the semantic list element is rendered inside another
330
+ * scrollable container, such as a custom ScrollArea viewport.
331
+ */
332
+ setListScrollContainerRef(ref: React.RefObject<HTMLElement | null>): void;
333
+ /**
334
+ * Set the popup (visual container) ref. Used by popup-layer features such as
335
+ * Select's align-item-with-trigger positioning.
336
+ */
337
+ setPopupRef(ref: React.RefObject<HTMLElement | null>): void;
338
+ /**
339
+ * Register an item's DOM ref for scrollIntoView behavior.
340
+ * Returns a cleanup function.
341
+ */
342
+ registerItemRef(id: string, ref: React.RefObject<HTMLElement | null>): () => void;
343
+ /**
344
+ * Check if pointer has moved and should allow highlight.
345
+ * This prevents "phantom" highlights when content shifts under a stationary pointer
346
+ * (e.g., when search results change or menu items reorder).
347
+ *
348
+ * @param x - Current pointer X position
349
+ * @param y - Current pointer Y position
350
+ * @returns true if pointer has actually moved and highlight should be allowed
351
+ */
352
+ shouldAllowPointerHighlight(x: number, y: number): boolean;
353
+ /**
354
+ * Reset pointer position tracking.
355
+ * Call this when the menu opens or content changes significantly.
356
+ */
357
+ resetPointerPosition(): void;
358
+ /**
359
+ * Pre-register virtual items so they appear in filteredItems.
360
+ * This allows filtering to work for items that aren't mounted yet.
361
+ */
362
+ private preRegisterVirtualItems;
363
+ registerItem(id: string, registration: ItemRegistration): () => void;
364
+ /**
365
+ * Register a group. Optionally registers the group's DOM element ref,
366
+ * used for scroll positioning (e.g. revealing the group's label).
367
+ * Returns a cleanup function.
368
+ */
369
+ registerGroup(id: string, ref?: React.RefObject<HTMLElement | null>): () => void;
370
+ /**
371
+ * Register a mounted row element for positional tracking.
372
+ * Rows are kept in `state.orderedRows` sorted by DOM document position.
373
+ * Call from a layout effect once the element is mounted; the returned
374
+ * cleanup removes the row (call it when the element unmounts).
375
+ */
376
+ registerRow(id: string, element: HTMLElement, row: {
377
+ kind: ListboxRowKind;
378
+ groupId?: string;
379
+ }): () => void;
380
+ /**
381
+ * Compare two rows by DOM document position.
382
+ * Falls back to preserving current relative order when either element
383
+ * is missing or disconnected (Array.prototype.sort is stable).
384
+ */
385
+ private compareRowOrder;
386
+ registerItemSelect(id: string, onSelect: (() => void) | undefined): () => void;
387
+ registerSubmenuOpen(id: string, onOpen: (() => void) | undefined): () => void;
388
+ registerSubmenuClose(id: string, onClose: (() => void) | undefined): () => void;
389
+ /**
390
+ * Close all submenus except the one with the given ID.
391
+ * Used when hovering over a new submenu trigger to close sibling submenus.
392
+ */
393
+ closeSiblingSubmenus(exceptId: string | null): void;
394
+ highlightNext(): void;
395
+ highlightPrev(): void;
396
+ selectHighlighted(): void;
397
+ /**
398
+ * Select an item by its keyboard shortcut.
399
+ * Returns true if an item was found and selected, false otherwise.
400
+ */
401
+ selectByShortcut(key: string): boolean;
402
+ openSubmenuForHighlighted(): void;
403
+ isHighlightedSubmenuTrigger(): boolean;
404
+ /**
405
+ * Get the item registration for the highlighted item.
406
+ * Returns undefined if no item is highlighted.
407
+ */
408
+ getHighlightedItem(): ItemRegistration | undefined;
409
+ clearSearch(): void;
410
+ clearHighlight(): void;
411
+ highlightFirstItem(): void;
412
+ /**
413
+ * Apply auto-highlight based on the current context.autoHighlightFirst value.
414
+ * Called by Surface after updating the context to ensure correct value is used.
415
+ */
416
+ applyAutoHighlight(): void;
417
+ /**
418
+ * Highlight a specific item by its value.
419
+ * If the item is not visible or doesn't exist, falls back to highlighting the first item.
420
+ * Scrolls the highlighted item into view.
421
+ */
422
+ highlightItemByValue(value: string): void;
423
+ /**
424
+ * Returns whether filtering is disabled (consumer handles filtering externally).
425
+ */
426
+ isFilterDisabled(): boolean;
427
+ getVisibleItemIds(): string[];
428
+ /**
429
+ * Get the index of an item in the visible items list.
430
+ * Returns -1 if the item is not found or not visible.
431
+ */
432
+ getVisibleItemIndex(id: string): number;
433
+ /**
434
+ * Get the index of an item in the virtualItems array.
435
+ * This is used for virtualizer scrollToIndex which needs the raw array index,
436
+ * not the filtered/visible index.
437
+ * Returns -1 if not found or not in virtualized mode.
438
+ */
439
+ getVirtualItemIndex(value: string): number;
440
+ /**
441
+ * Validates and updates the highlighted item.
442
+ * This is the single source of truth for highlight management.
443
+ *
444
+ * @param options.forceFirst - Force highlight first item even if current is valid
445
+ * @param options.filteredItems - Use this map instead of state (for mid-update calls)
446
+ * @param options.newSearch - The search query for filteredItems (to detect search cleared)
447
+ */
448
+ private validateHighlight;
449
+ private recomputeFilteredItems;
450
+ static useStore(externalStore: ListboxStore | undefined, initialState?: Partial<ListboxState>, context?: Partial<ListboxContext>): ListboxStore;
451
+ }
452
+
453
+ export { type DOMRefs as D, type FilterFn as F, type HighlightSource as H, type ItemRegistration as I, type ListboxContext as L, type SearchNormalizer as S, type VirtualItem as V, type ListboxState as a, ListboxStore as b };
@@ -0,0 +1,2 @@
1
+ var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};
2
+ //# sourceMappingURL=chunk-4C666HHU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var d=(e,n)=>Object.is(e,n);function l(e,n,t){return e==null||n==null?Object.is(e,n):t(e,n)}function o(e,n,t){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:l(r,n,t))}function f(e,n,t){return e.filter(r=>!l(r,n,t))}function a(e){return _nullishCoalesce(e, () => (""))}function i(e,n){if(!e)return;if(Array.isArray(e)){let r=e.find(u=>a(u.value)===n);return r?{label:r.label,keywords:r.keywords}:void 0}let t=e[n];if(t!==void 0)return{label:t}}function m(e,n){return _optionalChain([i, 'call', _ => _(e,n), 'optionalAccess', _2 => _2.label])}function y(e,n){let t=n.filter(u=>!!u);if(t.length===0)return e;let r=e?[...e]:[];for(let u of t)r.includes(u)||r.push(u);return r}exports.a = d; exports.b = l; exports.c = o; exports.d = f; exports.e = i; exports.f = m; exports.g = y;
2
+ //# sourceMappingURL=chunk-5T5B5SPR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/item-equality.ts","../src/utils/items.ts"],"names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem","entryKey","resolveItemFromItems","items","valueKey","entry","i","label","resolveLabelFromItems","mergeKeywords","keywords","extra","additions","k","merged","keyword"],"mappings":"AAaO,qrBAAMA,CAAAA,CAA4C,CAACC,CAAAA,CAAMC,CAAAA,CAAAA,EAC9D,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAMhB,SAASC,CAAAA,CACdF,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACS,CAET,OAAIH,CAAAA,EAAQ,IAAA,EAAQC,CAAAA,EAAS,IAAA,CACpB,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAEvBE,CAAAA,CAASH,CAAAA,CAAMC,CAAK,CAC7B,CAKO,SAASG,CAAAA,CACdC,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,MAAI,CAACE,CAAAA,EAAcA,CAAAA,CAAW,MAAA,GAAW,CAAA,CAChC,CAAA,CAAA,CAEFA,CAAAA,CAAW,IAAA,CAAML,CAAAA,EAClBA,CAAAA,GAAS,KAAA,CAAA,CACJ,CAAA,CAAA,CAEFE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,CAAAA,CACdD,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,OAAOE,CAAAA,CAAW,MAAA,CACfL,CAAAA,EAAS,CAACE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACtD,CACF,CC3CA,SAASI,CAAAA,CAASN,CAAAA,CAA8B,CAC9C,wBAAOA,CAAAA,SAAgB,IACzB,CAMO,SAASO,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CAC0B,CAC1B,EAAA,CAAI,CAACD,CAAAA,CAAO,MAAA,CAEZ,EAAA,CAAI,KAAA,CAAM,OAAA,CAAQA,CAAK,CAAA,CAAG,CACxB,IAAME,CAAAA,CAAQF,CAAAA,CAAM,IAAA,CAAMG,CAAAA,EAAML,CAAAA,CAASK,CAAAA,CAAE,KAAK,CAAA,GAAMF,CAAQ,CAAA,CAC9D,OAAKC,CAAAA,CACE,CAAE,KAAA,CAAOA,CAAAA,CAAM,KAAA,CAAO,QAAA,CAAUA,CAAAA,CAAM,QAAS,CAAA,CAD1C,KAAA,CAEd,CAEA,IAAME,CAAAA,CAAQJ,CAAAA,CAAMC,CAAQ,CAAA,CAC5B,EAAA,CAAIG,CAAAA,GAAU,KAAA,CAAA,CACd,MAAO,CAAE,KAAA,CAAAA,CAAM,CACjB,CAMO,SAASC,CAAAA,CACdL,CAAAA,CACAC,CAAAA,CAC6B,CAC7B,uBAAOF,CAAAA,iBAAqBC,CAAAA,CAAOC,CAAQ,CAAA,6BAAG,OAChD,CAOO,SAASK,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACsB,CACtB,IAAMC,CAAAA,CAAYD,CAAAA,CAAM,MAAA,CAAQE,CAAAA,EAAmB,CAAA,CAAQA,CAAE,CAAA,CAC7D,EAAA,CAAID,CAAAA,CAAU,MAAA,GAAW,CAAA,CAAG,OAAOF,CAAAA,CAEnC,IAAMI,CAAAA,CAASJ,CAAAA,CAAW,CAAC,GAAGA,CAAQ,CAAA,CAAI,CAAC,CAAA,CAC3C,GAAA,CAAA,IAAWK,EAAAA,GAAWH,CAAAA,CACfE,CAAAA,CAAO,QAAA,CAASC,CAAO,CAAA,EAAGD,CAAAA,CAAO,IAAA,CAAKC,CAAO,CAAA,CAEpD,OAAOD,CACT,CAAA,wGAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-5T5B5SPR.cjs","sourcesContent":["/**\n * Type for custom item equality comparison functions.\n * Used to compare object values in Select and Combobox components.\n */\nexport type ItemEqualityComparer<Value = unknown> = (\n itemValue: Value,\n value: Value,\n) => boolean\n\n/**\n * Default equality comparer using Object.is.\n * Handles primitives and object reference equality.\n */\nexport const defaultItemEquality: ItemEqualityComparer = (item, value) =>\n Object.is(item, value)\n\n/**\n * Compare two items for equality using a custom comparer.\n * Handles null/undefined values separately using Object.is.\n */\nexport function compareItemEquality<Value>(\n item: Value | null | undefined,\n value: Value | null | undefined,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n // Handle null/undefined with Object.is for consistent behavior\n if (item == null || value == null) {\n return Object.is(item, value)\n }\n return comparer(item, value)\n}\n\n/**\n * Check if a collection includes a specific value using custom equality.\n */\nexport function itemIncludes<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value | null | undefined,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n if (!collection || collection.length === 0) {\n return false\n }\n return collection.some((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Find the index of a value in a collection using custom equality.\n * Returns -1 if not found.\n */\nexport function findItemIndex<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): number {\n if (!collection || collection.length === 0) {\n return -1\n }\n return collection.findIndex((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Remove a value from a collection using custom equality.\n * Returns a new array without the matching item.\n */\nexport function removeItem<Value>(\n collection: readonly Value[],\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): Value[] {\n return collection.filter(\n (item) => !compareItemEquality(item, value, comparer),\n )\n}\n","import type * as React from 'react'\n\n/**\n * A single entry in the array form of the `items` prop passed to\n * `Select.Root` / `Combobox.Root`.\n */\nexport interface ItemsEntry {\n /**\n * The item's value.\n *\n * Use `null` to describe a clearable/placeholder item (its label is used as\n * the trigger placeholder and selecting it clears the value).\n */\n value: string | null\n /** The label to display for this item. */\n label: React.ReactNode\n /**\n * Additional keywords to match against when filtering, on top of the label.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n}\n\n/**\n * Data structure describing the items rendered in a Select/Combobox popup.\n *\n * Either a record mapping a value to its label, or an array of entries. Only\n * the array form can express `keywords` or a `null` (clearable) value.\n */\nexport type Items = Record<string, React.ReactNode> | Array<ItemsEntry>\n\n/**\n * The resolved metadata for a single item looked up from the `items` prop.\n */\nexport interface ResolvedItem {\n label: React.ReactNode\n keywords?: string[]\n}\n\n/** Serialize an entry value to the string key used for registry lookups. */\nfunction entryKey(value: string | null): string {\n return value == null ? '' : value\n}\n\n/**\n * Resolve the full entry (label + keywords) from the `items` prop for a given\n * serialized value key. Returns `undefined` when there is no match.\n */\nexport function resolveItemFromItems(\n items: Items | undefined,\n valueKey: string,\n): ResolvedItem | undefined {\n if (!items) return undefined\n\n if (Array.isArray(items)) {\n const entry = items.find((i) => entryKey(i.value) === valueKey)\n if (!entry) return undefined\n return { label: entry.label, keywords: entry.keywords }\n }\n\n const label = items[valueKey]\n if (label === undefined) return undefined\n return { label }\n}\n\n/**\n * Resolve just the label from the `items` prop for a given serialized value\n * key. Returns `undefined` when there is no match.\n */\nexport function resolveLabelFromItems(\n items: Items | undefined,\n valueKey: string,\n): React.ReactNode | undefined {\n return resolveItemFromItems(items, valueKey)?.label\n}\n\n/**\n * Merge a set of extra keyword strings into an existing keywords array,\n * preserving order and removing duplicates. Returns the original `keywords`\n * reference untouched when there is nothing to add.\n */\nexport function mergeKeywords(\n keywords: string[] | undefined,\n extra: Array<string | undefined>,\n): string[] | undefined {\n const additions = extra.filter((k): k is string => Boolean(k))\n if (additions.length === 0) return keywords\n\n const merged = keywords ? [...keywords] : []\n for (const keyword of additions) {\n if (!merged.includes(keyword)) merged.push(keyword)\n }\n return merged\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{a as Ve}from"./chunk-4C666HHU.js";import*as G from"react";var he=G.createContext(null);function B(){return G.useContext(he)}import*as H from"react";var q=H.createContext(null);function ze(){let n=H.useContext(q);if(!n)throw new Error("Item child components must be used within an Item");return n}function Ne(){return H.useContext(q)}import*as T from"react";var $=T.createContext(null);function Y(){let n=T.useContext($);if(!n)throw new Error("Listbox components must be used within a Listbox provider");return n}function Fe(){return T.useContext($)}import*as A from"react";var W=A.createContext(null);process.env.NODE_ENV!=="production"&&(W.displayName="RowWidthContext");function Ge(){let n=A.useContext(W);if(!n)throw new Error("useRowWidthContext must be used within a List with measureRowWidth enabled");return n}function X(){return A.useContext(W)}import*as D from"react";var J=D.createContext(null);function Q(){let n=D.useContext(J);if(!n)throw new Error("Listbox components must be used within a Surface provider");return n}function We(){return D.useContext(J)}import*as b from"react";function P(n){return n?.trim()??""}function fe(n){return n.normalize("NFD").replace(/\p{Diacritic}/gu,"")}function Ke(n){return n?n.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function _e(n){let{id:e,value:t,keywords:r,disabled:s=!1,activatable:o=!0,forceMount:a=!1,shortcut:l,forceOrder:d,forceScore:c,isSubmenuTrigger:h=!1,onSelect:g,closeOnClick:v=!0,onAfterSelect:R,children:m,aimGuard:E}=n,{store:i}=Q(),u=B(),{depth:x}=Y(),f=b.useRef(null),I=b.useId(),[O,z]=b.useState(null);b.useLayoutEffect(()=>{if(O)return i.registerRow(I,O,{kind:"item",groupId:u?.groupId})},[O,I,u?.groupId,i]);let[M,N]=b.useState("");b.useLayoutEffect(()=>{if(e===void 0&&t===void 0&&f.current){let y=f.current.textContent?.trim()??"";N(y)}},[e,t,m]);let p=e??(P(t)||M),F=b.useId(),K=e??`item-${F}`,_=r?.map(y=>P(y)).filter(Boolean),ye=_?JSON.stringify(_):void 0;b.useEffect(()=>!p&&!a?void 0:i.registerItem(p,{value:p,keywords:_,groupId:u?.groupId,disabled:s,activatable:o,isSubmenuTrigger:h,shortcut:l,forceOrder:d,forceScore:c,closeOnClick:v}),[p,ye,u?.groupId,s,o,h,l,d,c,v,i,a]),b.useEffect(()=>{if(p)return i.registerItemRef(p,f)},[p,i]);let U=X();b.useLayoutEffect(()=>{U&&f.current&&p&&U.queueMeasurement(f.current,p)},[U,p]),b.useEffect(()=>{if(!(!g||!p))return i.registerItemSelect(p,g)},[p,g,i]);let we=i.useState("normalizedSearch"),j=i.useState("isHighlighted",p),ie=i.useState("isFirstRow",I),se=i.useState("isLastRow",I),oe=i.useState("isFirstInGroup",I),ae=i.useState("isLastInGroup",I),Oe=i.useState("getItemScore",p),Me=i.isFilterDisabled(),Le=we.length>0,Pe=a||Me||!Le||Oe>0,le=b.useCallback(y=>{if(y.defaultPrevented||s||o===!1||!p)return;y.preventDefault(),i.context.itemSelects.get(p)?.(),R?.(p)},[s,o,i,p,R]),ce=b.useCallback(y=>{y.preventDefault()},[]),ue=b.useCallback(y=>{if(!y.defaultPrevented&&!s&&p){if(E){let{aimGuardActiveRef:de,guardedDepthRef:De}=E;if(de.current&&De.current===x)return}i.shouldAllowPointerHighlight(y.clientX,y.clientY)&&i.setHighlightedId(p)}},[s,E,x,i,p]),ke=b.useMemo(()=>({id:K,highlighted:j,disabled:s,shortcut:l}),[K,j,s,l]),He=b.useCallback(y=>p?i.registerItemSelect(p,y):()=>{},[i,p]),Te=b.useMemo(()=>({onClick:le,onPointerMove:ue,onPointerDown:ce}),[le,ue,ce]),k=u?.positional,Ae=b.useMemo(()=>({first:k?.first??ie,last:k?.last??se,firstInGroup:k?.firstInGroup??oe,lastInGroup:k?.lastInGroup??ae}),[k,ie,se,oe,ae]);return{id:K,storeId:p,ref:f,rowRef:z,positional:Ae,isHighlighted:j,isVisible:Pe,contextValue:ke,handlers:Te,registerSelect:He}}import*as ge from"react";function Ue(n){let{store:e,surfaceId:t,enabled:r,onKeyDown:s,onSelect:o,closeAll:a,focusOwner:l,depth:d=0,submenuContext:c,subpageContext:h,enableTypeToSearch:g=!1,skipFocusOwnerCheck:v=!1}=n,R=l?.useState("isOwner",t)??!0,m=v?!0:R;return{handleKeyDown:ge.useCallback(i=>{if(s?.(i),!i.defaultPrevented&&r&&m&&!(i.nativeEvent.isComposing||i.keyCode===229)){if(g){let u=e.context.hideUntilActive,x=e.state.inputActive;if(u&&!x&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let I=e.context.shortcuts.get(i.key.toLowerCase());if(I&&e.selectByShortcut(i.key)){i.preventDefault();let O=e.context.items.get(I);o?.({itemId:I,closeOnClick:O?.closeOnClick??!0});return}i.preventDefault(),e.setPendingSearch(i.key),e.setInputActive(!0);return}}switch(i.key){case"ArrowDown":{i.preventDefault(),e.highlightNext();break}case"ArrowUp":{i.preventDefault(),e.highlightPrev();break}case"n":{i.ctrlKey&&(i.preventDefault(),e.highlightNext());break}case"p":{i.ctrlKey&&(i.preventDefault(),e.highlightPrev());break}case"ArrowRight":{e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"l":{i.ctrlKey&&e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"ArrowLeft":{if(h?.goBack()){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"h":{if(i.ctrlKey&&h?.goBack()){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}i.ctrlKey&&d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"Enter":{i.preventDefault();let u=e.state.highlightedId,x=e.getHighlightedItem();if(x?.activatable===!1)break;e.selectHighlighted(),o?.({itemId:u,closeOnClick:x?.closeOnClick??!0});break}case"Home":{i.preventDefault(),e.setHighlightedId(null),e.highlightNext();break}case"End":{i.preventDefault(),e.setHighlightedId(null),e.highlightPrev();break}case"Escape":{if(h){i.preventDefault(),i.stopPropagation(),h.closeRootOnEsc?a():h.goBack()&&l&&h.parentSurfaceId?l.setOwnerId(h.parentSurfaceId):d>0&&c&&(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}if(d===0)break;i.preventDefault(),i.stopPropagation(),c?.closeRootOnEsc!==!1?a():(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}default:{let u=e.state.normalizedSearch.length>0;if(i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!u){let f=e.context.shortcuts.get(i.key.toLowerCase());if(f&&e.selectByShortcut(i.key)){i.preventDefault();let I=e.context.items.get(f);o?.({itemId:f,closeOnClick:I?.closeOnClick??!0})}}break}}}},[s,r,m,g,e,d,c,h,l,o,a])}}import*as C from"react";var je=!1,Be=!1;function w(...n){je&&console.log("[useStickyRowWidth]",...n)}function pe(n){return`${Math.ceil(n)}px`}function qe(n){let e=Number.parseFloat(n);return Number.isFinite(e)?e:null}function $e(n){let{listRef:e,targetRef:t,maxWidth:r,enabled:s=!0}=n,o=C.useCallback(()=>t?.current??e.current,[t,e]),a=C.useRef(0);C.useLayoutEffect(()=>{if(!s)return;let i=o();if(!i)return;let u=qe(i.style.getPropertyValue("--row-width").trim());!u||u<=a.current||(a.current=u,w("Hydrated max width from existing --row-width:",{hydratedWidth:u}))},[s,o]);let l=C.useRef([]),d=C.useRef([]),c=C.useRef(!1),h=C.useRef(new Set),g=C.useCallback(i=>{let u=o();if(!u)return;let x=r!==void 0?Math.min(i,r):i;w("--row-width updated:",{rawWidth:i,cappedWidth:x,cssValue:pe(x),maxWidthCap:r,targetElement:u.tagName+(u.className?`.${u.className.split(" ").join(".")}`:"")}),u.style.setProperty("--row-width",pe(x))},[o,r]),v=C.useCallback(()=>{c.current||(c.current=!0,requestAnimationFrame(()=>{let i=l.current,u=a.current,x=!1;if(i.length>0){w("Measuring batch of",i.length,"rows");for(let{element:f,id:I}of i){if(h.current.has(I))continue;if(!f.isConnected){w("Row skipped (unmounted):",{id:I});continue}let O=f.style.width,z=f.style.maxWidth;f.setAttribute("data-measuring",""),f.style.maxWidth="none",f.style.width="max-content";let M=Math.max(f.scrollWidth,f.offsetWidth)+1,N=getComputedStyle(f);if(w("Row measurement details:",{id:I,measuredWidth:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,computedWidth:N.width,computedMaxWidth:N.maxWidth,inlineMaxWidth:z,textContent:f.textContent?.slice(0,50)}),Be||(f.style.width=O,f.style.maxWidth=z,f.removeAttribute("data-measuring")),M<=1){let p=f.getBoundingClientRect(),F=getComputedStyle(f);w("Row skipped (0-width, will retry):",{id:I,width:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,boundingRect:{width:p.width,height:p.height},display:F.display,visibility:F.visibility,innerHTML:f.innerHTML.slice(0,100),isConnected:f.isConnected,parentElement:f.parentElement?.tagName});continue}w("Row measured:",{id:I,width:M,currentMax:u,isNewMax:M>u}),M>u&&(u=M,x=!0),h.current.add(I)}l.current=[]}x&&(w("New max width found:",{previousMax:a.current,newMax:u,totalMeasured:h.current.size}),a.current=u,d.current.push(()=>g(u)));for(let f of d.current)f();d.current=[],c.current=!1}))},[g]),R=C.useCallback((i,u)=>{if(!s){w("queueMeasurement skipped (disabled):",u);return}if(h.current.has(u)){w("queueMeasurement skipped (already measured):",u);return}w("queueMeasurement:",{id:u,queueSize:l.current.length+1,element:i.tagName}),l.current.push({element:i,id:u}),v()},[s,v]),m=C.useCallback(()=>{let i=a.current,u=h.current.size;h.current.clear(),a.current=0;let x=o();x&&x.style.removeProperty("--row-width"),w("Measurements reset:",{previousMaxWidth:i,previousMeasuredCount:u,targetElement:x?.tagName})},[o]),E=C.useCallback(()=>{let i=h.current.size;h.current.clear(),w("Measured IDs cleared (sticky width kept):",{previousMeasuredCount:i,currentMaxWidth:a.current})},[]);return C.useEffect(()=>{if(!s)return;let i=o();if(!i||typeof ResizeObserver>"u")return;let u=null,x=new ResizeObserver(f=>{u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=null,a.current>0&&(w("ResizeObserver triggered re-apply:",{currentMax:a.current,containerSize:f[0]?.contentRect}),g(a.current))})});return x.observe(i),()=>{u!==null&&cancelAnimationFrame(u),x.disconnect()}},[o,s,g]),{queueMeasurement:R,resetMeasurements:m,clearMeasuredIds:E}}import{createSelector as S,ReactStore as Ot}from"@base-ui/utils/store";import{useRefWithInit as Mt}from"@base-ui/utils/useRefWithInit";var L={};Ve(L,{auto:()=>ft,clearPress:()=>at,closePress:()=>it,escapeKey:()=>Ze,focusOut:()=>tt,imperativeAction:()=>gt,inputChange:()=>st,inputClear:()=>ot,itemKeyboardSelect:()=>rt,itemPress:()=>nt,keyboard:()=>ht,listNavigation:()=>lt,none:()=>pt,outsidePress:()=>et,pointer:()=>dt,siblingOpen:()=>ut,submenuTrigger:()=>ct,triggerContextMenu:()=>Qe,triggerFocus:()=>Je,triggerHover:()=>Xe,triggerPress:()=>Ye});var Ye="trigger-press",Xe="trigger-hover",Je="trigger-focus",Qe="trigger-context-menu",Ze="escape-key",et="outside-press",tt="focus-out",nt="item-press",rt="item-keyboard-select",it="close-press",st="input-change",ot="input-clear",at="clear-press",lt="list-navigation",ct="submenu-trigger",ut="sibling-open",dt="pointer",ht="keyboard",ft="auto",gt="imperative-action",pt="none";function me(n,e,t,r){let s=!1,o=!1;return{reason:n,event:e??new Event("ui-event"),cancel(){s=!0},allowPropagation(){o=!0},get isCanceled(){return s},get isPropagationAllowed(){return o},trigger:t,...r}}function xe(n,e,t){return{reason:n,event:e??new Event("ui-event"),...t}}var Z=null,be=!1;function mt(n){Z=n.pointerType||"mouse"}function xt(){Z=null}function Zt(){be||typeof document>"u"||(be=!0,document.addEventListener("pointerdown",mt,{capture:!0,passive:!0}),document.addEventListener("keydown",xt,{capture:!0,passive:!0}))}function Se(n){switch(n){case"touch":return"touch";case"pen":return"pen";case"mouse":return"mouse";default:return null}}function Ie(n){let e=Se(n?.pointerType);return e||(n&&typeof KeyboardEvent<"u"&&n instanceof KeyboardEvent?"keyboard":Se(Z)??"keyboard")}var Re=1,bt=.9,St=.8,It=.17,ee=.1,te=.999,Rt=.9999;var vt=.99,Ct=/[\\/_+.#"@[({&]/,Et=/[\\/_+.#"@[({&]/g,yt=/[\s-]/,Ce=/[\s-]/g;function ne(n,e,t,r,s,o,a){if(o===e.length)return s===n.length?Re:vt;let l=`${s},${o}`;if(a[l]!==void 0)return a[l];let d=r.charAt(o),c=t.indexOf(d,s),h=0,g,v,R,m;for(;c>=0;)g=ne(n,e,t,r,c+1,o+1,a),g>h&&(c===s?g*=Re:Ct.test(n.charAt(c-1))?(g*=St,R=n.slice(s,c-1).match(Et),R&&s>0&&(g*=te**R.length)):yt.test(n.charAt(c-1))?(g*=bt,m=n.slice(s,c-1).match(Ce),m&&s>0&&(g*=te**m.length)):(g*=It,s>0&&(g*=te**(c-s))),n.charAt(c)!==e.charAt(o)&&(g*=Rt)),(g<ee&&t.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&t.charAt(c-1)!==r.charAt(o))&&(v=ne(n,e,t,r,c+1,o+2,a),v*ee>g&&(g=v*ee)),g>h&&(h=g),c=t.indexOf(d,c+1);return a[l]=h,h}function ve(n){return fe(n.toLowerCase()).replace(Ce," ")}function V(n,e,t){if(!e)return 1;if(!n)return 0;let r=t&&t.length>0?`${n} ${t.join(" ")}`:n;return ne(r,e,ve(r),ve(e),0,0,{})}var wt=V;var Lt={open:S(n=>n.openProp??n.open),openMethod:S(n=>n.openMethod),search:S(n=>n.searchProp??n.search),normalizedSearch:S(n=>n.normalizedSearch),highlightedId:S(n=>n.highlightedId),highlightSource:S(n=>n.highlightSource),hasInput:S(n=>n.hasInput),inputActive:S(n=>n.inputActive),pendingSearch:S(n=>n.pendingSearch),filteredCount:S(n=>n.filteredCount),filteredItems:S(n=>n.filteredItems),visibleGroups:S(n=>n.visibleGroups),virtualized:S(n=>n.virtualized),isHighlighted:S((n,e)=>n.highlightedId===e),isGroupVisible:S((n,e)=>n.normalizedSearch.length===0||n.visibleGroups.has(e)),isFirstRow:S((n,e)=>n.virtualized?!1:n.orderedRows.filter(r=>r.groupId===void 0)[0]?.id===e),isLastRow:S((n,e)=>n.virtualized?!1:n.orderedRows.filter(r=>r.groupId===void 0).at(-1)?.id===e),isFirstGroup:S((n,e)=>n.virtualized?!1:n.orderedRows.filter(r=>r.kind==="group")[0]?.id===e),isLastGroup:S((n,e)=>n.virtualized?!1:n.orderedRows.filter(r=>r.kind==="group").at(-1)?.id===e),isFirstInGroup:S((n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return t?.groupId?n.orderedRows.filter(s=>s.groupId===t.groupId)[0]?.id===e:!1}),isLastInGroup:S((n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return t?.groupId?n.orderedRows.filter(s=>s.groupId===t.groupId).at(-1)?.id===e:!1}),getItemScore:S((n,e)=>n.normalizedSearch.length===0?1:n.filteredItems.get(e)??0),hasSearchWithNoResults:S(n=>n.normalizedSearch.length===0?!1:n.virtualized&&n.virtualItemsCount>=0?n.virtualItemsCount===0:n.filteredCount===0)};function Ee(n,e){return n.element===null||e.element===null||!n.element.isConnected||!e.element.isConnected?n.index-e.index:n.element.compareDocumentPosition(e.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Pt=n=>P(n),re=class n extends Ot{constructor(e,t){let s={...{filter:V,normalizeSearch:Pt,loop:!0,autoHighlightFirst:!0,clearSearchOnClose:!0,resetScrollOnSearch:!0,hideUntilActive:!1,listId:"",inputId:"",items:new Map,groups:new Map,itemSelects:new Map,submenuOpens:new Map,submenuCloses:new Map,shortcuts:new Map,rowElements:new Map,onOpenChange:()=>{},onSearchChange:void 0,virtualItems:[],orderedItems:[],onHighlightChange:void 0,refs:{listRef:{current:null},listScrollContainerRef:{current:null},popupRef:{current:null},itemRefs:new Map,groupRefs:new Map},onCloseComplete:void 0,onPopupCloseComplete:void 0,lastPointerPosition:null},...t},o={...kt(),...e};o.normalizedSearch=s.normalizeSearch(o.search),super(o,s,Lt),this.observe("open",(a,l)=>{if(a!==l)if(a)this.resetPointerPosition(),this.context.autoHighlightFirst===!0&&this.highlightFirstItem();else{this.context.clearSearchOnClose===!0&&this.setSearch("");let d=this.context.clearSearchOnClose==="after-exit";this.update({inputActive:d?this.state.inputActive:!1,pendingSearch:""})}}),this.observe("search",(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe(a=>a.searchProp,(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe("normalizedSearch",(a,l)=>{a!==l&&(this.resetPointerPosition(),this.recomputeFilteredItems(l),this.context.resetScrollOnSearch&&!this.state.virtualized&&this.scrollListToTop())})}setOpen(e,t=L.none,r){let s=me(t,r);this.context.onOpenChange(e,s),!s.isCanceled&&(e&&this.set("openMethod",Ie(r)),this.set("open",e))}setSearch(e){let t=this.state.searchProp??e;this.update({search:e,normalizedSearch:this.context.normalizeSearch(t)}),this.context.onSearchChange?.(e)}setSearchNormalizer(e){this.context.normalizeSearch=e;let t=this.state.searchProp??this.state.search,r=e(t);r!==this.state.normalizedSearch&&this.set("normalizedSearch",r)}syncNormalizedSearch(){let e=this.state.searchProp??this.state.search,t=this.context.normalizeSearch(e);t!==this.state.normalizedSearch&&this.set("normalizedSearch",t)}defaultSearchInitialized=!1;initializeDefaultSearch(e){this.defaultSearchInitialized||(this.defaultSearchInitialized=!0,this.state.searchProp===void 0&&e!==this.state.search&&this.setSearch(e))}setHighlightedId(e,t="pointer"){this.state.highlightedId!==e&&(this.closeSiblingSubmenus(e),this.update({highlightedId:e,highlightSource:t}),this.notifyHighlightChange(e,t),t==="keyboard"&&e!==null&&this.scrollItemIntoView(e))}notifyHighlightChange(e,t){let{onHighlightChange:r}=this.context;if(!r)return;let s=t==="keyboard"?L.keyboard:t==="pointer"?L.pointer:L.auto,o=e===null?-1:this.state.virtualized?this.getVirtualItemIndex(e):this.getVisibleItemIndex(e),a=xe(s,void 0,{index:o});r(e,o,a)}scrollItemIntoView(e){let{refs:t}=this.context,r=t.listRef.current,o=t.itemRefs.get(e)?.current;if(o&&r)try{r.contains(o)&&(o.scrollIntoView({block:"nearest"}),this.maybeRevealGroupTop(e,r))}catch{}}maybeRevealGroupTop(e,t){let r=this.context.items.get(e)?.groupId;if(!r||this.getVisibleItemIds().find(c=>this.context.items.get(c)?.groupId===r)!==e)return;let a=this.context.refs.groupRefs.get(r)?.current;if(!a||!t.contains(a))return;let l=this.context.refs.listScrollContainerRef.current??this.getScrollResetElement(t),d=l.getBoundingClientRect().top-a.getBoundingClientRect().top;d>0&&(l.scrollTop-=d)}scrollListToTop(){let e=this.context.refs.listRef.current,t=this.context.refs.listScrollContainerRef.current??(e?this.getScrollResetElement(e):null);if(t){if(typeof t.scrollTo=="function"){t.scrollTo({top:0});return}t.scrollTop=0}}getScrollResetElement(e){let t=e;for(;t;){if(this.isScrollableElement(t))return t;t=t.parentElement}return e}isScrollableElement(e){let r=e.ownerDocument?.defaultView?.getComputedStyle(e).overflowY,s=r==="auto"||r==="scroll"||r==="overlay";return e.scrollTop>0||s&&e.scrollHeight>e.clientHeight}setHasInput(e){this.set("hasInput",e)}setInputActive(e){this.set("inputActive",e)}setPendingSearch(e){this.set("pendingSearch",e)}setHideUntilActive(e){this.context.hideUntilActive=e,e&&this.state.normalizedSearch.length>0&&this.setInputActive(!0)}setVirtualized(e){this.set("virtualized",e)}setVirtualItems(e){let t=this.context.virtualItems;if(this.context.virtualItems=e,this.set("virtualItemsCount",e.length),this.preRegisterVirtualItems(),e===t)return;if(t.length===e.length){let a=!0;for(let l=0;l<t.length;l++){let d=t[l],c=e[l];if(!d||!c||d.value!==c.value||d.disabled!==c.disabled){a=!1;break}}if(a)return}if(!this.state.virtualized||!this.state.open||e.length===0)return;let r=t.find(a=>!a.disabled),s=e.find(a=>!a.disabled),o=r!==void 0&&s?.value!==r.value;this.validateHighlight({forceFirst:o})}setOrderedItems(e,t){let r=t?.reason??"replace",s=this.context.orderedItems;if(this.context.orderedItems=e,e!==s&&this.state.open){if(r==="append"&&this.state.highlightedId!==null){let o=this.state.highlightedId,a=this.context.items.get(o),l=e.includes(o),d=a?!a.disabled:!1;if(l&&d)return}if(e.length>0){let o=e.find(a=>this.context.items.has(a));o!==void 0?this.setHighlightedId(o,"auto"):this.setHighlightedId(null)}else this.setHighlightedId(null)}}maybeAutoHighlightOnRegister(e){if(this.context.filter!==!1||!this.state.open||this.state.highlightedId!==null||!this.context.autoHighlightFirst)return;let t=this.context.orderedItems;if(t.length===0)return;t.find(s=>this.context.items.has(s))===e&&this.setHighlightedId(e,"auto")}setOnHighlightChange(e){this.context.onHighlightChange=e}setListRef(e){this.context.refs.listRef=e}setListScrollContainerRef(e){this.context.refs.listScrollContainerRef=e}setPopupRef(e){this.context.refs.popupRef=e}registerItemRef(e,t){return this.context.refs.itemRefs.set(e,t),()=>{this.context.refs.itemRefs.delete(e)}}shouldAllowPointerHighlight(e,t){let r=this.context.lastPointerPosition;if(r===null)return this.context.lastPointerPosition={x:e,y:t},!0;let s=Math.abs(e-r.x),o=Math.abs(t-r.y);return s>1||o>1?(this.context.lastPointerPosition={x:e,y:t},!0):!1}resetPointerPosition(){this.context.lastPointerPosition=null}preRegisterVirtualItems(){let e=this.context.virtualItems;if(e.length!==0){for(let t of e)this.context.items.has(t.value)||this.context.items.set(t.value,{value:t.value,keywords:t.keywords,disabled:t.disabled});this.recomputeFilteredItems()}}registerItem(e,t){let r=this.context.items.get(e);if(r&&r.value===t.value&&r.disabled===t.disabled&&r.forceOrder===t.forceOrder&&r.forceScore===t.forceScore&&r.groupId===t.groupId&&r.shortcut===t.shortcut&&r.activatable===t.activatable)return()=>{this.context.items.get(e)===r&&(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId&&this.context.groups.get(t.groupId)?.delete(e),t.shortcut&&this.context.shortcuts.delete(t.shortcut.toLowerCase()),this.recomputeFilteredItems())};if(this.context.items.set(e,t),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.add(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.set(o,e)}return this.recomputeFilteredItems(),this.maybeAutoHighlightOnRegister(e),()=>{if(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.delete(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.delete(o)}this.recomputeFilteredItems()}}registerGroup(e,t){return this.context.groups.set(e,new Set),t&&this.context.refs.groupRefs.set(e,t),()=>{this.context.groups.delete(e),this.context.refs.groupRefs.delete(e)}}registerRow(e,t,r){this.context.rowElements.set(e,t);let o=[...this.state.orderedRows.filter(a=>a.id!==e),{id:e,kind:r.kind,groupId:r.groupId}];return o.sort((a,l)=>this.compareRowOrder(a,l)),this.set("orderedRows",o),()=>{this.context.rowElements.get(e)===t&&(this.context.rowElements.delete(e),this.set("orderedRows",this.state.orderedRows.filter(a=>a.id!==e)))}}compareRowOrder(e,t){let r=this.context.rowElements.get(e.id),s=this.context.rowElements.get(t.id);if(!r||!s||!r.isConnected||!s.isConnected)return 0;let o=r.compareDocumentPosition(s);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0}registerItemSelect(e,t){return t&&this.context.itemSelects.set(e,t),()=>{this.context.itemSelects.delete(e)}}registerSubmenuOpen(e,t){return t&&this.context.submenuOpens.set(e,t),()=>{this.context.submenuOpens.delete(e)}}registerSubmenuClose(e,t){return t&&this.context.submenuCloses.set(e,t),()=>{this.context.submenuCloses.delete(e)}}closeSiblingSubmenus(e){for(let[t,r]of this.context.submenuCloses)if(t!==e)try{r()}catch{}}highlightNext(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):-1)+1;r>=e.length&&(r=this.context.loop?0:e.length-1);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}highlightPrev(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):e.length)-1;r<0&&(r=this.context.loop?e.length-1:0);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}selectHighlighted(){if(this.state.highlightedId){if(this.context.items.get(this.state.highlightedId)?.activatable===!1)return;this.context.itemSelects.get(this.state.highlightedId)?.()}}selectByShortcut(e){let t=this.context.shortcuts.get(e.toLowerCase());if(!t)return!1;let r=this.context.items.get(t);if(!r||r.disabled)return!1;let s=this.state.filteredItems.get(t)??0;return this.state.normalizedSearch.length===0||s>0?(this.context.itemSelects.get(t)?.(),!0):!1}openSubmenuForHighlighted(){this.state.highlightedId&&this.context.submenuOpens.get(this.state.highlightedId)?.()}isHighlightedSubmenuTrigger(){return this.state.highlightedId?this.context.items.get(this.state.highlightedId)?.isSubmenuTrigger??!1:!1}getHighlightedItem(){if(this.state.highlightedId)return this.context.items.get(this.state.highlightedId)}clearSearch(){this.setSearch("")}clearHighlight(){this.update({highlightedId:null,highlightSource:null})}highlightFirstItem(){let e=this.getVisibleItemIds();e.length>0&&e[0]?this.update({highlightedId:e[0],highlightSource:null}):this.update({highlightedId:null,highlightSource:null})}applyAutoHighlight(){if(!this.state.open)return;let e=this.context.autoHighlightFirst;e===!0?this.highlightFirstItem():typeof e=="string"&&this.highlightItemByValue(e)}highlightItemByValue(e){let t=this.getVisibleItemIds(),r=null;t.includes(e)?r=e:t.length>0&&t[0]&&(r=t[0]),this.update({highlightedId:r,highlightSource:null}),r&&requestAnimationFrame(()=>{this.scrollItemIntoView(r)})}isFilterDisabled(){return this.context.filter===!1}getVisibleItemIds(){let e=[],t=this.state.normalizedSearch,r=this.state.filteredItems,s=this.context.virtualItems,o=this.context.orderedItems;if(this.state.virtualized&&s.length>0){for(let d of s){let c=r.get(d.value)??0;(t.length===0||c>0)&&!d.disabled&&e.push(d.value)}return e}if(this.context.filter===!1&&o.length>0){let d=[];for(let c of o){let h=this.context.items.get(c);h&&!h.disabled?e.push(c):h||d.push(c)}if(process.env.NODE_ENV!=="production"&&d.length>0&&e.length>0)for(let c of d)console.warn(`[ListboxStore] Item "${c}" is in orderedItems but not registered. This may cause keyboard navigation to skip this item. Make sure the render function passes the \`id\` prop: <Item {...props}>...</Item>`);return e}let a=[],l=0;this.context.items.forEach((d,c)=>{let h=l++,g=r.get(c)??0;(t.length===0||g>0)&&!d.disabled&&a.push({id:c,element:this.context.refs.itemRefs.get(c)?.current??null,index:h})}),a.sort(Ee);for(let{id:d}of a)e.push(d);return e}getVisibleItemIndex(e){return this.getVisibleItemIds().indexOf(e)}getVirtualItemIndex(e){return this.state.virtualized?this.context.virtualItems.findIndex(t=>t.value===e):-1}validateHighlight(e={}){let{forceFirst:t=!1,filteredItems:r=this.state.filteredItems,newSearch:s,prevSearch:o}=e,a=o!==void 0?o:this.state.normalizedSearch,l=s!==void 0?s:a,d=s!==void 0&&s!==a;if(!this.state.open||!this.context.autoHighlightFirst)return this.state.highlightedId;let c=this.state.highlightedId,{filter:h}=this.context,g=t||d,v=!1;if(c&&!g){let m=r.get(c)??0,E=l.length===0||h===!1||m>0,i=this.context.items.get(c),u=this.context.virtualItems.find(O=>O.value===c),x=i?.disabled??u?.disabled??!1,f=this.state.virtualized||i!==void 0,I=!this.state.virtualized||this.context.virtualItems.length===0||u!==void 0;v=E&&!x&&f&&I}if(v)return c;let R=null;if(this.state.virtualized&&this.context.virtualItems.length>0)for(let m of this.context.virtualItems){let E=r.get(m.value)??0;if((l.length===0||h===!1||E>0)&&!m.disabled){R=m.value;break}}else if(h===!1&&this.context.orderedItems.length>0)for(let m of this.context.orderedItems){let E=this.context.items.get(m);if(E&&!E.disabled){R=m;break}}else{let m=null,E=0;for(let[i,u]of this.context.items){let x=E++,f=r.get(i)??0;if((l.length===0||f>0)&&!u.disabled){let O={id:i,element:this.context.refs.itemRefs.get(i)?.current??null,index:x};(m===null||Ee(O,m)<0)&&(m=O)}}R=m?.id??null}return R!==c&&this.update({highlightedId:R,highlightSource:null}),R}recomputeFilteredItems(e){let{filter:t}=this.context,r=this.state.normalizedSearch,s=this.context.items,o=this.context.groups,a=new Map,l=new Set,d=0;if(!r||t===!1){if(this.state.virtualized&&this.context.virtualItems.length>0)for(let h of this.context.virtualItems)a.set(h.value,1),d++;else s.forEach((h,g)=>{a.set(g,1),d++});o.forEach((h,g)=>{l.add(g)})}else{let h=t||V;s.forEach((g,v)=>{let R=h(g.value,r,g.keywords),m=g.forceScore??R;a.set(v,m),m>0&&(d++,g.groupId&&l.add(g.groupId))})}if(t===!1){this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1});return}let c=this.validateHighlight({filteredItems:a,newSearch:r,prevSearch:e});this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1,highlightedId:c,highlightSource:null})}static useStore(e,t,r){return Mt(()=>e??new n(t,r)).current}};function kt(){return{open:!1,openProp:void 0,openMethod:null,search:"",searchProp:void 0,normalizedSearch:"",highlightedId:null,highlightSource:null,hasInput:!1,inputActive:!1,pendingSearch:"",filteredItems:new Map,visibleGroups:new Set,filteredCount:0,filterTrigger:0,virtualized:!1,virtualItemsCount:0,orderedRows:[]}}export{L as a,me as b,Zt as c,he as d,B as e,q as f,ze as g,Ne as h,$ as i,Y as j,Fe as k,W as l,Ge as m,X as n,J as o,Q as p,We as q,P as r,Ke as s,_e as t,Ue as u,$e as v,V as w,wt as x,re as y};
2
+ //# sourceMappingURL=chunk-A4Z5BY7H.js.map