"use client"
import type { ReactNode } from "react"
import { lookupTerm } from "@/lib/glossary"
import { SignalTooltip } from "@/components/signals/signal-tooltip"
interface TermProps {
/**
* Glossary key to look up. Defaults to the visible text.
*/
term?: string
children: ReactNode
/**
* Override the tooltip body. If omitted, glossary entry is used.
*/
explain?: ReactNode
className?: string
}
export function Term({ term, children, explain, className }: TermProps) {
const key = term ?? (typeof children === "string" ? children : undefined)
const entry = key ? lookupTerm(key) : undefined
const content = explain ?? (entry ? (
{entry.short}
{entry.long ? {entry.long} : null}
) : null)
if (!content) {
return {children}
}
return (
{children}
)
}