astrbot_plugin_imagestudio/frontend/standalone-web/src/features/materials/AdvancedMaterialImportPage.vue

1863 行
105 KiB
Vue

<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue"
import { endpoints } from "../../../../shared/api/endpoints"
import { deleteJson, getJson, postJson } from "../../../../shared/api/client"
import type {
AdvancedMaterial,
AdvancedMaterialDecisionRequest,
AdvancedMaterialImport,
AdvancedMaterialUploadRequest,
AdvancedMaterialUploadResult,
AdvancedStyleConsensus,
AdvancedStyleSetUploadRequest,
AdvancedStyleSource,
AdvancedStyleValidationCase,
AdvancedMaterialValidationAttempt,
} from "../../../../shared/types/advanced-material"
import type { MaterialCategory } from "../../../../shared/types/material"
import type { MediaFetchResult, MediaSignResult } from "../../../../shared/types/storage"
import { materialCategoryLabel } from "../../material-labels"
import ImagePreviewDialog from "../../components/ImagePreviewDialog.vue"
import {
advancedAttemptStatusMeta,
advancedImportStatusMeta,
advancedMaterialErrorMessage,
firstRecord,
listItems,
sortAdvancedImports,
sortAdvancedMaterials,
sortValidationAttempts,
type MaterialLibraryView,
} from "./advanced-material-state"
const MAX_UPLOAD_BYTES = 20 * 1024 * 1024
const MIN_STYLE_IMAGES = 2
const MAX_STYLE_IMAGES = 8
const POLL_INTERVAL_MS = 4500
interface StyleUploadDraft {
id: string
file: File
dataUrl: string
source: AdvancedMaterialUploadRequest["upload_source"]
}
const props = withDefaults(defineProps<{
mode: Extract<MaterialLibraryView, "advanced" | "advanced-import">
categories: MaterialCategory[]
canManage?: boolean
}>(), {
canManage: true,
})
const emit = defineEmits<{
navigate: [view: MaterialLibraryView]
changed: []
}>()
const imports = ref<AdvancedMaterialImport[]>([])
const materials = ref<AdvancedMaterial[]>([])
const attempts = ref<AdvancedMaterialValidationAttempt[]>([])
const selectedImportId = ref("")
const selectedImportDetail = ref<AdvancedMaterialImport | null>(null)
const loading = ref(false)
const detailLoading = ref(false)
const actionBusy = ref("")
const deleteConfirmImportId = ref("")
const error = ref("")
const message = ref("")
const signedMediaUrls = ref<Record<string, string>>({})
const pollBusy = ref(false)
const previewImageSrc = ref("")
const previewImageTitle = ref("")
const fileInput = ref<HTMLInputElement | null>(null)
const uploadFile = ref<File | null>(null)
const uploadDataUrl = ref("")
const uploadSource = ref<AdvancedMaterialUploadRequest["upload_source"]>("file")
const styleUploadDrafts = ref<StyleUploadDraft[]>([])
const uploadDisplayName = ref("")
const uploadCategoryId = ref("")
const adjustmentText = ref("")
const validationInstructionText = ref("")
const decisionNotes = ref("")
const fidelityPercent = ref(85)
const acceptConfirmed = ref(false)
let pollTimer = 0
const ownedMediaObjectUrls = new Set<string>()
const rootCategories = computed(() =>
props.categories
.filter((category) => !category.parent_id && category.category_type !== "accessory_group")
.sort((left, right) => left.sort_order - right.sort_order || left.name.localeCompare(right.name, "zh-CN")),
)
const selectedUploadCategory = computed(() =>
rootCategories.value.find((category) => category.category_id === uploadCategoryId.value) ?? null,
)
const styleSetUploadEnabled = computed(() => isStyleCategory(selectedUploadCategory.value))
const sortedImports = computed(() => sortAdvancedImports(imports.value))
const sortedMaterials = computed(() => sortAdvancedMaterials(materials.value))
const selectedImport = computed(() =>
selectedImportDetail.value?.import_id === selectedImportId.value
? selectedImportDetail.value
: imports.value.find((item) => item.import_id === selectedImportId.value) ?? null,
)
const sortedAttempts = computed(() => sortValidationAttempts(attempts.value))
const currentAttempt = computed(() => {
const currentId = selectedImport.value?.current_attempt_id
return sortedAttempts.value.find((attempt) => attempt.attempt_id === currentId) ?? sortedAttempts.value[0] ?? null
})
const selectedStyleSet = computed(() => isStyleSetImport(selectedImport.value))
const styleSources = computed(() =>
[...(selectedImport.value?.sources ?? [])].sort((left, right) =>
Number(left.sort_order || 0) - Number(right.sort_order || 0),
),
)
const activeStyleSources = computed(() => styleSources.value.filter((source) => !source.excluded))
const recognizedStyleSources = computed(() =>
activeStyleSources.value.filter((source) => ["recognized", "completed", "succeeded"].includes(normalizeStatus(source.status))),
)
const styleConsensus = computed(() => selectedImport.value?.consensus ?? null)
const styleValidationCases = computed(() => {
const cases = currentAttempt.value?.validation_cases?.length
? currentAttempt.value.validation_cases
: selectedImport.value?.validation_cases ?? []
const rank: Record<string, number> = { portrait: 0, fullbody: 1, novel_scene: 2 }
return [...cases].sort((left, right) => (rank[left.scenario] ?? 99) - (rank[right.scenario] ?? 99))
})
const selectedStatus = computed(() => advancedImportStatusMeta(selectedImport.value?.status ?? ""))
const currentAttemptStatus = computed(() => advancedAttemptStatusMeta(currentAttempt.value?.status ?? ""))
const activeImportCount = computed(() =>
imports.value.filter((item) => advancedImportStatusMeta(item.status).busy).length,
)
const reviewImportCount = computed(() =>
imports.value.filter((item) =>
["pending_review", "awaiting_review", "rejected", "adjustment_required"].includes(normalizeStatus(item.status)),
).length,
)
const failedImportCount = computed(() =>
imports.value.filter((item) =>
["failed", "recognition_failed", "validation_failed"].includes(normalizeStatus(item.status)),
).length,
)
const uploadReady = computed(() =>
Boolean(
props.canManage &&
(styleSetUploadEnabled.value
? styleUploadDrafts.value.length >= MIN_STYLE_IMAGES && styleUploadDrafts.value.length <= MAX_STYLE_IMAGES
: uploadFile.value && uploadDataUrl.value) &&
uploadDisplayName.value.trim() &&
uploadCategoryId.value &&
!actionBusy.value,
),
)
const canStartValidation = computed(() => {
const item = selectedImport.value
if (!item || !props.canManage || actionBusy.value) return false
if (selectedStyleSet.value) return false
if ([
"accepted",
"archived",
"cancelled",
"recognition_queued",
"recognizing",
"pending_recognition",
"validation_queued",
"validating",
"awaiting_review",
].includes(normalizeStatus(item.status))) {
return false
}
return Boolean(item.recognition_prompt && !currentAttemptStatus.value.busy)
})
const canReviewCurrentAttempt = computed(() => {
const attempt = currentAttempt.value
if (!attempt || !props.canManage || actionBusy.value) return false
if (selectedStyleSet.value) {
return styleValidationCases.value.length === 3 && styleValidationCases.value.every((item) =>
["succeeded", "completed", "pending_review", "awaiting_review"].includes(normalizeStatus(item.status)) &&
Boolean(styleValidationCaseImageUrl(item)),
)
}
return ["succeeded", "completed", "pending_review", "awaiting_review"].includes(normalizeStatus(attempt.status)) && Boolean(attemptImageUrl(attempt))
})
const uploadPreview = computed(() => uploadDataUrl.value)
const canRunStyleConsensus = computed(() => Boolean(
selectedStyleSet.value &&
props.canManage &&
recognizedStyleSources.value.length >= MIN_STYLE_IMAGES &&
!["queued", "running"].includes(normalizeStatus(styleConsensus.value?.status ?? "")) &&
![
"ready_for_validation",
"validating",
"validation_partial_failed",
"awaiting_review",
"accepted",
"cancelled",
"archived",
].includes(normalizeStatus(selectedImport.value?.status ?? "")) &&
!actionBusy.value,
))
const canEditStyleSources = computed(() => Boolean(
selectedStyleSet.value &&
(!styleConsensus.value || ["failed", "cancelled"].includes(normalizeStatus(styleConsensus.value.status))),
))
watch(
() => props.categories,
() => {
if (!uploadCategoryId.value && rootCategories.value.length) {
uploadCategoryId.value = rootCategories.value[0].category_id
}
},
{ immediate: true },
)
watch(styleSetUploadEnabled, (enabled, previous) => {
if (enabled === previous) return
if (enabled && uploadFile.value && uploadDataUrl.value) {
styleUploadDrafts.value = [{
id: styleUploadId(uploadFile.value),
file: uploadFile.value,
dataUrl: uploadDataUrl.value,
source: uploadSource.value,
}]
uploadFile.value = null
uploadDataUrl.value = ""
return
}
if (!enabled && styleUploadDrafts.value.length) {
const [first, ...discarded] = styleUploadDrafts.value
uploadFile.value = first.file
uploadDataUrl.value = first.dataUrl
uploadSource.value = first.source
styleUploadDrafts.value = []
if (discarded.length) message.value = "当前分类只支持单图,已保留第一张图片。"
}
})
watch(
() => props.mode,
(mode) => {
error.value = ""
message.value = ""
if (mode === "advanced" && !selectedImportId.value && sortedImports.value.length) {
void selectImport(sortedImports.value[0].import_id)
}
},
)
watch(selectedImportId, () => {
closeImagePreview()
adjustmentText.value = ""
validationInstructionText.value = ""
decisionNotes.value = ""
fidelityPercent.value = 85
acceptConfirmed.value = false
})
onMounted(async () => {
await refreshAll()
pollTimer = window.setInterval(() => {
if (
document.visibilityState === "visible" &&
shouldPoll() &&
!pollBusy.value &&
!loading.value &&
!detailLoading.value &&
!actionBusy.value
) {
void pollActiveState()
}
}, POLL_INTERVAL_MS)
})
onBeforeUnmount(() => {
if (pollTimer) window.clearInterval(pollTimer)
for (const url of ownedMediaObjectUrls) URL.revokeObjectURL(url)
ownedMediaObjectUrls.clear()
})
async function refreshAll(silent = false) {
if (!silent) loading.value = true
if (!silent) error.value = ""
try {
const [importPayload, materialPayload] = await Promise.all([
props.canManage
? getJson<unknown>(endpoints.advancedMaterialImports, { page: 1, page_size: 100 })
: Promise.resolve({ items: [] }),
getJson<unknown>(endpoints.advancedMaterials, { page: 1, page_size: 100 }),
])
imports.value = listItems<AdvancedMaterialImport>(importPayload).map(normalizeImport)
materials.value = listItems<AdvancedMaterial>(materialPayload).map(normalizeMaterial)
await resolveRecordMedia([...imports.value, ...materials.value])
if (selectedImportId.value) {
const exists = imports.value.some((item) => item.import_id === selectedImportId.value)
if (exists) await loadImportDetail(selectedImportId.value, true)
} else if (sortedImports.value.length) {
await selectImport(sortedImports.value[0].import_id)
}
} catch (err) {
if (!silent) error.value = errorMessage(err)
} finally {
if (!silent) loading.value = false
}
}
async function pollActiveState() {
if (pollBusy.value) return
pollBusy.value = true
try {
const importId = selectedImportId.value
const selectedWasBusy = selectedStateIsBusy()
if (importId && selectedWasBusy) {
await loadImportDetail(importId, true)
const detail = selectedImportDetail.value
if (detail) {
imports.value = replaceImportSummary(imports.value, detail)
}
if (selectedWasBusy && !selectedStateIsBusy()) {
await refreshAll(true)
}
return
}
await refreshImportSummaries()
} catch {
// Poll failures are transient and should not replace the user's current
// page with an error state or trigger a visual reset.
} finally {
pollBusy.value = false
}
}
async function refreshImportSummaries() {
if (!props.canManage) return
const payload = await getJson<unknown>(endpoints.advancedMaterialImports, { page: 1, page_size: 100 })
const nextItems = listItems<AdvancedMaterialImport>(payload).map(normalizeImport)
imports.value = mergeImportSummaries(imports.value, nextItems)
const selectedSummary = imports.value.find((item) => item.import_id === selectedImportId.value)
if (selectedImportDetail.value && selectedSummary) {
selectedImportDetail.value = preserveStableMedia(selectedImportDetail.value, {
...selectedImportDetail.value,
...selectedSummary,
sources: selectedImportDetail.value.sources,
consensus: selectedImportDetail.value.consensus,
validation_cases: selectedImportDetail.value.validation_cases,
})
}
await resolveRecordMedia(imports.value)
}
async function selectImport(importId: string) {
deleteConfirmImportId.value = ""
selectedImportId.value = importId
await loadImportDetail(importId)
}
async function deleteImport() {
const item = selectedImport.value
if (!item || actionBusy.value || item.accepted_material_id) return
if (deleteConfirmImportId.value !== item.import_id) {
deleteConfirmImportId.value = item.import_id
message.value = "再次点击“确认删除导入”将取消残留任务,并删除该导入、样本、验证轮次和独立文件。"
error.value = ""
return
}
actionBusy.value = "delete-import"
error.value = ""
message.value = ""
try {
await deleteJson<Record<string, unknown>>(endpoints.advancedMaterialImportDelete(item.import_id))
const deletedName = item.display_name
selectedImportId.value = ""
selectedImportDetail.value = null
attempts.value = []
deleteConfirmImportId.value = ""
await refreshAll(true)
message.value = `已删除进阶导入“${deletedName}”。`
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function loadImportDetail(importId: string, silent = false) {
if (!silent) detailLoading.value = true
try {
const [detailPayload, attemptPayload] = await Promise.all([
getJson<unknown>(endpoints.advancedMaterialImport(importId)),
getJson<unknown>(endpoints.advancedMaterialValidationAttempts(importId)),
])
const detailRecord = detailPayload && typeof detailPayload === "object"
? detailPayload as Record<string, unknown>
: {}
const importRecord = firstRecord<AdvancedMaterialImport>(detailPayload, ["import", "item"])
?? (detailPayload as AdvancedMaterialImport)
const nextDetail = normalizeImport({
...importRecord,
sources: Array.isArray(detailRecord.sources) ? detailRecord.sources as AdvancedStyleSource[] : importRecord.sources,
consensus: detailRecord.consensus && typeof detailRecord.consensus === "object"
? detailRecord.consensus as AdvancedStyleConsensus
: importRecord.consensus,
validation_cases: Array.isArray(detailRecord.validation_cases)
? detailRecord.validation_cases as AdvancedStyleValidationCase[]
: importRecord.validation_cases,
})
const nextAttempts = listItems<AdvancedMaterialValidationAttempt>(attemptPayload).map(normalizeAttempt)
selectedImportDetail.value = preserveStableMedia(selectedImportDetail.value, nextDetail)
attempts.value = mergeAttempts(attempts.value, nextAttempts)
await resolveRecordMedia([
selectedImportDetail.value,
...(selectedImportDetail.value.sources ?? []),
...(selectedImportDetail.value.validation_cases ?? []),
...attempts.value,
...attempts.value.flatMap((attempt) => attempt.validation_cases ?? []),
])
} catch (err) {
if (!silent) error.value = errorMessage(err)
} finally {
if (!silent) detailLoading.value = false
}
}
function openFilePicker() {
if (props.canManage && !actionBusy.value) fileInput.value?.click()
}
async function onFileInput(event: Event) {
const files = Array.from((event.target as HTMLInputElement).files ?? [])
if (files.length) await prepareUploadFiles(files, "file")
;(event.target as HTMLInputElement).value = ""
}
async function onPaste(event: ClipboardEvent) {
const files = Array.from(event.clipboardData?.items ?? [])
.filter((item) => item.kind === "file" && item.type.startsWith("image/"))
.map((item) => item.getAsFile())
.filter((item): item is File => Boolean(item))
if (!files.length) return
event.preventDefault()
await prepareUploadFiles(files, "paste")
}
async function onDrop(event: DragEvent) {
const files = Array.from(event.dataTransfer?.files ?? []).filter((item) => item.type.startsWith("image/"))
if (files.length) await prepareUploadFiles(files, "drop")
}
async function prepareUploadFiles(files: File[], source: AdvancedMaterialUploadRequest["upload_source"]) {
if (!styleSetUploadEnabled.value) {
await prepareUploadFile(files[0], source)
return
}
error.value = ""
message.value = ""
const existing = new Set(styleUploadDrafts.value.map((item) => styleUploadId(item.file)))
const accepted = files.filter((file) => {
if (!file.type.startsWith("image/")) return false
if (file.size > MAX_UPLOAD_BYTES) return false
const id = styleUploadId(file)
if (existing.has(id)) return false
existing.add(id)
return true
}).slice(0, Math.max(0, MAX_STYLE_IMAGES - styleUploadDrafts.value.length))
if (!accepted.length) {
error.value = styleUploadDrafts.value.length >= MAX_STYLE_IMAGES
? `画风样本最多上传 ${MAX_STYLE_IMAGES} 张。`
: "没有可添加的图片;请检查格式、20 MB 大小限制或重复文件。"
return
}
try {
const drafts = await Promise.all(accepted.map(async (file) => ({
id: styleUploadId(file),
file,
dataUrl: await readFileAsDataUrl(file),
source,
})))
styleUploadDrafts.value = [...styleUploadDrafts.value, ...drafts]
if (!uploadDisplayName.value.trim()) uploadDisplayName.value = `${filenameStem(drafts[0].file.name) || "未命名"}画风组`
if (accepted.length < files.length) {
message.value = `已添加 ${accepted.length} 张;重复、格式异常、超限或超过 8 张的图片已跳过。`
}
} catch (err) {
error.value = errorMessage(err)
}
}
async function prepareUploadFile(file: File, source: AdvancedMaterialUploadRequest["upload_source"]) {
error.value = ""
message.value = ""
if (!file.type.startsWith("image/")) {
error.value = "请选择 PNG、JPEG、WebP 等图片文件。"
return
}
if (file.size > MAX_UPLOAD_BYTES) {
error.value = "单张素材不能超过 20 MB。"
return
}
try {
uploadDataUrl.value = await readFileAsDataUrl(file)
uploadFile.value = file
uploadSource.value = source
if (!uploadDisplayName.value.trim()) uploadDisplayName.value = filenameStem(file.name) || "进阶素材"
} catch (err) {
error.value = errorMessage(err)
}
}
function resetUpload() {
uploadFile.value = null
uploadDataUrl.value = ""
styleUploadDrafts.value = []
uploadDisplayName.value = ""
uploadSource.value = "file"
}
function removeStyleUpload(id: string) {
if (actionBusy.value) return
styleUploadDrafts.value = styleUploadDrafts.value.filter((item) => item.id !== id)
}
function moveStyleUpload(id: string, direction: -1 | 1) {
if (actionBusy.value) return
const current = styleUploadDrafts.value.findIndex((item) => item.id === id)
const target = current + direction
if (current < 0 || target < 0 || target >= styleUploadDrafts.value.length) return
const next = [...styleUploadDrafts.value]
const [item] = next.splice(current, 1)
next.splice(target, 0, item)
styleUploadDrafts.value = next
}
async function submitUpload() {
if (!uploadReady.value) return
actionBusy.value = "upload"
error.value = ""
message.value = ""
try {
if (styleSetUploadEnabled.value) {
const payload: AdvancedStyleSetUploadRequest = {
display_name: uploadDisplayName.value.trim(),
category_id: uploadCategoryId.value,
images: styleUploadDrafts.value.map((draft, index) => ({
client_source_id: draft.id,
image_data_url: draft.dataUrl,
filename: draft.file.name || `style-source-${index + 1}.png`,
...(draft.file.type.trim() ? { content_type: draft.file.type.trim() } : {}),
size_bytes: draft.file.size,
upload_source: draft.source,
sort_order: index,
is_primary: index === 0,
})),
metadata: { pipeline: "advanced_style_consensus_validation", workflow_kind: "style_set" },
}
const result = await postJson<AdvancedMaterialUploadResult | AdvancedMaterialImport>(
endpoints.advancedMaterialStyleSetUpload,
payload,
)
const created = normalizeImport(
firstRecord<AdvancedMaterialImport>(result, ["import", "item"]) ?? (result as AdvancedMaterialImport),
)
message.value = `${payload.images.length} 张画风样本已拆分入队,将并行识别并在完成后交叉分析。`
resetUpload()
await refreshAll(true)
if (created.import_id) await selectImport(created.import_id)
emit("changed")
return
}
if (!uploadFile.value) return
const declaredContentType = uploadFile.value.type.trim()
const payload: AdvancedMaterialUploadRequest = {
image_data_url: uploadDataUrl.value,
display_name: uploadDisplayName.value.trim(),
category_id: uploadCategoryId.value,
filename: uploadFile.value.name || "advanced-material.png",
...(declaredContentType ? { content_type: declaredContentType } : {}),
size_bytes: uploadFile.value.size,
upload_source: uploadSource.value,
metadata: { pipeline: "advanced_material_fidelity_validation" },
}
const result = await postJson<AdvancedMaterialUploadResult | AdvancedMaterialImport>(
endpoints.advancedMaterialImportUpload,
payload,
)
const created = normalizeImport(
firstRecord<AdvancedMaterialImport>(result, ["import", "item"]) ?? (result as AdvancedMaterialImport),
)
message.value = "进阶素材已加入识别与还原度验证队列。完成后可在这里对照源图审核。"
resetUpload()
await refreshAll(true)
if (created.import_id) await selectImport(created.import_id)
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function retryImport() {
const item = selectedImport.value
if (!item || actionBusy.value) return
actionBusy.value = "retry"
error.value = ""
message.value = ""
try {
await postJson<unknown>(endpoints.advancedMaterialImportRetry(item.import_id), {})
message.value = "重试任务已加入队列。"
await refreshAll(true)
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function retryStyleSource(source: AdvancedStyleSource) {
const item = selectedImport.value
if (!item || actionBusy.value) return
actionBusy.value = `source-retry:${source.source_id}`
error.value = ""
message.value = ""
try {
await postJson<unknown>(endpoints.advancedMaterialStyleSourceRetry(item.import_id, source.source_id), {})
message.value = `样本 ${source.sort_order + 1} 已重新加入独立识别队列。`
await loadImportDetail(item.import_id, true)
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function excludeStyleSource(source: AdvancedStyleSource, excluded = true) {
const item = selectedImport.value
if (!item || actionBusy.value || source.is_primary) return
actionBusy.value = `source-exclude:${source.source_id}`
error.value = ""
message.value = ""
try {
await postJson<unknown>(endpoints.advancedMaterialStyleSourceExclude(item.import_id, source.source_id), { excluded })
message.value = excluded
? `样本 ${source.sort_order + 1} 已从交叉分析中排除。`
: `样本 ${source.sort_order + 1} 已恢复;如识别失败可单独重试。`
await loadImportDetail(item.import_id, true)
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function createStyleConsensus() {
const item = selectedImport.value
if (!item || !canRunStyleConsensus.value) return
actionBusy.value = "style-consensus"
error.value = ""
message.value = ""
try {
await postJson<unknown>(endpoints.advancedMaterialStyleConsensus(item.import_id), {
included_source_ids: recognizedStyleSources.value.map((source) => source.source_id),
})
message.value = "画风交叉分析已入队;模型会同时读取所有有效原图与逐图报告。"
await loadImportDetail(item.import_id, true)
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function retryStyleValidationCase(validationCase: AdvancedStyleValidationCase) {
const item = selectedImport.value
if (!item || actionBusy.value) return
actionBusy.value = `case-retry:${validationCase.case_id}`
error.value = ""
message.value = ""
try {
await postJson<unknown>(
endpoints.advancedMaterialStyleValidationCaseRetry(item.import_id, validationCase.case_id),
{},
)
message.value = `${styleValidationScenarioLabel(validationCase.scenario)}已重新加入独立生图队列。`
await loadImportDetail(item.import_id, true)
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function createValidationAttempt() {
const item = selectedImport.value
if (!item || !canStartValidation.value) return
actionBusy.value = "validation"
error.value = ""
message.value = ""
try {
await postJson<unknown>(endpoints.advancedMaterialValidationAttempts(item.import_id), {
adjustment_text: adjustmentText.value.trim() || undefined,
})
message.value = "还原度验证图已加入生成队列。"
adjustmentText.value = ""
await refreshAll(true)
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function rejectAndRegenerate() {
const item = selectedImport.value
const attempt = currentAttempt.value
const adjustment = adjustmentText.value.trim()
const validationInstruction = validationInstructionText.value.trim()
if (!item || !attempt || !canReviewCurrentAttempt.value) return
if (!adjustment && !validationInstruction) {
error.value = selectedStyleSet.value
? "请至少填写画风修正或下一轮验证内容。"
: "请先说明验证图与源图的差异,以及下一轮需要怎样调整。"
return
}
actionBusy.value = "reject"
error.value = ""
message.value = ""
try {
const payload: AdvancedMaterialDecisionRequest = {
adjustment_text: selectedStyleSet.value ? undefined : adjustment,
style_adjustment_text: selectedStyleSet.value ? adjustment || undefined : undefined,
validation_instruction: selectedStyleSet.value ? validationInstruction || undefined : undefined,
fidelity_score: fidelityPercent.value / 100,
decision_notes: decisionNotes.value.trim() || undefined,
reuse_validation_scenarios: selectedStyleSet.value && !validationInstruction || undefined,
}
await postJson<unknown>(endpoints.advancedMaterialAttemptReject(item.import_id, attempt.attempt_id), payload)
message.value = "本轮反馈已保存,调整后的下一轮验证图已加入队列。"
adjustmentText.value = ""
validationInstructionText.value = ""
decisionNotes.value = ""
acceptConfirmed.value = false
await refreshAll(true)
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
async function acceptAttempt() {
const item = selectedImport.value
const attempt = currentAttempt.value
if (!item || !attempt || !canReviewCurrentAttempt.value || !acceptConfirmed.value) return
actionBusy.value = "accept"
error.value = ""
message.value = ""
try {
const payload: AdvancedMaterialDecisionRequest = {
fidelity_score: fidelityPercent.value / 100,
decision_notes: decisionNotes.value.trim() || undefined,
}
await postJson<unknown>(endpoints.advancedMaterialAttemptAccept(item.import_id, attempt.attempt_id), payload)
message.value = "验证结果已封存,素材已进入高优先级进阶素材库。"
acceptConfirmed.value = false
await refreshAll(true)
emit("changed")
} catch (err) {
error.value = errorMessage(err)
} finally {
actionBusy.value = ""
}
}
function shouldPoll() {
return imports.value.some((item) => advancedImportStatusMeta(item.status).busy) ||
attempts.value.some((attempt) => advancedAttemptStatusMeta(attempt.status).busy) ||
activeStyleSources.value.some((source) => ["uploaded", "recognition_queued", "recognizing", "queued", "running"].includes(normalizeStatus(source.status))) ||
["queued", "running"].includes(normalizeStatus(styleConsensus.value?.status ?? "")) ||
styleValidationCases.value.some((item) => ["queued", "running", "validating"].includes(normalizeStatus(item.status)))
}
function selectedStateIsBusy() {
return Boolean(
advancedImportStatusMeta(selectedImport.value?.status ?? "").busy ||
attempts.value.some((attempt) => advancedAttemptStatusMeta(attempt.status).busy) ||
activeStyleSources.value.some((source) => ["uploaded", "recognition_queued", "recognizing", "queued", "running"].includes(normalizeStatus(source.status))) ||
["queued", "running"].includes(normalizeStatus(styleConsensus.value?.status ?? "")) ||
styleValidationCases.value.some((item) => ["queued", "running", "validating"].includes(normalizeStatus(item.status)))
)
}
function replaceImportSummary(items: AdvancedMaterialImport[], detail: AdvancedMaterialImport) {
const index = items.findIndex((item) => item.import_id === detail.import_id)
if (index < 0) return [detail, ...items]
const next = [...items]
next[index] = preserveStableMedia(items[index], detail)
return next
}
function mergeImportSummaries(current: AdvancedMaterialImport[], incoming: AdvancedMaterialImport[]) {
const currentById = new Map(current.map((item) => [item.import_id, item]))
return incoming.map((item) => preserveStableMedia(currentById.get(item.import_id) ?? null, item))
}
function mergeAttempts(
current: AdvancedMaterialValidationAttempt[],
incoming: AdvancedMaterialValidationAttempt[],
) {
const currentById = new Map(current.map((item) => [item.attempt_id, item]))
return incoming.map((item) => preserveStableMedia(currentById.get(item.attempt_id) ?? null, item))
}
function preserveStableMedia<T extends object>(current: T | null, incoming: T): T {
if (!current) return incoming
const currentRecord = current as Record<string, unknown>
const incomingRecord = incoming as Record<string, unknown>
const next = { ...incoming }
for (const [key, value] of Object.entries(currentRecord)) {
if (!key.endsWith("_url")) continue
const uriKey = key.replace(/_url$/, "_uri")
const currentUri = String(currentRecord[uriKey] || "")
const incomingUri = String(incomingRecord[uriKey] || "")
if (currentUri && currentUri === incomingUri && value) {
;(next as Record<string, unknown>)[key] = value
}
}
return next
}
function sourceImageUrl(item: AdvancedMaterialImport | AdvancedMaterial) {
return mediaUrl(item.source_thumbnail_uri, item.source_image_uri, item.source_thumbnail_url, item.source_image_url)
}
function validationImageUrl(item: AdvancedMaterial) {
return mediaUrl(
item.validation_thumbnail_uri,
item.validation_image_uri,
item.validation_thumbnail_url,
item.validation_image_url,
)
}
function attemptImageUrl(item: AdvancedMaterialValidationAttempt) {
return mediaUrl(
item.validation_thumbnail_uri,
item.validation_image_uri,
item.validation_thumbnail_url,
item.validation_image_url,
)
}
function styleSourceImageUrl(item: AdvancedStyleSource) {
return mediaUrl(
item.source_thumbnail_uri,
item.source_image_uri,
item.thumbnail_uri,
item.image_uri,
item.source_thumbnail_url,
item.source_image_url,
item.thumbnail_url,
item.image_url,
)
}
function styleValidationCaseImageUrl(item: AdvancedStyleValidationCase) {
return mediaUrl(
item.validation_thumbnail_uri,
item.validation_image_uri,
item.validation_thumbnail_url,
item.validation_image_url,
)
}
function sourcePreviewUrl(item: AdvancedMaterialImport | AdvancedMaterial | AdvancedStyleSource) {
return mediaUrl(
item.source_image_uri,
item.source_image_url,
item.source_thumbnail_uri,
item.source_thumbnail_url,
)
}
function validationCasePreviewUrl(item: AdvancedStyleValidationCase) {
return mediaUrl(
item.validation_image_uri,
item.validation_image_url,
item.validation_thumbnail_uri,
item.validation_thumbnail_url,
)
}
function attemptPreviewUrl(item: AdvancedMaterialValidationAttempt) {
return mediaUrl(
item.validation_image_uri,
item.validation_image_url,
item.validation_thumbnail_uri,
item.validation_thumbnail_url,
)
}
function openImagePreview(src: string, title: string) {
const resolved = String(src || "").trim()
if (!resolved) return
previewImageSrc.value = resolved
previewImageTitle.value = title
}
function closeImagePreview() {
previewImageSrc.value = ""
previewImageTitle.value = ""
}
function mediaUrl(...values: Array<string | null | undefined>) {
for (const value of values) {
const candidate = String(value || "").trim()
if (!candidate) continue
if (signedMediaUrls.value[candidate]) return signedMediaUrls.value[candidate]
if (/^(?:https?:|data:|blob:|\/)/i.test(candidate)) return candidate
}
return ""
}
async function resolveRecordMedia(records: unknown[]) {
const uris = new Set<string>()
const signedUrls = new Set<string>()
for (const record of records) {
if (!record || typeof record !== "object") continue
const mediaRecord = record as Record<string, unknown>
for (const [key, value] of Object.entries(mediaRecord)) {
if (key.endsWith("_uri") && typeof value === "string" && value.startsWith("storage://")) uris.add(value)
if (key.endsWith("_url") && typeof value === "string" && signedMediaToken(value)) {
const pairedUri = String(mediaRecord[key.replace(/_url$/, "_uri")] || "")
if (!pairedUri || !pairedUri.startsWith("storage://")) signedUrls.add(value)
}
}
}
await Promise.allSettled([...signedUrls].map((url) => resolveSignedMedia(url)))
const pending = [...uris].filter((uri) => !signedMediaUrls.value[uri])
if (!pending.length) return
const resolved = await Promise.allSettled(
pending.map(async (uri) => ({ uri, result: await getJson<MediaSignResult>(endpoints.mediaSign, { uri }) })),
)
const additions: Record<string, string> = {}
for (const result of resolved) {
if (result.status !== "fulfilled" || !result.value.result.url) continue
const displayUrl = await resolveSignedMedia(result.value.result.url)
additions[result.value.uri] = displayUrl || result.value.result.url
}
if (Object.keys(additions).length) signedMediaUrls.value = { ...signedMediaUrls.value, ...additions }
}
async function resolveSignedMedia(url: string): Promise<string> {
if (signedMediaUrls.value[url]) return signedMediaUrls.value[url]
const token = signedMediaToken(url)
if (!token) return url
try {
const payload = await getJson<MediaFetchResult>(endpoints.mediaPayload, { token })
const normalized = String(payload.body_base64 || "").replace(/-/g, "+").replace(/_/g, "/")
if (!normalized) return url
const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=")
const binary = window.atob(padded)
const bytes = new Uint8Array(binary.length)
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index)
const objectUrl = URL.createObjectURL(new Blob([bytes], { type: payload.content_type || "application/octet-stream" }))
ownedMediaObjectUrls.add(objectUrl)
signedMediaUrls.value = { ...signedMediaUrls.value, [url]: objectUrl }
return objectUrl
} catch {
return url
}
}
function signedMediaToken(rawUrl: string) {
try {
const url = new URL(rawUrl, window.location.origin)
return url.pathname.endsWith("/media/fetch") ? url.searchParams.get("token")?.trim() || "" : ""
} catch {
return ""
}
}
function categoryName(categoryId?: string | null) {
return materialCategoryLabel(
props.categories.find((category) => category.category_id === categoryId)?.name || "未分类",
)
}
function importError(item: AdvancedMaterialImport | null) {
return advancedMaterialErrorMessage(item?.error)
}
function attemptError(item: AdvancedMaterialValidationAttempt | null) {
return advancedMaterialErrorMessage(item?.error)
}
function formatDate(value?: string | null) {
if (!value) return "-"
const parsed = new Date(value)
return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleString("zh-CN", { hour12: false })
}
function normalizeImport(value: AdvancedMaterialImport): AdvancedMaterialImport {
const record = value && typeof value === "object" ? value : ({} as AdvancedMaterialImport)
return {
...record,
import_id: String(record.import_id || ""),
display_name: String(record.display_name || "未命名进阶素材"),
status: String(record.status || "pending_recognition"),
recognition_tags: Array.isArray(record.recognition_tags) ? record.recognition_tags.map(String) : [],
recognition_result: record.recognition_result && typeof record.recognition_result === "object" ? record.recognition_result : {},
workflow_kind: String(record.workflow_kind || record.metadata?.workflow_kind || "single"),
sources: Array.isArray(record.sources) ? record.sources.map(normalizeStyleSource) : [],
consensus: record.consensus && typeof record.consensus === "object"
? normalizeStyleConsensus(record.consensus)
: null,
validation_cases: Array.isArray(record.validation_cases)
? record.validation_cases.map(normalizeStyleValidationCase)
: [],
error: record.error && typeof record.error === "object" ? record.error : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
created_at: String(record.created_at || ""),
updated_at: String(record.updated_at || record.created_at || ""),
}
}
function normalizeAttempt(value: AdvancedMaterialValidationAttempt): AdvancedMaterialValidationAttempt {
const record = value && typeof value === "object" ? value : ({} as AdvancedMaterialValidationAttempt)
return {
...record,
attempt_id: String(record.attempt_id || ""),
import_id: String(record.import_id || ""),
attempt_number: Number(record.attempt_number || 0),
status: String(record.status || "queued"),
usage: record.usage && typeof record.usage === "object" ? record.usage : {},
error: record.error && typeof record.error === "object" ? record.error : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
validation_cases: Array.isArray(record.validation_cases)
? record.validation_cases.map(normalizeStyleValidationCase)
: [],
created_at: String(record.created_at || ""),
updated_at: String(record.updated_at || record.created_at || ""),
}
}
function normalizeStyleSource(value: AdvancedStyleSource): AdvancedStyleSource {
const record = value && typeof value === "object" ? value : ({} as AdvancedStyleSource)
return {
...record,
source_id: String(record.source_id || ""),
sort_order: Number(record.sort_order || 0),
is_primary: Boolean(record.is_primary),
excluded: Boolean(record.excluded || record.excluded_at || normalizeStatus(record.status) === "excluded"),
status: String(record.status || "uploaded"),
recognition_tags: Array.isArray(record.recognition_tags) ? record.recognition_tags.map(String) : [],
recognition_result: record.recognition_result && typeof record.recognition_result === "object" ? record.recognition_result : {},
error: record.error && typeof record.error === "object" ? record.error : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
}
}
function normalizeStyleConsensus(value: AdvancedStyleConsensus): AdvancedStyleConsensus {
const record = value && typeof value === "object" ? value : ({} as AdvancedStyleConsensus)
const result = record.result && typeof record.result === "object" ? record.result : {}
return {
...record,
status: String(record.status || "queued"),
version_id: record.version_id || record.consensus_id || null,
version_number: Number(record.version_number || record.revision || 0),
consensus_style: record.consensus_style && typeof record.consensus_style === "object"
? record.consensus_style
: result.consensus_style && typeof result.consensus_style === "object" ? result.consensus_style as Record<string, unknown> : [],
variable_style_features: Array.isArray(record.variable_style_features)
? record.variable_style_features
: Array.isArray(result.variable_style_features) ? result.variable_style_features : [],
source_content_features: Array.isArray(record.source_content_features) || (record.source_content_features && typeof record.source_content_features === "object")
? record.source_content_features
: Array.isArray(result.source_content_features) || (result.source_content_features && typeof result.source_content_features === "object")
? result.source_content_features as AdvancedStyleConsensus["source_content_features"]
: [],
content_leakage_exclusions: (Array.isArray(record.content_leakage_exclusions)
? record.content_leakage_exclusions
: Array.isArray(result.content_leakage_exclusions) ? result.content_leakage_exclusions : []).map(String),
outlier_source_ids: (Array.isArray(record.outlier_source_ids)
? record.outlier_source_ids
: Array.isArray(result.outlier_source_ids) ? result.outlier_source_ids : []).map(String),
representative_source_ids: (Array.isArray(record.representative_source_ids)
? record.representative_source_ids
: Array.isArray(result.representative_source_ids) ? result.representative_source_ids : []).map(String),
consensus_confidence: Number(record.consensus_confidence ?? result.consensus_confidence ?? 0),
generation_capsules: record.generation_capsules && typeof record.generation_capsules === "object"
? record.generation_capsules
: result.generation_capsules && typeof result.generation_capsules === "object" ? result.generation_capsules as Record<string, unknown> : {},
error: record.error && typeof record.error === "object" ? record.error : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
}
}
function normalizeStyleValidationCase(value: AdvancedStyleValidationCase): AdvancedStyleValidationCase {
const record = value && typeof value === "object" ? value : ({} as AdvancedStyleValidationCase)
return {
...record,
case_id: String(record.case_id || ""),
scenario: String(record.scenario || record.case_key || "novel_scene"),
status: String(record.status || "queued"),
input_image_count: Number(record.input_image_count || 0),
fidelity_score: record.fidelity_score == null ? null : Number(record.fidelity_score),
style_scores: record.style_scores && typeof record.style_scores === "object"
? record.style_scores
: record.style_review && typeof record.style_review === "object" ? record.style_review : {},
content_novelty: record.content_novelty && typeof record.content_novelty === "object" ? record.content_novelty : {},
error: record.error && typeof record.error === "object" ? record.error : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
}
}
function normalizeMaterial(value: AdvancedMaterial): AdvancedMaterial {
const record = value && typeof value === "object" ? value : ({} as AdvancedMaterial)
return {
...record,
material_id: String(record.material_id || ""),
import_id: String(record.import_id || ""),
accepted_attempt_id: String(record.accepted_attempt_id || ""),
display_name: String(record.display_name || "未命名进阶素材"),
tags: Array.isArray(record.tags) ? record.tags.map(String) : [],
priority: Number(record.priority || 0),
status: String(record.status || "active"),
capsule: record.capsule && typeof record.capsule === "object" ? record.capsule : {},
metadata: record.metadata && typeof record.metadata === "object" ? record.metadata : {},
created_at: String(record.created_at || ""),
updated_at: String(record.updated_at || record.created_at || ""),
}
}
function readFileAsDataUrl(file: File) {
return new Promise<string>((resolve, reject) => {
const reader = new FileReader()
reader.onload = () => resolve(String(reader.result || ""))
reader.onerror = () => reject(reader.error || new Error("读取图片失败"))
reader.readAsDataURL(file)
})
}
function filenameStem(filename: string) {
return filename.replace(/\.[^.]+$/, "").trim()
}
function styleUploadId(file: File) {
return `${file.name}:${file.size}:${file.lastModified}`
}
function isStyleCategory(category: MaterialCategory | null | undefined) {
if (!category) return false
const group = String(category.metadata?.frontend_group || category.name || "").trim().toLowerCase()
return group === "风格" || group === "style"
}
function isStyleSetImport(item: AdvancedMaterialImport | null | undefined) {
const workflowKind = String(item?.workflow_kind || item?.metadata?.workflow_kind || "").trim().toLowerCase()
return workflowKind === "style_set" || workflowKind === "advanced_style_set" || item?.metadata?.style_set === true
}
function styleSourceStatusLabel(source: AdvancedStyleSource) {
if (source.excluded) return "已排除"
const labels: Record<string, string> = {
uploaded: "等待识别",
recognition_queued: "已入队",
recognizing: "识别中",
recognized: "识别完成",
completed: "识别完成",
succeeded: "识别完成",
failed: "识别失败",
cancelled: "已取消",
}
return labels[normalizeStatus(source.status)] || source.status || "未知状态"
}
function styleSourceTone(source: AdvancedStyleSource) {
if (source.excluded) return "idle"
const status = normalizeStatus(source.status)
if (["recognized", "completed", "succeeded"].includes(status)) return "good"
if (["failed", "cancelled"].includes(status)) return "bad"
if (["recognizing", "running"].includes(status)) return "active"
return "idle"
}
function styleValidationScenarioLabel(scenario: string) {
const labels: Record<string, string> = {
portrait: "异角色头像",
fullbody: "异角色全身",
novel_scene: "异场景动态构图",
}
return labels[scenario] || scenario || "验证场景"
}
function styleValidationStatusLabel(status: string) {
const labels: Record<string, string> = {
queued: "已入队",
running: "生成中",
validating: "生成中",
succeeded: "待审核",
completed: "待审核",
awaiting_review: "待审核",
pending_review: "待审核",
failed: "生成失败",
cancelled: "已取消",
accepted: "已采纳",
rejected: "未采纳",
}
return labels[normalizeStatus(status)] || status || "未知状态"
}
function styleValidationFidelityPercent(validationCase: AdvancedStyleValidationCase) {
const score = Number(validationCase.fidelity_score ?? validationCase.style_review?.fidelity_score)
return Number.isFinite(score) ? Math.max(0, Math.min(100, Math.round(score * 100))) : null
}
function styleValidationReviewSummary(validationCase: AdvancedStyleValidationCase) {
const review = validationCase.style_review && typeof validationCase.style_review === "object"
? validationCase.style_review
: validationCase.style_scores && typeof validationCase.style_scores === "object" ? validationCase.style_scores : {}
const mismatches = Array.isArray(review.mismatches) ? review.mismatches.map(String).filter(Boolean) : []
if (mismatches.length) return `主要偏差:${mismatches.slice(0, 2).join(";")}`
return String(review.description || "").trim()
}
function consensusItems(value: AdvancedStyleConsensus["consensus_style"] | AdvancedStyleConsensus["source_content_features"]) {
if (Array.isArray(value)) return value.map(consensusItemLabel).filter(Boolean)
if (!value || typeof value !== "object") return []
return Object.entries(value).flatMap(([key, item]) => {
if (Array.isArray(item)) return item.map(consensusItemLabel).filter(Boolean)
const label = consensusItemLabel(item)
return label ? [`${key}:${label}`] : []
})
}
function consensusItemLabel(value: unknown): string {
if (typeof value === "string") return value.trim()
if (!value || typeof value !== "object") return ""
const record = value as Record<string, unknown>
return String(record.trait || record.label || record.description || record.value || "").trim()
}
function styleSourceLabel(sourceId: string) {
const index = styleSources.value.findIndex((source) => source.source_id === sourceId)
if (index < 0) return sourceId
return styleSources.value[index]?.is_primary ? "主参考图" : `样本 ${index + 1}`
}
function normalizeStatus(value: string) {
return String(value || "").trim().toLowerCase()
}
function errorMessage(err: unknown) {
return err instanceof Error ? err.message || "请求失败" : String(err || "请求失败")
}
</script>
<template>
<section class="advanced-material-page">
<div v-if="error || message" :class="['advanced-material-banner', error ? 'bad' : 'good']" role="status">
<div>
<strong>{{ error ? "操作未完成" : "操作已提交" }}</strong>
<span>{{ error || message }}</span>
</div>
<button type="button" aria-label="关闭提示" @click="error = ''; message = ''">×</button>
</div>
<div v-if="!canManage" class="advanced-material-banner" role="status">
<div><strong>当前账号为只读权限</strong><span>可以查看已封存进阶素材,但导入记录、验证轮次和封存操作需要素材管理权限。</span></div>
</div>
<template v-if="mode === 'advanced'">
<section class="advanced-material-metrics" aria-label="进阶素材状态">
<article><span>已封存进阶素材</span><strong>{{ sortedMaterials.length }}</strong><small>在自动检索与角色拼装中优先于普通素材</small></article>
<article><span>处理中</span><strong>{{ activeImportCount }}</strong><small>识别与验证在独立队列执行</small></article>
<article><span>等待人工审核</span><strong>{{ reviewImportCount }}</strong><small>需要比较源图与验证图</small></article>
<article><span>异常任务</span><strong>{{ failedImportCount }}</strong><small>保留错误信息,可单独重试</small></article>
</section>
<section class="advanced-material-library-layout">
<article class="advanced-material-panel advanced-material-library-panel">
<header class="advanced-section-header">
<div>
<span>高优先级封存库</span>
<h3>{{ sortedMaterials.length }} 条进阶素材</h3>
<p>源图、验证图和最终提示词被独立封存,不进入普通图库或工作流候选池。</p>
</div>
<button type="button" class="primary" @click="emit('navigate', 'advanced-import')">+ 新建进阶导入</button>
</header>
<div v-if="loading && !sortedMaterials.length" class="advanced-material-skeleton"><span v-for="index in 4" :key="index" /></div>
<div v-else-if="sortedMaterials.length" class="advanced-material-card-grid">
<button
v-for="material in sortedMaterials"
:key="material.material_id"
type="button"
class="advanced-material-card"
@click="selectImport(material.import_id)"
>
<span class="advanced-material-card-images">
<span><img v-if="sourceImageUrl(material)" :src="sourceImageUrl(material)" :alt="`${material.display_name} 源图`"><i v-else>源图</i></span>
<span><img v-if="validationImageUrl(material)" :src="validationImageUrl(material)" :alt="`${material.display_name} 验证图`"><i v-else>验证图</i></span>
</span>
<span class="advanced-material-card-copy">
<small>进阶素材 · {{ categoryName(material.category_id) }}</small>
<strong>{{ material.display_name }}</strong>
<em>{{ material.prompt || "已封存高优先级生成胶囊" }}</em>
</span>
<span class="advanced-material-card-tags">
<b>优先级 {{ material.priority }}</b>
<b v-for="tag in material.tags.slice(0, 2)" :key="tag">{{ tag }}</b>
</span>
</button>
</div>
<div v-else class="advanced-material-empty">
<strong>还没有封存的进阶素材</strong>
<p>导入一张参考图,经过识别、验证生图和人工还原度审核后才会进入这里。</p>
<button type="button" class="primary" @click="emit('navigate', 'advanced-import')">开始第一次进阶导入</button>
</div>
</article>
<aside class="advanced-material-panel advanced-import-queue">
<header class="advanced-section-header compact">
<div><span>验证流水线</span><h3>最近导入</h3></div>
<button type="button" :disabled="loading" @click="refreshAll()">{{ loading ? "刷新中" : "刷新" }}</button>
</header>
<div v-if="sortedImports.length" class="advanced-import-list">
<button
v-for="item in sortedImports"
:key="item.import_id"
type="button"
:class="['advanced-import-list-item', { active: selectedImportId === item.import_id }]"
@click="selectImport(item.import_id)"
>
<span :class="['status-dot', advancedImportStatusMeta(item.status).tone]" />
<span><strong>{{ item.display_name }}</strong><small>{{ advancedImportStatusMeta(item.status).label }} · {{ formatDate(item.updated_at) }}</small></span>
</button>
</div>
<div v-else class="advanced-material-empty compact"><p>暂无导入记录。</p></div>
</aside>
</section>
</template>
<template v-else>
<section class="advanced-material-import-layout">
<article class="advanced-material-panel advanced-upload-panel">
<header class="advanced-section-header">
<div>
<span>进阶素材导入</span>
<h3>上传源图并验证还原度</h3>
<p>视觉模型先提取关键词和提示词,再由生图模型生成独立验证图;只有人工确认后才会封存。</p>
</div>
<button type="button" @click="emit('navigate', 'advanced')">返回进阶素材库</button>
</header>
<div class="advanced-upload-grid">
<div
class="advanced-upload-dropzone"
tabindex="0"
@click="openFilePicker"
@keydown.enter.prevent="openFilePicker"
@keydown.space.prevent="openFilePicker"
@paste="onPaste"
@dragover.prevent
@drop.prevent="onDrop"
>
<div v-if="styleSetUploadEnabled && styleUploadDrafts.length" class="advanced-style-upload-grid">
<figure v-for="(draft, index) in styleUploadDrafts" :key="draft.id">
<img :src="draft.dataUrl" :alt="`画风样本 ${index + 1}`">
<figcaption><strong>{{ index === 0 ? "主参考" : `样本 ${index + 1}` }}</strong><small>{{ draft.file.name }}</small></figcaption>
<div class="advanced-style-upload-actions" @click.stop>
<button type="button" :disabled="index === 0" :aria-label="`将样本 ${index + 1} 前移`" title="前移;移到首位即设为主参考" @click.stop="moveStyleUpload(draft.id, -1)">←</button>
<button type="button" :disabled="index === styleUploadDrafts.length - 1" :aria-label="`将样本 ${index + 1} 后移`" title="后移" @click.stop="moveStyleUpload(draft.id, 1)">→</button>
<button type="button" :aria-label="`移除样本 ${index + 1}`" title="移除" @click.stop="removeStyleUpload(draft.id)">×</button>
</div>
</figure>
<span v-if="styleUploadDrafts.length < MAX_STYLE_IMAGES" class="advanced-style-upload-add"><b>+</b><small>继续添加</small></span>
</div>
<img v-else-if="!styleSetUploadEnabled && uploadPreview" :src="uploadPreview" alt="待导入素材预览">
<span v-else class="advanced-upload-placeholder">
<b>{{ styleSetUploadEnabled ? "粘贴、拖入或选择 2~8 张画风样本" : "粘贴、拖入或选择图片" }}</b>
<small>PNG / JPEG / WebP,单张不超过 20 MB{{ styleSetUploadEnabled ? ";推荐 3~6 张" : "" }}</small>
</span>
<em v-if="!styleSetUploadEnabled && uploadFile">{{ uploadFile.name }} · {{ (uploadFile.size / 1024 / 1024).toFixed(2) }} MB</em>
<input ref="fileInput" type="file" accept="image/*" :multiple="styleSetUploadEnabled" hidden @change="onFileInput">
</div>
<form class="advanced-upload-form" @submit.prevent="submitUpload">
<label><span>素材名称</span><input v-model="uploadDisplayName" type="text" maxlength="120" placeholder="例如:银白冬季斗篷"></label>
<label>
<span>素材分类</span>
<select v-model="uploadCategoryId">
<option value="" disabled>选择现有分类</option>
<option v-for="category in rootCategories" :key="category.category_id" :value="category.category_id">{{ materialCategoryLabel(category.name) }}</option>
</select>
<small v-if="styleSetUploadEnabled" class="advanced-style-mode-note">风格分类启用多图交叉提取;每张图独立并行识别,验证阶段不传任何源图。</small>
</label>
<dl>
<div><dt>处理方式</dt><dd>{{ styleSetUploadEnabled ? "并行逐图识别 → 多图交叉分析 → 三场景纯文本验证 → 人工封存" : "视觉识别 → 验证生图 → 人工对照 → 独立封存" }}</dd></div>
<div><dt>存储隔离</dt><dd>源图和验证轮次不会进入普通素材库、图库或角色候选池</dd></div>
<div><dt>{{ styleSetUploadEnabled ? "迁移验证" : "检索优先级" }}</dt><dd>{{ styleSetUploadEnabled ? "使用完全不同的角色、场景和构图,只用提示词验证画风泛化能力" : "封存后在自动检索中优先于普通素材,显式选择仍以用户选择为准" }}</dd></div>
</dl>
<div class="advanced-upload-actions">
<span v-if="styleSetUploadEnabled" class="advanced-style-upload-count">{{ styleUploadDrafts.length }}/{{ MAX_STYLE_IMAGES }} 张</span>
<button type="button" :disabled="(!uploadFile && !styleUploadDrafts.length) || Boolean(actionBusy)" @click="resetUpload">清空</button>
<button type="submit" class="primary" :disabled="!uploadReady">{{ actionBusy === "upload" ? "提交中" : styleSetUploadEnabled ? "并行识别画风样本" : "提交识别与验证" }}</button>
</div>
</form>
</div>
</article>
<aside class="advanced-material-panel advanced-import-queue">
<header class="advanced-section-header compact"><div><span>继续处理</span><h3>最近导入</h3></div><button type="button" :disabled="loading" @click="refreshAll()">刷新</button></header>
<div v-if="sortedImports.length" class="advanced-import-list">
<button v-for="item in sortedImports" :key="item.import_id" type="button" :class="['advanced-import-list-item', { active: selectedImportId === item.import_id }]" @click="selectImport(item.import_id)">
<span :class="['status-dot', advancedImportStatusMeta(item.status).tone]" />
<span><strong>{{ item.display_name }}</strong><small>{{ advancedImportStatusMeta(item.status).label }}</small></span>
</button>
</div>
<div v-else class="advanced-material-empty compact"><p>提交后的识别和验证任务会显示在这里。</p></div>
</aside>
</section>
</template>
<section v-if="selectedImport" class="advanced-material-panel advanced-review-panel">
<header class="advanced-review-header">
<div>
<span>还原度验证工作台</span>
<h3>{{ selectedImport.display_name }}</h3>
<p>{{ categoryName(selectedImport.category_id) }} · 导入于 {{ formatDate(selectedImport.created_at) }}</p>
</div>
<div class="advanced-review-header-actions">
<div :class="['advanced-status-chip', selectedStatus.tone]"><i /><span><strong>{{ selectedStatus.label }}</strong><small>{{ selectedStatus.detail }}</small></span></div>
<button
v-if="canManage && !selectedImport.accepted_material_id"
type="button"
class="danger"
:disabled="Boolean(actionBusy)"
@click="deleteImport"
>{{ actionBusy === "delete-import" ? "删除中" : deleteConfirmImportId === selectedImport.import_id ? "确认删除导入" : "删除导入" }}</button>
</div>
</header>
<div v-if="detailLoading" class="advanced-review-loading">正在读取识别结果与验证轮次…</div>
<template v-else>
<div v-if="importError(selectedImport) || attemptError(currentAttempt)" class="advanced-inline-error">
<div><strong>任务错误</strong><span>{{ attemptError(currentAttempt) || importError(selectedImport) }}</span></div>
<button
v-if="['failed', 'recognition_failed', 'validation_failed', 'style_consensus_failed'].includes(normalizeStatus(selectedImport.status))"
type="button"
:disabled="Boolean(actionBusy)"
@click="retryImport"
>{{ actionBusy === "retry" ? "重试中" : "重试当前阶段" }}</button>
</div>
<section v-if="selectedStyleSet" class="advanced-style-workbench">
<article class="advanced-style-stage">
<header class="advanced-style-stage-header">
<div><span>01 · 并行识别</span><h4>画风样本 {{ recognizedStyleSources.length }}/{{ activeStyleSources.length || styleSources.length }} 已完成</h4><p>每张图片拥有独立任务、计时器和错误;失败不会中断其他样本。</p></div>
<button v-if="canRunStyleConsensus" type="button" class="primary" @click="createStyleConsensus">{{ actionBusy === "style-consensus" ? "入队中" : "交叉分析有效样本" }}</button>
</header>
<div class="advanced-style-source-grid">
<article v-for="(source, index) in styleSources" :key="source.source_id" :class="{ excluded: source.excluded }">
<div class="advanced-style-source-image"><img v-if="styleSourceImageUrl(source)" :src="styleSourceImageUrl(source)" :alt="`画风样本 ${index + 1}`" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(sourcePreviewUrl(source), source.is_primary ? '主参考图' : `画风样本 ${index + 1}`)" @keydown.enter.prevent="openImagePreview(sourcePreviewUrl(source), source.is_primary ? '主参考图' : `画风样本 ${index + 1}`)" @keydown.space.prevent="openImagePreview(sourcePreviewUrl(source), source.is_primary ? '主参考图' : `画风样本 ${index + 1}`)"><span v-else>源图准备中</span></div>
<div class="advanced-style-source-copy">
<span :class="['status-dot', styleSourceTone(source)]" />
<strong>{{ source.is_primary ? "主参考图" : `样本 ${index + 1}` }}</strong>
<small>{{ styleSourceStatusLabel(source) }}</small>
<p>{{ source.recognition_prompt || "等待视觉模型完成独立画风分析。" }}</p>
<em v-if="advancedMaterialErrorMessage(source.error)">{{ advancedMaterialErrorMessage(source.error) }}</em>
</div>
<div v-if="canManage && canEditStyleSources" class="advanced-style-source-actions">
<button v-if="normalizeStatus(source.status) === 'failed'" type="button" :disabled="Boolean(actionBusy)" @click="retryStyleSource(source)">{{ actionBusy === `source-retry:${source.source_id}` ? "入队中" : "单独重试" }}</button>
<button v-if="!source.is_primary && !source.excluded" type="button" :disabled="Boolean(actionBusy)" @click="excludeStyleSource(source)">{{ actionBusy === `source-exclude:${source.source_id}` ? "处理中" : "排除" }}</button>
<button v-if="!source.is_primary && source.excluded" type="button" :disabled="Boolean(actionBusy)" @click="excludeStyleSource(source, false)">{{ actionBusy === `source-exclude:${source.source_id}` ? "处理中" : "恢复" }}</button>
</div>
</article>
</div>
<p v-if="recognizedStyleSources.length < MIN_STYLE_IMAGES" class="advanced-style-stage-tip">至少需要 2 张有效样本才能交叉分析;失败样本可以单独重试或排除。</p>
</article>
<article class="advanced-style-stage">
<header class="advanced-style-stage-header">
<div><span>02 · 交叉分析</span><h4>统一画风指纹{{ styleConsensus?.revision ? ` · 第 ${styleConsensus.revision} 版` : "" }}</h4><p>共同画风进入胶囊,可变项降权,人物、服装和场景进入内容污染排除。</p></div>
<b v-if="styleConsensus?.consensus_confidence != null" class="advanced-style-confidence">置信度 {{ Math.round(Number(styleConsensus.consensus_confidence) * 100) }}%</b>
</header>
<div v-if="styleConsensus" class="advanced-style-consensus-grid">
<section><span>核心共同画风</span><ul><li v-for="item in consensusItems(styleConsensus.consensus_style)" :key="item">{{ item }}</li><li v-if="!consensusItems(styleConsensus.consensus_style).length">交叉任务完成后显示稳定共同特征。</li></ul></section>
<section><span>可变或弱特征</span><ul><li v-for="item in styleConsensus.variable_style_features.map(consensusItemLabel).filter(Boolean)" :key="item">{{ item }}</li><li v-if="!styleConsensus.variable_style_features.length">暂无可变特征。</li></ul></section>
<section><span>内容污染排除</span><ul><li v-for="item in styleConsensus.content_leakage_exclusions" :key="item">{{ item }}</li><li v-if="!styleConsensus.content_leakage_exclusions.length">等待模型分离人物、服装、姿势和场景。</li></ul></section>
</div>
<div v-if="styleConsensus" class="advanced-style-source-flags">
<span>代表样本 <b v-for="sourceId in styleConsensus.representative_source_ids" :key="`representative:${sourceId}`">{{ styleSourceLabel(sourceId) }}</b><small v-if="!styleConsensus.representative_source_ids.length">自动选择中</small></span>
<span>疑似离群 <em v-for="sourceId in styleConsensus.outlier_source_ids" :key="`outlier:${sourceId}`">{{ styleSourceLabel(sourceId) }}</em><small v-if="!styleConsensus.outlier_source_ids.length">无</small></span>
</div>
<div v-else class="advanced-style-stage-empty">逐图识别达到至少两张后,可启动交叉分析。</div>
</article>
<article class="advanced-style-stage">
<header class="advanced-style-stage-header">
<div><span>03 · 纯文本迁移验证</span><h4>近域、中域与跨场景案例</h4><p>只发送统一画风提示词,不携带源图;默认使用同一新角色逐级改变构图与场景,文字调整会直接写入下一轮提示词。</p></div>
<b class="advanced-style-text-only">0 张参考图</b>
</header>
<div v-if="styleValidationCases.length" class="advanced-style-validation-grid">
<article v-for="validationCase in styleValidationCases" :key="validationCase.case_id">
<div class="advanced-style-validation-image"><img v-if="styleValidationCaseImageUrl(validationCase)" :src="styleValidationCaseImageUrl(validationCase)" :alt="styleValidationScenarioLabel(validationCase.scenario)" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / ${styleValidationScenarioLabel(validationCase.scenario)}`)" @keydown.enter.prevent="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / ${styleValidationScenarioLabel(validationCase.scenario)}`)" @keydown.space.prevent="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / ${styleValidationScenarioLabel(validationCase.scenario)}`)"><span v-else>{{ styleValidationStatusLabel(validationCase.status) }}</span></div>
<div class="advanced-style-validation-copy">
<span>{{ styleValidationScenarioLabel(validationCase.scenario) }}</span>
<strong>{{ styleValidationStatusLabel(validationCase.status) }}</strong>
<p>{{ validationCase.content_prompt || "后端将规划与源样本不同、但便于对照的验证角色与场景。" }}</p>
<small v-if="validationCase.metadata?.validation_instruction" class="advanced-applied-adjustment">已应用文字调整:{{ validationCase.metadata.validation_instruction }}</small>
<small v-if="styleValidationFidelityPercent(validationCase) != null" class="advanced-style-fidelity">自动还原度:{{ styleValidationFidelityPercent(validationCase) }}%</small>
<small v-if="styleValidationReviewSummary(validationCase)" class="advanced-style-review-summary">{{ styleValidationReviewSummary(validationCase) }}</small>
<small>纯文本验证 · {{ Number(validationCase.input_image_count || 0) }} 张参考图 · 种子 {{ validationCase.seed || "自动" }}</small>
<em v-if="advancedMaterialErrorMessage(validationCase.error)">{{ advancedMaterialErrorMessage(validationCase.error) }}</em>
</div>
<button v-if="normalizeStatus(validationCase.status) === 'failed'" type="button" :disabled="Boolean(actionBusy)" @click="retryStyleValidationCase(validationCase)">{{ actionBusy === `case-retry:${validationCase.case_id}` ? "入队中" : "单独重试" }}</button>
</article>
</div>
<div v-else class="advanced-style-stage-empty">完成交叉分析后会同时生成头像、全身和异场景三项验证。</div>
</article>
</section>
<div v-else class="advanced-recognition-summary">
<article><span>识别提示词</span><p>{{ selectedImport.recognition_prompt || "视觉模型识别完成后会显示在这里。" }}</p></article>
<article><span>负向约束</span><p>{{ selectedImport.recognition_negative_prompt || "暂无负向约束。" }}</p></article>
<article><span>识别标签</span><div><b v-for="tag in selectedImport.recognition_tags" :key="tag">{{ tag }}</b><small v-if="!selectedImport.recognition_tags.length">等待识别</small></div></article>
</div>
<div v-if="!selectedStyleSet" class="advanced-comparison-grid">
<figure>
<div><img v-if="sourceImageUrl(selectedImport)" :src="sourceImageUrl(selectedImport)" :alt="`${selectedImport.display_name} 源图`" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(sourcePreviewUrl(selectedImport), `${selectedImport.display_name} / 源图`)" @keydown.enter.prevent="openImagePreview(sourcePreviewUrl(selectedImport), `${selectedImport.display_name} / 源图`)" @keydown.space.prevent="openImagePreview(sourcePreviewUrl(selectedImport), `${selectedImport.display_name} / 源图`)"><span v-else>源图正在准备</span></div>
<figcaption><strong>源图</strong><small>独立保存的识别依据</small></figcaption>
</figure>
<figure>
<div><img v-if="currentAttempt && attemptImageUrl(currentAttempt)" :src="attemptImageUrl(currentAttempt)" :alt="`${selectedImport.display_name} 验证图`" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(attemptPreviewUrl(currentAttempt), `${selectedImport.display_name} / 第 ${currentAttempt.attempt_number} 轮验证图`)" @keydown.enter.prevent="openImagePreview(attemptPreviewUrl(currentAttempt), `${selectedImport.display_name} / 第 ${currentAttempt.attempt_number} 轮验证图`)" @keydown.space.prevent="openImagePreview(attemptPreviewUrl(currentAttempt), `${selectedImport.display_name} / 第 ${currentAttempt.attempt_number} 轮验证图`)"><span v-else>{{ currentAttemptStatus.busy ? "验证图生成中" : "尚未生成验证图" }}</span></div>
<figcaption><strong>验证图 · 第 {{ currentAttempt?.attempt_number || 0 }} 轮</strong><small>{{ currentAttempt ? currentAttemptStatus.label : "等待首轮验证" }}</small></figcaption>
</figure>
</div>
<div class="advanced-review-controls">
<div v-if="selectedStyleSet" class="advanced-adjustment-grid">
<label class="advanced-adjustment-field">
<span>画风修正(选填)</span>
<textarea v-model="adjustmentText" rows="4" maxlength="2000" placeholder="例如:加强干净细线与两阶赛璐璐阴影,降低暖色滤镜;高光更锐利。" />
<small>{{ adjustmentText.length }}/2000 · 只修改画风共识与胶囊;未填写验证内容时沿用相同场景和种子做 A/B 对比。</small>
</label>
<label class="advanced-adjustment-field">
<span>下一轮验证内容(选填)</span>
<textarea v-model="validationInstructionText" rows="4" maxlength="2000" placeholder="例如:女性角色,全身,萌袖卫衣、泡泡袜和运动鞋,白发蓝瞳猫耳;三个案例保持同一角色。" />
<small>{{ validationInstructionText.length }}/2000 · 会直接写入三个生图提示词,并为新内容使用新的随机种子,不再复用旧场景。</small>
</label>
</div>
<label v-else class="advanced-adjustment-field">
<span>{{ canReviewCurrentAttempt ? "不还原时,说明下一轮怎样调整" : "验证描述补充(可选)" }}</span>
<textarea v-model="adjustmentText" rows="4" maxlength="2000" placeholder="例如:斗篷应更长,领口是银色毛边;保持原图的蓝灰配色,不要改变材质。" />
<small>{{ adjustmentText.length }}/2000 · 描述会叠加在识别提示词上,并保留每一轮历史。</small>
</label>
<div v-if="canReviewCurrentAttempt" class="advanced-decision-fields">
<label><span>主观还原度 {{ fidelityPercent }}%</span><input v-model.number="fidelityPercent" type="range" min="0" max="100" step="1"></label>
<label><span>审核备注(可选)</span><input v-model="decisionNotes" type="text" maxlength="500" placeholder="记录接受或拒绝本轮的理由"></label>
<label class="advanced-accept-confirm"><input v-model="acceptConfirmed" type="checkbox"><span>{{ selectedStyleSet ? "我已检查近域、中域和跨场景结果,确认画风可以脱离源图迁移并封存。" : "我已并排比较源图与验证图,确认可以封存为进阶素材。" }}</span></label>
</div>
<div class="advanced-review-actions">
<button v-if="canStartValidation && !canReviewCurrentAttempt" type="button" class="primary" :disabled="Boolean(actionBusy)" @click="createValidationAttempt">{{ actionBusy === "validation" ? "入队中" : currentAttempt ? "重新生成验证图" : "生成首轮验证图" }}</button>
<template v-if="canReviewCurrentAttempt">
<button type="button" class="warn" :disabled="Boolean(actionBusy) || (!adjustmentText.trim() && !validationInstructionText.trim())" @click="rejectAndRegenerate">{{ actionBusy === "reject" ? "提交中" : selectedStyleSet ? "应用文字调整并生成下一轮" : "不够还原,按描述重试" }}</button>
<button type="button" class="primary" :disabled="Boolean(actionBusy) || !acceptConfirmed" @click="acceptAttempt">{{ actionBusy === "accept" ? "封存中" : selectedStyleSet ? "确认迁移能力并封存" : "确认还原并封存" }}</button>
</template>
<span v-if="selectedStatus.busy">任务已在后台执行,离开页面不会中断;本页会自动刷新状态。</span>
</div>
</div>
<details v-if="sortedAttempts.length" class="advanced-attempt-history" open>
<summary>验证轮次历史 · {{ sortedAttempts.length }} 轮</summary>
<div>
<article v-for="attempt in sortedAttempts" :key="attempt.attempt_id">
<span :class="['status-dot', advancedAttemptStatusMeta(attempt.status).tone]" />
<div><strong>第 {{ attempt.attempt_number }} 轮 · {{ advancedAttemptStatusMeta(attempt.status).label }}</strong><p>{{ attempt.adjustment_text || "使用识别结果生成首轮验证图" }}</p><small>{{ attempt.provider_id || "自动路由" }} / {{ attempt.provider_model || attempt.model_route || "默认生图模型" }} · {{ formatDate(attempt.updated_at) }}</small><em v-if="attemptError(attempt)">{{ attemptError(attempt) }}</em></div>
<div v-if="attempt.validation_cases?.length" class="advanced-attempt-history-images">
<figure v-for="validationCase in attempt.validation_cases" :key="validationCase.case_id">
<img v-if="styleValidationCaseImageUrl(validationCase)" :src="styleValidationCaseImageUrl(validationCase)" :alt="`第 ${attempt.attempt_number} 轮 ${styleValidationScenarioLabel(validationCase.scenario)}`" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮 / ${styleValidationScenarioLabel(validationCase.scenario)}`)" @keydown.enter.prevent="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮 / ${styleValidationScenarioLabel(validationCase.scenario)}`)" @keydown.space.prevent="openImagePreview(validationCasePreviewUrl(validationCase), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮 / ${styleValidationScenarioLabel(validationCase.scenario)}`)">
<span v-else>{{ styleValidationStatusLabel(validationCase.status) }}</span>
<figcaption>{{ styleValidationScenarioLabel(validationCase.scenario) }}</figcaption>
</figure>
</div>
<img v-else-if="attemptImageUrl(attempt)" :src="attemptImageUrl(attempt)" :alt="`第 ${attempt.attempt_number} 轮验证图`" role="button" tabindex="0" title="点击查看大图" @click="openImagePreview(attemptPreviewUrl(attempt), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮验证图`)" @keydown.enter.prevent="openImagePreview(attemptPreviewUrl(attempt), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮验证图`)" @keydown.space.prevent="openImagePreview(attemptPreviewUrl(attempt), `${selectedImport.display_name} / 第 ${attempt.attempt_number} 轮验证图`)">
</article>
</div>
</details>
</template>
</section>
<ImagePreviewDialog
:open="Boolean(previewImageSrc)"
:title="previewImageTitle"
:src="previewImageSrc"
@close="closeImagePreview"
/>
</section>
</template>
<style scoped>
.advanced-material-page,
.advanced-material-panel,
.advanced-section-header > div,
.advanced-material-card-copy,
.advanced-import-list-item > span:last-child,
.advanced-review-header > div:first-child,
.advanced-status-chip span,
.advanced-inline-error > div,
.advanced-upload-form,
.advanced-review-controls,
.advanced-adjustment-field,
.advanced-decision-fields,
.advanced-attempt-history article > div {
display: grid;
min-width: 0;
}
.advanced-material-page { gap: 14px; }
.advanced-material-panel { gap: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--panel); }
.advanced-material-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; background: var(--panel); }
.advanced-material-banner > div { display: grid; gap: 4px; }
.advanced-material-banner strong { color: var(--text); }
.advanced-material-banner span { color: var(--text-soft); font-size: 13px; }
.advanced-material-banner.good { border-color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.advanced-material-banner.bad { border-color: var(--danger-strong); background: var(--danger-soft); }
.advanced-material-banner button { width: 30px; height: 30px; border-radius: 7px; color: var(--text); background: var(--panel-muted); font-size: 20px; }
.advanced-material-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.advanced-material-metrics article { display: grid; gap: 6px; min-width: 0; min-height: 110px; border: 1px solid var(--border); border-radius: 9px; padding: 12px; background: var(--panel); }
.advanced-material-metrics span, .advanced-material-metrics small { color: var(--text-soft); font-size: 12px; }
.advanced-material-metrics strong { color: var(--text); font-size: 25px; line-height: 1; }
.advanced-material-metrics small { line-height: 1.4; }
.advanced-material-library-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 330px); gap: 12px; align-items: start; }
.advanced-material-import-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 330px); gap: 12px; align-items: start; }
.advanced-section-header, .advanced-review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.advanced-section-header > div, .advanced-review-header > div:first-child { gap: 4px; }
.advanced-section-header span, .advanced-review-header span { color: var(--text-soft); font-size: 12px; font-weight: 800; }
.advanced-section-header h3, .advanced-review-header h3 { margin: 0; color: var(--text); font-size: 20px; }
.advanced-section-header p, .advanced-review-header p { max-width: 720px; margin: 0; color: var(--text-soft); font-size: 13px; line-height: 1.5; }
.advanced-section-header button, .advanced-review-header-actions button, .advanced-review-actions button, .advanced-upload-actions button, .advanced-inline-error button, .advanced-material-empty button { min-height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; color: var(--text); background: var(--panel-muted); font-weight: 800; }
button.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
button.warn { color: var(--text); border-color: var(--warn-strong); background: var(--warn-soft); }
button.danger { color: var(--danger); border-color: var(--danger-strong); background: var(--danger-soft); }
button:disabled { cursor: not-allowed; opacity: .52; }
.advanced-material-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.advanced-material-card { display: grid; grid-template-columns: 126px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; min-width: 0; min-height: 164px; border: 1px solid var(--border); border-radius: 9px; padding: 10px; color: var(--text); text-align: left; background: var(--panel); }
.advanced-material-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.advanced-material-card-images { display: grid; grid-row: 1 / 3; grid-template-columns: 1fr 1fr; gap: 3px; overflow: hidden; border-radius: 7px; background: var(--panel-muted); }
.advanced-material-card-images > span { display: grid; place-items: center; min-width: 0; overflow: hidden; }
.advanced-material-card-images img { width: 100%; height: 100%; object-fit: cover; }
.advanced-material-card-images i { color: var(--text-soft); font-size: 10px; font-style: normal; writing-mode: vertical-rl; }
.advanced-material-card-copy { align-content: start; gap: 6px; }
.advanced-material-card-copy small, .advanced-material-card-copy em { overflow: hidden; color: var(--text-soft); font-size: 12px; font-style: normal; text-overflow: ellipsis; }
.advanced-material-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.advanced-material-card-copy em { display: -webkit-box; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.advanced-material-card-tags { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 5px; }
.advanced-material-card-tags b, .advanced-recognition-summary b { border-radius: 999px; padding: 4px 7px; color: var(--text-soft); background: var(--panel-muted); font-size: 10px; }
.advanced-import-queue { position: sticky; top: 86px; max-height: 720px; overflow: hidden; }
.advanced-section-header.compact { align-items: center; }
.advanced-section-header.compact h3 { font-size: 17px; }
.advanced-import-list { display: grid; gap: 6px; min-height: 0; overflow-y: auto; }
.advanced-import-list-item { display: grid; grid-template-columns: 10px minmax(0, 1fr); align-items: center; gap: 9px; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 9px; color: var(--text); text-align: left; background: var(--panel-muted); }
.advanced-import-list-item:hover, .advanced-import-list-item.active { border-color: var(--primary); background: var(--primary-soft); }
.advanced-import-list-item > span:last-child { gap: 3px; }
.advanced-import-list-item strong, .advanced-import-list-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.advanced-import-list-item small { color: var(--text-soft); font-size: 11px; }
.status-dot { display: block; width: 9px; height: 9px; border-radius: 999px; background: var(--neutral); }
.status-dot.good { background: var(--accent); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--danger); }
.status-dot.active { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.advanced-material-empty { display: grid; place-items: center; gap: 8px; min-height: 240px; border: 1px dashed var(--border); border-radius: 9px; padding: 24px; text-align: center; background: var(--panel-muted); }
.advanced-material-empty.compact { min-height: 100px; padding: 14px; }
.advanced-material-empty strong { color: var(--text); font-size: 17px; }
.advanced-material-empty p { max-width: 520px; margin: 0; color: var(--text-soft); line-height: 1.5; }
.advanced-material-skeleton { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.advanced-material-skeleton span { min-height: 164px; border-radius: 9px; background: linear-gradient(100deg, var(--panel-muted), var(--primary-soft), var(--panel-muted)); background-size: 220% 100%; animation: advanced-pulse 1.2s linear infinite; }
.advanced-upload-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr); gap: 14px; }
.advanced-upload-dropzone { position: relative; display: grid; place-items: center; min-height: 390px; overflow: hidden; border: 1px dashed var(--primary); border-radius: 10px; color: var(--text); background: var(--panel-muted); cursor: pointer; outline: none; }
.advanced-upload-dropzone:focus { box-shadow: 0 0 0 3px var(--primary-soft); }
.advanced-upload-dropzone img { width: 100%; height: 100%; max-height: 520px; object-fit: contain; }
.advanced-upload-placeholder { display: grid; gap: 7px; text-align: center; }
.advanced-upload-placeholder b { font-size: 17px; }
.advanced-upload-placeholder small, .advanced-upload-dropzone em { color: var(--text-soft); font-size: 12px; font-style: normal; }
.advanced-upload-dropzone em { position: absolute; right: 10px; bottom: 10px; left: 10px; overflow: hidden; border-radius: 7px; padding: 7px 9px; color: #fff; background: color-mix(in srgb, #101827 75%, transparent); text-overflow: ellipsis; white-space: nowrap; }
.advanced-upload-form { align-content: start; gap: 11px; }
.advanced-upload-form label, .advanced-adjustment-field, .advanced-decision-fields label { display: grid; gap: 6px; color: var(--text-soft); font-size: 12px; font-weight: 800; }
.advanced-upload-form input, .advanced-upload-form select, .advanced-review-controls textarea, .advanced-decision-fields input[type="text"] { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 10px 11px; color: var(--text); background: var(--panel-muted); outline: none; }
.advanced-upload-form input:focus, .advanced-upload-form select:focus, .advanced-review-controls textarea:focus, .advanced-decision-fields input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.advanced-upload-form dl { display: grid; gap: 7px; margin: 0; }
.advanced-upload-form dl div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 9px; border: 1px solid var(--border); border-radius: 8px; padding: 9px; background: var(--panel-muted); }
.advanced-upload-form dt { color: var(--text-soft); font-size: 11px; font-weight: 800; }
.advanced-upload-form dd { margin: 0; color: var(--text); font-size: 12px; line-height: 1.45; }
.advanced-upload-actions { display: flex; justify-content: flex-end; gap: 8px; }
.advanced-style-mode-note { color: var(--primary); font-weight: 700; line-height: 1.45; }
.advanced-style-upload-count { align-self: center; margin-right: auto; color: var(--text-soft); font-size: 12px; font-weight: 800; }
.advanced-style-upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; padding: 10px; }
.advanced-style-upload-grid figure { position: relative; display: grid; grid-template-rows: 130px auto; min-width: 0; overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.advanced-style-upload-grid figure > img { width: 100%; height: 130px; object-fit: cover; }
.advanced-style-upload-grid figcaption { display: grid; gap: 2px; min-width: 0; padding: 7px 8px; }
.advanced-style-upload-grid figcaption strong { color: var(--text); font-size: 11px; }
.advanced-style-upload-grid figcaption small { overflow: hidden; color: var(--text-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.advanced-style-upload-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.advanced-style-upload-actions button { display: grid; place-items: center; width: 27px; height: 27px; padding: 0; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: color-mix(in srgb, var(--panel) 88%, transparent); font-size: 14px; }
.advanced-style-upload-actions button:last-child { font-size: 17px; }
.advanced-style-upload-actions button:disabled { opacity: .38; cursor: not-allowed; }
.advanced-style-upload-add { display: grid; place-items: center; align-content: center; gap: 3px; min-height: 177px; border: 1px dashed var(--border); border-radius: 8px; color: var(--text-soft); background: var(--panel); }
.advanced-style-upload-add b { color: var(--primary); font-size: 25px; }
.advanced-style-upload-add small { font-size: 11px; }
.advanced-review-panel { margin-top: 0; }
.advanced-review-header { align-items: center; }
.advanced-review-header-actions { display: flex; align-items: center; gap: 8px; }
.advanced-status-chip { display: grid; grid-template-columns: 10px minmax(0, 1fr); align-items: center; gap: 9px; max-width: 360px; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; background: var(--panel-muted); }
.advanced-status-chip i { width: 9px; height: 9px; border-radius: 999px; background: var(--neutral); }
.advanced-status-chip.good i { background: var(--accent); }
.advanced-status-chip.warn i { background: var(--warn); }
.advanced-status-chip.bad i { background: var(--danger); }
.advanced-status-chip.active i { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.advanced-status-chip span { gap: 2px; }
.advanced-status-chip strong { color: var(--text); font-size: 12px; }
.advanced-status-chip small { color: var(--text-soft); font-size: 11px; font-weight: 500; line-height: 1.35; }
.advanced-review-loading { min-height: 160px; display: grid; place-items: center; color: var(--text-soft); background: var(--panel-muted); border-radius: 9px; }
.advanced-inline-error { display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--danger-strong); border-radius: 9px; padding: 10px; background: var(--danger-soft); }
.advanced-inline-error > div { gap: 3px; }
.advanced-inline-error strong { color: var(--danger); }
.advanced-inline-error span { color: var(--text); font-size: 12px; }
.advanced-recognition-summary { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 9px; }
.advanced-recognition-summary article { display: grid; align-content: start; gap: 7px; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 10px; background: var(--panel-muted); }
.advanced-recognition-summary article > span { color: var(--text-soft); font-size: 11px; font-weight: 800; }
.advanced-recognition-summary p { max-height: 96px; overflow-y: auto; margin: 0; color: var(--text); font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.advanced-recognition-summary article > div { display: flex; flex-wrap: wrap; gap: 5px; }
.advanced-recognition-summary small { color: var(--text-soft); }
.advanced-comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.advanced-comparison-grid figure { display: grid; gap: 0; min-width: 0; overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-muted); }
.advanced-comparison-grid figure > div { display: grid; place-items: center; min-height: 390px; overflow: hidden; background: color-mix(in srgb, var(--panel-muted) 82%, #000 18%); }
.advanced-comparison-grid img { width: 100%; height: 100%; max-height: 620px; object-fit: contain; }
.advanced-comparison-grid figure > div > span { color: var(--text-soft); font-size: 13px; }
.advanced-comparison-grid figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.advanced-comparison-grid figcaption strong { color: var(--text); }
.advanced-comparison-grid figcaption small { color: var(--text-soft); }
.advanced-style-workbench { display: grid; gap: 12px; }
.advanced-style-stage { display: grid; gap: 11px; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 11px; background: var(--panel-muted); }
.advanced-style-stage-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.advanced-style-stage-header > div { display: grid; gap: 3px; min-width: 0; }
.advanced-style-stage-header span { color: var(--primary); font-size: 11px; font-weight: 900; letter-spacing: .04em; }
.advanced-style-stage-header h4 { margin: 0; color: var(--text); font-size: 16px; }
.advanced-style-stage-header p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
.advanced-style-stage-header button, .advanced-style-source-actions button, .advanced-style-validation-grid article > button { min-height: 32px; border: 1px solid var(--border); border-radius: 7px; padding: 0 10px; color: var(--text); background: var(--panel); font-size: 11px; font-weight: 800; }
.advanced-style-confidence, .advanced-style-text-only { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; padding: 6px 9px; color: var(--text); background: var(--panel); font-size: 11px; }
.advanced-style-text-only { color: var(--accent-strong); border-color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.advanced-style-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.advanced-style-source-grid > article { display: grid; grid-template-columns: 92px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--panel); }
.advanced-style-source-grid > article.excluded { opacity: .55; }
.advanced-style-source-image { display: grid; grid-row: 1 / 3; place-items: center; min-height: 110px; overflow: hidden; border-radius: 6px; color: var(--text-soft); background: var(--panel-muted); font-size: 10px; }
.advanced-style-source-image img { width: 100%; height: 100%; object-fit: cover; }
.advanced-style-source-copy { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 3px 7px; min-width: 0; }
.advanced-style-source-copy .status-dot { align-self: center; grid-row: 1 / 3; }
.advanced-style-source-copy strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.advanced-style-source-copy small { color: var(--text-soft); font-size: 10px; }
.advanced-style-source-copy p, .advanced-style-source-copy em { grid-column: 1 / -1; margin: 3px 0 0; font-size: 10px; line-height: 1.4; }
.advanced-style-source-copy p { display: -webkit-box; overflow: hidden; color: var(--text-soft); -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.advanced-style-source-copy em { color: var(--danger); font-style: normal; }
.advanced-style-source-actions { display: flex; justify-content: flex-end; gap: 6px; }
.advanced-style-stage-tip, .advanced-style-stage-empty { margin: 0; border: 1px dashed var(--border); border-radius: 7px; padding: 9px; color: var(--text-soft); background: var(--panel); font-size: 11px; line-height: 1.45; }
.advanced-style-consensus-grid, .advanced-style-validation-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.advanced-style-consensus-grid > section { min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 9px; background: var(--panel); }
.advanced-style-consensus-grid > section > span { color: var(--text); font-size: 12px; font-weight: 900; }
.advanced-style-consensus-grid ul { display: grid; gap: 5px; margin: 8px 0 0; padding-left: 17px; color: var(--text-soft); font-size: 11px; line-height: 1.4; }
.advanced-style-source-flags { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; color: var(--text-soft); font-size: 11px; }
.advanced-style-source-flags > span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.advanced-style-source-flags b, .advanced-style-source-flags em { border-radius: 999px; padding: 3px 7px; font-style: normal; font-weight: 800; }
.advanced-style-source-flags b { color: var(--primary); background: var(--primary-soft); }
.advanced-style-source-flags em { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.advanced-style-validation-grid > article { display: grid; gap: 8px; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--panel); }
.advanced-style-validation-image { display: grid; place-items: center; min-height: 220px; overflow: hidden; border-radius: 6px; color: var(--text-soft); background: var(--panel-muted); font-size: 11px; }
.advanced-style-validation-image img { width: 100%; height: 220px; object-fit: contain; }
.advanced-style-validation-copy { display: grid; gap: 3px; min-width: 0; }
.advanced-style-validation-copy > span { color: var(--primary); font-size: 10px; font-weight: 900; }
.advanced-style-validation-copy strong { color: var(--text); font-size: 12px; }
.advanced-style-validation-copy p { display: -webkit-box; overflow: hidden; margin: 2px 0; color: var(--text-soft); font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.advanced-style-validation-copy small { color: var(--accent-strong); font-size: 10px; }
.advanced-style-validation-copy .advanced-applied-adjustment { border-left: 2px solid var(--primary); padding-left: 6px; color: var(--primary); line-height: 1.4; }
.advanced-style-validation-copy .advanced-style-fidelity { color: var(--text); font-weight: 900; }
.advanced-style-validation-copy .advanced-style-review-summary { border-left: 2px solid var(--warning, #d89b30); padding-left: 6px; color: var(--text-soft); line-height: 1.4; }
.advanced-style-validation-copy em { color: var(--danger); font-size: 10px; font-style: normal; }
.advanced-review-controls { gap: 10px; }
.advanced-adjustment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.advanced-adjustment-field { gap: 7px; }
.advanced-review-controls textarea { resize: vertical; line-height: 1.5; }
.advanced-adjustment-field small { color: var(--text-soft); font-weight: 500; }
.advanced-decision-fields { grid-template-columns: 1fr 1fr; gap: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 10px; background: var(--panel-muted); }
.advanced-accept-confirm { grid-column: 1 / -1; display: flex !important; grid-template-columns: none !important; align-items: flex-start; flex-direction: row; }
.advanced-accept-confirm input { flex: 0 0 auto; margin-top: 2px; }
.advanced-accept-confirm span { color: var(--text); line-height: 1.4; }
.advanced-review-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.advanced-review-actions > span { margin-right: auto; color: var(--text-soft); font-size: 12px; }
.advanced-attempt-history { border-top: 1px solid var(--border); padding-top: 10px; }
.advanced-attempt-history summary { color: var(--text); font-weight: 900; cursor: pointer; }
.advanced-attempt-history > div { display: grid; gap: 7px; margin-top: 10px; }
.advanced-attempt-history article { display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(210px, 280px); align-items: center; gap: 10px; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 9px; background: var(--panel-muted); }
.advanced-attempt-history article > div { gap: 3px; }
.advanced-attempt-history strong { color: var(--text); font-size: 12px; }
.advanced-attempt-history p { margin: 0; color: var(--text); font-size: 12px; line-height: 1.4; }
.advanced-attempt-history small { color: var(--text-soft); font-size: 10px; }
.advanced-attempt-history em { color: var(--danger); font-size: 11px; font-style: normal; }
.advanced-attempt-history img { width: 84px; height: 64px; border-radius: 6px; object-fit: cover; }
.advanced-attempt-history-images { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; min-width: 0; }
.advanced-attempt-history-images figure { display: grid; grid-template-rows: 62px auto; min-width: 0; overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.advanced-attempt-history-images img { width: 100%; height: 62px; border-radius: 0; object-fit: cover; }
.advanced-attempt-history-images figure > span { display: grid; place-items: center; min-height: 62px; color: var(--text-soft); font-size: 9px; }
.advanced-attempt-history-images figcaption { overflow: hidden; padding: 3px 4px; color: var(--text-soft); font-size: 9px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.advanced-style-source-image img[role="button"], .advanced-style-validation-image img[role="button"], .advanced-comparison-grid img[role="button"], .advanced-attempt-history img[role="button"] { cursor: zoom-in; }
.advanced-style-source-image img[role="button"]:focus-visible, .advanced-style-validation-image img[role="button"]:focus-visible, .advanced-comparison-grid img[role="button"]:focus-visible, .advanced-attempt-history img[role="button"]:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
@keyframes advanced-pulse { to { background-position: -220% 0; } }
@media (max-width: 1180px) {
.advanced-material-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.advanced-material-library-layout, .advanced-material-import-layout { grid-template-columns: 1fr; }
.advanced-import-queue { position: static; max-height: none; }
}
@media (max-width: 820px) {
.advanced-material-metrics, .advanced-material-card-grid, .advanced-upload-grid, .advanced-recognition-summary, .advanced-comparison-grid, .advanced-decision-fields, .advanced-style-consensus-grid, .advanced-style-validation-grid, .advanced-adjustment-grid { grid-template-columns: 1fr; }
.advanced-section-header, .advanced-review-header { align-items: stretch; flex-direction: column; }
.advanced-status-chip { max-width: none; }
.advanced-material-card { grid-template-columns: 108px minmax(0, 1fr); }
.advanced-comparison-grid figure > div { min-height: 300px; }
}
@media (max-width: 520px) {
.advanced-material-metrics { grid-template-columns: 1fr; }
.advanced-material-card { grid-template-columns: 1fr; }
.advanced-material-card-images { grid-row: auto; min-height: 190px; }
.advanced-upload-dropzone { min-height: 300px; }
.advanced-upload-actions, .advanced-review-actions { align-items: stretch; flex-direction: column; }
.advanced-style-upload-count { margin: 0; }
.advanced-style-upload-grid, .advanced-style-source-grid { grid-template-columns: 1fr; }
.advanced-style-stage-header { align-items: stretch; flex-direction: column; }
.advanced-review-actions > span { margin: 0; }
.advanced-attempt-history article { grid-template-columns: 10px minmax(0, 1fr); }
.advanced-attempt-history > div > article > img, .advanced-attempt-history-images { grid-column: 2; width: 100%; }
.advanced-attempt-history > div > article > img { height: 120px; }
}
</style>