import { cn } from '@langgenius/dify-ui/cn'
import { FileTreeIcon } from '@langgenius/dify-ui/file-tree'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { use } from 'react'
import { RosterReferenceBlockContext } from './context'
import {
getRosterReferenceFileIconType,
getRosterReferenceIconClassName,
parseRosterReferenceToken,
} from './utils'
type RosterReferenceBlockComponentProps = {
text: string
}
const RosterReferenceBlockComponent = ({ text }: RosterReferenceBlockComponentProps) => {
const rosterReferenceBlock = use(RosterReferenceBlockContext)
const token = parseRosterReferenceToken(text)
if (!token) return null
const isKnowledge = token.kind === 'knowledge'
const customIcon = rosterReferenceBlock?.renderIcon?.(token)
const warning = rosterReferenceBlock?.getWarning?.(token)
const defaultIcon =
token.kind === 'file' ? (
) : (
)
const tokenBlock = (
{customIcon || defaultIcon}
{token.label}
{warning && (
)}
)
if (!warning) return tokenBlock
return (
{warning}
)
}
export default RosterReferenceBlockComponent