memory-eternal 0.9.5 → 0.9.7
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.en.md +19 -7
- package/README.md +20 -8
- package/index.js +33 -6
- package/lib/client.js +80 -14
- package/lib/node-bin.js +99 -0
- package/lib/watchdog.js +8 -3
- package/lib/web.js +10 -3
- package/package.json +6 -4
- package/web/app.js +84 -18
package/lib/client.js
CHANGED
|
@@ -3,7 +3,12 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
var Bt=Object.create;var dt=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ft=(t,l)=>{for(var d in l)dt(t,d,{get:l[d],enumerable:!0})},kt=(t,l,d,v)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of Dt(l))!jt.call(t,m)&&m!==d&&dt(t,m,{get:()=>l[m],enumerable:!(v=At(l,m))||v.enumerable});return t};var Pt=(t,l,d)=>(d=t!=null?Bt(Rt(t)):{},kt(l||!t||!t.__esModule?dt(d,"default",{value:t,enumerable:!0}):d,t)),Et=t=>kt(dt({},"__esModule",{value:!0}),t);var sa={};Ft(sa,{EN:()=>zt,MemoryLibrary:()=>Xt,ZH:()=>Nt,apply:()=>_t,inject:()=>Ot});module.exports=Et(sa);var n=Pt(require("react"),1),e=require("react/jsx-runtime"),Ge="memory-eternal",W="/memory-eternal/api",$t=100,Ot=["slots","locale"],Nt={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",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",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",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",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",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",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",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",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",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]
|
|
6
|
+
var jt=Object.create;var ct=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Ot=Object.prototype.hasOwnProperty;var Wt=(t,l)=>{for(var s in l)ct(t,s,{get:l[s],enumerable:!0})},Nt=(t,l,s,f)=>{if(l&&typeof l=="object"||typeof l=="function")for(let c of $t(l))!Ot.call(t,c)&&c!==s&&ct(t,c,{get:()=>l[c],enumerable:!(f=Et(l,c))||f.enumerable});return t};var Ht=(t,l,s)=>(s=t!=null?jt(Pt(t)):{},Nt(l||!t||!t.__esModule?ct(s,"default",{value:t,enumerable:!0}):s,t)),_t=t=>Nt(ct({},"__esModule",{value:!0}),t);var ha={};Wt(ha,{EN:()=>At,MemoryLibrary:()=>ia,ZH:()=>Tt,apply:()=>ea,inject:()=>Jt});module.exports=_t(ha);var n=Ht(require("react"),1);var Ut={"&":"&","<":"<",">":">"},gt=t=>String(t).replace(/[&<>]/g,l=>Ut[l]),Kt=[[/结论|总结|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"]],Yt=["\u2728","info"],qt=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],Xt=t=>{let l=String(t);for(let[s,f,c]of Kt)if(s.test(l))return[f,c];return Yt},Vt=t=>{let l=t.join(" ");for(let[s,f,c]of qt)if(s.test(l))return[f,c];return["\u{1F4CC}","info"]};function Ge(t){let l=String(t),s=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(l);if(s&&!/[是为有了吗呢着过把被和与或于]/.test(s[1]))return'<span class="md-kv"><span class="md-k">'+gt(s[1])+'</span><span class="md-v">'+Ge(s[2])+"</span></span>";let f=gt(l);return f=f.replace(/^\[([ xX])\](?=\s|$)\s*/,(c,i)=>'<span class="md-task">'+(i.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),f=f.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),f=f.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),f=f.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),f=f.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(c,i,k)=>/^(https?:|\/|#)/i.test(k)?'<a class="md-link" href="'+k+'" target="_blank" rel="noopener noreferrer">'+i+"</a>":i),f}function ft(t){let l=String(t||"").replace(/\r\n?/g,`
|
|
7
|
+
`),s=/^---\n([\s\S]*?)\n---\n?/.exec(l);if(!s)return{meta:[],body:l};let f=[];for(let c of s[1].split(`
|
|
8
|
+
`)){let i=c.indexOf(":");if(i<=0)continue;let k=c.slice(0,i).trim(),x=c.slice(i+1).trim().replace(/^["']|["']$/g,"");k&&f.push([k,x])}return{meta:f,body:l.slice(s[0].length)}}function zt(t){let l=String(t||"").trim().replace(/^\[|\]$/g,"");return l?l.split(",").map(s=>s.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function It(t){let l=ft(String(t||"").replace(/\r\n?/g,`
|
|
9
|
+
`)).body;if(!l.trim())return"";let s=[],f=l.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(y,B,z)=>(s.push('<pre class="md-pre"><code>'+gt(z.replace(/\n$/,""))+"</code></pre>"),"\0F"+(s.length-1)+"\0")),c=[],i=[],k=null,x=null,N=()=>{i.length&&(c.push('<p class="md-p">'+i.join("<br/>")+"</p>"),i=[])},L=()=>{if(!k)return;let y=k.type;c.push("<"+y+' class="md-'+y+'">'+k.items.map(B=>"<li>"+B+"</li>").join("")+"</"+y+">"),k=null},C=()=>{if(!x)return;let[y,B]=Vt(x);c.push('<div class="md-callout md-c-'+B+'"><span class="md-ico">'+y+"</span>"+x.join("<br/>")+"</div>"),x=null},b=()=>{N(),L(),C()};for(let y of f.split(`
|
|
10
|
+
`)){let B=y.trim();if(!B){b();continue}let z=/^\u0000F(\d+)\u0000$/.exec(B);if(z){b(),c.push(s[Number(z[1])]);continue}let v;if(v=/^(#{1,6})\s+(.+)$/.exec(B)){b();let[I,S]=Xt(v[2]);c.push('<div class="md-h md-h-'+(v[1].length<=2?"h1":"h2")+" md-c-"+S+'"><span class="md-ico">'+I+'</span><span class="md-hx">'+Ge(v[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(B)){b(),c.push('<hr class="md-hr"/>');continue}if(v=/^>\s?(.*)$/.exec(B)){N(),L(),x=x||[],x.push(Ge(v[1]));continue}if(v=/^[-*+]\s+(.+)$/.exec(B)){N(),C(),(!k||k.type!=="ul")&&(L(),k={type:"ul",items:[]}),k.items.push(Ge(v[1]));continue}if(v=/^\d+[.)]\s+(.+)$/.exec(B)){N(),C(),(!k||k.type!=="ol")&&(L(),k={type:"ol",items:[]}),k.items.push(Ge(v[1]));continue}L(),C(),i.push(Ge(B))}return b(),c.join(`
|
|
11
|
+
`)}var e=require("react/jsx-runtime"),Je="memory-eternal",_="/memory-eternal/api",Gt=100,Jt=["slots","locale"],Tt={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",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",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",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",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",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",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",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",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",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]
|
|
7
12
|
|
|
8
13
|
## \u80CC\u666F
|
|
9
14
|
- \u95EE\u9898\u63CF\u8FF0
|
|
@@ -48,7 +53,7 @@ var Bt=Object.create;var dt=Object.defineProperty;var At=Object.getOwnPropertyDe
|
|
|
48
53
|
-
|
|
49
54
|
|
|
50
55
|
## \u98CE\u9669/\u963B\u585E
|
|
51
|
-
- `},
|
|
56
|
+
- `},At={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",importedSkipped:" (skipped dup ",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",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",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",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",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",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]
|
|
52
57
|
|
|
53
58
|
## Background
|
|
54
59
|
- Problem
|
|
@@ -93,7 +98,7 @@ Option A, because:
|
|
|
93
98
|
-
|
|
94
99
|
|
|
95
100
|
## Risks/blockers
|
|
96
|
-
- `},
|
|
101
|
+
- `},yt=["all","project","knowledge","content","prompt","business","tool","mistake"],$e={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},pt={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},Re={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},ot="deepseek-harness",tt=t=>{let l=String(t||""),s=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||s.startsWith("claude-code")?s.startsWith("claude-code")?"claude":ot:s==="deepseek harness"?ot:l.split(":")[0]||ot},Zt=[ot,"claude","codex","cursor","codex-desktop"],Dt=(t=[])=>[...new Set([...Zt,...(t||[]).map(tt)])],Qt={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Ie=`
|
|
97
102
|
.memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
|
|
98
103
|
.mc-card { background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 12px; padding: 14px 16px; }
|
|
99
104
|
.mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
|
|
@@ -180,17 +185,53 @@ Option A, because:
|
|
|
180
185
|
.me-dialog { background: var(--dsw-alias-bg-layer-1, #1e232c); color: var(--dsw-alias-label-primary, #e5e7eb); border-radius: 14px; max-width: 760px; width: 100%; max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,0.5); border: 1px solid var(--dsw-alias-border-l1, #2c333c); }
|
|
181
186
|
.me-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--dsw-alias-border-l1, #e5e7eb); }
|
|
182
187
|
.me-dialog-head h3 { margin: 0; font-size: 15px; }
|
|
183
|
-
.me-dialog-body { padding: 14px 18px; overflow: auto; font-size:
|
|
188
|
+
.me-dialog-body { padding: 14px 18px; overflow: auto; font-size: 13.5px; line-height: 1.78; white-space: normal; word-break: break-word; position: relative; }
|
|
184
189
|
.me-dialog-body h3 { font-size: 15px; margin: 10px 0 6px; color: var(--dsw-alias-label-primary, #111); }
|
|
185
190
|
.me-dialog-body h4 { font-size: 13px; margin: 8px 0 4px; color: var(--dsw-alias-label-primary, #111); }
|
|
186
|
-
.me-dialog-body b, .me-dialog-body strong { font-weight: 700; }
|
|
187
|
-
.me-dialog-body code { background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.14)); border-radius: 4px; padding: 1px 5px; font-size: 0.9em; font-family: ui-monospace, SFMono-Regular, monospace; }
|
|
188
|
-
.me-dialog-body pre { background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.1)); border-radius: 8px; padding: 10px; overflow: auto; margin: 8px 0; }
|
|
189
|
-
.me-dialog-body pre code { background: none; padding: 0; }
|
|
190
|
-
.me-dialog-body ul, .me-dialog-body ol { margin: 6px 0; padding-left: 20px; }
|
|
191
191
|
.me-dialog-body a { color: var(--dsw-alias-accent, #2563eb); }
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
/* ---- \u5361\u7247\u6B63\u6587\u6392\u7248\uFF08.md-doc\uFF09\uFF1Aemoji \u5C0F\u6807\u9898 + \u989C\u8272\u5206\u7EC4 + \u771F\u6B63\u7684\u5217\u8868 ---- */
|
|
193
|
+
.md-doc { max-width: 78ch; }
|
|
194
|
+
.md-doc > *:first-child { margin-top: 0 !important; }
|
|
195
|
+
.md-p { margin: 8px 0; }
|
|
196
|
+
.md-h { display: flex; align-items: center; gap: 7px; margin: 15px 0 7px; font-size: 14.5px; font-weight: 700; letter-spacing: .2px; }
|
|
197
|
+
.md-h .md-ico { font-size: 15px; line-height: 1; }
|
|
198
|
+
.md-h .md-hx { min-width: 0; }
|
|
199
|
+
.md-h::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .16; border-radius: 1px; }
|
|
200
|
+
.md-h-h1 { font-size: 16px; }
|
|
201
|
+
.md-c-ok { color: #10B981; }
|
|
202
|
+
.md-c-warn { color: #F59E0B; }
|
|
203
|
+
.md-c-info { color: var(--dsw-alias-label-primary, #3B82F6); }
|
|
204
|
+
.md-c-plan { color: #A855F7; }
|
|
205
|
+
.md-c-idea { color: #EC4899; }
|
|
206
|
+
.md-c-bad { color: #EF4444; }
|
|
207
|
+
.md-ul, .md-ol { margin: 8px 0; padding-left: 0; list-style: none; }
|
|
208
|
+
.md-ul > li, .md-ol > li { position: relative; padding-left: 19px; margin: 5px 0; }
|
|
209
|
+
.md-ul > li::before { content: ''; position: absolute; left: 5px; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-brand-primary, #3B82F6); opacity: .8; }
|
|
210
|
+
.md-ol { counter-reset: mdol; }
|
|
211
|
+
.md-ol > li { padding-left: 27px; }
|
|
212
|
+
.md-ol > li::before { counter-increment: mdol; content: counter(mdol); position: absolute; left: 0; top: .2em; width: 18px; height: 18px; border-radius: 50%; background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.16)); font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
|
|
213
|
+
.md-b { font-weight: 700; background: linear-gradient(transparent 64%, rgba(59,130,246,.24) 64%); border-radius: 2px; }
|
|
214
|
+
.md-code { background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.14)); border: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.18)); border-radius: 5px; padding: .5px 5px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: .92em; }
|
|
215
|
+
.md-pre { background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.1)); border: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.16)); border-radius: 10px; padding: 10px 12px; overflow: auto; margin: 10px 0; }
|
|
216
|
+
.md-pre code { background: none; border: 0; padding: 0; font-size: 12.5px; line-height: 1.6; }
|
|
217
|
+
.md-callout { margin: 10px 0; padding: 9px 12px; border-radius: 10px; border-left: 3px solid currentColor; background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.08)); }
|
|
218
|
+
.md-callout .md-ico { margin-right: 6px; }
|
|
219
|
+
.md-kv { display: inline-flex; gap: 8px; align-items: baseline; margin: 3px 0; max-width: 100%; }
|
|
220
|
+
.md-k { flex: none; min-width: 4.5em; font-weight: 600; opacity: .72; }
|
|
221
|
+
.md-v { min-width: 0; word-break: break-word; }
|
|
222
|
+
.md-hr { border: 0; border-top: 1px dashed var(--dsw-alias-border-l1, rgba(127,127,127,.28)); margin: 14px 0; }
|
|
223
|
+
.md-task { margin-right: 2px; }
|
|
224
|
+
.md-link { color: var(--dsw-alias-accent, #2563eb); text-decoration: none; border-bottom: 1px solid currentColor; }
|
|
225
|
+
/* \u5143\u4FE1\u606F chips\uFF08kind / \u72B6\u6001 / \u6807\u7B7E / \u65F6\u95F4 / \u6765\u6E90\uFF09 */
|
|
226
|
+
.md-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 18px 0; }
|
|
227
|
+
.md-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; line-height: 1; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.24)); background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.08)); white-space: nowrap; max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
|
|
228
|
+
.md-chip-kind { font-weight: 600; }
|
|
229
|
+
.md-chip-st-ok { color: #10B981; border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.1); }
|
|
230
|
+
.md-chip-st-warn { color: #F59E0B; border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.1); }
|
|
231
|
+
.md-chip-st-bad { color: #EF4444; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.1); }
|
|
232
|
+
.md-date { opacity: .65; }
|
|
233
|
+
.md-collapsed-hint { text-align: center; font-size: 12px; padding: 7px; cursor: pointer; opacity: .72; border-top: 1px dashed var(--dsw-alias-border-l1, rgba(127,127,127,.28)); }
|
|
234
|
+
.md-collapsed-hint:hover { opacity: 1; color: var(--dsw-alias-accent, #2563eb); }
|
|
194
235
|
/* ---- enhanced graph ---- */
|
|
195
236
|
.me-graph { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
|
|
196
237
|
.me-graph-toolbar { display: flex; align-items: center; gap: 8px; }
|
|
@@ -219,12 +260,37 @@ Option A, because:
|
|
|
219
260
|
.me-graph-ctxmenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
|
|
220
261
|
.me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
|
|
221
262
|
.me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
|
|
222
|
-
|
|
263
|
+
/* ---- \u5B98\u65B9\u684C\u9762\u7248\uFF1A\u8BA9\u5F00\u7A97\u53E3\u6807\u9898\u680F ----------------------------------------------
|
|
264
|
+
\u684C\u9762\u58F3\uFF08Electron\uFF09\u628A\u300C\u6700\u5C0F\u5316 / \u6700\u5927\u5316 / \u5173\u95ED\u300D\u753B\u5728\u9875\u9762\u9876\u90E8\uFF0C\u5E76\u6309 DSH \u7684\u7EA6\u5B9A\u5728
|
|
265
|
+
<html> \u4E0A\u6253 data-windows-titlebar\u3001\u7ED9\u51FA --dsh-windows-titlebar-height
|
|
266
|
+
\uFF08DSH \u81EA\u5DF1\u7684\u5168\u5C4F\u6D6E\u5C42\u4E5F\u662F\u8FD9\u4E48\u8BA9\u4F4D\u7684\uFF1B\u5DF2\u5728\u5B98\u65B9\u684C\u9762\u7248\u7684 app.asar \u91CC\u786E\u8BA4\u8FD9\u4E24\u4E2A\u6807\u8BB0\u5B58\u5728\uFF09\u3002
|
|
267
|
+
\u8BB0\u5FC6\u5E93\u6D6E\u5C42\u5FC5\u987B\u6574\u6761\u8BA9\u5F00\uFF1A\u4E00\u6765\u76D6\u4F4F\u7A97\u53E3\u63A7\u5236\u9762\u677F\u5F88\u96BE\u770B\uFF0C\u4E8C\u6765\u6211\u4EEC\u81EA\u5DF1\u53F3\u4E0A\u89D2\u7684\u300C\xD7\u300D
|
|
268
|
+
\u6070\u597D\u538B\u5728\u7A97\u53E3\u300C\u5173\u95ED\u300D\u4E0A \u2014\u2014 \u70B9\u4E0B\u53BB\u4F1A\u76F4\u63A5\u9000\u51FA\u6574\u4E2A\u684C\u9762\u58F3\uFF08\u5B9E\u6D4B\u8E29\u5751\uFF09\u3002
|
|
269
|
+
\u6D4F\u89C8\u5668\u91CC\u6CA1\u6709\u8BE5\u5C5E\u6027 \u2192 \u504F\u79FB 0px\uFF0C\u884C\u4E3A\u4E0E\u4E4B\u524D\u5B8C\u5168\u4E00\u81F4\u3002 */
|
|
270
|
+
[data-windows-titlebar] .me-overlay-top,
|
|
271
|
+
[data-windows-titlebar] .me-overlay {
|
|
272
|
+
top: var(--dsh-windows-titlebar-height, 0px);
|
|
273
|
+
}
|
|
274
|
+
.me-modal-full {
|
|
275
|
+
position: fixed;
|
|
276
|
+
inset: 0;
|
|
277
|
+
width: 100vw;
|
|
278
|
+
height: 100vh;
|
|
279
|
+
max-width: 100vw;
|
|
280
|
+
max-height: 100vh;
|
|
281
|
+
border-radius: 0;
|
|
282
|
+
}
|
|
283
|
+
[data-windows-titlebar] .me-modal-full {
|
|
284
|
+
top: var(--dsh-windows-titlebar-height, 0px);
|
|
285
|
+
height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
|
|
286
|
+
max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
|
|
287
|
+
}
|
|
288
|
+
`;function ea(t){t.effect(()=>t.locale.register(Je,{zh:Tt,en:At}),"memory-eternal: locale");let l=t.locale.bind(Je);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Je,order:25,label:()=>l("nav"),locale:Je,inject:()=>({})},()=>n.default.createElement(aa,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Je}:footer`,order:100,label:()=>l("nav"),locale:Je,inject:()=>({})},s=>n.default.createElement(na,{t:l,locale:t.locale,wide:!(s&&s.wide===!1)}))),"memory-eternal: sidebar footer action")}function ta(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(s=>s.json()).then(s=>{s&&s.ok&&s.url&&l(s.url.endsWith("/")?s.url:s.url+"/")}).catch(()=>{})},[]),t}function aa({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)(Ft,{t,onReload:()=>{},version:0})]})}function na({t,locale:l,wide:s}){let[f,c]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>c(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Rt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),f&&(0,e.jsx)(oa,{t,locale:l,onClose:()=>c(!1)})]})}function oa({t,locale:l,onClose:s,tab:f}){let[c,i]=(0,n.useState)(!1),k=(0,n.useRef)(null),x=ta(),N=(0,n.useCallback)(z=>l&&typeof l.subscribe=="function"?l.subscribe(z):()=>{},[l]),L=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),C=(0,n.useSyncExternalStore)(N,L),b=C&&(C.active==="zh"||C.active==="en")?C.active:null,y=(0,n.useRef)(null);y.current===null&&b&&(y.current=b);let B=(0,n.useMemo)(()=>{let z=y.current?`lang=${y.current}`:"";return f==="config"?`${_}/ui/config?tab=config${z?`&${z}`:""}`:f?`${x.replace(/\/$/,"")}/?tab=${f}${z?`&${z}`:""}`:z?`${x}${x.endsWith("/")?"":"/"}?${z}`:x},[x,f]);return(0,n.useEffect)(()=>{let z=k.current&&k.current.contentWindow;z&&b&&z.postMessage({source:"memory-eternal",type:"locale",lang:b},"*")},[b]),(0,n.useEffect)(()=>{let z=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)("div",{className:"me-modal"+(c?" me-modal-full":""),onClick:z=>z.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(z=>!z),"aria-label":t(c?"exitFullscreen":"enterFullscreen"),title:t(c?"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:c?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:s,"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:B,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Rt(){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)"})]})}function ia({t,inModal:l,onClose:s,onFull:f,full:c}){let[i,k]=(0,n.useState)(null),[x,N]=(0,n.useState)([]),[L,C]=(0,n.useState)(!0),[b,y]=(0,n.useState)(null),[B,z]=(0,n.useState)(""),[v,I]=(0,n.useState)("all"),[S,$]=(0,n.useState)(""),[re,ee]=(0,n.useState)("all"),[O,Le]=(0,n.useState)("all"),[j,be]=(0,n.useState)(()=>{try{let u=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),E={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(u&&E[u])return E[u]}catch{}return"cards"}),[w,ie]=(0,n.useState)(()=>new Set([j])),g=(0,n.useCallback)(u=>{ie(E=>E.has(u)?E:new Set(E).add(u)),be(u)},[]),[D,U]=(0,n.useState)("recent"),[V,P]=(0,n.useState)(null),H=(0,n.useRef)(null),J=(0,n.useRef)(null),[G,ye]=(0,n.useState)(!1),[Fe,We]=(0,n.useState)(null),[Me,de]=(0,n.useState)(!1),[Z,p]=(0,n.useState)(!0),[Y,X]=(0,n.useState)(null),[oe,Ne]=(0,n.useState)(0),Ae=(0,n.useCallback)(()=>Ne(u=>u+1),[]),ze=(0,n.useRef)(null),[He,_e]=(0,n.useState)(0),[je,le]=(0,n.useState)(!1),Ke=(0,n.useRef)(null),Se=(0,n.useRef)(null),r=(0,n.useCallback)(async(u=v,E=S,K=O,ue={})=>{let pe=ue.append===!0;try{pe?le(!0):(C(!0),z(""));let me=new URLSearchParams;u&&u!=="all"&&me.set("kind",u),E.trim()&&me.set("q",E.trim()),me.set("status",K||"all"),me.set("limit",String(Gt)),me.set("offset",String(ue.offset||0)),D==="title"&&me.set("sort","title");let Pe=await(await fetch(`${_}/cards?${me.toString()}`)).json();if(Pe.ok){let Ee=Pe.cards||[];N(Ce=>pe?[...Ce,...Ee.filter(Ye=>!Ce.some(qe=>qe.path===Ye.path))]:Ee),_e(Number(Pe.total)||Ee.length)}}catch(me){z(String(me&&me.message?me.message:me))}finally{pe?le(!1):C(!1)}},[v,S,O,D]),o=(0,n.useCallback)(async()=>{try{let[u,E]=await Promise.all([fetch(`${_}/overview`).then(K=>K.json()),fetch(`${_}/capture-log`).then(K=>K.json()).catch(()=>null)]);u.ok&&k(u),y(E&&E.ok&&E.available&&E.health||null)}catch(u){z(String(u&&u.message?u.message:u))}finally{C(!1)}},[]),A=async u=>{try{let K=await(await fetch(`${_}/delete?path=${encodeURIComponent(u)}`)).json();K.ok?(P({ok:!0,msg:t("deleted")}),await o(),Ae()):P({ok:!1,msg:K.error||t("deleteFail")})}catch{P({ok:!1,msg:t("deleteFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>P(null),2e3)};(0,n.useEffect)(()=>(o(),()=>{ze.current&&clearTimeout(ze.current)}),[o]);let te=u=>{$(u),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>r(v,u,O),280)},ce=u=>{I(u),r(u,S,O)};(0,n.useEffect)(()=>{j==="cards"&&r(v,S,O)},[O,j,oe,D]),(0,n.useEffect)(()=>{if(j!=="cards"||L||je||x.length>=He)return;let u=Ke.current,E=Se.current;if(!u)return;let K=new IntersectionObserver(ue=>{ue[0]&&ue[0].isIntersecting&&r(v,S,O,{append:!0,offset:x.length})},{root:E||null,rootMargin:"400px"});return K.observe(u),()=>K.disconnect()},[j,x,He,L,je,v,S,O,r]);let ke=async u=>{try{let K=await(await fetch(`${_}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();K.ok&&We({path:K.path,title:u.title,text:K.text})}catch(E){z(String(E&&E.message?E.message:E))}},a=async(u,E)=>{ye(!0);try{let K=await fetch(`${_}/export`);if(!K.ok)throw new Error("HTTP "+K.status);let ue=await K.json();if(!ue.ok)throw new Error(ue.error||"export failed");let pe,me,ge;u==="json"?(me="memory-vault.json",ge="application/json",pe=JSON.stringify(ue.cards.map(Ce=>({path:Ce.path,title:Ce.title,kind:Ce.kind,text:Ce.text})),null,2)):(me="memory-vault.md",ge="text/markdown;charset=utf-8",pe=ue.cards.map(Ce=>Ce.text.trim()).filter(Boolean).join(`
|
|
223
289
|
|
|
224
290
|
---
|
|
225
291
|
|
|
226
|
-
`));let Ee=new Blob([pe],{type:ge}),Fe=await la(Ee,me,!1);if(!Fe.ok){F({ok:!1,msg:t("exportFail")}),ye(!1);return}F({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(K){F({ok:!1,msg:t("exportFail")+" \xB7 "+(K.message||"")})}finally{ye(!1)}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2600)},et=async u=>{let j=u.target.files&&u.target.files[0];if(u.target.value="",!!j){try{let K=await j.text(),pe=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:K})).json();pe.ok?(await o(),F({ok:!0,msg:t("importedVault")+"\uFF1A"+(pe.imported||0)+(pe.skipped?t("importedSkipped")+pe.skipped:"")})):F({ok:!1,msg:pe.error||t("importFail")})}catch{F({ok:!1,msg:t("importFail")})}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2400)}},ot=(0,n.useMemo)(()=>{let u=C.slice();return re!=="all"&&(u=u.filter(j=>Qe(j.submittedBy)===re)),E!=="all"&&(u=u.filter(j=>(j.status||"approved")===E)),I==="title"?u.sort((j,K)=>String(j.title||"").localeCompare(String(K.title||""))):I==="hot"?u.sort((j,K)=>(K.weight||K.links||0)-(j.weight||j.links||0)):u.sort((j,K)=>new Date(K.updated||0).getTime()-new Date(j.updated||0).getTime()),u},[C,I,re,E]),it=(0,n.useMemo)(()=>[...new Set(C.map(u=>Qe(u.submittedBy)))],[C]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ie}),V&&(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 "+(V.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:V.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:V.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:V.msg})]}),l&&(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)(Lt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),v&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:v,"aria-label":t(m?"exitFull":"fullscreen"),children:m?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),y&&y.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:[y.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:y.since?nt(new Date(y.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${Z?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>c(u=>!u),"aria-label":t(Z?"collapse":"expand"),title:t(Z?"collapse":"expand"),children:Z?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Se,children:[R==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Je,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Je,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Je,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Je,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Je,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Je,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:w,onChange:u=>te(u.target.value)}),(0,e.jsx)("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:et}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>J.current&&J.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>X({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("md"),children:t(G?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("json"),children:t(G?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ut.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${N===u?" active":""}`,onClick:()=>ce(u),children:t(u==="all"?"all":Pe[u])},u)),(0,e.jsxs)("select",{value:re,onChange:u=>ee(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.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),It(it).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsxs)("select",{value:E,onChange:u=>Le(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("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(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${I===u.key?" active":""}`,onClick:()=>_(u.key),children:u.label},u.key))]}),U&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U]}),(0,e.jsx)("div",{style:{display:R==="cards"?"contents":"none"},children:S?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):U?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("retry")})]}):C.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:ot.map(u=>(0,e.jsx)(Jt,{card:u,t,query:w.trim(),onOpen:ke,onDelete:z},u.path))}),C.length<He&&(0,e.jsx)("div",{ref:Ke,style:{height:1}}),je&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",C.length," / ",He,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:R==="graph"?"flex":"none",flex:1,minHeight:0},children:b.has("graph")&&(0,e.jsx)(ta,{t,onOpen:ke,all:Me,onAllChange:de,onMutate:Ae,active:R==="graph",visible:R==="graph"})}),(0,e.jsx)("div",{style:{display:R==="config"?"contents":"none"},children:b.has("config")&&(0,e.jsx)(Tt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="stats"?"contents":"none"},children:b.has("stats")&&(0,e.jsx)(Zt,{t,tab:"stats",onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="audit"?"contents":"none"},children:b.has("audit")&&(0,e.jsx)(Vt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="optimize"?"contents":"none"},children:b.has("optimize")&&(0,e.jsx)(Gt,{t,onReload:()=>o(),version:oe})}),Re&&(0,e.jsx)(ea,{t,card:Re,query:w.trim(),onClose:()=>We(null),onDelete:u=>{We(null),z(u)},onFeedback:u=>{let j=Re.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:w.trim(),path:j,useful:u})}).then(()=>F({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}}),(0,e.jsx)(Qt,{t,newCard:Y,setNewCard:X,onCreated:()=>{o(),Ae(),F({ok:!0,msg:t("created")}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}})]})]})]})}var Je=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]});function Tt({t,onReload:l,version:d,compact:v}){let[m,i]=(0,n.useState)(null),[A,C]=(0,n.useState)(0),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(!1),[D,N]=(0,n.useState)(null),[H,w]=(0,n.useState)(null),[P,re]=(0,n.useState)(""),[ee,E]=(0,n.useState)(""),[Le,R]=(0,n.useState)(""),[be,b]=(0,n.useState)(""),[ie,g]=(0,n.useState)(null),I=(0,n.useRef)(null),_=(c,Y=!0)=>{I.current&&clearTimeout(I.current),g({msg:c,ok:Y}),I.current=setTimeout(()=>g(null),1900)},V=(c,Y)=>Object.keys(Y).reduce((X,oe)=>X.split("{"+oe+"}").join(Y[oe]),t(c)),F=(0,n.useCallback)(async()=>{try{let[c,Y,X]=await Promise.all([fetch(`${W}/config`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/setup-status`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/budget`).then(oe=>oe.json()).catch(()=>null)]);c&&c.ok?(i(c),C(c.revision??0),S(c.schema??null),y({...c.config??{}}),N(c.dsh??null),U(c.writable===!1),re("")):X&&X.ok?(y({...X}),U(!0),re(t("configNeedsDsh"))):re(t("adminLoadFail")),Y&&Y.ok&&w(Y),R("")}catch{re(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{F()},[d,F]);let O=(c,Y)=>y(X=>({...X??{},[c]:Y})),J=c=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[c]||c,G=async()=>{if(k){if(x){_(t("editInSetting"),!1);return}E("save");try{let c=await fetch(`${W}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:k,expectedRevision:A})}),Y=await c.json();if(Y&&Y.ok)R(t("savedOk")+(Y.note?` \xB7 ${t("restartHint")}`:"")),_(t("savedOk")),await F();else{let X=c.status===409?t("conflictRefresh"):Y?.error||t("saveFail");re(X),_(X,!1)}}catch{re(t("saveFail")),_(t("saveFail"),!1)}finally{E("")}}},ye=()=>{y({...m?.config??{}}),R("")},Re={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,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}},We=async c=>{let Y=Re[c];Y&&y(X=>({...X??{},...Y}))},Me=async(c,Y)=>{E(c+Y);try{let oe=await(await fetch(`${W}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:c,action:Y})})).json();oe&&oe.ok?_(V(Y==="install"?"mcpInstalled":"mcpUninstalled",{agent:c})):_(V("mcpActionFail",{agent:c,error:oe?.error||""}),!1);try{let Ne=await fetch(`${W}/setup-status`).then(Ae=>Ae.json());Ne&&Ne.ok&&w(Ne)}catch{}}catch{_(t("mergeFail"),!1)}finally{E("")}},de=({k:c,label:Y,type:X="text",step:oe,min:Ne,max:Ae})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:Y||c}),(0,e.jsx)("input",{type:X,step:oe,min:Ne,max:Ae,value:k?k[c]??"":"",onChange:ze=>O(c,X==="number"?Number(ze.target.value):ze.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}})]}),Z=({k:c,label:Y})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(k&&k[c]),onChange:X=>O(c,X.target.checked)}),(0,e.jsx)("span",{children:Y||c})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:v?"0 0 auto":1,minHeight:0,maxHeight:v?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ie}),ie&&(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 "+(ie.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ie.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ie.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ie.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[P&&(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 ",P]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:F,children:["\u21BB ",t("retry")]})]}),x&&(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")]}),Le&&(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 ",Le]}),m&&(m.version||m.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,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")}),m.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",m.version]}),m.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",m.dsh.vaultDir]})]}),H&&H.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:H.agents.map(c=>(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:c.isDsh?t("dshHostLabel"):c.name}),c.isDsh&&c.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",c.version]}),!c.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),c.installed&&c.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),c.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),c.mcpConfigured===!0&&c.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),c.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",c.recallTool?t("enabled"):t("disabled"),")"]})]}),c.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",c.hook]}),!c.isDsh&&c.installed&&c.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ee,onClick:()=>Me(c.name,"install"),children:t("installMcp")}),!c.isDsh&&c.installed&&c.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ee,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Me(c.name,"uninstall")},children:t("uninstallMcp")})]},c.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),be&&(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:be})})]}),k?(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(c=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>We(c),disabled:!!ee,children:[c==="A"?"\u{1F7E2} ":c==="B"?"\u{1F4B0} ":"\u2B50 ",Re[c].label]},c))})]}),(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(150px, 1fr))",gap:8},children:[(0,e.jsx)(Z,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Z,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(de,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(de,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(de,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(de,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(de,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Z,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(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(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(Z,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Z,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(de,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(de,{k:"recallMinScore",label:t("recallMinScore"),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(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:k.auditMode??"all",onChange:c=>O("auditMode",c.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)(St,{label:t("auditExemptAgents"),value:k.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(H?.agents||[]).filter(c=>!c.isDsh).map(c=>({value:c.name,label:c.name}))],onChange:c=>O("auditExemptAgents",c)}),(0,e.jsx)(St,{label:t("auditExemptKinds"),value:k.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...ut.filter(c=>c!=="all").map(c=>({value:c,label:t(Pe[c])}))],onChange:c=>O("auditExemptKinds",c)}),(0,e.jsx)(de,{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(150px, 1fr))",gap:8},children:[(0,e.jsx)(Z,{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:k.autoWebMode??"init",onChange:c=>O("autoWebMode",c.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)(de,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(de,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(de,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Z,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Z,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:ye,disabled:!!ee,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:G,disabled:!!ee||ee==="save"||x,children:ee==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Vt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,A]=(0,n.useState)([]),[C,L]=(0,n.useState)("all"),[S,k]=(0,n.useState)("all"),[y,x]=(0,n.useState)(""),[U,D]=(0,n.useState)(new Set),[N,H]=(0,n.useState)(""),[w,P]=(0,n.useState)("pending"),re=[...new Set([...v,...i].map(b=>b.submittedBy).filter(Boolean))],ee=(0,n.useCallback)(async()=>{try{let b=await fetch(`${W}/audit/list`).then(ie=>ie.json());b.ok&&(m(b.pending||[]),A(b.rejected||[]),D(new Set))}catch{}},[]);(0,n.useEffect)(()=>{ee()},[d,ee]);let E=(w==="pending"?v:i).filter(b=>{if(C!=="all"&&b.kind!==C||S!=="all"&&Qe(b.submittedBy)!==S)return!1;if(y){let ie=(b.created||"").slice(0,10);if(ie&&ie!==y)return!1}return!0}),Le=b=>D(ie=>{let g=new Set(ie);return g.has(b)?g.delete(b):g.add(b),g}),R=async(b,ie)=>{H("apply");try{for(let g of ie||[...U])await fetch(`${W}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${b==="delete"?"&permanent=0":""}`);await ee(),l&&l()}catch{}finally{H("")}},be=[...U];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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(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:C,onChange:b=>L(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")}),ut.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(Pe[b])},b))]}),(0,e.jsxs)("select",{value:S,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("allAgents")}),It(re).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>x(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${w==="pending"?" me-on":""}`,onClick:()=>P("pending"),children:[t("pending"),"\uFF08",v.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${w==="rejected"?" me-on":""}`,onClick:()=>P("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:E.length>0&&be.length===E.length,onChange:b=>{b.target.checked?D(new Set(E.map(ie=>ie.path))):D(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!be.length||!!N,onClick:()=>R("approved"),children:["\u2713 ",t(w==="rejected"?"restore":"approve")]}),w==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>R("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&R("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),E.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:E.map(b=>(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)("input",{type:"checkbox",checked:U.has(b.path),onChange:()=>Le(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Qe(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||"-"}),w==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>R("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>R("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:()=>R("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"))&&R("delete",[b.path])},children:"\u{1F5D1}"})]})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Gt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,A]=(0,n.useState)(""),C=(0,n.useCallback)(async()=>{try{let S=await fetch(`${W}/recycle/list`).then(k=>k.json());S.ok&&m(S.items||[])}catch{}},[]);(0,n.useEffect)(()=>{C()},[d,C]);let L=async(S,k)=>{A(S+k);try{S==="restore"?await fetch(`${W}/recycle/restore?path=${encodeURIComponent(k)}`):S==="purge"&&await fetch(`${W}/recycle/purge?path=${encodeURIComponent(k)}`),await C(),l&&l()}catch{}finally{A("")}};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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(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,onClick:async()=>{A("purgeAll");try{await fetch(`${W}/recycle/purge-expired?days=0`),await C()}catch{}finally{A("")}},children:t("emptyRecycle")})]}),v.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:v.map(S=>(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:Oe[S.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(S.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>L("restore",S.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"))&&L("purge",S.path)},children:t("purge")})]},S.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Jt=({card:t,t:l,onOpen:d,query:v,onDelete:m})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[t.kind]||Oe.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:Ct[t.kind]||"\u{1F4CE}"}),v?Mt(t.title,v):t.title,ia(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",l("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",l("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",l("statusApproved")]})]}),(0,e.jsx)("p",{children:v?Mt(t.summary||"",v):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:[Ct[t.kind]||"\u{1F4CE}"," ",l(Pe[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Qe(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",nt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&m&&m(t.path)},children:"\u{1F5D1}"})]})]});function Zt({t,tab:l,onReload:d,version:v}){let[m,i]=(0,n.useState)(null),[A,C]=(0,n.useState)(""),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(null),[D,N]=(0,n.useState)([]),[H,w]=(0,n.useState)(""),[P,re]=(0,n.useState)(!1),ee=(0,n.useCallback)(async()=>{if(!(!L||!L.merge||!L.merge.length)&&window.confirm(t("mergeAllConfirm"))){w("merge");try{let g={},I=J=>g[J]===void 0?J:g[J]=I(g[J]),_=(J,G)=>{g[I(J)]=I(G)},V=new Set;for(let J of L.merge)V.add(J.a.path),V.add(J.b.path),_(J.a.path,J.b.path);let F={};for(let J of V){let G=I(J);(F[G]=F[G]||[]).push(J)}let O=0;for(let J of Object.values(F)){if(J.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(J.join(","))}`).then(ye=>ye.json())).ok&&O++}await E(),d&&d()}catch{}w("")}},[L,E,d,t]);async function E(){try{let g=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/budget`),fetch(`${W}/capture-log`),fetch(`${W}/cards?status=all&limit=30&agent=${at}`)]),[I,_,V,F]=await Promise.all(g.map(O=>O.json()));I&&I.ok&&i(I),_&&_.ok&&y(_),V&&V.ok&&U(V),F&&F.ok&&N(F.cards||[]),C(!I||!I.ok?t("adminLoadFail"):"")}catch{C(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{w("scan");try{let g=await fetch(`${W}/optimize`).then(I=>I.json());g.ok&&S(g)}catch{C(t("adminLoadFail"))}finally{w("")}},[t]);(0,n.useEffect)(()=>{E()},[v]);let R=async(g,I)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(g+","+I)}`).then(V=>V.json())).ok&&(await E(),d&&d())}catch{}},be=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(g)}`).then(_=>_.json())).ok&&(await E(),d&&d())}catch{}},b=["project","knowledge","content","prompt","business","tool","mistake"],ie=({title:g,kind:I,updated:_,path:V})=>(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:Ze.colors[I]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(_)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>be(V),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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[A&&(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 ",A]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:E,children:["\u21BB ",t("retry")]})]}),l==="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:()=>E(),children:["\u21BB ",t("refresh")]})]}),x?x.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(x.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:(x.entries||[]).map((g,I)=>{let _=Ht[g.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:nt(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:_[1],fontWeight:600},children:[_[0]," ",g.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:g.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.preview||"",children:g.preview||""})]},I)})})})}):(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",D.length,"\uFF09"]}),D.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:D.map(g=>(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:Oe[g.kind]||Oe.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.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:nt(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),m&&(0,e.jsxs)(e.Fragment,{children:[m.trend&&m.trend.length>0&&(()=>{let g=m.trend,I=Math.max(...g.map(O=>O.count),1),_=260,V=50,F=_/g.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:_,height:V,style:{display:"block",width:"100%",height:50},children:g.map((O,J)=>{let G=Math.round(O.count/I*(V-4));return(0,e.jsx)("rect",{x:J*F+1,y:V-G,width:Math.max(F-2,2),height:G,rx:1.5,fill:O.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:O.count>0?.85:.35},O.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.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:b.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[g]||"#666"}}),t(Pe[g]),": ",m.byKind?.[g]||0]},g))})]}),k&&(k.budgetChars||k.recallLimit||k.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:k.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:k.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",k.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",m.todayCards?.length||0,"\uFF09"]}),m.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:m.todayCards.map(g=>(0,e.jsx)(ie,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="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:!!H,onClick:Le,children:H==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),L&&L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){w("oneclick");try{let g=JSON.stringify({cleanupStale:P}),_=await(await fetch(`${W}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();_&&_.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${_.plan.merged} ${t("optimizedMerged")}${P?` \xB7 ${_.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await E(),d&&d(),S(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{w("")}}},children:H==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),L&&L.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:P,onChange:g=>re(g.target.checked)}),t("oneClickAlsoStale")]})]}),!L&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),L&&(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}}),L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:ee,children:t(H==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),L.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:L.merge.map((g,I)=>(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:[g.a.title," \u21C4 ",g.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(g.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>R(g.a.path,g.b.path),children:t("mergeNow")})]},I))}):(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",L.stale?.length||0,"\uFF09"]}),L.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!H,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;w("clean");let g=0;for(let I of L.stale)try{await fetch(`${W}/delete?path=${encodeURIComponent(I.path)}`),g++}catch{}w(""),notify(`${g} ${t("deletedStale")}`),await E(),d&&d()},children:t("cleanStale")})}),L.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:L.stale.map(g=>(0,e.jsx)(ie,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var mt=[{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 Qt({t,newCard:l,setNewCard:d,onCreated:v}){if(!l)return null;let m=mt.find(y=>y.key===l.template),i=l.body||(m?t(m.bodyKey):""),A=l.kind||(m?m.kind:"knowledge"),C=l.tags||(m?t(m.tagKey):""),L=l._creating,S=y=>{let x=mt.find(U=>U.key===y);d(U=>({...U,template:y,kind:x?x.kind:U.kind,body:x?t(x.bodyKey):U.body,tags:x?t(x.tagKey):U.tags}))},k=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${W}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:A,tags:C.split(",").map(x=>x.trim()).filter(Boolean),body:i,source:"manual"})}).then(x=>x.json())).ok?(d(null),v&&v()):d(x=>({...x,_creating:!1}))}catch{d(x=>({...x,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.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:()=>d(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:[mt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>S(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:A,onChange:y=>d(x=>({...x,kind:y.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(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(x=>({...x,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:C,onChange:y=>d(x=>({...x,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(x=>({...x,body:y.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:L,onClick:k,children:t(L?"exporting":"createCard")})})]})]})]})}function ea({t,card:l,query:d,onClose:v,onDelete:m,onFeedback:i}){(0,n.useEffect)(()=>{let S=k=>{k.key==="Escape"&&v()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[v]);let[A,C]=(0,n.useState)(!1),L=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:v,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",onClick:S=>S.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(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("fbIrr")]})]}),L&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>C(S=>!S),children:t(A?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&m&&m(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:v,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:A?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ra(l.text)}})]})]})}function ta({t,onOpen:l,all:d,onAllChange:v,onMutate:m,active:i,visible:A}){let[C,L]=(0,n.useState)(null),[S,k]=(0,n.useState)(""),y=(0,n.useRef)(!1),x=(0,n.useRef)(0),U=(0,n.useRef)(t);U.current=t;let D=(0,n.useCallback)(async()=>{try{y.current=!1;let P=await(await fetch(`${W}/graph${d?"?all=1":""}`)).json();P.ok?(L(P),k(""),y.current=!0):(L(null),k(P.error||t("error")))}catch(w){k(String(w&&w.message?w.message:w))}},[d,t]);(0,n.useEffect)(()=>{if(!i||y.current)return;let w=!0;return fetch(`${W}/graph${d?"?all=1":""}`).then(P=>P.json()).then(P=>{w&&(P.ok?(L(P),k(""),y.current=!0):(L(null),k(P.error||t("error"))))}).catch(P=>{w&&k(String(P&&P.message?P.message:P))}),()=>{w=!1}},[d,t,i]),(0,n.useEffect)(()=>{A&&C&&x.current++},[A,C]);let N=(0,n.useCallback)(async w=>{try{let re=await(await fetch(`${W}/delete?path=${encodeURIComponent(w)}`)).json();return re&&re.ok?(await D(),m&&m(),!0):!1}catch{return!1}},[D]),H=(0,n.useCallback)(async w=>{if(!w||w.length<2)return!1;try{let P=await fetch(`${W}/merge?paths=${encodeURIComponent(w.join(","))}`).then(re=>re.json());return P&&P.ok?(await D(),m&&m(),!0):!1}catch{return!1}},[D,m]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ie}),S&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",S]}),!C&&!S&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),C&&C.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),C&&C.nodes.length>0&&(0,e.jsx)(na,{nodes:C.nodes,edges:C.edges,onOpen:l,onDelete:N,onMerge:H,t,all:d,onAllChange:v,countLabel:`${C.nodes.length} ${t("nodes")} \xB7 ${aa(C.edges)} ${t("edges")}`,fitTrigger:x.current})]})}function aa(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var Ze={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 na({nodes:t,edges:l,onOpen:d,onDelete:v,onMerge:m,t:i,countLabel:A,all:C,onAllChange:L,fitTrigger:S}){let k=(0,n.useRef)(null),y=(0,n.useRef)(null),x=(0,n.useRef)(null),U=(0,n.useRef)(null),D=(0,n.useRef)(null),N=(0,n.useRef)(d);(0,n.useEffect)(()=>{N.current=d},[d]);let H=(0,n.useRef)(v);(0,n.useEffect)(()=>{H.current=v},[v]);let w=(0,n.useRef)(m);(0,n.useEffect)(()=>{w.current=m},[m]);let[P,re]=(0,n.useState)(""),[ee,E]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=P.trim().toLowerCase()},[P]),(0,n.useEffect)(()=>{let r=x.current;if(!r)return;let o=P.trim().toLowerCase();if(!o)return;let z=r.nodes.find(te=>(te.name||"").toLowerCase().includes(o));z&&(x.current.selectedId=z.id,E(z.id),r.panX=r.w/2-z.x*r.zoom,r.panY=r.h/2-z.y*r.zoom,r.render&&r.render())},[P]);let[R,be]=(0,n.useState)("all"),[b,ie]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[I,_]=(0,n.useState)(""),V=(0,n.useRef)(""),[F,O]=(0,n.useState)(!1),J=(0,n.useRef)(!1),[G,ye]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=R},[R]),(0,n.useEffect)(()=>{V.current=I},[I]),(0,n.useEffect)(()=>{J.current=F},[F]);let Re=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let z of o.tags||[]){let te=String(z).trim();te&&r.set(te,(r.get(te)||0)+1)}return[...r.entries()].sort((o,z)=>z[1]-o[1]).slice(0,24).map(([o,z])=>({tag:o,n:z}))},[t]),We=(()=>{let r=P.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(Pe[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=x.current;r&&r.wake&&r.wake()},[P]),(0,n.useEffect)(()=>{let r=x.current;r&&r.render&&r.render()},[R,I,F]);let Me=(0,n.useRef)(null),[de,Z]=(0,n.useState)([]),[c,Y]=(0,n.useState)(null),[X,oe]=(0,n.useState)(!1),[Ne,Ae]=(0,n.useState)(null),[ze,He]=(0,n.useState)(""),_e=(0,n.useRef)(null),je=(0,n.useRef)(null),le=(r,o=!0)=>{_e.current&&clearTimeout(_e.current),Ae({msg:r,ok:o}),_e.current=setTimeout(()=>Ae(null),1900)},Ke=r=>{He(r),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>He(""),1600)};(0,n.useEffect)(()=>()=>{_e.current&&clearTimeout(_e.current),je.current&&clearTimeout(je.current)},[]);let Se=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let z=Math.max(1,window.devicePixelRatio||1),te=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(s=>{ce[s.source]=(ce[s.source]||0)+1,ce[s.target]=(ce[s.target]||0)+1});let ke=Math.max(1,...Object.values(ce)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(ce[s.id]||0)/ke*8),x:0,y:0,vx:0,vy:0})),edges:l.map(s=>({sourceNodeId:s.source,targetNodeId:s.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:z,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,h)=>(s[h.id]=h,s),{}),a.nodes.forEach((s,h)=>{let f=h/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let et=[...new Set(a.nodes.map(s=>s.type))];a.clustered=et.length>1,a.typeCenters={},et.forEach((s,h)=>{let f=h/et.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),x.current=a;let ot=0,it=0,u=()=>{let s=r.clientWidth,h=r.clientHeight;a.w=s,a.h=h,r.width=s*z,r.height=h*z,o.setTransform(z,0,0,z,0,0),(ot===0||it===0)&&s>0&&h>0&&a.tickCount>0&&requestAnimationFrame(()=>pe()),ot=s,it=h};u();let j=new ResizeObserver(u);j.observe(r.parentElement);let K=(s,h)=>s&&s.length>h?s.slice(0,h)+"\u2026":s,ue=(s,h,f,M)=>{if(o.beginPath(),M==="rect")o.rect(s-f,h-f*.75,f*2,f*1.5);else if(M==="diamond")o.moveTo(s,h-f),o.lineTo(s+f,h),o.lineTo(s,h+f),o.lineTo(s-f,h),o.closePath();else if(M==="hexagon"){for(let T=0;T<6;T++){let Q=Math.PI/3*T-Math.PI/2,q=s+f*Math.cos(Q),he=h+f*Math.sin(Q);T===0?o.moveTo(q,he):o.lineTo(q,he)}o.closePath()}else o.arc(s,h,f,0,Math.PI*2)},pe=()=>{if(!a.nodes.length)return;let s=1/0,h=-1/0,f=1/0,M=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),h=Math.max(h,p.x),f=Math.min(f,p.y),M=Math.max(M,p.y)});let T=20,Q=h-s+T*2,q=M-f+T*2,he=Math.min(a.w/Q,a.h/q);a.zoom=Math.max(.35,Math.min(1.8,he)),a.panX=a.w/2-(s+h)/2*a.zoom,a.panY=a.h/2-(f+M)/2*a.zoom};U.current=pe;let me=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=g.current,a.timeMode=J.current,a.tagFilter=V.current;let s=a.tagFilter,h=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=te()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let p=0;p<a.w;p+=24)o.beginPath(),o.moveTo(p,0),o.lineTo(p,a.h),o.stroke();for(let p=0;p<a.h;p+=24)o.beginPath(),o.moveTo(0,p),o.lineTo(a.w,p),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let M={};a.nodes.forEach(p=>M[p.id]=p);let T=a.nodes.length>40,Q=T?1.5:.55,q=a.selectedId||a.hoverId;a.edges.forEach(p=>{let ae=M[p.sourceNodeId],B=M[p.targetNodeId];if(!ae||!B)return;if(h!=="all"){let rt=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,we=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(rt!==h&&we!==h)return}if(s){let rt=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),we=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!rt&&!we)return}let $=B.x-ae.x,ne=B.y-ae.y,se=Math.sqrt($*$+ne*ne)||1,fe=T?12:18,xe=-ne/se*fe,ve=$/se*fe,Te=(ae.x+B.x)/2+xe,Be=(ae.y+B.y)/2+ve,De=Ze.colors[a.domainById[ae.id]&&a.domainById[ae.id].kind||"other"],Ue=q&&(p.sourceNodeId===q||p.targetNodeId===q),ct=q?Ue?.6:.08:T?.14:.24,pt=parseInt(De.slice(1,3),16),tt=parseInt(De.slice(3,5),16),lt=parseInt(De.slice(5,7),16);o.strokeStyle="rgba("+pt+","+tt+","+lt+","+ct+")",o.lineWidth=Ue?1.6+(p.weight||1):.8+(p.weight||1)*.5,o.beginPath(),o.moveTo(ae.x,ae.y),o.quadraticCurveTo(Te,Be,B.x,B.y),o.stroke()});let he=[];if(a.nodes.forEach(p=>{let ae=a.domainById[p.id]||{},B=ae.kind||"other",$=a.timeMode?oa(ae.updated):Ze.colors[B],ne=Ze.shapes[B],se=a.selectedId===p.id,fe=a.hoverId===p.id,xe=a.searchTerm||"",ve=!xe||(p.name||"").toLowerCase().includes(xe)||String(Pe[B]||"").toLowerCase().includes(xe)||String(B).toLowerCase().includes(xe),Te=h==="all"||B===h,Be=!s||(ae.tags||[]).includes(s),De=q&&p.id!==q&&!a.edges.some(we=>we.sourceNodeId===q&&we.targetNodeId===p.id||we.targetNodeId===q&&we.sourceNodeId===p.id)||xe&&!ve||!Te||!Be;o.save(),o.globalAlpha=De?.08:1,(se||fe)&&(o.shadowColor=$,o.shadowBlur=se?20:14),ue(p.x,p.y,p.r,ne);let Ue=parseInt($.slice(1,3),16),ct=parseInt($.slice(3,5),16),pt=parseInt($.slice(5,7),16),tt=o.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);tt.addColorStop(0,"rgba("+Math.min(255,Ue+70)+","+Math.min(255,ct+70)+","+Math.min(255,pt+70)+",0.95)"),tt.addColorStop(1,$),o.fillStyle=tt,o.fill(),o.restore(),se?(o.save(),ue(p.x,p.y,p.r+3,ne),o.strokeStyle=$,o.lineWidth=3,o.shadowColor=$,o.shadowBlur=12,o.stroke(),o.restore()):fe?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle=$,o.lineWidth=2,o.stroke(),o.restore()):xe&&ve?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(p.id)>=0&&(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let lt=K(p.name,16);if((se||fe||a.zoom>Q||!T&&a.zoom>.6)&&Te&&Be){let we=1/a.zoom;o.font="500 "+(12*we).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let $e=o.measureText(lt).width+16*we,st=18*we,Xe=p.y+p.r+8*we,wt=!0;for(let Ve of he)if(p.x-$e/2<Ve.x+Ve.w&&p.x+$e/2>Ve.x&&Xe<Ve.y+Ve.h&&Xe+st>Ve.y){wt=!1;break}if(!wt&&!se&&!fe)return;he.push({x:p.x-$e/2,y:Xe,w:$e,h:st}),o.fillStyle=te()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(p.x-$e/2,Xe,$e,st,4*we):o.rect(p.x-$e/2,Xe,$e,st),o.fill(),o.strokeStyle=te()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*we,o.stroke(),o.fillStyle=te()?se||fe?"#eee":"#bbb":se||fe?"#111":"#444",o.textAlign="center",o.fillText(lt,p.x,Xe+13*we)}}),o.restore(),a.marquee){let p=a.marquee,ae=Math.min(p.sx,p.ex),B=Math.min(p.sy,p.ey),$=Math.abs(p.ex-p.sx),ne=Math.abs(p.ey-p.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(ae,B,$,ne),o.strokeRect(ae,B,$,ne),o.restore()}if(a.hoverId&&Me.current){let p=a.domainById[a.hoverId],ae=a.nodes.find(function(B){return B.id===a.hoverId});if(p&&ae){let B=a.edges.filter(function(se){return se.sourceNodeId===p.id||se.targetNodeId===p.id}).length,$=ae.x*a.zoom+a.panX,ne=ae.y*a.zoom+a.panY;Me.current.style.display="block",Me.current.style.left=$+14+"px",Me.current.style.top=ne-6+"px",Me.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",B)+"</span>"}}else Me.current&&(Me.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Fe))};a.wake=ge,a.render=me;let Ee=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),M=s>1e3?3e3:s>100?2e3:s>50?1200:800,T=s>100?.002:.005,Q=s>1e3?.012:s>100?.005:.01,q=s>1e3?6:s>200?12:24,he={};a.nodes.forEach(B=>he[B.id]=B);for(let B=0;B<s;B++){if(a.dragNode===a.nodes[B])continue;let $=a.nodes[B],ne=0,se=0;for(let ve=0;ve<s;ve++){if(B===ve)continue;let Te=$.x-a.nodes[ve].x,Be=$.y-a.nodes[ve].y,De=Math.sqrt(Te*Te+Be*Be)||1,Ue=M/(De*De);ne+=Te/De*Ue,se+=Be/De*Ue}if(a.clustered&&a.typeCenters[$.type]){let ve=a.typeCenters[$.type];ne+=(ve.x-$.x)*.006,se+=(ve.y-$.y)*.006}else ne-=$.x*Q,se-=$.y*Q;let fe=($.vx+ne)*f,xe=($.vy+se)*f;fe=Math.max(-q,Math.min(q,fe)),xe=Math.max(-q,Math.min(q,xe)),$.vx=fe,$.vy=xe}a.edges.forEach(B=>{let $=he[B.sourceNodeId],ne=he[B.targetNodeId];if(!$||!ne)return;let se=ne.x-$.x,fe=ne.y-$.y,xe=Math.sqrt(se*se+fe*fe)||1,ve=(xe-100)*T,Te=se/xe*ve,Be=fe/xe*ve;a.dragNode!==$&&($.vx+=Te,$.vy+=Be),a.dragNode!==ne&&(ne.vx-=Te,ne.vy-=Be)});let p=0;a.nodes.forEach(B=>{a.dragNode!==B&&(B.x+=B.vx,B.y+=B.vy,p+=B.vx*B.vx+B.vy*B.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,pe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Fe=()=>{if(a.running){try{Ee(),me()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Fe)}},Ce=(s,h)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(h-f.top-a.panY)/a.zoom}},Ye=s=>{let h=a.domainById[s];return!(!h||g.current!=="all"&&h.kind!==g.current||V.current&&!(h.tags||[]).includes(V.current))},qe=(s,h,f)=>Math.max(h,Math.min(f,s)),gt=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+36){f=T.id;break}}f!==a.hoverId&&(a.hoverId=f,ge())},ft=s=>{if(s.button!==0)return;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(s.shiftKey){if(f){a.shiftClick=f.id;return}a.marquee={sx:s.clientX,sy:s.clientY,ex:s.clientX,ey:s.clientY};return}a.dragStart={x:s.clientX,y:s.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=f||null,f&&(a.dragOffset={dx:f.x-h.x,dy:f.y-h.y})},bt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ge();return}if(!a.dragStart)return;let h=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let M=Ce(s.clientX,s.clientY);a.dragNode.x=M.x+a.dragOffset.dx,a.dragNode.y=M.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=qe(a.dragStart.px+h,-1e5,1e5),a.panY=qe(a.dragStart.py+f,-1e5,1e5),ge())},yt=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let M=r.getBoundingClientRect(),T=Math.min(f.sx,f.ex)-M.left,Q=Math.max(f.sx,f.ex)-M.left,q=Math.min(f.sy,f.ey)-M.top,he=Math.max(f.sy,f.ey)-M.top,p=a.nodes.filter(ae=>{let B=ae.x*a.zoom+a.panX,$=ae.y*a.zoom+a.panY;return B>=T&&B<=Q&&$>=q&&$<=he}).map(ae=>ae.id);a.multi=p,Z(p),ge();return}let h=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let M=Array.isArray(a.multi)?a.multi.slice():[];M.includes(f)||M.push(f),a.multi=M,Z(M),ge();return}if(h){let f=Ce(s.clientX,s.clientY),M=null;for(let T=a.nodes.length-1;T>=0;T--){let Q=a.nodes[T];if(!Ye(Q.id))continue;let q=Q.x-f.x,he=Q.y-f.y;if(q*q+he*he<Q.r*Q.r+20){M=Q;break}}M?(a.selectedId=M.id,E(M.id),ge()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],Z([])),E(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ht=s=>{s.preventDefault();let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(f){let M=a.domainById[f.id];M&&ye({x:s.clientX,y:s.clientY,id:f.id,path:M.id,title:M.title})}else ye(null)},xt=s=>{s.preventDefault();let h=r.getBoundingClientRect(),f=(s.clientX-h.left-a.panX)/a.zoom,M=(s.clientY-h.top-a.panY)/a.zoom,T=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+f*(a.zoom-T),-1e5,1e5),a.panY=qe(a.panY+M*(a.zoom-T),-1e5,1e5),a.zoom=T,ge()};r.addEventListener("mousemove",gt),r.addEventListener("mousedown",ft),window.addEventListener("mousemove",bt),window.addEventListener("mouseup",yt),r.addEventListener("wheel",xt,{passive:!1}),r.addEventListener("contextmenu",ht),D.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Z([]),pe(),ge()};for(let s=0;s<200;s++)Ee();pe(),ge();let vt=()=>ie(!1);return window.addEventListener("mousedown",vt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),j.disconnect(),r.removeEventListener("mousemove",gt),r.removeEventListener("mousedown",ft),window.removeEventListener("mousemove",bt),window.removeEventListener("mouseup",yt),r.removeEventListener("wheel",xt),r.removeEventListener("contextmenu",ht),window.removeEventListener("mousedown",vt)}},[t,l]),(0,n.useEffect)(()=>{S!==void 0&&U.current&&requestAnimationFrame(()=>U.current())},[S]),(0,e.jsxs)("div",{className:"me-graph",ref:y,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:P,onChange:r=>re(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ie(r=>!r),"aria-expanded":b,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",R!=="all"||F||I?"\u25CF":"\u25BE"]}),b&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.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${R==="all"&&!F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{be("all"),O(!1)},children:i("all")}),Object.keys(Oe).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${R===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>be(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[r]||Oe[r]}}),i(Pe[r])]},r)),(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${F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>O(r=>!r),children:["\u23F1 ",i("timeDim")]}),Re.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:Re.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${I===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>_(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(R!=="all"||F||I)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{be("all"),O(!1),_("")},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:!!C,onChange:r=>L&&L(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${F?" me-on":""}`,onClick:()=>O(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(o=>{o&&Y({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>U.current&&U.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{E(null),be("all"),D.current&&D.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Me,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)"}}),We&&(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")}),G&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ye(null)}),G&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:G.x,top:G.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{N.current({path:G.path,title:G.title}),ye(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.id&&(x.current.selectedId=G.id,E(G.id)),ye(null);let r=x.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(G.title||"")}catch{}ye(null),le(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=x.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],z=G.id;if(z&&!o.includes(z)&&o.push(z),ye(null),o.length<2){le(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let te=w.current&&w.current(o);te&&te.then?te.then(ce=>ce?le(i("merged")):le(i("mergeFail"),!1)).catch(()=>le(i("mergeFail"),!1)):te&&le(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=G.path;ye(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(H.current?await H.current(r):!1)?le(i("deleted")):le(i("deleteFail"),!1)}catch{le(i("deleteFail"),!1)}})()},children:i("delete")})]}),de.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:[de.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=de.map(ke=>Se[ke]).filter(Boolean).map(ke=>ke.title||ke.name).join(`
|
|
227
|
-
`),
|
|
292
|
+
`));let Pe=new Blob([pe],{type:ge}),Ee=await ya(Pe,me,!1);if(!Ee.ok){P({ok:!1,msg:t("exportFail")}),ye(!1);return}P({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Ee.name})}catch(K){P({ok:!1,msg:t("exportFail")+" \xB7 "+(K.message||"")})}finally{ye(!1)}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>P(null),2600)},at=async u=>{let E=u.target.files&&u.target.files[0];if(u.target.value="",!!E){try{let K=await E.text(),pe=await(await fetch(`${_}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:K})).json();pe.ok?(await o(),P({ok:!0,msg:t("importedVault")+"\uFF1A"+(pe.imported||0)+(pe.skipped?t("importedSkipped")+pe.skipped:"")})):P({ok:!1,msg:pe.error||t("importFail")})}catch{P({ok:!1,msg:t("importFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>P(null),2400)}},it=(0,n.useMemo)(()=>{let u=x.slice();return re!=="all"&&(u=u.filter(E=>tt(E.submittedBy)===re)),O!=="all"&&(u=u.filter(E=>(E.status||"approved")===O)),D==="title"?u.sort((E,K)=>String(E.title||"").localeCompare(String(K.title||""))):D==="hot"?u.sort((E,K)=>(K.weight||K.links||0)-(E.weight||E.links||0)):u.sort((E,K)=>new Date(K.updated||0).getTime()-new Date(E.updated||0).getTime()),u},[x,D,re,O]),lt=(0,n.useMemo)(()=>[...new Set(x.map(u=>tt(u.submittedBy)))],[x]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ie}),V&&(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 "+(V.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:V.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:V.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:V.msg})]}),l&&(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)(Rt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),f&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:f,"aria-label":t(c?"exitFull":"fullscreen"),children:c?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:s,"aria-label":t("close"),children:"\u2715"})]}),b&&b.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:[b.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:b.since?et(new Date(b.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${Z?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>p(u=>!u),"aria-label":t(Z?"collapse":"expand"),title:t(Z?"collapse":"expand"),children:Z?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Se,children:[j==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ze,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Ze,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Ze,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Ze,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Ze,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Ze,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),j==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:S,onChange:u=>te(u.target.value)}),(0,e.jsx)("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:at}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>J.current&&J.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>X({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("md"),children:t(G?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("json"),children:t(G?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),j==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[yt.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${v===u?" active":""}`,onClick:()=>ce(u),children:t(u==="all"?"all":Re[u])},u)),(0,e.jsxs)("select",{value:re,onChange:u=>ee(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.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Dt(lt).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsxs)("select",{value:O,onChange:u=>Le(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("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(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${D===u.key?" active":""}`,onClick:()=>U(u.key),children:u.label},u.key))]}),B&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",B]}),(0,e.jsx)("div",{style:{display:j==="cards"?"contents":"none"},children:L?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):B?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",B," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("retry")})]}):x.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:it.map(u=>(0,e.jsx)(sa,{card:u,t,query:S.trim(),onOpen:ke,onDelete:A},u.path))}),x.length<He&&(0,e.jsx)("div",{ref:Ke,style:{height:1}}),je&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",x.length," / ",He,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:j==="graph"?"flex":"none",flex:1,minHeight:0},children:w.has("graph")&&(0,e.jsx)(ma,{t,onOpen:ke,all:Me,onAllChange:de,onMutate:Ae,active:j==="graph",visible:j==="graph"})}),(0,e.jsx)("div",{style:{display:j==="config"?"contents":"none"},children:w.has("config")&&(0,e.jsx)(Ft,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:j==="stats"?"contents":"none"},children:w.has("stats")&&(0,e.jsx)(da,{t,tab:"stats",onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:j==="audit"?"contents":"none"},children:w.has("audit")&&(0,e.jsx)(la,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:j==="optimize"?"contents":"none"},children:w.has("optimize")&&(0,e.jsx)(ra,{t,onReload:()=>o(),version:oe})}),Fe&&(0,e.jsx)(pa,{t,card:Fe,query:S.trim(),onClose:()=>We(null),onDelete:u=>{We(null),A(u)},onFeedback:u=>{let E=Fe.path;fetch(`${_}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:S.trim(),path:E,useful:u})}).then(()=>P({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>P(null),2e3)}}),(0,e.jsx)(ca,{t,newCard:Y,setNewCard:X,onCreated:()=>{o(),Ae(),P({ok:!0,msg:t("created")}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>P(null),2e3)}})]})]})]})}var Ze=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]});function Ft({t,onReload:l,version:s,compact:f}){let[c,i]=(0,n.useState)(null),[k,x]=(0,n.useState)(0),[N,L]=(0,n.useState)(null),[C,b]=(0,n.useState)(null),[y,B]=(0,n.useState)(!1),[z,v]=(0,n.useState)(null),[I,S]=(0,n.useState)(null),[$,re]=(0,n.useState)(""),[ee,O]=(0,n.useState)(""),[Le,j]=(0,n.useState)(""),[be,w]=(0,n.useState)(""),[ie,g]=(0,n.useState)(null),D=(0,n.useRef)(null),U=(p,Y=!0)=>{D.current&&clearTimeout(D.current),g({msg:p,ok:Y}),D.current=setTimeout(()=>g(null),1900)},V=(p,Y)=>Object.keys(Y).reduce((X,oe)=>X.split("{"+oe+"}").join(Y[oe]),t(p)),P=(0,n.useCallback)(async()=>{try{let[p,Y,X]=await Promise.all([fetch(`${_}/config`).then(oe=>oe.json()).catch(()=>null),fetch(`${_}/setup-status`).then(oe=>oe.json()).catch(()=>null),fetch(`${_}/budget`).then(oe=>oe.json()).catch(()=>null)]);p&&p.ok?(i(p),x(p.revision??0),L(p.schema??null),b({...p.config??{}}),v(p.dsh??null),B(p.writable===!1),re("")):X&&X.ok?(b({...X}),B(!0),re(t("configNeedsDsh"))):re(t("adminLoadFail")),Y&&Y.ok&&S(Y),j("")}catch{re(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{P()},[s,P]);let H=(p,Y)=>b(X=>({...X??{},[p]:Y})),J=p=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[p]||p,G=async()=>{if(C){if(y){U(t("editInSetting"),!1);return}O("save");try{let p=await fetch(`${_}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:C,expectedRevision:k})}),Y=await p.json();if(Y&&Y.ok)j(t("savedOk")+(Y.note?` \xB7 ${t("restartHint")}`:"")),U(t("savedOk")),await P();else{let X=p.status===409?t("conflictRefresh"):Y?.error||t("saveFail");re(X),U(X,!1)}}catch{re(t("saveFail")),U(t("saveFail"),!1)}finally{O("")}}},ye=()=>{b({...c?.config??{}}),j("")},Fe={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,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}},We=async p=>{let Y=Fe[p];Y&&b(X=>({...X??{},...Y}))},Me=async(p,Y)=>{O(p+Y);try{let oe=await(await fetch(`${_}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:p,action:Y})})).json();oe&&oe.ok?U(V(Y==="install"?"mcpInstalled":"mcpUninstalled",{agent:p})):U(V("mcpActionFail",{agent:p,error:oe?.error||""}),!1);try{let Ne=await fetch(`${_}/setup-status`).then(Ae=>Ae.json());Ne&&Ne.ok&&S(Ne)}catch{}}catch{U(t("mergeFail"),!1)}finally{O("")}},de=({k:p,label:Y,type:X="text",step:oe,min:Ne,max:Ae})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:Y||p}),(0,e.jsx)("input",{type:X,step:oe,min:Ne,max:Ae,value:C?C[p]??"":"",onChange:ze=>H(p,X==="number"?Number(ze.target.value):ze.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}})]}),Z=({k:p,label:Y})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(C&&C[p]),onChange:X=>H(p,X.target.checked)}),(0,e.jsx)("span",{children:Y||p})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:f?"0 0 auto":1,minHeight:0,maxHeight:f?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ie}),ie&&(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 "+(ie.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ie.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ie.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ie.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[$&&(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 ",$]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:P,children:["\u21BB ",t("retry")]})]}),y&&(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")]}),Le&&(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 ",Le]}),c&&(c.version||c.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,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")}),c.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",c.version]}),c.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",c.dsh.vaultDir]})]}),I&&I.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:I.agents.map(p=>(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:p.isDsh?t("dshHostLabel"):p.name}),p.isDsh&&p.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",p.version]}),!p.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),p.installed&&p.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),p.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),p.mcpConfigured===!0&&p.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),p.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",p.recallTool?t("enabled"):t("disabled"),")"]})]}),p.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",p.hook]}),!p.isDsh&&p.installed&&p.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ee,onClick:()=>Me(p.name,"install"),children:t("installMcp")}),!p.isDsh&&p.installed&&p.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ee,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Me(p.name,"uninstall")},children:t("uninstallMcp")})]},p.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),be&&(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:be})})]}),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(p=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>We(p),disabled:!!ee,children:[p==="A"?"\u{1F7E2} ":p==="B"?"\u{1F4B0} ":"\u2B50 ",Fe[p].label]},p))})]}),(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(150px, 1fr))",gap:8},children:[(0,e.jsx)(Z,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Z,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(de,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(de,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(de,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(de,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(de,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Z,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(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(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(Z,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Z,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(de,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(de,{k:"recallMinScore",label:t("recallMinScore"),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(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:C.auditMode??"all",onChange:p=>H("auditMode",p.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)(Lt,{label:t("auditExemptAgents"),value:C.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(I?.agents||[]).filter(p=>!p.isDsh).map(p=>({value:p.name,label:p.name}))],onChange:p=>H("auditExemptAgents",p)}),(0,e.jsx)(Lt,{label:t("auditExemptKinds"),value:C.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...yt.filter(p=>p!=="all").map(p=>({value:p,label:t(Re[p])}))],onChange:p=>H("auditExemptKinds",p)}),(0,e.jsx)(de,{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(150px, 1fr))",gap:8},children:[(0,e.jsx)(Z,{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:p=>H("autoWebMode",p.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)(de,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(de,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(de,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Z,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Z,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:ye,disabled:!!ee,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:G,disabled:!!ee||ee==="save"||y,children:ee==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function la({t,onReload:l,version:s}){let[f,c]=(0,n.useState)([]),[i,k]=(0,n.useState)([]),[x,N]=(0,n.useState)("all"),[L,C]=(0,n.useState)("all"),[b,y]=(0,n.useState)(""),[B,z]=(0,n.useState)(new Set),[v,I]=(0,n.useState)(""),[S,$]=(0,n.useState)("pending"),re=[...new Set([...f,...i].map(w=>w.submittedBy).filter(Boolean))],ee=(0,n.useCallback)(async()=>{try{let w=await fetch(`${_}/audit/list`).then(ie=>ie.json());w.ok&&(c(w.pending||[]),k(w.rejected||[]),z(new Set))}catch{}},[]);(0,n.useEffect)(()=>{ee()},[s,ee]);let O=(S==="pending"?f:i).filter(w=>{if(x!=="all"&&w.kind!==x||L!=="all"&&tt(w.submittedBy)!==L)return!1;if(b){let ie=(w.created||"").slice(0,10);if(ie&&ie!==b)return!1}return!0}),Le=w=>z(ie=>{let g=new Set(ie);return g.has(w)?g.delete(w):g.add(w),g}),j=async(w,ie)=>{I("apply");try{for(let g of ie||[...B])await fetch(`${_}/${w==="approved"?"audit/approve":w==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${w==="delete"?"&permanent=0":""}`);await ee(),l&&l()}catch{}finally{I("")}},be=[...B];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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(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:x,onChange:w=>N(w.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")}),yt.filter(w=>w!=="all").map(w=>(0,e.jsx)("option",{value:w,children:t(Re[w])},w))]}),(0,e.jsxs)("select",{value:L,onChange:w=>C(w.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")}),Dt(re).map(w=>(0,e.jsx)("option",{value:w,children:w},w))]}),(0,e.jsx)("input",{type:"date",value:b,onChange:w=>y(w.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${S==="pending"?" me-on":""}`,onClick:()=>$("pending"),children:[t("pending"),"\uFF08",f.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${S==="rejected"?" me-on":""}`,onClick:()=>$("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:O.length>0&&be.length===O.length,onChange:w=>{w.target.checked?z(new Set(O.map(ie=>ie.path))):z(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!be.length||!!v,onClick:()=>j("approved"),children:["\u2713 ",t(S==="rejected"?"restore":"approve")]}),S==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!v,onClick:()=>j("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!v,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&j("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),O.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:O.map(w=>(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)("input",{type:"checkbox",checked:B.has(w.path),onChange:()=>Le(w.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:$e[w.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:tt(w.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:w.created?w.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:w.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:w.severity==="high"?"#f87171":"#9ca3af"},children:w.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.reason||"-"}),S==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>j("approved",[w.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>j("rejected",[w.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:()=>j("approved",[w.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"))&&j("delete",[w.path])},children:"\u{1F5D1}"})]})]},w.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function ra({t,onReload:l,version:s}){let[f,c]=(0,n.useState)([]),[i,k]=(0,n.useState)(""),x=(0,n.useCallback)(async()=>{try{let L=await fetch(`${_}/recycle/list`).then(C=>C.json());L.ok&&c(L.items||[])}catch{}},[]);(0,n.useEffect)(()=>{x()},[s,x]);let N=async(L,C)=>{k(L+C);try{L==="restore"?await fetch(`${_}/recycle/restore?path=${encodeURIComponent(C)}`):L==="purge"&&await fetch(`${_}/recycle/purge?path=${encodeURIComponent(C)}`),await x(),l&&l()}catch{}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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(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,onClick:async()=>{k("purgeAll");try{await fetch(`${_}/recycle/purge-expired?days=0`),await x()}catch{}finally{k("")}},children:t("emptyRecycle")})]}),f.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:f.map(L=>(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:$e[L.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(L.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>N("restore",L.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"))&&N("purge",L.path)},children:t("purge")})]},L.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var sa=({card:t,t:l,onOpen:s,query:f,onDelete:c})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>s(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:$e[t.kind]||$e.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:pt[t.kind]||"\u{1F4CE}"}),f?Bt(t.title,f):t.title,ba(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",l("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",l("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",l("statusApproved")]})]}),(0,e.jsx)("p",{children:f?Bt(t.summary||"",f):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:[pt[t.kind]||"\u{1F4CE}"," ",l(Re[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",tt(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",et(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&c&&c(t.path)},children:"\u{1F5D1}"})]})]});function da({t,tab:l,onReload:s,version:f}){let[c,i]=(0,n.useState)(null),[k,x]=(0,n.useState)(""),[N,L]=(0,n.useState)(null),[C,b]=(0,n.useState)(null),[y,B]=(0,n.useState)(null),[z,v]=(0,n.useState)([]),[I,S]=(0,n.useState)(""),[$,re]=(0,n.useState)(!1),ee=(0,n.useCallback)(async()=>{if(!(!N||!N.merge||!N.merge.length)&&window.confirm(t("mergeAllConfirm"))){S("merge");try{let g={},D=J=>g[J]===void 0?J:g[J]=D(g[J]),U=(J,G)=>{g[D(J)]=D(G)},V=new Set;for(let J of N.merge)V.add(J.a.path),V.add(J.b.path),U(J.a.path,J.b.path);let P={};for(let J of V){let G=D(J);(P[G]=P[G]||[]).push(J)}let H=0;for(let J of Object.values(P)){if(J.length<2)continue;(await fetch(`${_}/merge?paths=${encodeURIComponent(J.join(","))}`).then(ye=>ye.json())).ok&&H++}await O(),s&&s()}catch{}S("")}},[N,O,s,t]);async function O(){try{let g=await Promise.all([fetch(`${_}/stats`),fetch(`${_}/budget`),fetch(`${_}/capture-log`),fetch(`${_}/cards?status=all&limit=30&agent=${ot}`)]),[D,U,V,P]=await Promise.all(g.map(H=>H.json()));D&&D.ok&&i(D),U&&U.ok&&b(U),V&&V.ok&&B(V),P&&P.ok&&v(P.cards||[]),x(!D||!D.ok?t("adminLoadFail"):"")}catch{x(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{S("scan");try{let g=await fetch(`${_}/optimize`).then(D=>D.json());g.ok&&L(g)}catch{x(t("adminLoadFail"))}finally{S("")}},[t]);(0,n.useEffect)(()=>{O()},[f]);let j=async(g,D)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${_}/merge?paths=${encodeURIComponent(g+","+D)}`).then(V=>V.json())).ok&&(await O(),s&&s())}catch{}},be=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${_}/delete?path=${encodeURIComponent(g)}`).then(U=>U.json())).ok&&(await O(),s&&s())}catch{}},w=["project","knowledge","content","prompt","business","tool","mistake"],ie=({title:g,kind:D,updated:U,path:V})=>(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:Qe.colors[D]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:et(U)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>be(V),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:Ie}),(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:O,children:["\u21BB ",t("retry")]})]}),l==="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:()=>O(),children:["\u21BB ",t("refresh")]})]}),y?y.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(y.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:(y.entries||[]).map((g,D)=>{let U=Qt[g.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:et(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:U[1],fontWeight:600},children:[U[0]," ",g.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:g.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.preview||"",children:g.preview||""})]},D)})})})}):(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",z.length,"\uFF09"]}),z.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.map(g=>(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:$e[g.kind]||$e.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.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:et(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),c&&(0,e.jsxs)(e.Fragment,{children:[c.trend&&c.trend.length>0&&(()=>{let g=c.trend,D=Math.max(...g.map(H=>H.count),1),U=260,V=50,P=U/g.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:U,height:V,style:{display:"block",width:"100%",height:50},children:g.map((H,J)=>{let G=Math.round(H.count/D*(V-4));return(0,e.jsx)("rect",{x:J*P+1,y:V-G,width:Math.max(P-2,2),height:G,rx:1.5,fill:H.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:H.count>0?.85:.35},H.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.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:w.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Qe.colors[g]||"#666"}}),t(Re[g]),": ",c.byKind?.[g]||0]},g))})]}),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",c.todayCards?.length||0,"\uFF09"]}),c.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:c.todayCards.map(g=>(0,e.jsx)(ie,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="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:!!I,onClick:Le,children:I==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),N&&N.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!I,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){S("oneclick");try{let g=JSON.stringify({cleanupStale:$}),U=await(await fetch(`${_}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();U&&U.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${U.plan.merged} ${t("optimizedMerged")}${$?` \xB7 ${U.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await O(),s&&s(),L(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{S("")}}},children:I==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),N&&N.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:g=>re(g.target.checked)}),t("oneClickAlsoStale")]})]}),!N&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),N&&(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}}),N.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!I,onClick:ee,children:t(I==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),N.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:N.merge.map((g,D)=>(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:[g.a.title," \u21C4 ",g.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(g.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>j(g.a.path,g.b.path),children:t("mergeNow")})]},D))}):(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",N.stale?.length||0,"\uFF09"]}),N.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!I,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;S("clean");let g=0;for(let D of N.stale)try{await fetch(`${_}/delete?path=${encodeURIComponent(D.path)}`),g++}catch{}S(""),notify(`${g} ${t("deletedStale")}`),await O(),s&&s()},children:t("cleanStale")})}),N.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:N.stale.map(g=>(0,e.jsx)(ie,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var bt=[{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 ca({t,newCard:l,setNewCard:s,onCreated:f}){if(!l)return null;let c=bt.find(b=>b.key===l.template),i=l.body||(c?t(c.bodyKey):""),k=l.kind||(c?c.kind:"knowledge"),x=l.tags||(c?t(c.tagKey):""),N=l._creating,L=b=>{let y=bt.find(B=>B.key===b);s(B=>({...B,template:b,kind:y?y.kind:B.kind,body:y?t(y.bodyKey):B.body,tags:y?t(y.tagKey):B.tags}))},C=async()=>{if(!(!l.title&&!i)){s(b=>({...b,_creating:!0}));try{(await fetch(`${_}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:k,tags:x.split(",").map(y=>y.trim()).filter(Boolean),body:i,source:"manual"})}).then(y=>y.json())).ok?(s(null),f&&f()):s(y=>({...y,_creating:!1}))}catch{s(y=>({...y,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>s(null),children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:b=>b.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:()=>s(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:[bt.map(b=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===b.key?" me-on":""}`,onClick:()=>L(b.key),children:t(b.label)},b.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>s(b=>({...b,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:k,onChange:b=>s(y=>({...y,kind:b.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(b=>(0,e.jsx)("option",{value:b,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:b},b))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:b=>s(y=>({...y,title:b.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:x,onChange:b=>s(y=>({...y,tags:b.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:b=>s(y=>({...y,body:b.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:N,onClick:C,children:t(N?"exporting":"createCard")})})]})]})]})}function pa({t,card:l,query:s,onClose:f,onDelete:c,onFeedback:i}){(0,n.useEffect)(()=>{let I=S=>{S.key==="Escape"&&f()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[f]);let{meta:k,body:x}=(0,n.useMemo)(()=>ft(l.text||""),[l.text]),N=I=>{let S=k.find(([$])=>String($).toLowerCase()===I);return S?S[1]:""},L=zt(N("tags")),C=N("kind")||"knowledge",b=(N("status")||"approved").toLowerCase(),y=$e[C]||"#6B7280",B=(x||"").length>460,[z,v]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:f,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",onClick:I=>I.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:[(0,e.jsx)("span",{style:{marginRight:6},children:pt[C]||"\u{1F4CE}"}),l.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[s&&(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")]})]}),B&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":z,onClick:()=>v(I=>!I),children:t(z?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&c&&c(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:f,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:y,borderColor:y+"59",background:y+"1a"},children:[pt[C]||"\u{1F4CE}"," ",t(Re[C]||"kindKnowledge")]}),(0,e.jsxs)("span",{className:"md-chip "+(b==="approved"?"md-chip-st-ok":b==="pending"?"md-chip-st-warn":"md-chip-st-bad"),children:[b==="approved"?"\u2705":b==="pending"?"\u23F3":"\u26D4"," ",t(b==="approved"?"statusApproved":b==="pending"?"statusPending":"statusRejected")]}),L.slice(0,8).map(I=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",I]},I)),!!N("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",et(N("updated"))]}),!!N("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",N("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:z?{}:{maxHeight:300,overflow:"hidden"},onClick:z?void 0:I=>{I.stopPropagation(),v(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:It(x)}})}),!z&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:I=>{I.stopPropagation(),v(!0)},children:[t("expand")," \u2304"]})]})]})}function ma({t,onOpen:l,all:s,onAllChange:f,onMutate:c,active:i,visible:k}){let[x,N]=(0,n.useState)(null),[L,C]=(0,n.useState)(""),b=(0,n.useRef)(!1),y=(0,n.useRef)(0),B=(0,n.useRef)(t);B.current=t;let z=(0,n.useCallback)(async()=>{try{b.current=!1;let $=await(await fetch(`${_}/graph${s?"?all=1":""}`)).json();$.ok?(N($),C(""),b.current=!0):(N(null),C($.error||t("error")))}catch(S){C(String(S&&S.message?S.message:S))}},[s,t]);(0,n.useEffect)(()=>{if(!i||b.current)return;let S=!0;return fetch(`${_}/graph${s?"?all=1":""}`).then($=>$.json()).then($=>{S&&($.ok?(N($),C(""),b.current=!0):(N(null),C($.error||t("error"))))}).catch($=>{S&&C(String($&&$.message?$.message:$))}),()=>{S=!1}},[s,t,i]),(0,n.useEffect)(()=>{k&&x&&y.current++},[k,x]);let v=(0,n.useCallback)(async S=>{try{let re=await(await fetch(`${_}/delete?path=${encodeURIComponent(S)}`)).json();return re&&re.ok?(await z(),c&&c(),!0):!1}catch{return!1}},[z]),I=(0,n.useCallback)(async S=>{if(!S||S.length<2)return!1;try{let $=await fetch(`${_}/merge?paths=${encodeURIComponent(S.join(","))}`).then(re=>re.json());return $&&$.ok?(await z(),c&&c(),!0):!1}catch{return!1}},[z,c]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ie}),L&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",L]}),!x&&!L&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),x&&x.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),x&&x.nodes.length>0&&(0,e.jsx)(ga,{nodes:x.nodes,edges:x.edges,onOpen:l,onDelete:v,onMerge:I,t,all:s,onAllChange:f,countLabel:`${x.nodes.length} ${t("nodes")} \xB7 ${ua(x.edges)} ${t("edges")}`,fitTrigger:y.current})]})}function ua(t){let l=new Set;for(let s of t||[])l.add([s.source,s.target].sort().join("|"));return l.size}var Qe={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 ga({nodes:t,edges:l,onOpen:s,onDelete:f,onMerge:c,t:i,countLabel:k,all:x,onAllChange:N,fitTrigger:L}){let C=(0,n.useRef)(null),b=(0,n.useRef)(null),y=(0,n.useRef)(null),B=(0,n.useRef)(null),z=(0,n.useRef)(null),v=(0,n.useRef)(s);(0,n.useEffect)(()=>{v.current=s},[s]);let I=(0,n.useRef)(f);(0,n.useEffect)(()=>{I.current=f},[f]);let S=(0,n.useRef)(c);(0,n.useEffect)(()=>{S.current=c},[c]);let[$,re]=(0,n.useState)(""),[ee,O]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=$.trim().toLowerCase()},[$]),(0,n.useEffect)(()=>{let r=y.current;if(!r)return;let o=$.trim().toLowerCase();if(!o)return;let A=r.nodes.find(te=>(te.name||"").toLowerCase().includes(o));A&&(y.current.selectedId=A.id,O(A.id),r.panX=r.w/2-A.x*r.zoom,r.panY=r.h/2-A.y*r.zoom,r.render&&r.render())},[$]);let[j,be]=(0,n.useState)("all"),[w,ie]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[D,U]=(0,n.useState)(""),V=(0,n.useRef)(""),[P,H]=(0,n.useState)(!1),J=(0,n.useRef)(!1),[G,ye]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=j},[j]),(0,n.useEffect)(()=>{V.current=D},[D]),(0,n.useEffect)(()=>{J.current=P},[P]);let Fe=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let A of o.tags||[]){let te=String(A).trim();te&&r.set(te,(r.get(te)||0)+1)}return[...r.entries()].sort((o,A)=>A[1]-o[1]).slice(0,24).map(([o,A])=>({tag:o,n:A}))},[t]),We=(()=>{let r=$.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(Re[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[$]),(0,n.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[j,D,P]);let Me=(0,n.useRef)(null),[de,Z]=(0,n.useState)([]),[p,Y]=(0,n.useState)(null),[X,oe]=(0,n.useState)(!1),[Ne,Ae]=(0,n.useState)(null),[ze,He]=(0,n.useState)(""),_e=(0,n.useRef)(null),je=(0,n.useRef)(null),le=(r,o=!0)=>{_e.current&&clearTimeout(_e.current),Ae({msg:r,ok:o}),_e.current=setTimeout(()=>Ae(null),1900)},Ke=r=>{He(r),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>He(""),1600)};(0,n.useEffect)(()=>()=>{_e.current&&clearTimeout(_e.current),je.current&&clearTimeout(je.current)},[]);let Se=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=C.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let A=Math.max(1,window.devicePixelRatio||1),te=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(d=>{ce[d.source]=(ce[d.source]||0)+1,ce[d.target]=(ce[d.target]||0)+1});let ke=Math.max(1,...Object.values(ce)),a={nodes:t.map(d=>({id:d.id,name:d.title||"",type:d.kind||"other",r:9+Math.min(10,(ce[d.id]||0)/ke*8),x:0,y:0,vx:0,vy:0})),edges:l.map(d=>({sourceNodeId:d.source,targetNodeId:d.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:A,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((d,M)=>(d[M.id]=M,d),{}),a.nodes.forEach((d,M)=>{let h=M/a.nodes.length*Math.PI*2-Math.PI/2;d.x=Math.cos(h)*60,d.y=Math.sin(h)*60});let at=[...new Set(a.nodes.map(d=>d.type))];a.clustered=at.length>1,a.typeCenters={},at.forEach((d,M)=>{let h=M/at.length*Math.PI*2-Math.PI/2;a.typeCenters[d]={x:Math.cos(h)*160,y:Math.sin(h)*160}}),y.current=a;let it=0,lt=0,u=()=>{let d=r.clientWidth,M=r.clientHeight;a.w=d,a.h=M,r.width=d*A,r.height=M*A,o.setTransform(A,0,0,A,0,0),(it===0||lt===0)&&d>0&&M>0&&a.tickCount>0&&requestAnimationFrame(()=>pe()),it=d,lt=M};u();let E=new ResizeObserver(u);E.observe(r.parentElement);let K=(d,M)=>d&&d.length>M?d.slice(0,M)+"\u2026":d,ue=(d,M,h,T)=>{if(o.beginPath(),T==="rect")o.rect(d-h,M-h*.75,h*2,h*1.5);else if(T==="diamond")o.moveTo(d,M-h),o.lineTo(d+h,M),o.lineTo(d,M+h),o.lineTo(d-h,M),o.closePath();else if(T==="hexagon"){for(let R=0;R<6;R++){let Q=Math.PI/3*R-Math.PI/2,q=d+h*Math.cos(Q),he=M+h*Math.sin(Q);R===0?o.moveTo(q,he):o.lineTo(q,he)}o.closePath()}else o.arc(d,M,h,0,Math.PI*2)},pe=()=>{if(!a.nodes.length)return;let d=1/0,M=-1/0,h=1/0,T=-1/0;a.nodes.forEach(m=>{d=Math.min(d,m.x),M=Math.max(M,m.x),h=Math.min(h,m.y),T=Math.max(T,m.y)});let R=20,Q=M-d+R*2,q=T-h+R*2,he=Math.min(a.w/Q,a.h/q);a.zoom=Math.max(.35,Math.min(1.8,he)),a.panX=a.w/2-(d+M)/2*a.zoom,a.panY=a.h/2-(h+T)/2*a.zoom};B.current=pe;let me=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=g.current,a.timeMode=J.current,a.tagFilter=V.current;let d=a.tagFilter,M=a.kindFilter,h=m=>String(m||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=te()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let m=0;m<a.w;m+=24)o.beginPath(),o.moveTo(m,0),o.lineTo(m,a.h),o.stroke();for(let m=0;m<a.h;m+=24)o.beginPath(),o.moveTo(0,m),o.lineTo(a.w,m),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let T={};a.nodes.forEach(m=>T[m.id]=m);let R=a.nodes.length>40,Q=R?1.5:.55,q=a.selectedId||a.hoverId;a.edges.forEach(m=>{let ae=T[m.sourceNodeId],F=T[m.targetNodeId];if(!ae||!F)return;if(M!=="all"){let st=a.domainById[m.sourceNodeId]&&a.domainById[m.sourceNodeId].kind,we=a.domainById[m.targetNodeId]&&a.domainById[m.targetNodeId].kind;if(st!==M&&we!==M)return}if(d){let st=a.domainById[m.sourceNodeId]&&(a.domainById[m.sourceNodeId].tags||[]).includes(d),we=a.domainById[m.targetNodeId]&&(a.domainById[m.targetNodeId].tags||[]).includes(d);if(!st&&!we)return}let W=F.x-ae.x,ne=F.y-ae.y,se=Math.sqrt(W*W+ne*ne)||1,fe=R?12:18,xe=-ne/se*fe,ve=W/se*fe,Be=(ae.x+F.x)/2+xe,Te=(ae.y+F.y)/2+ve,De=Qe.colors[a.domainById[ae.id]&&a.domainById[ae.id].kind||"other"],Ue=q&&(m.sourceNodeId===q||m.targetNodeId===q),mt=q?Ue?.6:.08:R?.14:.24,ut=parseInt(De.slice(1,3),16),nt=parseInt(De.slice(3,5),16),rt=parseInt(De.slice(5,7),16);o.strokeStyle="rgba("+ut+","+nt+","+rt+","+mt+")",o.lineWidth=Ue?1.6+(m.weight||1):.8+(m.weight||1)*.5,o.beginPath(),o.moveTo(ae.x,ae.y),o.quadraticCurveTo(Be,Te,F.x,F.y),o.stroke()});let he=[];if(a.nodes.forEach(m=>{let ae=a.domainById[m.id]||{},F=ae.kind||"other",W=a.timeMode?fa(ae.updated):Qe.colors[F],ne=Qe.shapes[F],se=a.selectedId===m.id,fe=a.hoverId===m.id,xe=a.searchTerm||"",ve=!xe||(m.name||"").toLowerCase().includes(xe)||String(Re[F]||"").toLowerCase().includes(xe)||String(F).toLowerCase().includes(xe),Be=M==="all"||F===M,Te=!d||(ae.tags||[]).includes(d),De=q&&m.id!==q&&!a.edges.some(we=>we.sourceNodeId===q&&we.targetNodeId===m.id||we.targetNodeId===q&&we.sourceNodeId===m.id)||xe&&!ve||!Be||!Te;o.save(),o.globalAlpha=De?.08:1,(se||fe)&&(o.shadowColor=W,o.shadowBlur=se?20:14),ue(m.x,m.y,m.r,ne);let Ue=parseInt(W.slice(1,3),16),mt=parseInt(W.slice(3,5),16),ut=parseInt(W.slice(5,7),16),nt=o.createRadialGradient(m.x-m.r*.3,m.y-m.r*.3,0,m.x,m.y,m.r*1.2);nt.addColorStop(0,"rgba("+Math.min(255,Ue+70)+","+Math.min(255,mt+70)+","+Math.min(255,ut+70)+",0.95)"),nt.addColorStop(1,W),o.fillStyle=nt,o.fill(),o.restore(),se?(o.save(),ue(m.x,m.y,m.r+3,ne),o.strokeStyle=W,o.lineWidth=3,o.shadowColor=W,o.shadowBlur=12,o.stroke(),o.restore()):fe?(o.save(),ue(m.x,m.y,m.r+2,ne),o.strokeStyle=W,o.lineWidth=2,o.stroke(),o.restore()):xe&&ve?(o.save(),ue(m.x,m.y,m.r+2,ne),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(m.id)>=0&&(o.save(),ue(m.x,m.y,m.r+2,ne),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let rt=K(m.name,16);if((se||fe||a.zoom>Q||!R&&a.zoom>.6)&&Be&&Te){let we=1/a.zoom;o.font="500 "+(12*we).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Oe=o.measureText(rt).width+16*we,dt=18*we,Xe=m.y+m.r+8*we,Mt=!0;for(let Ve of he)if(m.x-Oe/2<Ve.x+Ve.w&&m.x+Oe/2>Ve.x&&Xe<Ve.y+Ve.h&&Xe+dt>Ve.y){Mt=!1;break}if(!Mt&&!se&&!fe)return;he.push({x:m.x-Oe/2,y:Xe,w:Oe,h:dt}),o.fillStyle=te()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(m.x-Oe/2,Xe,Oe,dt,4*we):o.rect(m.x-Oe/2,Xe,Oe,dt),o.fill(),o.strokeStyle=te()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*we,o.stroke(),o.fillStyle=te()?se||fe?"#eee":"#bbb":se||fe?"#111":"#444",o.textAlign="center",o.fillText(rt,m.x,Xe+13*we)}}),o.restore(),a.marquee){let m=a.marquee,ae=Math.min(m.sx,m.ex),F=Math.min(m.sy,m.ey),W=Math.abs(m.ex-m.sx),ne=Math.abs(m.ey-m.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(ae,F,W,ne),o.strokeRect(ae,F,W,ne),o.restore()}if(a.hoverId&&Me.current){let m=a.domainById[a.hoverId],ae=a.nodes.find(function(F){return F.id===a.hoverId});if(m&&ae){let F=a.edges.filter(function(se){return se.sourceNodeId===m.id||se.targetNodeId===m.id}).length,W=ae.x*a.zoom+a.panX,ne=ae.y*a.zoom+a.panY;Me.current.style.display="block",Me.current.style.left=W+14+"px",Me.current.style.top=ne-6+"px",Me.current.innerHTML="<b>"+h(m.title||m.name||"")+'</b><br/><span style="opacity:.8">'+h(m.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",F)+"</span>"}}else Me.current&&(Me.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Ee))};a.wake=ge,a.render=me;let Pe=()=>{let d=a.nodes.length;a.tickCount++;let h=.9-Math.min(.4,a.tickCount/1500),T=d>1e3?3e3:d>100?2e3:d>50?1200:800,R=d>100?.002:.005,Q=d>1e3?.012:d>100?.005:.01,q=d>1e3?6:d>200?12:24,he={};a.nodes.forEach(F=>he[F.id]=F);for(let F=0;F<d;F++){if(a.dragNode===a.nodes[F])continue;let W=a.nodes[F],ne=0,se=0;for(let ve=0;ve<d;ve++){if(F===ve)continue;let Be=W.x-a.nodes[ve].x,Te=W.y-a.nodes[ve].y,De=Math.sqrt(Be*Be+Te*Te)||1,Ue=T/(De*De);ne+=Be/De*Ue,se+=Te/De*Ue}if(a.clustered&&a.typeCenters[W.type]){let ve=a.typeCenters[W.type];ne+=(ve.x-W.x)*.006,se+=(ve.y-W.y)*.006}else ne-=W.x*Q,se-=W.y*Q;let fe=(W.vx+ne)*h,xe=(W.vy+se)*h;fe=Math.max(-q,Math.min(q,fe)),xe=Math.max(-q,Math.min(q,xe)),W.vx=fe,W.vy=xe}a.edges.forEach(F=>{let W=he[F.sourceNodeId],ne=he[F.targetNodeId];if(!W||!ne)return;let se=ne.x-W.x,fe=ne.y-W.y,xe=Math.sqrt(se*se+fe*fe)||1,ve=(xe-100)*R,Be=se/xe*ve,Te=fe/xe*ve;a.dragNode!==W&&(W.vx+=Be,W.vy+=Te),a.dragNode!==ne&&(ne.vx-=Be,ne.vy-=Te)});let m=0;a.nodes.forEach(F=>{a.dragNode!==F&&(F.x+=F.vx,F.y+=F.vy,m+=F.vx*F.vx+F.vy*F.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,pe()),(d?Math.sqrt(m/d):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Ee=()=>{if(a.running){try{Pe(),me()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Ee)}},Ce=(d,M)=>{let h=r.getBoundingClientRect();return{x:(d-h.left-a.panX)/a.zoom,y:(M-h.top-a.panY)/a.zoom}},Ye=d=>{let M=a.domainById[d];return!(!M||g.current!=="all"&&M.kind!==g.current||V.current&&!(M.tags||[]).includes(V.current))},qe=(d,M,h)=>Math.max(M,Math.min(h,d)),ht=d=>{a.mouseX=d.clientX,a.mouseY=d.clientY;let M=Ce(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let Q=R.x-M.x,q=R.y-M.y;if(Q*Q+q*q<R.r*R.r+36){h=R.id;break}}h!==a.hoverId&&(a.hoverId=h,ge())},xt=d=>{if(d.button!==0)return;let M=Ce(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let Q=R.x-M.x,q=R.y-M.y;if(Q*Q+q*q<R.r*R.r+25){h=R;break}}if(d.shiftKey){if(h){a.shiftClick=h.id;return}a.marquee={sx:d.clientX,sy:d.clientY,ex:d.clientX,ey:d.clientY};return}a.dragStart={x:d.clientX,y:d.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=h||null,h&&(a.dragOffset={dx:h.x-M.x,dy:h.y-M.y})},vt=d=>{if(a.marquee){a.marquee.ex=d.clientX,a.marquee.ey=d.clientY,ge();return}if(!a.dragStart)return;let M=d.clientX-a.dragStart.x,h=d.clientY-a.dragStart.y;if(Math.abs(M)+Math.abs(h)>3&&(a.dragging=!0),a.dragNode){let T=Ce(d.clientX,d.clientY);a.dragNode.x=T.x+a.dragOffset.dx,a.dragNode.y=T.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=qe(a.dragStart.px+M,-1e5,1e5),a.panY=qe(a.dragStart.py+h,-1e5,1e5),ge())},wt=d=>{if(a.marquee){let h=a.marquee;a.marquee=null;let T=r.getBoundingClientRect(),R=Math.min(h.sx,h.ex)-T.left,Q=Math.max(h.sx,h.ex)-T.left,q=Math.min(h.sy,h.ey)-T.top,he=Math.max(h.sy,h.ey)-T.top,m=a.nodes.filter(ae=>{let F=ae.x*a.zoom+a.panX,W=ae.y*a.zoom+a.panY;return F>=R&&F<=Q&&W>=q&&W<=he}).map(ae=>ae.id);a.multi=m,Z(m),ge();return}let M=a.dragStart&&!a.dragging;if(a.shiftClick){let h=a.shiftClick;a.shiftClick=null;let T=Array.isArray(a.multi)?a.multi.slice():[];T.includes(h)||T.push(h),a.multi=T,Z(T),ge();return}if(M){let h=Ce(d.clientX,d.clientY),T=null;for(let R=a.nodes.length-1;R>=0;R--){let Q=a.nodes[R];if(!Ye(Q.id))continue;let q=Q.x-h.x,he=Q.y-h.y;if(q*q+he*he<Q.r*Q.r+20){T=Q;break}}T?(a.selectedId=T.id,O(T.id),ge()):(a.selectedId=null,a.hoverId=null,d.shiftKey||(a.multi=[],Z([])),O(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},kt=d=>{d.preventDefault();let M=Ce(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let Q=R.x-M.x,q=R.y-M.y;if(Q*Q+q*q<R.r*R.r+25){h=R;break}}if(h){let T=a.domainById[h.id];T&&ye({x:d.clientX,y:d.clientY,id:h.id,path:T.id,title:T.title})}else ye(null)},Ct=d=>{d.preventDefault();let M=r.getBoundingClientRect(),h=(d.clientX-M.left-a.panX)/a.zoom,T=(d.clientY-M.top-a.panY)/a.zoom,R=Math.max(.3,Math.min(3,a.zoom*(d.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+h*(a.zoom-R),-1e5,1e5),a.panY=qe(a.panY+T*(a.zoom-R),-1e5,1e5),a.zoom=R,ge()};r.addEventListener("mousemove",ht),r.addEventListener("mousedown",xt),window.addEventListener("mousemove",vt),window.addEventListener("mouseup",wt),r.addEventListener("wheel",Ct,{passive:!1}),r.addEventListener("contextmenu",kt),z.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Z([]),pe(),ge()};for(let d=0;d<200;d++)Pe();pe(),ge();let St=()=>ie(!1);return window.addEventListener("mousedown",St),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),E.disconnect(),r.removeEventListener("mousemove",ht),r.removeEventListener("mousedown",xt),window.removeEventListener("mousemove",vt),window.removeEventListener("mouseup",wt),r.removeEventListener("wheel",Ct),r.removeEventListener("contextmenu",kt),window.removeEventListener("mousedown",St)}},[t,l]),(0,n.useEffect)(()=>{L!==void 0&&B.current&&requestAnimationFrame(()=>B.current())},[L]),(0,e.jsxs)("div",{className:"me-graph",ref:b,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:$,onChange:r=>re(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ie(r=>!r),"aria-expanded":w,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",j!=="all"||P||D?"\u25CF":"\u25BE"]}),w&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.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${j==="all"&&!P?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{be("all"),H(!1)},children:i("all")}),Object.keys($e).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${j===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>be(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Qe.colors[r]||$e[r]}}),i(Re[r])]},r)),(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:()=>H(r=>!r),children:["\u23F1 ",i("timeDim")]}),Fe.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:Fe.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${D===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>U(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(j!=="all"||P||D)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{be("all"),H(!1),U("")},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:!!x,onChange:r=>N&&N(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${P?" me-on":""}`,onClick:()=>H(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=C.current;if(r)try{r.toBlob(o=>{o&&Y({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>B.current&&B.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{O(null),be("all"),z.current&&z.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:Me,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)"}}),We&&(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")}),G&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ye(null)}),G&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:G.x,top:G.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{v.current({path:G.path,title:G.title}),ye(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.id&&(y.current.selectedId=G.id,O(G.id)),ye(null);let r=y.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(G.title||"")}catch{}ye(null),le(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],A=G.id;if(A&&!o.includes(A)&&o.push(A),ye(null),o.length<2){le(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let te=S.current&&S.current(o);te&&te.then?te.then(ce=>ce?le(i("merged")):le(i("mergeFail"),!1)).catch(()=>le(i("mergeFail"),!1)):te&&le(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=G.path;ye(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(I.current?await I.current(r):!1)?le(i("deleted")):le(i("deleteFail"),!1)}catch{le(i("deleteFail"),!1)}})()},children:i("delete")})]}),de.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:[de.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=de.map(ke=>Se[ke]).filter(Boolean).map(ke=>ke.title||ke.name).join(`
|
|
293
|
+
`),A=new Blob([o],{type:"text/plain;charset=utf-8"}),te=URL.createObjectURL(A),ce=document.createElement("a");ce.href=te,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(te),1e3),le(de.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(de.length<2){le(i("mergeNeed"),!1);return}let r=de.map(A=>Se[A]?Se[A].id:A);if(!window.confirm(i("mergeConfirm")))return;Z([]);let o=y.current;o&&(o.multi=[]),fetch(`${_}/merge?paths=${encodeURIComponent(r.join(","))}`).then(A=>A.json()).then(A=>{A&&A.ok?le(i("merged")):le(i("mergeFail"),!1)}).catch(()=>le(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 r=de.map(A=>Se[A]?Se[A].id:A);Z([]);let o=y.current;o&&(o.multi=[]),(async()=>{let A=0;for(let te of r)try{(I.current?await I.current(te):!1)&&A++}catch{}le(A+i("deletedSelected"),A>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=y.current;r&&(r.multi=[]),Z([]);let o=y.current;o&&o.render&&o.render()},children:i("clearSelection")})]}),ee&&(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:Se[ee]?Se[ee].title||Se[ee].name:ee}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:Se[ee]?i(Re[Se[ee].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===ee||r.target===ee)||[]).slice(0,8).map((r,o)=>{let A=r.source===ee?r.target:r.source,te=Se[A];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let ke=y.current;ke&&(ke.selectedId=A,ke.hoverId=A,ke.wake&&ke.wake()),O(A)},children:te?(te.title||te.name).slice(0,28):A},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),Ne&&(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 "+(Ne.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Ne.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Ne.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Ne.msg})]}),p&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{p.url&&URL.revokeObjectURL(p.url),Y(null),oe(!1)},children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:X?"100vw":900,width:X?"100vw":"92vw",maxHeight:X?"100%":"90vh",height:X?"100%":void 0,borderRadius:X?0:14},onClick:r=>r.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:p.url,download:"memory-graph.png",onClick:()=>{Ke("download"),le(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(ze==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ke("full"),oe(r=>!r),le(i("fullscreen"))},children:i(ze==="full"?"done":X?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=p.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{Ke("copy"),le(i("copied"))}).catch(()=>{le(i("copyFail"),!1)}):le(i("copyFail"),!1)},children:i(ze==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{p.url&&URL.revokeObjectURL(p.url),Y(null),oe(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:X?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:p.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:X?"calc(100% - 64px)":"70vh",borderRadius:X?0:8,cursor:"zoom-in"},onClick:()=>oe(r=>!r)})})]})]})]})}function fa(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let s=(Date.now()-l)/864e5;return s<3?"#10b981":s<14?"#f59e0b":s<30?"#f97316":"#94a3b8"}function Lt({label:t,value:l=[],options:s,onChange:f,placeholder:c,z:i=20}){let[k,x]=(0,n.useState)(!1),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!k)return;let v=I=>{N.current&&!N.current.contains(I.target)&&x(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[k]);let L=Array.isArray(l)?l:[],C=L.includes("__all__"),b=C?s.find(v=>v.value==="__all__")?.label||"":L.length?L.map(v=>s.find(I=>I.value===v)?.label||v).join("\u3001"):"",y=(v,I)=>{if(v.value==="__all__"){f(I?["__all__"]:[]);return}let S=new Set(L);S.has("__all__")&&S.delete("__all__"),I?S.add(v.value):S.delete(v.value),f([...S])},B=s.find(v=>v.value==="__all__"),z=s.filter(v=>v.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t}),(0,e.jsxs)("div",{ref:N,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>x(v=>!v),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:b||c||"\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:[B&&(0,e.jsxs)("label",{onClick:v=>v.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:v=>y(B,v.target.checked)}),(0,e.jsx)("span",{children:B.label})]}),z.map(v=>(0,e.jsxs)("label",{onClick:I=>I.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:L.includes(v.value),onChange:I=>y(v,I.target.checked)}),(0,e.jsx)("span",{children:v.label})]},v.value))]})]})]})}function ba(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function ya(t,l,s){if(s&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),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 f=URL.createObjectURL(t),c=document.createElement("a");return c.href=f,c.download=l,document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(f),1e3),{ok:!0,picked:!1,name:l}}function Bt(t,l){if(!l||!t)return t;let s=t.toLowerCase(),f=l.toLowerCase(),c=[],i=0;for(;i<t.length;){let k=s.indexOf(f,i);if(k<0){c.push(t.slice(i));break}k>i&&c.push(t.slice(i,k)),c.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(k,k+f.length)},k)),i=k+f.length}return c}function et(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let s=new Date,f=l.toDateString()===s.toDateString(),c=k=>String(k).padStart(2,"0"),i=`${c(l.getHours())}:${c(l.getMinutes())}`;return f?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
|
|
228
294
|
|
|
229
295
|
return module.exports;
|
|
230
296
|
},
|