memory-eternal 0.10.21 → 0.10.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -3,17 +3,17 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
- var aa=Object.create;var St=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var oa=Object.getOwnPropertyNames;var ia=Object.getPrototypeOf,ra=Object.prototype.hasOwnProperty;var sa=(t,o)=>{for(var r in o)St(t,r,{get:o[r],enumerable:!0})},Ht=(t,o,r,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of oa(o))!ra.call(t,d)&&d!==r&&St(t,d,{get:()=>o[d],enumerable:!(m=na(o,d))||m.enumerable});return t};var la=(t,o,r)=>(r=t!=null?aa(ia(t)):{},Ht(o||!t||!t.__esModule?St(r,"default",{value:t,enumerable:!0}):r,t)),da=t=>Ht(St({},"__esModule",{value:!0}),t);var $a={};sa($a,{EN:()=>Jt,MemoryLibrary:()=>za,ZH:()=>Xt,apply:()=>Sa,inject:()=>xa});module.exports=da($a);var n=la(require("react"),1);var ca={"&":"&amp;","<":"&lt;",">":"&gt;"},zt=t=>String(t).replace(/[&<>]/g,o=>ca[o]),pa=[[/结论|总结|tl;?dr|summary|takeaway/i,"\u2705","ok"],[/风险|注意|警告|禁止|坑|踩坑|务必/i,"\u26A0\uFE0F","warn"],[/根因|原因|为什么|定位|复现/i,"\u{1F50D}","info"],[/修复|解决|变更|fix/i,"\u{1F527}","ok"],[/验证|测试|实测|回归/i,"\u{1F9EA}","ok"],[/方案|做法|实现|设计|思路|架构/i,"\u{1F6E0}\uFE0F","plan"],[/步骤|流程|操作|用法|命令/i,"\u{1F9E9}","plan"],[/背景|由来|context/i,"\u{1F9ED}","info"],[/目标|需求|要解决/i,"\u{1F3AF}","plan"],[/环境|依赖|前置|安装/i,"\u{1F4E6}","info"],[/收益|效果|性能|指标|数据|统计/i,"\u{1F4C8}","ok"],[/示例|例子|样例|demo/i,"\u{1F4A1}","idea"],[/参考|链接|相关/i,"\u{1F517}","info"]],ua=["\u2728","info"],ma=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],ga=t=>{let o=String(t);for(let[r,m,d]of pa)if(r.test(o))return[m,d];return ua},fa=t=>{let o=t.join(" ");for(let[r,m,d]of ma)if(r.test(o))return[m,d];return["\u{1F4CC}","info"]};function st(t){let o=String(t),r=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(o);if(r&&!/[是为有了吗呢着过把被和与或于]/.test(r[1]))return'<span class="md-kv"><span class="md-k">'+zt(r[1])+'</span><span class="md-v">'+st(r[2])+"</span></span>";let m=zt(o);return m=m.replace(/^\[([ xX])\](?=\s|$)\s*/,(d,i)=>'<span class="md-task">'+(i.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),m=m.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),m=m.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),m=m.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),m=m.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(d,i,S)=>/^(https?:|\/|#)/i.test(S)?'<a class="md-link" href="'+S+'" target="_blank" rel="noopener noreferrer">'+i+"</a>":i),m}function Ct(t){let o=String(t||"").replace(/\r\n?/g,`
7
- `),r=/^---\n([\s\S]*?)\n---\n?/.exec(o);if(!r)return{meta:[],body:o};let m=[];for(let d of r[1].split(`
8
- `)){let i=d.indexOf(":");if(i<=0)continue;let S=d.slice(0,i).trim(),M=d.slice(i+1).trim().replace(/^["']|["']$/g,"");S&&m.push([S,M])}return{meta:m,body:o.slice(r[0].length)}}function jt(t){let o=String(t||"").trim().replace(/^\[|\]$/g,"");return o?o.split(",").map(r=>r.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function Tt(t){let o=Ct(String(t||"").replace(/\r\n?/g,`
9
- `)).body;if(!o.trim())return"";let r=[],m=o.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(u,z,I)=>(r.push('<pre class="md-pre"><code>'+zt(I.replace(/\n$/,""))+"</code></pre>"),"\0F"+(r.length-1)+"\0")),d=[],i=[],S=null,M=null,k=()=>{i.length&&(d.push('<p class="md-p">'+i.join("<br/>")+"</p>"),i=[])},E=()=>{if(!S)return;let u=S.type;d.push("<"+u+' class="md-'+u+'">'+S.items.map(z=>"<li>"+z+"</li>").join("")+"</"+u+">"),S=null},C=()=>{if(!M)return;let[u,z]=fa(M);d.push('<div class="md-callout md-c-'+z+'"><span class="md-ico">'+u+"</span>"+M.join("<br/>")+"</div>"),M=null},h=()=>{k(),E(),C()};for(let u of m.split(`
10
- `)){let z=u.trim();if(!z){h();continue}let I=/^\u0000F(\d+)\u0000$/.exec(z);if(I){h(),d.push(r[Number(I[1])]);continue}let w;if(w=/^(#{1,6})\s+(.+)$/.exec(z)){h();let[R,D]=ga(w[2]);d.push('<div class="md-h md-h-'+(w[1].length<=2?"h1":"h2")+" md-c-"+D+'"><span class="md-ico">'+R+'</span><span class="md-hx">'+st(w[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(z)){h(),d.push('<hr class="md-hr"/>');continue}if(w=/^>\s?(.*)$/.exec(z)){k(),E(),M=M||[],M.push(st(w[1]));continue}if(w=/^[-*+]\s+(.+)$/.exec(z)){k(),C(),(!S||S.type!=="ul")&&(E(),S={type:"ul",items:[]}),S.items.push(st(w[1]));continue}if(w=/^\d+[.)]\s+(.+)$/.exec(z)){k(),C(),(!S||S.type!=="ol")&&(E(),S={type:"ol",items:[]}),S.items.push(st(w[1]));continue}E(),C(),i.push(st(z))}return h(),d.join(`
11
- `)}function Ot(t={}){let o=t.repo||"EternalNight996/memory-eternal",r=String(t.title||"[Bug] ").slice(0,120),m=Array.isArray(t.labels)?t.labels:["bug"],d=Number(t.maxLength)>500?Number(t.maxLength):7e3,i=k=>{let E=new URLSearchParams;return E.set("title",r),E.set("body",k),m.length&&E.set("labels",m.join(",")),"https://github.com/"+o+"/issues/new?"+E.toString()},S=String(t.body||""),M=i(S);if(M.length>d){let k=`
12
-
13
- > \u5185\u5BB9\u8FC7\u957F\u5DF2\u622A\u65AD\uFF1A\u5B8C\u6574\u8BCA\u65AD\u8BF7\u5728\u63D2\u4EF6\u91CC\u70B9\u300C\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u300D\uFF0C\u518D\u8865\u5230 issue \u8BC4\u8BBA\u91CC\u3002`,E=C=>i(S.slice(0,C)+k);if(E(0).length>d)S=k;else{let C=0,h=S.length;for(;C<h;){let u=Math.ceil((C+h)/2);E(u).length<=d?C=u:h=u-1}S=S.slice(0,C)+k}M=i(S)}return M}function Wt(t={}){return["## \u73B0\u8C61",String(t.description||"").trim()||"\uFF08\u8BF7\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF09","","## \u590D\u73B0\u6B65\u9AA4","1. ","2. ","","## \u671F\u671B\u884C\u4E3A","","## \u5B9E\u9645\u884C\u4E3A","","## \u73AF\u5883","- \u63D2\u4EF6\u7248\u672C: "+(t.version||"\uFF08\u89C1\u8BCA\u65AD\u4FE1\u606F\uFF09"),"",t.diagnostics||"","","---","> \u7531 memory-eternal \u63D2\u4EF6\u5185\u300C\u53CD\u9988\u5F02\u5E38\u300D\u751F\u6210\uFF08\u8BCA\u65AD\u4FE1\u606F\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E\u5404\u7C7B key/token \u5DF2\u66FF\u6362\uFF09\u3002"].join(`
6
+ var aa=Object.create;var St=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var oa=Object.getOwnPropertyNames;var ia=Object.getPrototypeOf,ra=Object.prototype.hasOwnProperty;var sa=(t,o)=>{for(var r in o)St(t,r,{get:o[r],enumerable:!0})},Ht=(t,o,r,g)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of oa(o))!ra.call(t,d)&&d!==r&&St(t,d,{get:()=>o[d],enumerable:!(g=na(o,d))||g.enumerable});return t};var la=(t,o,r)=>(r=t!=null?aa(ia(t)):{},Ht(o||!t||!t.__esModule?St(r,"default",{value:t,enumerable:!0}):r,t)),da=t=>Ht(St({},"__esModule",{value:!0}),t);var $a={};sa($a,{EN:()=>Jt,MemoryLibrary:()=>Ta,ZH:()=>Xt,apply:()=>Sa,inject:()=>xa});module.exports=da($a);var n=la(require("react"),1);var ca={"&":"&amp;","<":"&lt;",">":"&gt;"},Tt=t=>String(t).replace(/[&<>]/g,o=>ca[o]),pa=[[/结论|总结|tl;?dr|summary|takeaway/i,"\u2705","ok"],[/风险|注意|警告|禁止|坑|踩坑|务必/i,"\u26A0\uFE0F","warn"],[/根因|原因|为什么|定位|复现/i,"\u{1F50D}","info"],[/修复|解决|变更|fix/i,"\u{1F527}","ok"],[/验证|测试|实测|回归/i,"\u{1F9EA}","ok"],[/方案|做法|实现|设计|思路|架构/i,"\u{1F6E0}\uFE0F","plan"],[/步骤|流程|操作|用法|命令/i,"\u{1F9E9}","plan"],[/背景|由来|context/i,"\u{1F9ED}","info"],[/目标|需求|要解决/i,"\u{1F3AF}","plan"],[/环境|依赖|前置|安装/i,"\u{1F4E6}","info"],[/收益|效果|性能|指标|数据|统计/i,"\u{1F4C8}","ok"],[/示例|例子|样例|demo/i,"\u{1F4A1}","idea"],[/参考|链接|相关/i,"\u{1F517}","info"]],ua=["\u2728","info"],ma=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],fa=t=>{let o=String(t);for(let[r,g,d]of pa)if(r.test(o))return[g,d];return ua},ga=t=>{let o=t.join(" ");for(let[r,g,d]of ma)if(r.test(o))return[g,d];return["\u{1F4CC}","info"]};function st(t){let o=String(t),r=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(o);if(r&&!/[是为有了吗呢着过把被和与或于]/.test(r[1]))return'<span class="md-kv"><span class="md-k">'+Tt(r[1])+'</span><span class="md-v">'+st(r[2])+"</span></span>";let g=Tt(o);return g=g.replace(/^\[([ xX])\](?=\s|$)\s*/,(d,i)=>'<span class="md-task">'+(i.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),g=g.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),g=g.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),g=g.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),g=g.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(d,i,k)=>/^(https?:|\/|#)/i.test(k)?'<a class="md-link" href="'+k+'" target="_blank" rel="noopener noreferrer">'+i+"</a>":i),g}function Ct(t){let o=String(t||"").replace(/\r\n?/g,`
7
+ `),r=/^---\n([\s\S]*?)\n---\n?/.exec(o);if(!r)return{meta:[],body:o};let g=[];for(let d of r[1].split(`
8
+ `)){let i=d.indexOf(":");if(i<=0)continue;let k=d.slice(0,i).trim(),M=d.slice(i+1).trim().replace(/^["']|["']$/g,"");k&&g.push([k,M])}return{meta:g,body:o.slice(r[0].length)}}function jt(t){let o=String(t||"").trim().replace(/^\[|\]$/g,"");return o?o.split(",").map(r=>r.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function zt(t){let o=Ct(String(t||"").replace(/\r\n?/g,`
9
+ `)).body;if(!o.trim())return"";let r=[],g=o.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(f,T,I)=>(r.push('<pre class="md-pre"><code>'+Tt(I.replace(/\n$/,""))+"</code></pre>"),"\0F"+(r.length-1)+"\0")),d=[],i=[],k=null,M=null,w=()=>{i.length&&(d.push('<p class="md-p">'+i.join("<br/>")+"</p>"),i=[])},j=()=>{if(!k)return;let f=k.type;d.push("<"+f+' class="md-'+f+'">'+k.items.map(T=>"<li>"+T+"</li>").join("")+"</"+f+">"),k=null},S=()=>{if(!M)return;let[f,T]=ga(M);d.push('<div class="md-callout md-c-'+T+'"><span class="md-ico">'+f+"</span>"+M.join("<br/>")+"</div>"),M=null},h=()=>{w(),j(),S()};for(let f of g.split(`
10
+ `)){let T=f.trim();if(!T){h();continue}let I=/^\u0000F(\d+)\u0000$/.exec(T);if(I){h(),d.push(r[Number(I[1])]);continue}let x;if(x=/^(#{1,6})\s+(.+)$/.exec(T)){h();let[D,C]=fa(x[2]);d.push('<div class="md-h md-h-'+(x[1].length<=2?"h1":"h2")+" md-c-"+C+'"><span class="md-ico">'+D+'</span><span class="md-hx">'+st(x[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(T)){h(),d.push('<hr class="md-hr"/>');continue}if(x=/^>\s?(.*)$/.exec(T)){w(),j(),M=M||[],M.push(st(x[1]));continue}if(x=/^[-*+]\s+(.+)$/.exec(T)){w(),S(),(!k||k.type!=="ul")&&(j(),k={type:"ul",items:[]}),k.items.push(st(x[1]));continue}if(x=/^\d+[.)]\s+(.+)$/.exec(T)){w(),S(),(!k||k.type!=="ol")&&(j(),k={type:"ol",items:[]}),k.items.push(st(x[1]));continue}j(),S(),i.push(st(T))}return h(),d.join(`
11
+ `)}function Ot(t={}){let o=t.repo||"EternalNight996/memory-eternal",r=String(t.title||"[Bug] ").slice(0,120),g=Array.isArray(t.labels)?t.labels:["bug"],d=Number(t.maxLength)>500?Number(t.maxLength):7e3,i=w=>{let j=new URLSearchParams;return j.set("title",r),j.set("body",w),g.length&&j.set("labels",g.join(",")),"https://github.com/"+o+"/issues/new?"+j.toString()},k=String(t.body||""),M=i(k);if(M.length>d){let w=`
12
+
13
+ > \u5185\u5BB9\u8FC7\u957F\u5DF2\u622A\u65AD\uFF1A\u5B8C\u6574\u8BCA\u65AD\u8BF7\u5728\u63D2\u4EF6\u91CC\u70B9\u300C\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u300D\uFF0C\u518D\u8865\u5230 issue \u8BC4\u8BBA\u91CC\u3002`,j=S=>i(k.slice(0,S)+w);if(j(0).length>d)k=w;else{let S=0,h=k.length;for(;S<h;){let f=Math.ceil((S+h)/2);j(f).length<=d?S=f:h=f-1}k=k.slice(0,S)+w}M=i(k)}return M}function Wt(t={}){return["## \u73B0\u8C61",String(t.description||"").trim()||"\uFF08\u8BF7\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF09","","## \u590D\u73B0\u6B65\u9AA4","1. ","2. ","","## \u671F\u671B\u884C\u4E3A","","## \u5B9E\u9645\u884C\u4E3A","","## \u73AF\u5883","- \u63D2\u4EF6\u7248\u672C: "+(t.version||"\uFF08\u89C1\u8BCA\u65AD\u4FE1\u606F\uFF09"),"",t.diagnostics||"","","---","> \u7531 memory-eternal \u63D2\u4EF6\u5185\u300C\u53CD\u9988\u5F02\u5E38\u300D\u751F\u6210\uFF08\u8BCA\u65AD\u4FE1\u606F\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E\u5404\u7C7B key/token \u5DF2\u66FF\u6362\uFF09\u3002"].join(`
14
14
  `)}var Rt="https://github.com/EternalNight996/memory-eternal",ba=["\u6211\u5728\u4F7F\u7528 memory-eternal\uFF08DeepSeek Harness \u7684\u8BB0\u5FC6\u63D2\u4EF6\uFF09\u65F6\u9047\u5230\u4E86\u95EE\u9898\uFF0C\u8BF7\u4F60\u5E2E\u6211\u628A\u8FD9\u4E2A\u95EE\u9898\u63D0\u4EA4\u5230 GitHub\u3002","","\u4ED3\u5E93\uFF1A"+Rt,"","\u8BF7\u6309\u8FD9\u4E2A\u6D41\u7A0B\u505A\uFF1A","","1. \u5148\u8DD1 `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50`\uFF0C\u770B\u662F\u5426\u5DF2\u6709\u76F8\u540C\u95EE\u9898\uFF1A"," - \u5DF2\u6709 \u2192 \u7528 `gh issue comment <\u7F16\u53F7> --body-file <\u6587\u4EF6>` \u8865\u5145\u73B0\u8C61\uFF0C\u4E0D\u8981\u91CD\u590D\u5F00\u65B0 issue\uFF1B"," - \u6CA1\u6709 \u2192 \u7EE7\u7EED\u7B2C 2 \u6B65\u3002",'2. \u628A\u6B63\u6587\u5199\u6210\u6587\u4EF6\uFF0C\u7136\u540E `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <\u4E00\u53E5\u8BDD\u6982\u62EC>" --body-file <\u6587\u4EF6>`\uFF1B\u6B63\u6587\u7528\u8FD9\u4E2A\u7ED3\u6784\uFF1A'," \u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A / \u5B9E\u9645\u884C\u4E3A / \u73AF\u5883\uFF08\u63D2\u4EF6\u7248\u672C / DSH \u7248\u672C / \u64CD\u4F5C\u7CFB\u7EDF / Node\uFF09/ \u8BCA\u65AD\u4FE1\u606F\u3002","3. \u5982\u679C `gh` \u6CA1\u767B\u5F55\u6216\u4E0D\u53EF\u7528\uFF0C\u4E0D\u8981\u5C1D\u8BD5\u63D0\u4EA4\uFF0C\u6539\u4E3A\u8F93\u51FA\u4E00\u6761\u300C\u6807\u9898\u4E0E\u6B63\u6587\u90FD\u5DF2\u9884\u586B\u300D\u7684 GitHub \u65B0\u5EFA issue \u94FE\u63A5\u7ED9\u6211\uFF0C\u6211\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002","4. \u63D0\u4EA4\u6210\u529F\u540E\uFF0C\u628A issue \u94FE\u63A5\u53D1\u7ED9\u6211\u3002","","\u6CE8\u610F\uFF1A\u6211\u7684\u95EE\u9898\u63CF\u8FF0\u8BF7\u539F\u6837\u7167\u5F55\uFF0C\u4E0D\u8981\u66FF\u6211\u7F8E\u5316\u6216\u7701\u7565\u7EC6\u8282\uFF1B\u8BCA\u65AD\u4FE1\u606F\u539F\u6837\u653E\u8FDB\u300C\u8BCA\u65AD\u4FE1\u606F\u300D\u4E00\u8282\u3002","","\u6211\u7684\u95EE\u9898\u63CF\u8FF0\uFF1A","<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>","","\u8BCA\u65AD\u4FE1\u606F\uFF1A","<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>"].join(`
15
15
  `),ya=["I hit a problem while using memory-eternal (a DeepSeek Harness memory plugin). Please file it on GitHub for me.","","Repo: "+Rt,"","Workflow:","","1. Run `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50` first: if a matching issue exists, add a comment with `gh issue comment <n> --body-file <file>` instead of opening a duplicate.",'2. Otherwise create it with `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <one-line summary>" --body-file <file>`, using sections: Symptoms / Steps to reproduce / Expected / Actual / Environment (plugin, DSH, OS, Node) / Diagnostics.',"3. If `gh` is not authenticated or unavailable, do NOT try to submit: output a GitHub new-issue link with the title and body pre-filled instead, and I will click submit myself.","4. Report the resulting issue URL back to me.","","Keep my description verbatim - do not rewrite or summarise it. Put the diagnostics under the Diagnostics section as-is.","","My description:","<write your problem here>","","Diagnostics:","<paste the diagnostics copied from the in-app Report-a-bug dialog>"].join(`
16
- `);function $t(t={}){let o=t.lang==="en"?"en":"zh",r=o==="en"?ya:ba,m=t.repo||"EternalNight996/memory-eternal";return r=r.split(Rt).join("https://github.com/"+m),t.description&&(r=r.replace(o==="en"?"<write your problem here>":"<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>",String(t.description).trim())),t.diagnostics&&(r=r.replace(o==="en"?"<paste the diagnostics copied from the in-app Report-a-bug dialog>":"<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>",String(t.diagnostics).trim())),r}function _t({panX:t=0,panY:o=0,zoom:r=1,w:m=0,h:d=0,margin:i=60}={}){let S=r||1;return{x0:(0-t)/S-i,y0:(0-o)/S-i,x1:(m-t)/S+i,y1:(d-o)/S+i}}function Nt(t,o,r,m){return m?t+r>=m.x0&&t-r<=m.x1&&o+r>=m.y0&&o-r<=m.y1:!0}function Ut(t){let o=Number(t)||0;return o<=120?1/0:o<=300?160:o<=600?90:60}function Kt(t,o={}){let r=Number.isFinite(o.limit)?o.limit:1/0,m=new Set,d=k=>{k&&m.size<r&&m.add(k)};if(d(o.focusId),d(o.hoverId),o.searchHits)for(let k of o.searchHits){if(m.size>=r)break;m.add(k)}let i=o.degree||{},S=k=>Number(i[k])||0,M=[];for(let k of Array.isArray(t)?t:[])k&&k.id&&!m.has(k.id)&&M.push(k);M.sort((k,E)=>S(E.id)-S(k.id));for(let k of M){if(m.size>=r)break;m.add(k.id)}return m}function ha(t,o){if(t===o)return!0;if(t===null||o===null||t===void 0||o===void 0||typeof t!="object"&&typeof o!="object")return t===o;try{return JSON.stringify(t)===JSON.stringify(o)}catch{return!1}}function qt(t,o){let r={...t||{}},m={};for(let[d,i]of Object.entries(o||{}))ha(t?t[d]:void 0,i)||(r[d]=i,m[d]=i);return{values:r,overlay:m}}var e=require("react/jsx-runtime"),lt="memory-eternal",_="/memory-eternal/api",va=100,xa=["slots","locale"],Xt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedTotal:" \u5F20 / \u6587\u4EF6\u5171 ",importedTotalTail:" \u5F20",importedQuarantine:" \xB7 \u5F85\u5BA1\u6838 ",importedQuarantineTail:" \u5F20\uFF08\u9694\u79BB\u533A\uFF0C\u6279\u51C6\u540E\u624D\u53C2\u4E0E\u53EC\u56DE\uFF09",importedSkipped:" \xB7 \u8DF3\u8FC7 ",importedSkippedTail:" \u5F20\uFF08\u91CD\u590D\u6216\u7A7A\uFF09",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",auditBodyFail:"\u6B63\u6587\u8BFB\u53D6\u5931\u8D25",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",pendingSyncNote:"\u6B64\u9875\u662F\u72EC\u7ACB Web \u9875\uFF1A\u4FDD\u5B58\u540E\u7531 DSH \u5BBF\u4E3B\u5E94\u7528\uFF08\u65B0\u7248\u5BBF\u4E3B\u4F1A\u88AB\u76F4\u63A5\u53EB\u9192\u3001\u5728\u8BF7\u6C42\u4E0A\u4E0B\u6587\u91CC\u5E94\u7528\uFF0C\u70B9\u4FDD\u5B58\u5373\u751F\u6548\uFF09\uFF1B\u82E5\u672C\u673A\u6CA1\u6709 DSH \u5BBF\u4E3B\u5728\u8FD0\u884C\uFF0C\u5219\u76F4\u63A5\u5199\u5165\u5171\u4EAB\u914D\u7F6E\u3001\u7ACB\u5373\u751F\u6548\u3002\u53EA\u6709\u5728\u5BF9\u63A5\u65E7\u7248\u5BBF\u4E3B\u65F6\u624D\u4F1A\u9000\u56DE\u300C\u6392\u961F\u7B49\u5B83\u81EA\u5DF1\u540C\u6B65\u300D\uFF0C\u90A3\u65F6\u53EF\u5728 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u91CC\u6539\u540C\u4E00\u9879\u3002",readonlyTitle:"\u5F53\u524D\u9875\u9762\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u914D\u7F6E",readonlyBody:"\u8FD9\u4E2A\u8FDB\u7A0B\u6CA1\u6709 DSH \u7684\u8BBE\u7F6E\u670D\u52A1\uFF08settings.update \u4E0D\u5B58\u5728\uFF09\uFF0C\u914D\u7F6E\u53EA\u80FD\u5728\u672C\u673A DSH \u91CC\u4FEE\u6539\uFF1A\u684C\u9762\u7248 \u2192 \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u3002",readonlyBtn:"\u53EA\u8BFB",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",vaultMulti:"\u591A\u5E93\uFF08\u6309\u9879\u76EE\u9694\u79BB\uFF09",vaultMultiHint:"\u7559\u7A7A\u5373\u5355\u5E93\uFF0C\u8001\u914D\u7F6E\u4E0D\u53D7\u5F71\u54CD",vaultNow:"\u5F53\u524D\u751F\u6548",vaultSource:"\u6765\u6E90",vaultWorkspace:"\u5F53\u524D workspace",vaultNamePh:"\u5E93\u540D\uFF0C\u5982 work",vaultPathPh:"\u76EE\u5F55\uFF0C\u5982 D:/vaults/work",vaultMatchPh:"\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u6309 workspace \u81EA\u52A8\u9009\u5E93\uFF09",vaultAdd:"\u6DFB\u52A0\u4E00\u4E2A\u5E93",vaultActive:"\u6FC0\u6D3B\u5E93",vaultActiveNone:"\u9ED8\u8BA4\u5E93\uFF08\u4E0D\u6307\u5B9A\uFF09",vaultSrcEnv:"\u73AF\u5883\u53D8\u91CF MEMORY_VAULT_DIR",vaultSrcProfile:"\u6FC0\u6D3B\u5E93\u914D\u7F6E",vaultSrcWorkspace:"\u6309\u9879\u76EE\u76EE\u5F55\u81EA\u52A8\u547D\u4E2D",vaultSrcVaultDir:"\u5355\u5E93\u914D\u7F6E vaultDir",vaultSrcDefault:"\u9ED8\u8BA4\u76EE\u5F55",fbNav:"\u53CD\u9988\u5F02\u5E38",fbTitle:"\u53CD\u9988\u5F02\u5E38\uFF08\u63D0\u4EA4\u5230 GitHub\uFF09",fbDesc:"\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF08\u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A\uFF09",fbDiag:"\u8BCA\u65AD\u4FE1\u606F\uFF08\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E key/token \u5DF2\u66FF\u6362\uFF09",fbCopyDiag:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",fbOpenIssue:"\u5728 GitHub \u63D0\u4EA4\uFF08\u5DF2\u9884\u586B\uFF09",fbCopyPrompt:"\u590D\u5236\u7ED9 AI \u7684\u63D0\u793A\u8BCD",fbCopiedDiag:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",fbCopiedPrompt:"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB AI \u5BF9\u8BDD\u6846\u5373\u53EF",fbCopyFail:"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u590D\u5236",fbWhy:"GitHub \u4E0D\u5141\u8BB8\u533F\u540D\u521B\u5EFA issue\uFF0C\u63D2\u4EF6\u91CC\u4E5F\u4E0D\u5E94\u5185\u7F6E token\uFF1A\u6240\u4EE5\u8FD9\u91CC\u628A\u6807\u9898 / \u6B63\u6587 / \u8BCA\u65AD\u90FD\u9884\u586B\u597D\uFF0C\u4F60\u53EA\u9700\u518D\u70B9\u4E00\u6B21 Submit\u3002",fbNeedDesc:"\u8BF7\u5148\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898",fbLoading:"\u6B63\u5728\u6536\u96C6\u8BCA\u65AD\u4FE1\u606F\u2026",fbDiagFail:"\u8BCA\u65AD\u63A5\u53E3\u4E0D\u53EF\u7528\uFF08\u72EC\u7ACB web \u6216\u65E7\u7248\u5BBF\u4E3B\uFF09\uFF0C\u8BF7\u624B\u52A8\u8865\u5145\u73AF\u5883\u4FE1\u606F",fbOr:"\u6216\u8005",fbSelectAll:"\u5168\u9009",toastApproved:"\u5DF2\u6279\u51C6",toastRejected:"\u5DF2\u9A73\u56DE",toastCardDeleted:"\u5DF2\u5220\u9664",toastRestored:"\u5DF2\u6062\u590D",toastPurged:"\u5DF2\u5F7B\u5E95\u5220\u9664",toastPurgedExpired:"\u5DF2\u6E05\u7406\u8FC7\u671F\u56DE\u6536\u7AD9",toastFailed:"\u64CD\u4F5C\u5931\u8D25",noSelection:"\u8BF7\u5148\u9009\u62E9\u8981\u5904\u7406\u7684\u5361\u7247",enabledLabel:"\u542F\u7528\u8BB0\u5FC6\u6838\u5FC3",vaultDirLabel:"\u8BB0\u5FC6\u5E93\u76EE\u5F55\uFF08\u5355\u5E93\uFF09",captureCooldownMs:"\u6C89\u6DC0\u51B7\u5374 (ms)",captureProvider:"\u84B8\u998F provider\uFF08\u7559\u7A7A\u81EA\u52A8\uFF09",captureModel:"\u84B8\u998F model\uFF08\u7559\u7A7A\u81EA\u52A8\uFF09",recallEmbedding:"\u8BED\u4E49\u53EC\u56DE provider\uFF08\u53EF\u9009\uFF09",sessionBudgetChars:"\u4F1A\u8BDD\u9884\u7B97 (\u5B57\u7B26)",saving:"\u4FDD\u5B58\u4E2D\u2026",savePending:"\u5DF2\u5199\u5165\u914D\u7F6E\u6587\u4EF6\uFF1B\u5BBF\u4E3B\u4ECD\u662F\u65E7\u7248\uFF0C\u91CD\u542F DSH \u540E\u5373\u4EE5\u65B0\u503C\u4E3A\u51C6\uFF08\u672C\u9762\u677F\u5DF2\u751F\u6548\uFF09",actionRunning:"\u5904\u7406\u4E2D\u2026",recycleEmptyHint:"\u56DE\u6536\u7AD9\u4E3A\u7A7A\uFF1A\u5220\u6389\u7684\u5361\u7247\u4F1A\u5148\u653E\u5230\u8FD9\u91CC\uFF0C\u4FDD\u7559 {days} \u5929\u540E\u81EA\u52A8\u6E05\u7406\u3002",recyclePurgeAll:"\u6E05\u7A7A\u56DE\u6536\u7AD9",fbCopyManual:"\u81EA\u52A8\u590D\u5236\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u5DF2\u628A\u5185\u5BB9\u653E\u5728\u4E0B\u9762\uFF1A\u70B9\u300C\u5168\u9009\u300D\u518D\u6309 Ctrl+C",vcPage:"\u9875\u9762\u811A\u672C",vcPageStale:"\u26A0 \u5F53\u524D\u9875\u9762\u4ECD\u5728\u8FD0\u884C\u65E7\u7248\u811A\u672C\uFF08\u9875\u9762 v{page} / \u78C1\u76D8 v{disk}\uFF09\uFF1A\u6309 Ctrl+F5 \u5237\u65B0\u9875\u9762\u5373\u751F\u6548\uFF1B\u82E5\u300C\u8FD0\u884C\u4E2D\u300D\u4ECD\u662F\u65E7\u7248\u53F7\uFF0C\u5219\u8FD8\u9700\u91CD\u542F\u684C\u9762\u7248 / DSH",vcLoaded:"\u8FD0\u884C\u4E2D\uFF08\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\uFF09",vcResident:"\u5E38\u9A7B\u5B9E\u4F8B",vcOnDisk:"\u78C1\u76D8\u5B89\u88C5",vcLatest:"npm \u6700\u65B0",vcStale:"\u78C1\u76D8\u5DF2\u5B89\u88C5 v{disk}\uFF0C\u4F46\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\u4ECD\u52A0\u8F7D v{loaded} \u2014\u2014 \u70B9\u300C\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B\u300D\u5373\u53EF\u7528\u65B0\u4EE3\u7801\u91CD\u542F\u5B83\uFF08\u4E0D\u7528\u91CD\u542F DSH\uFF09",vcRestart:"\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B",vcRestarting:"\u91CD\u542F\u4E2D\u2026",vcRestartSent:"\u5DF2\u8C03\u5EA6\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B\uFF1A\u7EA6 3-8 \u79D2\u540E\u65B0\u8FDB\u7A0B\u63A5\u7BA1\uFF0C\u8BF7\u7A0D\u7B49\u518D\u5237\u65B0\u9875\u9762\uFF08Ctrl+F5\uFF09",vcRestartCurrent:"\u5E38\u9A7B\u5B9E\u4F8B\u5DF2\u7ECF\u662F\u6700\u65B0\u7248\uFF0C\u65E0\u9700\u91CD\u542F",vcRestartFail:"\u91CD\u542F\u8BF7\u6C42\u5931\u8D25",vcRestartNoRoute:"\u5F53\u524D\u9875\u9762\u5BF9\u63A5\u7684\u8FDB\u7A0B\u8FD8\u662F\u65E7\u7248\uFF08\u6CA1\u6709\u8FD9\u4E2A\u63A5\u53E3\uFF09\uFF1A\u8BF7\u91CD\u542F\u684C\u9762\u7248 / DSH \u540E\u518D\u8BD5\uFF0C\u6216\u6267\u884C {cmd}",vcHostStale:"\u4E0A\u65B9\u7684\u300C\u8FD0\u884C\u4E2D\u300D\u6765\u81EA\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\uFF1B\u5E38\u9A7B\u5B9E\u4F8B\u5DF2\u662F\u65B0\u7248 \u2014\u2014 \u8981\u8BA9\u5B83\u4E5F\u53D8\u6210\u65B0\u7248\u53F7\uFF0C\u9700\u91CD\u542F\u684C\u9762\u7248 / DSH",vcResidentDownShort:"\u672A\u8FD0\u884C",vcResidentDown:"\u5E38\u9A7B\u5B9E\u4F8B\u6CA1\u5728\u8FD0\u884C\uFF08\u7AEF\u53E3 {port} \u65E0\u54CD\u5E94\uFF09\u2014\u2014 \u70B9\u4E0B\u9762\u7684\u6309\u94AE\u7528\u65B0\u4EE3\u7801\u628A\u5B83\u62C9\u8D77\u6765\uFF1B\u62C9\u4E0D\u8D77\u6765\u65F6\u6267\u884C {cmd}\uFF0C\u5E76\u8D34\u4E00\u4E0B dsh-memory status \u7684\u8F93\u51FA",vcResidentUnmanagedShort:"\u672A\u6258\u7BA1",vcResidentUnmanaged:"\u5E38\u9A7B\u5B9E\u4F8B\u5728\u670D\u52A1 v{served}\uFF0C\u4F46**\u6CA1\u6709\u770B\u95E8\u72D7\u4FDD\u6D3B**\uFF08\u505C\u6B62 / \u786C\u6740\u540E\u6B8B\u7559\u7684\u5B64\u513F\uFF09\u2014\u2014 \u70B9\u4E0B\u9762\u7684\u6309\u94AE\u628A\u5B83\u91CD\u65B0\u6258\u7BA1\uFF08\u91CD\u65B0\u62C9\u4E00\u4E2A\u770B\u95E8\u72D7 + \u65B0\u5B9E\u4F8B\uFF09\uFF1B\u4E5F\u53EF\u4EE5\u6267\u884C {cmd}",vcOutdated:"\u6709\u65B0\u7248\u672C",vcUpToDate:"\u5DF2\u662F\u6700\u65B0",vcCheck:"\u68C0\u67E5\u66F4\u65B0",checking:"\u68C0\u67E5\u4E2D\u2026",vcCheckFail:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",secretHint:"\u51ED\u8BC1\u53D6\u7528\u63D0\u793A\uFF08\u6CE8\u5165\u6BCF\u4E2A\u4F1A\u8BDD\uFF09",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoRestartOnDrift:"\u7248\u672C\u6F02\u79FB\u81EA\u52A8\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",savedDirect:"\u672C\u673A\u6CA1\u6709 DSH \u5BBF\u4E3B\u5728\u8FD0\u884C\uFF0C\u5DF2\u76F4\u63A5\u5199\u5165\u5171\u4EAB\u914D\u7F6E\uFF08hooks / MCP / \u72EC\u7ACB\u9875\u7ACB\u5373\u751F\u6548\uFF09",savedApplied:"\u5DF2\u4FDD\u5B58\u5E76\u751F\u6548\uFF08\u5BBF\u4E3B\u5DF2\u5728\u8BF7\u6C42\u4E0A\u4E0B\u6587\u91CC\u5E94\u7528\uFF09",saveQueued:"\u5DF2\u4EA4\u7ED9 DSH \u5BBF\u4E3B\u540C\u6B65\uFF0C\u5C1A\u672A\u786E\u8BA4\u751F\u6548",saveHostGuard:"\u8BE5\u5BBF\u4E3B\u4E0D\u5141\u8BB8\u63D2\u4EF6\u4ECE\u81EA\u5DF1\u7684\u56DE\u8C03\u4E0A\u4E0B\u6587\u91CC\u5199\u914D\u7F6E\uFF1B\u8BF7\u5728\u300CDSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u300D\u91CC\u6539\u540C\u4E00\u9879\uFF0C\u6216\u7F16\u8F91 profile \u7684\u914D\u7F6E\u8865\u4E01\u5C42",saveFailHint:"\u5BBF\u4E3B\u4FA7\u672A\u5E94\u7528\uFF0C\u8BE6\u89C1\u300C\u53CD\u9988\u5F02\u5E38\u300D\u91CC\u7684\u8BCA\u65AD\u4FE1\u606F",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548\uFF1B\u5DF2\u6709\u5E38\u9A7B watchdog \u4E0D\u4F1A\u88AB\u81EA\u52A8\u505C\u6389\uFF0C\u9700 dsh-memory stop / restart\uFF08#19\uFF09",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
16
+ `);function $t(t={}){let o=t.lang==="en"?"en":"zh",r=o==="en"?ya:ba,g=t.repo||"EternalNight996/memory-eternal";return r=r.split(Rt).join("https://github.com/"+g),t.description&&(r=r.replace(o==="en"?"<write your problem here>":"<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>",String(t.description).trim())),t.diagnostics&&(r=r.replace(o==="en"?"<paste the diagnostics copied from the in-app Report-a-bug dialog>":"<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>",String(t.diagnostics).trim())),r}function _t({panX:t=0,panY:o=0,zoom:r=1,w:g=0,h:d=0,margin:i=60}={}){let k=r||1;return{x0:(0-t)/k-i,y0:(0-o)/k-i,x1:(g-t)/k+i,y1:(d-o)/k+i}}function Nt(t,o,r,g){return g?t+r>=g.x0&&t-r<=g.x1&&o+r>=g.y0&&o-r<=g.y1:!0}function Ut(t){let o=Number(t)||0;return o<=120?1/0:o<=300?160:o<=600?90:60}function Kt(t,o={}){let r=Number.isFinite(o.limit)?o.limit:1/0,g=new Set,d=w=>{w&&g.size<r&&g.add(w)};if(d(o.focusId),d(o.hoverId),o.searchHits)for(let w of o.searchHits){if(g.size>=r)break;g.add(w)}let i=o.degree||{},k=w=>Number(i[w])||0,M=[];for(let w of Array.isArray(t)?t:[])w&&w.id&&!g.has(w.id)&&M.push(w);M.sort((w,j)=>k(j.id)-k(w.id));for(let w of M){if(g.size>=r)break;g.add(w.id)}return g}function ha(t,o){if(t===o)return!0;if(t===null||o===null||t===void 0||o===void 0||typeof t!="object"&&typeof o!="object")return t===o;try{return JSON.stringify(t)===JSON.stringify(o)}catch{return!1}}function qt(t,o){let r={...t||{}},g={};for(let[d,i]of Object.entries(o||{}))ha(t?t[d]:void 0,i)||(r[d]=i,g[d]=i);return{values:r,overlay:g}}var e=require("react/jsx-runtime"),lt="memory-eternal",U="/memory-eternal/api",va=100,xa=["slots","locale"],Xt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedTotal:" \u5F20 / \u6587\u4EF6\u5171 ",importedTotalTail:" \u5F20",importedQuarantine:" \xB7 \u5F85\u5BA1\u6838 ",importedQuarantineTail:" \u5F20\uFF08\u9694\u79BB\u533A\uFF0C\u6279\u51C6\u540E\u624D\u53C2\u4E0E\u53EC\u56DE\uFF09",importedSkipped:" \xB7 \u8DF3\u8FC7 ",importedSkippedTail:" \u5F20\uFF08\u91CD\u590D\u6216\u7A7A\uFF09",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",refineTitle:"\u77DB\u76FE\u626B\u63CF",refineScan:"\u5F00\u59CB\u626B\u63CF",refineHint:"\u76F8\u4F3C\u53EF\u4EE5\u5408\u5E76\uFF0C\u77DB\u76FE\u5FC5\u987B\u4EBA\u5224\u65AD \u2014\u2014 \u626B\u63CF\u53EA\u8BFB\uFF0C\u9009\u62E9\u540E\u624D\u52A8\u6570\u636E\uFF08\u4FDD\u7559\u4E00\u5F20\u4F1A\u628A\u53E6\u4E00\u5F20\u653E\u8FDB\u56DE\u6536\u7AD9\uFF0C\u53EF\u8FD8\u539F\uFF09",refineIdle:"\u70B9\u300C\u5F00\u59CB\u626B\u63CF\u300D\uFF1A\u5148\u5BBD\u53EC\u56DE\u53EF\u80FD\u6709\u5173\u7CFB\u7684\u5361\u7247\u5BF9\uFF0C\u518D\u8BA9\u6A21\u578B\u5224\u65AD\u662F\u91CD\u590D / \u8865\u5145 / \u77DB\u76FE / \u65E0\u5173",refineNone:"\u8FD9\u4E00\u8F6E\u6CA1\u6709\u53D1\u73B0\u9700\u8981\u4F60\u88C1\u51B3\u7684\u5361\u7247\u5BF9 \u{1F389}",refineFail:"\u77DB\u76FE\u626B\u63CF\u5931\u8D25",refineApplied:"\u5DF2\u8BB0\u5F55\u4F60\u7684\u88C1\u51B3\uFF08\u4E0D\u4F1A\u91CD\u590D\u6253\u6270\uFF09",refineRel_duplicate:"\u91CD\u590D\uFF08\u53EF\u5408\u5E76\uFF09",refineRel_complement:"\u8865\u5145\uFF08\u90FD\u7559\u7740\uFF09",refineRel_conflict:"\u77DB\u76FE\uFF08\u9700\u4F60\u88C1\u51B3\uFF09",refineRel_unrelated:"\u65E0\u5173",refineKeepA:"\u4FDD\u7559 A",refineKeepB:"\u4FDD\u7559 B",refineKeepBoth:"\u90FD\u4FDD\u7559",refineMerge:"\u5408\u5E76",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",auditBodyFail:"\u6B63\u6587\u8BFB\u53D6\u5931\u8D25",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",pendingSyncNote:"\u6B64\u9875\u662F\u72EC\u7ACB Web \u9875\uFF1A\u4FDD\u5B58\u540E\u7531 DSH \u5BBF\u4E3B\u5E94\u7528\uFF08\u65B0\u7248\u5BBF\u4E3B\u4F1A\u88AB\u76F4\u63A5\u53EB\u9192\u3001\u5728\u8BF7\u6C42\u4E0A\u4E0B\u6587\u91CC\u5E94\u7528\uFF0C\u70B9\u4FDD\u5B58\u5373\u751F\u6548\uFF09\uFF1B\u82E5\u672C\u673A\u6CA1\u6709 DSH \u5BBF\u4E3B\u5728\u8FD0\u884C\uFF0C\u5219\u76F4\u63A5\u5199\u5165\u5171\u4EAB\u914D\u7F6E\u3001\u7ACB\u5373\u751F\u6548\u3002\u53EA\u6709\u5728\u5BF9\u63A5\u65E7\u7248\u5BBF\u4E3B\u65F6\u624D\u4F1A\u9000\u56DE\u300C\u6392\u961F\u7B49\u5B83\u81EA\u5DF1\u540C\u6B65\u300D\uFF0C\u90A3\u65F6\u53EF\u5728 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u91CC\u6539\u540C\u4E00\u9879\u3002",readonlyTitle:"\u5F53\u524D\u9875\u9762\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u914D\u7F6E",readonlyBody:"\u8FD9\u4E2A\u8FDB\u7A0B\u6CA1\u6709 DSH \u7684\u8BBE\u7F6E\u670D\u52A1\uFF08settings.update \u4E0D\u5B58\u5728\uFF09\uFF0C\u914D\u7F6E\u53EA\u80FD\u5728\u672C\u673A DSH \u91CC\u4FEE\u6539\uFF1A\u684C\u9762\u7248 \u2192 \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u3002",readonlyBtn:"\u53EA\u8BFB",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",vaultMulti:"\u591A\u5E93\uFF08\u6309\u9879\u76EE\u9694\u79BB\uFF09",vaultMultiHint:"\u7559\u7A7A\u5373\u5355\u5E93\uFF0C\u8001\u914D\u7F6E\u4E0D\u53D7\u5F71\u54CD",vaultNow:"\u5F53\u524D\u751F\u6548",vaultSource:"\u6765\u6E90",vaultWorkspace:"\u5F53\u524D workspace",vaultNamePh:"\u5E93\u540D\uFF0C\u5982 work",vaultPathPh:"\u76EE\u5F55\uFF0C\u5982 D:/vaults/work",vaultMatchPh:"\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u6309 workspace \u81EA\u52A8\u9009\u5E93\uFF09",vaultAdd:"\u6DFB\u52A0\u4E00\u4E2A\u5E93",vaultActive:"\u6FC0\u6D3B\u5E93",vaultActiveNone:"\u9ED8\u8BA4\u5E93\uFF08\u4E0D\u6307\u5B9A\uFF09",vaultSrcEnv:"\u73AF\u5883\u53D8\u91CF MEMORY_VAULT_DIR",vaultSrcProfile:"\u6FC0\u6D3B\u5E93\u914D\u7F6E",vaultSrcWorkspace:"\u6309\u9879\u76EE\u76EE\u5F55\u81EA\u52A8\u547D\u4E2D",vaultSrcVaultDir:"\u5355\u5E93\u914D\u7F6E vaultDir",vaultSrcDefault:"\u9ED8\u8BA4\u76EE\u5F55",fbNav:"\u53CD\u9988\u5F02\u5E38",fbTitle:"\u53CD\u9988\u5F02\u5E38\uFF08\u63D0\u4EA4\u5230 GitHub\uFF09",fbDesc:"\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF08\u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A\uFF09",fbDiag:"\u8BCA\u65AD\u4FE1\u606F\uFF08\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E key/token \u5DF2\u66FF\u6362\uFF09",fbCopyDiag:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",fbOpenIssue:"\u5728 GitHub \u63D0\u4EA4\uFF08\u5DF2\u9884\u586B\uFF09",fbCopyPrompt:"\u590D\u5236\u7ED9 AI \u7684\u63D0\u793A\u8BCD",fbCopiedDiag:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",fbCopiedPrompt:"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB AI \u5BF9\u8BDD\u6846\u5373\u53EF",fbCopyFail:"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u590D\u5236",fbWhy:"GitHub \u4E0D\u5141\u8BB8\u533F\u540D\u521B\u5EFA issue\uFF0C\u63D2\u4EF6\u91CC\u4E5F\u4E0D\u5E94\u5185\u7F6E token\uFF1A\u6240\u4EE5\u8FD9\u91CC\u628A\u6807\u9898 / \u6B63\u6587 / \u8BCA\u65AD\u90FD\u9884\u586B\u597D\uFF0C\u4F60\u53EA\u9700\u518D\u70B9\u4E00\u6B21 Submit\u3002",fbNeedDesc:"\u8BF7\u5148\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898",fbLoading:"\u6B63\u5728\u6536\u96C6\u8BCA\u65AD\u4FE1\u606F\u2026",fbDiagFail:"\u8BCA\u65AD\u63A5\u53E3\u4E0D\u53EF\u7528\uFF08\u72EC\u7ACB web \u6216\u65E7\u7248\u5BBF\u4E3B\uFF09\uFF0C\u8BF7\u624B\u52A8\u8865\u5145\u73AF\u5883\u4FE1\u606F",fbOr:"\u6216\u8005",fbSelectAll:"\u5168\u9009",toastApproved:"\u5DF2\u6279\u51C6",toastRejected:"\u5DF2\u9A73\u56DE",toastCardDeleted:"\u5DF2\u5220\u9664",toastRestored:"\u5DF2\u6062\u590D",toastPurged:"\u5DF2\u5F7B\u5E95\u5220\u9664",toastPurgedExpired:"\u5DF2\u6E05\u7406\u8FC7\u671F\u56DE\u6536\u7AD9",toastFailed:"\u64CD\u4F5C\u5931\u8D25",noSelection:"\u8BF7\u5148\u9009\u62E9\u8981\u5904\u7406\u7684\u5361\u7247",enabledLabel:"\u542F\u7528\u8BB0\u5FC6\u6838\u5FC3",vaultDirLabel:"\u8BB0\u5FC6\u5E93\u76EE\u5F55\uFF08\u5355\u5E93\uFF09",captureCooldownMs:"\u6C89\u6DC0\u51B7\u5374 (ms)",captureProvider:"\u84B8\u998F provider\uFF08\u7559\u7A7A\u81EA\u52A8\uFF09",captureModel:"\u84B8\u998F model\uFF08\u7559\u7A7A\u81EA\u52A8\uFF09",recallEmbedding:"\u8BED\u4E49\u53EC\u56DE provider\uFF08\u53EF\u9009\uFF09",sessionBudgetChars:"\u4F1A\u8BDD\u9884\u7B97 (\u5B57\u7B26)",saving:"\u4FDD\u5B58\u4E2D\u2026",savePending:"\u5DF2\u5199\u5165\u914D\u7F6E\u6587\u4EF6\uFF1B\u5BBF\u4E3B\u4ECD\u662F\u65E7\u7248\uFF0C\u91CD\u542F DSH \u540E\u5373\u4EE5\u65B0\u503C\u4E3A\u51C6\uFF08\u672C\u9762\u677F\u5DF2\u751F\u6548\uFF09",actionRunning:"\u5904\u7406\u4E2D\u2026",recycleEmptyHint:"\u56DE\u6536\u7AD9\u4E3A\u7A7A\uFF1A\u5220\u6389\u7684\u5361\u7247\u4F1A\u5148\u653E\u5230\u8FD9\u91CC\uFF0C\u4FDD\u7559 {days} \u5929\u540E\u81EA\u52A8\u6E05\u7406\u3002",recyclePurgeAll:"\u6E05\u7A7A\u56DE\u6536\u7AD9",fbCopyManual:"\u81EA\u52A8\u590D\u5236\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u5DF2\u628A\u5185\u5BB9\u653E\u5728\u4E0B\u9762\uFF1A\u70B9\u300C\u5168\u9009\u300D\u518D\u6309 Ctrl+C",vcPage:"\u9875\u9762\u811A\u672C",vcPageStale:"\u26A0 \u5F53\u524D\u9875\u9762\u4ECD\u5728\u8FD0\u884C\u65E7\u7248\u811A\u672C\uFF08\u9875\u9762 v{page} / \u78C1\u76D8 v{disk}\uFF09\uFF1A\u6309 Ctrl+F5 \u5237\u65B0\u9875\u9762\u5373\u751F\u6548\uFF1B\u82E5\u300C\u8FD0\u884C\u4E2D\u300D\u4ECD\u662F\u65E7\u7248\u53F7\uFF0C\u5219\u8FD8\u9700\u91CD\u542F\u684C\u9762\u7248 / DSH",vcLoaded:"\u8FD0\u884C\u4E2D\uFF08\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\uFF09",vcResident:"\u5E38\u9A7B\u5B9E\u4F8B",vcOnDisk:"\u78C1\u76D8\u5B89\u88C5",vcLatest:"npm \u6700\u65B0",vcStale:"\u78C1\u76D8\u5DF2\u5B89\u88C5 v{disk}\uFF0C\u4F46\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\u4ECD\u52A0\u8F7D v{loaded} \u2014\u2014 \u70B9\u300C\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B\u300D\u5373\u53EF\u7528\u65B0\u4EE3\u7801\u91CD\u542F\u5B83\uFF08\u4E0D\u7528\u91CD\u542F DSH\uFF09",vcRestart:"\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B",vcRestarting:"\u91CD\u542F\u4E2D\u2026",vcRestartSent:"\u5DF2\u8C03\u5EA6\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B\uFF1A\u7EA6 3-8 \u79D2\u540E\u65B0\u8FDB\u7A0B\u63A5\u7BA1\uFF0C\u8BF7\u7A0D\u7B49\u518D\u5237\u65B0\u9875\u9762\uFF08Ctrl+F5\uFF09",vcRestartCurrent:"\u5E38\u9A7B\u5B9E\u4F8B\u5DF2\u7ECF\u662F\u6700\u65B0\u7248\uFF0C\u65E0\u9700\u91CD\u542F",vcRestartFail:"\u91CD\u542F\u8BF7\u6C42\u5931\u8D25",vcRestartNoRoute:"\u5F53\u524D\u9875\u9762\u5BF9\u63A5\u7684\u8FDB\u7A0B\u8FD8\u662F\u65E7\u7248\uFF08\u6CA1\u6709\u8FD9\u4E2A\u63A5\u53E3\uFF09\uFF1A\u8BF7\u91CD\u542F\u684C\u9762\u7248 / DSH \u540E\u518D\u8BD5\uFF0C\u6216\u6267\u884C {cmd}",vcHostStale:"\u4E0A\u65B9\u7684\u300C\u8FD0\u884C\u4E2D\u300D\u6765\u81EA\u670D\u52A1\u672C\u9875\u7684\u8FDB\u7A0B\uFF1B\u5E38\u9A7B\u5B9E\u4F8B\u5DF2\u662F\u65B0\u7248 \u2014\u2014 \u8981\u8BA9\u5B83\u4E5F\u53D8\u6210\u65B0\u7248\u53F7\uFF0C\u9700\u91CD\u542F\u684C\u9762\u7248 / DSH",vcResidentDownShort:"\u672A\u8FD0\u884C",vcResidentDown:"\u5E38\u9A7B\u5B9E\u4F8B\u6CA1\u5728\u8FD0\u884C\uFF08\u7AEF\u53E3 {port} \u65E0\u54CD\u5E94\uFF09\u2014\u2014 \u70B9\u4E0B\u9762\u7684\u6309\u94AE\u7528\u65B0\u4EE3\u7801\u628A\u5B83\u62C9\u8D77\u6765\uFF1B\u62C9\u4E0D\u8D77\u6765\u65F6\u6267\u884C {cmd}\uFF0C\u5E76\u8D34\u4E00\u4E0B dsh-memory status \u7684\u8F93\u51FA",vcResidentUnmanagedShort:"\u672A\u6258\u7BA1",vcResidentUnmanaged:"\u5E38\u9A7B\u5B9E\u4F8B\u5728\u670D\u52A1 v{served}\uFF0C\u4F46**\u6CA1\u6709\u770B\u95E8\u72D7\u4FDD\u6D3B**\uFF08\u505C\u6B62 / \u786C\u6740\u540E\u6B8B\u7559\u7684\u5B64\u513F\uFF09\u2014\u2014 \u70B9\u4E0B\u9762\u7684\u6309\u94AE\u628A\u5B83\u91CD\u65B0\u6258\u7BA1\uFF08\u91CD\u65B0\u62C9\u4E00\u4E2A\u770B\u95E8\u72D7 + \u65B0\u5B9E\u4F8B\uFF09\uFF1B\u4E5F\u53EF\u4EE5\u6267\u884C {cmd}",vcOutdated:"\u6709\u65B0\u7248\u672C",vcUpToDate:"\u5DF2\u662F\u6700\u65B0",vcCheck:"\u68C0\u67E5\u66F4\u65B0",checking:"\u68C0\u67E5\u4E2D\u2026",vcCheckFail:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",secretHint:"\u51ED\u8BC1\u53D6\u7528\u63D0\u793A\uFF08\u6CE8\u5165\u6BCF\u4E2A\u4F1A\u8BDD\uFF09",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoRestartOnDrift:"\u7248\u672C\u6F02\u79FB\u81EA\u52A8\u91CD\u542F\u5E38\u9A7B\u5B9E\u4F8B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",savedDirect:"\u672C\u673A\u6CA1\u6709 DSH \u5BBF\u4E3B\u5728\u8FD0\u884C\uFF0C\u5DF2\u76F4\u63A5\u5199\u5165\u5171\u4EAB\u914D\u7F6E\uFF08hooks / MCP / \u72EC\u7ACB\u9875\u7ACB\u5373\u751F\u6548\uFF09",savedApplied:"\u5DF2\u4FDD\u5B58\u5E76\u751F\u6548\uFF08\u5BBF\u4E3B\u5DF2\u5728\u8BF7\u6C42\u4E0A\u4E0B\u6587\u91CC\u5E94\u7528\uFF09",saveQueued:"\u5DF2\u4EA4\u7ED9 DSH \u5BBF\u4E3B\u540C\u6B65\uFF0C\u5C1A\u672A\u786E\u8BA4\u751F\u6548",saveHostGuard:"\u8BE5\u5BBF\u4E3B\u4E0D\u5141\u8BB8\u63D2\u4EF6\u4ECE\u81EA\u5DF1\u7684\u56DE\u8C03\u4E0A\u4E0B\u6587\u91CC\u5199\u914D\u7F6E\uFF1B\u8BF7\u5728\u300CDSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u300D\u91CC\u6539\u540C\u4E00\u9879\uFF0C\u6216\u7F16\u8F91 profile \u7684\u914D\u7F6E\u8865\u4E01\u5C42",saveFailHint:"\u5BBF\u4E3B\u4FA7\u672A\u5E94\u7528\uFF0C\u8BE6\u89C1\u300C\u53CD\u9988\u5F02\u5E38\u300D\u91CC\u7684\u8BCA\u65AD\u4FE1\u606F",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548\uFF1B\u5DF2\u6709\u5E38\u9A7B watchdog \u4E0D\u4F1A\u88AB\u81EA\u52A8\u505C\u6389\uFF0C\u9700 dsh-memory stop / restart\uFF08#19\uFF09",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
17
17
 
18
18
  ## \u80CC\u666F
19
19
  - \u95EE\u9898\u63CF\u8FF0
@@ -58,7 +58,7 @@ var aa=Object.create;var St=Object.defineProperty;var na=Object.getOwnPropertyDe
58
58
  -
59
59
 
60
60
  ## \u98CE\u9669/\u963B\u585E
61
- - `},Jt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedTotal:" / of ",importedTotalTail:"",importedQuarantine:" \xB7 pending review ",importedQuarantineTail:" (quarantined until approved)",importedSkipped:" \xB7 skipped ",importedSkippedTail:" (duplicate or empty)",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",auditBodyFail:"Failed to load the card body",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",pendingSyncNote:'This is the standalone web page: the DSH host applies a save (a current host is woken up and applies it in a request context, so saving takes effect immediately); when no DSH host is running here the change goes straight into the shared config. Only an older host falls back to "queued until it syncs on its own" \u2014 in that case change the same option under DSH Settings \u2192 Memory.',readonlyTitle:"This page is read-only; config cannot be saved here",readonlyBody:"This process has no DSH settings service (settings.update is unavailable). Edit the config in DSH: desktop app \u2192 Settings \u2192 Memory.",readonlyBtn:"Read-only",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",vaultMulti:"Multiple vaults (per project)",vaultMultiHint:"Empty = single vault; existing setups unaffected",vaultNow:"Active now",vaultSource:"Source",vaultWorkspace:"Current workspace",vaultNamePh:"Name, e.g. work",vaultPathPh:"Directory, e.g. D:/vaults/work",vaultMatchPh:"Project dir (optional, auto-select by workspace)",vaultAdd:"Add a vault",vaultActive:"Active vault",vaultActiveNone:"Default vault (unset)",vaultSrcEnv:"env MEMORY_VAULT_DIR",vaultSrcProfile:"activeVault profile",vaultSrcWorkspace:"matched by project dir",vaultSrcVaultDir:"vaultDir setting",vaultSrcDefault:"default directory",fbNav:"Report a bug",fbTitle:"Report a bug (files on GitHub)",fbDesc:"Describe the problem (symptoms / steps / expected)",fbDiag:"Diagnostics (auto-redacted: home dir and keys/tokens replaced)",fbCopyDiag:"Copy diagnostics",fbOpenIssue:"Open prefilled issue on GitHub",fbCopyPrompt:"Copy AI prompt",fbCopiedDiag:"Diagnostics copied",fbCopiedPrompt:"Prompt copied \u2014 paste it into your AI chat",fbCopyFail:"Copy failed; please select and copy manually",fbWhy:"GitHub does not allow anonymous issue creation and the plugin must not ship a token: so the title, body and diagnostics are pre-filled \u2014 you just click Submit.",fbNeedDesc:"Please describe the problem first",fbLoading:"Collecting diagnostics\u2026",fbDiagFail:"Diagnostics endpoint unavailable (standalone web or older host); please add environment info manually",fbOr:"or",fbSelectAll:"Select all",toastApproved:"approved",toastRejected:"rejected",toastCardDeleted:"deleted",toastRestored:"restored",toastPurged:"permanently deleted",toastPurgedExpired:"expired recycle entries purged",toastFailed:"Action failed",noSelection:"Select the cards to act on first",enabledLabel:"Enable memory core",vaultDirLabel:"Vault directory (single)",captureCooldownMs:"Capture cooldown (ms)",captureProvider:"Distill provider (auto if empty)",captureModel:"Distill model (auto if empty)",recallEmbedding:"Semantic recall provider (optional)",sessionBudgetChars:"Session budget (chars)",saving:"Saving\u2026",savePending:"Saved to the config file; the host half is still the old build, so restart DSH to make it effective (already applied in this panel)",saveInvalid:"Some field values are invalid; nothing was submitted",invalidField:'"{field}" must be a number between {min} and {max} (now: {value})',actionRunning:"Working\u2026",recycleEmptyHint:"Recycle bin is empty: deleted cards land here first and are purged automatically after {days} days.",recyclePurgeAll:"Empty recycle bin",fbCopyManual:"Auto-copy was blocked by the browser \u2014 the text is below: click Select all, then Ctrl+C",vcLoaded:"running (process serving this page)",vcResident:"resident instance",vcOnDisk:"on disk",vcLatest:"npm latest",vcStale:'v{disk} is installed on disk but the process serving this page still has v{loaded} loaded \u2014 click "Restart resident instance" to restart it on the new code (no DSH restart needed)',vcRestart:"Restart resident instance",vcRestarting:"Restarting\u2026",vcRestartSent:"Resident restart scheduled: the new process takes over in ~3-8s \u2014 refresh the page (Ctrl+F5) shortly",vcRestartCurrent:"The resident instance is already up to date \u2014 no restart needed",vcRestartFail:"Restart request failed",vcRestartNoRoute:"The process serving this page is still the old build (no such endpoint): restart the desktop app / DSH and retry, or run {cmd}",vcHostStale:'The "running" chip above comes from the process serving this page; the resident instance is already current \u2014 restart the desktop app / DSH to refresh that chip',vcResidentDownShort:"not running",vcResidentDown:"The resident instance is not running (no response on port {port}) \u2014 use the button below to bring it up on the new code; if that fails run {cmd} and share the output of dsh-memory status",vcResidentUnmanagedShort:"unmanaged",vcResidentUnmanaged:"The resident instance serves v{served} but has **no watchdog keeping it alive** (an orphan left by a stop or a hard kill) \u2014 use the button below to put it back under management (a fresh watchdog plus a new instance), or run {cmd}",vcPage:"Page script",vcPageStale:"\u26A0 This page is still running an older script (page v{page} / disk v{disk}): press Ctrl+F5 to refresh. If the running version is still old, restart the desktop app / DSH as well",vcOutdated:"update available",vcUpToDate:"up to date",vcCheck:"Check for updates",checking:"Checking\u2026",vcCheckFail:"Update check failed",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",secretHint:"Credential hint (injected into every session)",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoRestartOnDrift:"Auto-restart resident on version drift",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",savedDirect:"No DSH host is running here, so the change went straight into the shared config (hooks / MCP / the standalone page pick it up immediately)",savedApplied:"Saved and applied (the host applied it in a request context)",saveQueued:"Handed to the DSH host for sync \u2014 not confirmed applied yet",saveHostGuard:"This host does not let a plugin write config from its own callback context; change the same option under DSH Settings \u2192 Memory, or edit the profile patch layer",saveFailHint:"the host did not apply it \u2014 see Diagnostics under Report a bug",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH; a resident watchdog is never stopped automatically \u2014 use dsh-memory stop / restart (#19)",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
61
+ - `},Jt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedTotal:" / of ",importedTotalTail:"",importedQuarantine:" \xB7 pending review ",importedQuarantineTail:" (quarantined until approved)",importedSkipped:" \xB7 skipped ",importedSkippedTail:" (duplicate or empty)",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",refineTitle:"Conflict scan",refineScan:"Scan now",refineHint:"Similar cards can be merged; conflicts must be judged by a human \u2014 the scan is read-only, and data only moves after you choose (keeping one moves the other to the recycle bin, recoverable)",refineIdle:'Hit "Scan now": recall possibly-related card pairs, then let the model classify each as duplicate / complement / conflict / unrelated',refineNone:"No card pairs need your ruling this round \u{1F389}",refineFail:"Conflict scan failed",refineApplied:"Your ruling was recorded (it will not ask again)",refineRel_duplicate:"Duplicate (mergeable)",refineRel_complement:"Complement (keep both)",refineRel_conflict:"Conflict (needs your ruling)",refineRel_unrelated:"Unrelated",refineKeepA:"Keep A",refineKeepB:"Keep B",refineKeepBoth:"Keep both",refineMerge:"Merge",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",auditBodyFail:"Failed to load the card body",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",pendingSyncNote:'This is the standalone web page: the DSH host applies a save (a current host is woken up and applies it in a request context, so saving takes effect immediately); when no DSH host is running here the change goes straight into the shared config. Only an older host falls back to "queued until it syncs on its own" \u2014 in that case change the same option under DSH Settings \u2192 Memory.',readonlyTitle:"This page is read-only; config cannot be saved here",readonlyBody:"This process has no DSH settings service (settings.update is unavailable). Edit the config in DSH: desktop app \u2192 Settings \u2192 Memory.",readonlyBtn:"Read-only",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",vaultMulti:"Multiple vaults (per project)",vaultMultiHint:"Empty = single vault; existing setups unaffected",vaultNow:"Active now",vaultSource:"Source",vaultWorkspace:"Current workspace",vaultNamePh:"Name, e.g. work",vaultPathPh:"Directory, e.g. D:/vaults/work",vaultMatchPh:"Project dir (optional, auto-select by workspace)",vaultAdd:"Add a vault",vaultActive:"Active vault",vaultActiveNone:"Default vault (unset)",vaultSrcEnv:"env MEMORY_VAULT_DIR",vaultSrcProfile:"activeVault profile",vaultSrcWorkspace:"matched by project dir",vaultSrcVaultDir:"vaultDir setting",vaultSrcDefault:"default directory",fbNav:"Report a bug",fbTitle:"Report a bug (files on GitHub)",fbDesc:"Describe the problem (symptoms / steps / expected)",fbDiag:"Diagnostics (auto-redacted: home dir and keys/tokens replaced)",fbCopyDiag:"Copy diagnostics",fbOpenIssue:"Open prefilled issue on GitHub",fbCopyPrompt:"Copy AI prompt",fbCopiedDiag:"Diagnostics copied",fbCopiedPrompt:"Prompt copied \u2014 paste it into your AI chat",fbCopyFail:"Copy failed; please select and copy manually",fbWhy:"GitHub does not allow anonymous issue creation and the plugin must not ship a token: so the title, body and diagnostics are pre-filled \u2014 you just click Submit.",fbNeedDesc:"Please describe the problem first",fbLoading:"Collecting diagnostics\u2026",fbDiagFail:"Diagnostics endpoint unavailable (standalone web or older host); please add environment info manually",fbOr:"or",fbSelectAll:"Select all",toastApproved:"approved",toastRejected:"rejected",toastCardDeleted:"deleted",toastRestored:"restored",toastPurged:"permanently deleted",toastPurgedExpired:"expired recycle entries purged",toastFailed:"Action failed",noSelection:"Select the cards to act on first",enabledLabel:"Enable memory core",vaultDirLabel:"Vault directory (single)",captureCooldownMs:"Capture cooldown (ms)",captureProvider:"Distill provider (auto if empty)",captureModel:"Distill model (auto if empty)",recallEmbedding:"Semantic recall provider (optional)",sessionBudgetChars:"Session budget (chars)",saving:"Saving\u2026",savePending:"Saved to the config file; the host half is still the old build, so restart DSH to make it effective (already applied in this panel)",saveInvalid:"Some field values are invalid; nothing was submitted",invalidField:'"{field}" must be a number between {min} and {max} (now: {value})',actionRunning:"Working\u2026",recycleEmptyHint:"Recycle bin is empty: deleted cards land here first and are purged automatically after {days} days.",recyclePurgeAll:"Empty recycle bin",fbCopyManual:"Auto-copy was blocked by the browser \u2014 the text is below: click Select all, then Ctrl+C",vcLoaded:"running (process serving this page)",vcResident:"resident instance",vcOnDisk:"on disk",vcLatest:"npm latest",vcStale:'v{disk} is installed on disk but the process serving this page still has v{loaded} loaded \u2014 click "Restart resident instance" to restart it on the new code (no DSH restart needed)',vcRestart:"Restart resident instance",vcRestarting:"Restarting\u2026",vcRestartSent:"Resident restart scheduled: the new process takes over in ~3-8s \u2014 refresh the page (Ctrl+F5) shortly",vcRestartCurrent:"The resident instance is already up to date \u2014 no restart needed",vcRestartFail:"Restart request failed",vcRestartNoRoute:"The process serving this page is still the old build (no such endpoint): restart the desktop app / DSH and retry, or run {cmd}",vcHostStale:'The "running" chip above comes from the process serving this page; the resident instance is already current \u2014 restart the desktop app / DSH to refresh that chip',vcResidentDownShort:"not running",vcResidentDown:"The resident instance is not running (no response on port {port}) \u2014 use the button below to bring it up on the new code; if that fails run {cmd} and share the output of dsh-memory status",vcResidentUnmanagedShort:"unmanaged",vcResidentUnmanaged:"The resident instance serves v{served} but has **no watchdog keeping it alive** (an orphan left by a stop or a hard kill) \u2014 use the button below to put it back under management (a fresh watchdog plus a new instance), or run {cmd}",vcPage:"Page script",vcPageStale:"\u26A0 This page is still running an older script (page v{page} / disk v{disk}): press Ctrl+F5 to refresh. If the running version is still old, restart the desktop app / DSH as well",vcOutdated:"update available",vcUpToDate:"up to date",vcCheck:"Check for updates",checking:"Checking\u2026",vcCheckFail:"Update check failed",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",secretHint:"Credential hint (injected into every session)",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoRestartOnDrift:"Auto-restart resident on version drift",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",savedDirect:"No DSH host is running here, so the change went straight into the shared config (hooks / MCP / the standalone page pick it up immediately)",savedApplied:"Saved and applied (the host applied it in a request context)",saveQueued:"Handed to the DSH host for sync \u2014 not confirmed applied yet",saveHostGuard:"This host does not let a plugin write config from its own callback context; change the same option under DSH Settings \u2192 Memory, or edit the profile patch layer",saveFailHint:"the host did not apply it \u2014 see Diagnostics under Report a bug",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH; a resident watchdog is never stopped automatically \u2014 use dsh-memory stop / restart (#19)",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
62
62
 
63
63
  ## Background
64
64
  - Problem
@@ -298,13 +298,13 @@ Option A, because:
298
298
  height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
299
299
  max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
300
300
  }
301
- `;function Sa(t){t.effect(()=>t.locale.register(lt,{zh:Xt,en:Jt}),"memory-eternal: locale");let o=t.locale.bind(lt);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:lt,order:25,label:()=>o("nav"),locale:lt,inject:()=>({})},()=>n.default.createElement(Na,{t:o}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${lt}:footer`,order:100,label:()=>o("nav"),locale:lt,inject:()=>({})},r=>n.default.createElement(Ma,{t:o,locale:t.locale,wide:!(r&&r.wide===!1)}))),"memory-eternal: sidebar footer action")}function Ca(){let[t,o]=(0,n.useState)(_+"/ui/app");return(0,n.useEffect)(()=>{let r=!0,m=()=>fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{r&&d&&d.ok&&d.alive!==!1&&d.url&&o(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{});return fetch(_+"/ui/app",{method:"HEAD"}).then(d=>{if(r&&!d.ok)return m()}).catch(()=>r?m():void 0),()=>{r=!1}},[]),t}function Na({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsx)(ta,{t,onReload:()=>{},version:0})]})}function Ma({t,locale:o,wide:r}){let[m,d]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${r?"":" rail"}`,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>d(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Qt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),m&&(0,e.jsx)(Da,{t,locale:o,onClose:()=>d(!1)})]})}function Da({t,locale:o,onClose:r,tab:m}){let[d,i]=(0,n.useState)(!1),S=(0,n.useRef)(null),M=Ca(),k=(0,n.useCallback)(I=>o&&typeof o.subscribe=="function"?o.subscribe(I):()=>{},[o]),E=(0,n.useCallback)(()=>o&&typeof o.getSnapshot=="function"?o.getSnapshot():null,[o]),C=(0,n.useSyncExternalStore)(k,E),h=C&&(C.active==="zh"||C.active==="en")?C.active:null,u=(0,n.useRef)(null);u.current===null&&h&&(u.current=h);let z=(0,n.useMemo)(()=>{let I=u.current?`lang=${u.current}`:"";if(m==="config")return`${_}/ui/config?tab=config${I?`&${I}`:""}`;let w=M.replace(/\/$/,""),R=w.endsWith("/ui/app")?"?":"/?";return m?`${w}${R}tab=${m}${I?`&${I}`:""}`:I?`${w}${R}${I}`:M},[M,m]);return(0,n.useEffect)(()=>{let I=S.current&&S.current.contentWindow;I&&h&&I.postMessage({source:"memory-eternal",type:"locale",lang:h},"*")},[h]),(0,n.useEffect)(()=>{let I=w=>{w.key==="Escape"&&r()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[r]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:r,children:[(0,e.jsx)("style",{children:He}),(0,e.jsx)("div",{className:"me-modal"+(d?" me-modal-full":""),onClick:I=>I.stopPropagation(),children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>i(I=>!I),"aria-label":t(d?"exitFullscreen":"enterFullscreen"),title:t(d?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:d?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:r,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{ref:S,src:z,title:"memory-eternal",allow:"clipboard-write; clipboard-read",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Qt(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}var bt="0.10.21";function za({t,inModal:o,onClose:r,onFull:m,full:d}){let[i,S]=(0,n.useState)(null),[M,k]=(0,n.useState)([]),[E,C]=(0,n.useState)(!0),[h,u]=(0,n.useState)(null),[z,I]=(0,n.useState)(""),[w,R]=(0,n.useState)("all"),[D,O]=(0,n.useState)(""),[J,ve]=(0,n.useState)("all"),[V,Le]=(0,n.useState)("all"),[U,ue]=(0,n.useState)(()=>{try{let g=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),x={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(g&&x[g])return x[g]}catch{}return"cards"}),[re,H]=(0,n.useState)(()=>new Set([U])),y=(0,n.useCallback)(g=>{H(x=>x.has(g)?x:new Set(x).add(g)),ue(g)},[]),[j,v]=(0,n.useState)("recent"),[te,K]=(0,n.useState)(null),X=(0,n.useRef)(null),oe=(0,n.useRef)(null),[b,$]=(0,n.useState)(!1),[se,Y]=(0,n.useState)(null),[ae,he]=(0,n.useState)(!1),[Ae,De]=(0,n.useState)(!1),[we,Be]=(0,n.useState)(!0),[Pe,ze]=(0,n.useState)(null),[Ce,tt]=(0,n.useState)(0),at=(0,n.useCallback)(()=>tt(g=>g+1),[]),Ke=i?.quarantine?.pending??0,qe=i?.quarantine?.deleted??0,de=(0,n.useRef)(null),[Re,ke]=(0,n.useState)(0),[c,s]=(0,n.useState)(!1),B=(0,n.useRef)(null),ie=(0,n.useRef)(null),ce=(0,n.useCallback)(async(g=w,x=D,L=V,ne={})=>{let q=ne.append===!0;try{q?s(!0):(C(!0),I(""));let ge=new URLSearchParams;g&&g!=="all"&&ge.set("kind",g),x.trim()&&ge.set("q",x.trim()),ge.set("status",L||"all"),ge.set("limit",String(va)),ge.set("offset",String(ne.offset||0)),j==="title"&&ge.set("sort","title");let Te=await(await fetch(`${_}/cards?${ge.toString()}`)).json();if(Te.ok){let Ve=Te.cards||[];k(je=>q?[...je,...Ve.filter(Ye=>!je.some(vt=>vt.path===Ye.path))]:Ve),ke(Number(Te.total)||Ve.length)}}catch(ge){I(String(ge&&ge.message?ge.message:ge))}finally{q?s(!1):C(!1)}},[w,D,V,j]),me=(0,n.useCallback)(async()=>{try{let[g,x]=await Promise.all([fetch(`${_}/overview`).then(L=>L.json()),fetch(`${_}/capture-log`).then(L=>L.json()).catch(()=>null)]);g.ok&&S(g),u(x&&x.ok&&x.available&&x.health||null)}catch(g){I(String(g&&g.message?g.message:g))}finally{C(!1)}},[]),a=async g=>{try{let L=await(await fetch(`${_}/delete?path=${encodeURIComponent(g)}`)).json();L.ok?(K({ok:!0,msg:t("deleted")}),await me(),at()):K({ok:!1,msg:L.error||t("deleteFail")})}catch{K({ok:!1,msg:t("deleteFail")})}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>K(null),2e3)};(0,n.useEffect)(()=>(me(),()=>{de.current&&clearTimeout(de.current)}),[me]);let be=g=>{O(g),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>ce(w,g,V),280)},it=g=>{R(g),ce(g,D,V)};(0,n.useEffect)(()=>{U==="cards"&&ce(w,D,V)},[V,U,Ce,j]),(0,n.useEffect)(()=>{if(U!=="cards"||E||c||M.length>=Re)return;let g=B.current,x=ie.current;if(!g)return;let L=new IntersectionObserver(ne=>{ne[0]&&ne[0].isIntersecting&&ce(w,D,V,{append:!0,offset:M.length})},{root:x||null,rootMargin:"400px"});return L.observe(g),()=>L.disconnect()},[U,M,Re,E,c,w,D,V,ce]);let Ne=async g=>{try{let x=g.status;if(!x&&g.path)try{let Me=((await fetch(`${_}/cards?status=all&q=${encodeURIComponent(g.title||"")}&limit=50`).then(Te=>Te.json())).cards||[]).find(Te=>Te.path===g.path);Me&&(x=Me.status)}catch{}let L=x&&x!=="approved"?`&status=${encodeURIComponent(x)}`:"",ne=await fetch(`${_}/card?path=${encodeURIComponent(g.path||g.id)}${L}`),q=await ne.json();q.ok?Y({path:q.path,title:g.title,text:q.text}):I(q.error||`HTTP ${ne.status}`)}catch(x){I(String(x&&x.message?x.message:x))}},l=async(g,x)=>{$(!0);try{let L=await fetch(`${_}/export`);if(!L.ok)throw new Error("HTTP "+L.status);let ne=await L.json();if(!ne.ok)throw new Error(ne.error||"export failed");let q,ge,Me;if(g==="json"){ge="memory-vault.json",Me="application/json";let je=ne.cards.map(Ye=>({path:Ye.path,title:Ye.title,kind:Ye.kind,status:Ye.status,store:Ye.store,text:Ye.text}));q=JSON.stringify({format:ne.format||"memory-eternal-vault",formatVersion:ne.formatVersion||1,exportedAt:ne.exportedAt||new Date().toISOString(),count:je.length,cards:je},null,2)}else ge="memory-vault.md",Me="text/markdown;charset=utf-8",q=ne.cards.map(je=>je.text.trim()).filter(Boolean).join(`
301
+ `;function Sa(t){t.effect(()=>t.locale.register(lt,{zh:Xt,en:Jt}),"memory-eternal: locale");let o=t.locale.bind(lt);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:lt,order:25,label:()=>o("nav"),locale:lt,inject:()=>({})},()=>n.default.createElement(Na,{t:o}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${lt}:footer`,order:100,label:()=>o("nav"),locale:lt,inject:()=>({})},r=>n.default.createElement(Ma,{t:o,locale:t.locale,wide:!(r&&r.wide===!1)}))),"memory-eternal: sidebar footer action")}function Ca(){let[t,o]=(0,n.useState)(U+"/ui/app");return(0,n.useEffect)(()=>{let r=!0,g=()=>fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{r&&d&&d.ok&&d.alive!==!1&&d.url&&o(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{});return fetch(U+"/ui/app",{method:"HEAD"}).then(d=>{if(r&&!d.ok)return g()}).catch(()=>r?g():void 0),()=>{r=!1}},[]),t}function Na({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsx)(ta,{t,onReload:()=>{},version:0})]})}function Ma({t,locale:o,wide:r}){let[g,d]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${r?"":" rail"}`,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>d(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Qt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),g&&(0,e.jsx)(Da,{t,locale:o,onClose:()=>d(!1)})]})}function Da({t,locale:o,onClose:r,tab:g}){let[d,i]=(0,n.useState)(!1),k=(0,n.useRef)(null),M=Ca(),w=(0,n.useCallback)(I=>o&&typeof o.subscribe=="function"?o.subscribe(I):()=>{},[o]),j=(0,n.useCallback)(()=>o&&typeof o.getSnapshot=="function"?o.getSnapshot():null,[o]),S=(0,n.useSyncExternalStore)(w,j),h=S&&(S.active==="zh"||S.active==="en")?S.active:null,f=(0,n.useRef)(null);f.current===null&&h&&(f.current=h);let T=(0,n.useMemo)(()=>{let I=f.current?`lang=${f.current}`:"";if(g==="config")return`${U}/ui/config?tab=config${I?`&${I}`:""}`;let x=M.replace(/\/$/,""),D=x.endsWith("/ui/app")?"?":"/?";return g?`${x}${D}tab=${g}${I?`&${I}`:""}`:I?`${x}${D}${I}`:M},[M,g]);return(0,n.useEffect)(()=>{let I=k.current&&k.current.contentWindow;I&&h&&I.postMessage({source:"memory-eternal",type:"locale",lang:h},"*")},[h]),(0,n.useEffect)(()=>{let I=x=>{x.key==="Escape"&&r()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[r]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:r,children:[(0,e.jsx)("style",{children:He}),(0,e.jsx)("div",{className:"me-modal"+(d?" me-modal-full":""),onClick:I=>I.stopPropagation(),children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>i(I=>!I),"aria-label":t(d?"exitFullscreen":"enterFullscreen"),title:t(d?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:d?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:r,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{ref:k,src:T,title:"memory-eternal",allow:"clipboard-write; clipboard-read",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Qt(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}var bt="0.10.22";function Ta({t,inModal:o,onClose:r,onFull:g,full:d}){let[i,k]=(0,n.useState)(null),[M,w]=(0,n.useState)([]),[j,S]=(0,n.useState)(!0),[h,f]=(0,n.useState)(null),[T,I]=(0,n.useState)(""),[x,D]=(0,n.useState)("all"),[C,$]=(0,n.useState)(""),[Z,he]=(0,n.useState)("all"),[V,Le]=(0,n.useState)("all"),[K,de]=(0,n.useState)(()=>{try{let b=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),v={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(b&&v[b])return v[b]}catch{}return"cards"}),[ie,O]=(0,n.useState)(()=>new Set([K])),ae=(0,n.useCallback)(b=>{O(v=>v.has(b)?v:new Set(v).add(b)),de(b)},[]),[ye,R]=(0,n.useState)("recent"),[ve,p]=(0,n.useState)(null),L=(0,n.useRef)(null),G=(0,n.useRef)(null),[u,P]=(0,n.useState)(!1),[X,B]=(0,n.useState)(null),[Y,fe]=(0,n.useState)(!1),[Ae,De]=(0,n.useState)(!1),[we,Be]=(0,n.useState)(!0),[Pe,Te]=(0,n.useState)(null),[Ce,tt]=(0,n.useState)(0),at=(0,n.useCallback)(()=>tt(b=>b+1),[]),Ke=i?.quarantine?.pending??0,qe=i?.quarantine?.deleted??0,se=(0,n.useRef)(null),[Re,ke]=(0,n.useState)(0),[c,s]=(0,n.useState)(!1),F=(0,n.useRef)(null),oe=(0,n.useRef)(null),le=(0,n.useCallback)(async(b=x,v=C,A=V,ne={})=>{let q=ne.append===!0;try{q?s(!0):(S(!0),I(""));let ue=new URLSearchParams;b&&b!=="all"&&ue.set("kind",b),v.trim()&&ue.set("q",v.trim()),ue.set("status",A||"all"),ue.set("limit",String(va)),ue.set("offset",String(ne.offset||0)),ye==="title"&&ue.set("sort","title");let ze=await(await fetch(`${U}/cards?${ue.toString()}`)).json();if(ze.ok){let Ve=ze.cards||[];w(je=>q?[...je,...Ve.filter(Ye=>!je.some(vt=>vt.path===Ye.path))]:Ve),ke(Number(ze.total)||Ve.length)}}catch(ue){I(String(ue&&ue.message?ue.message:ue))}finally{q?s(!1):S(!1)}},[x,C,V,ye]),pe=(0,n.useCallback)(async()=>{try{let[b,v]=await Promise.all([fetch(`${U}/overview`).then(A=>A.json()),fetch(`${U}/capture-log`).then(A=>A.json()).catch(()=>null)]);b.ok&&k(b),f(v&&v.ok&&v.available&&v.health||null)}catch(b){I(String(b&&b.message?b.message:b))}finally{S(!1)}},[]),a=async b=>{try{let A=await(await fetch(`${U}/delete?path=${encodeURIComponent(b)}`)).json();A.ok?(p({ok:!0,msg:t("deleted")}),await pe(),at()):p({ok:!1,msg:A.error||t("deleteFail")})}catch{p({ok:!1,msg:t("deleteFail")})}L.current&&clearTimeout(L.current),L.current=setTimeout(()=>p(null),2e3)};(0,n.useEffect)(()=>(pe(),()=>{se.current&&clearTimeout(se.current)}),[pe]);let ge=b=>{$(b),se.current&&clearTimeout(se.current),se.current=setTimeout(()=>le(x,b,V),280)},it=b=>{D(b),le(b,C,V)};(0,n.useEffect)(()=>{K==="cards"&&le(x,C,V)},[V,K,Ce,ye]),(0,n.useEffect)(()=>{if(K!=="cards"||j||c||M.length>=Re)return;let b=F.current,v=oe.current;if(!b)return;let A=new IntersectionObserver(ne=>{ne[0]&&ne[0].isIntersecting&&le(x,C,V,{append:!0,offset:M.length})},{root:v||null,rootMargin:"400px"});return A.observe(b),()=>A.disconnect()},[K,M,Re,j,c,x,C,V,le]);let Ne=async b=>{try{let v=b.status;if(!v&&b.path)try{let Me=((await fetch(`${U}/cards?status=all&q=${encodeURIComponent(b.title||"")}&limit=50`).then(ze=>ze.json())).cards||[]).find(ze=>ze.path===b.path);Me&&(v=Me.status)}catch{}let A=v&&v!=="approved"?`&status=${encodeURIComponent(v)}`:"",ne=await fetch(`${U}/card?path=${encodeURIComponent(b.path||b.id)}${A}`),q=await ne.json();q.ok?B({path:q.path,title:b.title,text:q.text}):I(q.error||`HTTP ${ne.status}`)}catch(v){I(String(v&&v.message?v.message:v))}},l=async(b,v)=>{P(!0);try{let A=await fetch(`${U}/export`);if(!A.ok)throw new Error("HTTP "+A.status);let ne=await A.json();if(!ne.ok)throw new Error(ne.error||"export failed");let q,ue,Me;if(b==="json"){ue="memory-vault.json",Me="application/json";let je=ne.cards.map(Ye=>({path:Ye.path,title:Ye.title,kind:Ye.kind,status:Ye.status,store:Ye.store,text:Ye.text}));q=JSON.stringify({format:ne.format||"memory-eternal-vault",formatVersion:ne.formatVersion||1,exportedAt:ne.exportedAt||new Date().toISOString(),count:je.length,cards:je},null,2)}else ue="memory-vault.md",Me="text/markdown;charset=utf-8",q=ne.cards.map(je=>je.text.trim()).filter(Boolean).join(`
302
302
 
303
303
  ---
304
304
 
305
- `);let Te=new Blob([q],{type:Me}),Ve=await Wa(Te,ge,!1);if(!Ve.ok){K({ok:!1,msg:t("exportFail")}),$(!1);return}K({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Ve.name})}catch(L){K({ok:!1,msg:t("exportFail")+" \xB7 "+(L.message||"")})}finally{$(!1)}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>K(null),2600)},A=async g=>{let x=g.target.files&&g.target.files[0];if(g.target.value="",!!x){try{let L=await x.text(),q=await(await fetch(`${_}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:L})).json();if(q.ok){await me();let ge=q.imported||0,Me=t("importedVault")+"\uFF1A"+ge;q.total&&(Me+=t("importedTotal")+q.total+t("importedTotalTail")),q.quarantined&&(Me+=t("importedQuarantine")+q.quarantined+t("importedQuarantineTail")),q.skipped&&(Me+=t("importedSkipped")+q.skipped+t("importedSkippedTail")),q.warning&&(Me+=" \xB7 "+q.warning),K({ok:ge>0||!q.total,msg:Me})}else K({ok:!1,msg:q.error||t("importFail")})}catch{K({ok:!1,msg:t("importFail")})}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>K(null),2400)}},F=(0,n.useMemo)(()=>{let g=M.slice();return J!=="all"&&(g=g.filter(x=>ut(x.submittedBy)===J)),V!=="all"&&(g=g.filter(x=>(x.status||"approved")===V)),j==="title"?g.sort((x,L)=>String(x.title||"").localeCompare(String(L.title||""))):j==="hot"?g.sort((x,L)=>(L.weight||L.links||0)-(x.weight||x.links||0)):g.sort((x,L)=>new Date(L.updated||0).getTime()-new Date(x.updated||0).getTime()),g},[M,j,J,V]),G=(0,n.useMemo)(()=>[...new Set(M.map(g=>ut(g.submittedBy)))],[M]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:He}),te&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(te.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:te.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:te.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:te.msg})]}),o&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(Qt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),m&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:m,"aria-label":t(d?"exitFull":"fullscreen"),children:d?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:r,"aria-label":t("close"),children:"\u2715"})]}),h&&h.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[h.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:h.since?pt(new Date(h.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${we?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Be(g=>!g),"aria-label":t(we?"collapse":"expand"),title:t(we?"collapse":"expand"),children:we?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="cards"?" active":""}`,onClick:()=>y("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="graph"?" active":""}`,onClick:()=>y("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="stats"?" active":""}`,onClick:()=>y("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="audit"?" active":""}`,onClick:()=>y("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")}),Ke>0&&(0,e.jsx)("span",{className:"mc-dot",children:Ke>99?"99+":Ke})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="optimize"?" active":""}`,onClick:()=>y("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")}),qe>0&&(0,e.jsx)("span",{className:"mc-dot",style:{background:"#6b7280"},children:qe>99?"99+":qe})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${U==="config"?" active":""}`,onClick:()=>y("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]}),(0,e.jsxs)("button",{type:"button",className:"mc-railbtn",onClick:()=>De(!0),title:t("fbNav"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F41E}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("fbNav")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:ie,children:[U==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(dt,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(dt,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(dt,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(dt,{label:t("pending"),value:i?.quarantine?.pending??i?.status?.pending??0}),(0,e.jsx)(dt,{label:t("rejected"),value:i?.quarantine?.rejected??i?.status?.rejected??0}),(0,e.jsx)(dt,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),U==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:D,onChange:g=>be(g.target.value)}),(0,e.jsx)("input",{ref:oe,type:"file",accept:".json,application/json",style:{display:"none"},onChange:A}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>oe.current&&oe.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ze({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:b,onClick:()=>l("md"),children:t(b?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:b,onClick:()=>l("json"),children:t(b?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>me(),children:t("refresh")})]}),U==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Lt.map(g=>(0,e.jsx)("button",{type:"button",className:`mc-chip${w===g?" active":""}`,onClick:()=>it(g),children:t(g==="all"?"all":_e[g])},g)),(0,e.jsxs)("select",{value:J,onChange:g=>ve(g.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Zt(G).map(g=>(0,e.jsx)("option",{value:g,children:g},g))]}),(0,e.jsxs)("select",{value:V,onChange:g=>Le(g.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(g=>(0,e.jsx)("button",{type:"button",className:`mc-chip${j===g.key?" active":""}`,onClick:()=>v(g.key),children:g.label},g.key))]}),z&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",z]}),(0,e.jsx)("div",{style:{display:U==="cards"?"contents":"none"},children:E?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):z?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",z," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>me(),children:t("retry")})]}):M.length===0?(0,e.jsx)("div",{className:"mc-empty",children:t("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:F.map(g=>(0,e.jsx)(Ia,{card:g,t,query:D.trim(),onOpen:Ne,onDelete:a},g.path))}),M.length<Re&&(0,e.jsx)("div",{ref:B,style:{height:1}}),c&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",M.length," / ",Re,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:U==="graph"?"flex":"none",flex:1,minHeight:0},children:re.has("graph")&&(0,e.jsx)(Ea,{t,onOpen:Ne,all:ae,onAllChange:he,onMutate:at,active:U==="graph",visible:U==="graph"})}),(0,e.jsx)("div",{style:{display:U==="config"?"contents":"none"},children:re.has("config")&&(0,e.jsx)(ta,{t,onReload:()=>me(),version:Ce})}),(0,e.jsx)("div",{style:{display:U==="stats"?"contents":"none"},children:re.has("stats")&&(0,e.jsx)(La,{t,tab:"stats",onReload:()=>me(),version:Ce})}),(0,e.jsx)("div",{style:{display:U==="audit"?"contents":"none"},children:re.has("audit")&&(0,e.jsx)(Ta,{t,onReload:()=>me(),version:Ce})}),(0,e.jsx)("div",{style:{display:U==="optimize"?"contents":"none"},children:re.has("optimize")&&(0,e.jsx)(Ra,{t,onReload:()=>me(),version:Ce})}),Ae&&(0,e.jsx)(Ba,{t,onClose:()=>De(!1)}),se&&(0,e.jsx)(Pa,{t,card:se,query:D.trim(),onClose:()=>Y(null),onDelete:g=>{Y(null),a(g)},onFeedback:g=>{let x=se.path;fetch(`${_}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:D.trim(),path:x,useful:g})}).then(()=>K({ok:!0,msg:t(g?"fbUseful":"fbIrr")})).catch(()=>{}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>K(null),2e3)}}),(0,e.jsx)(Aa,{t,newCard:Pe,setNewCard:ze,onCreated:()=>{me(),at(),K({ok:!0,msg:t("created")}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>K(null),2e3)}})]})]})]})}var ea=({toast:t})=>t?(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"8px 12px",fontSize:12,borderLeft:"4px solid "+(t.ok?"#10b981":"#ef4444"),background:t.ok?"rgba(16,185,129,0.08)":"rgba(239,68,68,0.08)"},children:[t.ok?"\u2705":"\u26A0"," ",t.msg]}):null,dt=({label:t,value:o})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:o}),(0,e.jsx)("span",{children:t})]});function ta({t,onReload:o,version:r,compact:m}){let[d,i]=(0,n.useState)(null),[S,M]=(0,n.useState)(0),[k,E]=(0,n.useState)(null),[C,h]=(0,n.useState)(null),[u,z]=(0,n.useState)(!1),[I,w]=(0,n.useState)(!1),R=(0,n.useRef)(!1),D=(0,n.useRef)(null),O=(0,n.useRef)({}),[J,ve]=(0,n.useState)(null),[V,Le]=(0,n.useState)(null),[U,ue]=(0,n.useState)(""),[re,H]=(0,n.useState)(""),[y,j]=(0,n.useState)(""),[v,te]=(0,n.useState)(null),K=(0,n.useCallback)(async l=>{H("version");try{let A=await fetch(_+"/version-check"+(l?"?force=1":"")).then(F=>F.json());A&&A.ok?(te(A),l&&Y(A.updateAvailable?t("vcLatest")+" v"+A.latest:t("vcUpToDate"))):l&&Y(t("vcCheckFail"),!1)}catch{l&&Y(t("vcCheckFail"),!1)}finally{H("")}},[t]);(0,n.useEffect)(()=>{K(!1)},[r,K]);let[X,oe]=(0,n.useState)(""),[b,$]=(0,n.useState)(null),se=(0,n.useRef)(null),Y=(l,A=!0)=>{se.current&&clearTimeout(se.current),$({msg:l,ok:A}),se.current=setTimeout(()=>$(null),1900)},ae=async()=>{if(!re){H("restart");try{let l=await fetch(_+"/restart-self",{method:"POST"});if(l.status===404||l.status===405){Y(Pe("vcRestartNoRoute",{cmd:v&&v.restartCommand||"dsh-memory restart --port 7999"}),!1);return}let A=await l.json().catch(()=>null);if(!A){Y(t("vcRestartFail")+"\uFF08HTTP "+l.status+"\uFF09",!1);return}if(!A.ok){Y(A.error||t("vcRestartFail"),!1);return}if(A.alreadyCurrent){Y(A.note||t("vcRestartCurrent"));return}Y(A.note||t("vcRestartSent")),A.alreadyRunning||setTimeout(()=>{K(!0)},6e3)}catch(l){Y(t("vcRestartFail")+"\uFF1A"+String(l&&l.message||l),!1)}finally{H("")}}},he=v&&v.resident?String(v.resident.served||""):"",Ae=!!(v&&v.onDisk&&he&&he!==v.onDisk),De=!!(v&&v.resident&&v.resident.managed===!1),we=!!(v&&v.resident&&!he),Be=Ae||we||De,Pe=(l,A)=>Object.keys(A).reduce((F,G)=>F.split("{"+G+"}").join(A[G]),t(l)),ze=(0,n.useCallback)(async()=>{try{let[l,A,F]=await Promise.all([fetch(`${_}/config`).then(G=>G.json()).catch(()=>null),fetch(`${_}/setup-status`).then(G=>G.json()).catch(()=>null),fetch(`${_}/budget`).then(G=>G.json()).catch(()=>null)]);if(l&&l.ok){i(l),M(l.revision??0),E(l.schema??null);let G=qt(l.config??{},O.current);O.current=G.overlay,h({...G.values}),ve(l.dsh??null),z(l.writable===!1),w(l.viaPending===!0),ue(""),R.current=!1}else F&&F.ok?(h({...F}),z(!0),ue(t("configNeedsDsh"))):ue(t("adminLoadFail"));A&&A.ok&&Le(A),j("")}catch{ue(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{ze()},[r,ze]);let Ce=(l,A)=>{R.current=!0,h(F=>({...F??{},[l]:A}))};(0,n.useEffect)(()=>{D.current=ze},[ze]),(0,n.useEffect)(()=>{if(typeof EventSource>"u")return;let l=null;try{l=new EventSource(_+"/events")}catch{return}let A=()=>{!R.current&&typeof D.current=="function"&&D.current()};try{l.addEventListener("config",A)}catch{}return()=>{try{l.close()}catch{}}},[]);let tt=new Set(["dedupThreshold","captureMinChars","captureCooldownMs","maxCardsPerDay","captureMaxTokens","recallMinScore","recallLimit","recallSummaryLen","recycleRetentionDays","webPort","webCheckIntervalMs","webMaxRestart","sessionBudgetChars"]),at=l=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[l]||l,Ke=async()=>{if(!C)return;if(u){Y(t("editInSetting"),!1);return}let l={dedupThreshold:[0,1],captureMinChars:[0,1e6],captureCooldownMs:[0,1e9],maxCardsPerDay:[0,1e6],captureMaxTokens:[100,4e3],recallMinScore:[0,50],recallLimit:[1,20],recallSummaryLen:[40,400],recycleRetentionDays:[1,3650],webPort:[1,65535],webCheckIntervalMs:[1e3,6e5],webMaxRestart:[1,1e3],sessionBudgetChars:[0,1e9]},A=[];for(let[F,[G,g]]of Object.entries(l)){if(!(F in C))continue;let x=C[F],L=typeof x=="number"?x:Number(x);(x===""||x===null||x===void 0||!Number.isFinite(L)||L<G||L>g)&&A.push(t("invalidField",{field:F,min:G,max:g,value:String(x===""?"\u7A7A":x)}))}if(A.length){let F=t("saveInvalid")+"\uFF1A"+A.join("\uFF1B");ue(F),Y(F,!1);return}H("save");try{let F={...C};for(let L of Object.keys(C))L in F&&typeof F[L]=="string"&&F[L].trim()!==""&&tt.has(L)&&(F[L]=Number(F[L]));Array.isArray(F.vaultProfiles)&&(F.vaultProfiles=F.vaultProfiles.filter(L=>L&&(String(L.name||"").trim()||String(L.path||"").trim())));let G=await fetch(`${_}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:F,expectedRevision:S})}),g=await G.text(),x=null;try{x=g?JSON.parse(g):null}catch{x=null}if(x||(x={error:"HTTP "+G.status+(g?"\uFF1A"+g.slice(0,200):"\uFF08\u5BBF\u4E3B\u672A\u8FD4\u56DE\u539F\u56E0\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u6709\u6570\u5B57\u5B57\u6BB5\u4E3A\u7A7A\u6216\u8D85\u51FA\u8303\u56F4\uFF09")}),x&&x.ok){let L=typeof x.pendingOutcome=="string"?x.pendingOutcome:"",ne,q=!0;if(L==="applied")ne=t("savedApplied")+(Array.isArray(x.applied)&&x.applied.length?" \xB7 "+x.applied.join("\u3001"):"");else if(L==="queued")q=!1,ne=t("saveQueued");else if(L==="failed")q=!1,ne=t("saveFail")+" \xB7 "+(x.hostGuard?t("saveHostGuard"):t("saveFailHint"));else if(L==="applied-direct")ne=t("savedOk")+" \xB7 "+t("savedDirect");else{let ge=Array.isArray(x.pending)&&x.pending.length?" \xB7 "+t("savePending"):x.note?" \xB7 "+t("restartHint"):"";ne=(x.retried?"\u267B ":"")+t("savedOk")+ge}O.current={...O.current,...F},q?j(ne):ue(ne),Y(ne,q),await ze()}else{let L=G.status===409?t("conflictRefresh"):x?.error||t("saveFail");ue(L),Y(L,!1)}}catch{ue(t("saveFail")),Y(t("saveFail"),!1)}finally{H("")}},qe=()=>{O.current={},h({...d?.config??{}}),j("")},de={env:"vaultSrcEnv",profile:"vaultSrcProfile",workspace:"vaultSrcWorkspace",vaultDir:"vaultSrcVaultDir",default:"vaultSrcDefault"},Re=l=>Array.isArray(l?.vaultProfiles)?l.vaultProfiles:[],ke=(l,A,F)=>h(G=>{let g=Re(G).map(L=>({...L||{}})),x={...g[l]||{}};return A==="match"?String(F).trim()?x.match={...x.match||{},workspace:F}:delete x.match:x[A]=F,g[l]=x,{...G??{},vaultProfiles:g}}),c=()=>h(l=>({...l??{},vaultProfiles:[...Re(l),{name:"",path:""}]})),s=l=>h(A=>({...A??{},vaultProfiles:Re(A).filter((F,G)=>G!==l)})),B={fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},ie={padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:12,minWidth:0},ce={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:4e3,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},me=async l=>{let A=ce[l];A&&h(F=>({...F??{},...A}))},a=async(l,A)=>{H(l+A);try{let G=await(await fetch(`${_}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:l,action:A})})).json();G&&G.ok?Y(Pe(A==="install"?"mcpInstalled":"mcpUninstalled",{agent:l})):Y(Pe("mcpActionFail",{agent:l,error:G?.error||""}),!1);try{let g=await fetch(`${_}/setup-status`).then(x=>x.json());g&&g.ok&&Le(g)}catch{}}catch{Y(t("mergeFail"),!1)}finally{H("")}},be=({k:l,label:A,type:F="text",step:G,min:g,max:x})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:A||l}),(0,e.jsx)("input",{type:F,step:G,min:g,max:x,value:C?C[l]??"":"",onChange:L=>{let ne=L.target.value;Ce(l,F==="number"?ne===""?"":Number(ne):ne)},style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),it=new Set(["autoRestartOnDrift"]),Ne=({k:l,label:A})=>{let F=C?C[l]:void 0,G=F===void 0?it.has(l):!!F;return(0,e.jsxs)("label",{style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:12,minWidth:0,lineHeight:1.5},children:[(0,e.jsx)("input",{type:"checkbox",checked:G,onChange:g=>Ce(l,g.target.checked),style:{marginTop:2,flex:"0 0 auto"}}),(0,e.jsx)("span",{style:{whiteSpace:"normal",overflowWrap:"anywhere"},children:A||l})]})};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:m?"0 0 auto":1,minHeight:0,maxHeight:m?"52vh":void 0},children:[(0,e.jsx)("style",{children:He}),b&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(b.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:b.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:b.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:b.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[U&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",U]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:ze,children:["\u21BB ",t("retry")]})]}),I&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #3b82f6",background:"rgba(59,130,246,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#1d4ed8",lineHeight:1.7},children:["\u2139 ",t("pendingSyncNote")]}),u&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),y&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",y]}),d&&(d.version||d.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:t("dshHostLabel")}),d.version&&(0,e.jsxs)("code",{style:B,children:[t("vcLoaded")," v",d.version]}),v&&v.resident&&v.resident.served&&v.resident.served!==d.version&&(0,e.jsxs)("code",{style:B,children:[t("vcResident")," v",v.resident.served]}),v&&v.resident&&!v.resident.served&&(0,e.jsxs)("code",{style:{...B,color:"#b45309",fontWeight:600},children:[t("vcResident")," ",t("vcResidentDownShort")]}),v&&v.resident&&v.resident.served&&v.resident.managed===!1&&(0,e.jsxs)("code",{style:{...B,color:"#b45309",fontWeight:600},children:[t("vcResident")," v",v.resident.served," \xB7 ",t("vcResidentUnmanagedShort")]}),bt&&(0,e.jsxs)("code",{style:B,children:[t("vcPage")," v",bt]}),v&&v.onDisk&&(0,e.jsxs)("code",{style:B,children:[t("vcOnDisk")," v",v.onDisk]}),v&&v.latest&&(0,e.jsxs)("code",{style:B,children:[t("vcLatest")," v",v.latest]}),d.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",d.dsh.vaultDir]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:re==="version",onClick:()=>K(!0),children:re==="version"?t("checking"):"\u{1F504} "+t("vcCheck")})]}),v&&(v.stale||we||De)&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"6px 10px"},children:[(0,e.jsxs)("div",{children:["\u26A0\uFE0F ",v.stale?Pe("vcStale",{disk:v.onDisk,loaded:v.loaded}):we?Pe("vcResidentDown",{port:v.resident&&v.resident.port||"",cmd:v.restartCommand||"dsh-memory restart --port 7999"}):Pe("vcResidentUnmanaged",{served:he,cmd:v.restartCommand||"dsh-memory restart --port 7999"})]}),Be?(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:6,flexWrap:"wrap"},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!re,onClick:ae,children:re==="restart"?"\u23F3 "+t("vcRestarting"):"\u{1F504} "+t("vcRestart")}),v.restartCommand&&(0,e.jsx)("code",{style:{fontSize:11,opacity:.75},children:v.restartCommand})]}):(0,e.jsxs)("div",{style:{marginTop:6,lineHeight:1.7},children:["\u2139\uFE0F ",t("vcHostStale"),v.restartCommand&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)("code",{style:{fontSize:11,opacity:.75},children:v.restartCommand})]})]})]}),bt&&v&&v.onDisk&&bt!==v.onDisk&&(0,e.jsx)("div",{style:{marginTop:8,fontSize:11.5,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"6px 10px",lineHeight:1.7},children:t("vcPageStale",{page:bt,disk:v.onDisk})}),v&&v.updateAvailable&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,opacity:.88},children:["\u2B06 ",t("vcOutdated")," \u2192 ",(0,e.jsx)("code",{children:v.updateCommand})]}),v&&v.checkError&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b91c1c"},children:[t("vcCheckFail"),"\uFF1A",v.checkError]})]}),V&&V.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:V.agents.map(l=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:l.isDsh?t("dshHostLabel"):l.name}),l.isDsh&&l.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",l.version]}),!l.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),l.installed&&l.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),l.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),l.mcpConfigured===!0&&l.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),l.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",l.recallTool?t("enabled"):t("disabled"),")"]})]}),l.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",l.hook]}),!l.isDsh&&l.installed&&l.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!re,onClick:()=>a(l.name,"install"),children:t("installMcp")}),!l.isDsh&&l.installed&&l.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!re,onClick:()=>{window.confirm(t("uninstallConfirm"))&&a(l.name,"uninstall")},children:t("uninstallMcp")})]},l.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),X&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:X})})]}),C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(l=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>me(l),disabled:!!re,children:[l==="A"?"\u{1F7E2} ":l==="B"?"\u{1F4B0} ":"\u2B50 ",ce[l].label]},l))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Ne,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(be,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(be,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(be,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(be,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(be,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Ne,{k:"recallIncludeBody",label:t("recallBody")}),(0,e.jsx)(be,{k:"secretHint",label:t("secretHint")}),(0,e.jsx)(be,{k:"recallEmbedding",label:t("recallEmbedding")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #06b6d4"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5C2}\uFE0F ",t("vaultMulti")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("vaultMultiHint")})]}),(0,e.jsxs)("div",{style:{fontSize:11.5,opacity:.85,marginBottom:8,lineHeight:1.7},children:[t("vaultNow"),"\uFF1A",(0,e.jsx)("code",{children:J?.vaultDir||"\u2014"}),J?.vaultName?`\uFF08${J.vaultName}\uFF09`:""," \xB7 ",t("vaultSource"),"\uFF1A",t(de[J?.vaultSource]||"vaultSrcDefault"),J?.workspace?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),t("vaultWorkspace"),"\uFF1A",(0,e.jsx)("code",{children:J.workspace})]}):null]}),Re(C).map((l,A)=>(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.6fr 1.5fr auto",gap:6,marginBottom:6},children:[(0,e.jsx)("input",{value:l.name||"",placeholder:t("vaultNamePh"),onChange:F=>ke(A,"name",F.target.value),style:ie,disabled:u}),(0,e.jsx)("input",{value:l.path||"",placeholder:t("vaultPathPh"),onChange:F=>ke(A,"path",F.target.value),style:ie,disabled:u}),(0,e.jsx)("input",{value:l.match&&l.match.workspace||"",placeholder:t("vaultMatchPh"),onChange:F=>ke(A,"match",F.target.value),style:ie,disabled:u}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>s(A),disabled:u,title:t("delete"),children:"\u2715"})]},A)),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginTop:4},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:c,disabled:u,children:["\uFF0B ",t("vaultAdd")]}),(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("vaultActive")}),(0,e.jsxs)("select",{value:C.activeVault||"",onChange:l=>Ce("activeVault",l.target.value),disabled:u,style:ie,children:[(0,e.jsx)("option",{value:"",children:t("vaultActiveNone")}),Re(C).filter(l=>l&&l.name).map(l=>(0,e.jsx)("option",{value:l.name,children:l.name},l.name))]})]})]})]}),(0,e.jsx)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"enabled",label:t("enabledLabel")}),(0,e.jsx)(be,{k:"vaultDir",label:t("vaultDirLabel")})]})}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(Ne,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Ne,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(be,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(be,{k:"recallMinScore",label:t("recallMinScore"),type:"number"}),(0,e.jsx)(be,{k:"captureCooldownMs",label:t("captureCooldownMs"),type:"number"}),(0,e.jsx)(be,{k:"captureProvider",label:t("captureProvider")}),(0,e.jsx)(be,{k:"captureModel",label:t("captureModel")}),(0,e.jsx)(be,{k:"sessionBudgetChars",label:t("sessionBudgetChars"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:t("auditMode")}),(0,e.jsxs)("select",{value:C.auditMode??"all",onChange:l=>Ce("auditMode",l.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(Yt,{label:t("auditExemptAgents"),value:C.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(V?.agents||[]).filter(l=>!l.isDsh).map(l=>({value:l.name,label:l.name}))],onChange:l=>Ce("auditExemptAgents",l)}),(0,e.jsx)(Yt,{label:t("auditExemptKinds"),value:C.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...Lt.filter(l=>l!=="all").map(l=>({value:l,label:t(_e[l])}))],onChange:l=>Ce("auditExemptKinds",l)}),(0,e.jsx)(be,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:C.autoWebMode??"init",onChange:l=>Ce("autoWebMode",l.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(be,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(be,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(be,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Ne,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Ne,{k:"autoRestartOnDrift",label:t("autoRestartOnDrift")}),(0,e.jsx)(Ne,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",alignItems:"center",marginBottom:10,flexWrap:"wrap"},children:[re==="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,opacity:.75},children:["\u23F3 ",t("saving")]}),y&&re!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#10b981"},children:["\u2705 ",y]}),U&&re!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#b91c1c"},children:["\u26A0 ",U]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:qe,disabled:!!re,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:u?()=>Y(t("readonlyTitle")+"\uFF1A"+t("readonlyBody"),!1):Ke,disabled:re==="save",title:t(u?"readonlyBody":"saveConfig"),children:re==="save"?"\u23F3 "+t("saving"):u?"\u{1F512} "+t("readonlyBtn"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Ta({t,onReload:o,version:r}){let[m,d]=(0,n.useState)([]),[i,S]=(0,n.useState)([]),[M,k]=(0,n.useState)("all"),[E,C]=(0,n.useState)("all"),[h,u]=(0,n.useState)(""),[z,I]=(0,n.useState)(new Set),[w,R]=(0,n.useState)(""),[D,O]=(0,n.useState)(null),[J,ve]=(0,n.useState)("pending"),V=(b,$=!0)=>{O({msg:b,ok:$}),setTimeout(()=>O(null),3e3)},Le=[...new Set([...m,...i].map(b=>b.submittedBy).filter(Boolean))],U=(0,n.useCallback)(async()=>{try{let b=await fetch(`${_}/audit/list`).then($=>$.json());b.ok&&(d(b.pending||[]),S(b.rejected||[]),I(new Set),j(new Set),te({}))}catch{}},[]);(0,n.useEffect)(()=>{U()},[r,U]);let ue=(J==="pending"?m:i).filter(b=>{if(M!=="all"&&b.kind!==M||E!=="all"&&ut(b.submittedBy)!==E)return!1;if(h){let $=(b.created||"").slice(0,10);if($&&$!==h)return!1}return!0}),re=b=>I($=>{let se=new Set($);return se.has(b)?se.delete(b):se.add(b),se}),H=async(b,$)=>{let se=$||[...z];if(!se.length){V(t("noSelection"),!1);return}R("apply");let Y=t(b==="approved"?"toastApproved":b==="rejected"?"toastRejected":"toastCardDeleted");try{let ae=0;for(let he of se){let Ae=b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete";try{(await fetch(_+"/"+Ae+"?path="+encodeURIComponent(he)+(b==="delete"?"&permanent=0":""))).ok||ae++}catch{ae++}}await U(),o&&o(),ae?V(t("toastFailed")+"\uFF08"+ae+"/"+se.length+"\uFF09",!1):V(Y+" "+se.length+" \u5F20")}catch(ae){V(t("toastFailed")+": "+String(ae&&ae.message||ae),!1)}finally{R("")}},[y,j]=(0,n.useState)(new Set),[v,te]=(0,n.useState)({}),K=b=>v[b]||{},X=async b=>{let $=b.path,se=!y.has($);if(j(Y=>{let ae=new Set(Y);return se?ae.add($):ae.delete($),ae}),!(!se||v[$])){te(Y=>({...Y,[$]:{loading:!0}}));try{let Y=b.status||(J==="pending"?"pending":"rejected"),ae=await fetch(`${_}/card?path=${encodeURIComponent($)}&status=${Y}`).then(he=>he.json());ae&&ae.ok?te(he=>({...he,[$]:{text:ae.text||""}})):te(he=>({...he,[$]:{error:ae&&ae.error||"HTTP"}}))}catch(Y){te(ae=>({...ae,[$]:{error:String(Y&&Y.message||Y)}}))}}},oe=[...z];return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(ea,{toast:D}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:M,onChange:b=>k(b.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),Lt.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(_e[b])},b))]}),(0,e.jsxs)("select",{value:E,onChange:b=>C(b.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),Zt(Le).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:h,onChange:b=>u(b.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${J==="pending"?" me-on":""}`,onClick:()=>ve("pending"),children:[t("pending"),"\uFF08",m.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${J==="rejected"?" me-on":""}`,onClick:()=>ve("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:ue.length>0&&oe.length===ue.length,onChange:b=>{b.target.checked?I(new Set(ue.map($=>$.path))):I(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!oe.length||!!w,onClick:()=>H("approved"),children:["\u2713 ",t(J==="rejected"?"restore":"approve")]}),J==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!oe.length||!!w,onClick:()=>H("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!oe.length||!!w,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&H("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),ue.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:ue.map(b=>{let $=K(b.path),se=y.has(b.path);return(0,e.jsxs)("div",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:z.has(b.path),onChange:()=>re(b.path)}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"0 6px"},title:t(se?"collapse":"expand"),"aria-expanded":se,onClick:()=>X(b),children:se?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},title:t(se?"collapse":"expand"),onClick:()=>X(b),children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:ut(b.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.created?b.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:b.severity==="high"?"#f87171":"#9ca3af"},children:b.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.reason||"-"}),J==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>H("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>H("rejected",[b.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>H("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&H("delete",[b.path])},children:"\u{1F5D1}"})]})]}),se&&(0,e.jsxs)("div",{style:{padding:"2px 10px 12px 34px"},children:[$.loading&&(0,e.jsxs)("div",{style:{fontSize:12,opacity:.6},children:["\u23F3 ",t("loading")]}),$.error&&(0,e.jsxs)("div",{style:{fontSize:12,color:"#f87171"},children:["\u26A0 ",t("auditBodyFail"),"\uFF1A",$.error]}),$.text!=null&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"md-meta",style:{marginBottom:6},children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:Ue[b.kind]||"#6B7280",borderColor:(Ue[b.kind]||"#6B7280")+"59",background:(Ue[b.kind]||"#6B7280")+"1a"},children:[ht[b.kind]||"\u{1F4CE}"," ",t(_e[b.kind]||"kindKnowledge")]}),(Array.isArray(b.tags)?b.tags:[]).slice(0,8).map(Y=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",Y]},Y)),!!b.reason&&(0,e.jsxs)("span",{className:"md-chip md-chip-st-warn",children:["\u2691 ",b.reason]})]}),(0,e.jsx)("div",{className:"md-doc",style:{maxHeight:340,overflow:"auto"},dangerouslySetInnerHTML:{__html:Tt(Ct($.text).body)}}),J==="pending"&&(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!!w,onClick:()=>H("approved",[b.path]),children:["\u2713 ",t("approve")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!w,onClick:()=>H("rejected",[b.path]),children:["\u2715 ",t("reject")]})]})]})]})]},b.path)})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Ra({t,onReload:o,version:r}){let[m,d]=(0,n.useState)([]),[i,S]=(0,n.useState)(""),[M,k]=(0,n.useState)(null),E=(u,z=!0)=>{k({msg:u,ok:z}),setTimeout(()=>k(null),3200)},C=(0,n.useCallback)(async()=>{try{let u=await fetch(`${_}/recycle/list`).then(z=>z.json());u.ok&&d(u.items||[])}catch{}},[]);(0,n.useEffect)(()=>{C()},[r,C]);let h=async(u,z)=>{let I=(m.find(w=>w.path===z)||{}).title||z;S(u+z);try{let R=await fetch(_+(u==="restore"?"/recycle/restore":"/recycle/purge")+"?path="+encodeURIComponent(z)),D=await R.json().catch(()=>null);await C(),o&&o(),R.ok&&(!D||D.ok!==!1)?E(t(u==="restore"?"toastRestored":"toastPurged")+"\uFF1A"+I):E(t("toastFailed")+"\uFF1A"+(D&&D.error||"HTTP "+R.status),!1)}catch(w){E(t("toastFailed")+"\uFF1A"+String(w&&w.message||w),!1)}finally{S("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(ea,{toast:M}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i||m.length===0,title:m.length?"":t("emptyRecycle"),onClick:async()=>{S("purgeAll");try{let u=await fetch(_+"/recycle/purge-expired?days=0"),z=await u.json().catch(()=>null);await C(),E(u.ok?t("toastPurgedExpired")+(z&&z.purged!=null?"\uFF08"+z.purged+"\uFF09":""):t("toastFailed"),u.ok)}catch(u){E(t("toastFailed")+"\uFF1A"+String(u&&u.message||u),!1)}finally{S("")}},children:t("emptyRecycle")})]}),m.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:m.map(u=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[u.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(u.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>h("restore",u.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&h("purge",u.path)},children:t("purge")})]},u.path))}):(0,e.jsxs)("div",{className:"mc-card",style:{padding:18,fontSize:12.5,opacity:.78,textAlign:"center",lineHeight:1.9},children:["\u{1F5D1}\uFE0F ",t("emptyRecycle"),(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{fontSize:11.5},children:t("recycleEmptyHint").split("{days}").join("30")})]})]})]})}var Ia=({card:t,t:o,onOpen:r,query:m,onDelete:d})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>r(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[t.kind]||Ue.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:ht[t.kind]||"\u{1F4CE}"}),m?Gt(t.title,m):t.title,Oa(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:o("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",o("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",o("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",o("statusApproved")]})]}),(0,e.jsx)("p",{children:m?Gt(t.summary||"",m):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[ht[t.kind]||"\u{1F4CE}"," ",o(_e[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",ut(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",pt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:o("delete"),onClick:i=>{i.stopPropagation(),window.confirm(o("deleteConfirm"))&&d&&d(t.path)},children:"\u{1F5D1}"})]})]});function La({t,tab:o,onReload:r,version:m}){let[d,i]=(0,n.useState)(null),[S,M]=(0,n.useState)(""),[k,E]=(0,n.useState)(null),[C,h]=(0,n.useState)(null),[u,z]=(0,n.useState)(null),[I,w]=(0,n.useState)([]),[R,D]=(0,n.useState)(""),[O,J]=(0,n.useState)(!1),ve=(0,n.useCallback)(async()=>{if(!(!k||!k.merge||!k.merge.length)&&window.confirm(t("mergeAllConfirm"))){D("merge");try{let y={},j=oe=>y[oe]===void 0?oe:y[oe]=j(y[oe]),v=(oe,b)=>{y[j(oe)]=j(b)},te=new Set;for(let oe of k.merge)te.add(oe.a.path),te.add(oe.b.path),v(oe.a.path,oe.b.path);let K={};for(let oe of te){let b=j(oe);(K[b]=K[b]||[]).push(oe)}let X=0;for(let oe of Object.values(K)){if(oe.length<2)continue;(await fetch(`${_}/merge?paths=${encodeURIComponent(oe.join(","))}`).then($=>$.json())).ok&&X++}await V(),r&&r()}catch{}D("")}},[k,V,r,t]);async function V(){try{let y=await Promise.all([fetch(`${_}/stats`),fetch(`${_}/budget`),fetch(`${_}/capture-log`),fetch(`${_}/cards?status=all&limit=30&agent=${yt}`)]),[j,v,te,K]=await Promise.all(y.map(X=>X.json()));j&&j.ok&&i(j),v&&v.ok&&h(v),te&&te.ok&&z(te),K&&K.ok&&w(K.cards||[]),M(!j||!j.ok?t("adminLoadFail"):"")}catch{M(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{D("scan");try{let y=await fetch(`${_}/optimize`).then(j=>j.json());y.ok&&E(y)}catch{M(t("adminLoadFail"))}finally{D("")}},[t]);(0,n.useEffect)(()=>{V()},[m]);let U=async(y,j)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${_}/merge?paths=${encodeURIComponent(y+","+j)}`).then(te=>te.json())).ok&&(await V(),r&&r())}catch{}},ue=async y=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${_}/delete?path=${encodeURIComponent(y)}`).then(v=>v.json())).ok&&(await V(),r&&r())}catch{}},re=["project","knowledge","content","prompt","business","tool","mistake"],H=({title:y,kind:j,updated:v,path:te})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[j]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:pt(v)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ue(te),children:[t("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[S&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",S]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:V,children:["\u21BB ",t("retry")]})]}),o==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",t("captureLog")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("captureLogHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>V(),children:["\u21BB ",t("refresh")]})]}),u?u.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(u.entries||[]).length===0?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogEmpty")}):(0,e.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,e.jsx)("tbody",{children:(u.entries||[]).map((y,j)=>{let v=ka[y.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:pt(y.time?new Date(y.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:v[1],fontWeight:600},children:[v[0]," ",y.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:y.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:y.preview||"",children:y.preview||""})]},j)})})})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("loading")})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",t("captureAgentCards"),"\uFF08",I.length,"\uFF09"]}),I.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.map(y=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[y.kind]||Ue.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.title}),y.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:pt(y.updated)})]},y.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),d&&(0,e.jsxs)(e.Fragment,{children:[d.trend&&d.trend.length>0&&(()=>{let y=d.trend,j=Math.max(...y.map(X=>X.count),1),v=260,te=50,K=v/y.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:v,height:te,style:{display:"block",width:"100%",height:50},children:y.map((X,oe)=>{let b=Math.round(X.count/j*(te-4));return(0,e.jsx)("rect",{x:oe*K+1,y:te-b,width:Math.max(K-2,2),height:b,rx:1.5,fill:X.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:X.count>0?.85:.35},X.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:re.map(y=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[y]||"#666"}}),t(_e[y]),": ",d.byKind?.[y]||0]},y))})]}),C&&(C.budgetChars||C.recallLimit||C.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:C.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:C.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",C.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",d.todayCards?.length||0,"\uFF09"]}),d.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:d.todayCards.map(y=>(0,e.jsx)(H,{title:y.title,kind:y.kind,updated:y.updated,path:y.path},y.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),o==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!R,onClick:Le,children:R==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),k&&k.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!R,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){D("oneclick");try{let y=JSON.stringify({cleanupStale:O}),v=await(await fetch(`${_}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:y})).json();v&&v.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${v.plan.merged} ${t("optimizedMerged")}${O?` \xB7 ${v.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await V(),r&&r(),E(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{D("")}}},children:R==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),k&&k.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:O,onChange:y=>J(y.target.checked)}),t("oneClickAlsoStale")]})]}),!k&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),k&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),k.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!R,onClick:ve,children:t(R==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),k.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:k.merge.map((y,j)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[y.a.title," \u21C4 ",y.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(y.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>U(y.a.path,y.b.path),children:t("mergeNow")})]},j))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",k.stale?.length||0,"\uFF09"]}),k.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!R,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;D("clean");let y=0;for(let j of k.stale)try{await fetch(`${_}/delete?path=${encodeURIComponent(j.path)}`),y++}catch{}D(""),notify(`${y} ${t("deletedStale")}`),await V(),r&&r()},children:t("cleanStale")})}),k.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:k.stale.map(y=>(0,e.jsx)(H,{title:y.title,kind:"other",updated:y.updated,path:y.path},y.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var It=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function Aa({t,newCard:o,setNewCard:r,onCreated:m}){if(!o)return null;let d=It.find(h=>h.key===o.template),i=o.body||(d?t(d.bodyKey):""),S=o.kind||(d?d.kind:"knowledge"),M=o.tags||(d?t(d.tagKey):""),k=o._creating,E=h=>{let u=It.find(z=>z.key===h);r(z=>({...z,template:h,kind:u?u.kind:z.kind,body:u?t(u.bodyKey):z.body,tags:u?t(u.tagKey):z.tags}))},C=async()=>{if(!(!o.title&&!i)){r(h=>({...h,_creating:!0}));try{(await fetch(`${_}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.title||t("untitled"),kind:S,tags:M.split(",").map(u=>u.trim()).filter(Boolean),body:i,source:"manual"})}).then(u=>u.json())).ok?(r(null),m&&m()):r(u=>({...u,_creating:!1}))}catch{r(u=>({...u,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>r(null),children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:h=>h.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>r(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[It.map(h=>(0,e.jsx)("button",{type:"button",className:`mc-btn${o.template===h.key?" me-on":""}`,onClick:()=>E(h.key),children:t(h.label)},h.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${o.template===""?" me-on":""}`,onClick:()=>r(h=>({...h,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:S,onChange:h=>r(u=>({...u,kind:h.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(h=>(0,e.jsx)("option",{value:h,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:h},h))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:o.title||"",onChange:h=>r(u=>({...u,title:h.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:M,onChange:h=>r(u=>({...u,tags:h.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:h=>r(u=>({...u,body:h.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:k,onClick:C,children:t(k?"exporting":"createCard")})})]})]})]})}async function Vt(t){let o=String(t||"");if(!o)return!1;try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(o),!0}catch{}try{let r=document.createElement("textarea");r.value=o,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();let m=!!(document.execCommand&&document.execCommand("copy"));return document.body.removeChild(r),m}catch{return!1}}function Ba({t,onClose:o}){let[r,m]=(0,n.useState)(""),[d,i]=(0,n.useState)(""),[S,M]=(0,n.useState)(""),[k,E]=(0,n.useState)(!0),[C,h]=(0,n.useState)(!1),[u,z]=(0,n.useState)(""),[I,w]=(0,n.useState)(""),R=(0,n.useRef)(null),D=(0,n.useRef)(null),O=()=>{let H=R.current;if(H)try{H.focus(),H.select()}catch{}},J=H=>{z(H),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>z(""),2400)};(0,n.useEffect)(()=>{let H=!0;return fetch(_+"/diagnostics").then(y=>y.json()).then(y=>{H&&(y&&y.ok?(i(String(y.diagnostics||"")),M(String(y.version||""))):h(!0))}).catch(()=>{H&&h(!0)}).finally(()=>{H&&E(!1)}),()=>{H=!1}},[]),(0,n.useEffect)(()=>{let H=y=>{y.key==="Escape"&&o()};return window.addEventListener("keydown",H),()=>{window.removeEventListener("keydown",H),D.current&&clearTimeout(D.current)}},[o]);let ve=(()=>{try{return String(navigator.language||"").toLowerCase().startsWith("en")?"en":"zh"}catch{return"zh"}})(),V=()=>{let H=r.trim().split(`
306
- `)[0]||"",y=Ot({title:"[Bug] "+(H.slice(0,60)||"memory-eternal \u95EE\u9898"),body:Wt({description:r,diagnostics:d,version:S})});try{window.open(y,"_blank","noopener")}catch{J(t("fbCopyFail"))}},Le=async()=>{await Vt(d)?(w(""),J(t("fbCopiedDiag"))):(w(d),J(t("fbCopyManual")))},U=async()=>{let H=$t({lang:ve,description:r,diagnostics:d});await Vt(H)?(w(""),J(t("fbCopiedPrompt"))):(w(H),J(t("fbCopyManual")))},ue={width:"100%",resize:"vertical",padding:"8px 10px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:13},re={margin:0,maxHeight:170,overflow:"auto",fontSize:11.5,lineHeight:1.55,padding:"8px 10px",borderRadius:10,background:"var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.08))",whiteSpace:"pre-wrap"};return(0,e.jsxs)("div",{className:"me-overlay",onClick:o,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720},onClick:H=>H.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:["\u{1F41E} ",t("fbTitle")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:o,children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsx)("div",{style:{fontSize:12,opacity:.72,lineHeight:1.6},children:t("fbWhy")}),(0,e.jsx)("textarea",{value:r,onChange:H=>m(H.target.value),placeholder:t("fbDesc"),rows:5,style:ue}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("fbDiag")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Le,disabled:!d,children:t("fbCopyDiag")})]}),(0,e.jsx)("pre",{style:re,children:k?t("fbLoading"):C?t("fbDiagFail"):d})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>{if(!r.trim()){J(t("fbNeedDesc"));return}V()},style:{borderColor:"var(--dsw-alias-brand-primary, #3b82f6)",color:"var(--dsw-alias-brand-primary, #3b82f6)",fontWeight:600},children:["\u{1F680} ",t("fbOpenIssue")]}),(0,e.jsx)("span",{style:{opacity:.5,fontSize:12},children:t("fbOr")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:U,children:["\u{1F916} ",t("fbCopyPrompt")]})]}),u&&(0,e.jsx)("div",{style:{fontSize:12,color:"var(--dsw-alias-brand-primary, #3b82f6)"},children:u}),I&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12,color:"#b45309"},children:["\u26A0 ",t("fbCopyFail")]}),(0,e.jsx)("span",{style:{fontSize:11.5,opacity:.75},children:t("fbCopyManual")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:O,children:t("fbSelectAll")})]}),(0,e.jsx)("textarea",{ref:R,readOnly:!0,value:I,rows:7,style:ue})]})]})]})]})}function Pa({t,card:o,query:r,onClose:m,onDelete:d,onFeedback:i}){(0,n.useEffect)(()=>{let R=D=>{D.key==="Escape"&&m()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[m]);let{meta:S,body:M}=(0,n.useMemo)(()=>Ct(o.text||""),[o.text]),k=R=>{let D=S.find(([O])=>String(O).toLowerCase()===R);return D?D[1]:""},E=jt(k("tags")),C=k("kind")||"knowledge",h=(k("status")||"approved").toLowerCase(),u=Ue[C]||"#6B7280",z=(M||"").length>460,[I,w]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:m,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",onClick:R=>R.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:[(0,e.jsx)("span",{style:{marginRight:6},children:ht[C]||"\u{1F4CE}"}),o.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),z&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":I,onClick:()=>w(R=>!R),children:t(I?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&d&&d(o.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:m,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:u,borderColor:u+"59",background:u+"1a"},children:[ht[C]||"\u{1F4CE}"," ",t(_e[C]||"kindKnowledge")]}),(0,e.jsxs)("span",{className:"md-chip "+(h==="approved"?"md-chip-st-ok":h==="pending"?"md-chip-st-warn":"md-chip-st-bad"),children:[h==="approved"?"\u2705":h==="pending"?"\u23F3":"\u26D4"," ",t(h==="approved"?"statusApproved":h==="pending"?"statusPending":"statusRejected")]}),E.slice(0,8).map(R=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",R]},R)),!!k("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",pt(k("updated"))]}),!!k("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",k("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:I?{}:{maxHeight:300,overflow:"hidden"},onClick:I?void 0:R=>{R.stopPropagation(),w(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:Tt(M)}})}),!I&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:R=>{R.stopPropagation(),w(!0)},children:[t("expand")," \u2304"]})]})]})}function Ea({t,onOpen:o,all:r,onAllChange:m,onMutate:d,active:i,visible:S}){let[M,k]=(0,n.useState)(null),[E,C]=(0,n.useState)(""),h=(0,n.useRef)(!1),u=(0,n.useRef)(0),z=(0,n.useRef)(t);z.current=t;let I=(0,n.useCallback)(async()=>{try{h.current=!1;let O=await(await fetch(`${_}/graph${r?"?all=1":""}`)).json();O.ok?(k(O),C(""),h.current=!0):(k(null),C(O.error||t("error")))}catch(D){C(String(D&&D.message?D.message:D))}},[r,t]);(0,n.useEffect)(()=>{if(!i||h.current)return;let D=!0;return fetch(`${_}/graph${r?"?all=1":""}`).then(O=>O.json()).then(O=>{D&&(O.ok?(k(O),C(""),h.current=!0):(k(null),C(O.error||t("error"))))}).catch(O=>{D&&C(String(O&&O.message?O.message:O))}),()=>{D=!1}},[r,t,i]),(0,n.useEffect)(()=>{S&&M&&u.current++},[S,M]);let w=(0,n.useCallback)(async D=>{try{let J=await(await fetch(`${_}/delete?path=${encodeURIComponent(D)}`)).json();return J&&J.ok?(await I(),d&&d(),!0):!1}catch{return!1}},[I]),R=(0,n.useCallback)(async D=>{if(!D||D.length<2)return!1;try{let O=await fetch(`${_}/merge?paths=${encodeURIComponent(D.join(","))}`).then(J=>J.json());return O&&O.ok?(await I(),d&&d(),!0):!1}catch{return!1}},[I,d]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:He}),E&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",E]}),!M&&!E&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),M&&M.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),M&&M.nodes.length>0&&(0,e.jsx)(Ha,{nodes:M.nodes,edges:M.edges,onOpen:o,onDelete:w,onMerge:R,t,all:r,onAllChange:m,countLabel:`${M.nodes.length} ${t("nodes")} \xB7 ${Fa(M.edges)} ${t("edges")}`,fitTrigger:u.current})]})}function Fa(t){let o=new Set;for(let r of t||[])o.add([r.source,r.target].sort().join("|"));return o.size}var ct={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Ha({nodes:t,edges:o,onOpen:r,onDelete:m,onMerge:d,t:i,countLabel:S,all:M,onAllChange:k,fitTrigger:E}){let C=(0,n.useRef)(null),h=(0,n.useRef)(null),u=(0,n.useRef)(null),z=(0,n.useRef)(null),I=(0,n.useRef)(null),w=(0,n.useRef)(r);(0,n.useEffect)(()=>{w.current=r},[r]);let R=(0,n.useRef)(m);(0,n.useEffect)(()=>{R.current=m},[m]);let D=(0,n.useRef)(d);(0,n.useEffect)(()=>{D.current=d},[d]);let[O,J]=(0,n.useState)(""),[ve,V]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=O.trim().toLowerCase()},[O]),(0,n.useEffect)(()=>{let c=u.current;if(!c)return;let s=O.trim().toLowerCase();if(!s)return;let B=c.nodes.find(ie=>(ie.name||"").toLowerCase().includes(s));B&&(u.current.selectedId=B.id,V(B.id),c.panX=c.w/2-B.x*c.zoom,c.panY=c.h/2-B.y*c.zoom,c.render&&c.render())},[O]);let[U,ue]=(0,n.useState)("all"),[re,H]=(0,n.useState)(!1),y=(0,n.useRef)("all"),[j,v]=(0,n.useState)(""),te=(0,n.useRef)(""),[K,X]=(0,n.useState)(!1),oe=(0,n.useRef)(!1),[b,$]=(0,n.useState)(null);(0,n.useEffect)(()=>{y.current=U},[U]),(0,n.useEffect)(()=>{te.current=j},[j]),(0,n.useEffect)(()=>{oe.current=K},[K]);let se=(0,n.useMemo)(()=>{let c=new Map;for(let s of t)for(let B of s.tags||[]){let ie=String(B).trim();ie&&c.set(ie,(c.get(ie)||0)+1)}return[...c.entries()].sort((s,B)=>B[1]-s[1]).slice(0,24).map(([s,B])=>({tag:s,n:B}))},[t]),Y=(()=>{let c=O.trim().toLowerCase();return!!c&&!t.some(s=>(s.title||s.name||"").toLowerCase().includes(c)||String(s.kind||"").toLowerCase().includes(c)||String(_e[s.kind]||"").toLowerCase().includes(c))})();(0,n.useEffect)(()=>{let c=u.current;c&&c.wake&&c.wake()},[O]),(0,n.useEffect)(()=>{let c=u.current;c&&c.render&&c.render()},[U,j,K]);let ae=(0,n.useRef)(null),[he,Ae]=(0,n.useState)([]),[De,we]=(0,n.useState)(null),[Be,Pe]=(0,n.useState)(!1),[ze,Ce]=(0,n.useState)(null),[tt,at]=(0,n.useState)(""),Ke=(0,n.useRef)(null),qe=(0,n.useRef)(null),de=(c,s=!0)=>{Ke.current&&clearTimeout(Ke.current),Ce({msg:c,ok:s}),Ke.current=setTimeout(()=>Ce(null),1900)},Re=c=>{at(c),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>at(""),1600)};(0,n.useEffect)(()=>()=>{Ke.current&&clearTimeout(Ke.current),qe.current&&clearTimeout(qe.current)},[]);let ke=(0,n.useMemo)(()=>t.reduce((c,s)=>(c[s.id]=s,c),{}),[t]);return(0,n.useEffect)(()=>{let c=C.current;if(!c||t.length===0)return;let s=c.getContext("2d");if(!s)return;let B=Math.max(1,window.devicePixelRatio||1),ie=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};o.forEach(p=>{ce[p.source]=(ce[p.source]||0)+1,ce[p.target]=(ce[p.target]||0)+1});let me=Math.max(1,...Object.values(ce)),a={nodes:t.map(p=>({id:p.id,name:p.title||"",type:p.kind||"other",r:9+Math.min(10,(ce[p.id]||0)/me*8),x:0,y:0,vx:0,vy:0})),edges:o.map(p=>({sourceNodeId:p.source,targetNodeId:p.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:B,ctx:s,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((p,T)=>(p[T.id]=T,p),{}),a.nodes.forEach((p,T)=>{let N=T/a.nodes.length*Math.PI*2-Math.PI/2;p.x=Math.cos(N)*60,p.y=Math.sin(N)*60});let be=[...new Set(a.nodes.map(p=>p.type))];a.clustered=be.length>1,a.typeCenters={},be.forEach((p,T)=>{let N=T/be.length*Math.PI*2-Math.PI/2;a.typeCenters[p]={x:Math.cos(N)*160,y:Math.sin(N)*160}}),u.current=a;let it=0,Ne=0,l=()=>{let p=c.clientWidth,T=c.clientHeight;a.w=p,a.h=T,c.width=p*B,c.height=T*B,s.setTransform(B,0,0,B,0,0),(it===0||Ne===0)&&p>0&&T>0&&a.tickCount>0&&requestAnimationFrame(()=>L()),it=p,Ne=T};l();let A=new ResizeObserver(l);A.observe(c.parentElement);let F=(p,T)=>p&&p.length>T?p.slice(0,T)+"\u2026":p,G=(p,T,N,P)=>{if(s.beginPath(),P==="rect")s.rect(p-N,T-N*.75,N*2,N*1.5);else if(P==="diamond")s.moveTo(p,T-N),s.lineTo(p+N,T),s.lineTo(p,T+N),s.lineTo(p-N,T),s.closePath();else if(P==="hexagon"){for(let W=0;W<6;W++){let le=Math.PI/3*W-Math.PI/2,Z=p+N*Math.cos(le),Se=T+N*Math.sin(le);W===0?s.moveTo(Z,Se):s.lineTo(Z,Se)}s.closePath()}else s.arc(p,T,N,0,Math.PI*2)},g=new Map,x=(p,T)=>{let N=p+"|"+Math.round(T),P=g.get(N);if(!P){let W=parseInt(p.slice(1,3),16),le=parseInt(p.slice(3,5),16),Z=parseInt(p.slice(5,7),16);P=s.createRadialGradient(-T*.3,-T*.3,0,0,0,T*1.2),P.addColorStop(0,"rgba("+Math.min(255,W+70)+","+Math.min(255,le+70)+","+Math.min(255,Z+70)+",0.95)"),P.addColorStop(1,p),g.set(N,P)}return P},L=()=>{if(!a.nodes.length)return;let p=1/0,T=-1/0,N=1/0,P=-1/0;a.nodes.forEach(Oe=>{p=Math.min(p,Oe.x),T=Math.max(T,Oe.x),N=Math.min(N,Oe.y),P=Math.max(P,Oe.y)});let W=20,le=T-p+W*2,Z=P-N+W*2,Se=Math.min(a.w/le,a.h/Z);a.zoom=Math.max(.35,Math.min(1.8,Se)),a.panX=a.w/2-(p+T)/2*a.zoom,a.panY=a.h/2-(N+P)/2*a.zoom};z.current=L;let ne=()=>{s.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=y.current,a.timeMode=oe.current,a.tagFilter=te.current;let p=a.tagFilter,T=a.kindFilter,N=f=>String(f||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.save(),s.strokeStyle=ie()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",s.lineWidth=.5;for(let f=0;f<a.w;f+=24)s.beginPath(),s.moveTo(f,0),s.lineTo(f,a.h),s.stroke();for(let f=0;f<a.h;f+=24)s.beginPath(),s.moveTo(0,f),s.lineTo(a.w,f),s.stroke();s.restore(),s.save(),s.translate(a.panX,a.panY),s.scale(a.zoom,a.zoom);let P={};a.nodes.forEach(f=>P[f.id]=f);let W=a.nodes.length>40,le=W?1.5:.55,Z=a.selectedId||a.hoverId,Se=_t({panX:a.panX,panY:a.panY,zoom:a.zoom,w:a.w,h:a.h,margin:80}),Oe=(()=>{let f=(a.searchTerm||"").toLowerCase();if(!f)return null;let Q=[];for(let ee of a.nodes){let xe=(a.domainById[ee.id]||{}).kind||"other";if(((ee.name||"").toLowerCase().includes(f)||String(_e[xe]||"").toLowerCase().includes(f)||String(xe).toLowerCase().includes(f))&&Q.push(ee.id),Q.length>200)break}return Q})(),nt=Kt(a.nodes,{limit:Ut(a.nodes.length),focusId:Z,hoverId:a.hoverId,searchHits:Oe,degree:ce}),pe=new Map,ye=(f,Q)=>{let ee=f+"|"+Q,fe=pe.get(ee);return fe===void 0&&(s.font=f,fe=s.measureText(Q).width,pe.set(ee,fe)),fe},Ee=a.nodes.length<=250,We=new Map;a.edges.forEach(f=>{let Q=P[f.sourceNodeId],ee=P[f.targetNodeId];if(!Q||!ee||!Nt(Q.x,Q.y,10,Se)&&!Nt(ee.x,ee.y,10,Se))return;if(T!=="all"){let rt=a.domainById[f.sourceNodeId]&&a.domainById[f.sourceNodeId].kind,Ze=a.domainById[f.targetNodeId]&&a.domainById[f.targetNodeId].kind;if(rt!==T&&Ze!==T)return}if(p){let rt=a.domainById[f.sourceNodeId]&&(a.domainById[f.sourceNodeId].tags||[]).includes(p),Ze=a.domainById[f.targetNodeId]&&(a.domainById[f.targetNodeId].tags||[]).includes(p);if(!rt&&!Ze)return}let fe=ee.x-Q.x,xe=ee.y-Q.y,Ie=Math.sqrt(fe*fe+xe*xe)||1,Qe=W?12:18,et=-xe/Ie*Qe,xt=fe/Ie*Qe,wt=(Q.x+ee.x)/2+et,kt=(Q.y+ee.y)/2+xt,mt=ct.colors[a.domainById[Q.id]&&a.domainById[Q.id].kind||"other"],gt=Z&&(f.sourceNodeId===Z||f.targetNodeId===Z),Mt=Z?gt?.6:.08:W?.14:.24,Je=parseInt(mt.slice(1,3),16),ft=parseInt(mt.slice(3,5),16),Dt=parseInt(mt.slice(5,7),16),Ge=gt?1.6+(f.weight||1):.8+(f.weight||1)*.5,ot=Je+","+ft+","+Dt+","+Mt+","+Ge,$e=We.get(ot);$e||($e={path:new Path2D,stroke:"rgba("+Je+","+ft+","+Dt+","+Mt+")",width:Ge},We.set(ot,$e)),$e.path.moveTo(Q.x,Q.y),$e.path.quadraticCurveTo(wt,kt,ee.x,ee.y)}),We.forEach(f=>{s.strokeStyle=f.stroke,s.lineWidth=f.width,s.stroke(f.path)});let Fe=null;Z&&(Fe=new Set,a.edges.forEach(f=>{f.sourceNodeId===Z?Fe.add(f.targetNodeId):f.targetNodeId===Z&&Fe.add(f.sourceNodeId)}));let Xe=[];if(a.nodes.forEach(f=>{if(!Nt(f.x,f.y,f.r+2,Se))return;let Q=a.domainById[f.id]||{},ee=Q.kind||"other",fe=a.timeMode?ja(Q.updated):ct.colors[ee],xe=ct.shapes[ee],Ie=a.selectedId===f.id,Qe=a.hoverId===f.id,et=a.searchTerm||"",xt=!et||(f.name||"").toLowerCase().includes(et)||String(_e[ee]||"").toLowerCase().includes(et)||String(ee).toLowerCase().includes(et),wt=T==="all"||ee===T,kt=!p||(Q.tags||[]).includes(p),mt=Z&&f.id!==Z&&!(Fe&&Fe.has(f.id))||et&&!xt||!wt||!kt;s.save(),s.globalAlpha=mt?.08:1,(Ie||Qe)&&Ee&&(s.shadowColor=fe,s.shadowBlur=Ie?20:14),s.translate(f.x,f.y),G(0,0,f.r,xe),s.fillStyle=x(fe,f.r),s.fill(),s.restore(),Ie?(s.save(),G(f.x,f.y,f.r+3,xe),s.strokeStyle=fe,s.lineWidth=3,s.shadowColor=fe,s.shadowBlur=12,s.stroke(),s.restore()):Qe?(s.save(),G(f.x,f.y,f.r+2,xe),s.strokeStyle=fe,s.lineWidth=2,s.stroke(),s.restore()):et&&xt?(s.save(),G(f.x,f.y,f.r+2,xe),s.strokeStyle="#e11d48",s.lineWidth=2,s.stroke(),s.restore()):a.multi.indexOf(f.id)>=0&&(s.save(),G(f.x,f.y,f.r+2,xe),s.strokeStyle="#60a5fa",s.lineWidth=2,s.shadowColor="#60a5fa",s.shadowBlur=8,s.stroke(),s.restore());let gt=F(f.name,16);if((Ie||Qe||nt.has(f.id)&&a.zoom>le||!W&&a.zoom>.6)&&wt&&kt){let Je=1/a.zoom,ft="500 "+(12*Je).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";s.font=ft;let Ge=ye(ft,gt)+16*Je,ot=18*Je,$e=f.y+f.r+8*Je,rt=!0;for(let Ze of Xe)if(f.x-Ge/2<Ze.x+Ze.w&&f.x+Ge/2>Ze.x&&$e<Ze.y+Ze.h&&$e+ot>Ze.y){rt=!1;break}if(!rt&&!Ie&&!Qe)return;Xe.push({x:f.x-Ge/2,y:$e,w:Ge,h:ot}),s.fillStyle=ie()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",s.beginPath(),s.roundRect?s.roundRect(f.x-Ge/2,$e,Ge,ot,4*Je):s.rect(f.x-Ge/2,$e,Ge,ot),s.fill(),s.strokeStyle=ie()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",s.lineWidth=1*Je,s.stroke(),s.fillStyle=ie()?Ie||Qe?"#eee":"#bbb":Ie||Qe?"#111":"#444",s.textAlign="center",s.fillText(gt,f.x,$e+13*Je)}}),s.restore(),a.marquee){let f=a.marquee,Q=Math.min(f.sx,f.ex),ee=Math.min(f.sy,f.ey),fe=Math.abs(f.ex-f.sx),xe=Math.abs(f.ey-f.sy);s.save(),s.setLineDash([4,4]),s.strokeStyle="rgba(96,165,250,0.9)",s.lineWidth=1,s.fillStyle="rgba(96,165,250,0.12)",s.fillRect(Q,ee,fe,xe),s.strokeRect(Q,ee,fe,xe),s.restore()}if(a.hoverId&&ae.current){let f=a.domainById[a.hoverId],Q=a.nodes.find(function(ee){return ee.id===a.hoverId});if(f&&Q){let ee=a.edges.filter(function(Ie){return Ie.sourceNodeId===f.id||Ie.targetNodeId===f.id}).length,fe=Q.x*a.zoom+a.panX,xe=Q.y*a.zoom+a.panY;ae.current.style.display="block",ae.current.style.left=fe+14+"px",ae.current.style.top=xe-6+"px",ae.current.innerHTML="<b>"+N(f.title||f.name||"")+'</b><br/><span style="opacity:.8">'+N(f.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",ee)+"</span>"}}else ae.current&&(ae.current.style.display="none")},q=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Me))};a.wake=q,a.render=ne;let ge=()=>{let p=a.nodes.length;a.tickCount++;let N=.9-Math.min(.4,a.tickCount/1500),P=p>1e3?3e3:p>100?2e3:p>50?1200:800,W=p>100?.002:.005,le=p>1e3?.012:p>100?.005:.01,Z=p>1e3?6:p>200?12:24,Se={};a.nodes.forEach(pe=>Se[pe.id]=pe);for(let pe=0;pe<p;pe++){if(a.dragNode===a.nodes[pe])continue;let ye=a.nodes[pe],Ee=0,We=0;for(let f=0;f<p;f++){if(pe===f)continue;let Q=ye.x-a.nodes[f].x,ee=ye.y-a.nodes[f].y,fe=Math.sqrt(Q*Q+ee*ee)||1,xe=P/(fe*fe);Ee+=Q/fe*xe,We+=ee/fe*xe}if(a.clustered&&a.typeCenters[ye.type]){let f=a.typeCenters[ye.type];Ee+=(f.x-ye.x)*.006,We+=(f.y-ye.y)*.006}else Ee-=ye.x*le,We-=ye.y*le;let Fe=(ye.vx+Ee)*N,Xe=(ye.vy+We)*N;Fe=Math.max(-Z,Math.min(Z,Fe)),Xe=Math.max(-Z,Math.min(Z,Xe)),ye.vx=Fe,ye.vy=Xe}a.edges.forEach(pe=>{let ye=Se[pe.sourceNodeId],Ee=Se[pe.targetNodeId];if(!ye||!Ee)return;let We=Ee.x-ye.x,Fe=Ee.y-ye.y,Xe=Math.sqrt(We*We+Fe*Fe)||1,f=(Xe-100)*W,Q=We/Xe*f,ee=Fe/Xe*f;a.dragNode!==ye&&(ye.vx+=Q,ye.vy+=ee),a.dragNode!==Ee&&(Ee.vx-=Q,Ee.vy-=ee)});let Oe=0;a.nodes.forEach(pe=>{a.dragNode!==pe&&(pe.x+=pe.vx,pe.y+=pe.vy,Oe+=pe.vx*pe.vx+pe.vy*pe.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,L()),(p?Math.sqrt(Oe/p):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Me=()=>{if(a.running){try{ge(),ne()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Me)}},Te=(p,T)=>{let N=c.getBoundingClientRect();return{x:(p-N.left-a.panX)/a.zoom,y:(T-N.top-a.panY)/a.zoom}},Ve=p=>{let T=a.domainById[p];return!(!T||y.current!=="all"&&T.kind!==y.current||te.current&&!(T.tags||[]).includes(te.current))},je=(p,T,N)=>Math.max(T,Math.min(N,p)),Ye=p=>{a.mouseX=p.clientX,a.mouseY=p.clientY;let T=Te(p.clientX,p.clientY),N=null;for(let P=a.nodes.length-1;P>=0;P--){let W=a.nodes[P];if(!Ve(W.id))continue;let le=W.x-T.x,Z=W.y-T.y;if(le*le+Z*Z<W.r*W.r+36){N=W.id;break}}N!==a.hoverId&&(a.hoverId=N,q())},vt=p=>{if(p.button!==0)return;let T=Te(p.clientX,p.clientY),N=null;for(let P=a.nodes.length-1;P>=0;P--){let W=a.nodes[P];if(!Ve(W.id))continue;let le=W.x-T.x,Z=W.y-T.y;if(le*le+Z*Z<W.r*W.r+25){N=W;break}}if(p.shiftKey){if(N){a.shiftClick=N.id;return}a.marquee={sx:p.clientX,sy:p.clientY,ex:p.clientX,ey:p.clientY};return}a.dragStart={x:p.clientX,y:p.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=N||null,N&&(a.dragOffset={dx:N.x-T.x,dy:N.y-T.y})},At=p=>{if(a.marquee){a.marquee.ex=p.clientX,a.marquee.ey=p.clientY,q();return}if(!a.dragStart)return;let T=p.clientX-a.dragStart.x,N=p.clientY-a.dragStart.y;if(Math.abs(T)+Math.abs(N)>3&&(a.dragging=!0),a.dragNode){let P=Te(p.clientX,p.clientY);a.dragNode.x=P.x+a.dragOffset.dx,a.dragNode.y=P.y+a.dragOffset.dy,q()}else a.dragging&&(a.panX=je(a.dragStart.px+T,-1e5,1e5),a.panY=je(a.dragStart.py+N,-1e5,1e5),q())},Bt=p=>{if(a.marquee){let N=a.marquee;a.marquee=null;let P=c.getBoundingClientRect(),W=Math.min(N.sx,N.ex)-P.left,le=Math.max(N.sx,N.ex)-P.left,Z=Math.min(N.sy,N.ey)-P.top,Se=Math.max(N.sy,N.ey)-P.top,Oe=a.nodes.filter(nt=>{let pe=nt.x*a.zoom+a.panX,ye=nt.y*a.zoom+a.panY;return pe>=W&&pe<=le&&ye>=Z&&ye<=Se}).map(nt=>nt.id);a.multi=Oe,Ae(Oe),q();return}let T=a.dragStart&&!a.dragging;if(a.shiftClick){let N=a.shiftClick;a.shiftClick=null;let P=Array.isArray(a.multi)?a.multi.slice():[];P.includes(N)||P.push(N),a.multi=P,Ae(P),q();return}if(T){let N=Te(p.clientX,p.clientY),P=null;for(let W=a.nodes.length-1;W>=0;W--){let le=a.nodes[W];if(!Ve(le.id))continue;let Z=le.x-N.x,Se=le.y-N.y;if(Z*Z+Se*Se<le.r*le.r+20){P=le;break}}P?(a.selectedId=P.id,V(P.id),q()):(a.selectedId=null,a.hoverId=null,p.shiftKey||(a.multi=[],Ae([])),V(null),q())}a.dragStart=null,a.dragging=!1,a.dragNode=null},Pt=p=>{p.preventDefault();let T=Te(p.clientX,p.clientY),N=null;for(let P=a.nodes.length-1;P>=0;P--){let W=a.nodes[P];if(!Ve(W.id))continue;let le=W.x-T.x,Z=W.y-T.y;if(le*le+Z*Z<W.r*W.r+25){N=W;break}}if(N){let P=a.domainById[N.id];P&&$({x:p.clientX,y:p.clientY,id:N.id,path:P.id,title:P.title})}else $(null)},Et=p=>{p.preventDefault();let T=c.getBoundingClientRect(),N=(p.clientX-T.left-a.panX)/a.zoom,P=(p.clientY-T.top-a.panY)/a.zoom,W=Math.max(.3,Math.min(3,a.zoom*(p.deltaY<0?1.1:1/1.1)));a.panX=je(a.panX+N*(a.zoom-W),-1e5,1e5),a.panY=je(a.panY+P*(a.zoom-W),-1e5,1e5),a.zoom=W,q()};c.addEventListener("mousemove",Ye),c.addEventListener("mousedown",vt),window.addEventListener("mousemove",At),window.addEventListener("mouseup",Bt),c.addEventListener("wheel",Et,{passive:!1}),c.addEventListener("contextmenu",Pt),I.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Ae([]),L(),q()};for(let p=0;p<200;p++)ge();L(),q();let Ft=()=>H(!1);return window.addEventListener("mousedown",Ft),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),A.disconnect(),c.removeEventListener("mousemove",Ye),c.removeEventListener("mousedown",vt),window.removeEventListener("mousemove",At),window.removeEventListener("mouseup",Bt),c.removeEventListener("wheel",Et),c.removeEventListener("contextmenu",Pt),window.removeEventListener("mousedown",Ft)}},[t,o]),(0,n.useEffect)(()=>{E!==void 0&&z.current&&requestAnimationFrame(()=>z.current())},[E]),(0,e.jsxs)("div",{className:"me-graph",ref:h,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",o.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:O,onChange:c=>J(c.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>H(c=>!c),"aria-expanded":re,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",U!=="all"||K||j?"\u25CF":"\u25BE"]}),re&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:c=>c.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${U==="all"&&!K?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{ue("all"),X(!1)},children:i("all")}),Object.keys(Ue).map(c=>(0,e.jsxs)("button",{type:"button",className:`lg${U===c?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ue(s=>s===c?"all":c),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[c]||Ue[c]}}),i(_e[c])]},c)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${K?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>X(c=>!c),children:["\u23F1 ",i("timeDim")]}),se.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:se.map(c=>(0,e.jsxs)("button",{type:"button",className:`lg${j===c.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>v(s=>s===c.tag?"":c.tag),title:c.tag,children:["#",c.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:c.n})]},c.tag))})]}),(U!=="all"||K||j)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{ue("all"),X(!1),v("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!M,onChange:c=>k&&k(c.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${K?" me-on":""}`,onClick:()=>X(c=>!c),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=C.current;if(c)try{c.toBlob(s=>{s&&we({url:URL.createObjectURL(s),blob:s})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>z.current&&z.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{V(null),ue("all"),I.current&&I.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:C,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ae,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Y&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),b&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>$(null)}),b&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:b.x,top:b.y,zIndex:31},onMouseDown:c=>c.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{w.current({path:b.path,title:b.title}),$(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{b.id&&(u.current.selectedId=b.id,V(b.id)),$(null);let c=u.current;c&&c.wake&&c.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(b.title||"")}catch{}$(null),de(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let c=u.current,s=c&&Array.isArray(c.multi)?c.multi.slice():[],B=b.id;if(B&&!s.includes(B)&&s.push(B),$(null),s.length<2){de(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let ie=D.current&&D.current(s);ie&&ie.then?ie.then(ce=>ce?de(i("merged")):de(i("mergeFail"),!1)).catch(()=>de(i("mergeFail"),!1)):ie&&de(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let c=b.path;$(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(R.current?await R.current(c):!1)?de(i("deleted")):de(i("deleteFail"),!1)}catch{de(i("deleteFail"),!1)}})()},children:i("delete")})]}),he.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[he.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=he.map(me=>ke[me]).filter(Boolean).map(me=>me.title||me.name).join(`
307
- `),B=new Blob([s],{type:"text/plain;charset=utf-8"}),ie=URL.createObjectURL(B),ce=document.createElement("a");ce.href=ie,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(ie),1e3),de(he.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(he.length<2){de(i("mergeNeed"),!1);return}let c=he.map(B=>ke[B]?ke[B].id:B);if(!window.confirm(i("mergeConfirm")))return;Ae([]);let s=u.current;s&&(s.multi=[]),fetch(`${_}/merge?paths=${encodeURIComponent(c.join(","))}`).then(B=>B.json()).then(B=>{B&&B.ok?de(i("merged")):de(i("mergeFail"),!1)}).catch(()=>de(i("mergeFail"),!1))},children:i("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(i("deleteConfirm")))return;let c=he.map(B=>ke[B]?ke[B].id:B);Ae([]);let s=u.current;s&&(s.multi=[]),(async()=>{let B=0;for(let ie of c)try{(R.current?await R.current(ie):!1)&&B++}catch{}de(B+i("deletedSelected"),B>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=u.current;c&&(c.multi=[]),Ae([]);let s=u.current;s&&s.render&&s.render()},children:i("clearSelection")})]}),ve&&(0,e.jsxs)("div",{className:"me-graph-sidebar",style:{position:"absolute",right:10,top:10,zIndex:3,maxWidth:240,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:12,fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:ke[ve]?ke[ve].title||ke[ve].name:ve}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ke[ve]?i(_e[ke[ve].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(o.filter(c=>c.source===ve||c.target===ve)||[]).slice(0,8).map((c,s)=>{let B=c.source===ve?c.target:c.source,ie=ke[B];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let me=u.current;me&&(me.selectedId=B,me.hoverId=B,me.wake&&me.wake()),V(B)},children:ie?(ie.title||ie.name).slice(0,28):B},s)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),ze&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ze.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ze.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ze.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ze.msg})]}),De&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{De.url&&URL.revokeObjectURL(De.url),we(null),Pe(!1)},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:Be?"100vw":900,width:Be?"100vw":"92vw",maxHeight:Be?"100%":"90vh",height:Be?"100%":void 0,borderRadius:Be?0:14},onClick:c=>c.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:De.url,download:"memory-graph.png",onClick:()=>{Re("download"),de(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(tt==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Re("full"),Pe(c=>!c),de(i("fullscreen"))},children:i(tt==="full"?"done":Be?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=De.blob;c&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":c})]).then(()=>{Re("copy"),de(i("copied"))}).catch(()=>{de(i("copyFail"),!1)}):de(i("copyFail"),!1)},children:i(tt==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{De.url&&URL.revokeObjectURL(De.url),we(null),Pe(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:Be?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:De.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:Be?"calc(100% - 64px)":"70vh",borderRadius:Be?0:8,cursor:"zoom-in"},onClick:()=>Pe(c=>!c)})})]})]})]})}function ja(t){let o=new Date(t||0).getTime();if(!o)return"#94a3b8";let r=(Date.now()-o)/864e5;return r<3?"#10b981":r<14?"#f59e0b":r<30?"#f97316":"#94a3b8"}function Yt({label:t,value:o=[],options:r,onChange:m,placeholder:d,z:i=20}){let[S,M]=(0,n.useState)(!1),k=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!S)return;let w=R=>{k.current&&!k.current.contains(R.target)&&M(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[S]);let E=Array.isArray(o)?o:[],C=E.includes("__all__"),h=C?r.find(w=>w.value==="__all__")?.label||"":E.length?E.map(w=>r.find(R=>R.value===w)?.label||w).join("\u3001"):"",u=(w,R)=>{if(w.value==="__all__"){m(R?["__all__"]:[]);return}let D=new Set(E);D.has("__all__")&&D.delete("__all__"),R?D.add(w.value):D.delete(w.value),m([...D])},z=r.find(w=>w.value==="__all__"),I=r.filter(w=>w.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:t}),(0,e.jsxs)("div",{ref:k,style:{position:"relative",minWidth:0},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>M(w=>!w),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h||d||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),S&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[z&&(0,e.jsxs)("label",{onClick:w=>w.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("input",{type:"checkbox",checked:C,onChange:w=>u(z,w.target.checked)}),(0,e.jsx)("span",{children:z.label})]}),I.map(w=>(0,e.jsxs)("label",{onClick:R=>R.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:E.includes(w.value),onChange:R=>u(w,R.target.checked)}),(0,e.jsx)("span",{children:w.label})]},w.value))]})]})]})}function Oa(t){let o=new Date(t||0).getTime();return!!o&&(Date.now()-o)/864e5<3}async function Wa(t,o,r){if(r&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:o}),S=await i.createWritable();return await S.write(t),await S.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let m=URL.createObjectURL(t),d=document.createElement("a");return d.href=m,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(m),1e3),{ok:!0,picked:!1,name:o}}function Gt(t,o){if(!o||!t)return t;let r=t.toLowerCase(),m=o.toLowerCase(),d=[],i=0;for(;i<t.length;){let S=r.indexOf(m,i);if(S<0){d.push(t.slice(i));break}S>i&&d.push(t.slice(i,S)),d.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(S,S+m.length)},S)),i=S+m.length}return d}function pt(t){if(!t)return"";let o=new Date(t);if(Number.isNaN(o.getTime()))return"";let r=new Date,m=o.toDateString()===r.toDateString(),d=S=>String(S).padStart(2,"0"),i=`${d(o.getHours())}:${d(o.getMinutes())}`;return m?i:`${o.getMonth()+1}-${o.getDate()} ${i}`}
305
+ `);let ze=new Blob([q],{type:Me}),Ve=await Wa(ze,ue,!1);if(!Ve.ok){p({ok:!1,msg:t("exportFail")}),P(!1);return}p({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Ve.name})}catch(A){p({ok:!1,msg:t("exportFail")+" \xB7 "+(A.message||"")})}finally{P(!1)}L.current&&clearTimeout(L.current),L.current=setTimeout(()=>p(null),2600)},E=async b=>{let v=b.target.files&&b.target.files[0];if(b.target.value="",!!v){try{let A=await v.text(),q=await(await fetch(`${U}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:A})).json();if(q.ok){await pe();let ue=q.imported||0,Me=t("importedVault")+"\uFF1A"+ue;q.total&&(Me+=t("importedTotal")+q.total+t("importedTotalTail")),q.quarantined&&(Me+=t("importedQuarantine")+q.quarantined+t("importedQuarantineTail")),q.skipped&&(Me+=t("importedSkipped")+q.skipped+t("importedSkippedTail")),q.warning&&(Me+=" \xB7 "+q.warning),p({ok:ue>0||!q.total,msg:Me})}else p({ok:!1,msg:q.error||t("importFail")})}catch{p({ok:!1,msg:t("importFail")})}L.current&&clearTimeout(L.current),L.current=setTimeout(()=>p(null),2400)}},W=(0,n.useMemo)(()=>{let b=M.slice();return Z!=="all"&&(b=b.filter(v=>ut(v.submittedBy)===Z)),V!=="all"&&(b=b.filter(v=>(v.status||"approved")===V)),ye==="title"?b.sort((v,A)=>String(v.title||"").localeCompare(String(A.title||""))):ye==="hot"?b.sort((v,A)=>(A.weight||A.links||0)-(v.weight||v.links||0)):b.sort((v,A)=>new Date(A.updated||0).getTime()-new Date(v.updated||0).getTime()),b},[M,ye,Z,V]),J=(0,n.useMemo)(()=>[...new Set(M.map(b=>ut(b.submittedBy)))],[M]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:He}),ve&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ve.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ve.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ve.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:ve.msg})]}),o&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(Qt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),g&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:g,"aria-label":t(d?"exitFull":"fullscreen"),children:d?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:r,"aria-label":t("close"),children:"\u2715"})]}),h&&h.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[h.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:h.since?pt(new Date(h.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${we?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Be(b=>!b),"aria-label":t(we?"collapse":"expand"),title:t(we?"collapse":"expand"),children:we?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="cards"?" active":""}`,onClick:()=>ae("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="graph"?" active":""}`,onClick:()=>ae("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="stats"?" active":""}`,onClick:()=>ae("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="audit"?" active":""}`,onClick:()=>ae("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")}),Ke>0&&(0,e.jsx)("span",{className:"mc-dot",children:Ke>99?"99+":Ke})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="optimize"?" active":""}`,onClick:()=>ae("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")}),qe>0&&(0,e.jsx)("span",{className:"mc-dot",style:{background:"#6b7280"},children:qe>99?"99+":qe})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${K==="config"?" active":""}`,onClick:()=>ae("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]}),(0,e.jsxs)("button",{type:"button",className:"mc-railbtn",onClick:()=>De(!0),title:t("fbNav"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F41E}"}),we&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("fbNav")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:oe,children:[K==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(dt,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(dt,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(dt,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(dt,{label:t("pending"),value:i?.quarantine?.pending??i?.status?.pending??0}),(0,e.jsx)(dt,{label:t("rejected"),value:i?.quarantine?.rejected??i?.status?.rejected??0}),(0,e.jsx)(dt,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),K==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:C,onChange:b=>ge(b.target.value)}),(0,e.jsx)("input",{ref:G,type:"file",accept:".json,application/json",style:{display:"none"},onChange:E}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>G.current&&G.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>Te({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:u,onClick:()=>l("md"),children:t(u?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:u,onClick:()=>l("json"),children:t(u?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>pe(),children:t("refresh")})]}),K==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Lt.map(b=>(0,e.jsx)("button",{type:"button",className:`mc-chip${x===b?" active":""}`,onClick:()=>it(b),children:t(b==="all"?"all":_e[b])},b)),(0,e.jsxs)("select",{value:Z,onChange:b=>he(b.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Zt(J).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsxs)("select",{value:V,onChange:b=>Le(b.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(b=>(0,e.jsx)("button",{type:"button",className:`mc-chip${ye===b.key?" active":""}`,onClick:()=>R(b.key),children:b.label},b.key))]}),T&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T]}),(0,e.jsx)("div",{style:{display:K==="cards"?"contents":"none"},children:j?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):T?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>pe(),children:t("retry")})]}):M.length===0?(0,e.jsx)("div",{className:"mc-empty",children:t("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:W.map(b=>(0,e.jsx)(Ia,{card:b,t,query:C.trim(),onOpen:Ne,onDelete:a},b.path))}),M.length<Re&&(0,e.jsx)("div",{ref:F,style:{height:1}}),c&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",M.length," / ",Re,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:K==="graph"?"flex":"none",flex:1,minHeight:0},children:ie.has("graph")&&(0,e.jsx)(Ea,{t,onOpen:Ne,all:Y,onAllChange:fe,onMutate:at,active:K==="graph",visible:K==="graph"})}),(0,e.jsx)("div",{style:{display:K==="config"?"contents":"none"},children:ie.has("config")&&(0,e.jsx)(ta,{t,onReload:()=>pe(),version:Ce})}),(0,e.jsx)("div",{style:{display:K==="stats"?"contents":"none"},children:ie.has("stats")&&(0,e.jsx)(La,{t,tab:"stats",onReload:()=>pe(),version:Ce})}),(0,e.jsx)("div",{style:{display:K==="audit"?"contents":"none"},children:ie.has("audit")&&(0,e.jsx)(za,{t,onReload:()=>pe(),version:Ce})}),(0,e.jsx)("div",{style:{display:K==="optimize"?"contents":"none"},children:ie.has("optimize")&&(0,e.jsx)(Ra,{t,onReload:()=>pe(),version:Ce})}),Ae&&(0,e.jsx)(Ba,{t,onClose:()=>De(!1)}),X&&(0,e.jsx)(Pa,{t,card:X,query:C.trim(),onClose:()=>B(null),onDelete:b=>{B(null),a(b)},onFeedback:b=>{let v=X.path;fetch(`${U}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:C.trim(),path:v,useful:b})}).then(()=>p({ok:!0,msg:t(b?"fbUseful":"fbIrr")})).catch(()=>{}),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>p(null),2e3)}}),(0,e.jsx)(Aa,{t,newCard:Pe,setNewCard:Te,onCreated:()=>{pe(),at(),p({ok:!0,msg:t("created")}),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>p(null),2e3)}})]})]})]})}var ea=({toast:t})=>t?(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"8px 12px",fontSize:12,borderLeft:"4px solid "+(t.ok?"#10b981":"#ef4444"),background:t.ok?"rgba(16,185,129,0.08)":"rgba(239,68,68,0.08)"},children:[t.ok?"\u2705":"\u26A0"," ",t.msg]}):null,dt=({label:t,value:o})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:o}),(0,e.jsx)("span",{children:t})]});function ta({t,onReload:o,version:r,compact:g}){let[d,i]=(0,n.useState)(null),[k,M]=(0,n.useState)(0),[w,j]=(0,n.useState)(null),[S,h]=(0,n.useState)(null),[f,T]=(0,n.useState)(!1),[I,x]=(0,n.useState)(!1),D=(0,n.useRef)(!1),C=(0,n.useRef)(null),$=(0,n.useRef)({}),[Z,he]=(0,n.useState)(null),[V,Le]=(0,n.useState)(null),[K,de]=(0,n.useState)(""),[ie,O]=(0,n.useState)(""),[ae,ye]=(0,n.useState)(""),[R,ve]=(0,n.useState)(null),p=(0,n.useCallback)(async l=>{O("version");try{let E=await fetch(U+"/version-check"+(l?"?force=1":"")).then(W=>W.json());E&&E.ok?(ve(E),l&&B(E.updateAvailable?t("vcLatest")+" v"+E.latest:t("vcUpToDate"))):l&&B(t("vcCheckFail"),!1)}catch{l&&B(t("vcCheckFail"),!1)}finally{O("")}},[t]);(0,n.useEffect)(()=>{p(!1)},[r,p]);let[L,G]=(0,n.useState)(""),[u,P]=(0,n.useState)(null),X=(0,n.useRef)(null),B=(l,E=!0)=>{X.current&&clearTimeout(X.current),P({msg:l,ok:E}),X.current=setTimeout(()=>P(null),1900)},Y=async()=>{if(!ie){O("restart");try{let l=await fetch(U+"/restart-self",{method:"POST"});if(l.status===404||l.status===405){B(Pe("vcRestartNoRoute",{cmd:R&&R.restartCommand||"dsh-memory restart --port 7999"}),!1);return}let E=await l.json().catch(()=>null);if(!E){B(t("vcRestartFail")+"\uFF08HTTP "+l.status+"\uFF09",!1);return}if(!E.ok){B(E.error||t("vcRestartFail"),!1);return}if(E.alreadyCurrent){B(E.note||t("vcRestartCurrent"));return}B(E.note||t("vcRestartSent")),E.alreadyRunning||setTimeout(()=>{p(!0)},6e3)}catch(l){B(t("vcRestartFail")+"\uFF1A"+String(l&&l.message||l),!1)}finally{O("")}}},fe=R&&R.resident?String(R.resident.served||""):"",Ae=!!(R&&R.onDisk&&fe&&fe!==R.onDisk),De=!!(R&&R.resident&&R.resident.managed===!1),we=!!(R&&R.resident&&!fe),Be=Ae||we||De,Pe=(l,E)=>Object.keys(E).reduce((W,J)=>W.split("{"+J+"}").join(E[J]),t(l)),Te=(0,n.useCallback)(async()=>{try{let[l,E,W]=await Promise.all([fetch(`${U}/config`).then(J=>J.json()).catch(()=>null),fetch(`${U}/setup-status`).then(J=>J.json()).catch(()=>null),fetch(`${U}/budget`).then(J=>J.json()).catch(()=>null)]);if(l&&l.ok){i(l),M(l.revision??0),j(l.schema??null);let J=qt(l.config??{},$.current);$.current=J.overlay,h({...J.values}),he(l.dsh??null),T(l.writable===!1),x(l.viaPending===!0),de(""),D.current=!1}else W&&W.ok?(h({...W}),T(!0),de(t("configNeedsDsh"))):de(t("adminLoadFail"));E&&E.ok&&Le(E),ye("")}catch{de(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{Te()},[r,Te]);let Ce=(l,E)=>{D.current=!0,h(W=>({...W??{},[l]:E}))};(0,n.useEffect)(()=>{C.current=Te},[Te]),(0,n.useEffect)(()=>{if(typeof EventSource>"u")return;let l=null;try{l=new EventSource(U+"/events")}catch{return}let E=()=>{!D.current&&typeof C.current=="function"&&C.current()};try{l.addEventListener("config",E)}catch{}return()=>{try{l.close()}catch{}}},[]);let tt=new Set(["dedupThreshold","captureMinChars","captureCooldownMs","maxCardsPerDay","captureMaxTokens","recallMinScore","recallLimit","recallSummaryLen","recycleRetentionDays","webPort","webCheckIntervalMs","webMaxRestart","sessionBudgetChars"]),at=l=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[l]||l,Ke=async()=>{if(!S)return;if(f){B(t("editInSetting"),!1);return}let l={dedupThreshold:[0,1],captureMinChars:[0,1e6],captureCooldownMs:[0,1e9],maxCardsPerDay:[0,1e6],captureMaxTokens:[100,4e3],recallMinScore:[0,50],recallLimit:[1,20],recallSummaryLen:[40,400],recycleRetentionDays:[1,3650],webPort:[1,65535],webCheckIntervalMs:[1e3,6e5],webMaxRestart:[1,1e3],sessionBudgetChars:[0,1e9]},E=[];for(let[W,[J,b]]of Object.entries(l)){if(!(W in S))continue;let v=S[W],A=typeof v=="number"?v:Number(v);(v===""||v===null||v===void 0||!Number.isFinite(A)||A<J||A>b)&&E.push(t("invalidField",{field:W,min:J,max:b,value:String(v===""?"\u7A7A":v)}))}if(E.length){let W=t("saveInvalid")+"\uFF1A"+E.join("\uFF1B");de(W),B(W,!1);return}O("save");try{let W={...S};for(let A of Object.keys(S))A in W&&typeof W[A]=="string"&&W[A].trim()!==""&&tt.has(A)&&(W[A]=Number(W[A]));Array.isArray(W.vaultProfiles)&&(W.vaultProfiles=W.vaultProfiles.filter(A=>A&&(String(A.name||"").trim()||String(A.path||"").trim())));let J=await fetch(`${U}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:W,expectedRevision:k})}),b=await J.text(),v=null;try{v=b?JSON.parse(b):null}catch{v=null}if(v||(v={error:"HTTP "+J.status+(b?"\uFF1A"+b.slice(0,200):"\uFF08\u5BBF\u4E3B\u672A\u8FD4\u56DE\u539F\u56E0\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u6709\u6570\u5B57\u5B57\u6BB5\u4E3A\u7A7A\u6216\u8D85\u51FA\u8303\u56F4\uFF09")}),v&&v.ok){let A=typeof v.pendingOutcome=="string"?v.pendingOutcome:"",ne,q=!0;if(A==="applied")ne=t("savedApplied")+(Array.isArray(v.applied)&&v.applied.length?" \xB7 "+v.applied.join("\u3001"):"");else if(A==="queued")q=!1,ne=t("saveQueued");else if(A==="failed")q=!1,ne=t("saveFail")+" \xB7 "+(v.hostGuard?t("saveHostGuard"):t("saveFailHint"));else if(A==="applied-direct")ne=t("savedOk")+" \xB7 "+t("savedDirect");else{let ue=Array.isArray(v.pending)&&v.pending.length?" \xB7 "+t("savePending"):v.note?" \xB7 "+t("restartHint"):"";ne=(v.retried?"\u267B ":"")+t("savedOk")+ue}$.current={...$.current,...W},q?ye(ne):de(ne),B(ne,q),await Te()}else{let A=J.status===409?t("conflictRefresh"):v?.error||t("saveFail");de(A),B(A,!1)}}catch{de(t("saveFail")),B(t("saveFail"),!1)}finally{O("")}},qe=()=>{$.current={},h({...d?.config??{}}),ye("")},se={env:"vaultSrcEnv",profile:"vaultSrcProfile",workspace:"vaultSrcWorkspace",vaultDir:"vaultSrcVaultDir",default:"vaultSrcDefault"},Re=l=>Array.isArray(l?.vaultProfiles)?l.vaultProfiles:[],ke=(l,E,W)=>h(J=>{let b=Re(J).map(A=>({...A||{}})),v={...b[l]||{}};return E==="match"?String(W).trim()?v.match={...v.match||{},workspace:W}:delete v.match:v[E]=W,b[l]=v,{...J??{},vaultProfiles:b}}),c=()=>h(l=>({...l??{},vaultProfiles:[...Re(l),{name:"",path:""}]})),s=l=>h(E=>({...E??{},vaultProfiles:Re(E).filter((W,J)=>J!==l)})),F={fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},oe={padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:12,minWidth:0},le={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:4e3,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},pe=async l=>{let E=le[l];E&&h(W=>({...W??{},...E}))},a=async(l,E)=>{O(l+E);try{let J=await(await fetch(`${U}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:l,action:E})})).json();J&&J.ok?B(Pe(E==="install"?"mcpInstalled":"mcpUninstalled",{agent:l})):B(Pe("mcpActionFail",{agent:l,error:J?.error||""}),!1);try{let b=await fetch(`${U}/setup-status`).then(v=>v.json());b&&b.ok&&Le(b)}catch{}}catch{B(t("mergeFail"),!1)}finally{O("")}},ge=({k:l,label:E,type:W="text",step:J,min:b,max:v})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:E||l}),(0,e.jsx)("input",{type:W,step:J,min:b,max:v,value:S?S[l]??"":"",onChange:A=>{let ne=A.target.value;Ce(l,W==="number"?ne===""?"":Number(ne):ne)},style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),it=new Set(["autoRestartOnDrift"]),Ne=({k:l,label:E})=>{let W=S?S[l]:void 0,J=W===void 0?it.has(l):!!W;return(0,e.jsxs)("label",{style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:12,minWidth:0,lineHeight:1.5},children:[(0,e.jsx)("input",{type:"checkbox",checked:J,onChange:b=>Ce(l,b.target.checked),style:{marginTop:2,flex:"0 0 auto"}}),(0,e.jsx)("span",{style:{whiteSpace:"normal",overflowWrap:"anywhere"},children:E||l})]})};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:g?"0 0 auto":1,minHeight:0,maxHeight:g?"52vh":void 0},children:[(0,e.jsx)("style",{children:He}),u&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(u.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:u.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:u.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:u.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[K&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",K]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Te,children:["\u21BB ",t("retry")]})]}),I&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #3b82f6",background:"rgba(59,130,246,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#1d4ed8",lineHeight:1.7},children:["\u2139 ",t("pendingSyncNote")]}),f&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),ae&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",ae]}),d&&(d.version||d.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:t("dshHostLabel")}),d.version&&(0,e.jsxs)("code",{style:F,children:[t("vcLoaded")," v",d.version]}),R&&R.resident&&R.resident.served&&R.resident.served!==d.version&&(0,e.jsxs)("code",{style:F,children:[t("vcResident")," v",R.resident.served]}),R&&R.resident&&!R.resident.served&&(0,e.jsxs)("code",{style:{...F,color:"#b45309",fontWeight:600},children:[t("vcResident")," ",t("vcResidentDownShort")]}),R&&R.resident&&R.resident.served&&R.resident.managed===!1&&(0,e.jsxs)("code",{style:{...F,color:"#b45309",fontWeight:600},children:[t("vcResident")," v",R.resident.served," \xB7 ",t("vcResidentUnmanagedShort")]}),bt&&(0,e.jsxs)("code",{style:F,children:[t("vcPage")," v",bt]}),R&&R.onDisk&&(0,e.jsxs)("code",{style:F,children:[t("vcOnDisk")," v",R.onDisk]}),R&&R.latest&&(0,e.jsxs)("code",{style:F,children:[t("vcLatest")," v",R.latest]}),d.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",d.dsh.vaultDir]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:ie==="version",onClick:()=>p(!0),children:ie==="version"?t("checking"):"\u{1F504} "+t("vcCheck")})]}),R&&(R.stale||we||De)&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"6px 10px"},children:[(0,e.jsxs)("div",{children:["\u26A0\uFE0F ",R.stale?Pe("vcStale",{disk:R.onDisk,loaded:R.loaded}):we?Pe("vcResidentDown",{port:R.resident&&R.resident.port||"",cmd:R.restartCommand||"dsh-memory restart --port 7999"}):Pe("vcResidentUnmanaged",{served:fe,cmd:R.restartCommand||"dsh-memory restart --port 7999"})]}),Be?(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:6,flexWrap:"wrap"},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!ie,onClick:Y,children:ie==="restart"?"\u23F3 "+t("vcRestarting"):"\u{1F504} "+t("vcRestart")}),R.restartCommand&&(0,e.jsx)("code",{style:{fontSize:11,opacity:.75},children:R.restartCommand})]}):(0,e.jsxs)("div",{style:{marginTop:6,lineHeight:1.7},children:["\u2139\uFE0F ",t("vcHostStale"),R.restartCommand&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)("code",{style:{fontSize:11,opacity:.75},children:R.restartCommand})]})]})]}),bt&&R&&R.onDisk&&bt!==R.onDisk&&(0,e.jsx)("div",{style:{marginTop:8,fontSize:11.5,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"6px 10px",lineHeight:1.7},children:t("vcPageStale",{page:bt,disk:R.onDisk})}),R&&R.updateAvailable&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,opacity:.88},children:["\u2B06 ",t("vcOutdated")," \u2192 ",(0,e.jsx)("code",{children:R.updateCommand})]}),R&&R.checkError&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b91c1c"},children:[t("vcCheckFail"),"\uFF1A",R.checkError]})]}),V&&V.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:V.agents.map(l=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:l.isDsh?t("dshHostLabel"):l.name}),l.isDsh&&l.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",l.version]}),!l.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),l.installed&&l.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),l.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),l.mcpConfigured===!0&&l.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),l.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",l.recallTool?t("enabled"):t("disabled"),")"]})]}),l.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",l.hook]}),!l.isDsh&&l.installed&&l.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ie,onClick:()=>a(l.name,"install"),children:t("installMcp")}),!l.isDsh&&l.installed&&l.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ie,onClick:()=>{window.confirm(t("uninstallConfirm"))&&a(l.name,"uninstall")},children:t("uninstallMcp")})]},l.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),L&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:L})})]}),S?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(l=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>pe(l),disabled:!!ie,children:[l==="A"?"\u{1F7E2} ":l==="B"?"\u{1F4B0} ":"\u2B50 ",le[l].label]},l))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Ne,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(ge,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(ge,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(ge,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(ge,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(ge,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Ne,{k:"recallIncludeBody",label:t("recallBody")}),(0,e.jsx)(ge,{k:"secretHint",label:t("secretHint")}),(0,e.jsx)(ge,{k:"recallEmbedding",label:t("recallEmbedding")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #06b6d4"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5C2}\uFE0F ",t("vaultMulti")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("vaultMultiHint")})]}),(0,e.jsxs)("div",{style:{fontSize:11.5,opacity:.85,marginBottom:8,lineHeight:1.7},children:[t("vaultNow"),"\uFF1A",(0,e.jsx)("code",{children:Z?.vaultDir||"\u2014"}),Z?.vaultName?`\uFF08${Z.vaultName}\uFF09`:""," \xB7 ",t("vaultSource"),"\uFF1A",t(se[Z?.vaultSource]||"vaultSrcDefault"),Z?.workspace?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),t("vaultWorkspace"),"\uFF1A",(0,e.jsx)("code",{children:Z.workspace})]}):null]}),Re(S).map((l,E)=>(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.6fr 1.5fr auto",gap:6,marginBottom:6},children:[(0,e.jsx)("input",{value:l.name||"",placeholder:t("vaultNamePh"),onChange:W=>ke(E,"name",W.target.value),style:oe,disabled:f}),(0,e.jsx)("input",{value:l.path||"",placeholder:t("vaultPathPh"),onChange:W=>ke(E,"path",W.target.value),style:oe,disabled:f}),(0,e.jsx)("input",{value:l.match&&l.match.workspace||"",placeholder:t("vaultMatchPh"),onChange:W=>ke(E,"match",W.target.value),style:oe,disabled:f}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>s(E),disabled:f,title:t("delete"),children:"\u2715"})]},E)),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginTop:4},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:c,disabled:f,children:["\uFF0B ",t("vaultAdd")]}),(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("vaultActive")}),(0,e.jsxs)("select",{value:S.activeVault||"",onChange:l=>Ce("activeVault",l.target.value),disabled:f,style:oe,children:[(0,e.jsx)("option",{value:"",children:t("vaultActiveNone")}),Re(S).filter(l=>l&&l.name).map(l=>(0,e.jsx)("option",{value:l.name,children:l.name},l.name))]})]})]})]}),(0,e.jsx)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"enabled",label:t("enabledLabel")}),(0,e.jsx)(ge,{k:"vaultDir",label:t("vaultDirLabel")})]})}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(Ne,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Ne,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(ge,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(ge,{k:"recallMinScore",label:t("recallMinScore"),type:"number"}),(0,e.jsx)(ge,{k:"captureCooldownMs",label:t("captureCooldownMs"),type:"number"}),(0,e.jsx)(ge,{k:"captureProvider",label:t("captureProvider")}),(0,e.jsx)(ge,{k:"captureModel",label:t("captureModel")}),(0,e.jsx)(ge,{k:"sessionBudgetChars",label:t("sessionBudgetChars"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:t("auditMode")}),(0,e.jsxs)("select",{value:S.auditMode??"all",onChange:l=>Ce("auditMode",l.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(Yt,{label:t("auditExemptAgents"),value:S.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(V?.agents||[]).filter(l=>!l.isDsh).map(l=>({value:l.name,label:l.name}))],onChange:l=>Ce("auditExemptAgents",l)}),(0,e.jsx)(Yt,{label:t("auditExemptKinds"),value:S.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...Lt.filter(l=>l!=="all").map(l=>({value:l,label:t(_e[l])}))],onChange:l=>Ce("auditExemptKinds",l)}),(0,e.jsx)(ge,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},children:[(0,e.jsx)(Ne,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:S.autoWebMode??"init",onChange:l=>Ce("autoWebMode",l.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(ge,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(ge,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(ge,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Ne,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Ne,{k:"autoRestartOnDrift",label:t("autoRestartOnDrift")}),(0,e.jsx)(Ne,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",alignItems:"center",marginBottom:10,flexWrap:"wrap"},children:[ie==="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,opacity:.75},children:["\u23F3 ",t("saving")]}),ae&&ie!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#10b981"},children:["\u2705 ",ae]}),K&&ie!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#b91c1c"},children:["\u26A0 ",K]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:qe,disabled:!!ie,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:f?()=>B(t("readonlyTitle")+"\uFF1A"+t("readonlyBody"),!1):Ke,disabled:ie==="save",title:t(f?"readonlyBody":"saveConfig"),children:ie==="save"?"\u23F3 "+t("saving"):f?"\u{1F512} "+t("readonlyBtn"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function za({t,onReload:o,version:r}){let[g,d]=(0,n.useState)([]),[i,k]=(0,n.useState)([]),[M,w]=(0,n.useState)("all"),[j,S]=(0,n.useState)("all"),[h,f]=(0,n.useState)(""),[T,I]=(0,n.useState)(new Set),[x,D]=(0,n.useState)(""),[C,$]=(0,n.useState)(null),[Z,he]=(0,n.useState)("pending"),V=(u,P=!0)=>{$({msg:u,ok:P}),setTimeout(()=>$(null),3e3)},Le=[...new Set([...g,...i].map(u=>u.submittedBy).filter(Boolean))],K=(0,n.useCallback)(async()=>{try{let u=await fetch(`${U}/audit/list`).then(P=>P.json());u.ok&&(d(u.pending||[]),k(u.rejected||[]),I(new Set),ye(new Set),ve({}))}catch{}},[]);(0,n.useEffect)(()=>{K()},[r,K]);let de=(Z==="pending"?g:i).filter(u=>{if(M!=="all"&&u.kind!==M||j!=="all"&&ut(u.submittedBy)!==j)return!1;if(h){let P=(u.created||"").slice(0,10);if(P&&P!==h)return!1}return!0}),ie=u=>I(P=>{let X=new Set(P);return X.has(u)?X.delete(u):X.add(u),X}),O=async(u,P)=>{let X=P||[...T];if(!X.length){V(t("noSelection"),!1);return}D("apply");let B=t(u==="approved"?"toastApproved":u==="rejected"?"toastRejected":"toastCardDeleted");try{let Y=0;for(let fe of X){let Ae=u==="approved"?"audit/approve":u==="rejected"?"audit/reject":"delete";try{(await fetch(U+"/"+Ae+"?path="+encodeURIComponent(fe)+(u==="delete"?"&permanent=0":""))).ok||Y++}catch{Y++}}await K(),o&&o(),Y?V(t("toastFailed")+"\uFF08"+Y+"/"+X.length+"\uFF09",!1):V(B+" "+X.length+" \u5F20")}catch(Y){V(t("toastFailed")+": "+String(Y&&Y.message||Y),!1)}finally{D("")}},[ae,ye]=(0,n.useState)(new Set),[R,ve]=(0,n.useState)({}),p=u=>R[u]||{},L=async u=>{let P=u.path,X=!ae.has(P);if(ye(B=>{let Y=new Set(B);return X?Y.add(P):Y.delete(P),Y}),!(!X||R[P])){ve(B=>({...B,[P]:{loading:!0}}));try{let B=u.status||(Z==="pending"?"pending":"rejected"),Y=await fetch(`${U}/card?path=${encodeURIComponent(P)}&status=${B}`).then(fe=>fe.json());Y&&Y.ok?ve(fe=>({...fe,[P]:{text:Y.text||""}})):ve(fe=>({...fe,[P]:{error:Y&&Y.error||"HTTP"}}))}catch(B){ve(Y=>({...Y,[P]:{error:String(B&&B.message||B)}}))}}},G=[...T];return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(ea,{toast:C}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:M,onChange:u=>w(u.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),Lt.filter(u=>u!=="all").map(u=>(0,e.jsx)("option",{value:u,children:t(_e[u])},u))]}),(0,e.jsxs)("select",{value:j,onChange:u=>S(u.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),Zt(Le).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsx)("input",{type:"date",value:h,onChange:u=>f(u.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${Z==="pending"?" me-on":""}`,onClick:()=>he("pending"),children:[t("pending"),"\uFF08",g.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${Z==="rejected"?" me-on":""}`,onClick:()=>he("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:de.length>0&&G.length===de.length,onChange:u=>{u.target.checked?I(new Set(de.map(P=>P.path))):I(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!G.length||!!x,onClick:()=>O("approved"),children:["\u2713 ",t(Z==="rejected"?"restore":"approve")]}),Z==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!G.length||!!x,onClick:()=>O("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!G.length||!!x,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&O("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),de.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:de.map(u=>{let P=p(u.path),X=ae.has(u.path);return(0,e.jsxs)("div",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has(u.path),onChange:()=>ie(u.path)}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"0 6px"},title:t(X?"collapse":"expand"),"aria-expanded":X,onClick:()=>L(u),children:X?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[u.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},title:t(X?"collapse":"expand"),onClick:()=>L(u),children:u.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:ut(u.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:u.created?u.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:u.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:u.severity==="high"?"#f87171":"#9ca3af"},children:u.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.reason||"-"}),Z==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>O("approved",[u.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>O("rejected",[u.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>O("approved",[u.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&O("delete",[u.path])},children:"\u{1F5D1}"})]})]}),X&&(0,e.jsxs)("div",{style:{padding:"2px 10px 12px 34px"},children:[P.loading&&(0,e.jsxs)("div",{style:{fontSize:12,opacity:.6},children:["\u23F3 ",t("loading")]}),P.error&&(0,e.jsxs)("div",{style:{fontSize:12,color:"#f87171"},children:["\u26A0 ",t("auditBodyFail"),"\uFF1A",P.error]}),P.text!=null&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"md-meta",style:{marginBottom:6},children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:Ue[u.kind]||"#6B7280",borderColor:(Ue[u.kind]||"#6B7280")+"59",background:(Ue[u.kind]||"#6B7280")+"1a"},children:[ht[u.kind]||"\u{1F4CE}"," ",t(_e[u.kind]||"kindKnowledge")]}),(Array.isArray(u.tags)?u.tags:[]).slice(0,8).map(B=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",B]},B)),!!u.reason&&(0,e.jsxs)("span",{className:"md-chip md-chip-st-warn",children:["\u2691 ",u.reason]})]}),(0,e.jsx)("div",{className:"md-doc",style:{maxHeight:340,overflow:"auto"},dangerouslySetInnerHTML:{__html:zt(Ct(P.text).body)}}),Z==="pending"&&(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!!x,onClick:()=>O("approved",[u.path]),children:["\u2713 ",t("approve")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!x,onClick:()=>O("rejected",[u.path]),children:["\u2715 ",t("reject")]})]})]})]})]},u.path)})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Ra({t,onReload:o,version:r}){let[g,d]=(0,n.useState)([]),[i,k]=(0,n.useState)(""),[M,w]=(0,n.useState)(null),j=(f,T=!0)=>{w({msg:f,ok:T}),setTimeout(()=>w(null),3200)},S=(0,n.useCallback)(async()=>{try{let f=await fetch(`${U}/recycle/list`).then(T=>T.json());f.ok&&d(f.items||[])}catch{}},[]);(0,n.useEffect)(()=>{S()},[r,S]);let h=async(f,T)=>{let I=(g.find(x=>x.path===T)||{}).title||T;k(f+T);try{let D=await fetch(U+(f==="restore"?"/recycle/restore":"/recycle/purge")+"?path="+encodeURIComponent(T)),C=await D.json().catch(()=>null);await S(),o&&o(),D.ok&&(!C||C.ok!==!1)?j(t(f==="restore"?"toastRestored":"toastPurged")+"\uFF1A"+I):j(t("toastFailed")+"\uFF1A"+(C&&C.error||"HTTP "+D.status),!1)}catch(x){j(t("toastFailed")+"\uFF1A"+String(x&&x.message||x),!1)}finally{k("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(ea,{toast:M}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i||g.length===0,title:g.length?"":t("emptyRecycle"),onClick:async()=>{k("purgeAll");try{let f=await fetch(U+"/recycle/purge-expired?days=0"),T=await f.json().catch(()=>null);await S(),j(f.ok?t("toastPurgedExpired")+(T&&T.purged!=null?"\uFF08"+T.purged+"\uFF09":""):t("toastFailed"),f.ok)}catch(f){j(t("toastFailed")+"\uFF1A"+String(f&&f.message||f),!1)}finally{k("")}},children:t("emptyRecycle")})]}),g.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:g.map(f=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[f.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(f.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>h("restore",f.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&h("purge",f.path)},children:t("purge")})]},f.path))}):(0,e.jsxs)("div",{className:"mc-card",style:{padding:18,fontSize:12.5,opacity:.78,textAlign:"center",lineHeight:1.9},children:["\u{1F5D1}\uFE0F ",t("emptyRecycle"),(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{fontSize:11.5},children:t("recycleEmptyHint").split("{days}").join("30")})]})]})]})}var Ia=({card:t,t:o,onOpen:r,query:g,onDelete:d})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>r(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[t.kind]||Ue.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:ht[t.kind]||"\u{1F4CE}"}),g?Gt(t.title,g):t.title,Oa(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:o("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",o("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",o("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",o("statusApproved")]})]}),(0,e.jsx)("p",{children:g?Gt(t.summary||"",g):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[ht[t.kind]||"\u{1F4CE}"," ",o(_e[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",ut(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",pt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:o("delete"),onClick:i=>{i.stopPropagation(),window.confirm(o("deleteConfirm"))&&d&&d(t.path)},children:"\u{1F5D1}"})]})]});function La({t,tab:o,onReload:r,version:g}){let[d,i]=(0,n.useState)(null),[k,M]=(0,n.useState)(""),[w,j]=(0,n.useState)(null),[S,h]=(0,n.useState)(null),[f,T]=(0,n.useState)(null),[I,x]=(0,n.useState)([]),[D,C]=(0,n.useState)(""),[$,Z]=(0,n.useState)(!1),he=(0,n.useCallback)(async()=>{if(!(!w||!w.merge||!w.merge.length)&&window.confirm(t("mergeAllConfirm"))){C("merge");try{let p={},L=B=>p[B]===void 0?B:p[B]=L(p[B]),G=(B,Y)=>{p[L(B)]=L(Y)},u=new Set;for(let B of w.merge)u.add(B.a.path),u.add(B.b.path),G(B.a.path,B.b.path);let P={};for(let B of u){let Y=L(B);(P[Y]=P[Y]||[]).push(B)}let X=0;for(let B of Object.values(P)){if(B.length<2)continue;(await fetch(`${U}/merge?paths=${encodeURIComponent(B.join(","))}`).then(fe=>fe.json())).ok&&X++}await V(),r&&r()}catch{}C("")}},[w,V,r,t]);async function V(){try{let p=await Promise.all([fetch(`${U}/stats`),fetch(`${U}/budget`),fetch(`${U}/capture-log`),fetch(`${U}/cards?status=all&limit=30&agent=${yt}`)]),[L,G,u,P]=await Promise.all(p.map(X=>X.json()));L&&L.ok&&i(L),G&&G.ok&&h(G),u&&u.ok&&T(u),P&&P.ok&&x(P.cards||[]),M(!L||!L.ok?t("adminLoadFail"):"")}catch{M(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{C("scan");try{let p=await fetch(`${U}/optimize`).then(L=>L.json());p.ok&&j(p)}catch{M(t("adminLoadFail"))}finally{C("")}},[t]),[K,de]=(0,n.useState)(null),ie=(0,n.useCallback)(async()=>{C("refine");try{let p=await fetch(`${U}/refine-scan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({limit:8})}).then(L=>L.json());p&&p.ok?de(p):notify(p&&p.error||t("refineFail"),!1)}catch{notify(t("refineFail"),!1)}finally{C("")}},[t]),O=async(p,L)=>{if(!(L==="merge"&&!window.confirm(t("mergeConfirm")))){C("refineapply");try{let G=await fetch(`${U}/refine-apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({a:p.a.path,b:p.b.path,action:L,relation:p.relation})}).then(u=>u.json());G&&G.ok?(notify(t("refineApplied")),de(u=>u&&{...u,findings:(u.findings||[]).filter(P=>!(P.a.path===p.a.path&&P.b.path===p.b.path))}),await V(),r&&r()):notify(G&&G.error||t("refineFail"),!1)}catch{notify(t("refineFail"),!1)}finally{C("")}}};(0,n.useEffect)(()=>{V()},[g]);let ae=async(p,L)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${U}/merge?paths=${encodeURIComponent(p+","+L)}`).then(u=>u.json())).ok&&(await V(),r&&r())}catch{}},ye=async p=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${U}/delete?path=${encodeURIComponent(p)}`).then(G=>G.json())).ok&&(await V(),r&&r())}catch{}},R=["project","knowledge","content","prompt","business","tool","mistake"],ve=({title:p,kind:L,updated:G,path:u})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[L]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:pt(G)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ye(u),children:[t("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[k&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",k]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:V,children:["\u21BB ",t("retry")]})]}),o==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",t("captureLog")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("captureLogHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>V(),children:["\u21BB ",t("refresh")]})]}),f?f.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(f.entries||[]).length===0?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogEmpty")}):(0,e.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,e.jsx)("tbody",{children:(f.entries||[]).map((p,L)=>{let G=ka[p.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:pt(p.time?new Date(p.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:G[1],fontWeight:600},children:[G[0]," ",p.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:p.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:p.preview||"",children:p.preview||""})]},L)})})})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("loading")})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",t("captureAgentCards"),"\uFF08",I.length,"\uFF09"]}),I.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.map(p=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[p.kind]||Ue.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.title}),p.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:pt(p.updated)})]},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),d&&(0,e.jsxs)(e.Fragment,{children:[d.trend&&d.trend.length>0&&(()=>{let p=d.trend,L=Math.max(...p.map(X=>X.count),1),G=260,u=50,P=G/p.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:G,height:u,style:{display:"block",width:"100%",height:50},children:p.map((X,B)=>{let Y=Math.round(X.count/L*(u-4));return(0,e.jsx)("rect",{x:B*P+1,y:u-Y,width:Math.max(P-2,2),height:Y,rx:1.5,fill:X.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:X.count>0?.85:.35},X.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:R.map(p=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[p]||"#666"}}),t(_e[p]),": ",d.byKind?.[p]||0]},p))})]}),S&&(S.budgetChars||S.recallLimit||S.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:S.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:S.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",S.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",d.todayCards?.length||0,"\uFF09"]}),d.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:d.todayCards.map(p=>(0,e.jsx)(ve,{title:p.title,kind:p.kind,updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),o==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!D,onClick:Le,children:D==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),w&&w.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!D,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){C("oneclick");try{let p=JSON.stringify({cleanupStale:$}),G=await(await fetch(`${U}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:p})).json();G&&G.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${G.plan.merged} ${t("optimizedMerged")}${$?` \xB7 ${G.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await V(),r&&r(),j(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{C("")}}},children:D==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),w&&w.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:$,onChange:p=>Z(p.target.checked)}),t("oneClickAlsoStale")]})]}),!w&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),w&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),w.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!D,onClick:he,children:t(D==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),w.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:w.merge.map((p,L)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.a.title," \u21C4 ",p.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(p.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ae(p.a.path,p.b.path),children:t("mergeNow")})]},L))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",w.stale?.length||0,"\uFF09"]}),w.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!D,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;C("clean");let p=0;for(let L of w.stale)try{await fetch(`${U}/delete?path=${encodeURIComponent(L.path)}`),p++}catch{}C(""),notify(`${p} ${t("deletedStale")}`),await V(),r&&r()},children:t("cleanStale")})}),w.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:w.stale.map(p=>(0,e.jsx)(ve,{title:p.title,kind:"other",updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginBottom:6},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9ED} ",t("refineTitle")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!D,onClick:ie,children:t(D==="refine"?"exporting":"refineScan")}),(0,e.jsx)("span",{style:{opacity:.6,fontSize:11},children:t("refineHint")})]}),K?.findings?.length?K.findings.map((p,L)=>(0,e.jsxs)("div",{style:{borderTop:L?"1px solid rgba(127,127,127,0.14)":"none",padding:"7px 2px"},children:[(0,e.jsxs)("div",{style:{fontSize:12,marginBottom:3},children:[(0,e.jsx)("span",{style:{fontWeight:700,color:p.relation==="conflict"?"#ef4444":p.relation==="duplicate"?"#f59e0b":"#10b981"},children:t("refineRel_"+p.relation)}),(0,e.jsxs)("span",{style:{opacity:.55},children:[" \xB7 sim ",p.sim," \xB7 ",p.useModel||""]}),p.conflict?(0,e.jsx)("span",{style:{marginLeft:6},children:p.conflict}):null]}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.85,marginBottom:5},children:["A\uFF1A",p.a.title,(0,e.jsx)("br",{}),"B\uFF1A",p.b.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!D,onClick:()=>O(p,"keepA"),children:t("refineKeepA")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!D,onClick:()=>O(p,"keepB"),children:t("refineKeepB")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!D,onClick:()=>O(p,"keepBoth"),children:t("refineKeepBoth")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!D,onClick:()=>O(p,"merge"),children:t("refineMerge")})]})]},L)):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t(K?"refineNone":"refineIdle")})]})]})]})]})}var It=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function Aa({t,newCard:o,setNewCard:r,onCreated:g}){if(!o)return null;let d=It.find(h=>h.key===o.template),i=o.body||(d?t(d.bodyKey):""),k=o.kind||(d?d.kind:"knowledge"),M=o.tags||(d?t(d.tagKey):""),w=o._creating,j=h=>{let f=It.find(T=>T.key===h);r(T=>({...T,template:h,kind:f?f.kind:T.kind,body:f?t(f.bodyKey):T.body,tags:f?t(f.tagKey):T.tags}))},S=async()=>{if(!(!o.title&&!i)){r(h=>({...h,_creating:!0}));try{(await fetch(`${U}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.title||t("untitled"),kind:k,tags:M.split(",").map(f=>f.trim()).filter(Boolean),body:i,source:"manual"})}).then(f=>f.json())).ok?(r(null),g&&g()):r(f=>({...f,_creating:!1}))}catch{r(f=>({...f,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>r(null),children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:h=>h.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>r(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[It.map(h=>(0,e.jsx)("button",{type:"button",className:`mc-btn${o.template===h.key?" me-on":""}`,onClick:()=>j(h.key),children:t(h.label)},h.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${o.template===""?" me-on":""}`,onClick:()=>r(h=>({...h,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:k,onChange:h=>r(f=>({...f,kind:h.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(h=>(0,e.jsx)("option",{value:h,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:h},h))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:o.title||"",onChange:h=>r(f=>({...f,title:h.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:M,onChange:h=>r(f=>({...f,tags:h.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:h=>r(f=>({...f,body:h.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:w,onClick:S,children:t(w?"exporting":"createCard")})})]})]})]})}async function Vt(t){let o=String(t||"");if(!o)return!1;try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(o),!0}catch{}try{let r=document.createElement("textarea");r.value=o,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();let g=!!(document.execCommand&&document.execCommand("copy"));return document.body.removeChild(r),g}catch{return!1}}function Ba({t,onClose:o}){let[r,g]=(0,n.useState)(""),[d,i]=(0,n.useState)(""),[k,M]=(0,n.useState)(""),[w,j]=(0,n.useState)(!0),[S,h]=(0,n.useState)(!1),[f,T]=(0,n.useState)(""),[I,x]=(0,n.useState)(""),D=(0,n.useRef)(null),C=(0,n.useRef)(null),$=()=>{let O=D.current;if(O)try{O.focus(),O.select()}catch{}},Z=O=>{T(O),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>T(""),2400)};(0,n.useEffect)(()=>{let O=!0;return fetch(U+"/diagnostics").then(ae=>ae.json()).then(ae=>{O&&(ae&&ae.ok?(i(String(ae.diagnostics||"")),M(String(ae.version||""))):h(!0))}).catch(()=>{O&&h(!0)}).finally(()=>{O&&j(!1)}),()=>{O=!1}},[]),(0,n.useEffect)(()=>{let O=ae=>{ae.key==="Escape"&&o()};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O),C.current&&clearTimeout(C.current)}},[o]);let he=(()=>{try{return String(navigator.language||"").toLowerCase().startsWith("en")?"en":"zh"}catch{return"zh"}})(),V=()=>{let O=r.trim().split(`
306
+ `)[0]||"",ae=Ot({title:"[Bug] "+(O.slice(0,60)||"memory-eternal \u95EE\u9898"),body:Wt({description:r,diagnostics:d,version:k})});try{window.open(ae,"_blank","noopener")}catch{Z(t("fbCopyFail"))}},Le=async()=>{await Vt(d)?(x(""),Z(t("fbCopiedDiag"))):(x(d),Z(t("fbCopyManual")))},K=async()=>{let O=$t({lang:he,description:r,diagnostics:d});await Vt(O)?(x(""),Z(t("fbCopiedPrompt"))):(x(O),Z(t("fbCopyManual")))},de={width:"100%",resize:"vertical",padding:"8px 10px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:13},ie={margin:0,maxHeight:170,overflow:"auto",fontSize:11.5,lineHeight:1.55,padding:"8px 10px",borderRadius:10,background:"var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.08))",whiteSpace:"pre-wrap"};return(0,e.jsxs)("div",{className:"me-overlay",onClick:o,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720},onClick:O=>O.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:["\u{1F41E} ",t("fbTitle")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:o,children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsx)("div",{style:{fontSize:12,opacity:.72,lineHeight:1.6},children:t("fbWhy")}),(0,e.jsx)("textarea",{value:r,onChange:O=>g(O.target.value),placeholder:t("fbDesc"),rows:5,style:de}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("fbDiag")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Le,disabled:!d,children:t("fbCopyDiag")})]}),(0,e.jsx)("pre",{style:ie,children:w?t("fbLoading"):S?t("fbDiagFail"):d})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>{if(!r.trim()){Z(t("fbNeedDesc"));return}V()},style:{borderColor:"var(--dsw-alias-brand-primary, #3b82f6)",color:"var(--dsw-alias-brand-primary, #3b82f6)",fontWeight:600},children:["\u{1F680} ",t("fbOpenIssue")]}),(0,e.jsx)("span",{style:{opacity:.5,fontSize:12},children:t("fbOr")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:K,children:["\u{1F916} ",t("fbCopyPrompt")]})]}),f&&(0,e.jsx)("div",{style:{fontSize:12,color:"var(--dsw-alias-brand-primary, #3b82f6)"},children:f}),I&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12,color:"#b45309"},children:["\u26A0 ",t("fbCopyFail")]}),(0,e.jsx)("span",{style:{fontSize:11.5,opacity:.75},children:t("fbCopyManual")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:$,children:t("fbSelectAll")})]}),(0,e.jsx)("textarea",{ref:D,readOnly:!0,value:I,rows:7,style:de})]})]})]})]})}function Pa({t,card:o,query:r,onClose:g,onDelete:d,onFeedback:i}){(0,n.useEffect)(()=>{let D=C=>{C.key==="Escape"&&g()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[g]);let{meta:k,body:M}=(0,n.useMemo)(()=>Ct(o.text||""),[o.text]),w=D=>{let C=k.find(([$])=>String($).toLowerCase()===D);return C?C[1]:""},j=jt(w("tags")),S=w("kind")||"knowledge",h=(w("status")||"approved").toLowerCase(),f=Ue[S]||"#6B7280",T=(M||"").length>460,[I,x]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:g,children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",onClick:D=>D.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:[(0,e.jsx)("span",{style:{marginRight:6},children:ht[S]||"\u{1F4CE}"}),o.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),T&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":I,onClick:()=>x(D=>!D),children:t(I?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&d&&d(o.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:g,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:f,borderColor:f+"59",background:f+"1a"},children:[ht[S]||"\u{1F4CE}"," ",t(_e[S]||"kindKnowledge")]}),(0,e.jsxs)("span",{className:"md-chip "+(h==="approved"?"md-chip-st-ok":h==="pending"?"md-chip-st-warn":"md-chip-st-bad"),children:[h==="approved"?"\u2705":h==="pending"?"\u23F3":"\u26D4"," ",t(h==="approved"?"statusApproved":h==="pending"?"statusPending":"statusRejected")]}),j.slice(0,8).map(D=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",D]},D)),!!w("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",pt(w("updated"))]}),!!w("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",w("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:I?{}:{maxHeight:300,overflow:"hidden"},onClick:I?void 0:D=>{D.stopPropagation(),x(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:zt(M)}})}),!I&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:D=>{D.stopPropagation(),x(!0)},children:[t("expand")," \u2304"]})]})]})}function Ea({t,onOpen:o,all:r,onAllChange:g,onMutate:d,active:i,visible:k}){let[M,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(""),h=(0,n.useRef)(!1),f=(0,n.useRef)(0),T=(0,n.useRef)(t);T.current=t;let I=(0,n.useCallback)(async()=>{try{h.current=!1;let $=await(await fetch(`${U}/graph${r?"?all=1":""}`)).json();$.ok?(w($),S(""),h.current=!0):(w(null),S($.error||t("error")))}catch(C){S(String(C&&C.message?C.message:C))}},[r,t]);(0,n.useEffect)(()=>{if(!i||h.current)return;let C=!0;return fetch(`${U}/graph${r?"?all=1":""}`).then($=>$.json()).then($=>{C&&($.ok?(w($),S(""),h.current=!0):(w(null),S($.error||t("error"))))}).catch($=>{C&&S(String($&&$.message?$.message:$))}),()=>{C=!1}},[r,t,i]),(0,n.useEffect)(()=>{k&&M&&f.current++},[k,M]);let x=(0,n.useCallback)(async C=>{try{let Z=await(await fetch(`${U}/delete?path=${encodeURIComponent(C)}`)).json();return Z&&Z.ok?(await I(),d&&d(),!0):!1}catch{return!1}},[I]),D=(0,n.useCallback)(async C=>{if(!C||C.length<2)return!1;try{let $=await fetch(`${U}/merge?paths=${encodeURIComponent(C.join(","))}`).then(Z=>Z.json());return $&&$.ok?(await I(),d&&d(),!0):!1}catch{return!1}},[I,d]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:He}),j&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",j]}),!M&&!j&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),M&&M.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),M&&M.nodes.length>0&&(0,e.jsx)(Ha,{nodes:M.nodes,edges:M.edges,onOpen:o,onDelete:x,onMerge:D,t,all:r,onAllChange:g,countLabel:`${M.nodes.length} ${t("nodes")} \xB7 ${Fa(M.edges)} ${t("edges")}`,fitTrigger:f.current})]})}function Fa(t){let o=new Set;for(let r of t||[])o.add([r.source,r.target].sort().join("|"));return o.size}var ct={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Ha({nodes:t,edges:o,onOpen:r,onDelete:g,onMerge:d,t:i,countLabel:k,all:M,onAllChange:w,fitTrigger:j}){let S=(0,n.useRef)(null),h=(0,n.useRef)(null),f=(0,n.useRef)(null),T=(0,n.useRef)(null),I=(0,n.useRef)(null),x=(0,n.useRef)(r);(0,n.useEffect)(()=>{x.current=r},[r]);let D=(0,n.useRef)(g);(0,n.useEffect)(()=>{D.current=g},[g]);let C=(0,n.useRef)(d);(0,n.useEffect)(()=>{C.current=d},[d]);let[$,Z]=(0,n.useState)(""),[he,V]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=$.trim().toLowerCase()},[$]),(0,n.useEffect)(()=>{let c=f.current;if(!c)return;let s=$.trim().toLowerCase();if(!s)return;let F=c.nodes.find(oe=>(oe.name||"").toLowerCase().includes(s));F&&(f.current.selectedId=F.id,V(F.id),c.panX=c.w/2-F.x*c.zoom,c.panY=c.h/2-F.y*c.zoom,c.render&&c.render())},[$]);let[K,de]=(0,n.useState)("all"),[ie,O]=(0,n.useState)(!1),ae=(0,n.useRef)("all"),[ye,R]=(0,n.useState)(""),ve=(0,n.useRef)(""),[p,L]=(0,n.useState)(!1),G=(0,n.useRef)(!1),[u,P]=(0,n.useState)(null);(0,n.useEffect)(()=>{ae.current=K},[K]),(0,n.useEffect)(()=>{ve.current=ye},[ye]),(0,n.useEffect)(()=>{G.current=p},[p]);let X=(0,n.useMemo)(()=>{let c=new Map;for(let s of t)for(let F of s.tags||[]){let oe=String(F).trim();oe&&c.set(oe,(c.get(oe)||0)+1)}return[...c.entries()].sort((s,F)=>F[1]-s[1]).slice(0,24).map(([s,F])=>({tag:s,n:F}))},[t]),B=(()=>{let c=$.trim().toLowerCase();return!!c&&!t.some(s=>(s.title||s.name||"").toLowerCase().includes(c)||String(s.kind||"").toLowerCase().includes(c)||String(_e[s.kind]||"").toLowerCase().includes(c))})();(0,n.useEffect)(()=>{let c=f.current;c&&c.wake&&c.wake()},[$]),(0,n.useEffect)(()=>{let c=f.current;c&&c.render&&c.render()},[K,ye,p]);let Y=(0,n.useRef)(null),[fe,Ae]=(0,n.useState)([]),[De,we]=(0,n.useState)(null),[Be,Pe]=(0,n.useState)(!1),[Te,Ce]=(0,n.useState)(null),[tt,at]=(0,n.useState)(""),Ke=(0,n.useRef)(null),qe=(0,n.useRef)(null),se=(c,s=!0)=>{Ke.current&&clearTimeout(Ke.current),Ce({msg:c,ok:s}),Ke.current=setTimeout(()=>Ce(null),1900)},Re=c=>{at(c),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>at(""),1600)};(0,n.useEffect)(()=>()=>{Ke.current&&clearTimeout(Ke.current),qe.current&&clearTimeout(qe.current)},[]);let ke=(0,n.useMemo)(()=>t.reduce((c,s)=>(c[s.id]=s,c),{}),[t]);return(0,n.useEffect)(()=>{let c=S.current;if(!c||t.length===0)return;let s=c.getContext("2d");if(!s)return;let F=Math.max(1,window.devicePixelRatio||1),oe=()=>document.documentElement.getAttribute("data-theme")==="dark",le={};o.forEach(m=>{le[m.source]=(le[m.source]||0)+1,le[m.target]=(le[m.target]||0)+1});let pe=Math.max(1,...Object.values(le)),a={nodes:t.map(m=>({id:m.id,name:m.title||"",type:m.kind||"other",r:9+Math.min(10,(le[m.id]||0)/pe*8),x:0,y:0,vx:0,vy:0})),edges:o.map(m=>({sourceNodeId:m.source,targetNodeId:m.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:F,ctx:s,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((m,z)=>(m[z.id]=z,m),{}),a.nodes.forEach((m,z)=>{let N=z/a.nodes.length*Math.PI*2-Math.PI/2;m.x=Math.cos(N)*60,m.y=Math.sin(N)*60});let ge=[...new Set(a.nodes.map(m=>m.type))];a.clustered=ge.length>1,a.typeCenters={},ge.forEach((m,z)=>{let N=z/ge.length*Math.PI*2-Math.PI/2;a.typeCenters[m]={x:Math.cos(N)*160,y:Math.sin(N)*160}}),f.current=a;let it=0,Ne=0,l=()=>{let m=c.clientWidth,z=c.clientHeight;a.w=m,a.h=z,c.width=m*F,c.height=z*F,s.setTransform(F,0,0,F,0,0),(it===0||Ne===0)&&m>0&&z>0&&a.tickCount>0&&requestAnimationFrame(()=>A()),it=m,Ne=z};l();let E=new ResizeObserver(l);E.observe(c.parentElement);let W=(m,z)=>m&&m.length>z?m.slice(0,z)+"\u2026":m,J=(m,z,N,H)=>{if(s.beginPath(),H==="rect")s.rect(m-N,z-N*.75,N*2,N*1.5);else if(H==="diamond")s.moveTo(m,z-N),s.lineTo(m+N,z),s.lineTo(m,z+N),s.lineTo(m-N,z),s.closePath();else if(H==="hexagon"){for(let _=0;_<6;_++){let re=Math.PI/3*_-Math.PI/2,Q=m+N*Math.cos(re),Se=z+N*Math.sin(re);_===0?s.moveTo(Q,Se):s.lineTo(Q,Se)}s.closePath()}else s.arc(m,z,N,0,Math.PI*2)},b=new Map,v=(m,z)=>{let N=m+"|"+Math.round(z),H=b.get(N);if(!H){let _=parseInt(m.slice(1,3),16),re=parseInt(m.slice(3,5),16),Q=parseInt(m.slice(5,7),16);H=s.createRadialGradient(-z*.3,-z*.3,0,0,0,z*1.2),H.addColorStop(0,"rgba("+Math.min(255,_+70)+","+Math.min(255,re+70)+","+Math.min(255,Q+70)+",0.95)"),H.addColorStop(1,m),b.set(N,H)}return H},A=()=>{if(!a.nodes.length)return;let m=1/0,z=-1/0,N=1/0,H=-1/0;a.nodes.forEach(Oe=>{m=Math.min(m,Oe.x),z=Math.max(z,Oe.x),N=Math.min(N,Oe.y),H=Math.max(H,Oe.y)});let _=20,re=z-m+_*2,Q=H-N+_*2,Se=Math.min(a.w/re,a.h/Q);a.zoom=Math.max(.35,Math.min(1.8,Se)),a.panX=a.w/2-(m+z)/2*a.zoom,a.panY=a.h/2-(N+H)/2*a.zoom};T.current=A;let ne=()=>{s.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=ae.current,a.timeMode=G.current,a.tagFilter=ve.current;let m=a.tagFilter,z=a.kindFilter,N=y=>String(y||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.save(),s.strokeStyle=oe()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",s.lineWidth=.5;for(let y=0;y<a.w;y+=24)s.beginPath(),s.moveTo(y,0),s.lineTo(y,a.h),s.stroke();for(let y=0;y<a.h;y+=24)s.beginPath(),s.moveTo(0,y),s.lineTo(a.w,y),s.stroke();s.restore(),s.save(),s.translate(a.panX,a.panY),s.scale(a.zoom,a.zoom);let H={};a.nodes.forEach(y=>H[y.id]=y);let _=a.nodes.length>40,re=_?1.5:.55,Q=a.selectedId||a.hoverId,Se=_t({panX:a.panX,panY:a.panY,zoom:a.zoom,w:a.w,h:a.h,margin:80}),Oe=(()=>{let y=(a.searchTerm||"").toLowerCase();if(!y)return null;let ee=[];for(let te of a.nodes){let xe=(a.domainById[te.id]||{}).kind||"other";if(((te.name||"").toLowerCase().includes(y)||String(_e[xe]||"").toLowerCase().includes(y)||String(xe).toLowerCase().includes(y))&&ee.push(te.id),ee.length>200)break}return ee})(),nt=Kt(a.nodes,{limit:Ut(a.nodes.length),focusId:Q,hoverId:a.hoverId,searchHits:Oe,degree:le}),ce=new Map,be=(y,ee)=>{let te=y+"|"+ee,me=ce.get(te);return me===void 0&&(s.font=y,me=s.measureText(ee).width,ce.set(te,me)),me},Ee=a.nodes.length<=250,We=new Map;a.edges.forEach(y=>{let ee=H[y.sourceNodeId],te=H[y.targetNodeId];if(!ee||!te||!Nt(ee.x,ee.y,10,Se)&&!Nt(te.x,te.y,10,Se))return;if(z!=="all"){let rt=a.domainById[y.sourceNodeId]&&a.domainById[y.sourceNodeId].kind,Ze=a.domainById[y.targetNodeId]&&a.domainById[y.targetNodeId].kind;if(rt!==z&&Ze!==z)return}if(m){let rt=a.domainById[y.sourceNodeId]&&(a.domainById[y.sourceNodeId].tags||[]).includes(m),Ze=a.domainById[y.targetNodeId]&&(a.domainById[y.targetNodeId].tags||[]).includes(m);if(!rt&&!Ze)return}let me=te.x-ee.x,xe=te.y-ee.y,Ie=Math.sqrt(me*me+xe*xe)||1,Qe=_?12:18,et=-xe/Ie*Qe,xt=me/Ie*Qe,wt=(ee.x+te.x)/2+et,kt=(ee.y+te.y)/2+xt,mt=ct.colors[a.domainById[ee.id]&&a.domainById[ee.id].kind||"other"],ft=Q&&(y.sourceNodeId===Q||y.targetNodeId===Q),Mt=Q?ft?.6:.08:_?.14:.24,Je=parseInt(mt.slice(1,3),16),gt=parseInt(mt.slice(3,5),16),Dt=parseInt(mt.slice(5,7),16),Ge=ft?1.6+(y.weight||1):.8+(y.weight||1)*.5,ot=Je+","+gt+","+Dt+","+Mt+","+Ge,$e=We.get(ot);$e||($e={path:new Path2D,stroke:"rgba("+Je+","+gt+","+Dt+","+Mt+")",width:Ge},We.set(ot,$e)),$e.path.moveTo(ee.x,ee.y),$e.path.quadraticCurveTo(wt,kt,te.x,te.y)}),We.forEach(y=>{s.strokeStyle=y.stroke,s.lineWidth=y.width,s.stroke(y.path)});let Fe=null;Q&&(Fe=new Set,a.edges.forEach(y=>{y.sourceNodeId===Q?Fe.add(y.targetNodeId):y.targetNodeId===Q&&Fe.add(y.sourceNodeId)}));let Xe=[];if(a.nodes.forEach(y=>{if(!Nt(y.x,y.y,y.r+2,Se))return;let ee=a.domainById[y.id]||{},te=ee.kind||"other",me=a.timeMode?ja(ee.updated):ct.colors[te],xe=ct.shapes[te],Ie=a.selectedId===y.id,Qe=a.hoverId===y.id,et=a.searchTerm||"",xt=!et||(y.name||"").toLowerCase().includes(et)||String(_e[te]||"").toLowerCase().includes(et)||String(te).toLowerCase().includes(et),wt=z==="all"||te===z,kt=!m||(ee.tags||[]).includes(m),mt=Q&&y.id!==Q&&!(Fe&&Fe.has(y.id))||et&&!xt||!wt||!kt;s.save(),s.globalAlpha=mt?.08:1,(Ie||Qe)&&Ee&&(s.shadowColor=me,s.shadowBlur=Ie?20:14),s.translate(y.x,y.y),J(0,0,y.r,xe),s.fillStyle=v(me,y.r),s.fill(),s.restore(),Ie?(s.save(),J(y.x,y.y,y.r+3,xe),s.strokeStyle=me,s.lineWidth=3,s.shadowColor=me,s.shadowBlur=12,s.stroke(),s.restore()):Qe?(s.save(),J(y.x,y.y,y.r+2,xe),s.strokeStyle=me,s.lineWidth=2,s.stroke(),s.restore()):et&&xt?(s.save(),J(y.x,y.y,y.r+2,xe),s.strokeStyle="#e11d48",s.lineWidth=2,s.stroke(),s.restore()):a.multi.indexOf(y.id)>=0&&(s.save(),J(y.x,y.y,y.r+2,xe),s.strokeStyle="#60a5fa",s.lineWidth=2,s.shadowColor="#60a5fa",s.shadowBlur=8,s.stroke(),s.restore());let ft=W(y.name,16);if((Ie||Qe||nt.has(y.id)&&a.zoom>re||!_&&a.zoom>.6)&&wt&&kt){let Je=1/a.zoom,gt="500 "+(12*Je).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";s.font=gt;let Ge=be(gt,ft)+16*Je,ot=18*Je,$e=y.y+y.r+8*Je,rt=!0;for(let Ze of Xe)if(y.x-Ge/2<Ze.x+Ze.w&&y.x+Ge/2>Ze.x&&$e<Ze.y+Ze.h&&$e+ot>Ze.y){rt=!1;break}if(!rt&&!Ie&&!Qe)return;Xe.push({x:y.x-Ge/2,y:$e,w:Ge,h:ot}),s.fillStyle=oe()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",s.beginPath(),s.roundRect?s.roundRect(y.x-Ge/2,$e,Ge,ot,4*Je):s.rect(y.x-Ge/2,$e,Ge,ot),s.fill(),s.strokeStyle=oe()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",s.lineWidth=1*Je,s.stroke(),s.fillStyle=oe()?Ie||Qe?"#eee":"#bbb":Ie||Qe?"#111":"#444",s.textAlign="center",s.fillText(ft,y.x,$e+13*Je)}}),s.restore(),a.marquee){let y=a.marquee,ee=Math.min(y.sx,y.ex),te=Math.min(y.sy,y.ey),me=Math.abs(y.ex-y.sx),xe=Math.abs(y.ey-y.sy);s.save(),s.setLineDash([4,4]),s.strokeStyle="rgba(96,165,250,0.9)",s.lineWidth=1,s.fillStyle="rgba(96,165,250,0.12)",s.fillRect(ee,te,me,xe),s.strokeRect(ee,te,me,xe),s.restore()}if(a.hoverId&&Y.current){let y=a.domainById[a.hoverId],ee=a.nodes.find(function(te){return te.id===a.hoverId});if(y&&ee){let te=a.edges.filter(function(Ie){return Ie.sourceNodeId===y.id||Ie.targetNodeId===y.id}).length,me=ee.x*a.zoom+a.panX,xe=ee.y*a.zoom+a.panY;Y.current.style.display="block",Y.current.style.left=me+14+"px",Y.current.style.top=xe-6+"px",Y.current.innerHTML="<b>"+N(y.title||y.name||"")+'</b><br/><span style="opacity:.8">'+N(y.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",te)+"</span>"}}else Y.current&&(Y.current.style.display="none")},q=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Me))};a.wake=q,a.render=ne;let ue=()=>{let m=a.nodes.length;a.tickCount++;let N=.9-Math.min(.4,a.tickCount/1500),H=m>1e3?3e3:m>100?2e3:m>50?1200:800,_=m>100?.002:.005,re=m>1e3?.012:m>100?.005:.01,Q=m>1e3?6:m>200?12:24,Se={};a.nodes.forEach(ce=>Se[ce.id]=ce);for(let ce=0;ce<m;ce++){if(a.dragNode===a.nodes[ce])continue;let be=a.nodes[ce],Ee=0,We=0;for(let y=0;y<m;y++){if(ce===y)continue;let ee=be.x-a.nodes[y].x,te=be.y-a.nodes[y].y,me=Math.sqrt(ee*ee+te*te)||1,xe=H/(me*me);Ee+=ee/me*xe,We+=te/me*xe}if(a.clustered&&a.typeCenters[be.type]){let y=a.typeCenters[be.type];Ee+=(y.x-be.x)*.006,We+=(y.y-be.y)*.006}else Ee-=be.x*re,We-=be.y*re;let Fe=(be.vx+Ee)*N,Xe=(be.vy+We)*N;Fe=Math.max(-Q,Math.min(Q,Fe)),Xe=Math.max(-Q,Math.min(Q,Xe)),be.vx=Fe,be.vy=Xe}a.edges.forEach(ce=>{let be=Se[ce.sourceNodeId],Ee=Se[ce.targetNodeId];if(!be||!Ee)return;let We=Ee.x-be.x,Fe=Ee.y-be.y,Xe=Math.sqrt(We*We+Fe*Fe)||1,y=(Xe-100)*_,ee=We/Xe*y,te=Fe/Xe*y;a.dragNode!==be&&(be.vx+=ee,be.vy+=te),a.dragNode!==Ee&&(Ee.vx-=ee,Ee.vy-=te)});let Oe=0;a.nodes.forEach(ce=>{a.dragNode!==ce&&(ce.x+=ce.vx,ce.y+=ce.vy,Oe+=ce.vx*ce.vx+ce.vy*ce.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,A()),(m?Math.sqrt(Oe/m):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Me=()=>{if(a.running){try{ue(),ne()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Me)}},ze=(m,z)=>{let N=c.getBoundingClientRect();return{x:(m-N.left-a.panX)/a.zoom,y:(z-N.top-a.panY)/a.zoom}},Ve=m=>{let z=a.domainById[m];return!(!z||ae.current!=="all"&&z.kind!==ae.current||ve.current&&!(z.tags||[]).includes(ve.current))},je=(m,z,N)=>Math.max(z,Math.min(N,m)),Ye=m=>{a.mouseX=m.clientX,a.mouseY=m.clientY;let z=ze(m.clientX,m.clientY),N=null;for(let H=a.nodes.length-1;H>=0;H--){let _=a.nodes[H];if(!Ve(_.id))continue;let re=_.x-z.x,Q=_.y-z.y;if(re*re+Q*Q<_.r*_.r+36){N=_.id;break}}N!==a.hoverId&&(a.hoverId=N,q())},vt=m=>{if(m.button!==0)return;let z=ze(m.clientX,m.clientY),N=null;for(let H=a.nodes.length-1;H>=0;H--){let _=a.nodes[H];if(!Ve(_.id))continue;let re=_.x-z.x,Q=_.y-z.y;if(re*re+Q*Q<_.r*_.r+25){N=_;break}}if(m.shiftKey){if(N){a.shiftClick=N.id;return}a.marquee={sx:m.clientX,sy:m.clientY,ex:m.clientX,ey:m.clientY};return}a.dragStart={x:m.clientX,y:m.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=N||null,N&&(a.dragOffset={dx:N.x-z.x,dy:N.y-z.y})},At=m=>{if(a.marquee){a.marquee.ex=m.clientX,a.marquee.ey=m.clientY,q();return}if(!a.dragStart)return;let z=m.clientX-a.dragStart.x,N=m.clientY-a.dragStart.y;if(Math.abs(z)+Math.abs(N)>3&&(a.dragging=!0),a.dragNode){let H=ze(m.clientX,m.clientY);a.dragNode.x=H.x+a.dragOffset.dx,a.dragNode.y=H.y+a.dragOffset.dy,q()}else a.dragging&&(a.panX=je(a.dragStart.px+z,-1e5,1e5),a.panY=je(a.dragStart.py+N,-1e5,1e5),q())},Bt=m=>{if(a.marquee){let N=a.marquee;a.marquee=null;let H=c.getBoundingClientRect(),_=Math.min(N.sx,N.ex)-H.left,re=Math.max(N.sx,N.ex)-H.left,Q=Math.min(N.sy,N.ey)-H.top,Se=Math.max(N.sy,N.ey)-H.top,Oe=a.nodes.filter(nt=>{let ce=nt.x*a.zoom+a.panX,be=nt.y*a.zoom+a.panY;return ce>=_&&ce<=re&&be>=Q&&be<=Se}).map(nt=>nt.id);a.multi=Oe,Ae(Oe),q();return}let z=a.dragStart&&!a.dragging;if(a.shiftClick){let N=a.shiftClick;a.shiftClick=null;let H=Array.isArray(a.multi)?a.multi.slice():[];H.includes(N)||H.push(N),a.multi=H,Ae(H),q();return}if(z){let N=ze(m.clientX,m.clientY),H=null;for(let _=a.nodes.length-1;_>=0;_--){let re=a.nodes[_];if(!Ve(re.id))continue;let Q=re.x-N.x,Se=re.y-N.y;if(Q*Q+Se*Se<re.r*re.r+20){H=re;break}}H?(a.selectedId=H.id,V(H.id),q()):(a.selectedId=null,a.hoverId=null,m.shiftKey||(a.multi=[],Ae([])),V(null),q())}a.dragStart=null,a.dragging=!1,a.dragNode=null},Pt=m=>{m.preventDefault();let z=ze(m.clientX,m.clientY),N=null;for(let H=a.nodes.length-1;H>=0;H--){let _=a.nodes[H];if(!Ve(_.id))continue;let re=_.x-z.x,Q=_.y-z.y;if(re*re+Q*Q<_.r*_.r+25){N=_;break}}if(N){let H=a.domainById[N.id];H&&P({x:m.clientX,y:m.clientY,id:N.id,path:H.id,title:H.title})}else P(null)},Et=m=>{m.preventDefault();let z=c.getBoundingClientRect(),N=(m.clientX-z.left-a.panX)/a.zoom,H=(m.clientY-z.top-a.panY)/a.zoom,_=Math.max(.3,Math.min(3,a.zoom*(m.deltaY<0?1.1:1/1.1)));a.panX=je(a.panX+N*(a.zoom-_),-1e5,1e5),a.panY=je(a.panY+H*(a.zoom-_),-1e5,1e5),a.zoom=_,q()};c.addEventListener("mousemove",Ye),c.addEventListener("mousedown",vt),window.addEventListener("mousemove",At),window.addEventListener("mouseup",Bt),c.addEventListener("wheel",Et,{passive:!1}),c.addEventListener("contextmenu",Pt),I.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Ae([]),A(),q()};for(let m=0;m<200;m++)ue();A(),q();let Ft=()=>O(!1);return window.addEventListener("mousedown",Ft),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),E.disconnect(),c.removeEventListener("mousemove",Ye),c.removeEventListener("mousedown",vt),window.removeEventListener("mousemove",At),window.removeEventListener("mouseup",Bt),c.removeEventListener("wheel",Et),c.removeEventListener("contextmenu",Pt),window.removeEventListener("mousedown",Ft)}},[t,o]),(0,n.useEffect)(()=>{j!==void 0&&T.current&&requestAnimationFrame(()=>T.current())},[j]),(0,e.jsxs)("div",{className:"me-graph",ref:h,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",o.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:$,onChange:c=>Z(c.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>O(c=>!c),"aria-expanded":ie,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",K!=="all"||p||ye?"\u25CF":"\u25BE"]}),ie&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:c=>c.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${K==="all"&&!p?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{de("all"),L(!1)},children:i("all")}),Object.keys(Ue).map(c=>(0,e.jsxs)("button",{type:"button",className:`lg${K===c?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>de(s=>s===c?"all":c),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:ct.colors[c]||Ue[c]}}),i(_e[c])]},c)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${p?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>L(c=>!c),children:["\u23F1 ",i("timeDim")]}),X.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:X.map(c=>(0,e.jsxs)("button",{type:"button",className:`lg${ye===c.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>R(s=>s===c.tag?"":c.tag),title:c.tag,children:["#",c.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:c.n})]},c.tag))})]}),(K!=="all"||p||ye)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{de("all"),L(!1),R("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!M,onChange:c=>w&&w(c.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${p?" me-on":""}`,onClick:()=>L(c=>!c),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=S.current;if(c)try{c.toBlob(s=>{s&&we({url:URL.createObjectURL(s),blob:s})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>T.current&&T.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{V(null),de("all"),I.current&&I.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:S,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Y,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),B&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),u&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>P(null)}),u&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:u.x,top:u.y,zIndex:31},onMouseDown:c=>c.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{x.current({path:u.path,title:u.title}),P(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{u.id&&(f.current.selectedId=u.id,V(u.id)),P(null);let c=f.current;c&&c.wake&&c.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(u.title||"")}catch{}P(null),se(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let c=f.current,s=c&&Array.isArray(c.multi)?c.multi.slice():[],F=u.id;if(F&&!s.includes(F)&&s.push(F),P(null),s.length<2){se(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let oe=C.current&&C.current(s);oe&&oe.then?oe.then(le=>le?se(i("merged")):se(i("mergeFail"),!1)).catch(()=>se(i("mergeFail"),!1)):oe&&se(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let c=u.path;P(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(D.current?await D.current(c):!1)?se(i("deleted")):se(i("deleteFail"),!1)}catch{se(i("deleteFail"),!1)}})()},children:i("delete")})]}),fe.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[fe.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=fe.map(pe=>ke[pe]).filter(Boolean).map(pe=>pe.title||pe.name).join(`
307
+ `),F=new Blob([s],{type:"text/plain;charset=utf-8"}),oe=URL.createObjectURL(F),le=document.createElement("a");le.href=oe,le.download="memory-selected.txt",document.body.appendChild(le),le.click(),document.body.removeChild(le),setTimeout(()=>URL.revokeObjectURL(oe),1e3),se(fe.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(fe.length<2){se(i("mergeNeed"),!1);return}let c=fe.map(F=>ke[F]?ke[F].id:F);if(!window.confirm(i("mergeConfirm")))return;Ae([]);let s=f.current;s&&(s.multi=[]),fetch(`${U}/merge?paths=${encodeURIComponent(c.join(","))}`).then(F=>F.json()).then(F=>{F&&F.ok?se(i("merged")):se(i("mergeFail"),!1)}).catch(()=>se(i("mergeFail"),!1))},children:i("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(i("deleteConfirm")))return;let c=fe.map(F=>ke[F]?ke[F].id:F);Ae([]);let s=f.current;s&&(s.multi=[]),(async()=>{let F=0;for(let oe of c)try{(D.current?await D.current(oe):!1)&&F++}catch{}se(F+i("deletedSelected"),F>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=f.current;c&&(c.multi=[]),Ae([]);let s=f.current;s&&s.render&&s.render()},children:i("clearSelection")})]}),he&&(0,e.jsxs)("div",{className:"me-graph-sidebar",style:{position:"absolute",right:10,top:10,zIndex:3,maxWidth:240,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:12,fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:ke[he]?ke[he].title||ke[he].name:he}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ke[he]?i(_e[ke[he].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(o.filter(c=>c.source===he||c.target===he)||[]).slice(0,8).map((c,s)=>{let F=c.source===he?c.target:c.source,oe=ke[F];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:le=>{le.preventDefault();let pe=f.current;pe&&(pe.selectedId=F,pe.hoverId=F,pe.wake&&pe.wake()),V(F)},children:oe?(oe.title||oe.name).slice(0,28):F},s)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),Te&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(Te.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Te.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Te.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Te.msg})]}),De&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{De.url&&URL.revokeObjectURL(De.url),we(null),Pe(!1)},children:[(0,e.jsx)("style",{children:He}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:Be?"100vw":900,width:Be?"100vw":"92vw",maxHeight:Be?"100%":"90vh",height:Be?"100%":void 0,borderRadius:Be?0:14},onClick:c=>c.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:De.url,download:"memory-graph.png",onClick:()=>{Re("download"),se(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(tt==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Re("full"),Pe(c=>!c),se(i("fullscreen"))},children:i(tt==="full"?"done":Be?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let c=De.blob;c&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":c})]).then(()=>{Re("copy"),se(i("copied"))}).catch(()=>{se(i("copyFail"),!1)}):se(i("copyFail"),!1)},children:i(tt==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{De.url&&URL.revokeObjectURL(De.url),we(null),Pe(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:Be?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:De.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:Be?"calc(100% - 64px)":"70vh",borderRadius:Be?0:8,cursor:"zoom-in"},onClick:()=>Pe(c=>!c)})})]})]})]})}function ja(t){let o=new Date(t||0).getTime();if(!o)return"#94a3b8";let r=(Date.now()-o)/864e5;return r<3?"#10b981":r<14?"#f59e0b":r<30?"#f97316":"#94a3b8"}function Yt({label:t,value:o=[],options:r,onChange:g,placeholder:d,z:i=20}){let[k,M]=(0,n.useState)(!1),w=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!k)return;let x=D=>{w.current&&!w.current.contains(D.target)&&M(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[k]);let j=Array.isArray(o)?o:[],S=j.includes("__all__"),h=S?r.find(x=>x.value==="__all__")?.label||"":j.length?j.map(x=>r.find(D=>D.value===x)?.label||x).join("\u3001"):"",f=(x,D)=>{if(x.value==="__all__"){g(D?["__all__"]:[]);return}let C=new Set(j);C.has("__all__")&&C.delete("__all__"),D?C.add(x.value):C.delete(x.value),g([...C])},T=r.find(x=>x.value==="__all__"),I=r.filter(x=>x.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,minWidth:0},children:[(0,e.jsx)("span",{style:{opacity:.6,whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.5},children:t}),(0,e.jsxs)("div",{ref:w,style:{position:"relative",minWidth:0},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>M(x=>!x),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h||d||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),k&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[T&&(0,e.jsxs)("label",{onClick:x=>x.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("input",{type:"checkbox",checked:S,onChange:x=>f(T,x.target.checked)}),(0,e.jsx)("span",{children:T.label})]}),I.map(x=>(0,e.jsxs)("label",{onClick:D=>D.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:j.includes(x.value),onChange:D=>f(x,D.target.checked)}),(0,e.jsx)("span",{children:x.label})]},x.value))]})]})]})}function Oa(t){let o=new Date(t||0).getTime();return!!o&&(Date.now()-o)/864e5<3}async function Wa(t,o,r){if(r&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:o}),k=await i.createWritable();return await k.write(t),await k.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let g=URL.createObjectURL(t),d=document.createElement("a");return d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(g),1e3),{ok:!0,picked:!1,name:o}}function Gt(t,o){if(!o||!t)return t;let r=t.toLowerCase(),g=o.toLowerCase(),d=[],i=0;for(;i<t.length;){let k=r.indexOf(g,i);if(k<0){d.push(t.slice(i));break}k>i&&d.push(t.slice(i,k)),d.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(k,k+g.length)},k)),i=k+g.length}return d}function pt(t){if(!t)return"";let o=new Date(t);if(Number.isNaN(o.getTime()))return"";let r=new Date,g=o.toDateString()===r.toDateString(),d=k=>String(k).padStart(2,"0"),i=`${d(o.getHours())}:${d(o.getMinutes())}`;return g?i:`${o.getMonth()+1}-${o.getDate()} ${i}`}
308
308
 
309
309
  return module.exports;
310
310
  },