import { type MouseEvent, type PropsWithChildren } from 'react' import { cn } from 'ui' import { DynamicLink } from '@/components/ui/DynamicLink' import { getDocsPath } from '@/lib/telemetry/docs-path' import { useTrack } from '@/lib/telemetry/track' interface InlineLinkProps { href: string className?: string target?: string rel?: string title?: string onClick?: (e: MouseEvent) => void onAuxClick?: (e: MouseEvent) => void } export const InlineLinkClassName = 'underline transition underline-offset-2 decoration-inherit hover:decoration-foreground text-inherit hover:text-foreground' export const UntrackedInlineLink = ({ href, className: _className, children, title, ...props }: PropsWithChildren) => { const className = cn(InlineLinkClassName, _className) if (href.startsWith('http')) { return ( {children} ) } return ( {children} ) } const DocsInlineLink = ({ docsPath, onClick, onAuxClick, ...props }: PropsWithChildren) => { const track = useTrack() const handleClick = (e: MouseEvent) => { track('studio_docs_link_clicked', { docsPath }) onClick?.(e) } const handleAuxClick = (e: MouseEvent) => { const isMiddleClick = e.button === 1 if (isMiddleClick) track('studio_docs_link_clicked', { docsPath }) onAuxClick?.(e) } return } export const InlineLink = (props: PropsWithChildren) => { const docsPath = getDocsPath(props.href) if (!docsPath) return return }