import React, { useState } from "react" import React, { useState } from "react" export const TokenChip = ({ token, logprob, threshold, replacements, onReplace }: { token: string, logprob: number, threshold: number, replacements: string[], onReplace: (newToken: string) => void }) => { const [isExpanded, setIsExpanded] = useState(false); const handleClick = () => { if (logprob < threshold && replacements.length > 0) { setIsExpanded(true); } } const handleReplacement = (event: React.ChangeEvent) => { const newToken = event.target.value if (newToken !== token) { onReplace(newToken) } setIsExpanded(false); } return ( {token} {isExpanded && ( )} ) }