"use client"; import * as React from "react"; import { highlightSegments } from "@/lib/search/query"; import { cn } from "@/lib/utils"; /** Renders `text` with `` around every occurrence of `terms` (case-insensitive). */ export function Highlight({ text, terms, className, markClassName }: { text: string; terms: string[]; className?: string; markClassName?: string }) { const segments = React.useMemo(() => highlightSegments(text, terms), [text, terms]); return ( {segments.map((s, i) => s.hit ? ( {s.text} ) : ( {s.text} ), )} ); }