Files
mai-bot/dashboard/dist/assets/knowledge-base-Du35OURl.js

3 lines
141 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{r as t,j as e}from"./router-zNjPR4CY.js";import{C as Pa}from"./CodeEditor-4JcGD1og.js";import{g as Gi,a as Wi,b as Hi,r as Qi,p as Zi,c as Xi,d as Yi,f as el,e as sl,h as tl,i as rl,s as dn,q as al,j as nl,k as il,l as Ht,m as un,n as mn,o as xn,t as hn,u as fa,v as Qt,w as ja,x as pn,y as ll,z as cl,A as ol,B as dl,C as ul,D as ml,E as xl,F as hl,G as pl,H as gl,I as fl,J as jl,K as vl,L as bl,M as Nl,N as yl,O as gn,P as kl,Q as _l,R as Sl,S as wl,T as Cl,U as Il}from"./index-DIOXYKVA.js";import{E as dr,C as X,b as Y,e as ee,d as se,f as te,L as u,I as p,af as nr,ag as ir,B as k,g as G,ah as lr,S as ye,X as ze,Y as $e,O as Pl,P as Ml,R as xe,T as En,D as Tl,i as El,j as Rl,k as Ol,l as Fl,a3 as Dl}from"./index-CuOHsLf7.js";import{B as N}from"./badge-CDs67obV.js";import{T as We,a as _s,b as D,c as Z,d as He,e as b}from"./table-DFeDhBY_.js";import{T as ys}from"./textarea-8PIujbf-.js";import{S as Ma,a as cr,R as Be,L as Ge,a7 as Je,aA as Ll,aB as fn,U as Al,aC as Bl,ah as zl,v as Ta,W as Ea,as as Ra,G as $l,y as ql,a3 as Oa,e as jn,aD as Jl,aE as Ul,D as vn,aF as bn,x as Kl}from"./icons-DTcdLw9j.js";import{S as Ee,a as Re,b as Oe,c as Fe,d as C}from"./select-DGqIoF9r.js";import{C as me}from"./checkbox-DWiVrbnx.js";import{u as va}from"./unified-ws-CBnrIqHW.js";import{P as er}from"./progress-C6-hh8fF.js";import"./reactflow-Bd-f2Ch7.js";import"./charts-C6WIfXk3.js";import"./utils-DjBw3JGv.js";import"./uppy-S0BLpioz.js";import"./radix-C-ZuImoP.js";import"./misc-BwRzHX8c.js";function Vl(s){if(!s)return"-";const i=s>1e12?s:s*1e3,l=new Date(i);return Number.isNaN(l.getTime())?"-":l.toLocaleString("zh-CN",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Nn(s){const i=s.trim();if(!i)return;const l=Number(i);return Number.isFinite(l)?l:void 0}function Zt(s,i){const l=Number(s);return!Number.isInteger(l)||l<=0?i:l}function gt(s){return String(s?.episode_id??s?.id??"")}function yn(s){return String(s.title??s.summary??s.content??gt(s)??"未命名 Episode")}function Gl(s){const i=s?.paragraphs;return Array.isArray(i)?i:[]}function ba(s,i){const l=s?.counts;if(l&&typeof l[i]=="number")return l[i];const d=s?.[i];return typeof d=="number"?d:0}function Wl(){const{toast:s}=dr(),[i,l]=t.useState(""),[d,_]=t.useState(""),[g,y]=t.useState(""),[S,z]=t.useState(""),[I,$]=t.useState(""),[O,H]=t.useState(!1),[w,re]=t.useState(!1),[v,oe]=t.useState(""),[F,ne]=t.useState(""),[q,L]=t.useState("20"),[x,U]=t.useState([]),[m,P]=t.useState(null),[K,ie]=t.useState(""),[de,he]=t.useState(null),[h,le]=t.useState(!1),[W,Q]=t.useState(!1),[ce,A]=t.useState(!1),[ke,f]=t.useState(""),[J,ue]=t.useState(""),[ae,Qe]=t.useState(!1),[j,M]=t.useState("20"),[pe,De]=t.useState("3"),be=t.useRef(!1),B=t.useMemo(()=>de?.episode??x.find(c=>gt(c)===K),[de?.episode,x,K]),Ne=t.useMemo(()=>Gl(B),[B]),Ue=Array.isArray(m?.failed)?m.failed:[],_e=t.useCallback(async()=>{const c=await Gi(Zt(q,20));P(c)},[q]),Se=t.useCallback(async()=>{le(!0);try{const c=O?I.trim():"",[E]=await Promise.all([Wi({query:i.trim(),source:d.trim(),platform:g.trim(),userId:S.trim(),personId:c,limit:Zt(q,20),timeStart:Nn(v),timeEnd:Nn(F)}),_e()]),Xe=E.items??[];U(Xe),!K&&Xe.length>0&&ie(gt(Xe[0]))}catch(c){s({title:"加载情节记忆失败",description:c instanceof Error?c.message:String(c),variant:"destructive"})}finally{le(!1)}},[q,_e,I,g,i,K,O,d,F,v,s,S]),we=t.useCallback(async c=>{if(!c){he(null);return}Q(!0);try{const E=await Hi(c);he(E)}catch(E){s({title:"加载 Episode 详情失败",description:E instanceof Error?E.message:String(E),variant:"destructive"})}finally{Q(!1)}},[s]);t.useEffect(()=>{be.current||(be.current=!0,Se())},[Se]),t.useEffect(()=>{K&&we(K)},[we,K]);const Ss=t.useCallback(async()=>{if(ae&&!window.confirm("确认重建全部可用来源的 Episode这个操作可能耗时较长。"))return;const c=J.split(",").map(E=>E.trim()).filter(Boolean);A(!0);try{const E=await Qi({source:ke.trim(),sources:c,all:ae});s({title:E.success?"Episode 重建已提交":"Episode 重建失败",description:String(E.detail??E.error??`影响来源 ${E.rebuilt??0}`),variant:E.success?"default":"destructive"}),await Se()}catch(E){s({title:"Episode 重建失败",description:E instanceof Error?E.message:String(E),variant:"destructive"})}finally{A(!1)}},[Se,ae,ke,J,s]),Ze=t.useCallback(async()=>{A(!0);try{const c=await Zi({limit:Zt(j,20),max_retry:Zt(pe,3)});s({title:c.success?"已处理待生成 Episode":"处理待生成 Episode 失败",description:String(c.detail??c.error??`已处理 ${c.processed??0}`),variant:c.success?"default":"destructive"}),await Se()}catch(c){s({title:"处理待生成 Episode 失败",description:c instanceof Error?c.message:String(c),variant:"destructive"})}finally{A(!1)}},[Se,j,pe,s]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 xl:grid-cols-4",children:[{label:"待处理队列",value:Number(m?.pending_queue??0)},{label:"待重建",value:ba(m,"pending")},{label:"运行中",value:ba(m,"running")},{label:"失败来源",value:Ue.length||ba(m,"failed")}].map(c=>e.jsx(X,{children:e.jsxs(Y,{className:"pb-3",children:[e.jsx(ee,{children:c.label}),e.jsx(se,{className:"text-2xl",children:c.value})]})},c.label))}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)]",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"h-4 w-4"}),"Episode 查询"]}),e.jsx(ee,{children:"按平台账号、来源和时间范围查看情节记忆构建结果person_id 查询放在高级入口。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-platform",children:"平台"}),e.jsx(p,{id:"episode-platform",value:g,onChange:c=>y(c.target.value),placeholder:"例如 qq、telegram、webui"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-user-id",children:"用户账号"}),e.jsx(p,{id:"episode-user-id",value:S,onChange:c=>z(c.target.value),placeholder:"输入平台侧 user_id"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-query",children:"关键词"}),e.jsx(p,{id:"episode-query",value:i,onChange:c=>l(c.target.value),placeholder:"搜索摘要或内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-source",children:"来源"}),e.jsx(p,{id:"episode-source",value:d,onChange:c=>_(c.target.value),placeholder:"chat_summary:..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-limit",children:"数量"}),e.jsx(p,{id:"episode-limit",type:"number",value:q,onChange:c=>L(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-time-start",children:"开始时间戳"}),e.jsx(p,{id:"episode-time-start",value:v,onChange:c=>oe(c.target.value),placeholder:"可选"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-time-end",children:"结束时间戳"}),e.jsx(p,{id:"episode-time-end",value:F,onChange:c=>ne(c.target.value),placeholder:"可选"})]})]}),e.jsxs(nr,{open:O,onOpenChange:H,className:"rounded-lg border bg-muted/10",children:[e.jsx(ir,{asChild:!0,children:e.jsxs(k,{variant:"ghost",className:"flex h-10 w-full justify-between px-3",children:[e.jsx("span",{children:"高级查询"}),e.jsx(cr,{className:G("h-4 w-4 transition-transform",O&&"rotate-180")})]})}),e.jsxs(lr,{className:"space-y-2 border-t px-3 py-3",children:[e.jsx(u,{htmlFor:"episode-person",children:"person_id"}),e.jsx(p,{id:"episode-person",value:I,onChange:c=>$(c.target.value),placeholder:"调试或后台管理时直接输入"})]})]}),e.jsxs(k,{onClick:()=>{Se()},disabled:h,children:[e.jsx(Be,{className:G("mr-2 h-4 w-4",h&&"animate-spin")}),"刷新 Episode"]}),e.jsx(ye,{className:"h-[420px] rounded-lg border",children:e.jsxs(We,{children:[e.jsx(_s,{className:"sticky top-0 bg-background",children:e.jsxs(D,{children:[e.jsx(Z,{children:"Episode"}),e.jsx(Z,{children:"来源"}),e.jsx(Z,{children:"更新时间"})]})}),e.jsx(He,{children:x.length>0?x.map(c=>{const E=gt(c);return e.jsxs(D,{className:G("cursor-pointer",K===E&&"bg-muted/60"),onClick:()=>ie(E),children:[e.jsxs(b,{children:[e.jsx("div",{className:"max-w-[280px] truncate font-medium",children:yn(c)}),c.person_name||c.person_id?e.jsxs("div",{className:"max-w-[280px] truncate text-xs text-muted-foreground",children:[String(c.person_name||c.person_id),c.person_name&&c.person_id?e.jsxs("span",{className:"font-mono",children:[" · ",String(c.person_id)]}):null]}):null,e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground break-all",children:E||"-"})]}),e.jsx(b,{className:"max-w-[180px] truncate",children:String(c.source??"-")}),e.jsx(b,{children:Vl(c.updated_at??c.created_at)})]},E||yn(c))}):e.jsx(D,{children:e.jsx(b,{colSpan:3,className:"text-center text-muted-foreground",children:h?"正在加载 Episode...":"没有匹配的 Episode"})})})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(se,{children:"Episode 详情"}),e.jsx(ee,{children:"查看情节摘要、原始字段和关联段落。"})]}),e.jsx(te,{className:"space-y-4",children:W?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ge,{className:"h-4 w-4 animate-spin"}),"正在加载详情"]}):B?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{variant:"outline",children:gt(B)||"无 ID"}),B.source?e.jsx(N,{variant:"secondary",children:String(B.source)}):null,B.person_name?e.jsx(N,{children:String(B.person_name)}):null,B.person_id?e.jsx(N,{variant:"outline",children:String(B.person_id)}):null]}),e.jsx(ys,{value:String(B.summary??B.content??""),readOnly:!0,className:"min-h-[120px]"}),e.jsxs(nr,{open:w,onOpenChange:re,className:"rounded-lg border bg-muted/10",children:[e.jsx(ir,{asChild:!0,children:e.jsxs(k,{variant:"ghost",className:"flex h-10 w-full justify-between px-3",children:[e.jsx("span",{children:"原始响应 JSON"}),e.jsx(cr,{className:G("h-4 w-4 transition-transform",w&&"rotate-180")})]})}),e.jsx(lr,{className:"border-t",children:e.jsx("pre",{className:"max-h-56 overflow-auto p-3 text-xs break-words whitespace-pre-wrap",children:JSON.stringify(B,null,2)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"关联段落"}),Ne.length>0?e.jsx(ye,{className:"h-[220px] rounded-lg border bg-background/60",children:e.jsx("div",{className:"space-y-2 p-3",children:Ne.map((c,E)=>e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-3",children:[e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground break-all",children:String(c.hash??"-")}),e.jsx("div",{className:"mt-2 text-sm break-words",children:String(c.preview??c.content??"")})]},String(c.hash??E)))})}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-4 text-sm text-muted-foreground",children:"当前详情没有段落明细。"})]})]}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:"选择一个 Episode 查看详情。"})})]}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"Episode 运维"]}),e.jsx(ee,{children:"重新生成指定来源的情景记忆,或处理后台尚未生成的 Episode 任务。"})]}),e.jsxs(te,{className:"space-y-5",children:[Ue.length>0?e.jsx(ze,{children:e.jsxs($e,{children:["最近失败来源:",Ue.slice(0,3).map(c=>String(c.source??c.id??c.error??"未知")).join("、")]})}):null,e.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/10 p-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"重新生成来源 Episode"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"适用于导入内容变化、反馈纠错后,需要用来源下的段落替换旧 Episode 的场景。"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-rebuild-source",children:"来源 ID"}),e.jsx(p,{id:"episode-rebuild-source",value:ke,onChange:c=>f(c.target.value),placeholder:"例如 chat_summary:test-webui:coffee"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-rebuild-sources",children:"多个来源 ID"}),e.jsx(p,{id:"episode-rebuild-sources",value:J,onChange:c=>ue(c.target.value),placeholder:"用英文逗号分隔多个来源"})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:ae,onChange:c=>Qe(c.target.checked)}),"重新生成全部可用来源"]}),e.jsxs(k,{onClick:()=>{Ss()},disabled:ce,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"重新生成 Episode"]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/10 p-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"处理待生成任务"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"适用于后台已有待生成段落时,手动推进这些段落生成 Episode。"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[1fr_1fr_auto] md:items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-pending-limit",children:"本次处理上限"}),e.jsx(p,{id:"episode-pending-limit",type:"number",value:j,onChange:c=>M(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"episode-pending-retry",children:"失败重试上限"}),e.jsx(p,{id:"episode-pending-retry",type:"number",value:pe,onChange:c=>De(c.target.value)})]}),e.jsxs(k,{variant:"outline",onClick:()=>{Ze()},disabled:ce,children:[e.jsx(Ll,{className:"mr-2 h-4 w-4"}),"处理待生成任务"]})]})]})]})]})]})]})]})}function Hl(s){if(!s)return"-";const i=s>1e12?s:s*1e3,l=new Date(i);return Number.isNaN(l.getTime())?"-":l.toLocaleString("zh-CN",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Ql(s,i){const l=Number(s);return!Number.isInteger(l)||l<=0?i:l}function Zl(s){const i=s.trim();if(!i)return;const l=Number(i);return Number.isFinite(l)&&l>=0?l:void 0}function kn(s){return String(s.hash??s.relation_hash??"")}function _n(s){const i=String(s.text??"").trim();return i||[s.subject,s.predicate,s.object].map(l=>String(l??"").trim()).filter(Boolean).join(" ")}function Xt(s){switch(s){case"reinforce":return"强化";case"freeze":return"冻结";case"protect":return"保护";case"restore":return"恢复";default:return s}}function Xl(){const{toast:s}=dr(),[i,l]=t.useState(""),[d,_]=t.useState("reinforce"),[g,y]=t.useState(""),[S,z]=t.useState("50"),[I,$]=t.useState([]),[O,H]=t.useState(!1),[w,re]=t.useState(!1),[v,oe]=t.useState(""),F=t.useRef(!1),ne=t.useMemo(()=>{const x=v.trim().toLowerCase();return x?I.filter(U=>[kn(U),_n(U),U.source,U.subject,U.predicate,U.object].some(m=>String(m??"").toLowerCase().includes(x))):I},[v,I]),q=t.useCallback(async()=>{H(!0);try{const x=await Xi(Ql(S,50));$(x.items??[])}catch(x){s({title:"加载记忆回收站失败",description:x instanceof Error?x.message:String(x),variant:"destructive"})}finally{H(!1)}},[S,s]);t.useEffect(()=>{F.current||(F.current=!0,q())},[q]);const L=t.useCallback(async(x,U)=>{const m=U.trim();if(!m){s({title:"缺少维护目标",description:"请输入关系 hash 或查询文本。",variant:"destructive"});return}if(!(x==="freeze"&&!window.confirm("确认冻结命中的记忆关系?冻结后关系会从活跃图谱中移除。"))&&!(x==="restore"&&!window.confirm("确认恢复命中的记忆关系?"))){re(!0);try{let P;x==="reinforce"?P=await Yi(m):x==="freeze"?P=await el(m):x==="protect"?P=await sl(m,Zl(g)):P=await tl(m),s({title:P.success?`记忆${Xt(x)}完成`:`记忆${Xt(x)}失败`,description:String(P.detail??P.error??""),variant:P.success?"default":"destructive"}),await q()}catch(P){s({title:`记忆${Xt(x)}失败`,description:P instanceof Error?P.message:String(P),variant:"destructive"})}finally{re(!1)}}},[q,g,s]);return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)]",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"记忆维护操作"]}),e.jsx(ee,{children:"对关系 hash 或查询文本命中的长期记忆执行强化、冻结、保护和恢复。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx(ze,{children:e.jsx($e,{children:"维护目标沿用后端解析规则:优先匹配关系 hash也可以输入查询文本让后端解析命中的关系。"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"maintenance-target",children:"维护目标"}),e.jsx(p,{id:"maintenance-target",value:i,onChange:x=>l(x.target.value),placeholder:"relation hash 或查询文本"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"动作"}),e.jsxs(Ee,{value:d,onValueChange:x=>_(x),children:[e.jsx(Re,{children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"reinforce",children:"强化"}),e.jsx(C,{value:"freeze",children:"冻结"}),e.jsx(C,{value:"protect",children:"保护"}),e.jsx(C,{value:"restore",children:"恢复"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"maintenance-hours",children:"保护时长(小时)"}),e.jsx(p,{id:"maintenance-hours",type:"number",value:g,onChange:x=>y(x.target.value),placeholder:"空值表示永久保护",disabled:d!=="protect"})]})]}),e.jsxs(k,{onClick:()=>{L(d,i)},disabled:w,children:[d==="reinforce"?e.jsx(Al,{className:"mr-2 h-4 w-4"}):null,d==="freeze"?e.jsx(Bl,{className:"mr-2 h-4 w-4"}):null,d==="protect"?e.jsx(fn,{className:"mr-2 h-4 w-4"}):null,d==="restore"?e.jsx(Je,{className:"mr-2 h-4 w-4"}):null,"执行",Xt(d)]})]})]}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"记忆回收站"]}),e.jsx(ee,{children:"查看已删除关系,并支持按行恢复。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_140px_auto] md:items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"maintenance-search",children:"筛选"}),e.jsx(p,{id:"maintenance-search",value:v,onChange:x=>oe(x.target.value),placeholder:"按 hash、主体、谓词、来源筛选"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"maintenance-limit",children:"数量"}),e.jsx(p,{id:"maintenance-limit",type:"number",value:S,onChange:x=>z(x.target.value)})]}),e.jsxs(k,{variant:"outline",onClick:()=>{q()},disabled:O,children:[e.jsx(Be,{className:G("mr-2 h-4 w-4",O&&"animate-spin")}),"刷新"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-muted-foreground",children:[e.jsxs(N,{variant:"outline",children:["已加载 ",I.length," 条"]}),e.jsxs(N,{variant:"secondary",children:["当前命中 ",ne.length," 条"]})]}),e.jsx(ye,{className:"h-[520px] rounded-lg border",children:e.jsxs(We,{children:[e.jsx(_s,{className:"sticky top-0 bg-background",children:e.jsxs(D,{children:[e.jsx(Z,{children:"关系"}),e.jsx(Z,{children:"删除时间"}),e.jsx(Z,{children:"操作"})]})}),e.jsx(He,{children:ne.length>0?ne.map((x,U)=>{const m=kn(x);return e.jsxs(D,{children:[e.jsxs(b,{children:[e.jsx("div",{className:"font-medium break-words",children:_n(x)||"-"}),e.jsx("div",{className:"mt-1 font-mono text-[11px] text-muted-foreground break-all",children:m||"-"}),x.source?e.jsx(N,{variant:"outline",className:"mt-2",children:String(x.source)}):null]}),e.jsx(b,{children:Hl(x.deleted_at??x.updated_at)}),e.jsx(b,{children:e.jsx(k,{size:"sm",variant:"outline",onClick:()=>{L("restore",m)},disabled:!m||w,children:"恢复"})})]},`${m}:${U}`)}):e.jsx(D,{children:e.jsx(b,{colSpan:3,className:"text-center text-muted-foreground",children:O?"正在加载回收站...":"回收站没有可展示的关系"})})})]})})]})]})]})}function Rn({items:s,className:i,triggerClassName:l}){return e.jsx(Pl,{className:G("h-auto w-full flex-wrap justify-start gap-1.5 rounded-full border border-border/60","bg-gradient-to-r from-muted/40 via-background to-muted/30 p-1.5 shadow-inner",i),children:s.map(d=>e.jsx(Ml,{value:d.value,title:d.description,className:G("rounded-full px-3.5 py-1.5 text-xs font-medium text-muted-foreground transition-colors","hover:bg-background/80 hover:text-foreground","data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-primary/80","data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",l),children:d.label},d.value))})}function Sn(s){if(!s)return"-";const i=s>1e12?s:s*1e3,l=new Date(i);return Number.isNaN(l.getTime())?"-":l.toLocaleString("zh-CN",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Yl(s,i){const l=Number(s);return!Number.isInteger(l)||l<=0?i:l}function ec(s){if(!s)return"";if(typeof s=="string")return s;const i=s.override_text??s.text;return typeof i=="string"?i:JSON.stringify(s,null,2)}function sc(s,i){if(typeof s?.profile_text=="string")return s.profile_text;const l=s?.profile;return l&&typeof l=="object"&&typeof l.profile_text=="string"?l.profile_text:i?.profile_text??""}function tc(){const{toast:s}=dr(),[i,l]=t.useState([]),[d,_]=t.useState("library"),[g,y]=t.useState(""),[S,z]=t.useState(""),[I,$]=t.useState(""),[O,H]=t.useState(""),[w,re]=t.useState(""),[v,oe]=t.useState("12"),[F,ne]=t.useState(!1),[q,L]=t.useState(!1),[x,U]=t.useState(!1),[m,P]=t.useState(""),[K,ie]=t.useState(null),[de,he]=t.useState(!1),[h,le]=t.useState(!1),[W,Q]=t.useState(!1),ce=t.useRef(!1),A=t.useMemo(()=>i.find(j=>j.person_id===g)??null,[i,g]),ke=sc(K,A),f=A?.person_name||g||String(K?.person_id??"未选择"),J=t.useCallback(async()=>{he(!0);try{const M=(await rl(80)).items??[];l(M),_("library"),!g&&M.length>0&&y(M[0].person_id)}catch(j){s({title:"加载人物画像失败",description:j instanceof Error?j.message:String(j),variant:"destructive"})}finally{he(!1)}},[g,s]);t.useEffect(()=>{ce.current||(ce.current=!0,J())},[J]),t.useEffect(()=>{P(ec(A?.manual_override))},[A]);const ue=t.useCallback(async()=>{const j=q?S.trim():"",M=I.trim(),pe=O.trim(),De=w.trim(),be=!!(pe&&De);if(!j&&!M&&!be){s({title:"请输入查询条件",description:"用户账号、关键词、或高级 person_id 至少填写一种。",variant:"destructive"});return}le(!0);try{if(!j&&!be){const we=(await dn({personKeyword:M,limit:80})).items??[];l(we),_("search"),ie(null),y(we[0]?.person_id??""),s({title:"人物画像检索完成",description:`命中 ${we.length} 个画像。`});return}const B=await al({personId:j,personKeyword:M,platform:pe,userId:De,limit:Yl(v,12),forceRefresh:F});if(B.success===!1)throw new Error(String(B.error??"人物画像查询失败"));ie(B);const Ne=String(B.person_id??B.profile?.person_id??j??""),_e=(await dn({personId:Ne||j,personKeyword:M,platform:pe,userId:De,limit:80})).items??[];l(_e),_("search"),Ne?(y(Ne),z(Ne)):_e.length>0&&y(_e[0].person_id),s({title:"人物画像查询完成",description:F?"已请求强制刷新画像。":"已获取画像结果。"})}catch(B){s({title:"人物画像查询失败",description:B instanceof Error?B.message:String(B),variant:"destructive"})}finally{le(!1)}},[F,I,v,S,O,w,q,s]),ae=t.useCallback(async()=>{const j=g||S.trim();if(!j){s({title:"缺少人物 ID",description:"请选择或输入一个 person_id 后再保存 override。",variant:"destructive"});return}Q(!0);try{await nl({person_id:j,override_text:m,updated_by:"knowledge_base",source:"webui"}),s({title:"人物画像 override 已保存"}),await J()}catch(M){s({title:"保存人物画像 override 失败",description:M instanceof Error?M.message:String(M),variant:"destructive"})}finally{Q(!1)}},[J,m,S,g,s]),Qe=t.useCallback(async()=>{const j=g||S.trim();if(j&&window.confirm(`确认删除 ${j} 的人物画像 override`)){Q(!0);try{await il(j),P(""),s({title:"人物画像 override 已删除"}),await J()}catch(M){s({title:"删除人物画像 override 失败",description:M instanceof Error?M.message:String(M),variant:"destructive"})}finally{Q(!1)}}},[J,S,g,s]);return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"h-4 w-4"}),"人物画像查询"]}),e.jsx(ee,{children:"按平台账号定位人物画像可用关键词辅助检索person_id 查询放在高级入口。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"profile-platform",children:"平台"}),e.jsx(p,{id:"profile-platform",value:O,onChange:j=>H(j.target.value),placeholder:"例如 qq、telegram、webui"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"profile-user-id",children:"用户账号"}),e.jsx(p,{id:"profile-user-id",value:w,onChange:j=>re(j.target.value),placeholder:"输入平台侧 user_id"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"profile-keyword",children:"人物关键词"}),e.jsx(p,{id:"profile-keyword",value:I,onChange:j=>$(j.target.value),placeholder:"可选"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"profile-limit",children:"证据数量"}),e.jsx(p,{id:"profile-limit",type:"number",value:v,onChange:j=>oe(j.target.value)})]}),e.jsxs("div",{className:"flex items-center gap-2 self-end pb-2",children:[e.jsx(me,{id:"profile-force-refresh",checked:F,onCheckedChange:j=>ne(!!j)}),e.jsx(u,{htmlFor:"profile-force-refresh",className:"text-sm font-normal",children:"强制刷新画像"})]})]}),e.jsxs(nr,{open:q,onOpenChange:L,className:"rounded-lg border bg-muted/10",children:[e.jsx(ir,{asChild:!0,children:e.jsxs(k,{variant:"ghost",className:"flex h-10 w-full justify-between px-3",children:[e.jsx("span",{children:"高级查询"}),e.jsx(cr,{className:G("h-4 w-4 transition-transform",q&&"rotate-180")})]})}),e.jsxs(lr,{className:"space-y-2 border-t px-3 py-3",children:[e.jsx(u,{htmlFor:"profile-person-id",children:"person_id"}),e.jsx(p,{id:"profile-person-id",value:S,onChange:j=>z(j.target.value),placeholder:"调试或后台管理时直接输入"})]})]}),g||S?e.jsxs("div",{className:"rounded-lg border bg-muted/20 px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"当前定位 person_id"}),e.jsx("div",{className:"mt-1 break-all font-mono text-xs",children:g||S})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(k,{onClick:()=>{ue()},disabled:h,children:[e.jsx(Ma,{className:"mr-2 h-4 w-4"}),"查询人物画像"]}),e.jsxs(k,{variant:"outline",onClick:()=>{J()},disabled:de,children:[e.jsx(Be,{className:G("mr-2 h-4 w-4",de&&"animate-spin")}),"查看画像库"]})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/10 px-3 py-2",children:[e.jsx("div",{className:"text-sm font-medium",children:d==="search"?"检索结果":"画像库"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:d==="search"?"根据当前平台账号、关键词或 person_id 筛选出的画像候选。":"系统中已生成的最新人物画像快照,按更新时间排序。"})]}),e.jsx(ye,{className:"h-[520px] rounded-lg border",children:e.jsxs(We,{children:[e.jsx(_s,{className:"sticky top-0 bg-background",children:e.jsxs(D,{children:[e.jsx(Z,{children:"人物"}),e.jsx(Z,{children:"版本"}),e.jsx(Z,{children:"更新时间"})]})}),e.jsx(He,{children:i.length>0?i.map(j=>e.jsxs(D,{className:G("cursor-pointer",g===j.person_id&&"bg-muted/60"),onClick:()=>y(j.person_id),children:[e.jsxs(b,{children:[e.jsx("div",{className:"font-medium break-all",children:j.person_name||j.person_id}),j.person_name?e.jsx("div",{className:"mt-0.5 font-mono text-xs text-muted-foreground break-all",children:j.person_id}):null,e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[j.has_manual_override?e.jsx(N,{variant:"secondary",children:"手动 override"}):null,j.source_note?e.jsx(N,{variant:"outline",children:j.source_note}):null]})]}),e.jsx(b,{children:Number(j.profile_version??0)}),e.jsx(b,{children:Sn(j.updated_at)})]},j.person_id)):e.jsx(D,{children:e.jsx(b,{colSpan:3,className:"text-center text-muted-foreground",children:de?"正在加载人物画像...":d==="search"?"没有匹配的人物画像":"还没有人物画像快照"})})})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(se,{children:"画像详情"}),e.jsx(ee,{children:"展示当前快照、查询结果和原始响应。"})]}),e.jsxs(te,{className:"space-y-4",children:[h?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ge,{className:"h-4 w-4 animate-spin"}),"正在查询人物画像"]}):null,A||K?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{variant:"outline",children:g||String(K?.person_id??"未选择")}),A?.expires_at?e.jsxs(N,{variant:"secondary",children:["过期时间 ",Sn(A.expires_at)]}):null]}),e.jsx(ys,{value:ke,readOnly:!0,className:"min-h-[180px]",placeholder:"当前没有画像文本"}),e.jsxs(nr,{open:x,onOpenChange:U,className:"rounded-lg border bg-muted/10",children:[e.jsx(ir,{asChild:!0,children:e.jsxs(k,{variant:"ghost",className:"flex h-10 w-full justify-between px-3",children:[e.jsx("span",{children:"原始响应 JSON"}),e.jsx(cr,{className:G("h-4 w-4 transition-transform",x&&"rotate-180")})]})}),e.jsx(lr,{className:"border-t",children:e.jsx("pre",{className:"max-h-72 overflow-auto p-3 text-xs break-words whitespace-pre-wrap",children:JSON.stringify(K??A??{},null,2)})})]})]}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:"选择一个人物或执行查询后查看详情。"})]})]}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(se,{children:"手动 Override"}),e.jsx(ee,{children:"用人工画像覆盖自动生成结果;留空保存表示清空文本但保留 override 记录。"})]}),e.jsxs(te,{className:"space-y-3",children:[!g&&!S.trim()?e.jsx(ze,{children:e.jsx($e,{children:"请选择或输入 person_id 后再编辑 override。"})}):null,f?e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前编辑对象:",f]}):null,e.jsx(ys,{value:m,onChange:j=>P(j.target.value),className:"min-h-[180px]",placeholder:"输入希望固定使用的人物画像文本"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(k,{onClick:()=>{ae()},disabled:W,children:[e.jsx(zl,{className:"mr-2 h-4 w-4"}),"保存 override"]}),e.jsxs(k,{variant:"outline",onClick:()=>{Qe()},disabled:W||!g&&!S.trim(),children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"删除 override"]})]})]})]})]})]})}const Na="memory",wn=["import_progress","delete_progress","feedback_progress"];class rc{initialized=!1;listeners=new Set;activeTopics=new Set;initialize(){this.initialized||(va.addEventListener(i=>{if(i.domain!==Na)return;const l=i.topic??"";if(!wn.includes(l))return;const d={topic:l,event:i.event,data:i.data??{}};this.listeners.forEach(_=>{try{_(d)}catch(g){console.error("长期记忆进度监听器执行失败:",g)}})}),this.initialized=!0)}async subscribe(i,l=wn){this.initialize(),this.listeners.add(i);for(const d of l)if(!this.activeTopics.has(d))try{await va.subscribe(Na,d),this.activeTopics.add(d)}catch(_){console.warn(`订阅长期记忆 topic 失败(将退化到轮询兜底): ${d}`,_)}return async()=>{if(this.listeners.delete(i),this.listeners.size===0){const d=Array.from(this.activeTopics);this.activeTopics.clear();for(const _ of d)try{await va.unsubscribe(Na,_)}catch(g){console.warn(`取消订阅长期记忆 topic 失败: ${_}`,g)}}}}}const ac=new rc,ya=100,sr=6,tr=8,Cn=100,rr=6,ar=8,ft=50,or=new Set(["preparing","running","cancel_requested"]),Fa=new Set(["queued"]),nc={queued:"排队中",preparing:"准备中",running:"运行中",cancel_requested:"取消中",cancelled:"已取消",completed:"已完成",completed_with_errors:"完成(有错误)",failed:"失败"},ic={queued:"排队中",preparing:"准备中",running:"运行中",splitting:"分块中",extracting:"抽取中",writing:"写入中",saving:"保存中",backfilling:"回填中",converting:"转换中",verifying:"校验中",switching:"切换中",cancel_requested:"取消中",cancelled:"已取消",completed:"已完成",completed_with_errors:"完成(有错误)",failed:"失败"},lc=[{value:"upload",label:"上传文件",description:"从本地批量上传资料文件"},{value:"paste",label:"粘贴导入",description:"直接粘贴文本或 JSON 内容创建任务"},{value:"raw_scan",label:"本地扫描",description:"按路径别名和匹配规则批量扫描导入"},{value:"lpmm_openie",label:"LPMM OpenIE",description:"读取 LPMM 数据并抽取关系"},{value:"lpmm_convert",label:"LPMM 转换",description:"将 LPMM 数据转换到目标目录"},{value:"temporal_backfill",label:"时序回填",description:"为已有数据补充时间字段"},{value:"maibot_migration",label:"MaiBot 迁移",description:"从 MaiBot 历史数据迁移长期记忆"}];function jt(s){const i=Number(s??0);if(!Number.isFinite(i))return 0;const l=i>0&&i<=1?i*100:i;return l<0?0:l>100?100:l}function ht(s){return`${jt(s).toFixed(1)}%`}function Ae(s){const i=s.trim();if(!i)return;const l=Number(i);if(!(!Number.isInteger(l)||l<=0))return l}function ka(s){return s.split(",").map(i=>i.trim()).filter(Boolean)}function _a(s){return s==="json"?"json":"text"}function rs(s){const i=String(s??"").trim();return i?nc[i]??i:"-"}function pt(s){const i=String(s??"").trim();return i?ic[i]??i:"-"}function bs(s){return s==="failed"?"destructive":s==="completed"?"default":s==="completed_with_errors"||s==="cancelled"?"secondary":or.has(s)||Fa.has(s)?"outline":"secondary"}function Sa(s){if(!s)return"-";const i=s>1e12?s:s*1e3,l=new Date(i);return Number.isNaN(l.getTime())?"-":l.toLocaleString("zh-CN",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function In(s){switch(s){case"entity":return"实体";case"relation":return"关系";case"paragraph":return"段落";case"source":return"来源";case"mixed":return"混合";default:return s||"未知"}}function Pn(s){switch(s){case"executed":return"已执行";case"restored":return"已恢复";default:return s||"未知"}}function Ns(s){if(!s)return"未知时间";const i=s>1e12?s:s*1e3,l=new Date(i);return Number.isNaN(l.getTime())?"未知时间":l.toLocaleString("zh-CN",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function On(s,i=140){const l=String(s??"").trim().replace(/\s+/g," ");return l?l.length<=i?l:`${l.slice(0,i)}...`:""}function Da(s,i,l){const d=String(s??"").trim(),_=String(i??"").trim(),g=String(l??"").trim();return[d,_,g].filter(Boolean).join(" -> ")}function cc(s){const i=s.payload??{};if(s.item_type==="entity"){const l=i.entity??{};return String(l.name??s.item_key??s.item_hash??"未命名实体")}if(s.item_type==="relation"){const l=i.relation??{};return Da(String(l.subject??""),String(l.predicate??""),String(l.object??""))||String(s.item_key??s.item_hash??"未命名关系")}if(s.item_type==="paragraph"){const l=i.paragraph??{};return String(l.source??"").trim()||String(s.item_key??s.item_hash??"未命名段落")}return String(s.item_key??s.item_hash??"未命名对象")}function oc(s){const i=s.payload??{};if(s.item_type==="entity"){const l=Array.isArray(i.paragraph_links)?i.paragraph_links:[];return l.length>0?`关联段落 ${l.length}`:"实体快照"}if(s.item_type==="relation"){const l=i.relation??{},d=Array.isArray(i.paragraph_hashes)?i.paragraph_hashes:[],{confidence:_}=l,g=[];return d.length>0&&g.push(`证据段落 ${d.length}`),typeof _=="number"&&g.push(`置信度 ${_.toFixed(2)}`),g.join("")||"关系快照"}if(s.item_type==="paragraph"){const l=i.paragraph??{};return On(String(l.content??""))}return""}function dc(s){const i=s.payload??{};if(s.item_type==="paragraph"){const l=i.paragraph??{};return String(l.source??"").trim()}return String(i.source??"").trim()}function wa(s){switch(s){case"correct":return"纠正";case"reject":return"否定";case"confirm":return"确认";case"supplement":return"补充";case"none":return"无动作";default:return s||"未知"}}function Ca(s){switch(s){case"pending":return"待处理";case"running":return"处理中";case"applied":return"已应用";case"skipped":return"已跳过";case"error":return"失败";default:return s||"未知"}}function Ia(s){switch(s){case"none":return"未回退";case"running":return"回退中";case"rolled_back":return"已回退";case"error":return"回退失败";default:return s||"未知"}}function Yt(s){return s==="applied"||s==="rolled_back"?"default":s==="error"?"destructive":s==="running"||s==="pending"?"outline":"secondary"}function ks(s){if(!s)return"";const i=String(s.hash??"").trim(),l=String(s.subject??"").trim(),d=String(s.predicate??"").trim(),_=String(s.object??"").trim();return l&&d&&_?Da(l,d,_):i||(Array.isArray(s.target_hashes)&&s.target_hashes.length>0?`targets ${s.target_hashes.length}`:On(JSON.stringify(s,null,2),120))}function uc(s){if(!s||typeof s!="object")return null;const i=s,l=String(i.subject??"").trim(),d=String(i.predicate??"").trim(),_=String(i.object??"").trim();return!l||!d||!_?null:i}function Mn(s){const i=uc(s);return i?Da(String(i.subject??""),String(i.predicate??""),String(i.object??"")):""}function Fn(s){if(!s)return{headline:"当前没有纠错摘要",oldRelation:"",newRelation:""};const l=s.rollback_plan_summary??{},d=Array.isArray(l.forgotten_relations)?l.forgotten_relations:[],_=l.corrected_write&&typeof l.corrected_write=="object"?l.corrected_write:{},g=Array.isArray(_.corrected_relations)?_.corrected_relations:[],y=Mn(d[0]),S=Mn(g[0]);return y&&S?{headline:`将“${y}”纠正为“${S}`,oldRelation:y,newRelation:S}:S?{headline:`补充了新的纠错结论:“${S}`,oldRelation:"",newRelation:S}:y?{headline:`撤销了旧记忆关系:“${y}`,oldRelation:y,newRelation:""}:{headline:s.query_text||"当前纠错没有可读摘要",oldRelation:"",newRelation:""}}function Dn(s){if(!s)return[];const i=s.affected_counts??{},l=[];return Number(i.relations??0)>0&&l.push(`影响关系 ${Number(i.relations??0)}`),Number(i.corrected_relations??0)>0&&l.push(`新增纠正关系 ${Number(i.corrected_relations??0)}`),Number(i.correction_paragraphs??0)>0&&l.push(`写入纠错段落 ${Number(i.correction_paragraphs??0)}`),Number(i.stale_paragraphs??0)>0&&l.push(`标记旧段落 ${Number(i.stale_paragraphs??0)}`),Number(i.episode_sources??0)>0&&l.push(`触发 Episode 修复 ${Number(i.episode_sources??0)} 个来源`),Number(i.profile_person_ids??0)>0&&l.push(`触发 Profile 刷新 ${Number(i.profile_person_ids??0)} 个对象`),l}function mc(s){switch(s){case"classification":return"判定纠错";case"forget_relation":return"撤销旧关系";case"mark_stale_paragraph":return"标记旧段落";case"write_correction":return"写入纠错";case"rollback_restore_relation":return"恢复旧关系";case"rollback_delete_correction_paragraph":return"隐藏纠错段落";case"rollback_revert_corrected_relation":return"撤销纠正关系";case"rollback_clear_stale_mark":return"清除脏段落标记";case"rollback_enqueue_episode_rebuild":return"加入 Episode 修复队列";case"rollback_enqueue_profile_refresh":return"加入 Profile 刷新队列";case"rollback_error":return"回退失败";case"error":return"处理失败";case"skip":return"跳过处理";default:return s||"未知动作"}}function xc(s){const i=ks(s.before_payload),l=ks(s.after_payload);switch(s.action_type){case"classification":return l?`系统完成判定:${l}`:"系统完成纠错判定";case"forget_relation":return i?`旧关系已失效:${i}`:"旧关系已被标记为失效";case"mark_stale_paragraph":return"旧段落已标记为待复核,后续检索会更谨慎地使用它";case"write_correction":return l?`已写入新的纠错结果:${l}`:"已写入新的纠错段落和关系";case"rollback_restore_relation":return l?`已恢复旧关系状态:${l}`:"已恢复旧关系状态";case"rollback_delete_correction_paragraph":return"已隐藏这次纠错写入的段落";case"rollback_revert_corrected_relation":return"已撤销纠错阶段新增的关系";case"rollback_clear_stale_mark":return"已清除旧段落的待复核标记";case"rollback_enqueue_episode_rebuild":return"已重新加入 Episode 修复队列";case"rollback_enqueue_profile_refresh":return"已重新加入 Profile 刷新队列";case"rollback_error":return s.reason||"这次回退执行失败";case"error":return s.reason||"这次纠错处理失败";case"skip":return s.reason||"这次纠错被跳过";default:return l||i||s.reason||"记录了一条动作日志"}}function hc(s){const{sourceSearch:i,setSourceSearch:l,selectedSources:d,setSelectedSources:_,filteredSources:g,openSourceDeletePreview:y,toggleSourceSelection:S,operationSearch:z,setOperationSearch:I,operationModeFilter:$,setOperationModeFilter:O,operationStatusFilter:H,setOperationStatusFilter:w,filteredDeleteOperations:re,deleteOperations:v,operationPage:oe,setOperationPage:F,deleteOperationPageCount:ne,pagedDeleteOperations:q,selectedDeleteOperation:L,setSelectedOperationId:x,restoreDeleteOperation:U,deleteRestoring:m,selectedOperationCounts:P,selectedOperationDetailLoading:K,selectedOperationDetailError:ie,selectedOperationSources:de,selectedOperationItems:he,filteredSelectedOperationItems:h,selectedOperationItemSearch:le,setSelectedOperationItemSearch:W,selectedOperationItemPage:Q,setSelectedOperationItemPage:ce,selectedOperationItemPageCount:A,pagedSelectedOperationItems:ke}=s;return e.jsx(xe,{value:"delete",className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs(X,{className:"order-2",children:[e.jsxs(Y,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4"}),"来源批量删除"]}),e.jsx(ee,{children:"用于按来源清理测试数据或指定导入批次。该操作不会直接删除实体,只会删除来源段落和失去全部证据的关系。"})]}),e.jsxs(ze,{className:"border-amber-500/30 bg-amber-500/5 text-amber-950 dark:text-amber-200",children:[e.jsx(Ea,{className:"h-4 w-4 text-amber-500"}),e.jsx($e,{children:"建议先在图谱里确认影响范围,再在这里执行批量来源删除。所有删除都会先经过预览,并支持按删除记录恢复。"})]})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl border bg-muted/20 p-4 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"来源检索"}),e.jsx(p,{value:i,onChange:f=>l(f.target.value),placeholder:"搜索 source 名称"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 lg:justify-end",children:[e.jsx(k,{variant:"outline",onClick:()=>_(g.map(f=>String(f.source??"")).filter(Boolean)),children:"全选当前结果"}),e.jsxs(k,{onClick:()=>{y()},disabled:d.length<=0,children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"预览删除"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs(N,{variant:"outline",className:"bg-background/70",children:["当前命中 ",g.length," 个来源"]}),e.jsxs(N,{variant:d.length>0?"secondary":"outline",className:"bg-background/70",children:["已选择 ",d.length," 个来源"]})]}),e.jsx(ye,{className:"h-[320px] rounded-lg border",children:e.jsxs(We,{children:[e.jsx(_s,{className:"sticky top-0 bg-background",children:e.jsxs(D,{children:[e.jsx(Z,{className:"w-12",children:"选中"}),e.jsx(Z,{children:"来源"}),e.jsx(Z,{children:"段落数"}),e.jsx(Z,{children:"关系数"})]})}),e.jsx(He,{children:g.length>0?g.map(f=>{const J=String(f.source??""),ue=d.includes(J);return e.jsxs(D,{children:[e.jsx(b,{children:e.jsx(me,{checked:ue,onCheckedChange:ae=>S(J,!!ae)})}),e.jsx(b,{className:"font-mono text-xs break-all",children:J}),e.jsx(b,{children:Number(f.paragraph_count??0)}),e.jsx(b,{children:Number(f.relation_count??0)})]},J)}):e.jsx(D,{children:e.jsx(b,{colSpan:4,className:"text-center text-muted-foreground",children:"当前没有可删除的来源"})})})]})})]})]}),e.jsxs(X,{className:"order-1",children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"删除操作恢复"]}),e.jsx(ee,{children:"按列表浏览最近的删除操作,先选中记录,再在下方确认影响范围并执行恢复"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl border bg-muted/20 p-4 lg:grid-cols-[minmax(0,1fr)_180px_180px]",children:[e.jsx(p,{value:z,onChange:f=>I(f.target.value),placeholder:"搜索 operation / reason / requested_by / source"}),e.jsxs(Ee,{value:$,onValueChange:O,children:[e.jsx(Re,{children:e.jsx(Oe,{placeholder:"按模式筛选"})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"all",children:"全部模式"}),e.jsx(C,{value:"source",children:"来源删除"}),e.jsx(C,{value:"mixed",children:"混合删除"}),e.jsx(C,{value:"entity",children:"实体删除"}),e.jsx(C,{value:"relation",children:"关系删除"}),e.jsx(C,{value:"paragraph",children:"段落删除"})]})]}),e.jsxs(Ee,{value:H,onValueChange:w,children:[e.jsx(Re,{children:e.jsx(Oe,{placeholder:"按状态筛选"})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"all",children:"全部状态"}),e.jsx(C,{value:"executed",children:"已执行"}),e.jsx(C,{value:"restored",children:"已恢复"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["当前命中 ",re.length," 条记录,已加载最近 ",v.length," 条"]}),e.jsxs("span",{children:["第 ",oe," / ",ne," 页,每页显示 ",sr," 条"]})]}),e.jsx(ye,{className:"h-[320px] rounded-lg border",children:e.jsx("div",{className:"space-y-3 p-3",children:q.length>0?q.map(f=>{const ue=(f.summary??{}).counts??{},ae=L?.operation_id===f.operation_id;return e.jsxs("button",{type:"button",onClick:()=>x(f.operation_id),className:G("w-full rounded-xl border p-4 text-left transition-colors",ae?"border-primary bg-primary/5 shadow-sm":"bg-muted/20 hover:border-primary/40 hover:bg-muted/40"),children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:f.status==="restored"?"secondary":"default",children:Pn(String(f.status??""))}),e.jsx(N,{variant:"outline",children:In(String(f.mode??""))})]}),e.jsx("div",{className:"font-mono text-xs break-all",children:f.operation_id}),e.jsx("div",{className:"text-sm text-muted-foreground",children:f.reason||"未填写原因"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground lg:max-w-[280px] lg:justify-end",children:[e.jsxs("span",{children:["实体 ",Number(ue.entities??0)]}),e.jsxs("span",{children:["关系 ",Number(ue.relations??0)]}),e.jsxs("span",{children:["段落 ",Number(ue.paragraphs??0)]}),e.jsxs("span",{children:["来源 ",Number(ue.sources??0)]})]})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:Ns(f.created_at)})]},f.operation_id)}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:"当前筛选条件下没有删除操作"})})}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>F(f=>Math.max(1,f-1)),disabled:oe<=1,children:"上一页"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"支持按删除记录、模式、状态、发起人和来源检索"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>F(f=>Math.min(ne,f+1)),disabled:oe>=ne,children:"下一页"})]}),e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4",children:L?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:L.status==="restored"?"secondary":"default",children:Pn(String(L.status??""))}),e.jsx(N,{variant:"outline",children:In(String(L.mode??""))})]}),e.jsx("div",{className:"font-mono text-xs break-all",children:L.operation_id}),e.jsx("div",{className:"text-sm text-muted-foreground",children:L.reason||"未填写删除原因"})]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>{U(L.operation_id)},disabled:L.status==="restored"||m,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),L.status==="restored"?"已恢复":"恢复这次删除"]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"发起人"}),e.jsx("div",{className:"mt-1 text-sm",children:L.requested_by||"-"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"创建时间"}),e.jsx("div",{className:"mt-1 text-sm",children:Ns(L.created_at)})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"恢复时间"}),e.jsx("div",{className:"mt-1 text-sm",children:Ns(L.restored_at)})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"删除摘要"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",children:["实体 ",Number(P.entities??0)]}),e.jsxs(N,{variant:"outline",children:["关系 ",Number(P.relations??0)]}),e.jsxs(N,{variant:"outline",children:["段落 ",Number(P.paragraphs??0)]}),e.jsxs(N,{variant:"outline",children:["来源 ",Number(P.sources??0)]})]})]})]}),K?e.jsx("div",{className:"rounded-lg border bg-background/60 p-4 text-sm text-muted-foreground",children:"正在加载影响对象详情..."}):null,ie?e.jsx(ze,{variant:"destructive",children:e.jsx($e,{children:ie})}):null,de.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold",children:"关联来源"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:de.map(f=>e.jsx(N,{variant:"secondary",className:"max-w-full break-all",children:f},f))})]}):null,e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold",children:"选择器"}),e.jsx("pre",{className:"max-h-56 overflow-auto rounded-lg border bg-background/70 p-3 text-xs break-words whitespace-pre-wrap",children:JSON.stringify(L.selector??{},null,2)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-semibold",children:"影响对象"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["命中 ",h.length," / ",he.length," 项"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsx(p,{value:le,onChange:f=>W(f.target.value),placeholder:"搜索对象类型 / 哈希 / 对象键 / 来源",className:"lg:max-w-sm"}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground lg:min-w-[180px] lg:justify-end",children:[e.jsxs("span",{children:["第 ",Q," / ",A," 页"]}),e.jsxs("span",{children:["每页 ",tr," 项"]})]})]}),e.jsx(ye,{className:"h-[280px] rounded-lg border bg-background/60",children:e.jsx("div",{className:"space-y-2 p-3",children:ke.length>0?ke.map(f=>{const J=dc(f),ue=cc(f),ae=oc(f);return e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"outline",children:f.item_type}),J?e.jsx(N,{variant:"secondary",children:J}):null,f.item_key&&f.item_key!==f.item_hash?e.jsx("span",{className:"text-xs text-muted-foreground break-all",children:f.item_key}):null]}),e.jsx("div",{className:"mt-2 text-sm font-medium break-words",children:ue}),ae?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground break-words",children:ae}):null,e.jsx("div",{className:"mt-2 font-mono text-[11px] break-all text-muted-foreground",children:f.item_hash})]},`${f.item_type}:${f.item_hash}:${f.item_key??""}`)}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:he.length>0?"当前筛选条件下没有明细项":"当前操作没有记录明细项"})})}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>ce(f=>Math.max(1,f-1)),disabled:Q<=1,children:"上一页"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"支持按对象类型、哈希、对象键和来源检索"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>ce(f=>Math.min(A,f+1)),disabled:Q>=A,children:"下一页"})]})]})]})]}):e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-lg border border-dashed bg-background/40 p-6 text-center text-sm text-muted-foreground",children:"当前没有可查看的删除操作详情"})})]})]})]})})}function pc(s){const{feedbackSearch:i,setFeedbackSearch:l,feedbackStatusFilter:d,setFeedbackStatusFilter:_,feedbackRollbackFilter:g,setFeedbackRollbackFilter:y,filteredFeedbackCorrections:S,feedbackCorrections:z,pagedFeedbackCorrections:I,feedbackPage:$,setFeedbackPage:O,feedbackPageCount:H,selectedFeedbackCorrection:w,setSelectedFeedbackTaskId:re,selectedFeedbackResolved:v,selectedFeedbackPreview:oe,selectedFeedbackImpactSummary:F,openFeedbackRollbackDialog:ne,feedbackRollingBack:q,selectedFeedbackTaskLoading:L,selectedFeedbackTaskError:x,feedbackActionLogPage:U,setFeedbackActionLogPage:m,feedbackActionLogPageCount:P,feedbackActionLogSearch:K,setFeedbackActionLogSearch:ie,pagedFeedbackActionLogs:de,selectedFeedbackActionLogs:he}=s;return e.jsx(xe,{value:"feedback",className:"space-y-4",children:e.jsx("div",{className:"space-y-4",children:e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"反馈纠错历史"]}),e.jsx(ee,{children:"查看 feedback correction 的判定、修改轨迹与回退结果"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_180px_180px]",children:[e.jsx(p,{value:i,onChange:h=>l(h.target.value),placeholder:"搜索查询编号 / 会话 / 查询内容 / 原因"}),e.jsxs(Ee,{value:d,onValueChange:_,children:[e.jsx(Re,{children:e.jsx(Oe,{placeholder:"按任务状态筛选"})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"all",children:"全部任务状态"}),e.jsx(C,{value:"applied",children:"已应用"}),e.jsx(C,{value:"skipped",children:"已跳过"}),e.jsx(C,{value:"error",children:"失败"}),e.jsx(C,{value:"running",children:"处理中"}),e.jsx(C,{value:"pending",children:"待处理"})]})]}),e.jsxs(Ee,{value:g,onValueChange:y,children:[e.jsx(Re,{children:e.jsx(Oe,{placeholder:"按回退状态筛选"})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"all",children:"全部回退状态"}),e.jsx(C,{value:"none",children:"未回退"}),e.jsx(C,{value:"rolled_back",children:"已回退"}),e.jsx(C,{value:"error",children:"回退失败"}),e.jsx(C,{value:"running",children:"回退中"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border bg-background/70 px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["当前命中 ",S.length," 条记录,已加载最近 ",z.length," 条"]}),e.jsxs("span",{children:["第 ",$," / ",H," 页,每页显示 ",rr," 条"]})]}),e.jsxs("div",{className:"grid items-start gap-4 xl:grid-cols-[minmax(0,0.92fr)_minmax(0,1.08fr)]",children:[e.jsx(ye,{className:"h-[720px] rounded-lg border",children:e.jsx("div",{className:"space-y-3 p-3",children:I.length>0?I.map(h=>{const le=w?.task_id===h.task_id,W=Fn(h),Q=Dn(h);return e.jsx("button",{type:"button",onClick:()=>re(h.task_id),className:G("w-full rounded-xl border p-4 text-left transition-colors",le?"border-primary bg-primary/5 shadow-sm":"bg-muted/20 hover:border-primary/40 hover:bg-muted/40"),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:Yt(h.task_status),children:Ca(h.task_status)}),e.jsx(N,{variant:Yt(h.rollback_status),children:Ia(h.rollback_status)}),e.jsx(N,{variant:"outline",children:wa(h.decision)})]}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:Ns(h.query_timestamp??h.created_at)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-semibold break-words",children:W.headline}),e.jsxs("div",{className:"text-xs text-muted-foreground break-words",children:["查询:",h.query_text||"无查询文本"]})]}),W.oldRelation||W.newRelation?e.jsx("div",{className:"grid gap-2 rounded-lg border bg-background/70 p-3 text-xs shadow-sm",children:e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:items-stretch",children:[e.jsxs("div",{className:"rounded-md border border-amber-500/20 bg-amber-500/5 p-2",children:[e.jsx("div",{className:"text-[11px] font-medium text-amber-700 dark:text-amber-300",children:"纠错前"}),e.jsx("div",{className:"mt-1 break-words",children:W.oldRelation||"无"})]}),e.jsx("div",{className:"hidden items-center text-muted-foreground sm:flex",children:"→"}),e.jsxs("div",{className:"rounded-md border border-emerald-500/20 bg-emerald-500/5 p-2",children:[e.jsx("div",{className:"text-[11px] font-medium text-emerald-700 dark:text-emerald-300",children:"纠错后"}),e.jsx("div",{className:"mt-1 break-words",children:W.newRelation||"无"})]})]})}):null,e.jsx("div",{className:"flex flex-wrap gap-2",children:Q.length>0?Q.slice(0,3).map(ce=>e.jsx(N,{variant:"secondary",className:"font-normal",children:ce},`${h.task_id}:${ce}`)):e.jsx(N,{variant:"secondary",className:"font-normal",children:"暂无影响摘要"})}),e.jsx("div",{className:"font-mono text-[11px] break-all text-muted-foreground",children:h.query_tool_id})]})},h.task_id)}):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:"当前筛选条件下没有纠错历史"})})}),e.jsx("div",{className:"self-start rounded-xl border bg-muted/20 p-4",children:w?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:Yt(String(v?.task_status??"")),children:Ca(String(v?.task_status??""))}),e.jsx(N,{variant:Yt(String(v?.rollback_status??"none")),children:Ia(String(v?.rollback_status??"none"))}),e.jsx(N,{variant:"outline",children:wa(String(v?.decision??""))})]}),e.jsx("div",{className:"text-base font-semibold break-words",children:oe.headline}),e.jsxs("div",{className:"text-sm text-muted-foreground break-words",children:["查询:",v?.query_text||"无查询文本"]}),e.jsx("div",{className:"font-mono text-xs break-all text-muted-foreground",children:v?.query_tool_id})]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:ne,disabled:String(v?.task_status??"")!=="applied"||String(v?.rollback_status??"none")==="rolled_back"||q,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),String(v?.rollback_status??"none")==="rolled_back"?"已回退":"回退本次纠错"]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs("div",{className:"rounded-xl border bg-background/70 p-4 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold",children:"本次纠错结论"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] md:items-stretch",children:[e.jsxs("div",{className:"rounded-lg border border-amber-500/20 bg-amber-500/5 p-3",children:[e.jsx("div",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"纠错前"}),e.jsx("div",{className:"mt-2 text-sm break-words",children:oe.oldRelation||"当前详情没有记录旧结论"})]}),e.jsx("div",{className:"hidden items-center justify-center text-muted-foreground md:flex",children:"→"}),e.jsxs("div",{className:"rounded-lg border border-emerald-500/20 bg-emerald-500/5 p-3",children:[e.jsx("div",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300",children:"纠错后"}),e.jsx("div",{className:"mt-2 text-sm break-words",children:oe.newRelation||"当前详情没有记录新结论"})]})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background/70 p-4 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold",children:"影响范围摘要"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:F.length>0?F.map(h=>e.jsx(N,{variant:"secondary",className:"bg-primary/10 font-normal text-primary hover:bg-primary/15",children:h},h)):e.jsx("div",{className:"text-sm text-muted-foreground",children:"当前没有可展示的影响范围摘要"})})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"会话"}),e.jsx("div",{className:"mt-1 text-sm break-all",children:v?.session_id||"-"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"反馈消息数"}),e.jsx("div",{className:"mt-1 text-sm",children:Number(v?.feedback_message_count??0)})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"判定置信度"}),e.jsx("div",{className:"mt-1 text-sm",children:Number(v?.decision_confidence??0).toFixed(2)})]}),e.jsxs("div",{className:"rounded-lg border bg-background/60 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"回退时间"}),e.jsx("div",{className:"mt-1 text-sm",children:Ns(v?.rolled_back_at)})]})]}),L?e.jsx("div",{className:"rounded-lg border bg-background/60 p-4 text-sm text-muted-foreground",children:"正在加载纠错详情..."}):null,x?e.jsx(ze,{variant:"destructive",children:e.jsx($e,{children:x})}):null,v?.rollback_error?e.jsx(ze,{variant:"destructive",children:e.jsx($e,{children:v.rollback_error})}):null,e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs("div",{className:"rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-sm font-semibold",children:"回退后会发生什么"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("div",{children:"会恢复旧关系状态,并撤销本次纠错写入的段落与关系。"}),e.jsx("div",{children:"会清理旧段落的待复核标记,并重新触发相关 Episode / Profile 修复。"}),e.jsx("div",{children:"如果你当前只是核对结果,可以先查看下面的详细数据,不必立刻执行回退。"})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-sm font-semibold",children:"处理摘要"}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:["判定:",wa(String(v?.decision??""))]}),e.jsxs("div",{children:["任务状态:",Ca(String(v?.task_status??""))]}),e.jsxs("div",{children:["回退状态:",Ia(String(v?.rollback_status??"none"))]}),e.jsxs("div",{children:["反馈消息数:",Number(v?.feedback_message_count??0)]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold",children:"详细数据"}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[e.jsxs("details",{className:"rounded-lg border bg-background/70 p-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"查询快照 JSON"}),e.jsx("pre",{className:"mt-3 max-h-56 overflow-auto text-xs break-words whitespace-pre-wrap",children:JSON.stringify(v?.query_snapshot??{},null,2)})]}),e.jsxs("details",{className:"rounded-lg border bg-background/70 p-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"判定结果 JSON"}),e.jsx("pre",{className:"mt-3 max-h-56 overflow-auto text-xs break-words whitespace-pre-wrap",children:JSON.stringify(v?.decision_payload??{},null,2)})]}),e.jsxs("details",{className:"rounded-lg border bg-background/70 p-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"回退计划摘要 JSON"}),e.jsx("pre",{className:"mt-3 max-h-64 overflow-auto text-xs break-words whitespace-pre-wrap",children:JSON.stringify(v?.rollback_plan_summary??{},null,2)})]}),e.jsxs("details",{className:"rounded-lg border bg-background/70 p-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"回退结果 JSON"}),e.jsx("pre",{className:"mt-3 max-h-64 overflow-auto text-xs break-words whitespace-pre-wrap",children:JSON.stringify(v?.rollback_result??{},null,2)})]})]})]}),e.jsxs("details",{className:"rounded-xl border bg-background/70 p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold",children:"动作时间线"}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["第 ",U," / ",P," 页,每页 ",ar," 项"]}),e.jsx(p,{value:K,onChange:h=>ie(h.target.value),placeholder:"搜索动作 / 目标哈希 / 预览内容",className:"lg:w-80"})]}),e.jsx(ye,{className:"h-[240px] rounded-lg border bg-background/60",children:e.jsx("div",{className:"space-y-2 p-3",children:de.length>0?de.map(h=>e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"outline",children:mc(h.action_type)}),h.target_hash?e.jsx("span",{className:"font-mono text-[11px] break-all text-muted-foreground",children:h.target_hash}):null]}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:Ns(h.created_at)})]}),e.jsx("div",{className:"mt-2 text-sm break-words",children:xc(h)}),h.reason?e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground break-words",children:["原因:",h.reason]}):null,h.before_payload&&Object.keys(h.before_payload).length>0?e.jsxs("div",{className:"mt-3 rounded-md border bg-background/70 p-2 text-xs break-words",children:[e.jsx("span",{className:"font-medium",children:"处理前:"}),e.jsx("span",{className:"text-muted-foreground",children:ks(h.before_payload)})]}):null,h.after_payload&&Object.keys(h.after_payload).length>0?e.jsxs("div",{className:"mt-2 rounded-md border bg-background/70 p-2 text-xs break-words",children:[e.jsx("span",{className:"font-medium",children:"处理后:"}),e.jsx("span",{className:"text-muted-foreground",children:ks(h.after_payload)})]}):null]},`${h.id}:${h.action_type}`)):e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:he.length>0?"当前筛选条件下没有动作日志":"当前任务没有动作日志"})})}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>m(h=>Math.max(1,h-1)),disabled:U<=1,children:"上一页"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"支持按动作类型、目标哈希和摘要检索"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>m(h=>Math.min(P,h+1)),disabled:U>=P,children:"下一页"})]})]})]})]}):e.jsx("div",{className:"flex min-h-[360px] items-center justify-center rounded-lg border border-dashed bg-background/40 p-6 text-center text-sm text-muted-foreground",children:"当前没有可查看的纠错详情"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>O(h=>Math.max(1,h-1)),disabled:$<=1,children:"上一页"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"支持按查询内容、任务状态和回退状态检索"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>O(h=>Math.min(H,h+1)),disabled:$>=H,children:"下一页"})]})]})]})})})}const gc={default:"text-primary",success:"text-emerald-500",warning:"text-amber-500",destructive:"text-rose-500",muted:"text-muted-foreground"},fc={default:"default",success:"secondary",warning:"outline",destructive:"destructive",muted:"outline"};function jc({value:s,statusLabel:i,stepLabel:l,tone:d="default",busy:_=!1,compact:g=!1,detail:y,className:S}){const z=Number.isFinite(s)?Math.max(0,Math.min(100,s)):0,I=g?36:56,$=g?4:5,O=(I-$)/2,H=2*Math.PI*O,w=H*(1-z/100);return e.jsxs("div",{className:G("flex items-center gap-3",S),children:[e.jsxs("div",{className:G("relative shrink-0",gc[d]),style:{width:I,height:I},"aria-hidden":"true",children:[e.jsxs("svg",{width:I,height:I,className:"-rotate-90",children:[e.jsx("circle",{cx:I/2,cy:I/2,r:O,strokeWidth:$,className:"stroke-muted/40",fill:"none"}),e.jsx("circle",{cx:I/2,cy:I/2,r:O,strokeWidth:$,strokeLinecap:"round",stroke:"currentColor",fill:"none",strokeDasharray:H,strokeDashoffset:w,className:"transition-[stroke-dashoffset] duration-500 ease-out"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:_?e.jsx(Ge,{className:G("animate-spin",g?"h-3.5 w-3.5":"h-4 w-4")}):e.jsxs("span",{className:G("font-medium tabular-nums",g?"text-[10px]":"text-xs"),children:[Math.round(z),"%"]})})]}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i?e.jsx(N,{variant:fc[d],className:"shrink-0",children:i}):null,l?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:l}):null,g?null:e.jsxs("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[z.toFixed(1),"%"]})]}),e.jsx(er,{value:z,className:G(g?"h-1":"h-1.5")}),y?e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:y}):null]})]})}function Tn(s,i,l,d=0){const _=Number(s??0),g=Number(i??0),y=Number(l??0),S=Number(d??0),z=[`成功 ${_} / ${g} 分块`];return y>0&&z.push(`失败 ${y}`),S>0&&z.push(`取消 ${S}`),z.join(" · ")}function vc(s){const{importCreateMode:i,setImportCreateMode:l,importSettings:d,importCommonFileConcurrency:_,setImportCommonFileConcurrency:g,importCommonChunkConcurrency:y,setImportCommonChunkConcurrency:S,importCommonLlmEnabled:z,setImportCommonLlmEnabled:I,importCommonChatLog:$,setImportCommonChatLog:O,importCommonStrategyOverride:H,setImportCommonStrategyOverride:w,importCommonDedupePolicy:re,setImportCommonDedupePolicy:v,importCommonChatReferenceTime:oe,setImportCommonChatReferenceTime:F,importCommonForce:ne,setImportCommonForce:q,importCommonClearManifest:L,setImportCommonClearManifest:x,uploadInputMode:U,setUploadInputMode:m,uploadFiles:P,setUploadFiles:K,pasteName:ie,setPasteName:de,pasteMode:he,setPasteMode:h,pasteContent:le,setPasteContent:W,rawAlias:Q,setRawAlias:ce,rawInputMode:A,setRawInputMode:ke,rawRelativePath:f,setRawRelativePath:J,rawGlob:ue,setRawGlob:ae,rawRecursive:Qe,setRawRecursive:j,openieAlias:M,setOpenieAlias:pe,openieRelativePath:De,setOpenieRelativePath:be,openieIncludeAllJson:B,setOpenieIncludeAllJson:Ne,convertAlias:Ue,setConvertAlias:_e,convertTargetAlias:Se,setConvertTargetAlias:we,convertRelativePath:Ss,setConvertRelativePath:Ze,convertTargetRelativePath:c,setConvertTargetRelativePath:E,convertDimension:Xe,setConvertDimension:ws,convertBatchSize:ur,setConvertBatchSize:Cs,backfillAlias:mr,setBackfillAlias:Is,backfillLimit:xr,setBackfillLimit:as,backfillRelativePath:vt,setBackfillRelativePath:Ps,backfillDryRun:bt,setBackfillDryRun:Ms,backfillNoCreatedFallback:hr,setBackfillNoCreatedFallback:ns,maibotSourceDb:Nt,setMaibotSourceDb:Ts,maibotTimeFrom:yt,setMaibotTimeFrom:Es,maibotTimeTo:pr,setMaibotTimeTo:Rs,maibotStartId:gr,setMaibotStartId:Os,maibotEndId:fr,setMaibotEndId:Fs,maibotStreamIds:jr,setMaibotStreamIds:Ds,maibotGroupIds:kt,setMaibotGroupIds:Ls,maibotUserIds:vr,setMaibotUserIds:As,maibotReadBatchSize:br,setMaibotReadBatchSize:Bs,maibotCommitWindowRows:_t,setMaibotCommitWindowRows:zs,maibotEmbedWorkers:Nr,setMaibotEmbedWorkers:$s,maibotNoResume:St,setMaibotNoResume:qs,maibotResetState:yr,setMaibotResetState:Js,maibotDryRun:kr,setMaibotDryRun:Us,maibotVerifyOnly:_r,setMaibotVerifyOnly:Ks,submitImportByMode:wt,creatingImport:is,pathResolveAlias:Ct,setPathResolveAlias:Vs,importAliasKeys:It,pathResolveRelativePath:Gs,setPathResolveRelativePath:Sr,pathResolveMustExist:Ws,setPathResolveMustExist:wr,resolveImportPath:qe,resolvingPath:ls,pathResolveOutput:Hs,refreshImportQueue:Cr,runningImportTasks:Ke,queuedImportTasks:cs,recentImportTasks:Ve,selectedImportTaskId:Ye,selectImportTask:es,importAutoPolling:Ir,setImportAutoPolling:Qs,importPollInterval:Pr,importErrorText:os,cancelSelectedImportTask:Mr,retrySelectedImportTask:Zs,selectedImportTaskLoading:Tr,selectedImportTaskResolved:V,selectedImportRetrySummary:ss,selectedImportTaskErrorText:ds,selectedImportFiles:Pt,selectedImportFileId:Xs,selectImportFile:Er,importChunkTotal:ts,importChunkOffset:Mt,moveImportChunkPage:us,canImportChunkPrev:Rr,canImportChunkNext:Ys,importChunksLoading:Or,selectedImportChunks:ms}=s;return e.jsxs(xe,{value:"import",className:"space-y-6 [&_input]:h-10 [&_[role=combobox]]:h-10 [&_textarea]:min-h-[96px]",children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"order-2 space-y-6 lg:order-1",children:[e.jsxs(X,{className:"rounded-2xl border-border/70 shadow-sm",children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"h-4 w-4"}),"创建导入任务"]}),e.jsx(ee,{children:"按“选择导入方式 → 检查公共参数 → 创建任务”的顺序完成导入。"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs(En,{value:i,onValueChange:a=>l(a),className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"选择导入方式"}),e.jsx(Rn,{items:lc})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border bg-muted/30 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"公共参数"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"这些设置会应用到当前导入任务。一般保持默认即可,只在批量导入或排查问题时调整。"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"文件并发数"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"同时处理多少个文件;文件很多时再适当调高。"}),e.jsx(p,{type:"number",min:1,max:Number(d.max_file_concurrency??128),value:_,onChange:a=>g(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"分块并发数"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"单个文件内并行处理多少个分块;过高会增加资源占用。"}),e.jsx(p,{type:"number",min:1,max:Number(d.max_chunk_concurrency??256),value:y,onChange:a=>S(a.target.value)})]}),e.jsxs("div",{className:"rounded-md border bg-background/70 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:z,onCheckedChange:a=>I(!!a)}),"启用 LLM 抽取"]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"需要模型参与抽取,质量更高但耗时更长。"})]}),e.jsxs("div",{className:"rounded-md border bg-background/70 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:$,onCheckedChange:a=>O(!!a)}),"按聊天日志解析"]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"适合导入聊天记录,会尽量保留时间和对话上下文。"})]})]}),e.jsxs("details",{className:"rounded-md border bg-background/70 p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-medium text-muted-foreground",children:"高级参数(通常不用修改)"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"指定抽取策略"}),e.jsx(p,{value:H,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"去重策略"}),e.jsx(p,{value:re,onChange:a=>v(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"聊天参考时间"}),e.jsx(p,{value:oe,onChange:a=>F(a.target.value)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:ne,onCheckedChange:a=>q(!!a)}),"强制导入"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:L,onCheckedChange:a=>x(!!a)}),"清空导入清单"]})]})]})]}),e.jsx(xe,{value:"upload",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"选择一个或多个本地文件创建导入任务,适合批量导入资料或聊天记录。"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"输入模式"}),e.jsxs(Ee,{value:U,onValueChange:a=>m(_a(a)),children:[e.jsx(Re,{"aria-label":"upload-input-mode",children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"text",children:"文本"}),e.jsx(C,{value:"json",children:"结构化 JSON"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"文件选择"}),e.jsx(p,{type:"file",multiple:!0,accept:".txt,.md,.json,.jsonl,.csv,.log,.html,.htm,.xml",onChange:a=>K(Array.from(a.target.files??[]))})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["已选择 ",P.length," 个文件"]})]})}),e.jsx(xe,{value:"paste",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"直接粘贴少量文本或 JSON适合临时补充一段资料。"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"内容名称"}),e.jsx(p,{value:ie,onChange:a=>de(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"输入模式"}),e.jsxs(Ee,{value:he,onValueChange:a=>h(_a(a)),children:[e.jsx(Re,{"aria-label":"paste-input-mode",children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"text",children:"文本"}),e.jsx(C,{value:"json",children:"结构化 JSON"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"粘贴内容"}),e.jsx(ys,{value:le,onChange:a=>W(a.target.value),rows:8})]})]})]})}),e.jsx(xe,{value:"raw_scan",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"扫描目录文件,适合本地批处理"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"路径别名"}),e.jsx(p,{value:Q,onChange:a=>ce(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"输入模式"}),e.jsxs(Ee,{value:A,onValueChange:a=>ke(_a(a)),children:[e.jsx(Re,{"aria-label":"raw-input-mode",children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"text",children:"文本"}),e.jsx(C,{value:"json",children:"结构化 JSON"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"相对路径"}),e.jsx(p,{value:f,onChange:a=>J(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"匹配规则Glob"}),e.jsx(p,{value:ue,onChange:a=>ae(a.target.value)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:Qe,onCheckedChange:a=>j(!!a)}),"递归扫描"]})]})}),e.jsx(xe,{value:"lpmm_openie",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"读取 LPMM 内容并抽取关系"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"路径别名"}),e.jsx(p,{value:M,onChange:a=>pe(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"相对路径"}),e.jsx(p,{value:De,onChange:a=>be(a.target.value)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:B,onCheckedChange:a=>Ne(!!a)}),"包含全部 JSON 文件"]})]})}),e.jsx(xe,{value:"lpmm_convert",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"将 LPMM 数据转换到目标目录"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"源路径别名"}),e.jsx(p,{value:Ue,onChange:a=>_e(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"目标路径别名"}),e.jsx(p,{value:Se,onChange:a=>we(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"源相对路径"}),e.jsx(p,{value:Ss,onChange:a=>Ze(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"目标相对路径"}),e.jsx(p,{value:c,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"向量维度"}),e.jsx(p,{type:"number",min:1,value:Xe,onChange:a=>ws(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"批处理大小"}),e.jsx(p,{type:"number",min:1,value:ur,onChange:a=>Cs(a.target.value)})]})]})]})}),e.jsx(xe,{value:"temporal_backfill",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"为已有数据补齐时间字段"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"路径别名"}),e.jsx(p,{value:mr,onChange:a=>Is(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"处理上限"}),e.jsx(p,{type:"number",min:1,value:xr,onChange:a=>as(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"相对路径"}),e.jsx(p,{value:vt,onChange:a=>Ps(a.target.value)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:bt,onCheckedChange:a=>Ms(!!a)}),"只预演,不写入数据"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:hr,onCheckedChange:a=>ns(!!a)}),"禁用创建时间回退"]})]})]})}),e.jsx(xe,{value:"maibot_migration",className:"mt-0",children:e.jsxs("div",{className:"space-y-3 rounded-xl border bg-background/70 p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"迁移 MaiBot 历史长期记忆"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"源数据库路径"}),e.jsx(p,{value:Nt,onChange:a=>Ts(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"起始时间"}),e.jsx(p,{value:yt,onChange:a=>Es(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"结束时间"}),e.jsx(p,{value:pr,onChange:a=>Rs(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"起始 ID"}),e.jsx(p,{type:"number",min:1,value:gr,onChange:a=>Os(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"结束 ID"}),e.jsx(p,{type:"number",min:1,value:fr,onChange:a=>Fs(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"会话 ID 列表"}),e.jsx(p,{value:jr,onChange:a=>Ds(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"群组 ID 列表"}),e.jsx(p,{value:kt,onChange:a=>Ls(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"用户 ID 列表"}),e.jsx(p,{value:vr,onChange:a=>As(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"读取批大小"}),e.jsx(p,{type:"number",min:1,value:br,onChange:a=>Bs(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"提交窗口行数"}),e.jsx(p,{type:"number",min:1,value:_t,onChange:a=>zs(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"向量线程数"}),e.jsx(p,{type:"number",min:1,value:Nr,onChange:a=>$s(a.target.value)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:St,onCheckedChange:a=>qs(!!a)}),"从头开始,不继续上次进度"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:yr,onCheckedChange:a=>Js(!!a)}),"重置迁移状态"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:kr,onCheckedChange:a=>Us(!!a)}),"只预演,不写入数据"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:_r,onCheckedChange:a=>Ks(!!a)}),"仅校验"]})]})]})})]}),e.jsxs(k,{onClick:()=>{wt()},disabled:is,children:[is?e.jsx(Ge,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ra,{className:"mr-2 h-4 w-4"}),"创建导入任务"]})]})]}),e.jsxs(X,{className:"rounded-2xl border-border/70 bg-card/85 shadow-sm",children:[e.jsxs(Y,{children:[e.jsx(se,{children:"路径预检"}),e.jsx(ee,{children:"在创建本地扫描、转换或迁移任务前,先确认路径会被解析到哪里。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"路径别名"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"选择后端允许访问的数据根目录。"}),e.jsxs(Ee,{value:Ct,onValueChange:Vs,children:[e.jsx(Re,{"aria-label":"import-path-alias",children:e.jsx(Oe,{})}),e.jsx(Fe,{children:It.length>0?It.map(a=>e.jsx(C,{value:a,children:a},a)):e.jsx(C,{value:"raw",children:"raw"})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"相对路径"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"填写相对于路径别名的子路径,不需要填写完整磁盘路径。"}),e.jsx(p,{value:Gs,onChange:a=>Sr(a.target.value),placeholder:"例如 exports/weekly"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{checked:Ws,onCheckedChange:a=>wr(!!a)}),"要求路径已存在"]}),e.jsxs(k,{variant:"outline",onClick:()=>{qe()},disabled:ls||!Ct.trim(),children:[ls?e.jsx(Ge,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Be,{className:"mr-2 h-4 w-4"}),"解析路径"]}),e.jsx(ys,{value:Hs,readOnly:!0,rows:6,placeholder:"解析结果会显示在这里"})]})]})]}),e.jsx("div",{className:"order-1 space-y-6 lg:order-2",children:e.jsxs(X,{className:"rounded-2xl border-border/70 bg-card/90 shadow-sm",children:[e.jsxs(Y,{className:"space-y-4 pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(se,{children:"导入队列"}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{Cr()},children:[e.jsx(Be,{className:"mr-2 h-4 w-4"}),"刷新"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ee,{className:"text-sm",children:"查看任务是否正在运行、排队等待或已经结束。点击任务卡片可查看详情。"}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[e.jsxs(N,{variant:"outline",className:"bg-background/70",children:["运行中 ",Ke.length]}),e.jsxs(N,{variant:"outline",className:"bg-background/70",children:["排队中 ",cs.length]}),e.jsxs(N,{variant:"outline",className:"bg-background/70",children:["最近完成 ",Ve.length]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(me,{checked:Ir,onCheckedChange:a=>Qs(!!a)}),"自动轮询 ",Pr,"ms"]})]})]}),e.jsxs(te,{className:"space-y-6",children:[os?e.jsx(ze,{variant:"destructive",children:e.jsx($e,{children:os})}):null,e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"运行中"}),e.jsx(N,{variant:"outline",children:Ke.length})]}),Ke.length>0?e.jsx(ye,{className:"h-[208px] rounded-xl border bg-muted/10",children:e.jsx("div",{className:"space-y-2.5 p-2.5",children:Ke.map(a=>{const fe=a.task_id===Ye;return e.jsxs("button",{type:"button",onClick:()=>{es(a.task_id)},className:G("w-full rounded-xl border p-4 text-left transition-all",fe?"border-primary/70 bg-primary/5 shadow-sm":"bg-background/80 hover:border-muted-foreground/40 hover:bg-muted/20"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"break-all font-mono text-[11px] leading-relaxed text-muted-foreground",children:a.task_id}),e.jsx("div",{className:"text-sm font-medium",children:String(a.task_kind??a.mode??"-")})]}),e.jsx(N,{variant:bs(String(a.status??"")),children:rs(String(a.status??""))})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:pt(String(a.current_step??"running"))}),e.jsx("span",{children:ht(a.progress)})]}),e.jsx(er,{value:jt(a.progress),className:"mt-2 h-1.5"})]},a.task_id)})})}):e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:"当前没有运行中任务"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"排队中"}),e.jsx(N,{variant:"outline",children:cs.length})]}),cs.length>0?e.jsx(ye,{className:"h-[188px] rounded-xl border bg-muted/10",children:e.jsx("div",{className:"space-y-2.5 p-2.5",children:cs.map(a=>{const fe=a.task_id===Ye;return e.jsxs("button",{type:"button",onClick:()=>{es(a.task_id)},className:G("w-full rounded-xl border p-4 text-left transition-all",fe?"border-primary/70 bg-primary/5 shadow-sm":"bg-background/80 hover:border-muted-foreground/40 hover:bg-muted/20"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"break-all font-mono text-[11px] leading-relaxed text-muted-foreground",children:a.task_id}),e.jsx("div",{className:"text-sm font-medium",children:String(a.task_kind??a.mode??"-")})]}),e.jsx(N,{variant:bs(String(a.status??"")),children:rs(String(a.status??""))})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"创建时间"}),e.jsx("span",{children:Sa(a.created_at)})]})]},a.task_id)})})}):e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:"当前没有排队任务"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"最近完成"}),e.jsx(N,{variant:"secondary",children:Ve.length})]}),Ve.length>0?e.jsx(ye,{className:"h-[260px] rounded-xl border bg-muted/10",children:e.jsx("div",{className:"space-y-2.5 p-2.5",children:Ve.map(a=>{const fe=a.task_id===Ye;return e.jsxs("button",{type:"button",onClick:()=>{es(a.task_id)},className:G("w-full rounded-xl border p-4 text-left transition-all",fe?"border-primary/70 bg-primary/5 shadow-sm":"bg-background/80 hover:border-muted-foreground/40 hover:bg-muted/20"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"break-all font-mono text-[11px] leading-relaxed text-muted-foreground",children:a.task_id}),e.jsx("div",{className:"text-sm font-medium",children:String(a.task_kind??a.mode??"-")})]}),e.jsx(N,{variant:bs(String(a.status??"")),children:rs(String(a.status??""))})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"完成进度"}),e.jsx("span",{children:ht(a.progress)})]}),e.jsx(er,{value:jt(a.progress),className:"mt-2 h-1.5"})]},a.task_id)})})}):e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:"暂时没有历史任务"})]})]})]})})]}),e.jsxs(X,{className:"rounded-2xl border-border/70 bg-card/90 shadow-sm",children:[e.jsxs(Y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(se,{children:"任务详情"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(k,{size:"sm",variant:"outline","aria-label":"取消选中导入任务",onClick:()=>{Mr()},disabled:!Ye,children:"取消任务"}),e.jsx(k,{size:"sm","aria-label":"重试选中导入任务",onClick:()=>{Zs()},disabled:!Ye,children:"重试失败项"})]})]}),e.jsx(ee,{children:"支持文件级和分块级状态观察,可直接在当前页面定位失败原因"})]}),e.jsxs(te,{className:"space-y-6",children:[Tr?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ge,{className:"h-4 w-4 animate-spin"}),"正在加载任务详情..."]}):null,V?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"任务摘要"}),e.jsx("div",{className:"overflow-auto rounded-xl border bg-muted/10",children:e.jsx(We,{className:"min-w-[680px]",children:e.jsxs(He,{children:[e.jsxs(D,{children:[e.jsx(b,{className:"w-[140px] text-muted-foreground",children:"任务 ID"}),e.jsx(b,{className:"break-all font-mono text-xs leading-relaxed",children:V.task_id})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"任务类型"}),e.jsx(b,{children:String(V.task_kind??V.mode??"-")})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"状态 / 步骤"}),e.jsx(b,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:bs(String(V.status??"")),children:rs(String(V.status??""))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:pt(String(V.current_step??""))})]})})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"进度"}),e.jsx(b,{children:e.jsx(jc,{value:jt(V.progress),statusLabel:rs(String(V.status??"")),stepLabel:pt(String(V.current_step??"")),tone:String(V.status??"")==="completed"?"success":String(V.status??"")==="failed"?"destructive":String(V.status??"")==="completed_with_errors"?"warning":String(V.status??"")==="cancelled"?"muted":"default",busy:or.has(String(V.status??"")),detail:Tn(V.done_chunks,V.total_chunks,V.failed_chunks,V.cancelled_chunks)})})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"创建时间"}),e.jsx(b,{children:Sa(V.created_at)})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"更新时间"}),e.jsx(b,{children:Sa(V.updated_at)})]})]})})})]}),ss?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"重试摘要"}),e.jsx("div",{className:"overflow-auto rounded-xl border bg-muted/10",children:e.jsx(We,{children:e.jsxs(He,{children:[e.jsxs(D,{children:[e.jsx(b,{className:"w-[220px] text-muted-foreground",children:"按分块重试的文件数"}),e.jsx(b,{children:Number(ss.chunk_retry_files??0)})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"按分块重试的分块数"}),e.jsx(b,{children:Number(ss.chunk_retry_chunks??0)})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"回退整文件重试数"}),e.jsx(b,{children:Number(ss.file_fallback_files??0)})]}),e.jsxs(D,{children:[e.jsx(b,{className:"text-muted-foreground",children:"跳过文件数"}),e.jsx(b,{children:Number(ss.skipped_files??0)})]})]})})})]}):null,ds?e.jsx(ze,{variant:"destructive",children:e.jsx($e,{children:ds})}):null,e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"text-sm font-medium",children:"文件状态"}),Pt.length>0?e.jsx(ye,{className:"h-[260px] rounded-xl border bg-muted/10",children:e.jsx("div",{className:"space-y-2.5 p-2.5",children:Pt.map(a=>{const fe=a.file_id===Xs;return e.jsxs("button",{type:"button",onClick:()=>{Er(a.file_id)},className:G("w-full rounded-xl border p-4 text-left transition-all",fe?"border-primary/70 bg-primary/5 shadow-sm":"bg-background/80 hover:border-muted-foreground/40 hover:bg-muted/20"),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:a.name||a.file_id}),e.jsx(N,{variant:bs(String(a.status??"")),children:rs(String(a.status??""))})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:pt(String(a.current_step??""))}),e.jsx("span",{children:ht(a.progress)})]}),e.jsx(er,{value:jt(a.progress),className:"mt-2 h-1.5"}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[ht(a.progress)," · ",Tn(a.done_chunks,a.total_chunks,a.failed_chunks,a.cancelled_chunks)]}),a.error?e.jsx("div",{className:"mt-2 truncate text-xs text-destructive",children:a.error}):null]},a.file_id)})})}):e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:"当前任务没有文件明细"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"分块状态"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(k,{size:"icon",variant:"outline","aria-label":"上一页分块",onClick:()=>{us(-1)},disabled:!Rr,children:e.jsx($l,{className:"h-4 w-4"})}),e.jsxs("span",{children:[ts>0?`${Mt+1}-${Math.min(Mt+ft,ts)}`:"0-0"," / ",ts]}),e.jsx(k,{size:"icon",variant:"outline","aria-label":"下一页分块",onClick:()=>{us(1)},disabled:!Ys,children:e.jsx(ql,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"overflow-auto rounded-xl border bg-background/80",children:e.jsxs(We,{className:"min-w-[700px]",children:[e.jsx(_s,{children:e.jsxs(D,{children:[e.jsx(Z,{className:"w-[72px]",children:"序号"}),e.jsx(Z,{className:"w-[108px]",children:"状态"}),e.jsx(Z,{className:"w-[108px]",children:"步骤"}),e.jsx(Z,{className:"w-[84px]",children:"进度"}),e.jsx(Z,{children:"错误 / 预览"})]})}),e.jsx(He,{children:Or?e.jsx(D,{children:e.jsx(b,{colSpan:5,className:"text-center text-muted-foreground",children:"正在加载分块详情..."})}):ms.length>0?ms.map(a=>e.jsxs(D,{children:[e.jsx(b,{children:a.index}),e.jsx(b,{children:rs(String(a.status??""))}),e.jsx(b,{children:pt(String(a.step??""))}),e.jsx(b,{children:ht(a.progress)}),e.jsx(b,{className:"max-w-[360px]",children:e.jsxs("div",{className:"space-y-2",children:[String(a.error??"").trim()?e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-sm leading-relaxed text-destructive",children:String(a.error)}):null,e.jsxs("details",{className:"rounded-md border bg-muted/20 px-2.5 py-2 text-xs text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer font-medium text-foreground",children:String(a.error??"").trim()?"查看分块预览":"查看内容详情"}),e.jsx("div",{className:"mt-2 whitespace-pre-wrap break-words leading-relaxed",children:String(a.content_preview??"-")||"-"})]})]})})]},a.chunk_id)):e.jsx(D,{children:e.jsx(b,{colSpan:5,className:"text-center text-muted-foreground",children:"当前页没有分块数据"})})})]})})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed bg-muted/15 px-6 py-10 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted/40 p-3",children:e.jsx(Ge,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"还没选中任务"}),e.jsxs("div",{className:"text-xs leading-relaxed text-muted-foreground",children:["在左侧/上方的导入队列里点击任意任务卡片",e.jsx("br",{}),"即可在这里查看进度、文件状态和分块详情"]})]})]})]})]})]})}function bc(s){const{tuningObjective:i,setTuningObjective:l,tuningIntensity:d,setTuningIntensity:_,tuningSampleSize:g,setTuningSampleSize:y,tuningTopKEval:S,setTuningTopKEval:z,submitTuningTask:I,creatingTuning:$,tuningProfile:O,tuningProfileToml:H,tuningTasks:w,applyBestTask:re}=s;return e.jsx(xe,{value:"tuning",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[0.95fr_1.05fr]",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Oa,{className:"h-4 w-4"}),"调优任务"]}),e.jsx(ee,{children:"创建一次检索参数评估任务,完成后可在右侧列表中查看并应用最佳结果。"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"调优策略"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"先选择优化方向和搜索强度。默认的 balanced / standard 适合大多数情况。"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"优化目标"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"决定本次调优更偏向准确率、召回率,还是两者平衡。"}),e.jsxs(Ee,{value:i,onValueChange:l,children:[e.jsx(Re,{children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"precision_priority",children:"precision_priority"}),e.jsx(C,{value:"balanced",children:"balanced"}),e.jsx(C,{value:"recall_priority",children:"recall_priority"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"评估强度"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"强度越高,评估更充分,但任务耗时也更长。"}),e.jsxs(Ee,{value:d,onValueChange:_,children:[e.jsx(Re,{children:e.jsx(Oe,{})}),e.jsxs(Fe,{children:[e.jsx(C,{value:"quick",children:"quick"}),e.jsx(C,{value:"standard",children:"standard"}),e.jsx(C,{value:"deep",children:"deep"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"评估范围"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"控制本次任务使用多少样本,以及每次检索评估多少候选结果。"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"样本量"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"用于评估的样本数量。数量越大,结果越稳定。"}),e.jsx(p,{type:"number",value:g,onChange:v=>y(v.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"评估 Top-K"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"每次检索时用于评估的候选结果数量。"}),e.jsx(p,{type:"number",value:S,onChange:v=>z(v.target.value)})]})]})]}),e.jsxs(k,{onClick:()=>{I()},disabled:$,children:[e.jsx(Oa,{className:"mr-2 h-4 w-4"}),"创建调优任务"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(se,{children:"当前调优配置快照"}),e.jsx(ee,{children:"展示当前生效的检索调优参数,便于在应用新结果前做对照。"})]}),e.jsxs(te,{className:"space-y-3",children:[e.jsx(Pa,{value:JSON.stringify(O,null,2),language:"json",readOnly:!0,height:"220px"}),e.jsx(Pa,{value:H,language:"toml",readOnly:!0,height:"180px"})]})]}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(se,{children:"最近调优任务"}),e.jsx(ee,{children:"任务完成后,可以把最佳结果应用到当前调优配置。"})]}),e.jsx(te,{className:"space-y-3",children:e.jsxs(We,{children:[e.jsx(_s,{children:e.jsxs(D,{children:[e.jsx(Z,{children:"任务"}),e.jsx(Z,{children:"状态"}),e.jsx(Z,{children:"动作"})]})}),e.jsx(He,{children:w.length>0?w.map(v=>e.jsxs(D,{children:[e.jsx(b,{className:"font-mono text-xs",children:String(v.task_id??"-")}),e.jsx(b,{children:e.jsx(N,{variant:bs(String(v.status??"")),children:String(v.status??"-")})}),e.jsx(b,{children:e.jsx(k,{size:"sm",variant:"outline",onClick:()=>{re(String(v.task_id??""))},disabled:!v.task_id,children:"应用最佳"})})]},String(v.task_id??Math.random()))):e.jsx(D,{children:e.jsx(b,{colSpan:3,className:"text-center text-muted-foreground",children:"还没有调优任务。可以先使用默认参数创建一次评估任务。"})})})]})})]})]})]})})}function Bc(){const{toast:s}=dr(),[i,l]=t.useState(!0),[d,_]=t.useState(!1),[g,y]=t.useState(!1),[S,z]=t.useState(!1),[I,$]=t.useState("overview"),[O,H]=t.useState(()=>new Set),[w,re]=t.useState(null),[v,oe]=t.useState(null),[F,ne]=t.useState({}),[q,L]=t.useState({}),[x,U]=t.useState([]),[m,P]=t.useState(""),[K,ie]=t.useState(null),[de,he]=t.useState(!1),[h,le]=t.useState(""),[W,Q]=t.useState(0),[ce,A]=t.useState(null),[ke,f]=t.useState(!1),[J,ue]=t.useState("upload"),[ae,Qe]=t.useState(!0),[j,M]=t.useState(""),[pe,De]=t.useState("2"),[be,B]=t.useState("4"),[Ne,Ue]=t.useState(!0),[_e,Se]=t.useState("auto"),[we,Ss]=t.useState("content_hash"),[Ze,c]=t.useState(!1),[E,Xe]=t.useState(""),[ws,ur]=t.useState(!1),[Cs,mr]=t.useState(!1),[Is,xr]=t.useState("text"),[as,vt]=t.useState([]),[Ps,bt]=t.useState(""),[Ms,hr]=t.useState("text"),[ns,Nt]=t.useState(""),[Ts,yt]=t.useState("raw"),[Es,pr]=t.useState(""),[Rs,gr]=t.useState("*"),[Os,fr]=t.useState("text"),[Fs,jr]=t.useState(!0),[Ds,kt]=t.useState("lpmm"),[Ls,vr]=t.useState(""),[As,br]=t.useState(!1),[Bs,_t]=t.useState("lpmm"),[zs,Nr]=t.useState(""),[$s,St]=t.useState("plugin_data"),[qs,yr]=t.useState(""),[Js,kr]=t.useState(""),[Us,_r]=t.useState("1024"),[Ks,wt]=t.useState("plugin_data"),[is,Ct]=t.useState(""),[Vs,It]=t.useState("100000"),[Gs,Sr]=t.useState(!1),[Ws,wr]=t.useState(!1),[qe,ls]=t.useState(""),[Hs,Cr]=t.useState(""),[Ke,cs]=t.useState(""),[Ve,Ye]=t.useState(""),[es,Ir]=t.useState(""),[Qs,Pr]=t.useState(""),[os,Mr]=t.useState(""),[Zs,Tr]=t.useState(""),[V,ss]=t.useState("2000"),[ds,Pt]=t.useState("20000"),[Xs,Er]=t.useState(""),[ts,Mt]=t.useState(!1),[us,Rr]=t.useState(!1),[Ys,Or]=t.useState(!1),[ms,a]=t.useState(!1),[fe,Fr]=t.useState("raw"),[Dr,Ln]=t.useState(""),[Lr,An]=t.useState(!0),[Bn,La]=t.useState(""),[zn,Aa]=t.useState(!1),[$n,Ar]=t.useState([]),[Ba,za]=t.useState({}),[qn,$a]=t.useState(""),[Br,Tt]=t.useState([]),[zr,$r]=t.useState([]),[qr,et]=t.useState(null),[Jn,qa]=t.useState(!1),[Un,st]=t.useState(""),[Jr,Kn]=t.useState(""),[Et,Vn]=t.useState(""),[tt,Gn]=t.useState("all"),[rt,Wn]=t.useState("all"),[at,Ur]=t.useState(1),[xs,Kr]=t.useState(""),[Rt,Hn]=t.useState(""),[nt,Vr]=t.useState(1),[Ot,Gr]=t.useState([]),[Qn,Ft]=t.useState(!1),[Zn,Xn]=t.useState("删除预览"),[Yn,ei]=t.useState(""),[si,Wr]=t.useState(null),[ti,Dt]=t.useState(null),[ri,Ja]=t.useState(!1),[ai,Ua]=t.useState(!1),[Ka,Va]=t.useState(!1),[Hr,Qr]=t.useState(null),[Zr,Ga]=t.useState(null),[Xr,Wa]=t.useState([]),[Lt,ni]=t.useState(""),[it,ii]=t.useState("all"),[lt,li]=t.useState("all"),[ct,Yr]=t.useState(1),[hs,ea]=t.useState(0),[At,ps]=t.useState(null),[ci,Ha]=t.useState(!1),[oi,ot]=t.useState(""),[Bt,di]=t.useState(""),[dt,sa]=t.useState(1),[ui,zt]=t.useState(!1),[ta,Qa]=t.useState(""),[$t,Za]=t.useState(!1),[ra,mi]=t.useState("precision_priority"),[aa,xi]=t.useState("standard"),[na,hi]=t.useState("24"),[ia,pi]=t.useState("20"),ut=t.useCallback(async()=>{try{l(!0);const[r,n,o,T,R,ve,Te,pa,ga]=await Promise.all([Ht(),un(),mn(),xn(20),hn(),fa(20),Qt(),ja(ya),pn({limit:Cn})]);if(re(r),ne(n.settings??{}),L(o.path_aliases??{}),U(T.items??[]),za(R.profile??{}),$a(R.toml??""),Ar(ve.items??[]),Tt(Te.items??[]),$r(pa.items??[]),Wa(ga.items??[]),!m&&(T.items??[]).length>0){const xt=String(T.items?.[0]?.task_id??"");xt&&P(xt)}if(!qe&&String(n.settings?.maibot_source_db_default??"").trim()&&ls(String(n.settings?.maibot_source_db_default??"").trim()),!fe){const xt=Object.keys(o.path_aliases??{});xt.length>0&&Fr(xt[0])}}catch(r){s({title:"加载长期记忆控制台失败",description:r instanceof Error?r.message:"未知错误",variant:"destructive"})}finally{l(!1)}},[qe,fe,m,s]);t.useEffect(()=>{ut()},[ut]),t.useEffect(()=>{["episodes","profiles","maintenance"].includes(I)&&H(r=>{if(r.has(I))return r;const n=new Set(r);return n.add(I),n})},[I]);const Xa=t.useMemo(()=>w?[{label:"运行状态",value:w.runtime_ready?"就绪":"未就绪",description:w.embedding_degraded?"Embedding 降级运行":"运行时检查通过",icon:w.runtime_ready?jn:Ea,className:w.runtime_ready?"border-emerald-500/20 bg-emerald-500/5":"border-amber-500/20 bg-amber-500/5",iconClassName:w.runtime_ready?"text-emerald-500":"text-amber-500"},{label:"Embedding 维度",value:String(w.embedding_dimension),description:w.relation_vectors_enabled?"关系向量已启用":"关系向量未启用",icon:Jl,className:"border-sky-500/20 bg-sky-500/5",iconClassName:"text-sky-500"},{label:"自动保存",value:w.auto_save?"开启":"关闭",description:w.auto_save?"运行数据会自动落盘":"请留意手动保存",icon:w.auto_save?jn:Ea,className:w.auto_save?"border-primary/20 bg-primary/5":"border-muted-foreground/20 bg-muted/30",iconClassName:w.auto_save?"text-primary":"text-muted-foreground"},{label:"数据目录",value:w.data_dir,description:"长期记忆存储位置",icon:Ul,className:"border-violet-500/20 bg-violet-500/5",iconClassName:"text-violet-500"}]:[],[w]),la=t.useMemo(()=>Math.max(200,Number(F.poll_interval_ms??1e3)),[F.poll_interval_ms]),gs=t.useMemo(()=>Object.keys(q).sort((r,n)=>r.localeCompare(n)),[q]),gi=t.useMemo(()=>x.filter(r=>or.has(String(r.status??"").trim())),[x]),fi=t.useMemo(()=>x.filter(r=>Fa.has(String(r.status??"").trim())),[x]),ji=t.useMemo(()=>x.filter(r=>{const n=String(r.status??"").trim();return!or.has(n)&&!Fa.has(n)}),[x]),vi=t.useMemo(()=>m?x.find(r=>r.task_id===m)??null:null,[x,m]),bi=t.useMemo(()=>Array.isArray(K?.files)?K.files:[],[K?.files]),Ni=t.useMemo(()=>Array.isArray(ce?.items)?ce.items:[],[ce?.items]),ca=K??vi,yi=String(ca?.error??"").trim(),ki=ca?.retry_summary,Ya=Number(ce?.total??0),_i=W>0,Si=W+ft<Ya,Le=t.useCallback(()=>{const r={llm_enabled:Ne,strategy_override:_e,dedupe_policy:we,chat_log:Ze,force:ws,clear_manifest:Cs},n=Ae(pe),o=Ae(be);return n!==void 0&&(r.file_concurrency=n),o!==void 0&&(r.chunk_concurrency=o),E.trim()&&(r.chat_reference_time=E.trim()),r},[Ze,E,be,Cs,we,pe,ws,Ne,_e]),Pe=t.useCallback(async(r=!1)=>{try{const[n,o,T]=await Promise.all([xn(20),un(),mn()]),R=n.items??[];if(U(R),ne(o.settings??{}),L(T.path_aliases??{}),M(""),R.length<=0){P(""),ie(null),le(""),A(null);return}(!m||!R.some(ve=>ve.task_id===m))&&P(R[0].task_id)}catch(n){const o=n instanceof Error?n.message:"刷新导入任务失败";M(o),r||s({title:"刷新导入任务失败",description:o,variant:"destructive"})}},[m,s]),fs=t.useCallback(async(r,n,o=0,T=!1)=>{if(!r||!n){A(null);return}try{f(!0);const R=await ll(r,n,o,ft);if(!R.success)throw new Error(R.error||"加载分块详情失败");A(R),M("")}catch(R){const ve=R instanceof Error?R.message:"加载分块详情失败";A(null),M(ve),T||s({title:"加载分块详情失败",description:ve,variant:"destructive"})}finally{f(!1)}},[s]),ge=t.useCallback(async(r,n=!1)=>{if(!r){ie(null),le(""),A(null);return}try{n||he(!0);const o=await cl(r,!1);if(!o.success||!o.task)throw new Error(o.error||"任务不存在");const T=o.task;ie(T),M("");const R=Array.isArray(T.files)?T.files:[],ve=R.some(ga=>ga.file_id===h),Te=ve?h:String(R[0]?.file_id??""),pa=ve?W:0;ve||Q(0),le(Te),Te?await fs(r,Te,pa,n):A(null)}catch(o){const T=o instanceof Error?o.message:"加载导入任务详情失败";ie(null),le(""),A(null),M(T),n||s({title:"加载导入任务详情失败",description:T,variant:"destructive"})}finally{n||he(!1)}},[W,fs,h,s]),je=t.useCallback(async(r,n)=>{await Pe(!0),r&&(P(r),await ge(r,!0)),s({title:n,description:r?`任务 ${r.slice(0,12)} 已加入导入队列`:"导入任务已加入队列"})},[ge,Pe,s]),en=t.useCallback(async()=>{if(as.length<=0){s({title:"请选择上传文件",description:"至少选择一个 txt/md/json 文件后再提交",variant:"destructive"});return}try{y(!0);const r={...Le(),input_mode:Is},n=await ol(as,r);if(!n.success)throw new Error(n.error||"创建上传导入任务失败");const o=String(n.task?.task_id??"");vt([]),await je(o,"上传导入任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建上传导入任务失败";M(n),s({title:"创建上传导入任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Le,s,as,Is]),sn=t.useCallback(async()=>{if(!ns.trim()){s({title:"粘贴内容不能为空",description:"请填写导入内容后再提交",variant:"destructive"});return}try{y(!0);const r=await dl({...Le(),name:Ps||void 0,content:ns,input_mode:Ms});if(!r.success)throw new Error(r.error||"创建粘贴导入任务失败");const n=String(r.task?.task_id??"");Nt(""),bt(""),await je(n,"粘贴导入任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建粘贴导入任务失败";M(n),s({title:"创建粘贴导入任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Le,ns,Ms,Ps,s]),tn=t.useCallback(async()=>{try{y(!0);const r=await ul({...Le(),alias:Ts,relative_path:Es,glob:Rs,recursive:Fs,input_mode:Os});if(!r.success)throw new Error(r.error||"创建本地扫描任务失败");await je(String(r.task?.task_id??""),"本地扫描任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建本地扫描任务失败";M(n),s({title:"创建本地扫描任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Le,Ts,Rs,Os,Fs,Es,s]),rn=t.useCallback(async()=>{try{y(!0);const r=await ml({...Le(),alias:Ds,relative_path:Ls,include_all_json:As});if(!r.success)throw new Error(r.error||"创建 LPMM OpenIE 任务失败");await je(String(r.task?.task_id??""),"LPMM OpenIE 任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建 LPMM OpenIE 任务失败";M(n),s({title:"创建 LPMM OpenIE 任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Le,Ds,As,Ls,s]),an=t.useCallback(async()=>{try{y(!0);const r=await xl({alias:Bs,relative_path:zs,target_alias:$s,target_relative_path:qs,dimension:Ae(Js),batch_size:Ae(Us)});if(!r.success)throw new Error(r.error||"创建 LPMM 转换任务失败");await je(String(r.task?.task_id??""),"LPMM 转换任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建 LPMM 转换任务失败";M(n),s({title:"创建 LPMM 转换任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Bs,Us,Js,zs,$s,qs,s]),nn=t.useCallback(async()=>{try{y(!0);const r=await hl({alias:Ks,relative_path:is,limit:Ae(Vs),dry_run:Gs,no_created_fallback:Ws});if(!r.success)throw new Error(r.error||"创建时序回填任务失败");await je(String(r.task?.task_id??""),"时序回填任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建时序回填任务失败";M(n),s({title:"创建时序回填任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,Ks,Gs,Vs,Ws,is,s]),ln=t.useCallback(async()=>{try{y(!0);const r=await pl({source_db:qe||void 0,time_from:Hs||void 0,time_to:Ke||void 0,start_id:Ae(Ve),end_id:Ae(es),stream_ids:ka(Qs),group_ids:ka(os),user_ids:ka(Zs),read_batch_size:Ae(V),commit_window_rows:Ae(ds),embed_workers:Ae(Xs),no_resume:ts,reset_state:us,dry_run:Ys,verify_only:ms});if(!r.success)throw new Error(r.error||"创建 MaiBot 迁移任务失败");await je(String(r.task?.task_id??""),"MaiBot 迁移任务已创建")}catch(r){const n=r instanceof Error?r.message:"创建 MaiBot 迁移任务失败";M(n),s({title:"创建 MaiBot 迁移任务失败",description:n,variant:"destructive"})}finally{y(!1)}},[je,ds,Ys,Xs,es,os,ts,V,us,qe,Ve,Qs,Hs,Ke,Zs,ms,s]),wi=t.useCallback(async()=>{if(m)try{const r=await gl(m);if(!r.success)throw new Error(r.error||"取消导入任务失败");await Pe(!0),await ge(m,!0),s({title:"已请求取消任务",description:`任务 ${m.slice(0,12)} 正在取消`})}catch(r){const n=r instanceof Error?r.message:"取消导入任务失败";M(n),s({title:"取消导入任务失败",description:n,variant:"destructive"})}},[ge,Pe,m,s]),Ci=t.useCallback(async()=>{if(m)try{const r=await fl(m,{overrides:Le()});if(!r.success)throw new Error(r.error||"重试失败项失败");const n=String(r.task?.task_id??"");await Pe(!0),n?(P(n),await ge(n,!0)):await ge(m,!0),s({title:"重试任务已创建",description:n?`重试任务 ${n.slice(0,12)} 已进入队列`:"失败项已提交重试"})}catch(r){const n=r instanceof Error?r.message:"重试失败项失败";M(n),s({title:"重试失败项失败",description:n,variant:"destructive"})}},[Le,ge,Pe,m,s]),Ii=t.useCallback(async()=>{if(fe.trim())try{Aa(!0);const r=await jl({alias:fe,relative_path:Dr,must_exist:Lr}),n=[`路径别名: ${r.alias}`,`相对路径: ${r.relative_path||"(空)"}`,`解析结果: ${r.resolved_path}`,`是否存在: ${String(r.exists)}`,`是否文件: ${String(r.is_file)}`,`是否目录: ${String(r.is_dir)}`];La(n.join(`
`))}catch(r){const n=r instanceof Error?r.message:"路径解析失败";La(`解析失败:${n}`)}finally{Aa(!1)}},[fe,Lr,Dr]),mt=t.useCallback(async r=>{P(r),Q(0),await ge(r)},[ge]),Pi=t.useCallback(async r=>{m&&(le(r),Q(0),await fs(m,r,0))},[fs,m]),Mi=t.useCallback(async r=>{if(!m||!h)return;const n=r<0?Math.max(0,W-ft):W+ft;n!==W&&(Q(n),await fs(m,h,n))},[W,fs,h,m]);t.useEffect(()=>{if(gs.length<=0)return;const r=(n,o)=>n&&gs.includes(n)?n:gs.includes(o)?o:gs[0];yt(n=>r(n,"raw")),kt(n=>r(n,"lpmm")),_t(n=>r(n,"lpmm")),St(n=>r(n,"plugin_data")),wt(n=>r(n,"plugin_data")),Fr(n=>r(n,"raw"))},[gs]),t.useEffect(()=>{const r=String(F.default_file_concurrency??"").trim(),n=String(F.default_chunk_concurrency??"").trim();r&&pe==="2"&&De(r),n&&be==="4"&&B(n);const o=String(F.maibot_source_db_default??"").trim();o&&!qe.trim()&&ls(o)},[be,pe,F.default_chunk_concurrency,F.default_file_concurrency,F.maibot_source_db_default,qe]),t.useEffect(()=>{!m&&x.length>0&&mt(x[0].task_id)},[x,mt,m]),t.useEffect(()=>{if(!m){ie(null),le(""),A(null);return}if(!x.some(r=>r.task_id===m)&&x.length>0){mt(x[0].task_id);return}ge(m,!0)},[x,ge,mt,m]),t.useEffect(()=>{if(!ae)return;const r=window.setInterval(()=>{Pe(!0),m&&ge(m,!0)},la);return()=>{window.clearInterval(r)}},[ae,la,ge,Pe,m]);const oa=t.useRef("");t.useEffect(()=>{oa.current=m},[m]),t.useEffect(()=>{let r=!1,n;const o=T=>{T.topic==="import_progress"&&(Pe(!0),oa.current&&ge(oa.current,!0))};return ac.subscribe(o,["import_progress"]).then(T=>{if(r){T();return}n=T}).catch(T=>{console.warn("订阅长期记忆 WebSocket 失败,已退化到轮询兜底",T)}),()=>{r=!0,n&&n()}},[ge,Pe]);const Ti=t.useMemo(()=>{const r=Jr.trim().toLowerCase();return r?Br.filter(n=>String(n.source??"").toLowerCase().includes(r)):Br},[Br,Jr]),js=t.useMemo(()=>{const r=Et.trim().toLowerCase();return zr.filter(n=>{const o=String(n.mode??"").trim(),T=String(n.status??"").trim(),R=n.summary??{},ve=Array.isArray(R.sources)?R.sources:[];return tt!=="all"&&o!==tt||rt!=="all"&&T!==rt?!1:r?[n.operation_id,n.reason,n.requested_by,o,T,...ve.map(Te=>String(Te))].map(Te=>String(Te??"").toLowerCase()).some(Te=>Te.includes(r)):!0})},[zr,tt,Et,rt]),qt=Math.max(1,Math.ceil(js.length/sr)),da=t.useMemo(()=>{const r=(at-1)*sr;return js.slice(r,r+sr)},[js,at]),Ce=t.useMemo(()=>js.find(r=>r.operation_id===xs)??da[0]??null,[js,da,xs]);t.useEffect(()=>{Ur(1)},[Et,tt,rt]),t.useEffect(()=>{at>qt&&Ur(qt)},[qt,at]),t.useEffect(()=>{if(!Ce){xs&&Kr(""),et(null),st("");return}Ce.operation_id!==xs&&Kr(Ce.operation_id)},[Ce,xs]),t.useEffect(()=>{const r=Ce?.operation_id;if(!r){et(null),st("");return}let n=!1;return qa(!0),st(""),vl(r).then(o=>{if(!n){if(!o.success||!o.operation){et(null),st(o.error||"未能加载删除操作详情");return}et(o.operation)}}).catch(o=>{n||(et(null),st(o instanceof Error?o.message:"未能加载删除操作详情"))}).finally(()=>{n||qa(!1)}),()=>{n=!0}},[Ce?.operation_id]);const Ei=t.useCallback((r,n)=>{Gr(o=>n?o.includes(r)?o:[...o,r]:o.filter(T=>T!==r))},[]),Ri=t.useCallback(async()=>{if(Ot.length<=0){s({title:"请选择来源",description:"至少选择一个来源后再进行删除预览",variant:"destructive"});return}const r={mode:"source",selector:{sources:Ot},reason:"knowledge_base_source_delete",requested_by:"knowledge_base"};Xn("批量删除来源"),ei("删除来源只会删除该来源下的段落,以及失去全部证据的关系,不会自动删除实体"),Ga(r),Wr(null),Qr(null),Dt(null),Ft(!0),Ja(!0);try{const n=await bl(r);Wr(n)}catch(n){Dt(n instanceof Error?n.message:"删除预览失败")}finally{Ja(!1)}},[Ot,s]),Oi=t.useCallback(async()=>{if(Zr)try{Ua(!0);const r=await Nl(Zr);if(Qr(r),s({title:r.success?"删除成功":"删除失败",description:r.success?`操作 ${r.operation_id} 已完成`:r.error||"未能执行删除",variant:r.success?"default":"destructive"}),r.success){const[n,o]=await Promise.all([Qt(),ja(ya)]);Tt(n.items??[]),$r(o.items??[]),Gr([])}}catch(r){Dt(r instanceof Error?r.message:"删除失败"),s({title:"删除失败",description:r instanceof Error?r.message:"未知错误",variant:"destructive"})}finally{Ua(!1)}},[Zr,s]),cn=t.useCallback(async r=>{try{Va(!0),await yl({operation_id:r,requested_by:"knowledge_base"}),s({title:"恢复成功",description:`删除操作 ${r} 已恢复`}),Ft(!1);const[n,o]=await Promise.all([Qt(),ja(ya)]);Tt(n.items??[]),$r(o.items??[])}catch(n){s({title:"恢复失败",description:n instanceof Error?n.message:"未知错误",variant:"destructive"})}finally{Va(!1)}},[s]),Fi=t.useCallback(r=>{if(!r){Ft(!1),Wr(null),Qr(null),Dt(null),Ga(null);return}Ft(!0)},[]),vs=t.useMemo(()=>{const r=Lt.trim().toLowerCase();return Xr.filter(n=>{const o=String(n.task_status??"").trim().toLowerCase(),T=String(n.rollback_status??"").trim().toLowerCase();return it!=="all"&&o!==it||lt!=="all"&&T!==lt?!1:r?[n.query_tool_id,n.session_id,n.query_text,n.decision,n.task_status,n.rollback_status].map(R=>String(R??"").toLowerCase()).some(R=>R.includes(r)):!0})},[Xr,lt,Lt,it]),Jt=Math.max(1,Math.ceil(vs.length/rr)),ua=t.useMemo(()=>{const r=(ct-1)*rr;return vs.slice(r,r+rr)},[ct,vs]),Ie=t.useMemo(()=>vs.find(r=>r.task_id===hs)??ua[0]??null,[vs,ua,hs]);t.useEffect(()=>{Yr(1)},[Lt,it,lt]),t.useEffect(()=>{ct>Jt&&Yr(Jt)},[ct,Jt]),t.useEffect(()=>{if(!Ie){hs&&ea(0),ps(null),ot("");return}Ie.task_id!==hs&&ea(Ie.task_id)},[Ie,hs]),t.useEffect(()=>{const r=Ie?.task_id;if(!r){ps(null),ot("");return}let n=!1;return Ha(!0),ot(""),gn(r).then(o=>{if(!n){if(!o.success||!o.task){ps(null),ot(o.error||"未能加载纠错任务详情");return}ps(o.task)}}).catch(o=>{n||(ps(null),ot(o instanceof Error?o.message:"未能加载纠错任务详情"))}).finally(()=>{n||Ha(!1)}),()=>{n=!0}},[Ie?.task_id]);const Me=t.useMemo(()=>Ie?At?.task_id===Ie.task_id?{...Ie,...At}:At??Ie:null,[Ie,At]),Di=t.useMemo(()=>Fn(Me),[Me]),Li=t.useMemo(()=>Dn(Me),[Me]),Ut=Array.isArray(Me?.action_logs)?Me.action_logs:[],ma=t.useMemo(()=>{const r=Bt.trim().toLowerCase();return r?Ut.filter(n=>[n.action_type,n.target_hash,n.reason,ks(n.before_payload),ks(n.after_payload)].map(o=>String(o??"").toLowerCase()).some(o=>o.includes(r))):Ut},[Bt,Ut]),Kt=Math.max(1,Math.ceil(ma.length/ar)),Ai=t.useMemo(()=>{const r=(dt-1)*ar;return ma.slice(r,r+ar)},[dt,ma]);t.useEffect(()=>{sa(1)},[hs,Bt]),t.useEffect(()=>{dt>Kt&&sa(Kt)},[dt,Kt]);const Bi=t.useCallback(()=>{Qa(""),zt(!0)},[]),zi=t.useCallback(async()=>{const r=Me?.task_id;if(r)try{Za(!0);const n=await kl(r,{requested_by:"knowledge_base",reason:ta.trim()});if(!n.success)throw new Error(n.error||"回退失败");s({title:n.already_rolled_back?"该纠错已回退":"纠错回退成功",description:`任务 ${r} 的回退结果已写入日志`}),zt(!1);const[o,T]=await Promise.all([pn({limit:Cn}),gn(r)]);Wa(o.items??[]),ps(T.task??null);const[R,ve]=await Promise.all([Qt(),Ht()]);Tt(R.items??[]),re(ve)}catch(n){s({title:"纠错回退失败",description:n instanceof Error?n.message:"未知错误",variant:"destructive"})}finally{Za(!1)}},[ta,Me?.task_id,s]),xa=t.useMemo(()=>Ce?qr?.operation_id===Ce.operation_id?{...Ce,...qr}:Ce:null,[Ce,qr]),ha=xa?.summary??{},$i=ha.counts??{},qi=Array.isArray(ha.sources)?ha.sources.map(r=>String(r)).filter(Boolean):[],Vt=Array.isArray(xa?.items)?xa.items:[],Gt=t.useMemo(()=>{const r=Rt.trim().toLowerCase();return r?Vt.filter(n=>{const o=n.payload??{},T=String(o.source??"").trim();return[n.item_type,n.item_hash,n.item_key,T].map(R=>String(R??"").toLowerCase()).some(R=>R.includes(r))}):Vt},[Rt,Vt]),Wt=Math.max(1,Math.ceil(Gt.length/tr)),Ji=t.useMemo(()=>{const r=(nt-1)*tr;return Gt.slice(r,r+tr)},[Gt,nt]);t.useEffect(()=>{Vr(1)},[xs,Rt]),t.useEffect(()=>{nt>Wt&&Vr(Wt)},[nt,Wt]);const on=t.useCallback(async()=>{try{_(!0);const r=await _l();oe(r.report??null);const n=await Ht();re(n),s({title:r.success?"自检通过":"自检未通过",description:r.success?"运行时状态正常":"请检查 embedding 配置和外部服务连通性",variant:r.success?"default":"destructive"})}catch(r){s({title:"运行时自检失败",description:r instanceof Error?r.message:"未知错误",variant:"destructive"})}finally{_(!1)}},[s]),Ui=t.useCallback(async()=>{if(!g)switch(J){case"upload":await en();break;case"paste":await sn();break;case"raw_scan":await tn();break;case"lpmm_openie":await rn();break;case"lpmm_convert":await an();break;case"temporal_backfill":await nn();break;case"maibot_migration":await ln();break}},[g,J,nn,an,ln,rn,sn,tn,en]),Ki=t.useCallback(async()=>{try{z(!0),await Sl({objective:ra,intensity:aa,sample_size:Number(na),top_k_eval:Number(ia)});const r=await fa(20);Ar(r.items??[]),s({title:"调优任务已创建",description:"新的检索调优任务已经进入队列"})}catch(r){s({title:"创建调优任务失败",description:r instanceof Error?r.message:"未知错误",variant:"destructive"})}finally{z(!1)}},[s,aa,ra,na,ia]),Vi=t.useCallback(async r=>{try{await wl(r);const[n,o,T]=await Promise.all([hn(),Ht(),fa(20)]);za(n.profile??{}),$a(n.toml??""),re(o),Ar(T.items??[]),s({title:"最佳参数已应用",description:`任务 ${r} 的最佳轮次已经写入运行时`})}catch(n){s({title:"应用最佳参数失败",description:n instanceof Error?n.message:"未知错误",variant:"destructive"})}},[s]);return i?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"rounded-xl border bg-background px-6 py-5 text-sm text-muted-foreground shadow-sm",children:"正在加载长期记忆控制台..."})}):e.jsxs("div",{className:"flex h-full flex-col bg-gradient-to-b from-background via-background to-muted/15",children:[e.jsx("div",{className:"flex-none border-b bg-card/70 px-6 py-4 backdrop-blur",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-primary/80",children:"A_Memorix"}),e.jsx("h1",{className:"mt-1 text-2xl font-bold leading-tight",children:"长期记忆控制台"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"在这里完成自检、导入资料和检索调优——一站式管理记忆库"})]}),e.jsxs("div",{className:"hidden",children:[e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>$("graph"),children:[e.jsx(vn,{className:"mr-2 h-4 w-4"}),"打开图谱"]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{ut()},children:[e.jsx(Be,{className:"mr-2 h-4 w-4"}),"刷新数据"]})]})]})}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1800px] flex-col gap-6 px-6 py-6",children:[e.jsx("div",{className:"hidden",children:e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{ut()},children:[e.jsx(Be,{className:"mr-2 h-4 w-4"}),"刷新数据"]})}),Xa.length>0?e.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/60 p-4 shadow-sm backdrop-blur",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs("div",{className:"mr-auto flex items-center gap-2 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[e.jsx(bn,{className:"h-3.5 w-3.5"}),"运行时状态"]}),e.jsxs(k,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{ut()},children:[e.jsx(Be,{className:"mr-1.5 h-3 w-3"}),"刷新数据"]}),e.jsxs(k,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{on()},disabled:d,children:[e.jsx(Be,{className:G("mr-1.5 h-3 w-3",d&&"animate-spin")}),"自检"]})]}),e.jsx("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:Xa.map(r=>e.jsxs("div",{className:G("flex items-center gap-3 rounded-xl border px-3 py-2.5 transition-colors",r.className),children:[e.jsx("div",{className:"flex-none rounded-lg border bg-background/70 p-1.5 shadow-sm",children:e.jsx(r.icon,{className:G("h-4 w-4",r.iconClassName)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground",children:r.label}),e.jsx("div",{className:"truncate text-sm font-semibold leading-snug",title:r.value,children:r.value}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:r.description})]})]},r.label))})]}):null,e.jsx("div",{className:"overflow-hidden rounded-2xl border border-primary/20 bg-gradient-to-br from-primary/10 via-primary/5 to-transparent p-5 shadow-sm",children:e.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5 lg:max-w-sm",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-primary",children:"快速开始"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:"先从这三件事入手"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"不知道该做什么?挑一个最常用的入口,下面的标签页里有更详细的设置。"})]}),e.jsxs("div",{className:"grid w-full gap-2.5 sm:grid-cols-3 lg:max-w-3xl",children:[e.jsxs("button",{type:"button",onClick:()=>$("import"),className:"group flex items-start gap-3 rounded-xl border border-border/70 bg-background/80 p-3.5 text-left transition hover:border-primary/50 hover:bg-background hover:shadow-md",children:[e.jsx("div",{className:"flex-none rounded-lg bg-primary/10 p-2 text-primary transition-transform group-hover:scale-105",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold",children:"导入资料"}),e.jsx("div",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"把文件、聊天记录写进记忆库"})]})]}),e.jsxs("button",{type:"button",onClick:()=>$("tuning"),className:"group flex items-start gap-3 rounded-xl border border-border/70 bg-background/80 p-3.5 text-left transition hover:border-primary/50 hover:bg-background hover:shadow-md",children:[e.jsx("div",{className:"flex-none rounded-lg bg-amber-500/10 p-2 text-amber-500 transition-transform group-hover:scale-105",children:e.jsx(Kl,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold",children:"检索调优"}),e.jsx("div",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"让回忆变得更准、更聪明"})]})]}),e.jsxs("button",{type:"button",onClick:()=>$("graph"),className:"group flex items-start gap-3 rounded-xl border border-border/70 bg-background/80 p-3.5 text-left transition hover:border-primary/50 hover:bg-background hover:shadow-md",children:[e.jsx("div",{className:"flex-none rounded-lg bg-violet-500/10 p-2 text-violet-500 transition-transform group-hover:scale-105",children:e.jsx(vn,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold",children:"打开图谱"}),e.jsx("div",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"可视化已存的实体和关系"})]})]})]})]})}),e.jsxs(En,{value:I,onValueChange:r=>$(r),className:"space-y-5",children:[e.jsx("div",{className:"sticky top-0 z-10 -mx-6 border-b border-border/40 bg-background/85 px-6 pb-2 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:e.jsx(Rn,{items:[{value:"overview",label:"概览",description:"运行状态与运行时摘要"},{value:"graph",label:"图谱",description:"实体关系图与证据视图"},{value:"import",label:"导入",description:"创建并管理导入任务"},{value:"tuning",label:"调优",description:"检索策略调优"},{value:"episodes",label:"情景记忆",description:"查看和重建情景记忆"},{value:"profiles",label:"人物画像",description:"查询和维护人物画像"},{value:"maintenance",label:"维护",description:"回收站与记忆状态维护"},{value:"delete",label:"删除",description:"批量删除与历史回溯"},{value:"feedback",label:"纠错历史",description:"查看反馈与回滚"}],triggerClassName:"px-4"})}),e.jsx(xe,{value:"graph",className:"h-[calc(100vh-220px)] min-h-[720px] overflow-hidden rounded-2xl border border-border/60 bg-background shadow-sm",children:e.jsx(Cl,{embedded:!0,onOpenConsole:()=>$("overview")})}),e.jsx(xe,{value:"overview",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[1.15fr_0.85fr]",children:[e.jsxs(X,{children:[e.jsxs(Y,{className:"flex flex-row items-start justify-between space-y-0",children:[e.jsxs("div",{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4"}),"运行时自检"]}),e.jsx(ee,{children:"用于确认 embedding、向量库与运行时状态是否一致"})]}),e.jsxs(k,{size:"sm",onClick:()=>{on()},disabled:d,children:[e.jsx(Be,{className:`mr-2 h-4 w-4 ${d?"animate-spin":""}`}),"重新自检"]})]}),e.jsxs(te,{className:"space-y-3",children:[e.jsx(ze,{children:e.jsx($e,{children:"长期记忆配置已移动到主程序配置,请在“主程序配置 / 长期记忆”中调整。"})}),e.jsx(Pa,{value:JSON.stringify(v??w??{},null,2),language:"json",readOnly:!0,height:"320px"})]})]}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Oa,{className:"h-4 w-4"}),"关键指标"]}),e.jsx(ee,{children:"用于快速判断是否需要补回向量或重新调优"})]}),e.jsxs(te,{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"待补回段落向量"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:w?.paragraph_vector_backfill_pending??0})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"失败补回任务"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:w?.paragraph_vector_backfill_failed??0})]})]}),e.jsxs("details",{className:"rounded-lg border bg-muted/30 p-3",open:!0,children:[e.jsx("summary",{className:"cursor-pointer text-xs font-medium text-muted-foreground",children:"当前调优配置"}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words text-xs",children:JSON.stringify(Ba,null,2)})]})]})]})]})}),e.jsx(vc,{importCreateMode:J,setImportCreateMode:ue,importSettings:F,importCommonFileConcurrency:pe,setImportCommonFileConcurrency:De,importCommonChunkConcurrency:be,setImportCommonChunkConcurrency:B,importCommonLlmEnabled:Ne,setImportCommonLlmEnabled:Ue,importCommonChatLog:Ze,setImportCommonChatLog:c,importCommonStrategyOverride:_e,setImportCommonStrategyOverride:Se,importCommonDedupePolicy:we,setImportCommonDedupePolicy:Ss,importCommonChatReferenceTime:E,setImportCommonChatReferenceTime:Xe,importCommonForce:ws,setImportCommonForce:ur,importCommonClearManifest:Cs,setImportCommonClearManifest:mr,uploadInputMode:Is,setUploadInputMode:xr,uploadFiles:as,setUploadFiles:vt,pasteName:Ps,setPasteName:bt,pasteMode:Ms,setPasteMode:hr,pasteContent:ns,setPasteContent:Nt,rawAlias:Ts,setRawAlias:yt,rawInputMode:Os,setRawInputMode:fr,rawRelativePath:Es,setRawRelativePath:pr,rawGlob:Rs,setRawGlob:gr,rawRecursive:Fs,setRawRecursive:jr,openieAlias:Ds,setOpenieAlias:kt,openieRelativePath:Ls,setOpenieRelativePath:vr,openieIncludeAllJson:As,setOpenieIncludeAllJson:br,convertAlias:Bs,setConvertAlias:_t,convertTargetAlias:$s,setConvertTargetAlias:St,convertRelativePath:zs,setConvertRelativePath:Nr,convertTargetRelativePath:qs,setConvertTargetRelativePath:yr,convertDimension:Js,setConvertDimension:kr,convertBatchSize:Us,setConvertBatchSize:_r,backfillAlias:Ks,setBackfillAlias:wt,backfillLimit:Vs,setBackfillLimit:It,backfillRelativePath:is,setBackfillRelativePath:Ct,backfillDryRun:Gs,setBackfillDryRun:Sr,backfillNoCreatedFallback:Ws,setBackfillNoCreatedFallback:wr,maibotSourceDb:qe,setMaibotSourceDb:ls,maibotTimeFrom:Hs,setMaibotTimeFrom:Cr,maibotTimeTo:Ke,setMaibotTimeTo:cs,maibotStartId:Ve,setMaibotStartId:Ye,maibotEndId:es,setMaibotEndId:Ir,maibotStreamIds:Qs,setMaibotStreamIds:Pr,maibotGroupIds:os,setMaibotGroupIds:Mr,maibotUserIds:Zs,setMaibotUserIds:Tr,maibotReadBatchSize:V,setMaibotReadBatchSize:ss,maibotCommitWindowRows:ds,setMaibotCommitWindowRows:Pt,maibotEmbedWorkers:Xs,setMaibotEmbedWorkers:Er,maibotNoResume:ts,setMaibotNoResume:Mt,maibotResetState:us,setMaibotResetState:Rr,maibotDryRun:Ys,setMaibotDryRun:Or,maibotVerifyOnly:ms,setMaibotVerifyOnly:a,submitImportByMode:Ui,creatingImport:g,pathResolveAlias:fe,setPathResolveAlias:Fr,importAliasKeys:gs,pathResolveRelativePath:Dr,setPathResolveRelativePath:Ln,pathResolveMustExist:Lr,setPathResolveMustExist:An,resolveImportPath:Ii,resolvingPath:zn,pathResolveOutput:Bn,refreshImportQueue:Pe,runningImportTasks:gi,queuedImportTasks:fi,recentImportTasks:ji,selectedImportTaskId:m,selectImportTask:mt,importAutoPolling:ae,setImportAutoPolling:Qe,importPollInterval:la,importErrorText:j,cancelSelectedImportTask:wi,retrySelectedImportTask:Ci,selectedImportTaskLoading:de,selectedImportTaskResolved:ca,selectedImportRetrySummary:ki,selectedImportTaskErrorText:yi,selectedImportFiles:bi,selectedImportFileId:h,selectImportFile:Pi,importChunkTotal:Ya,importChunkOffset:W,moveImportChunkPage:Mi,canImportChunkPrev:_i,canImportChunkNext:Si,importChunksLoading:ke,selectedImportChunks:Ni}),e.jsx(bc,{tuningObjective:ra,setTuningObjective:mi,tuningIntensity:aa,setTuningIntensity:xi,tuningSampleSize:na,setTuningSampleSize:hi,tuningTopKEval:ia,setTuningTopKEval:pi,submitTuningTask:Ki,creatingTuning:S,tuningProfile:Ba,tuningProfileToml:qn,tuningTasks:$n,applyBestTask:Vi}),e.jsx(xe,{value:"episodes",className:"space-y-4",children:O.has("episodes")?e.jsx(Wl,{}):null}),e.jsx(xe,{value:"profiles",className:"space-y-4",children:O.has("profiles")?e.jsx(tc,{}):null}),e.jsx(xe,{value:"maintenance",className:"space-y-4",children:O.has("maintenance")?e.jsx(Xl,{}):null}),e.jsx(hc,{sourceSearch:Jr,setSourceSearch:Kn,selectedSources:Ot,setSelectedSources:Gr,filteredSources:Ti,openSourceDeletePreview:Ri,toggleSourceSelection:Ei,operationSearch:Et,setOperationSearch:Vn,operationModeFilter:tt,setOperationModeFilter:Gn,operationStatusFilter:rt,setOperationStatusFilter:Wn,filteredDeleteOperations:js,deleteOperations:zr,operationPage:at,setOperationPage:Ur,deleteOperationPageCount:qt,pagedDeleteOperations:da,selectedDeleteOperation:Ce,setSelectedOperationId:Kr,restoreDeleteOperation:cn,deleteRestoring:Ka,selectedOperationCounts:$i,selectedOperationDetailLoading:Jn,selectedOperationDetailError:Un,selectedOperationSources:qi,selectedOperationItems:Vt,filteredSelectedOperationItems:Gt,selectedOperationItemSearch:Rt,setSelectedOperationItemSearch:Hn,selectedOperationItemPage:nt,setSelectedOperationItemPage:Vr,selectedOperationItemPageCount:Wt,pagedSelectedOperationItems:Ji}),e.jsx(pc,{feedbackSearch:Lt,setFeedbackSearch:ni,feedbackStatusFilter:it,setFeedbackStatusFilter:ii,feedbackRollbackFilter:lt,setFeedbackRollbackFilter:li,filteredFeedbackCorrections:vs,feedbackCorrections:Xr,pagedFeedbackCorrections:ua,feedbackPage:ct,setFeedbackPage:Yr,feedbackPageCount:Jt,selectedFeedbackCorrection:Ie,setSelectedFeedbackTaskId:ea,selectedFeedbackResolved:Me,selectedFeedbackPreview:Di,selectedFeedbackImpactSummary:Li,openFeedbackRollbackDialog:Bi,feedbackRollingBack:$t,selectedFeedbackTaskLoading:ci,selectedFeedbackTaskError:oi,feedbackActionLogPage:dt,setFeedbackActionLogPage:sa,feedbackActionLogPageCount:Kt,feedbackActionLogSearch:Bt,setFeedbackActionLogSearch:di,pagedFeedbackActionLogs:Ai,selectedFeedbackActionLogs:Ut})]})]})}),e.jsx(Il,{open:Qn,onOpenChange:Fi,title:Zn,description:Yn,preview:si,result:Hr,loadingPreview:ri,executing:ai,restoring:Ka,error:ti,onExecute:()=>{Oi()},onRestore:()=>{Hr?.operation_id?cn(Hr.operation_id):Promise.resolve()}}),e.jsx(Tl,{open:ui,onOpenChange:zt,children:e.jsxs(El,{className:"max-w-lg",confirmOnEnter:!0,children:[e.jsxs(Rl,{children:[e.jsx(Ol,{children:"回退本次纠错"}),e.jsx(Fl,{children:"这会恢复旧关系状态、隐藏本次纠错写入的段落,并重新触发 Episode / Profile 的异步修复。"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm",children:[e.jsx("div",{className:"font-medium break-words",children:Me?.query_text||"无查询文本"}),e.jsx("div",{className:"mt-1 font-mono text-[11px] break-all text-muted-foreground",children:Me?.query_tool_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"feedback-rollback-reason",children:"回退原因"}),e.jsx(ys,{id:"feedback-rollback-reason",value:ta,onChange:r=>Qa(r.target.value),placeholder:"可选,建议填写本次人工回退原因"})]})]}),e.jsxs(Dl,{children:[e.jsx(k,{variant:"outline",onClick:()=>zt(!1),disabled:$t,children:"取消"}),e.jsx(k,{onClick:()=>{zi()},disabled:$t,children:$t?e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"mr-2 h-4 w-4 animate-spin"}),"回退中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"确认回退"]})})]})]})})]})}export{Bc as KnowledgeBasePage};