memory-eternal 0.3.7 → 0.3.8

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