import { memo, useCallback, useRef, } from 'react' import { useTranslation } from 'react-i18next' import type { BlockEnum, ToolWithProvider } from '../types' import { CollectionType } from '../../tools/types' import IndexBar, { groupItems } from './index-bar' import type { ToolDefaultValue } from './types' import ToolItem from './tool-item' import { ViewType } from './view-type-select' import Empty from '@/app/components/tools/add-tool-modal/empty' import { useGetLanguage } from '@/context/i18n' import cn from '@/utils/classnames' type ToolsProps = { showWorkflowEmpty: boolean onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void tools: ToolWithProvider[] viewType: ViewType } const Blocks = ({ showWorkflowEmpty, onSelect, tools, viewType, }: ToolsProps) => { const { t } = useTranslation() const language = useGetLanguage() const isListView = viewType === ViewType.list const isTreeView = viewType === ViewType.tree const { letters, groups: groupedTools } = groupItems(tools, tool => (tool as any).label[language][0]) const toolRefs = useRef({}) const renderGroup = useCallback((toolWithProvider: ToolWithProvider) => { const list = toolWithProvider.tools return (