export declare const INITIAL_KEYBOARD_NAV_STATE: KeyboardNavState; export type SelectableItem = { setAttribute(name: string, value: string): void; removeAttribute(name: string): void; }; export type SearchKeyResult = { preventDefault: boolean; selectedIndex: number; activate: boolean; }; /** * Clamp selection within `[0, length)`. From `-1`, ↓ → first, ↑ → last. * Empty list always returns `-1`. */ export declare function nextIndex(current: number, delta: number, length: number): number; /** Mark exactly one item as selected (or none when index is out of range). */ export declare function applySelection(items: SelectableItem[], index: number): void; export declare function handleSearchKey(key: string, selectedIndex: number, itemCount: number): SearchKeyResult; /** Result-list keys apply only while the query field is focused — not on clear / other controls. */ export declare function shouldHandleSearchListKeyboard(activeElement: Element | null, searchInput: Element | null): boolean; /** Visible Pagefind “load more” control, when present. */ export declare function collectLoadMoreButton(root: ParentNode): HTMLElement | null; /** Result rows plus load-more when Pagefind shows it. */ export declare function collectResultNavItems(root: ParentNode): HTMLElement[]; export declare function isLoadMoreButton(item: HTMLElement): boolean; export declare function activateSearchNavItem(item: HTMLElement): void; /** Page title / nested rows that already have a navigable link (skip placeholders). */ export declare function collectResultRows(root: ParentNode): HTMLElement[]; /** Idle suggestion chips. */ export declare function collectSuggestionChips(root: ParentNode): HTMLElement[]; export declare function resultLinkForRow(row: HTMLElement): HTMLAnchorElement | null; /** Scroll container for Pagefind hits (results-area when present, else drawer). */ export declare function findSearchResultsScroller(root: ParentNode): HTMLElement | null; /** * Keep keyboard selection visible. Index 0 scrolls the drawer flush to the top so * the match count and first row are fully shown — `nearest` leaves a stale offset. */ export declare function scrollSearchSelectionIntoView(root: ParentNode, selectedIndex: number, item: HTMLElement | undefined, itemCount: number): void; /** Strip keyboard highlight from a prior modal session. */ export declare function clearSearchSelection(root: ParentNode): void; /** Pagefind keeps results mounted while the dialog is closed — reset scroll position. */ export declare function resetSearchResultsScroll(root: ParentNode): void; /** Fresh keyboard-nav state when the search dialog closes or reopens. */ export declare function resetSearchNavSession(root: ParentNode): KeyboardNavState; export type KeyboardNavMode = 'idle' | 'results' | 'other'; export type KeyboardNavState = { selectedIndex: number; lastFingerprint: string; /** True after the query changes until fresh results are accepted. */ awaitingFreshResults: boolean; /** True if Pagefind showed a searching state while awaiting. */ sawSearchingWhileAwaiting: boolean; /** True after ↓/↑ in the results list — blocks auto-highlight on fresh hits. */ userMovedResults: boolean; }; export declare function markAwaitingFreshResults(state: KeyboardNavState): KeyboardNavState; /** * Updates selection when the dialog mode / result list fingerprint changes. * While awaiting, selection stays cleared until either the href fingerprint changes * or a searching→idle cycle completes (same hits after an edit). */ export declare function resolveKeyboardSelection(state: KeyboardNavState, mode: KeyboardNavMode, fingerprint: string, itemCount: number, isSearching: boolean): KeyboardNavState;