import React, { useCallback, useEffect, useState } from 'react'; import { Alert, Button, Card, Collapse, Descriptions, Drawer, Empty, Select, Space, Spin, Table, Tag, Tooltip, Typography, message, } from 'antd'; import { ArrowLeftOutlined, EyeOutlined, PlayCircleOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons'; import { useNavigate, useParams } from 'react-router-dom'; import { getAdminShotSegmentDetail, getAdminShotSegments, getAdminShotTaskSetDetail } from '../api'; import type { ShotAiSuggestionOut, ShotSegmentDetailOut, ShotSegmentOut, ShotTaskSetDetailOut } from '../types'; import { formatDate } from '../utils/formatDate'; import { getStepCodeLabel } from './adminReplication/components/StatusTag'; import { getShotAnalysisStatusMeta, getShotReplicateStatusMeta, getShotSplitStatusMeta, getShotTaskStatusMeta } from '../utils/shotReplicateStatus'; const RAW_API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000'; const RESOURCE_BASE = RAW_API_BASE.replace(/\/api\/?$/i, '').replace(/\/$/, ''); const PAGE_SIZE = 20; const SOURCE_OPTIONS = [ { value: 'ai_suggestion', label: 'AI 建议' }, { value: 'custom', label: '自定义' }, ]; const SPLIT_STATUS_OPTIONS = [ { value: 'none', label: '未拆镜' }, { value: 'pending', label: '待拆镜' }, { value: 'processing', label: '拆镜中' }, { value: 'completed', label: '拆镜完成' }, { value: 'failed', label: '拆镜失败' }, { value: 'retry_waiting', label: '等待重试' }, ]; const ANALYSIS_STATUS_OPTIONS = [ { value: 'not_required', label: '无需分析' }, { value: 'pending', label: '待分析' }, { value: 'processing', label: '分析中' }, { value: 'completed', label: '分析完成' }, { value: 'failed', label: '分析失败' }, ]; const REPLICATE_STATUS_OPTIONS = [ { value: 'not_started', label: '未复刻' }, { value: 'project_created', label: '已创建项目' }, { value: 'processing', label: '复刻中' }, { value: 'completed', label: '复刻完成' }, { value: 'failed', label: '复刻失败' }, ]; const apiUrl = (url?: string | null): string => { if (!url) return ''; const value = String(url).trim(); if (!value) return ''; if (/^(https?:)?\/\//i.test(value) || /^(blob|data):/i.test(value)) return value; return `${RESOURCE_BASE}${value.startsWith('/') ? value : `/${value}`}`; }; const safeDate = (value?: string | null): string => (value ? formatDate(value) : '-'); const shortId = (value?: string | null): string => (!value ? '-' : value.length > 16 ? `${value.slice(0, 10)}...` : value); const StatusTag: React.FC<{ status?: string | null; kind?: 'task' | 'analysis' | 'split' | 'replicate' }> = ({ status, kind = 'task' }) => { if (!status) return -; const meta = kind === 'analysis' ? getShotAnalysisStatusMeta(status) : (kind === 'split' ? getShotSplitStatusMeta(status) : (kind === 'replicate' ? getShotReplicateStatusMeta(status) : getShotTaskStatusMeta(status))); return {meta.text}; }; const JsonBlock: React.FC<{ value: unknown; maxHeight?: number }> = ({ value, maxHeight = 420 }) => (
    {JSON.stringify(value ?? {}, null, 2)}
  
); const VideoPreview: React.FC<{ url?: string | null; height?: number }> = ({ url, height = 280 }) => { if (!url) return ; return