import { h as SuggestionItem, b as SearchSuggestQuery, F as FetchOptions, g as SuggestResult } from './search-DKS7OIn2.mjs'; import './_spec-EgN7VmAI.mjs'; /** * `@cavuno/board/suggest` — framework-agnostic headless search-suggest * controller (Algolia autocomplete-core pattern). * * Owns debounce, abort, and stale-drop so tenant frontends don't re-invent * them. Patches ship via npm update. Zero runtime deps; isomorphic * (`globalThis` timers only — never `window`/`document`). * * The ONE permitted view-level filter is excluding currently-applied company * slugs from results (type `company` only). Wire data is never reshaped * otherwise — order stays server-ranked. */ interface SuggestControllerOptions { /** Minimum characters before querying (default 2 — hosted parity). */ minChars?: number; /** Debounce for setQuery → request (default 250ms). */ debounceMs?: number; /** Server `limit` passed through (1–25). */ limit?: number; } type SuggestStatus = 'idle' | 'loading' | 'ready' | 'error'; interface SuggestState { readonly query: string; /** * Server-ranked items. Previous items are RETAINED while a new request * is loading (no flash-to-empty — hosted behavior). */ readonly items: readonly SuggestionItem[]; /** * `'loading'` from the moment a qualifying query is set (debounce window * included) until that query's request settles. `'idle'` only when the * query is empty/below minChars. `'ready'` / `'error'` after settle. */ readonly status: SuggestStatus; readonly error: unknown; } interface SuggestController { setQuery(query: string): void; /** Company slugs to hide from results (e.g. the currently-applied filter). */ setExcludedCompanySlugs(slugs: readonly string[]): void; getState(): SuggestState; /** Returns an unsubscribe function. Compatible with useSyncExternalStore. */ subscribe(listener: () => void): () => void; dispose(): void; } type SuggestBoard = { search: { suggest(q?: SearchSuggestQuery, o?: FetchOptions): Promise; }; }; /** * Create a headless suggest controller bound to a board client (or any * object exposing `search.suggest`). * * @example * import { createBoardClient } from '@cavuno/board'; * import { createSuggestController } from '@cavuno/board/suggest'; * * const board = createBoardClient({ board: 'pk_…' }); * const suggest = createSuggestController(board); * suggest.subscribe(() => render(suggest.getState())); * suggest.setQuery('acme'); */ declare function createSuggestController(board: SuggestBoard, options?: SuggestControllerOptions): SuggestController; export { type SuggestController, type SuggestControllerOptions, type SuggestState, type SuggestStatus, createSuggestController };