import React from 'react';
import { Box, Typography, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { ConfigurationFormContainer } from './configuration-form-container';
import { 
  ChunkMethodItem,
  RaptorConfigItems,
  KnowledgeGraphConfigItems
} from './common-items';

export function QAConfiguration({ buildMode = 'buildIn' }: { buildMode?: 'buildIn' | 'pipeline' }) {
  const { t } = useTranslation();

  return (
    <ConfigurationFormContainer>
      <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
        {/* 第一部分：基础配置 */}
        {buildMode === 'buildIn' && (
          <Accordion defaultExpanded>
            <AccordionSummary expandIcon={<ExpandMoreIcon />}>
              <Typography variant="h6">{t('knowledge.config.basicConfig')}</Typography>
            </AccordionSummary>
            <AccordionDetails>
              <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
                {/* 分块方法 */}
                <ChunkMethodItem />
              </Box>
            </AccordionDetails>
          </Accordion>
        )}

        {/* 第二部分：RAPTOR策略 */}
        <Accordion>
          <AccordionSummary expandIcon={<ExpandMoreIcon />}>
            <Typography variant="h6">{t('knowledge.config.raptorStrategy')}</Typography>
          </AccordionSummary>
          <AccordionDetails>
            <RaptorConfigItems />
          </AccordionDetails>
        </Accordion>

        {/* 第三部分：Knowledge Graph 知识图谱 */}
        <Accordion>
          <AccordionSummary expandIcon={<ExpandMoreIcon />}>
            <Typography variant="h6">{t('knowledge.config.knowledgeGraph')}</Typography>
          </AccordionSummary>
          <AccordionDetails>
            <KnowledgeGraphConfigItems />
          </AccordionDetails>
        </Accordion>
      </Box>
    </ConfigurationFormContainer>
  );
}