import { RiQuestionLine } from '@remixicon/react' import { memo, useCallback, } from 'react' import { useTranslation } from 'react-i18next' import { Economic, HighQuality, } from '@/app/components/base/icons/src/vender/knowledge' import Input from '@/app/components/base/input' import Slider from '@/app/components/base/slider' import Tooltip from '@/app/components/base/tooltip' import { Field } from '@/app/components/workflow/nodes/_base/components/layout' import { cn } from '@/utils/classnames' import { ChunkStructureEnum, IndexMethodEnum, } from '../types' import OptionCard from './option-card' type IndexMethodProps = { chunkStructure: ChunkStructureEnum indexMethod?: IndexMethodEnum onIndexMethodChange: (value: IndexMethodEnum) => void keywordNumber: number onKeywordNumberChange: (value: number) => void readonly?: boolean } const IndexMethod = ({ chunkStructure, indexMethod, onIndexMethodChange, keywordNumber, onKeywordNumberChange, readonly = false, }: IndexMethodProps) => { const { t } = useTranslation() const isHighQuality = indexMethod === IndexMethodEnum.QUALIFIED const isEconomy = indexMethod === IndexMethodEnum.ECONOMICAL const handleIndexMethodChange = useCallback((newIndexMethod: IndexMethodEnum) => { onIndexMethodChange(newIndexMethod) }, [onIndexMethodChange]) const handleInputChange = useCallback((e: React.ChangeEvent) => { const value = Number(e.target.value) if (!Number.isNaN(value)) onKeywordNumberChange(value) }, [onKeywordNumberChange]) return (
id={IndexMethodEnum.QUALIFIED} selectedId={indexMethod} icon={( )} title={t('stepTwo.qualified', { ns: 'datasetCreation' })} description={t('form.indexMethodHighQualityTip', { ns: 'datasetSettings' })} onClick={handleIndexMethodChange} isRecommended effectColor="orange" > { chunkStructure === ChunkStructureEnum.general && ( )} title={t('form.indexMethodEconomy', { ns: 'datasetSettings' })} description={t('form.indexMethodEconomyTip', { ns: 'datasetSettings', count: keywordNumber })} onClick={handleIndexMethodChange} effectColor="blue" >
{t('form.numberOfKeywords', { ns: 'datasetSettings' })}
) }
) } export default memo(IndexMethod)