memory-eternal 0.2.0 → 0.3.1
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/index.js +10 -1
- package/lib/client.js +5 -5
- package/lib/db.js +52 -0
- package/lib/vault.js +16 -6
- package/package.json +1 -1
- package/web/app.js +8 -8
package/lib/client.js
CHANGED
|
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var Rt=(t,l)=>{for(var d in l)at(t,d,{get:l[d],enumerable:!0})},ht=(t,l,d,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let g of Tt(l))!Dt.call(t,g)&&g!==d&&at(t,g,{get:()=>l[g],enumerable:!(x=Lt(l,g))||x.enumerable});return t};var At=(t,l,d)=>(d=t!=null?It(Bt(t)):{},ht(l||!t||!t.__esModule?at(d,"default",{value:t,enumerable:!0}):d,t)),jt=t=>ht(at({},"__esModule",{value:!0}),t);var aa={};Rt(aa,{EN:()=>Ct,MemoryLibrary:()=>_t,ZH:()=>kt,apply:()=>Et,inject:()=>Ft});module.exports=jt(aa);var i=At(require("react"),1),e=require("react/jsx-runtime"),We="memory-eternal",j="/memory-eternal/api",Ft=["settingsScope","slots","locale","connection","remote"],kt={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",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",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"},Ct={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",todayBriefLabel:"Daily review",todayBrief:"Today brief",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"},rt=["all","project","knowledge","content","prompt","business","tool","mistake"],Ue={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},De={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},nt="deepseek-harness",Ye=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":nt:d==="deepseek harness"?nt:l.split(":")[0]||nt},$t=[nt,"claude","codex","cursor","codex-desktop"],St=(t=[])=>[...new Set([...$t,...(t||[]).map(Ye)])],Ce=`
|
|
6
|
+
var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var Rt=(t,l)=>{for(var d in l)at(t,d,{get:l[d],enumerable:!0})},ht=(t,l,d,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let g of Tt(l))!Dt.call(t,g)&&g!==d&&at(t,g,{get:()=>l[g],enumerable:!(x=Lt(l,g))||x.enumerable});return t};var At=(t,l,d)=>(d=t!=null?It(Bt(t)):{},ht(l||!t||!t.__esModule?at(d,"default",{value:t,enumerable:!0}):d,t)),jt=t=>ht(at({},"__esModule",{value:!0}),t);var aa={};Rt(aa,{EN:()=>Ct,MemoryLibrary:()=>_t,ZH:()=>kt,apply:()=>Et,inject:()=>Ft});module.exports=jt(aa);var o=At(require("react"),1),e=require("react/jsx-runtime"),We="memory-eternal",F="/memory-eternal/api",Ft=["settingsScope","slots","locale","connection","remote"],kt={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",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",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"},Ct={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",todayBriefLabel:"Daily review",todayBrief:"Today brief",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"},rt=["all","project","knowledge","content","prompt","business","tool","mistake"],Ue={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},De={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},nt="deepseek-harness",Ye=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":nt:d==="deepseek harness"?nt:l.split(":")[0]||nt},$t=[nt,"claude","codex","cursor","codex-desktop"],St=(t=[])=>[...new Set([...$t,...(t||[]).map(Ye)])],Ce=`
|
|
7
7
|
.memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
|
|
8
8
|
.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; }
|
|
9
9
|
.mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
|
|
@@ -129,11 +129,11 @@ var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDe
|
|
|
129
129
|
.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; }
|
|
130
130
|
.me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
|
|
131
131
|
.me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
|
|
132
|
-
`;function Et(t){t.effect(()=>t.locale.register(We,{zh:kt,en:Ct}),"memory-eternal: locale");let l=t.locale.bind(We);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:We,order:25,label:()=>l("nav"),locale:We,inject:()=>({})},()=>
|
|
132
|
+
`;function Et(t){t.effect(()=>t.locale.register(We,{zh:kt,en:Ct}),"memory-eternal: locale");let l=t.locale.bind(We);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:We,order:25,label:()=>l("nav"),locale:We,inject:()=>({})},()=>o.default.createElement(Ot,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${We}:footer`,order:100,label:()=>l("nav"),locale:We,inject:()=>({})},d=>o.default.createElement(Wt,{t:l,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function Pt(){let[t,l]=(0,o.useState)("http://127.0.0.1:7999/");return(0,o.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&l(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function Ot({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsx)(Nt,{t,onReload:()=>{},version:0})]})}function Wt({t,wide:l}){let[d,x]=(0,o.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${l?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>x(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Mt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(Ht,{t,onClose:()=>x(!1)})]})}function Ht({t,onClose:l,tab:d}){let[x,g]=(0,o.useState)(!1),i=Pt(),S=d==="config"?`${F}/ui/config?tab=config`:d?`${i.replace(/\/$/,"")}/?tab=${d}`:i;return(0,o.useEffect)(()=>{let L=T=>{T.key==="Escape"&&l()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[l]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:l,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsx)("div",{className:"me-modal",onClick:L=>L.stopPropagation(),style:x?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},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:()=>g(L=>!L),"aria-label":t(x?"exitFullscreen":"enterFullscreen"),title:t(x?"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:x?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:l,"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",{src:S,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Mt(){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 _t({t,inModal:l,onClose:d,onFull:x,full:g}){let[i,S]=(0,o.useState)(null),[L,T]=(0,o.useState)([]),[k,B]=(0,o.useState)(!0),[y,N]=(0,o.useState)(""),[I,A]=(0,o.useState)("all"),[h,K]=(0,o.useState)(""),[U,Se]=(0,o.useState)("all"),[P,Y]=(0,o.useState)("all"),[$,re]=(0,o.useState)(()=>{try{let c=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),z={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(c&&z[c])return z[c]}catch{}return"cards"}),[te,he]=(0,o.useState)("recent"),[b,u]=(0,o.useState)(null),w=(0,o.useRef)(null),W=(0,o.useRef)(null),[H,Q]=(0,o.useState)(!1),[ee,q]=(0,o.useState)(null),[Z,xe]=(0,o.useState)(!1),[pe,Ke]=(0,o.useState)(!0),[we,ne]=(0,o.useState)(null),[oe,m]=(0,o.useState)(0),E=(0,o.useCallback)(()=>m(c=>c+1),[]),_=(0,o.useRef)(null),[se,be]=(0,o.useState)(100),Ie=(0,o.useRef)(null),Le=(0,o.useRef)(null);(0,o.useEffect)(()=>{if($!=="cards")return;let c=Ie.current,z=Le.current;if(!c)return;let a=new IntersectionObserver(ae=>{ae[0]&&ae[0].isIntersecting&&be(ye=>ye+24)},{root:z||null,rootMargin:"400px"});return a.observe(c),()=>a.disconnect()},[$,L,I,h]);let Ee=(0,o.useCallback)(async(c=I,z=h,a=P)=>{try{B(!0),N("");let ae=new URLSearchParams;c&&c!=="all"&&ae.set("kind",c),z.trim()&&ae.set("q",z.trim()),ae.set("status",a||"all"),ae.set("limit","500");let Te=await(await fetch(`${F}/cards?${ae.toString()}`)).json();Te.ok&&(T(Te.cards||[]),be(100))}catch(ae){N(String(ae&&ae.message?ae.message:ae))}finally{B(!1)}},[I,h,P]),de=(0,o.useCallback)(async()=>{try{let[c,z]=await Promise.all([fetch(`${F}/overview`).then(a=>a.json()),fetch(`${F}/cards?status=all&limit=500`).then(a=>a.json())]);c.ok&&S(c),z.ok&&(T(z.cards||[]),be(100))}catch(c){N(String(c&&c.message?c.message:c))}finally{B(!1)}},[]),Re=async c=>{try{let a=await(await fetch(`${F}/delete?path=${encodeURIComponent(c)}`)).json();a.ok?(u({ok:!0,msg:t("deleted")}),await de()):u({ok:!1,msg:a.error||t("deleteFail")})}catch{u({ok:!1,msg:t("deleteFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)};(0,o.useEffect)(()=>(de(),()=>{_.current&&clearTimeout(_.current)}),[de]);let ie=c=>{K(c),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>Ee(I,c,P),280)},qe=c=>{A(c),Ee(c,h,P)};(0,o.useEffect)(()=>{Ee(I,h,P)},[P]);let ve=async c=>{try{let a=await(await fetch(`${F}/card?path=${encodeURIComponent(c.path||c.id)}`)).json();a.ok&&q({path:a.path,title:c.title,text:a.text})}catch(z){N(String(z&&z.message?z.message:z))}},r=async(c,z)=>{Q(!0);try{let a=await fetch(`${F}/export`);if(!a.ok)throw new Error("HTTP "+a.status);let ae=await a.json();if(!ae.ok)throw new Error(ae.error||"export failed");let ye,Te,Xe;c==="json"?(Te="memory-vault.json",Xe="application/json",ye=JSON.stringify(ae.cards.map(Be=>({path:Be.path,title:Be.title,kind:Be.kind,text:Be.text})),null,2)):(Te="memory-vault.md",Xe="text/markdown;charset=utf-8",ye=ae.cards.map(Be=>Be.text.trim()).filter(Boolean).join(`
|
|
133
133
|
|
|
134
134
|
---
|
|
135
135
|
|
|
136
|
-
`));let je=new Blob([ye],{type:Xe}),Fe=await ea(je,Te,!1);if(!Fe.ok){u({ok:!1,msg:t("exportFail")}),Q(!1);return}u({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(a){u({ok:!1,msg:t("exportFail")+" \xB7 "+(a.message||"")})}finally{Q(!1)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2600)},n=async c=>{let I=c.target.files&&c.target.files[0];if(c.target.value="",!!I){try{let a=await I.text(),ye=await(await fetch(`${j}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:a})).json();ye.ok?(await de(),u({ok:!0,msg:t("importedVault")+"\uFF1A"+(ye.imported||0)+(ye.skipped?t("importedSkipped")+ye.skipped:"")})):u({ok:!1,msg:ye.error||t("importFail")})}catch{u({ok:!1,msg:t("importFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2400)}},N=(0,i.useMemo)(()=>{let c=D.slice();return _!=="all"&&(c=c.filter(I=>Ye(I.submittedBy)===_)),E!=="all"&&(c=c.filter(I=>(I.status||"approved")===E)),te==="title"?c.sort((I,a)=>String(I.title||"").localeCompare(String(a.title||""))):te==="hot"?c.sort((I,a)=>(a.weight||a.links||0)-(I.weight||I.links||0)):c.sort((I,a)=>new Date(a.updated||0).getTime()-new Date(I.updated||0).getTime()),c},[D,te,_,E]),X=(0,i.useMemo)(()=>[...new Set(D.map(c=>Ye(c.submittedBy)))],[D]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ce}),b&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(b.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:b.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:b.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:b.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)(Mt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),x&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:x,"aria-label":t(g?"exitFull":"fullscreen"),children:g?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${pe?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ke(c=>!c),"aria-label":t(pe?"collapse":"expand"),title:t(pe?"collapse":"expand"),children:pe?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="cards"?" active":""}`,onClick:()=>re("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="graph"?" active":""}`,onClick:()=>re("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="stats"?" active":""}`,onClick:()=>re("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="audit"?" active":""}`,onClick:()=>re("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F6E1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="optimize"?" active":""}`,onClick:()=>re("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F5D1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="config"?" active":""}`,onClick:()=>re("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Le,children:[F==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(He,{label:t("total"),value:o?o.total:"\u2014"}),(0,e.jsx)(He,{label:t("recent"),value:o?o.recent:"\u2014"}),(0,e.jsx)(He,{label:t("tags"),value:o?o.tags:"\u2014"}),(0,e.jsx)(He,{label:t("pending"),value:o?.status?.pending??0}),(0,e.jsx)(He,{label:t("rejected"),value:o?.status?.rejected??0}),(0,e.jsx)(He,{label:t("cardCount"),value:o?o.byKind?.knowledge??0:"\u2014"})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:k,onChange:c=>ie(c.target.value)}),(0,e.jsx)("input",{ref:O,type:"file",accept:".json,application/json",style:{display:"none"},onChange:n}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>O.current&&O.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ne({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:W,onClick:()=>r("md"),children:t(W?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:W,onClick:()=>r("json"),children:t(W?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(),children:t("refresh")})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[rt.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${C===c?" active":""}`,onClick:()=>qe(c),children:t(c==="all"?"all":De[c])},c)),(0,e.jsxs)("select",{value:_,onChange:c=>Se(c.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")]}),St(X).map(c=>(0,e.jsx)("option",{value:c,children:c},c))]}),(0,e.jsxs)("select",{value:E,onChange:c=>U(c.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(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${te===c.key?" active":""}`,onClick:()=>he(c.key),children:c.label},c.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),F==="cards"?z&&!D.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):D.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:N.slice(0,se).map(c=>(0,e.jsx)(Kt,{card:c,t,query:k.trim(),onOpen:ve,onDelete:Re},c.path))}),N.length>se&&(0,e.jsx)("div",{ref:Ie,style:{height:1}})]}):F==="graph"?(0,e.jsx)(Vt,{t,onOpen:ve,all:Z,onAllChange:xe,onMutate:$}):F==="config"?(0,e.jsx)(Nt,{t,onReload:()=>de(),version:oe}):F==="stats"?(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}):F==="audit"?(0,e.jsx)(Ut,{t,onReload:()=>de(),version:oe}):F==="optimize"?(0,e.jsx)(Yt,{t,onReload:()=>de(),version:oe}):(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}),ee&&(0,e.jsx)(Xt,{t,card:ee,query:k.trim(),onClose:()=>K(null),onDelete:c=>{K(null),Re(c)},onFeedback:c=>{let I=ee.path;fetch(`${j}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:k.trim(),path:I,useful:c})}).then(()=>u({ok:!0,msg:t(c?"fbUseful":"fbIrr")})).catch(()=>{}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}}),(0,e.jsx)(qt,{t,newCard:we,setNewCard:ne,onCreated:()=>{de(),$(),u({ok:!0,msg:t("created")}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}})]})]})]})}var He=({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 Nt({t,onReload:l,version:d,compact:x}){let[g,o]=(0,i.useState)(null),[B,D]=(0,i.useState)(0),[M,z]=(0,i.useState)(null),[R,y]=(0,i.useState)(null),[h,C]=(0,i.useState)(!1),[J,k]=(0,i.useState)(null),[Y,_]=(0,i.useState)(null),[Se,E]=(0,i.useState)(""),[U,F]=(0,i.useState)(""),[re,te]=(0,i.useState)(""),[he,b]=(0,i.useState)(""),[u,w]=(0,i.useState)(null),O=(0,i.useRef)(null),W=(m,$=!0)=>{O.current&&clearTimeout(O.current),w({msg:m,ok:$}),O.current=setTimeout(()=>w(null),1900)},Q=(0,i.useCallback)(async()=>{try{let[m,$,H]=await Promise.all([fetch(`${j}/config`).then(se=>se.json()).catch(()=>null),fetch(`${j}/setup-status`).then(se=>se.json()).catch(()=>null),fetch(`${j}/budget`).then(se=>se.json()).catch(()=>null)]);m&&m.ok?(o(m),D(m.revision??0),z(m.schema??null),y({...m.config??{}}),k(m.dsh??null),C(m.writable===!1),E("")):H&&H.ok?(y({...H}),C(!0),E(t("configNeedsDsh"))):E(t("adminLoadFail")),$&&$.ok&&_($),te("")}catch{E(t("adminLoadFail"))}},[t]);(0,i.useEffect)(()=>{Q()},[d,Q]);let ee=(m,$)=>y(H=>({...H??{},[m]:$})),K=m=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[m]||m,Z=async()=>{if(R){if(h){W(t("editInSetting"),!1);return}F("save");try{let $=await(await fetch(`${j}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:R,expectedRevision:B})})).json();if($&&$.ok){let H=$.note||t("savedOk");te(t("savedOk")+($.note?` \xB7 ${$.note}`:"")),W(H),await Q()}else E($?.error||t("saveFail")),W($?.error||t("saveFail"),!1)}catch{E(t("saveFail")),W(t("saveFail"),!1)}finally{F("")}}},xe=()=>{y({...g?.config??{}}),te("")},pe={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}},Ke=async m=>{let $=pe[m];$&&y(H=>({...H??{},...$}))},we=async(m,$)=>{F(m+$);try{let se=await(await fetch(`${j}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:m,action:$})})).json();se&&se.ok?W($==="install"?`\u2705 ${m} MCP \u5DF2\u5B89\u88C5`:`\u2705 ${m} MCP \u5DF2\u5378\u8F7D`):W(`\u274C ${m} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A${se?.error||""}`,!1);try{let be=await fetch(`${j}/setup-status`).then(Ie=>Ie.json());be&&be.ok&&_(be)}catch{}}catch{W(t("mergeFail"),!1)}finally{F("")}},ne=({k:m,label:$,type:H="text",step:se,min:be,max:Ie})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:$||m}),(0,e.jsx)("input",{type:H,step:se,min:be,max:Ie,value:R?R[m]??"":"",onChange:Le=>ee(m,H==="number"?Number(Le.target.value):Le.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}})]}),oe=({k:m,label:$})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(R&&R[m]),onChange:H=>ee(m,H.target.checked)}),(0,e.jsx)("span",{children:$||m})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:x?"0 0 auto":1,minHeight:0,maxHeight:x?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ce}),u&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(u.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:u.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:u.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:u.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[Se&&(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 ",Se]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",t("retry")]})]}),h&&(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")]}),re&&(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 ",re]}),g&&(g.version||g.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:g.dsh?.label||t("nav")}),g.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",g.version]}),g.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",g.dsh.vaultDir]})]}),Y&&Y.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:Y.agents.map(m=>(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:m.isDsh?m.label||"DeepSeek Harness":m.name}),m.isDsh&&m.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",m.version]}),!m.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),m.installed&&m.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),m.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),m.mcpConfigured===!0&&m.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),m.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",m.recallTool?t("enabled"):t("disabled"),")"]})]}),m.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",m.hook]}),!m.isDsh&&m.installed&&m.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!U,onClick:()=>we(m.name,"install"),children:t("installMcp")}),!m.isDsh&&m.installed&&m.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!U,onClick:()=>{window.confirm(t("uninstallConfirm"))&&we(m.name,"uninstall")},children:t("uninstallMcp")})]},m.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),he&&(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:he})})]}),R?(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(m=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ke(m),disabled:!!U,children:[m==="A"?"\u{1F7E2} ":m==="B"?"\u{1F4B0} ":"\u2B50 ",pe[m].label]},m))})]}),(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)(oe,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(oe,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(ne,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(ne,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(ne,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(ne,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(ne,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(oe,{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)(oe,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(oe,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(ne,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(ne,{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:R.auditMode??"all",onChange:m=>ee("auditMode",m.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)(vt,{label:t("auditExemptAgents"),value:R.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(Y?.agents||[]).filter(m=>!m.isDsh).map(m=>({value:m.name,label:m.name}))],onChange:m=>ee("auditExemptAgents",m)}),(0,e.jsx)(vt,{label:t("auditExemptKinds"),value:R.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...rt.filter(m=>m!=="all").map(m=>({value:m,label:t(De[m])}))],onChange:m=>ee("auditExemptKinds",m)}),(0,e.jsx)(ne,{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)(oe,{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:R.autoWebMode??"init",onChange:m=>ee("autoWebMode",m.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)(ne,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(ne,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(ne,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(oe,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(oe,{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:xe,disabled:!!U,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:Z,disabled:!!U||U==="save"||h,children:U==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Ut({t,onReload:l,version:d}){let[x,g]=(0,i.useState)([]),[o,B]=(0,i.useState)([]),[D,M]=(0,i.useState)("all"),[z,R]=(0,i.useState)("all"),[y,h]=(0,i.useState)(""),[C,J]=(0,i.useState)(new Set),[k,Y]=(0,i.useState)(""),[_,Se]=(0,i.useState)("pending"),E=[...new Set([...x,...o].map(b=>b.submittedBy).filter(Boolean))],U=(0,i.useCallback)(async()=>{try{let b=await fetch(`${j}/audit/list`).then(u=>u.json());b.ok&&(g(b.pending||[]),B(b.rejected||[]),J(new Set))}catch{}},[]);(0,i.useEffect)(()=>{U()},[d,U]);let F=(_==="pending"?x:o).filter(b=>{if(D!=="all"&&b.kind!==D||z!=="all"&&Ye(b.submittedBy)!==z)return!1;if(y){let u=(b.created||"").slice(0,10);if(u&&u!==y)return!1}return!0}),re=b=>J(u=>{let w=new Set(u);return w.has(b)?w.delete(b):w.add(b),w}),te=async(b,u)=>{Y("apply");try{for(let w of u||[...C])await fetch(`${j}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(w)}${b==="delete"?"&permanent=0":""}`);await U(),l&&l()}catch{}finally{Y("")}},he=[...C];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:Ce}),(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:D,onChange:b=>M(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")}),rt.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(De[b])},b))]}),(0,e.jsxs)("select",{value:z,onChange:b=>R(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")}),St(E).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>h(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${_==="pending"?" me-on":""}`,onClick:()=>Se("pending"),children:[t("pending"),"\uFF08",x.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${_==="rejected"?" me-on":""}`,onClick:()=>Se("rejected"),children:[t("rejected"),"\uFF08",o.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:F.length>0&&he.length===F.length,onChange:b=>{b.target.checked?J(new Set(F.map(u=>u.path))):J(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!he.length||!!k,onClick:()=>te("approved"),children:["\u2713 ",t(_==="rejected"?"restore":"approve")]}),_==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!k,onClick:()=>te("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!k,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete")},children:["\u{1F5D1} ",t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9"]})]}),F.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:F.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:C.has(b.path),onChange:()=>re(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ye(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||"-"}),_==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>te("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:()=>te("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("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 Yt({t,onReload:l,version:d}){let[x,g]=(0,i.useState)([]),[o,B]=(0,i.useState)(""),D=(0,i.useCallback)(async()=>{try{let z=await fetch(`${j}/recycle/list`).then(R=>R.json());z.ok&&g(z.items||[])}catch{}},[]);(0,i.useEffect)(()=>{D()},[d,D]);let M=async(z,R)=>{B(z+R);try{z==="restore"?await fetch(`${j}/recycle/restore?path=${encodeURIComponent(R)}`):z==="purge"&&await fetch(`${j}/recycle/purge?path=${encodeURIComponent(R)}`),await D(),l&&l()}catch{}finally{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:Ce}),(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:!!o,onClick:async()=>{B("purgeAll");try{await fetch(`${j}/recycle/purge-expired?days=0`),await D()}catch{}finally{B("")}},children:t("emptyRecycle")})]}),x.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:x.map(z=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[z.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(z.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!o,onClick:()=>M("restore",z.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!o,onClick:()=>{window.confirm(t("purgeConfirm"))&&M("purge",z.path)},children:t("purge")})]},z.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Kt=({card:t,t:l,onOpen:d,query:x,onDelete:g})=>(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:Ue[t.kind]||Ue.other}}),x?wt(t.title,x):t.title,Qt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#f59e0b"},children:l("statusPending")}),t.status==="rejected"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#ef4444"},children:l("statusRejected")}),(!t.status||t.status==="approved")&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#10b981"},children:l("statusApproved")})]}),(0,e.jsx)("p",{children:x?wt(t.summary||"",x):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(o=>(0,e.jsx)("span",{className:"mc-tag",children:o},o))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:l(De[t.kind])}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ye(t.submittedBy)]}),(0,e.jsx)("span",{children:zt(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:o=>{o.stopPropagation(),window.confirm(l("deleteConfirm"))&&g&&g(t.path)},children:"\u2715"})]})]});function xt({t,tab:l,onReload:d,version:x}){let[g,o]=(0,i.useState)(null),[B,D]=(0,i.useState)(""),[M,z]=(0,i.useState)(null),[R,y]=(0,i.useState)(null),[h,C]=(0,i.useState)(""),[J,k]=(0,i.useState)(""),[Y,_]=(0,i.useState)(!1),Se=(0,i.useCallback)(async()=>{if(h){C("");return}try{let u=await fetch(`${j}/todayBrief`).then(w=>w.json());C(u.ok&&u.brief||"")}catch{}},[h]),E=(0,i.useCallback)(async()=>{if(!(!M||!M.merge||!M.merge.length)&&window.confirm(t("mergeAllConfirm"))){k("merge");try{let u={},w=K=>u[K]===void 0?K:u[K]=w(u[K]),O=(K,Z)=>{u[w(K)]=w(Z)},W=new Set;for(let K of M.merge)W.add(K.a.path),W.add(K.b.path),O(K.a.path,K.b.path);let Q={};for(let K of W){let Z=w(K);(Q[Z]=Q[Z]||[]).push(K)}let ee=0;for(let K of Object.values(Q)){if(K.length<2)continue;(await fetch(`${j}/merge?paths=${encodeURIComponent(K.join(","))}`).then(xe=>xe.json())).ok&&ee++}await U(),d&&d()}catch{}k("")}},[M,U,d,t]);async function U(){try{let u=await Promise.all([fetch(`${j}/stats`),fetch(`${j}/budget`)]),[w,O]=await Promise.all(u.map(W=>W.json()));w.ok&&o(w),O.ok&&y(O),D(w.ok?"":t("adminLoadFail"))}catch{D(t("adminLoadFail"))}}let F=(0,i.useCallback)(async()=>{k("scan");try{let u=await fetch(`${j}/optimize`).then(w=>w.json());u.ok&&z(u)}catch{D(t("adminLoadFail"))}finally{k("")}},[t]);(0,i.useEffect)(()=>{U()},[x]);let re=async(u,w)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${j}/merge?paths=${encodeURIComponent(u+","+w)}`).then(W=>W.json())).ok&&(await U(),d&&d())}catch{}},te=async u=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${j}/delete?path=${encodeURIComponent(u)}`).then(O=>O.json())).ok&&(await U(),d&&d())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],b=({title:u,kind:w,updated:O,path:W})=>(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:_e.colors[w]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:zt(O)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te(W),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:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[B&&(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 ",B]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:U,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(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("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Se,children:h?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),h&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:h})]}),g&&(0,e.jsxs)(e.Fragment,{children:[g.trend&&g.trend.length>0&&(()=>{let u=g.trend,w=Math.max(...u.map(ee=>ee.count),1),O=260,W=50,Q=O/u.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:O,height:W,style:{display:"block",width:"100%",height:50},children:u.map((ee,K)=>{let Z=Math.round(ee.count/w*(W-4));return(0,e.jsx)("rect",{x:K*Q+1,y:W-Z,width:Math.max(Q-2,2),height:Z,rx:1.5,fill:ee.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:ee.count>0?.85:.35},ee.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.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:he.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[u]||"#666"}}),t(De[u]),": ",g.byKind?.[u]||0]},u))})]}),R&&(R.budgetChars||R.recallLimit||R.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:R.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:R.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",R.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",g.todayCards?.length||0,"\uFF09"]}),g.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:g.todayCards.map(u=>(0,e.jsx)(b,{title:u.title,kind:u.kind,updated:u.updated,path:u.path},u.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:!!J,onClick:F,children:J==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),M&&M.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!J,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){k("oneclick");try{let u=JSON.stringify({cleanupStale:Y}),O=await(await fetch(`${j}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:u})).json();O&&O.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${O.plan.merged} ${t("optimizedMerged")}${Y?` \xB7 ${O.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await U(),d&&d(),z(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{k("")}}},children:J==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),M&&M.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:Y,onChange:u=>_(u.target.checked)}),t("oneClickAlsoStale")]})]}),!M&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),M&&(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}}),M.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!J,onClick:E,children:t(J==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),M.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:M.merge.map((u,w)=>(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:[u.a.title," \u21C4 ",u.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(u.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>re(u.a.path,u.b.path),children:t("mergeNow")})]},w))}):(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",M.stale?.length||0,"\uFF09"]}),M.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!J,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;k("clean");let u=0;for(let w of M.stale)try{await fetch(`${j}/delete?path=${encodeURIComponent(w.path)}`),u++}catch{}k(""),notify(`${u} ${t("deletedStale")}`),await U(),d&&d()},children:t("cleanStale")})}),M.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:M.stale.map(u=>(0,e.jsx)(b,{title:u.title,kind:"other",updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var lt=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
136
|
+
`));let je=new Blob([ye],{type:Xe}),Fe=await ea(je,Te,!1);if(!Fe.ok){u({ok:!1,msg:t("exportFail")}),Q(!1);return}u({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(a){u({ok:!1,msg:t("exportFail")+" \xB7 "+(a.message||"")})}finally{Q(!1)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2600)},n=async c=>{let z=c.target.files&&c.target.files[0];if(c.target.value="",!!z){try{let a=await z.text(),ye=await(await fetch(`${F}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:a})).json();ye.ok?(await de(),u({ok:!0,msg:t("importedVault")+"\uFF1A"+(ye.imported||0)+(ye.skipped?t("importedSkipped")+ye.skipped:"")})):u({ok:!1,msg:ye.error||t("importFail")})}catch{u({ok:!1,msg:t("importFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2400)}},M=(0,o.useMemo)(()=>{let c=L.slice();return U!=="all"&&(c=c.filter(z=>Ye(z.submittedBy)===U)),P!=="all"&&(c=c.filter(z=>(z.status||"approved")===P)),te==="title"?c.sort((z,a)=>String(z.title||"").localeCompare(String(a.title||""))):te==="hot"?c.sort((z,a)=>(a.weight||a.links||0)-(z.weight||z.links||0)):c.sort((z,a)=>new Date(a.updated||0).getTime()-new Date(z.updated||0).getTime()),c},[L,te,U,P]),V=(0,o.useMemo)(()=>[...new Set(L.map(c=>Ye(c.submittedBy)))],[L]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ce}),b&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(b.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:b.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:b.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:b.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)(Mt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),x&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:x,"aria-label":t(g?"exitFull":"fullscreen"),children:g?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${pe?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ke(c=>!c),"aria-label":t(pe?"collapse":"expand"),title:t(pe?"collapse":"expand"),children:pe?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="cards"?" active":""}`,onClick:()=>re("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="graph"?" active":""}`,onClick:()=>re("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="stats"?" active":""}`,onClick:()=>re("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="audit"?" active":""}`,onClick:()=>re("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F6E1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="optimize"?" active":""}`,onClick:()=>re("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F5D1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="config"?" active":""}`,onClick:()=>re("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Le,children:[$==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(He,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(He,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(He,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(He,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(He,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(He,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),$==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:h,onChange:c=>ie(c.target.value)}),(0,e.jsx)("input",{ref:W,type:"file",accept:".json,application/json",style:{display:"none"},onChange:n}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>W.current&&W.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ne({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:H,onClick:()=>r("md"),children:t(H?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:H,onClick:()=>r("json"),children:t(H?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(),children:t("refresh")})]}),$==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[rt.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${I===c?" active":""}`,onClick:()=>qe(c),children:t(c==="all"?"all":De[c])},c)),(0,e.jsxs)("select",{value:U,onChange:c=>Se(c.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")]}),St(V).map(c=>(0,e.jsx)("option",{value:c,children:c},c))]}),(0,e.jsxs)("select",{value:P,onChange:c=>Y(c.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(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${te===c.key?" active":""}`,onClick:()=>he(c.key),children:c.label},c.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),$==="cards"?k&&!L.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):L.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:M.slice(0,se).map(c=>(0,e.jsx)(Kt,{card:c,t,query:h.trim(),onOpen:ve,onDelete:Re},c.path))}),M.length>se&&(0,e.jsx)("div",{ref:Ie,style:{height:1}})]}):$==="graph"?(0,e.jsx)(Vt,{t,onOpen:ve,all:Z,onAllChange:xe,onMutate:E,active:$==="graph"}):$==="config"?(0,e.jsx)(Nt,{t,onReload:()=>de(),version:oe}):$==="stats"?(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}):$==="audit"?(0,e.jsx)(Ut,{t,onReload:()=>de(),version:oe}):$==="optimize"?(0,e.jsx)(Yt,{t,onReload:()=>de(),version:oe}):(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}),ee&&(0,e.jsx)(Xt,{t,card:ee,query:h.trim(),onClose:()=>q(null),onDelete:c=>{q(null),Re(c)},onFeedback:c=>{let z=ee.path;fetch(`${F}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:h.trim(),path:z,useful:c})}).then(()=>u({ok:!0,msg:t(c?"fbUseful":"fbIrr")})).catch(()=>{}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}}),(0,e.jsx)(qt,{t,newCard:we,setNewCard:ne,onCreated:()=>{de(),E(),u({ok:!0,msg:t("created")}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}})]})]})]})}var He=({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 Nt({t,onReload:l,version:d,compact:x}){let[g,i]=(0,o.useState)(null),[S,L]=(0,o.useState)(0),[T,k]=(0,o.useState)(null),[B,y]=(0,o.useState)(null),[N,I]=(0,o.useState)(!1),[A,h]=(0,o.useState)(null),[K,U]=(0,o.useState)(null),[Se,P]=(0,o.useState)(""),[Y,$]=(0,o.useState)(""),[re,te]=(0,o.useState)(""),[he,b]=(0,o.useState)(""),[u,w]=(0,o.useState)(null),W=(0,o.useRef)(null),H=(m,E=!0)=>{W.current&&clearTimeout(W.current),w({msg:m,ok:E}),W.current=setTimeout(()=>w(null),1900)},Q=(0,o.useCallback)(async()=>{try{let[m,E,_]=await Promise.all([fetch(`${F}/config`).then(se=>se.json()).catch(()=>null),fetch(`${F}/setup-status`).then(se=>se.json()).catch(()=>null),fetch(`${F}/budget`).then(se=>se.json()).catch(()=>null)]);m&&m.ok?(i(m),L(m.revision??0),k(m.schema??null),y({...m.config??{}}),h(m.dsh??null),I(m.writable===!1),P("")):_&&_.ok?(y({..._}),I(!0),P(t("configNeedsDsh"))):P(t("adminLoadFail")),E&&E.ok&&U(E),te("")}catch{P(t("adminLoadFail"))}},[t]);(0,o.useEffect)(()=>{Q()},[d,Q]);let ee=(m,E)=>y(_=>({..._??{},[m]:E})),q=m=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[m]||m,Z=async()=>{if(B){if(N){H(t("editInSetting"),!1);return}$("save");try{let E=await(await fetch(`${F}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:B,expectedRevision:S})})).json();if(E&&E.ok){let _=E.note||t("savedOk");te(t("savedOk")+(E.note?` \xB7 ${E.note}`:"")),H(_),await Q()}else P(E?.error||t("saveFail")),H(E?.error||t("saveFail"),!1)}catch{P(t("saveFail")),H(t("saveFail"),!1)}finally{$("")}}},xe=()=>{y({...g?.config??{}}),te("")},pe={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}},Ke=async m=>{let E=pe[m];E&&y(_=>({..._??{},...E}))},we=async(m,E)=>{$(m+E);try{let se=await(await fetch(`${F}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:m,action:E})})).json();se&&se.ok?H(E==="install"?`\u2705 ${m} MCP \u5DF2\u5B89\u88C5`:`\u2705 ${m} MCP \u5DF2\u5378\u8F7D`):H(`\u274C ${m} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A${se?.error||""}`,!1);try{let be=await fetch(`${F}/setup-status`).then(Ie=>Ie.json());be&&be.ok&&U(be)}catch{}}catch{H(t("mergeFail"),!1)}finally{$("")}},ne=({k:m,label:E,type:_="text",step:se,min:be,max:Ie})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:E||m}),(0,e.jsx)("input",{type:_,step:se,min:be,max:Ie,value:B?B[m]??"":"",onChange:Le=>ee(m,_==="number"?Number(Le.target.value):Le.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}})]}),oe=({k:m,label:E})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(B&&B[m]),onChange:_=>ee(m,_.target.checked)}),(0,e.jsx)("span",{children:E||m})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:x?"0 0 auto":1,minHeight:0,maxHeight:x?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ce}),u&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(u.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:u.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:u.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:u.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[Se&&(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 ",Se]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",t("retry")]})]}),N&&(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")]}),re&&(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 ",re]}),g&&(g.version||g.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:g.dsh?.label||t("nav")}),g.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",g.version]}),g.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",g.dsh.vaultDir]})]}),K&&K.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:K.agents.map(m=>(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:m.isDsh?m.label||"DeepSeek Harness":m.name}),m.isDsh&&m.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",m.version]}),!m.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),m.installed&&m.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),m.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),m.mcpConfigured===!0&&m.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),m.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",m.recallTool?t("enabled"):t("disabled"),")"]})]}),m.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",m.hook]}),!m.isDsh&&m.installed&&m.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!Y,onClick:()=>we(m.name,"install"),children:t("installMcp")}),!m.isDsh&&m.installed&&m.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!Y,onClick:()=>{window.confirm(t("uninstallConfirm"))&&we(m.name,"uninstall")},children:t("uninstallMcp")})]},m.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),he&&(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:he})})]}),B?(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(m=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ke(m),disabled:!!Y,children:[m==="A"?"\u{1F7E2} ":m==="B"?"\u{1F4B0} ":"\u2B50 ",pe[m].label]},m))})]}),(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)(oe,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(oe,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(ne,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(ne,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(ne,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(ne,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(ne,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(oe,{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)(oe,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(oe,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(ne,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(ne,{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:B.auditMode??"all",onChange:m=>ee("auditMode",m.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)(vt,{label:t("auditExemptAgents"),value:B.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(K?.agents||[]).filter(m=>!m.isDsh).map(m=>({value:m.name,label:m.name}))],onChange:m=>ee("auditExemptAgents",m)}),(0,e.jsx)(vt,{label:t("auditExemptKinds"),value:B.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...rt.filter(m=>m!=="all").map(m=>({value:m,label:t(De[m])}))],onChange:m=>ee("auditExemptKinds",m)}),(0,e.jsx)(ne,{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)(oe,{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:B.autoWebMode??"init",onChange:m=>ee("autoWebMode",m.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)(ne,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(ne,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(ne,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(oe,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(oe,{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:xe,disabled:!!Y,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:Z,disabled:!!Y||Y==="save"||N,children:Y==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Ut({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)([]),[L,T]=(0,o.useState)("all"),[k,B]=(0,o.useState)("all"),[y,N]=(0,o.useState)(""),[I,A]=(0,o.useState)(new Set),[h,K]=(0,o.useState)(""),[U,Se]=(0,o.useState)("pending"),P=[...new Set([...x,...i].map(b=>b.submittedBy).filter(Boolean))],Y=(0,o.useCallback)(async()=>{try{let b=await fetch(`${F}/audit/list`).then(u=>u.json());b.ok&&(g(b.pending||[]),S(b.rejected||[]),A(new Set))}catch{}},[]);(0,o.useEffect)(()=>{Y()},[d,Y]);let $=(U==="pending"?x:i).filter(b=>{if(L!=="all"&&b.kind!==L||k!=="all"&&Ye(b.submittedBy)!==k)return!1;if(y){let u=(b.created||"").slice(0,10);if(u&&u!==y)return!1}return!0}),re=b=>A(u=>{let w=new Set(u);return w.has(b)?w.delete(b):w.add(b),w}),te=async(b,u)=>{K("apply");try{for(let w of u||[...I])await fetch(`${F}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(w)}${b==="delete"?"&permanent=0":""}`);await Y(),l&&l()}catch{}finally{K("")}},he=[...I];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:Ce}),(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:L,onChange:b=>T(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")}),rt.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(De[b])},b))]}),(0,e.jsxs)("select",{value:k,onChange:b=>B(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")}),St(P).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>N(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${U==="pending"?" me-on":""}`,onClick:()=>Se("pending"),children:[t("pending"),"\uFF08",x.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${U==="rejected"?" me-on":""}`,onClick:()=>Se("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:$.length>0&&he.length===$.length,onChange:b=>{b.target.checked?A(new Set($.map(u=>u.path))):A(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!he.length||!!h,onClick:()=>te("approved"),children:["\u2713 ",t(U==="rejected"?"restore":"approve")]}),U==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!h,onClick:()=>te("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!h,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete")},children:["\u{1F5D1} ",t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9"]})]}),$.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:$.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:I.has(b.path),onChange:()=>re(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ye(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||"-"}),U==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>te("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:()=>te("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("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 Yt({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)(""),L=(0,o.useCallback)(async()=>{try{let k=await fetch(`${F}/recycle/list`).then(B=>B.json());k.ok&&g(k.items||[])}catch{}},[]);(0,o.useEffect)(()=>{L()},[d,L]);let T=async(k,B)=>{S(k+B);try{k==="restore"?await fetch(`${F}/recycle/restore?path=${encodeURIComponent(B)}`):k==="purge"&&await fetch(`${F}/recycle/purge?path=${encodeURIComponent(B)}`),await L(),l&&l()}catch{}finally{S("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(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()=>{S("purgeAll");try{await fetch(`${F}/recycle/purge-expired?days=0`),await L()}catch{}finally{S("")}},children:t("emptyRecycle")})]}),x.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:x.map(k=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[k.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(k.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>T("restore",k.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"))&&T("purge",k.path)},children:t("purge")})]},k.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Kt=({card:t,t:l,onOpen:d,query:x,onDelete:g})=>(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:Ue[t.kind]||Ue.other}}),x?wt(t.title,x):t.title,Qt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#f59e0b"},children:l("statusPending")}),t.status==="rejected"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#ef4444"},children:l("statusRejected")}),(!t.status||t.status==="approved")&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#10b981"},children:l("statusApproved")})]}),(0,e.jsx)("p",{children:x?wt(t.summary||"",x):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsx)("span",{className:"mc-tag",children:i},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:l(De[t.kind])}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ye(t.submittedBy)]}),(0,e.jsx)("span",{children:zt(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"))&&g&&g(t.path)},children:"\u2715"})]})]});function xt({t,tab:l,onReload:d,version:x}){let[g,i]=(0,o.useState)(null),[S,L]=(0,o.useState)(""),[T,k]=(0,o.useState)(null),[B,y]=(0,o.useState)(null),[N,I]=(0,o.useState)(""),[A,h]=(0,o.useState)(""),[K,U]=(0,o.useState)(!1),Se=(0,o.useCallback)(async()=>{if(N){I("");return}try{let u=await fetch(`${F}/todayBrief`).then(w=>w.json());I(u.ok&&u.brief||"")}catch{}},[N]),P=(0,o.useCallback)(async()=>{if(!(!T||!T.merge||!T.merge.length)&&window.confirm(t("mergeAllConfirm"))){h("merge");try{let u={},w=q=>u[q]===void 0?q:u[q]=w(u[q]),W=(q,Z)=>{u[w(q)]=w(Z)},H=new Set;for(let q of T.merge)H.add(q.a.path),H.add(q.b.path),W(q.a.path,q.b.path);let Q={};for(let q of H){let Z=w(q);(Q[Z]=Q[Z]||[]).push(q)}let ee=0;for(let q of Object.values(Q)){if(q.length<2)continue;(await fetch(`${F}/merge?paths=${encodeURIComponent(q.join(","))}`).then(xe=>xe.json())).ok&&ee++}await Y(),d&&d()}catch{}h("")}},[T,Y,d,t]);async function Y(){try{let u=await Promise.all([fetch(`${F}/stats`),fetch(`${F}/budget`)]),[w,W]=await Promise.all(u.map(H=>H.json()));w.ok&&i(w),W.ok&&y(W),L(w.ok?"":t("adminLoadFail"))}catch{L(t("adminLoadFail"))}}let $=(0,o.useCallback)(async()=>{h("scan");try{let u=await fetch(`${F}/optimize`).then(w=>w.json());u.ok&&k(u)}catch{L(t("adminLoadFail"))}finally{h("")}},[t]);(0,o.useEffect)(()=>{Y()},[x]);let re=async(u,w)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${F}/merge?paths=${encodeURIComponent(u+","+w)}`).then(H=>H.json())).ok&&(await Y(),d&&d())}catch{}},te=async u=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${F}/delete?path=${encodeURIComponent(u)}`).then(W=>W.json())).ok&&(await Y(),d&&d())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],b=({title:u,kind:w,updated:W,path:H})=>(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:_e.colors[w]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:zt(W)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te(H),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:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[S&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",S]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Y,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(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("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Se,children:N?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),N&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:N})]}),g&&(0,e.jsxs)(e.Fragment,{children:[g.trend&&g.trend.length>0&&(()=>{let u=g.trend,w=Math.max(...u.map(ee=>ee.count),1),W=260,H=50,Q=W/u.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:W,height:H,style:{display:"block",width:"100%",height:50},children:u.map((ee,q)=>{let Z=Math.round(ee.count/w*(H-4));return(0,e.jsx)("rect",{x:q*Q+1,y:H-Z,width:Math.max(Q-2,2),height:Z,rx:1.5,fill:ee.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:ee.count>0?.85:.35},ee.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.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:he.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[u]||"#666"}}),t(De[u]),": ",g.byKind?.[u]||0]},u))})]}),B&&(B.budgetChars||B.recallLimit||B.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:B.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:B.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",B.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",g.todayCards?.length||0,"\uFF09"]}),g.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:g.todayCards.map(u=>(0,e.jsx)(b,{title:u.title,kind:u.kind,updated:u.updated,path:u.path},u.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:!!A,onClick:$,children:A==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),T&&T.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){h("oneclick");try{let u=JSON.stringify({cleanupStale:K}),W=await(await fetch(`${F}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:u})).json();W&&W.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${W.plan.merged} ${t("optimizedMerged")}${K?` \xB7 ${W.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await Y(),d&&d(),k(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{h("")}}},children:A==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),T&&T.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:K,onChange:u=>U(u.target.checked)}),t("oneClickAlsoStale")]})]}),!T&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),T&&(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}}),T.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:P,children:t(A==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),T.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:T.merge.map((u,w)=>(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:[u.a.title," \u21C4 ",u.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(u.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>re(u.a.path,u.b.path),children:t("mergeNow")})]},w))}):(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",T.stale?.length||0,"\uFF09"]}),T.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!A,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;h("clean");let u=0;for(let w of T.stale)try{await fetch(`${F}/delete?path=${encodeURIComponent(w.path)}`),u++}catch{}h(""),notify(`${u} ${t("deletedStale")}`),await Y(),d&&d()},children:t("cleanStale")})}),T.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:T.stale.map(u=>(0,e.jsx)(b,{title:u.title,kind:"other",updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var lt=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
137
137
|
|
|
138
138
|
## \u80CC\u666F
|
|
139
139
|
- \u95EE\u9898\u63CF\u8FF0
|
|
@@ -178,8 +178,8 @@ var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDe
|
|
|
178
178
|
-
|
|
179
179
|
|
|
180
180
|
## \u98CE\u9669/\u963B\u585E
|
|
181
|
-
- `}];function qt({t,newCard:l,setNewCard:d,onCreated:x}){if(!l)return null;let g=lt.find(y=>y.key===l.template),o=l.body||(g?g.body:""),B=l.kind||(g?g.kind:"knowledge"),D=l.tags||(g?g.tags.join(", "):""),M=l._creating,z=y=>{let h=lt.find(C=>C.key===y);d(C=>({...C,template:y,kind:h?h.kind:C.kind,body:h?h.body:C.body,tags:h?h.tags.join(", "):C.tags}))},R=async()=>{if(!(!l.title&&!o)){d(y=>({...y,_creating:!0}));try{(await fetch(`${j}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||"\u65E0\u6807\u9898",kind:B,tags:D.split(",").map(h=>h.trim()).filter(Boolean),body:o,source:"manual"})}).then(h=>h.json())).ok?(d(null),x&&x()):d(h=>({...h,_creating:!1}))}catch{d(h=>({...h,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ce}),(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:[lt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>z(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:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:B,onChange:y=>d(h=>({...h,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(h=>({...h,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:D,onChange:y=>d(h=>({...h,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:o,onChange:y=>d(h=>({...h,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:M,onClick:R,children:t(M?"exporting":"createCard")})})]})]})]})}function Xt({t,card:l,query:d,onClose:x,onDelete:g,onFeedback:o}){(0,i.useEffect)(()=>{let z=R=>{R.key==="Escape"&&x()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[x]);let[B,D]=(0,i.useState)(!1),M=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:x,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",onClick:z=>z.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:()=>o&&o(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>o&&o(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),M&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>D(z=>!z),children:t(B?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&g&&g(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:x,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:B?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ta(l.text)}})]})]})}function Vt({t,onOpen:l,all:d,onAllChange:x,onMutate:g}){let[o,B]=(0,i.useState)(null),[D,M]=(0,i.useState)(""),z=(0,i.useCallback)(async()=>{try{let C=await(await fetch(`${j}/graph${d?"?all=1":""}`)).json();C.ok?(B(C),M("")):(B(null),M(C.error||t("error")))}catch(h){M(String(h&&h.message?h.message:h))}},[d,t]);(0,i.useEffect)(()=>{let h=!0;return fetch(`${j}/graph${d?"?all=1":""}`).then(C=>C.json()).then(C=>{h&&(C.ok?(B(C),M("")):(B(null),M(C.error||t("error"))))}).catch(C=>{h&&M(String(C&&C.message?C.message:C))}),()=>{h=!1}},[d,t]);let R=(0,i.useCallback)(async h=>{try{let J=await(await fetch(`${j}/delete?path=${encodeURIComponent(h)}`)).json();return J&&J.ok?(await z(),g&&g(),!0):!1}catch{return!1}},[z]),y=(0,i.useCallback)(async h=>{if(!h||h.length<2)return!1;try{let C=await fetch(`${j}/merge?paths=${encodeURIComponent(h.join(","))}`).then(J=>J.json());return C&&C.ok?(await z(),g&&g(),!0):!1}catch{return!1}},[z,g]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ce}),D&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",D]}),!o&&!D&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),o&&o.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),o&&o.nodes.length>0&&(0,e.jsx)(Jt,{nodes:o.nodes,edges:o.edges,onOpen:l,onDelete:R,onMerge:y,t,all:d,onAllChange:x,countLabel:`${o.nodes.length} ${t("nodes")} \xB7 ${Gt(o.edges)} ${t("edges")}`})]})}function Gt(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var _e={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 Jt({nodes:t,edges:l,onOpen:d,onDelete:x,onMerge:g,t:o,countLabel:B,all:D,onAllChange:M}){let z=(0,i.useRef)(null),R=(0,i.useRef)(null),y=(0,i.useRef)(null),h=(0,i.useRef)(null),C=(0,i.useRef)(null),J=(0,i.useRef)(d);(0,i.useEffect)(()=>{J.current=d},[d]);let k=(0,i.useRef)(x);(0,i.useEffect)(()=>{k.current=x},[x]);let Y=(0,i.useRef)(g);(0,i.useEffect)(()=>{Y.current=g},[g]);let[_,Se]=(0,i.useState)(""),[E,U]=(0,i.useState)(null),F=(0,i.useRef)("");(0,i.useEffect)(()=>{F.current=_.trim().toLowerCase()},[_]),(0,i.useEffect)(()=>{let r=y.current;if(!r)return;let n=_.trim().toLowerCase();if(!n)return;let N=r.nodes.find(X=>(X.name||"").toLowerCase().includes(n));N&&(y.current.selectedId=N.id,U(N.id),r.panX=r.w/2-N.x*r.zoom,r.panY=r.h/2-N.y*r.zoom,r.render&&r.render())},[_]);let[re,te]=(0,i.useState)("all"),[he,b]=(0,i.useState)(!1),u=(0,i.useRef)("all"),[w,O]=(0,i.useState)(""),W=(0,i.useRef)(""),[Q,ee]=(0,i.useState)(!1),K=(0,i.useRef)(!1),[Z,xe]=(0,i.useState)(null);(0,i.useEffect)(()=>{u.current=re},[re]),(0,i.useEffect)(()=>{W.current=w},[w]),(0,i.useEffect)(()=>{K.current=Q},[Q]);let pe=(0,i.useMemo)(()=>{let r=new Map;for(let n of t)for(let N of n.tags||[]){let X=String(N).trim();X&&r.set(X,(r.get(X)||0)+1)}return[...r.entries()].sort((n,N)=>N[1]-n[1]).slice(0,24).map(([n,N])=>({tag:n,n:N}))},[t]),Ke=(()=>{let r=_.trim().toLowerCase();return!!r&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(r)||String(n.kind||"").toLowerCase().includes(r)||String(De[n.kind]||"").toLowerCase().includes(r))})();(0,i.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[_]),(0,i.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[re,w,Q]);let we=(0,i.useRef)(null),[ne,oe]=(0,i.useState)([]),[m,$]=(0,i.useState)(null),[H,se]=(0,i.useState)(!1),[be,Ie]=(0,i.useState)(null),[Le,Ee]=(0,i.useState)(""),de=(0,i.useRef)(null),Re=(0,i.useRef)(null),ie=(r,n=!0)=>{de.current&&clearTimeout(de.current),Ie({msg:r,ok:n}),de.current=setTimeout(()=>Ie(null),1900)},qe=r=>{Ee(r),Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>Ee(""),1600)};(0,i.useEffect)(()=>()=>{de.current&&clearTimeout(de.current),Re.current&&clearTimeout(Re.current)},[]);let ve=(0,i.useMemo)(()=>t.reduce((r,n)=>(r[n.id]=n,r),{}),[t]);return(0,i.useEffect)(()=>{let r=z.current;if(!r||t.length===0)return;let n=r.getContext("2d");if(!n)return;let N=Math.max(1,window.devicePixelRatio||1),X=()=>document.documentElement.getAttribute("data-theme")==="dark",c={};l.forEach(s=>{c[s.source]=(c[s.source]||0)+1,c[s.target]=(c[s.target]||0)+1});let I=Math.max(1,...Object.values(c)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(c[s.id]||0)/I*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:N,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,v)=>(s[v.id]=v,s),{}),a.nodes.forEach((s,v)=>{let f=v/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let ae=[...new Set(a.nodes.map(s=>s.type))];a.clustered=ae.length>1,a.typeCenters={},ae.forEach((s,v)=>{let f=v/ae.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),y.current=a;let ye=()=>{let s=r.clientWidth,v=r.clientHeight;a.w=s,a.h=v,r.width=s*N,r.height=v*N,n.setTransform(N,0,0,N,0,0)};ye();let Te=new ResizeObserver(ye);Te.observe(r.parentElement);let Xe=(s,v)=>s&&s.length>v?s.slice(0,v)+"\u2026":s,je=(s,v,f,S)=>{if(n.beginPath(),S==="rect")n.rect(s-f,v-f*.75,f*2,f*1.5);else if(S==="diamond")n.moveTo(s,v-f),n.lineTo(s+f,v),n.lineTo(s,v+f),n.lineTo(s-f,v),n.closePath();else if(S==="hexagon"){for(let L=0;L<6;L++){let q=Math.PI/3*L-Math.PI/2,P=s+f*Math.cos(q),me=v+f*Math.sin(q);L===0?n.moveTo(P,me):n.lineTo(P,me)}n.closePath()}else n.arc(s,v,f,0,Math.PI*2)},Fe=()=>{if(!a.nodes.length)return;let s=1/0,v=-1/0,f=1/0,S=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),v=Math.max(v,p.x),f=Math.min(f,p.y),S=Math.max(S,p.y)});let L=20,q=v-s+L*2,P=S-f+L*2,me=Math.min(a.w/q,a.h/P);a.zoom=Math.max(.35,Math.min(1.8,me)),a.panX=a.w/2-(s+v)/2*a.zoom,a.panY=a.h/2-(f+S)/2*a.zoom};h.current=Fe;let Be=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=F.current,a.kindFilter=u.current,a.timeMode=K.current,a.tagFilter=W.current;let s=a.tagFilter,v=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");n.save(),n.strokeStyle=X()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let p=0;p<a.w;p+=24)n.beginPath(),n.moveTo(p,0),n.lineTo(p,a.h),n.stroke();for(let p=0;p<a.h;p+=24)n.beginPath(),n.moveTo(0,p),n.lineTo(a.w,p),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let S={};a.nodes.forEach(p=>S[p.id]=p);let L=a.nodes.length>40,q=L?1.5:.55,P=a.selectedId||a.hoverId;a.edges.forEach(p=>{let V=S[p.sourceNodeId],T=S[p.targetNodeId];if(!V||!T)return;if(v!=="all"){let et=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,fe=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(et!==v&&fe!==v)return}if(s){let et=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),fe=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!et&&!fe)return}let A=T.x-V.x,G=T.y-V.y,le=Math.sqrt(A*A+G*G)||1,ce=L?12:18,ue=-G/le*ce,ge=A/le*ce,Me=(V.x+T.x)/2+ue,Ne=(V.y+T.y)/2+ge,ze=_e.colors[a.domainById[V.id]&&a.domainById[V.id].kind||"other"],$e=P&&(p.sourceNodeId===P||p.targetNodeId===P),ot=P?$e?.6:.08:L?.14:.24,it=parseInt(ze.slice(1,3),16),Ge=parseInt(ze.slice(3,5),16),Qe=parseInt(ze.slice(5,7),16);n.strokeStyle="rgba("+it+","+Ge+","+Qe+","+ot+")",n.lineWidth=$e?1.6+(p.weight||1):.8+(p.weight||1)*.5,n.beginPath(),n.moveTo(V.x,V.y),n.quadraticCurveTo(Me,Ne,T.x,T.y),n.stroke()});let me=[];if(a.nodes.forEach(p=>{let V=a.domainById[p.id]||{},T=V.kind||"other",A=a.timeMode?Zt(V.updated):_e.colors[T],G=_e.shapes[T],le=a.selectedId===p.id,ce=a.hoverId===p.id,ue=a.searchTerm||"",ge=!ue||(p.name||"").toLowerCase().includes(ue)||String(De[T]||"").toLowerCase().includes(ue)||String(T).toLowerCase().includes(ue),Me=v==="all"||T===v,Ne=!s||(V.tags||[]).includes(s),ze=P&&p.id!==P&&!a.edges.some(fe=>fe.sourceNodeId===P&&fe.targetNodeId===p.id||fe.targetNodeId===P&&fe.sourceNodeId===p.id)||ue&&!ge||!Me||!Ne;n.save(),n.globalAlpha=ze?.08:1,(le||ce)&&(n.shadowColor=A,n.shadowBlur=le?20:14),je(p.x,p.y,p.r,G);let $e=parseInt(A.slice(1,3),16),ot=parseInt(A.slice(3,5),16),it=parseInt(A.slice(5,7),16),Ge=n.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);Ge.addColorStop(0,"rgba("+Math.min(255,$e+70)+","+Math.min(255,ot+70)+","+Math.min(255,it+70)+",0.95)"),Ge.addColorStop(1,A),n.fillStyle=Ge,n.fill(),n.restore(),le?(n.save(),je(p.x,p.y,p.r+3,G),n.strokeStyle=A,n.lineWidth=3,n.shadowColor=A,n.shadowBlur=12,n.stroke(),n.restore()):ce?(n.save(),je(p.x,p.y,p.r+2,G),n.strokeStyle=A,n.lineWidth=2,n.stroke(),n.restore()):ue&&ge?(n.save(),je(p.x,p.y,p.r+2,G),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(p.id)>=0&&(n.save(),je(p.x,p.y,p.r+2,G),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Qe=Xe(p.name,16);if((le||ce||a.zoom>q||!L&&a.zoom>.6)&&Me&&Ne){let fe=1/a.zoom;n.font="500 "+(12*fe).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ae=n.measureText(Qe).width+16*fe,tt=18*fe,Pe=p.y+p.r+8*fe,yt=!0;for(let Oe of me)if(p.x-Ae/2<Oe.x+Oe.w&&p.x+Ae/2>Oe.x&&Pe<Oe.y+Oe.h&&Pe+tt>Oe.y){yt=!1;break}if(!yt&&!le&&!ce)return;me.push({x:p.x-Ae/2,y:Pe,w:Ae,h:tt}),n.fillStyle=X()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(p.x-Ae/2,Pe,Ae,tt,4*fe):n.rect(p.x-Ae/2,Pe,Ae,tt),n.fill(),n.strokeStyle=X()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*fe,n.stroke(),n.fillStyle=X()?le||ce?"#eee":"#bbb":le||ce?"#111":"#444",n.textAlign="center",n.fillText(Qe,p.x,Pe+13*fe)}}),n.restore(),a.marquee){let p=a.marquee,V=Math.min(p.sx,p.ex),T=Math.min(p.sy,p.ey),A=Math.abs(p.ex-p.sx),G=Math.abs(p.ey-p.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(V,T,A,G),n.strokeRect(V,T,A,G),n.restore()}if(a.hoverId&&we.current){let p=a.domainById[a.hoverId],V=a.nodes.find(function(T){return T.id===a.hoverId});if(p&&V){let T=a.edges.filter(function(le){return le.sourceNodeId===p.id||le.targetNodeId===p.id}).length,A=V.x*a.zoom+a.panX,G=V.y*a.zoom+a.panY;we.current.style.display="block",we.current.style.left=A+14+"px",we.current.style.top=G-6+"px",we.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+T+" \u8FDE\u63A5</span>"}}else we.current&&(we.current.style.display="none")},ke=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(dt))};a.wake=ke,a.render=Be;let st=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),S=s>1e3?3e3:s>100?2e3:s>50?1200:800,L=s>100?.002:.005,q=s>1e3?.012:s>100?.005:.01,P=s>1e3?6:s>200?12:24,me={};a.nodes.forEach(T=>me[T.id]=T);for(let T=0;T<s;T++){if(a.dragNode===a.nodes[T])continue;let A=a.nodes[T],G=0,le=0;for(let ge=0;ge<s;ge++){if(T===ge)continue;let Me=A.x-a.nodes[ge].x,Ne=A.y-a.nodes[ge].y,ze=Math.sqrt(Me*Me+Ne*Ne)||1,$e=S/(ze*ze);G+=Me/ze*$e,le+=Ne/ze*$e}if(a.clustered&&a.typeCenters[A.type]){let ge=a.typeCenters[A.type];G+=(ge.x-A.x)*.006,le+=(ge.y-A.y)*.006}else G-=A.x*q,le-=A.y*q;let ce=(A.vx+G)*f,ue=(A.vy+le)*f;ce=Math.max(-P,Math.min(P,ce)),ue=Math.max(-P,Math.min(P,ue)),A.vx=ce,A.vy=ue}a.edges.forEach(T=>{let A=me[T.sourceNodeId],G=me[T.targetNodeId];if(!A||!G)return;let le=G.x-A.x,ce=G.y-A.y,ue=Math.sqrt(le*le+ce*ce)||1,ge=(ue-100)*L,Me=le/ue*ge,Ne=ce/ue*ge;a.dragNode!==A&&(A.vx+=Me,A.vy+=Ne),a.dragNode!==G&&(G.vx-=Me,G.vy-=Ne)});let p=0;a.nodes.forEach(T=>{a.dragNode!==T&&(T.x+=T.vx,T.y+=T.vy,p+=T.vx*T.vx+T.vy*T.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Fe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},dt=()=>{if(a.running){try{st(),Be()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(dt)}},Ve=(s,v)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(v-f.top-a.panY)/a.zoom}},Je=s=>{let v=a.domainById[s];return!(!v||u.current!=="all"&&v.kind!==u.current||W.current&&!(v.tags||[]).includes(W.current))},Ze=(s,v,f)=>Math.max(v,Math.min(f,s)),ct=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let v=Ve(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let L=a.nodes[S];if(!Je(L.id))continue;let q=L.x-v.x,P=L.y-v.y;if(q*q+P*P<L.r*L.r+36){f=L.id;break}}f!==a.hoverId&&(a.hoverId=f,ke())},pt=s=>{if(s.button!==0)return;let v=Ve(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let L=a.nodes[S];if(!Je(L.id))continue;let q=L.x-v.x,P=L.y-v.y;if(q*q+P*P<L.r*L.r+25){f=L;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-v.x,dy:f.y-v.y})},mt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ke();return}if(!a.dragStart)return;let v=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(v)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let S=Ve(s.clientX,s.clientY);a.dragNode.x=S.x+a.dragOffset.dx,a.dragNode.y=S.y+a.dragOffset.dy,ke()}else a.dragging&&(a.panX=Ze(a.dragStart.px+v,-1e5,1e5),a.panY=Ze(a.dragStart.py+f,-1e5,1e5),ke())},ut=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let S=r.getBoundingClientRect(),L=Math.min(f.sx,f.ex)-S.left,q=Math.max(f.sx,f.ex)-S.left,P=Math.min(f.sy,f.ey)-S.top,me=Math.max(f.sy,f.ey)-S.top,p=a.nodes.filter(V=>{let T=V.x*a.zoom+a.panX,A=V.y*a.zoom+a.panY;return T>=L&&T<=q&&A>=P&&A<=me}).map(V=>V.id);a.multi=p,oe(p),ke();return}let v=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let S=Array.isArray(a.multi)?a.multi.slice():[];S.includes(f)||S.push(f),a.multi=S,oe(S),ke();return}if(v){let f=Ve(s.clientX,s.clientY),S=null;for(let L=a.nodes.length-1;L>=0;L--){let q=a.nodes[L];if(!Je(q.id))continue;let P=q.x-f.x,me=q.y-f.y;if(P*P+me*me<q.r*q.r+20){S=q;break}}S?(a.selectedId=S.id,U(S.id),ke()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],oe([])),U(null),ke())}a.dragStart=null,a.dragging=!1,a.dragNode=null},gt=s=>{s.preventDefault();let v=Ve(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let L=a.nodes[S];if(!Je(L.id))continue;let q=L.x-v.x,P=L.y-v.y;if(q*q+P*P<L.r*L.r+25){f=L;break}}if(f){let S=a.domainById[f.id];S&&xe({x:s.clientX,y:s.clientY,id:f.id,path:S.id,title:S.title})}else xe(null)},ft=s=>{s.preventDefault();let v=r.getBoundingClientRect(),f=(s.clientX-v.left-a.panX)/a.zoom,S=(s.clientY-v.top-a.panY)/a.zoom,L=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=Ze(a.panX+f*(a.zoom-L),-1e5,1e5),a.panY=Ze(a.panY+S*(a.zoom-L),-1e5,1e5),a.zoom=L,ke()};r.addEventListener("mousemove",ct),r.addEventListener("mousedown",pt),window.addEventListener("mousemove",mt),window.addEventListener("mouseup",ut),r.addEventListener("wheel",ft,{passive:!1}),r.addEventListener("contextmenu",gt),C.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],oe([]),Fe(),ke()};for(let s=0;s<200;s++)st();Fe(),ke();let bt=()=>b(!1);return window.addEventListener("mousedown",bt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Te.disconnect(),r.removeEventListener("mousemove",ct),r.removeEventListener("mousedown",pt),window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",ut),r.removeEventListener("wheel",ft),r.removeEventListener("contextmenu",gt),window.removeEventListener("mousedown",bt)}},[t,l]),(0,e.jsxs)("div",{className:"me-graph",ref:R,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",o("nodes")," \xB7 ",l.length," ",o("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:o("search"),value:_,onChange:r=>Se(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>b(r=>!r),"aria-expanded":he,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",o("filterLabel")," ",re!=="all"||Q||w?"\u25CF":"\u25BE"]}),he&&(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${re==="all"&&!Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{te("all"),ee(!1)},children:o("all")}),Object.keys(Ue).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${re===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>te(n=>n===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[r]||Ue[r]}}),o(De[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${Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ee(r=>!r),children:["\u23F1 ",o("timeDim")]}),pe.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:pe.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${w===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>O(n=>n===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(re!=="all"||Q||w)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{te("all"),ee(!1),O("")},children:[o("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!D,onChange:r=>M&&M(r.target.checked)}),o("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${Q?" me-on":""}`,onClick:()=>ee(r=>!r),children:o("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=z.current;if(r)try{r.toBlob(n=>{n&&$({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:o("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h.current&&h.current(),children:o("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{U(null),te("all"),C.current&&C.current()},children:o("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:z,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:we,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)"}}),Ke&&(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:o("noMatch")}),Z&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),Z&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:Z.x,top:Z.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{J.current({path:Z.path,title:Z.title}),xe(null)},children:o("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Z.id&&(y.current.selectedId=Z.id,U(Z.id)),xe(null);let r=y.current;r&&r.wake&&r.wake()},children:o("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(Z.title||"")}catch{}xe(null),ie(o("copied"))},children:o("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,n=r&&Array.isArray(r.multi)?r.multi.slice():[],N=Z.id;if(N&&!n.includes(N)&&n.push(N),xe(null),n.length<2){ie(o("mergeNeed"),!1);return}if(!window.confirm(o("mergeConfirm")))return;let X=Y.current&&Y.current(n);X&&X.then?X.then(c=>c?ie(o("merged")):ie(o("mergeFail"),!1)).catch(()=>ie(o("mergeFail"),!1)):X&&ie(o("merged"))},children:o("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Z.path;xe(null),window.confirm(o("deleteConfirm"))&&(async()=>{try{(k.current?await k.current(r):!1)?ie(o("deleted")):ie(o("deleteFail"),!1)}catch{ie(o("deleteFail"),!1)}})()},children:o("delete")})]}),ne.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:[ne.length," ",o("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=ne.map(I=>ve[I]).filter(Boolean).map(I=>I.title||I.name).join(`
|
|
182
|
-
`),
|
|
181
|
+
- `}];function qt({t,newCard:l,setNewCard:d,onCreated:x}){if(!l)return null;let g=lt.find(y=>y.key===l.template),i=l.body||(g?g.body:""),S=l.kind||(g?g.kind:"knowledge"),L=l.tags||(g?g.tags.join(", "):""),T=l._creating,k=y=>{let N=lt.find(I=>I.key===y);d(I=>({...I,template:y,kind:N?N.kind:I.kind,body:N?N.body:I.body,tags:N?N.tags.join(", "):I.tags}))},B=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${F}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||"\u65E0\u6807\u9898",kind:S,tags:L.split(",").map(N=>N.trim()).filter(Boolean),body:i,source:"manual"})}).then(N=>N.json())).ok?(d(null),x&&x()):d(N=>({...N,_creating:!1}))}catch{d(N=>({...N,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ce}),(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:[lt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>k(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:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:S,onChange:y=>d(N=>({...N,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(N=>({...N,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:L,onChange:y=>d(N=>({...N,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(N=>({...N,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:T,onClick:B,children:t(T?"exporting":"createCard")})})]})]})]})}function Xt({t,card:l,query:d,onClose:x,onDelete:g,onFeedback:i}){(0,o.useEffect)(()=>{let k=B=>{B.key==="Escape"&&x()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[x]);let[S,L]=(0,o.useState)(!1),T=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:x,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",onClick:k=>k.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")]})]}),T&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>L(k=>!k),children:t(S?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&g&&g(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:x,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:S?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ta(l.text)}})]})]})}function Vt({t,onOpen:l,all:d,onAllChange:x,onMutate:g,active:i}){let[S,L]=(0,o.useState)(null),[T,k]=(0,o.useState)(""),B=(0,o.useCallback)(async()=>{try{let A=await(await fetch(`${F}/graph${d?"?all=1":""}`)).json();A.ok?(L(A),k("")):(L(null),k(A.error||t("error")))}catch(I){k(String(I&&I.message?I.message:I))}},[d,t]);(0,o.useEffect)(()=>{if(!i){L(null),k("");return}let I=!0;return fetch(`${F}/graph${d?"?all=1":""}`).then(A=>A.json()).then(A=>{I&&(A.ok?(L(A),k("")):(L(null),k(A.error||t("error"))))}).catch(A=>{I&&k(String(A&&A.message?A.message:A))}),()=>{I=!1,L(null),k("")}},[d,t,i]);let y=(0,o.useCallback)(async I=>{try{let h=await(await fetch(`${F}/delete?path=${encodeURIComponent(I)}`)).json();return h&&h.ok?(await B(),g&&g(),!0):!1}catch{return!1}},[B]),N=(0,o.useCallback)(async I=>{if(!I||I.length<2)return!1;try{let A=await fetch(`${F}/merge?paths=${encodeURIComponent(I.join(","))}`).then(h=>h.json());return A&&A.ok?(await B(),g&&g(),!0):!1}catch{return!1}},[B,g]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ce}),T&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T]}),!S&&!T&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),S&&S.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),S&&S.nodes.length>0&&(0,e.jsx)(Jt,{nodes:S.nodes,edges:S.edges,onOpen:l,onDelete:y,onMerge:N,t,all:d,onAllChange:x,countLabel:`${S.nodes.length} ${t("nodes")} \xB7 ${Gt(S.edges)} ${t("edges")}`})]})}function Gt(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var _e={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 Jt({nodes:t,edges:l,onOpen:d,onDelete:x,onMerge:g,t:i,countLabel:S,all:L,onAllChange:T}){let k=(0,o.useRef)(null),B=(0,o.useRef)(null),y=(0,o.useRef)(null),N=(0,o.useRef)(null),I=(0,o.useRef)(null),A=(0,o.useRef)(d);(0,o.useEffect)(()=>{A.current=d},[d]);let h=(0,o.useRef)(x);(0,o.useEffect)(()=>{h.current=x},[x]);let K=(0,o.useRef)(g);(0,o.useEffect)(()=>{K.current=g},[g]);let[U,Se]=(0,o.useState)(""),[P,Y]=(0,o.useState)(null),$=(0,o.useRef)("");(0,o.useEffect)(()=>{$.current=U.trim().toLowerCase()},[U]),(0,o.useEffect)(()=>{let r=y.current;if(!r)return;let n=U.trim().toLowerCase();if(!n)return;let M=r.nodes.find(V=>(V.name||"").toLowerCase().includes(n));M&&(y.current.selectedId=M.id,Y(M.id),r.panX=r.w/2-M.x*r.zoom,r.panY=r.h/2-M.y*r.zoom,r.render&&r.render())},[U]);let[re,te]=(0,o.useState)("all"),[he,b]=(0,o.useState)(!1),u=(0,o.useRef)("all"),[w,W]=(0,o.useState)(""),H=(0,o.useRef)(""),[Q,ee]=(0,o.useState)(!1),q=(0,o.useRef)(!1),[Z,xe]=(0,o.useState)(null);(0,o.useEffect)(()=>{u.current=re},[re]),(0,o.useEffect)(()=>{H.current=w},[w]),(0,o.useEffect)(()=>{q.current=Q},[Q]);let pe=(0,o.useMemo)(()=>{let r=new Map;for(let n of t)for(let M of n.tags||[]){let V=String(M).trim();V&&r.set(V,(r.get(V)||0)+1)}return[...r.entries()].sort((n,M)=>M[1]-n[1]).slice(0,24).map(([n,M])=>({tag:n,n:M}))},[t]),Ke=(()=>{let r=U.trim().toLowerCase();return!!r&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(r)||String(n.kind||"").toLowerCase().includes(r)||String(De[n.kind]||"").toLowerCase().includes(r))})();(0,o.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[U]),(0,o.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[re,w,Q]);let we=(0,o.useRef)(null),[ne,oe]=(0,o.useState)([]),[m,E]=(0,o.useState)(null),[_,se]=(0,o.useState)(!1),[be,Ie]=(0,o.useState)(null),[Le,Ee]=(0,o.useState)(""),de=(0,o.useRef)(null),Re=(0,o.useRef)(null),ie=(r,n=!0)=>{de.current&&clearTimeout(de.current),Ie({msg:r,ok:n}),de.current=setTimeout(()=>Ie(null),1900)},qe=r=>{Ee(r),Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>Ee(""),1600)};(0,o.useEffect)(()=>()=>{de.current&&clearTimeout(de.current),Re.current&&clearTimeout(Re.current)},[]);let ve=(0,o.useMemo)(()=>t.reduce((r,n)=>(r[n.id]=n,r),{}),[t]);return(0,o.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let n=r.getContext("2d");if(!n)return;let M=Math.max(1,window.devicePixelRatio||1),V=()=>document.documentElement.getAttribute("data-theme")==="dark",c={};l.forEach(s=>{c[s.source]=(c[s.source]||0)+1,c[s.target]=(c[s.target]||0)+1});let z=Math.max(1,...Object.values(c)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(c[s.id]||0)/z*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:M,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,v)=>(s[v.id]=v,s),{}),a.nodes.forEach((s,v)=>{let f=v/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let ae=[...new Set(a.nodes.map(s=>s.type))];a.clustered=ae.length>1,a.typeCenters={},ae.forEach((s,v)=>{let f=v/ae.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),y.current=a;let ye=()=>{let s=r.clientWidth,v=r.clientHeight;a.w=s,a.h=v,r.width=s*M,r.height=v*M,n.setTransform(M,0,0,M,0,0)};ye();let Te=new ResizeObserver(ye);Te.observe(r.parentElement);let Xe=(s,v)=>s&&s.length>v?s.slice(0,v)+"\u2026":s,je=(s,v,f,C)=>{if(n.beginPath(),C==="rect")n.rect(s-f,v-f*.75,f*2,f*1.5);else if(C==="diamond")n.moveTo(s,v-f),n.lineTo(s+f,v),n.lineTo(s,v+f),n.lineTo(s-f,v),n.closePath();else if(C==="hexagon"){for(let D=0;D<6;D++){let X=Math.PI/3*D-Math.PI/2,O=s+f*Math.cos(X),me=v+f*Math.sin(X);D===0?n.moveTo(O,me):n.lineTo(O,me)}n.closePath()}else n.arc(s,v,f,0,Math.PI*2)},Fe=()=>{if(!a.nodes.length)return;let s=1/0,v=-1/0,f=1/0,C=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),v=Math.max(v,p.x),f=Math.min(f,p.y),C=Math.max(C,p.y)});let D=20,X=v-s+D*2,O=C-f+D*2,me=Math.min(a.w/X,a.h/O);a.zoom=Math.max(.35,Math.min(1.8,me)),a.panX=a.w/2-(s+v)/2*a.zoom,a.panY=a.h/2-(f+C)/2*a.zoom};N.current=Fe;let Be=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=$.current,a.kindFilter=u.current,a.timeMode=q.current,a.tagFilter=H.current;let s=a.tagFilter,v=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");n.save(),n.strokeStyle=V()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let p=0;p<a.w;p+=24)n.beginPath(),n.moveTo(p,0),n.lineTo(p,a.h),n.stroke();for(let p=0;p<a.h;p+=24)n.beginPath(),n.moveTo(0,p),n.lineTo(a.w,p),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let C={};a.nodes.forEach(p=>C[p.id]=p);let D=a.nodes.length>40,X=D?1.5:.55,O=a.selectedId||a.hoverId;a.edges.forEach(p=>{let G=C[p.sourceNodeId],R=C[p.targetNodeId];if(!G||!R)return;if(v!=="all"){let et=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,fe=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(et!==v&&fe!==v)return}if(s){let et=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),fe=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!et&&!fe)return}let j=R.x-G.x,J=R.y-G.y,le=Math.sqrt(j*j+J*J)||1,ce=D?12:18,ue=-J/le*ce,ge=j/le*ce,Me=(G.x+R.x)/2+ue,Ne=(G.y+R.y)/2+ge,ze=_e.colors[a.domainById[G.id]&&a.domainById[G.id].kind||"other"],$e=O&&(p.sourceNodeId===O||p.targetNodeId===O),ot=O?$e?.6:.08:D?.14:.24,it=parseInt(ze.slice(1,3),16),Ge=parseInt(ze.slice(3,5),16),Qe=parseInt(ze.slice(5,7),16);n.strokeStyle="rgba("+it+","+Ge+","+Qe+","+ot+")",n.lineWidth=$e?1.6+(p.weight||1):.8+(p.weight||1)*.5,n.beginPath(),n.moveTo(G.x,G.y),n.quadraticCurveTo(Me,Ne,R.x,R.y),n.stroke()});let me=[];if(a.nodes.forEach(p=>{let G=a.domainById[p.id]||{},R=G.kind||"other",j=a.timeMode?Zt(G.updated):_e.colors[R],J=_e.shapes[R],le=a.selectedId===p.id,ce=a.hoverId===p.id,ue=a.searchTerm||"",ge=!ue||(p.name||"").toLowerCase().includes(ue)||String(De[R]||"").toLowerCase().includes(ue)||String(R).toLowerCase().includes(ue),Me=v==="all"||R===v,Ne=!s||(G.tags||[]).includes(s),ze=O&&p.id!==O&&!a.edges.some(fe=>fe.sourceNodeId===O&&fe.targetNodeId===p.id||fe.targetNodeId===O&&fe.sourceNodeId===p.id)||ue&&!ge||!Me||!Ne;n.save(),n.globalAlpha=ze?.08:1,(le||ce)&&(n.shadowColor=j,n.shadowBlur=le?20:14),je(p.x,p.y,p.r,J);let $e=parseInt(j.slice(1,3),16),ot=parseInt(j.slice(3,5),16),it=parseInt(j.slice(5,7),16),Ge=n.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);Ge.addColorStop(0,"rgba("+Math.min(255,$e+70)+","+Math.min(255,ot+70)+","+Math.min(255,it+70)+",0.95)"),Ge.addColorStop(1,j),n.fillStyle=Ge,n.fill(),n.restore(),le?(n.save(),je(p.x,p.y,p.r+3,J),n.strokeStyle=j,n.lineWidth=3,n.shadowColor=j,n.shadowBlur=12,n.stroke(),n.restore()):ce?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle=j,n.lineWidth=2,n.stroke(),n.restore()):ue&&ge?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(p.id)>=0&&(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Qe=Xe(p.name,16);if((le||ce||a.zoom>X||!D&&a.zoom>.6)&&Me&&Ne){let fe=1/a.zoom;n.font="500 "+(12*fe).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ae=n.measureText(Qe).width+16*fe,tt=18*fe,Pe=p.y+p.r+8*fe,yt=!0;for(let Oe of me)if(p.x-Ae/2<Oe.x+Oe.w&&p.x+Ae/2>Oe.x&&Pe<Oe.y+Oe.h&&Pe+tt>Oe.y){yt=!1;break}if(!yt&&!le&&!ce)return;me.push({x:p.x-Ae/2,y:Pe,w:Ae,h:tt}),n.fillStyle=V()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(p.x-Ae/2,Pe,Ae,tt,4*fe):n.rect(p.x-Ae/2,Pe,Ae,tt),n.fill(),n.strokeStyle=V()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*fe,n.stroke(),n.fillStyle=V()?le||ce?"#eee":"#bbb":le||ce?"#111":"#444",n.textAlign="center",n.fillText(Qe,p.x,Pe+13*fe)}}),n.restore(),a.marquee){let p=a.marquee,G=Math.min(p.sx,p.ex),R=Math.min(p.sy,p.ey),j=Math.abs(p.ex-p.sx),J=Math.abs(p.ey-p.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(G,R,j,J),n.strokeRect(G,R,j,J),n.restore()}if(a.hoverId&&we.current){let p=a.domainById[a.hoverId],G=a.nodes.find(function(R){return R.id===a.hoverId});if(p&&G){let R=a.edges.filter(function(le){return le.sourceNodeId===p.id||le.targetNodeId===p.id}).length,j=G.x*a.zoom+a.panX,J=G.y*a.zoom+a.panY;we.current.style.display="block",we.current.style.left=j+14+"px",we.current.style.top=J-6+"px",we.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+R+" \u8FDE\u63A5</span>"}}else we.current&&(we.current.style.display="none")},ke=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(dt))};a.wake=ke,a.render=Be;let st=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),C=s>1e3?3e3:s>100?2e3:s>50?1200:800,D=s>100?.002:.005,X=s>1e3?.012:s>100?.005:.01,O=s>1e3?6:s>200?12:24,me={};a.nodes.forEach(R=>me[R.id]=R);for(let R=0;R<s;R++){if(a.dragNode===a.nodes[R])continue;let j=a.nodes[R],J=0,le=0;for(let ge=0;ge<s;ge++){if(R===ge)continue;let Me=j.x-a.nodes[ge].x,Ne=j.y-a.nodes[ge].y,ze=Math.sqrt(Me*Me+Ne*Ne)||1,$e=C/(ze*ze);J+=Me/ze*$e,le+=Ne/ze*$e}if(a.clustered&&a.typeCenters[j.type]){let ge=a.typeCenters[j.type];J+=(ge.x-j.x)*.006,le+=(ge.y-j.y)*.006}else J-=j.x*X,le-=j.y*X;let ce=(j.vx+J)*f,ue=(j.vy+le)*f;ce=Math.max(-O,Math.min(O,ce)),ue=Math.max(-O,Math.min(O,ue)),j.vx=ce,j.vy=ue}a.edges.forEach(R=>{let j=me[R.sourceNodeId],J=me[R.targetNodeId];if(!j||!J)return;let le=J.x-j.x,ce=J.y-j.y,ue=Math.sqrt(le*le+ce*ce)||1,ge=(ue-100)*D,Me=le/ue*ge,Ne=ce/ue*ge;a.dragNode!==j&&(j.vx+=Me,j.vy+=Ne),a.dragNode!==J&&(J.vx-=Me,J.vy-=Ne)});let p=0;a.nodes.forEach(R=>{a.dragNode!==R&&(R.x+=R.vx,R.y+=R.vy,p+=R.vx*R.vx+R.vy*R.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Fe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},dt=()=>{if(a.running){try{st(),Be()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(dt)}},Ve=(s,v)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(v-f.top-a.panY)/a.zoom}},Je=s=>{let v=a.domainById[s];return!(!v||u.current!=="all"&&v.kind!==u.current||H.current&&!(v.tags||[]).includes(H.current))},Ze=(s,v,f)=>Math.max(v,Math.min(f,s)),ct=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let v=Ve(s.clientX,s.clientY),f=null;for(let C=a.nodes.length-1;C>=0;C--){let D=a.nodes[C];if(!Je(D.id))continue;let X=D.x-v.x,O=D.y-v.y;if(X*X+O*O<D.r*D.r+36){f=D.id;break}}f!==a.hoverId&&(a.hoverId=f,ke())},pt=s=>{if(s.button!==0)return;let v=Ve(s.clientX,s.clientY),f=null;for(let C=a.nodes.length-1;C>=0;C--){let D=a.nodes[C];if(!Je(D.id))continue;let X=D.x-v.x,O=D.y-v.y;if(X*X+O*O<D.r*D.r+25){f=D;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-v.x,dy:f.y-v.y})},mt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ke();return}if(!a.dragStart)return;let v=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(v)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let C=Ve(s.clientX,s.clientY);a.dragNode.x=C.x+a.dragOffset.dx,a.dragNode.y=C.y+a.dragOffset.dy,ke()}else a.dragging&&(a.panX=Ze(a.dragStart.px+v,-1e5,1e5),a.panY=Ze(a.dragStart.py+f,-1e5,1e5),ke())},ut=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let C=r.getBoundingClientRect(),D=Math.min(f.sx,f.ex)-C.left,X=Math.max(f.sx,f.ex)-C.left,O=Math.min(f.sy,f.ey)-C.top,me=Math.max(f.sy,f.ey)-C.top,p=a.nodes.filter(G=>{let R=G.x*a.zoom+a.panX,j=G.y*a.zoom+a.panY;return R>=D&&R<=X&&j>=O&&j<=me}).map(G=>G.id);a.multi=p,oe(p),ke();return}let v=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let C=Array.isArray(a.multi)?a.multi.slice():[];C.includes(f)||C.push(f),a.multi=C,oe(C),ke();return}if(v){let f=Ve(s.clientX,s.clientY),C=null;for(let D=a.nodes.length-1;D>=0;D--){let X=a.nodes[D];if(!Je(X.id))continue;let O=X.x-f.x,me=X.y-f.y;if(O*O+me*me<X.r*X.r+20){C=X;break}}C?(a.selectedId=C.id,Y(C.id),ke()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],oe([])),Y(null),ke())}a.dragStart=null,a.dragging=!1,a.dragNode=null},gt=s=>{s.preventDefault();let v=Ve(s.clientX,s.clientY),f=null;for(let C=a.nodes.length-1;C>=0;C--){let D=a.nodes[C];if(!Je(D.id))continue;let X=D.x-v.x,O=D.y-v.y;if(X*X+O*O<D.r*D.r+25){f=D;break}}if(f){let C=a.domainById[f.id];C&&xe({x:s.clientX,y:s.clientY,id:f.id,path:C.id,title:C.title})}else xe(null)},ft=s=>{s.preventDefault();let v=r.getBoundingClientRect(),f=(s.clientX-v.left-a.panX)/a.zoom,C=(s.clientY-v.top-a.panY)/a.zoom,D=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=Ze(a.panX+f*(a.zoom-D),-1e5,1e5),a.panY=Ze(a.panY+C*(a.zoom-D),-1e5,1e5),a.zoom=D,ke()};r.addEventListener("mousemove",ct),r.addEventListener("mousedown",pt),window.addEventListener("mousemove",mt),window.addEventListener("mouseup",ut),r.addEventListener("wheel",ft,{passive:!1}),r.addEventListener("contextmenu",gt),I.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],oe([]),Fe(),ke()};for(let s=0;s<200;s++)st();Fe(),ke();let bt=()=>b(!1);return window.addEventListener("mousedown",bt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Te.disconnect(),r.removeEventListener("mousemove",ct),r.removeEventListener("mousedown",pt),window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",ut),r.removeEventListener("wheel",ft),r.removeEventListener("contextmenu",gt),window.removeEventListener("mousedown",bt)}},[t,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:U,onChange:r=>Se(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>b(r=>!r),"aria-expanded":he,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",re!=="all"||Q||w?"\u25CF":"\u25BE"]}),he&&(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${re==="all"&&!Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{te("all"),ee(!1)},children:i("all")}),Object.keys(Ue).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${re===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>te(n=>n===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[r]||Ue[r]}}),i(De[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${Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ee(r=>!r),children:["\u23F1 ",i("timeDim")]}),pe.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:pe.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${w===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>W(n=>n===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(re!=="all"||Q||w)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{te("all"),ee(!1),W("")},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:!!L,onChange:r=>T&&T(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${Q?" me-on":""}`,onClick:()=>ee(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(n=>{n&&E({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>N.current&&N.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Y(null),te("all"),I.current&&I.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:we,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)"}}),Ke&&(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")}),Z&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),Z&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:Z.x,top:Z.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{A.current({path:Z.path,title:Z.title}),xe(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Z.id&&(y.current.selectedId=Z.id,Y(Z.id)),xe(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(Z.title||"")}catch{}xe(null),ie(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,n=r&&Array.isArray(r.multi)?r.multi.slice():[],M=Z.id;if(M&&!n.includes(M)&&n.push(M),xe(null),n.length<2){ie(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let V=K.current&&K.current(n);V&&V.then?V.then(c=>c?ie(i("merged")):ie(i("mergeFail"),!1)).catch(()=>ie(i("mergeFail"),!1)):V&&ie(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Z.path;xe(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(h.current?await h.current(r):!1)?ie(i("deleted")):ie(i("deleteFail"),!1)}catch{ie(i("deleteFail"),!1)}})()},children:i("delete")})]}),ne.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:[ne.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=ne.map(z=>ve[z]).filter(Boolean).map(z=>z.title||z.name).join(`
|
|
182
|
+
`),M=new Blob([n],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(M),c=document.createElement("a");c.href=V,c.download="memory-selected.txt",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(V),1e3),ie(ne.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(ne.length<2){ie(i("mergeNeed"),!1);return}let r=ne.map(M=>ve[M]?ve[M].id:M);if(!window.confirm(i("mergeConfirm")))return;oe([]);let n=y.current;n&&(n.multi=[]),fetch(`${F}/merge?paths=${encodeURIComponent(r.join(","))}`).then(M=>M.json()).then(M=>{M&&M.ok?ie(i("merged")):ie(i("mergeFail"),!1)}).catch(()=>ie(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=ne.map(M=>ve[M]?ve[M].id:M);oe([]);let n=y.current;n&&(n.multi=[]),(async()=>{let M=0;for(let V of r)try{(h.current?await h.current(V):!1)&&M++}catch{}ie(M+i("deletedSelected"),M>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=y.current;r&&(r.multi=[]),oe([]);let n=y.current;n&&n.render&&n.render()},children:i("clearSelection")})]}),P&&(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:ve[P]?ve[P].title||ve[P].name:P}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ve[P]?i(De[ve[P].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===P||r.target===P)||[]).slice(0,8).map((r,n)=>{let M=r.source===P?r.target:r.source,V=ve[M];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:c=>{c.preventDefault();let z=y.current;z&&(z.selectedId=M,z.hoverId=M,z.wake&&z.wake()),Y(M)},children:V?(V.title||V.name).slice(0,28):M},n)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),be&&(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 "+(be.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:be.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:be.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:be.msg})]}),m&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{m.url&&URL.revokeObjectURL(m.url),E(null),se(!1)},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:_?"100vw":900,width:_?"100vw":"92vw",maxHeight:_?"100vh":"90vh",height:_?"100vh":void 0,borderRadius:_?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:m.url,download:"memory-graph.png",onClick:()=>{qe("download"),ie(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(Le==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{qe("full"),se(r=>!r),ie(i("fullscreen"))},children:i(Le==="full"?"done":_?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=m.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{qe("copy"),ie(i("copied"))}).catch(()=>{ie(i("copyFail"),!1)}):ie(i("copyFail"),!1)},children:i(Le==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{m.url&&URL.revokeObjectURL(m.url),E(null),se(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:_?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:m.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:_?"calc(100vh - 64px)":"70vh",borderRadius:_?0:8,cursor:"zoom-in"},onClick:()=>se(r=>!r)})})]})]})]})}function Zt(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let d=(Date.now()-l)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function vt({label:t,value:l=[],options:d,onChange:x,placeholder:g,z:i=20}){let[S,L]=(0,o.useState)(!1),T=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!S)return;let h=K=>{T.current&&!T.current.contains(K.target)&&L(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[S]);let k=Array.isArray(l)?l:[],B=k.includes("__all__"),y=B?d.find(h=>h.value==="__all__")?.label||"":k.length?k.map(h=>d.find(K=>K.value===h)?.label||h).join("\u3001"):"",N=(h,K)=>{if(h.value==="__all__"){x(K?["__all__"]:[]);return}let U=new Set(k);U.has("__all__")&&U.delete("__all__"),K?U.add(h.value):U.delete(h.value),x([...U])},I=d.find(h=>h.value==="__all__"),A=d.filter(h=>h.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:T,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>L(h=>!h),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:y||g||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),S&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[I&&(0,e.jsxs)("label",{onClick:h=>h.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:B,onChange:h=>N(I,h.target.checked)}),(0,e.jsx)("span",{children:I.label})]}),A.map(h=>(0,e.jsxs)("label",{onClick:K=>K.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:k.includes(h.value),onChange:K=>N(h,K.target.checked)}),(0,e.jsx)("span",{children:h.label})]},h.value))]})]})]})}function Qt(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function ea(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),S=await i.createWritable();return await S.write(t),await S.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let x=URL.createObjectURL(t),g=document.createElement("a");return g.href=x,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),setTimeout(()=>URL.revokeObjectURL(x),1e3),{ok:!0,picked:!1,name:l}}function wt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),x=l.toLowerCase(),g=[],i=0;for(;i<t.length;){let S=d.indexOf(x,i);if(S<0){g.push(t.slice(i));break}S>i&&g.push(t.slice(i,S)),g.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(S,S+x.length)},S)),i=S+x.length}return g}function ta(t){if(!t)return"";let l=String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),d=[];return l=l.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(x,g,i){return d.push("<pre><code>"+i+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(x,g,i){return"<h"+g.length+">"+i+"</h"+g.length+">"}),l=l.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),l=l.replace(/`([^`\n]+)`/g,"<code>$1</code>"),l=l.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),l=l.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(x,g,i){return/^(https?:|\/)/.test(i)?'<a href="'+i+'" target="_blank" rel="noopener noreferrer">'+g+"</a>":g}),l=l.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),l=l.replace(/^\s*(>)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),l=l.replace(/\n/g,"<br/>"),l=l.replace(/\u0000(\d+)\u0000/g,function(x,g){return d[g]}),l}function zt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,x=l.toDateString()===d.toDateString(),g=S=>String(S).padStart(2,"0"),i=`${g(l.getHours())}:${g(l.getMinutes())}`;return x?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
|
|
183
183
|
|
|
184
184
|
return module.exports;
|
|
185
185
|
},
|