"use client"; import { useMemo } from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { partitionSelection, type OssSelection } from "@/lib/oss-selection"; import { useI18n } from "@/i18n/i18n-context"; import { OssBrowser } from "./oss-browser"; /** * Filter input shape — four free-text comma-separated fields. The translation * to the server's glob form (`prefix*` / `*suffix`) lives in * `@/lib/glob-filter`; this state is the raw text the user typed. */ export interface OssImportFilterState { prefixIncludeInput: string; prefixExcludeInput: string; suffixIncludeInput: string; suffixExcludeInput: string; } export const EMPTY_OSS_FILTER: OssImportFilterState = { prefixIncludeInput: "", prefixExcludeInput: "", suffixIncludeInput: "", suffixExcludeInput: "", }; interface OssImportTabProps { selection: OssSelection; onSelectionChange: (next: OssSelection) => void; filter: OssImportFilterState; onFilterChange: (next: OssImportFilterState) => void; } /** * The "从 OSS 导入" tab body. Hosts the OSS browser, exposes the four * filter knobs (prefix-include / prefix-exclude / suffix-include / * suffix-exclude), and renders a small selection summary. * * Filters apply only to folder selections — the server recurses into a * folder ossKey and applies the include / exclude globs server-side. * Individually-checked files are imported as-is, bypassing filters * (explicit user intent overrides any default rule). The four-field split * is what masks the server's glob constraint that `*` may only appear at * one anchor: `prefix*` or `*suffix` — users type the plain text, the * dialog adds the `*`. */ export function OssImportTab({ selection, onSelectionChange, filter, onFilterChange, }: OssImportTabProps) { const { t } = useI18n(); const { fileKeys, folderPrefixes } = useMemo( () => partitionSelection(selection), [selection], ); const hasFolderSelection = folderPrefixes.length > 0; return (