import type { CategoryLabel } from "./labels.js"; import type { CategoryNode } from "./tree.js"; /** * How well a row answered the query. The ORDER of these three is the ranking * (see {@link MATCH_RANK}), which is why they are named rather than scored: * a number invites tuning nobody can explain. */ export type CategoryMatchKind = "exact" | "prefix" | "substring"; /** One category the query reached. */ export interface CategorySearchHit { readonly node: CategoryNode; /** The row's display string and what to do with it — `kind: "key"` means * run it through the host's `t`, exactly as everywhere else in this pair. */ readonly label: CategoryLabel; /** The caption this hit was MATCHED against: translated when a translator * was supplied, the raw key otherwise. Handed back so a skin highlights the * same string the match was made on. */ readonly caption: string; /** Why it matched, strongest first — see {@link CategoryMatchKind}. */ readonly match: CategoryMatchKind; /** The storefront path for the hit, `basePath`-prefixed. */ readonly href: string; } /** * How many hits a query may return. * * Small on purpose. This surface is a short list of category links above the * results, not a browsable index — a person scanning twenty entries is doing * the tree's job by hand, and a catalogue with 3444 rows can supply twenty * matches for almost any two letters. */ export declare const CATEGORY_SEARCH_LIMIT = 6; /** * Case- and diacritic-insensitive comparison form. * * NFD splits a letter from its accents, the property escape drops the accents, * and `toLocaleLowerCase` folds case under the LABEL's own rules rather than * the invariant ones — a Turkish dotted capital must not become an `i` that * matches a different word. */ export declare function foldForSearch(value: string): string; export interface RankCategoryMatchesOptions { /** Resolve a translation key to the caption a person can actually read. * Without it, matching runs against the raw key — see this file's header. */ readonly translate?: (key: string) => string; /** Path prefix for a hit's link. Default `/c` — the spec's `/c/:slug`. */ readonly basePath?: string; /** Cap on the number of hits. Default {@link CATEGORY_SEARCH_LIMIT}. */ readonly limit?: number; } /** * Rank `nodes` against `query` and return the best few. * * `nodes` is expected in DISPLAY ORDER (what `flattenCategoryNodes` gives), * because that is the tie-break: within one match kind the catalogue's own * priority order decides, so two equally good hits do not swap places between * renders. * * A blank query returns nothing rather than the whole catalogue: "the person * has not asked yet" and "the person asked and everything matched" are * different, and only the first one is true here. */ export declare function rankCategoryMatches(nodes: readonly CategoryNode[], query: string, options?: RankCategoryMatchesOptions): readonly CategorySearchHit[]; //# sourceMappingURL=search.d.ts.map