dsh-memory-eternal 0.4.7 → 0.4.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.
Files changed (2) hide show
  1. package/lib/client.js +9 -5
  2. package/package.json +1 -1
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 st=Object.create;var Pe=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var mt=(o,s)=>{for(var m in s)Pe(o,m,{get:s[m],enumerable:!0})},tt=(o,s,m,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of ct(s))!pt.call(o,n)&&n!==m&&Pe(o,n,{get:()=>s[n],enumerable:!(u=lt(s,n))||u.enumerable});return o};var ut=(o,s,m)=>(m=o!=null?st(dt(o)):{},tt(s||!o||!o.__esModule?Pe(m,"default",{value:o,enumerable:!0}):m,o)),gt=o=>tt(Pe({},"__esModule",{value:!0}),o);var Bt={};mt(Bt,{apply:()=>xt,inject:()=>ft});module.exports=gt(Bt);var c=ut(require("react"),1),e=require("react/jsx-runtime"),Be="memory-eternal",U="/memory-eternal/api",ft=["settingsScope","slots","locale","connection","remote"],bt={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",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",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",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}",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"},ht={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",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear 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",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}",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"},yt=["all","project","knowledge","content","prompt","business","tool","mistake"],We={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},ve={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},we=`
6
+ var it=Object.create;var Pe=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var pt=(o,i)=>{for(var g in i)Pe(o,g,{get:i[g],enumerable:!0})},tt=(o,i,g,h)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of lt(i))!ct.call(o,n)&&n!==g&&Pe(o,n,{get:()=>i[n],enumerable:!(h=st(i,n))||h.enumerable});return o};var mt=(o,i,g)=>(g=o!=null?it(dt(o)):{},tt(i||!o||!o.__esModule?Pe(g,"default",{value:o,enumerable:!0}):g,o)),ut=o=>tt(Pe({},"__esModule",{value:!0}),o);var Lt={};pt(Lt,{apply:()=>yt,inject:()=>gt});module.exports=ut(Lt);var d=mt(require("react"),1),e=require("react/jsx-runtime"),Be="memory-eternal",A="/memory-eternal/api",gt=["settingsScope","slots","locale","connection","remote"],ft={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",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",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",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}",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"},bt={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",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear 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",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}",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"},ht=["all","project","knowledge","content","prompt","business","tool","mistake"],We={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},xe={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},ve=`
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; }
@@ -19,6 +19,10 @@ var st=Object.create;var Pe=Object.defineProperty;var lt=Object.getOwnPropertyDe
19
19
  .mc-btn:hover { opacity: 0.85; }
20
20
  .mc-tabs { display: inline-flex; gap: 4px; padding: 3px; background: var(--dsw-alias-bg-base, #f3f4f6); border-radius: 999px; }
21
21
  .mc-tab { border: 0; background: transparent; color: inherit; border-radius: 999px; padding: 5px 14px; font-size: 12px; cursor: pointer; opacity: 0.7; }
22
+ .mc-viewbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
23
+ .mc-view { flex: 1; border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); background: var(--dsw-alias-bg-base, #f3f4f6); color: var(--dsw-alias-label-secondary, #6b7280); border-radius: 12px; padding: 11px 16px; font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.18s ease; }
24
+ .mc-view.active { background: var(--dsw-alias-brand-primary, #3b82f6); border-color: transparent; color: #fff; box-shadow: 0 8px 22px rgba(59,130,246,0.32); }
25
+ .mc-view:not(.active):hover { border-color: var(--dsw-alias-brand-primary, #3b82f6); color: var(--dsw-alias-label-primary, #111); }
22
26
  .mc-tab.active { background: var(--dsw-alias-bg-layer-1, #fff); opacity: 1; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
23
27
  .mc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
24
28
  .mc-chip { border: 1px solid var(--dsw-alias-border-l2, #d1d5db); background: transparent; color: inherit; border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; opacity: 0.7; }
@@ -57,7 +61,7 @@ var st=Object.create;var Pe=Object.defineProperty;var lt=Object.getOwnPropertyDe
57
61
 
58
62
  /* ---- full library modal ---- */
59
63
  .me-overlay-top { position: fixed; inset: 0; z-index: 1001; background: rgba(0,0,0,0.55); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 28px; }
60
- .me-modal { width: min(1340px, 97vw); height: min(96vh, 1020px); display: flex; flex-direction: column; background: var(--dsw-alias-bg-overlay, #fff); color: var(--dsw-alias-label-primary, #111); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 18px; box-shadow: 0 34px 90px rgba(0,0,0,0.5); overflow: hidden; animation: me-pop 0.22s cubic-bezier(0.2,0.8,0.2,1); }
64
+ .me-modal { width: min(1380px, 98vw); height: min(98vh, 1080px); display: flex; flex-direction: column; background: var(--dsw-alias-bg-overlay, #fff); color: var(--dsw-alias-label-primary, #111); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 18px; box-shadow: 0 34px 90px rgba(0,0,0,0.5); overflow: hidden; animation: me-pop 0.22s cubic-bezier(0.2,0.8,0.2,1); }
61
65
  @keyframes me-pop { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
62
66
  .me-modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--dsw-alias-border-l1, #e5e7eb); }
63
67
  .me-modal-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
@@ -105,12 +109,12 @@ var st=Object.create;var Pe=Object.defineProperty;var lt=Object.getOwnPropertyDe
105
109
  .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; }
106
110
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
107
111
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
108
- `;function xt(o){o.effect(()=>o.locale.register(Be,{zh:bt,en:ht}),"memory-eternal: locale");let s=o.locale.bind(Be);o.effect(()=>o.slots.inject("settings.section",()=>o.slots.register({name:"settings.section",id:Be,order:25,label:()=>s("nav"),locale:Be,inject:()=>({})},()=>c.default.createElement(nt,{t:s,inModal:!1}))),"memory-eternal: settings section"),o.effect(()=>o.slots.inject("sidebar.footer.action",()=>o.slots.register({name:"sidebar.footer.action",id:`${Be}:footer`,order:100,label:()=>s("nav"),locale:Be,inject:()=>({})},m=>c.default.createElement(vt,{t:s,wide:!(m&&m.wide===!1)}))),"memory-eternal: sidebar footer action")}function vt({t:o,wide:s}){let[m,u]=(0,c.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:we}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>u(!0),"aria-label":o("nav"),title:o("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(at,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:o("nav")})]}),m&&(0,e.jsx)(wt,{t:o,onClose:()=>u(!1)})]})}function at(){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 wt({t:o,onClose:s}){return(0,c.useEffect)(()=>{let m=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:we}),(0,e.jsx)("div",{className:"me-modal",onClick:m=>m.stopPropagation(),children:(0,e.jsx)(nt,{t:o,inModal:!0,onClose:s})})]})}function nt({t:o,inModal:s,onClose:m}){let[u,n]=(0,c.useState)(null),[g,I]=(0,c.useState)([]),[z,P]=(0,c.useState)(!0),[T,F]=(0,c.useState)(""),[_,me]=(0,c.useState)("all"),[V,ke]=(0,c.useState)(""),[A,ce]=(0,c.useState)("cards"),[Q,ue]=(0,c.useState)("recent"),[ne,R]=(0,c.useState)(null),W=(0,c.useRef)(null),h=(0,c.useRef)(null),[j,L]=(0,c.useState)(!1),[$,ye]=(0,c.useState)(!1),[ee,S]=(0,c.useState)(null),[H,G]=(0,c.useState)(null),[Ce,re]=(0,c.useState)(!1),de=(0,c.useRef)(null),[fe,Ne]=(0,c.useState)(24),xe=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(A!=="cards")return;let d=xe.current;if(!d)return;let x=new IntersectionObserver(f=>{f[0]&&f[0].isIntersecting&&Ne(t=>t+24)},{rootMargin:"400px"});return x.observe(d),()=>x.disconnect()},[A,g,_,V]);let Fe=(0,c.useCallback)(async(d=_,x=V)=>{try{P(!0),F("");let f=new URLSearchParams;d&&d!=="all"&&f.set("kind",d),x.trim()&&f.set("q",x.trim());let q=await(await fetch(`${U}/cards?${f.toString()}`)).json();q.ok&&(I(q.cards||[]),Ne(24))}catch(f){F(String(f&&f.message?f.message:f))}finally{P(!1)}},[_,V]),te=(0,c.useCallback)(async()=>{try{let[d,x]=await Promise.all([fetch(`${U}/overview`).then(f=>f.json()),fetch(`${U}/cards`).then(f=>f.json())]);d.ok&&n(d),x.ok&&(I(x.cards||[]),Ne(24))}catch(d){F(String(d&&d.message?d.message:d))}finally{P(!1)}},[]),be=async d=>{try{let f=await(await fetch(`${U}/delete?path=${encodeURIComponent(d)}`)).json();f.ok?(R({ok:!0,msg:o("deleted")}),await te()):R({ok:!1,msg:f.error||o("deleteFail")})}catch{R({ok:!1,msg:o("deleteFail")})}W.current&&clearTimeout(W.current),W.current=setTimeout(()=>R(null),2e3)};(0,c.useEffect)(()=>(te(),()=>{de.current&&clearTimeout(de.current)}),[te]);let O=d=>{ke(d),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>Fe(_,d),280)},Me=d=>{me(d),Fe(d,V)},J=async d=>{try{let f=await(await fetch(`${U}/card?path=${encodeURIComponent(d.path||d.id)}`)).json();f.ok&&S({path:f.path,title:d.title,text:f.text})}catch(x){F(String(x&&x.message?x.message:x))}},i=async(d,x)=>{L(!0);try{let f=await fetch(`${U}/export`);if(!f.ok)throw new Error("HTTP "+f.status);let t=await f.json();if(!t.ok)throw new Error(t.error||"export failed");let q,Se,Ie;d==="json"?(Se="memory-vault.json",Ie="application/json",q=JSON.stringify(t.cards.map(se=>({path:se.path,title:se.title,kind:se.kind,text:se.text})),null,2)):(Se="memory-vault.md",Ie="text/markdown;charset=utf-8",q=t.cards.map(se=>se.text.trim()).filter(Boolean).join(`
112
+ `;function yt(o){o.effect(()=>o.locale.register(Be,{zh:ft,en:bt}),"memory-eternal: locale");let i=o.locale.bind(Be);o.effect(()=>o.slots.inject("settings.section",()=>o.slots.register({name:"settings.section",id:Be,order:25,label:()=>i("nav"),locale:Be,inject:()=>({})},()=>d.default.createElement(nt,{t:i,inModal:!1}))),"memory-eternal: settings section"),o.effect(()=>o.slots.inject("sidebar.footer.action",()=>o.slots.register({name:"sidebar.footer.action",id:`${Be}:footer`,order:100,label:()=>i("nav"),locale:Be,inject:()=>({})},g=>d.default.createElement(xt,{t:i,wide:!(g&&g.wide===!1)}))),"memory-eternal: sidebar footer action")}function xt({t:o,wide:i}){let[g,h]=(0,d.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:ve}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>h(!0),"aria-label":o("nav"),title:o("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(at,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:o("nav")})]}),g&&(0,e.jsx)(vt,{t:o,onClose:()=>h(!1)})]})}function at(){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 vt({t:o,onClose:i}){let[g,h]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let n=u=>{u.key==="Escape"&&i()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[i]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:i,children:[(0,e.jsx)("style",{children:ve}),(0,e.jsx)("div",{className:"me-modal",onClick:n=>n.stopPropagation(),style:g?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(nt,{t:o,inModal:!0,onClose:i,onFull:()=>h(n=>!n),full:g})})]})}function nt({t:o,inModal:i,onClose:g,onFull:h,full:n}){let[u,T]=(0,d.useState)(null),[M,D]=(0,d.useState)([]),[R,$]=(0,d.useState)(!0),[ne,ee]=(0,d.useState)(""),[V,we]=(0,d.useState)("all"),[O,me]=(0,d.useState)(""),[X,le]=(0,d.useState)("cards"),[de,G]=(0,d.useState)("recent"),[K,m]=(0,d.useState)(null),S=(0,d.useRef)(null),B=(0,d.useRef)(null),[L,ue]=(0,d.useState)(!1),[Q,z]=(0,d.useState)(null),[H,_]=(0,d.useState)(null),[ke,re]=(0,d.useState)(!1),ce=(0,d.useRef)(null),[fe,Ce]=(0,d.useState)(24),Ne=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(X!=="cards")return;let c=Ne.current;if(!c)return;let v=new IntersectionObserver(f=>{f[0]&&f[0].isIntersecting&&Ce(t=>t+24)},{rootMargin:"400px"});return v.observe(c),()=>v.disconnect()},[X,M,V,O]);let Ee=(0,d.useCallback)(async(c=V,v=O)=>{try{$(!0),ee("");let f=new URLSearchParams;c&&c!=="all"&&f.set("kind",c),v.trim()&&f.set("q",v.trim());let Y=await(await fetch(`${A}/cards?${f.toString()}`)).json();Y.ok&&(D(Y.cards||[]),Ce(24))}catch(f){ee(String(f&&f.message?f.message:f))}finally{$(!1)}},[V,O]),te=(0,d.useCallback)(async()=>{try{let[c,v]=await Promise.all([fetch(`${A}/overview`).then(f=>f.json()),fetch(`${A}/cards`).then(f=>f.json())]);c.ok&&T(c),v.ok&&(D(v.cards||[]),Ce(24))}catch(c){ee(String(c&&c.message?c.message:c))}finally{$(!1)}},[]),be=async c=>{try{let f=await(await fetch(`${A}/delete?path=${encodeURIComponent(c)}`)).json();f.ok?(m({ok:!0,msg:o("deleted")}),await te()):m({ok:!1,msg:f.error||o("deleteFail")})}catch{m({ok:!1,msg:o("deleteFail")})}S.current&&clearTimeout(S.current),S.current=setTimeout(()=>m(null),2e3)};(0,d.useEffect)(()=>(te(),()=>{ce.current&&clearTimeout(ce.current)}),[te]);let W=c=>{me(c),ce.current&&clearTimeout(ce.current),ce.current=setTimeout(()=>Ee(V,c),280)},Fe=c=>{we(c),Ee(c,O)},J=async c=>{try{let f=await(await fetch(`${A}/card?path=${encodeURIComponent(c.path||c.id)}`)).json();f.ok&&z({path:f.path,title:c.title,text:f.text})}catch(v){ee(String(v&&v.message?v.message:v))}},l=async(c,v)=>{ue(!0);try{let f=await fetch(`${A}/export`);if(!f.ok)throw new Error("HTTP "+f.status);let t=await f.json();if(!t.ok)throw new Error(t.error||"export failed");let Y,Me,Se;c==="json"?(Me="memory-vault.json",Se="application/json",Y=JSON.stringify(t.cards.map(ie=>({path:ie.path,title:ie.title,kind:ie.kind,text:ie.text})),null,2)):(Me="memory-vault.md",Se="text/markdown;charset=utf-8",Y=t.cards.map(ie=>ie.text.trim()).filter(Boolean).join(`
109
113
 
110
114
  ---
111
115
 
112
- `));let Ye=new Blob([q],{type:Ie}),ie=await rt(Ye,Se,x);if(!ie.ok){R({ok:!1,msg:ie.aborted?o("exportCancel"):o("exportFail")}),L(!1);return}R({ok:!0,msg:ie.picked?o("exportedTo")+"\uFF1A"+ie.name:o("exportedTo")+"\uFF1A"+o("defaultDownloads")+" \xB7 "+ie.name})}catch(f){R({ok:!1,msg:o("exportFail")+" \xB7 "+(f.message||"")})}finally{L(!1)}W.current&&clearTimeout(W.current),W.current=setTimeout(()=>R(null),2600)},a=async d=>{let x=d.target.files&&d.target.files[0];if(d.target.value="",!!x){try{let f=await x.text(),q=await(await fetch(`${U}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:f})).json();q.ok?(await te(),R({ok:!0,msg:o("importedVault")+"\uFF1A"+(q.imported||0)+(q.skipped?o("importedSkipped")+q.skipped:"")})):R({ok:!1,msg:q.error||o("importFail")})}catch{R({ok:!1,msg:o("importFail")})}W.current&&clearTimeout(W.current),W.current=setTimeout(()=>R(null),2400)}},N=(0,c.useMemo)(()=>{let d=g.slice();return Q==="title"?d.sort((x,f)=>String(x.title||"").localeCompare(String(f.title||""))):Q==="hot"?d.sort((x,f)=>(f.weight||f.links||0)-(x.weight||x.links||0)):d.sort((x,f)=>new Date(f.updated||0).getTime()-new Date(x.updated||0).getTime()),d},[g,Q]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:we}),ne&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ne.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ne.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ne.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:ne.msg})]}),s&&(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)(at,{})}),(0,e.jsx)("h2",{children:o("memoryTitle")}),(0,e.jsx)("span",{children:o("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:m,"aria-label":o("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ae,{label:o("total"),value:u?u.total:"\u2014"}),(0,e.jsx)(Ae,{label:o("recent"),value:u?u.recent:"\u2014"}),(0,e.jsx)(Ae,{label:o("tags"),value:u?u.tags:"\u2014"}),(0,e.jsx)(Ae,{label:o("cardCount"),value:u?u.byKind?.knowledge??0:"\u2014"})]}),(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:o("searchPlaceholder"),value:V,onChange:d=>O(d.target.value)}),(0,e.jsxs)("div",{className:"mc-tabs",children:[(0,e.jsx)("button",{type:"button",className:`mc-tab${A==="cards"?" active":""}`,onClick:()=>ce("cards"),children:o("cardsTab")}),(0,e.jsx)("button",{type:"button",className:`mc-tab${A==="graph"?" active":""}`,onClick:()=>ce("graph"),children:o("graphTab")})]}),(0,e.jsx)("input",{ref:h,type:"file",accept:".json,application/json",style:{display:"none"},onChange:a}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h.current&&h.current.click(),children:o("importVault")}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("location"),children:[(0,e.jsx)("input",{type:"checkbox",checked:$,onChange:d=>ye(d.target.checked)}),o("location")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:j,onClick:()=>i("md",$),children:o(j?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:j,onClick:()=>i("json",$),children:o(j?"exporting":"exportJson")}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:Ce,onChange:d=>re(d.target.checked)}),o("crossVault")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>G({tab:"stats"}),children:o("manage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>te(),children:o("refresh")})]}),A==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[yt.map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${_===d?" active":""}`,onClick:()=>Me(d),children:o(d==="all"?"all":ve[d])},d)),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:o("sortRecent")},{key:"title",label:o("sortTitle")},{key:"hot",label:o("sortHot")}].map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${Q===d.key?" active":""}`,onClick:()=>ue(d.key),children:d.label},d.key))]}),T&&(0,e.jsxs)("div",{className:"mc-empty",children:[o("error"),"\uFF1A",T]}),A==="cards"?z&&!g.length?(0,e.jsx)("div",{className:"mc-empty",children:o("loading")}):g.length===0?(0,e.jsx)("div",{className:"mc-empty",children:o("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:N.slice(0,fe).map(d=>(0,e.jsx)(kt,{card:d,t:o,query:V.trim(),onOpen:J,onDelete:be},d.path))}),N.length>fe&&(0,e.jsx)("div",{ref:xe,style:{height:1}})]}):(0,e.jsx)(Mt,{t:o,onOpen:J,all:Ce}),ee&&(0,e.jsx)(Nt,{t:o,card:ee,onClose:()=>S(null),onDelete:d=>{S(null),be(d)}}),H&&(0,e.jsx)(Ct,{t:o,tab:H.tab,onTab:d=>G({tab:d}),onClose:()=>G(null),onReload:()=>te()})]})]})}var Ae=({label:o,value:s})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:s}),(0,e.jsx)("span",{children:o})]}),kt=({card:o,t:s,onOpen:m,query:u,onDelete:n})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>m(o),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:We[o.kind]||We.other}}),u?ot(o.title,u):o.title,Tt(o.updated)&&(0,e.jsx)("span",{className:"mc-new",children:s("newBadge")})]}),(0,e.jsx)("p",{children:u?ot(o.summary||"",u):o.summary||""}),o.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:o.tags.slice(0,4).map(g=>(0,e.jsx)("span",{className:"mc-tag",children:g},g))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:s(ve[o.kind])}),(0,e.jsx)("span",{children:it(o.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:s("delete"),onClick:g=>{g.stopPropagation(),window.confirm(s("deleteConfirm"))&&n&&n(o.path)},children:"\u2715"})]})]});function Ct({t:o,tab:s,onTab:m,onClose:u,onReload:n}){let[g,I]=(0,c.useState)(null),[z,P]=(0,c.useState)(null),[T,F]=(0,c.useState)(null),[_,me]=(0,c.useState)(""),[V,ke]=(0,c.useState)(""),A=(0,c.useCallback)(async()=>{try{let h=await fetch(`${U}/todayBrief`).then(j=>j.json());me(h.ok&&h.brief||"")}catch{}},[]),ce=(0,c.useCallback)(async()=>{if(!(!z||!z.merge||!z.merge.length)&&window.confirm(o("mergeAllConfirm"))){ke("merge");try{let h={},j=S=>h[S]===void 0?S:h[S]=j(h[S]),L=(S,H)=>{h[j(S)]=j(H)},$=new Set;for(let S of z.merge)$.add(S.a.path),$.add(S.b.path),L(S.a.path,S.b.path);let ye={};for(let S of $){let H=j(S);(ye[H]=ye[H]||[]).push(S)}let ee=0;for(let S of Object.values(ye)){if(S.length<2)continue;(await fetch(`${U}/merge?paths=${encodeURIComponent(S.join(","))}`).then(G=>G.json())).ok&&ee++}await Q(),n&&n()}catch{}ke("")}},[z,Q,n,o]);async function Q(){try{let[h,j,L]=await Promise.all([fetch(`${U}/stats`).then($=>$.json()),fetch(`${U}/optimize`).then($=>$.json()),fetch(`${U}/budget`).then($=>$.json())]);h.ok&&I(h),j.ok&&P(j),L.ok&&F(L)}catch{}}(0,c.useEffect)(()=>{Q()},[]);let ue=async(h,j)=>{if(window.confirm(o("mergeConfirm")))try{(await fetch(`${U}/merge?paths=${encodeURIComponent(h+","+j)}`).then($=>$.json())).ok&&(await Q(),n&&n())}catch{}},ne=async h=>{if(window.confirm(o("deleteConfirm")))try{(await fetch(`${U}/delete?path=${encodeURIComponent(h)}`).then(L=>L.json())).ok&&(await Q(),n&&n())}catch{}},R=["project","knowledge","content","prompt","business","tool","mistake"],W=({title:h,kind:j,updated:L,path:$})=>(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:Ee.colors[j]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:it(L)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ne($),children:[o("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"me-overlay",onClick:u,children:[(0,e.jsx)("style",{children:we}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720,width:"94vw",maxHeight:"86vh"},onClick:h=>h.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"button",className:`mc-tab${s==="stats"?" active":""}`,onClick:()=>m("stats"),children:o("tabUsage")}),(0,e.jsx)("button",{type:"button",className:`mc-tab${s==="optimize"?" active":""}`,onClick:()=>m("optimize"),children:o("tabOptimize")})]}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:u,children:o("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{overflow:"auto"},children:[s==="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:o("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:A,children:o("todayBrief")}),_&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:_})]}),g&&(0,e.jsxs)(e.Fragment,{children:[(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:o("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.today}),(0,e.jsx)("span",{children:o("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.week}),(0,e.jsx)("span",{children:o("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.tags}),(0,e.jsx)("span",{children:o("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:o("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:R.map(h=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[h]||"#666"}}),o(ve[h]),": ",g.byKind?.[h]||0]},h))})]}),T&&(T.budgetChars||T.recallLimit||T.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:o("budgetLabel")}),"\uFF1A",o("budgetChars")," ",(0,e.jsx)("b",{children:T.budgetChars||8e4})," \xB7 ",o("recallLimitLabel")," ",(0,e.jsx)("b",{children:T.recallLimit||5})," \xB7 ",o("embeddingLabel")," ",T.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[o("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(h=>(0,e.jsx)(W,{title:h.title,kind:h.kind,updated:h.updated,path:h.path},h.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:o("noOptimize")})]})]})]}),s==="optimize"&&(0,e.jsx)("div",{children:z&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:z.merge?.length?o("mergePairs"):o("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),z.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!V,onClick:ce,children:o(V==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:o("mergePairs")}),z.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:z.merge.map((h,j)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[h.a.title," \u21C4 ",h.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(h.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ue(h.a.path,h.b.path),children:o("mergeNow")})]},j))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:o("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[o("staleCards"),"\uFF08",z.stale?.length||0,"\uFF09"]}),z.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.stale.map(h=>(0,e.jsx)(W,{title:h.title,kind:"other",updated:h.updated,path:h.path},h.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:o("noOptimize")})]})})]})]})]})}function Nt({t:o,card:s,onClose:m,onDelete:u}){(0,c.useEffect)(()=>{let z=P=>{P.key==="Escape"&&m()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[m]);let[n,g]=(0,c.useState)(!1),I=(s.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:m,children:[(0,e.jsx)("style",{children:we}),(0,e.jsxs)("div",{className:"me-dialog",onClick:z=>z.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:s.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[I&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>g(z=>!z),children:o(n?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(o("deleteConfirm"))&&u&&u(s.path)},children:o("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:m,children:o("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:n?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Lt(s.text)}})]})]})}function Mt({t:o,onOpen:s,all:m}){let[u,n]=(0,c.useState)(null),[g,I]=(0,c.useState)(""),z=(0,c.useCallback)(async()=>{try{let F=await(await fetch(`${U}/graph${m?"?all=1":""}`)).json();n(F.ok?F:null),I("")}catch(T){I(String(T&&T.message?T.message:T))}},[m]);(0,c.useEffect)(()=>{let T=!0;return fetch(`${U}/graph${m?"?all=1":""}`).then(F=>F.json()).then(F=>{T&&n(F.ok?F:null)}).catch(F=>{T&&I(String(F&&F.message?F.message:F))}),()=>{T=!1}},[m]);let P=(0,c.useCallback)(async T=>{try{let _=await(await fetch(`${U}/delete?path=${encodeURIComponent(T)}`)).json();return _&&_.ok?(await z(),!0):!1}catch{return!1}},[z]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:we}),g&&(0,e.jsxs)("div",{className:"mc-empty",children:[o("error"),"\uFF1A",g]}),!u&&!g&&(0,e.jsx)("div",{className:"mc-empty",children:o("loading")}),u&&u.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:o("emptyGraph")}),u&&u.nodes.length>0&&(0,e.jsx)(It,{nodes:u.nodes,edges:u.edges,onOpen:s,onDelete:P,t:o,countLabel:`${u.nodes.length} ${o("nodes")} \xB7 ${St(u.edges)} ${o("edges")}`})]})}function St(o){let s=new Set;for(let m of o||[])s.add([m.source,m.target].sort().join("|"));return s.size}var Ee={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 It({nodes:o,edges:s,onOpen:m,onDelete:u,t:n,countLabel:g}){let I=(0,c.useRef)(null),z=(0,c.useRef)(null),P=(0,c.useRef)(null),T=(0,c.useRef)(null),F=(0,c.useRef)(null),_=(0,c.useRef)(m);(0,c.useEffect)(()=>{_.current=m},[m]);let me=(0,c.useRef)(u);(0,c.useEffect)(()=>{me.current=u},[u]);let[V,ke]=(0,c.useState)(""),[A,ce]=(0,c.useState)(null),Q=(0,c.useRef)("");(0,c.useEffect)(()=>{Q.current=V.trim().toLowerCase()},[V]);let[ue,ne]=(0,c.useState)("all"),R=(0,c.useRef)("all"),[W,h]=(0,c.useState)(!1),j=(0,c.useRef)(!1),[L,$]=(0,c.useState)(null);(0,c.useEffect)(()=>{R.current=ue},[ue]),(0,c.useEffect)(()=>{j.current=W},[W]);let ye=(()=>{let i=V.trim().toLowerCase();return!!i&&!o.some(a=>(a.title||a.name||"").toLowerCase().includes(i)||String(a.kind||"").toLowerCase().includes(i)||String(ve[a.kind]||"").toLowerCase().includes(i))})();(0,c.useEffect)(()=>{let i=P.current;i&&i.wake&&i.wake()},[V]),(0,c.useEffect)(()=>{let i=P.current;i&&i.render&&i.render()},[ue,W]);let ee=(0,c.useRef)(null),[S,H]=(0,c.useState)([]),[G,Ce]=(0,c.useState)(null),[re,de]=(0,c.useState)(!1),[fe,Ne]=(0,c.useState)(null),[xe,Fe]=(0,c.useState)(""),te=(0,c.useRef)(null),be=(0,c.useRef)(null),O=(i,a=!0)=>{te.current&&clearTimeout(te.current),Ne({msg:i,ok:a}),te.current=setTimeout(()=>Ne(null),1900)},Me=i=>{Fe(i),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>Fe(""),1600)};(0,c.useEffect)(()=>()=>{te.current&&clearTimeout(te.current),be.current&&clearTimeout(be.current)},[]);let J=(0,c.useMemo)(()=>o.reduce((i,a)=>(i[a.id]=a,i),{}),[o]);return(0,c.useEffect)(()=>{let i=I.current;if(!i||o.length===0)return;let a=i.getContext("2d");if(!a)return;let N=Math.max(1,window.devicePixelRatio||1),d=()=>document.documentElement.getAttribute("data-theme")==="dark",x={};s.forEach(r=>{x[r.source]=(x[r.source]||0)+1,x[r.target]=(x[r.target]||0)+1});let f=Math.max(1,...Object.values(x)),t={nodes:o.map(r=>({id:r.id,name:r.title||"",type:r.kind||"other",r:9+Math.min(10,(x[r.id]||0)/f*8),x:0,y:0,vx:0,vy:0})),edges:s.map(r=>({sourceNodeId:r.source,targetNodeId:r.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:N,ctx:a,multi:[],marquee:null};t.domain=o,t.domainById=o.reduce((r,b)=>(r[b.id]=b,r),{}),t.nodes.forEach((r,b)=>{let p=b/t.nodes.length*Math.PI*2-Math.PI/2;r.x=Math.cos(p)*60,r.y=Math.sin(p)*60});let q=[...new Set(t.nodes.map(r=>r.type))];t.clustered=q.length>1,t.typeCenters={},q.forEach((r,b)=>{let p=b/q.length*Math.PI*2-Math.PI/2;t.typeCenters[r]={x:Math.cos(p)*160,y:Math.sin(p)*160}}),P.current=t;let Se=()=>{let r=i.clientWidth,b=i.clientHeight;t.w=r,t.h=b,i.width=r*N,i.height=b*N,a.setTransform(N,0,0,N,0,0)};Se();let Ie=new ResizeObserver(Se);Ie.observe(i.parentElement);let Ye=(r,b)=>r&&r.length>b?r.slice(0,b)+"\u2026":r,ie=(r,b,p,y)=>{if(a.beginPath(),y==="rect")a.rect(r-p,b-p*.75,p*2,p*1.5);else if(y==="diamond")a.moveTo(r,b-p),a.lineTo(r+p,b),a.lineTo(r,b+p),a.lineTo(r-p,b),a.closePath();else if(y==="hexagon"){for(let v=0;v<6;v++){let C=Math.PI/3*v-Math.PI/2,B=r+p*Math.cos(C),l=b+p*Math.sin(C);v===0?a.moveTo(B,l):a.lineTo(B,l)}a.closePath()}else a.arc(r,b,p,0,Math.PI*2)},se=()=>{if(!t.nodes.length)return;let r=1/0,b=-1/0,p=1/0,y=-1/0;t.nodes.forEach(M=>{r=Math.min(r,M.x),b=Math.max(b,M.x),p=Math.min(p,M.y),y=Math.max(y,M.y)});let v=36,C=b-r+v*2,B=y-p+v*2,l=Math.min(t.w/C,t.h/B);t.zoom=Math.max(.45,Math.min(2.4,l*1.22)),t.panX=t.w/2-(r+b)/2*t.zoom,t.panY=t.h/2-(p+y)/2*t.zoom};T.current=se;let Ue=()=>{a.clearRect(0,0,t.w,t.h),t.searchTerm=Q.current,t.kindFilter=R.current,t.timeMode=j.current;let r=t.kindFilter,b=l=>String(l||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.save(),a.strokeStyle=d()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",a.lineWidth=.5;for(let l=0;l<t.w;l+=24)a.beginPath(),a.moveTo(l,0),a.lineTo(l,t.h),a.stroke();for(let l=0;l<t.h;l+=24)a.beginPath(),a.moveTo(0,l),a.lineTo(t.w,l),a.stroke();a.restore(),a.save(),a.translate(t.panX,t.panY),a.scale(t.zoom,t.zoom);let p={};t.nodes.forEach(l=>p[l.id]=l);let y=t.nodes.length>40,v=y?1.5:.55,C=t.selectedId||t.hoverId;t.edges.forEach(l=>{let M=p[l.sourceNodeId],E=p[l.targetNodeId];if(!M||!E)return;if(r!=="all"){let Z=t.domainById[l.sourceNodeId]&&t.domainById[l.sourceNodeId].kind,Qe=t.domainById[l.targetNodeId]&&t.domainById[l.targetNodeId].kind;if(Z!==r&&Qe!==r)return}let w=E.x-M.x,k=E.y-M.y,D=Math.sqrt(w*w+k*k)||1,Y=y?12:18,X=-k/D*Y,oe=w/D*Y,K=(M.x+E.x)/2+X,pe=(M.y+E.y)/2+oe,ae=Ee.colors[t.domainById[M.id]&&t.domainById[M.id].kind||"other"],ge=C&&(l.sourceNodeId===C||l.targetNodeId===C),ze=C?ge?.6:.08:y?.14:.24,je=parseInt(ae.slice(1,3),16),De=parseInt(ae.slice(3,5),16),Ze=parseInt(ae.slice(5,7),16);a.strokeStyle="rgba("+je+","+De+","+Ze+","+ze+")",a.lineWidth=ge?1.6+(l.weight||1):.8+(l.weight||1)*.5,a.beginPath(),a.moveTo(M.x,M.y),a.quadraticCurveTo(K,pe,E.x,E.y),a.stroke()});let B=[];if(t.nodes.forEach(l=>{let M=t.domainById[l.id]||{},E=M.kind||"other",w=t.timeMode?zt(M.updated):Ee.colors[E],k=Ee.shapes[E],D=t.selectedId===l.id,Y=t.hoverId===l.id,X=t.searchTerm||"",oe=!X||(l.name||"").toLowerCase().includes(X)||String(ve[E]||"").toLowerCase().includes(X)||String(E).toLowerCase().includes(X),K=r==="all"||E===r,pe=C&&l.id!==C&&!t.edges.some(Z=>Z.sourceNodeId===C&&Z.targetNodeId===l.id||Z.targetNodeId===C&&Z.sourceNodeId===l.id)||X&&!oe||!K;a.save(),a.globalAlpha=pe?.08:1,(D||Y)&&(a.shadowColor=w,a.shadowBlur=D?20:14),ie(l.x,l.y,l.r,k);let ae=parseInt(w.slice(1,3),16),ge=parseInt(w.slice(3,5),16),ze=parseInt(w.slice(5,7),16),je=a.createRadialGradient(l.x-l.r*.3,l.y-l.r*.3,0,l.x,l.y,l.r*1.2);je.addColorStop(0,"rgba("+Math.min(255,ae+70)+","+Math.min(255,ge+70)+","+Math.min(255,ze+70)+",0.95)"),je.addColorStop(1,w),a.fillStyle=je,a.fill(),a.restore(),D?(a.save(),ie(l.x,l.y,l.r+3,k),a.strokeStyle=w,a.lineWidth=3,a.shadowColor=w,a.shadowBlur=12,a.stroke(),a.restore()):Y?(a.save(),ie(l.x,l.y,l.r+2,k),a.strokeStyle=w,a.lineWidth=2,a.stroke(),a.restore()):X&&oe?(a.save(),ie(l.x,l.y,l.r+2,k),a.strokeStyle="#e11d48",a.lineWidth=2,a.stroke(),a.restore()):t.multi.indexOf(l.id)>=0&&(a.save(),ie(l.x,l.y,l.r+2,k),a.strokeStyle="#60a5fa",a.lineWidth=2,a.shadowColor="#60a5fa",a.shadowBlur=8,a.stroke(),a.restore());let De=Ye(l.name,16);if((D||Y||t.zoom>v||!y&&t.zoom>.6)&&K){let Z=1/t.zoom;a.font="500 "+(12*Z).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let he=a.measureText(De).width+16*Z,Oe=18*Z,Te=l.y+l.r+8*Z,et=!0;for(let Le of B)if(l.x-he/2<Le.x+Le.w&&l.x+he/2>Le.x&&Te<Le.y+Le.h&&Te+Oe>Le.y){et=!1;break}if(!et&&!D&&!Y)return;B.push({x:l.x-he/2,y:Te,w:he,h:Oe}),a.fillStyle=d()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",a.beginPath(),a.roundRect?a.roundRect(l.x-he/2,Te,he,Oe,4*Z):a.rect(l.x-he/2,Te,he,Oe),a.fill(),a.strokeStyle=d()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",a.lineWidth=1*Z,a.stroke(),a.fillStyle=d()?D||Y?"#eee":"#bbb":D||Y?"#111":"#444",a.textAlign="center",a.fillText(De,l.x,Te+13*Z)}}),a.restore(),t.marquee){let l=t.marquee,M=Math.min(l.sx,l.ex),E=Math.min(l.sy,l.ey),w=Math.abs(l.ex-l.sx),k=Math.abs(l.ey-l.sy);a.save(),a.setLineDash([4,4]),a.strokeStyle="rgba(96,165,250,0.9)",a.lineWidth=1,a.fillStyle="rgba(96,165,250,0.12)",a.fillRect(M,E,w,k),a.strokeRect(M,E,w,k),a.restore()}if(t.hoverId&&ee.current){let l=t.domainById[t.hoverId],M=t.nodes.find(function(E){return E.id===t.hoverId});if(l&&M){let E=t.edges.filter(function(D){return D.sourceNodeId===l.id||D.targetNodeId===l.id}).length,w=M.x*t.zoom+t.panX,k=M.y*t.zoom+t.panY;ee.current.style.display="block",ee.current.style.left=w+14+"px",ee.current.style.top=k-6+"px",ee.current.innerHTML="<b>"+b(l.title||l.name||"")+'</b><br/><span style="opacity:.8">'+b(l.kind||"")+" \xB7 "+E+" \u8FDE\u63A5</span>"}}else ee.current&&(ee.current.style.display="none")},le=()=>{t.running=!0,t.raf||(t.raf=requestAnimationFrame(Xe))};t.wake=le,t.render=Ue;let qe=()=>{let r=t.nodes.length;t.tickCount++;let p=.9-Math.min(.4,t.tickCount/1500),y=r>1e3?3e3:r>100?2e3:r>50?1200:800,v=r>100?.002:.005,C=r>1e3?.012:r>100?.005:.01,B=r>1e3?6:r>200?12:24,l={};t.nodes.forEach(w=>l[w.id]=w);for(let w=0;w<r;w++){if(t.dragNode===t.nodes[w])continue;let k=t.nodes[w],D=0,Y=0;for(let K=0;K<r;K++){if(w===K)continue;let pe=k.x-t.nodes[K].x,ae=k.y-t.nodes[K].y,ge=Math.sqrt(pe*pe+ae*ae)||1,ze=y/(ge*ge);D+=pe/ge*ze,Y+=ae/ge*ze}if(t.clustered&&t.typeCenters[k.type]){let K=t.typeCenters[k.type];D+=(K.x-k.x)*.006,Y+=(K.y-k.y)*.006}else D-=k.x*C,Y-=k.y*C;let X=(k.vx+D)*p,oe=(k.vy+Y)*p;X=Math.max(-B,Math.min(B,X)),oe=Math.max(-B,Math.min(B,oe)),k.vx=X,k.vy=oe}t.edges.forEach(w=>{let k=l[w.sourceNodeId],D=l[w.targetNodeId];if(!k||!D)return;let Y=D.x-k.x,X=D.y-k.y,oe=Math.sqrt(Y*Y+X*X)||1,K=(oe-100)*v,pe=Y/oe*K,ae=X/oe*K;t.dragNode!==k&&(k.vx+=pe,k.vy+=ae),t.dragNode!==D&&(D.vx-=pe,D.vy-=ae)});let M=0;t.nodes.forEach(w=>{t.dragNode!==w&&(w.x+=w.vx,w.y+=w.vy,M+=w.vx*w.vx+w.vy*w.vy)}),t.autoFitPending&&t.tickCount>45&&(t.autoFitPending=!1,se()),(r?Math.sqrt(M/r):0)<.05&&t.tickCount>60&&!t.dragNode?t.quietTicks=(t.quietTicks|0)+1:t.quietTicks=0},Xe=()=>{if(t.running){try{qe(),Ue()}catch{}if(t.quietTicks>30){t.raf=0;return}t.raf=requestAnimationFrame(Xe)}},Re=(r,b)=>{let p=i.getBoundingClientRect();return{x:(r-p.left-t.panX)/t.zoom,y:(b-p.top-t.panY)/t.zoom}},$e=(r,b,p)=>Math.max(b,Math.min(p,r)),Ke=r=>{t.mouseX=r.clientX,t.mouseY=r.clientY;let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let v=t.nodes[y];if(R.current!=="all"&&(t.domainById[v.id]&&t.domainById[v.id].kind)!==R.current)continue;let C=v.x-b.x,B=v.y-b.y;if(C*C+B*B<v.r*v.r+36){p=v.id;break}}p!==t.hoverId&&(t.hoverId=p,le())},Ve=r=>{if(r.button!==0)return;let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let v=t.nodes[y];if(R.current!=="all"&&(t.domainById[v.id]&&t.domainById[v.id].kind)!==R.current)continue;let C=v.x-b.x,B=v.y-b.y;if(C*C+B*B<v.r*v.r+25){p=v;break}}if(r.shiftKey){t.marquee={sx:r.clientX,sy:r.clientY,ex:r.clientX,ey:r.clientY};return}t.dragStart={x:r.clientX,y:r.clientY,px:t.panX,py:t.panY},t.dragging=!1,t.dragNode=p||null,p&&(t.dragOffset={dx:p.x-b.x,dy:p.y-b.y})},He=r=>{if(t.marquee){t.marquee.ex=r.clientX,t.marquee.ey=r.clientY,le();return}if(!t.dragStart)return;let b=r.clientX-t.dragStart.x,p=r.clientY-t.dragStart.y;if(Math.abs(b)+Math.abs(p)>3&&(t.dragging=!0),t.dragNode){let y=Re(r.clientX,r.clientY);t.dragNode.x=y.x+t.dragOffset.dx,t.dragNode.y=y.y+t.dragOffset.dy,le()}else t.dragging&&(t.panX=$e(t.dragStart.px+b,-1e5,1e5),t.panY=$e(t.dragStart.py+p,-1e5,1e5),le())},Ge=r=>{if(t.marquee){let p=t.marquee;t.marquee=null;let y=i.getBoundingClientRect(),v=Math.min(p.sx,p.ex)-y.left,C=Math.max(p.sx,p.ex)-y.left,B=Math.min(p.sy,p.ey)-y.top,l=Math.max(p.sy,p.ey)-y.top,M=t.nodes.filter(E=>{let w=E.x*t.zoom+t.panX,k=E.y*t.zoom+t.panY;return w>=v&&w<=C&&k>=B&&k<=l}).map(E=>E.id);t.multi=M,H(M),le();return}if(t.dragStart&&!t.dragging){let p=Re(r.clientX,r.clientY),y=null;for(let v=t.nodes.length-1;v>=0;v--){let C=t.nodes[v];if(R.current!=="all"&&(t.domainById[C.id]&&t.domainById[C.id].kind)!==R.current)continue;let B=C.x-p.x,l=C.y-p.y;if(B*B+l*l<C.r*C.r+20){y=C;break}}y?(t.selectedId=y.id,ce(y.id),le()):(t.selectedId=null,t.hoverId=null,r.shiftKey||(t.multi=[],H([])),ce(null),le())}t.dragStart=null,t.dragging=!1,t.dragNode=null},_e=r=>{r.preventDefault();let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let v=t.nodes[y];if(R.current!=="all"&&(t.domainById[v.id]&&t.domainById[v.id].kind)!==R.current)continue;let C=v.x-b.x,B=v.y-b.y;if(C*C+B*B<v.r*v.r+25){p=v;break}}if(p){let y=t.domainById[p.id];y&&$({x:r.clientX,y:r.clientY,id:p.id,path:y.id,title:y.title})}else $(null)},Je=r=>{r.preventDefault();let b=i.getBoundingClientRect(),p=(r.clientX-b.left-t.panX)/t.zoom,y=(r.clientY-b.top-t.panY)/t.zoom,v=Math.max(.3,Math.min(3,t.zoom*(r.deltaY<0?1.1:1/1.1)));t.panX=$e(t.panX+p*(t.zoom-v),-1e5,1e5),t.panY=$e(t.panY+y*(t.zoom-v),-1e5,1e5),t.zoom=v,le()};i.addEventListener("mousemove",Ke),i.addEventListener("mousedown",Ve),window.addEventListener("mousemove",He),window.addEventListener("mouseup",Ge),i.addEventListener("wheel",Je,{passive:!1}),i.addEventListener("contextmenu",_e),F.current=()=>{t.selectedId=null,t.hoverId=null,t.multi=[],H([]),se(),le()};for(let r=0;r<200;r++)qe();return se(),le(),()=>{t.running=!1,t.raf&&cancelAnimationFrame(t.raf),Ie.disconnect(),i.removeEventListener("mousemove",Ke),i.removeEventListener("mousedown",Ve),window.removeEventListener("mousemove",He),window.removeEventListener("mouseup",Ge),i.removeEventListener("wheel",Je),i.removeEventListener("contextmenu",_e)}},[o,s]),(0,e.jsxs)("div",{className:"me-graph",ref:z,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[o.length," ",n("nodes")," \xB7 ",s.length," ",n("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",className:"mc-btn",style:{padding:"6px 10px",minWidth:140},placeholder:n("search"),value:V,onChange:i=>ke(i.target.value)}),(0,e.jsx)("button",{type:"button",className:`mc-btn${W?" me-on":""}`,onClick:()=>h(i=>!i),children:n("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let i=I.current;if(i)try{i.toBlob(a=>{a&&Ce({url:URL.createObjectURL(a),blob:a})},"image/png")}catch{}},children:n("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>T.current&&T.current(),children:n("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ce(null),ne("all"),F.current&&F.current()},children:n("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:I,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ee,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)"}}),(0,e.jsxs)("div",{className:"me-graph-legend",style:{position:"absolute",left:12,bottom:8,zIndex:2},children:[W?[{c:"#10b981",l:n("timeNew")},{c:"#f59e0b",l:n("timeRecent")},{c:"#f97316",l:n("timeMonth")},{c:"#94a3b8",l:n("timeOld")}].map(i=>(0,e.jsxs)("span",{className:"lg",children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:i.c}}),i.l]},i.c)):Object.keys(We).map(i=>(0,e.jsxs)("button",{type:"button",className:`lg${ue===i?" active":""}`,onClick:()=>ne(a=>a===i?"all":i),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[i]||We[i]}}),n(ve[i])]},i)),!W&&ue!=="all"&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",onClick:()=>ne("all"),children:[n("clearFilter")," \u2715"]})]}),ye&&(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:n("noMatch")}),L&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>$(null)}),L&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:L.x,top:L.y,zIndex:31},onMouseDown:i=>i.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{_.current({path:L.path,title:L.title}),$(null)},children:n("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{L.id&&(P.current.selectedId=L.id,ce(L.id)),$(null);let i=P.current;i&&i.wake&&i.wake()},children:n("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(L.title||"")}catch{}$(null),O(n("copied"))},children:n("copyName")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let i=L.path;$(null),window.confirm(n("deleteConfirm"))&&(async()=>{try{(me.current?await me.current(i):!1)?O(n("deleted")):O(n("deleteFail"),!1)}catch{O(n("deleteFail"),!1)}})()},children:n("delete")})]}),S.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:[S.length," ",n("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let a=S.map(f=>J[f]).filter(Boolean).map(f=>f.title||f.name).join(`
113
- `),N=new Blob([a],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(N),x=document.createElement("a");x.href=d,x.download="memory-selected.txt",document.body.appendChild(x),x.click(),document.body.removeChild(x),setTimeout(()=>URL.revokeObjectURL(d),1e3),O(S.length+n("exportedSel"))},children:n("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(S.length<2){O(n("mergeNeed"),!1);return}let i=S.map(N=>J[N]?J[N].id:N);if(!window.confirm(n("mergeConfirm")))return;H([]);let a=P.current;a&&(a.multi=[]),fetch(`${U}/merge?paths=${encodeURIComponent(i.join(","))}`).then(N=>N.json()).then(N=>{N&&N.ok?O(n("merged")):O(n("mergeFail"),!1)}).catch(()=>O(n("mergeFail"),!1))},children:n("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(n("deleteConfirm")))return;let i=S.map(N=>J[N]?J[N].id:N);H([]);let a=P.current;a&&(a.multi=[]),(async()=>{let N=0;for(let d of i)try{(me.current?await me.current(d):!1)&&N++}catch{}O(N+n("deletedSelected"),N>0)})()},children:n("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let i=P.current;i&&(i.multi=[]),H([]);let a=P.current;a&&a.render&&a.render()},children:n("clearSelection")})]}),A&&(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:J[A]?J[A].title||J[A].name:A}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:J[A]?n(ve[J[A].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:n("graphHint")}),(s.filter(i=>i.source===A||i.target===A)||[]).slice(0,8).map((i,a)=>{let N=i.source===A?i.target:i.source,d=J[N];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:x=>{x.preventDefault();let f=P.current;f&&(f.selectedId=N,f.hoverId=N,f.wake&&f.wake()),ce(N)},children:d?(d.title||d.name).slice(0,28):N},a)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:n("graphTip")}),fe&&(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 "+(fe.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:fe.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:fe.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:fe.msg})]}),G&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{G.url&&URL.revokeObjectURL(G.url),Ce(null),de(!1)},children:[(0,e.jsx)("style",{children:we}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:re?"100vw":900,width:re?"100vw":"92vw",maxHeight:re?"100vh":"90vh",height:re?"100vh":void 0,borderRadius:re?0:14},onClick:i=>i.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:n("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:G.url,download:"memory-graph.png",onClick:()=>{Me("download"),O(n("downloaded")+" \xB7 "+n("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:n(xe==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Me("save");let i=G.blob;i&&typeof window.showSaveFilePicker=="function"?rt(i,"memory-graph.png",!0).then(a=>{a.ok?O(n("exportedTo")+"\uFF1A"+a.name):a.aborted?O(n("exportCancel")):O(n("exportFail"),!1)}):O(n("saveAsUnsupported"),!1)},children:n(xe==="save"?"done":"saveAs")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Me("full"),de(i=>!i),O(n("fullscreen"))},children:n(xe==="full"?"done":re?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let i=G.blob;i&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":i})]).then(()=>{Me("copy"),O(n("copied"))}).catch(()=>{O(n("copyFail"),!1)}):O(n("copyFail"),!1)},children:n(xe==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{G.url&&URL.revokeObjectURL(G.url),Ce(null),de(!1)},children:n("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:re?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:G.url,alt:n("exportGraph"),style:{maxWidth:"100%",maxHeight:re?"calc(100vh - 64px)":"70vh",borderRadius:re?0:8,cursor:"zoom-in"},onClick:()=>de(i=>!i)})})]})]})]})}function zt(o){let s=new Date(o||0).getTime();if(!s)return"#94a3b8";let m=(Date.now()-s)/864e5;return m<3?"#10b981":m<14?"#f59e0b":m<30?"#f97316":"#94a3b8"}function Tt(o){let s=new Date(o||0).getTime();return!!s&&(Date.now()-s)/864e5<3}async function rt(o,s,m){if(m&&typeof window.showSaveFilePicker=="function")try{let g=await window.showSaveFilePicker({suggestedName:s}),I=await g.createWritable();return await I.write(o),await I.close(),{ok:!0,picked:!0,name:g.name}}catch(g){return g&&g.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(g.message||g)}}let u=URL.createObjectURL(o),n=document.createElement("a");return n.href=u,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(u),1e3),{ok:!0,picked:!1,name:s}}function ot(o,s){if(!s||!o)return o;let m=o.toLowerCase(),u=s.toLowerCase(),n=[],g=0;for(;g<o.length;){let I=m.indexOf(u,g);if(I<0){n.push(o.slice(g));break}I>g&&n.push(o.slice(g,I)),n.push((0,e.jsx)("mark",{className:"mc-hl",children:o.slice(I,I+u.length)},I)),g=I+u.length}return n}function Lt(o){if(!o)return"";let s=String(o).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),m=[];return s=s.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(u,n,g){return m.push("<pre><code>"+g+"</code></pre>"),"\0"+(m.length-1)+"\0"}),s=s.replace(/^(#{1,3})\s+(.+)$/gm,function(u,n,g){return"<h"+n.length+">"+g+"</h"+n.length+">"}),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/`([^`\n]+)`/g,"<code>$1</code>"),s=s.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(u,n,g){return/^(https?:|\/)/.test(g)?'<a href="'+g+'" target="_blank" rel="noopener noreferrer">'+n+"</a>":n}),s=s.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),s=s.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),s=s.replace(/\n/g,"<br/>"),s=s.replace(/\u0000(\d+)\u0000/g,function(u,n){return m[n]}),s}function it(o){if(!o)return"";let s=new Date(o);if(Number.isNaN(s.getTime()))return"";let m=new Date,u=s.toDateString()===m.toDateString(),n=I=>String(I).padStart(2,"0"),g=`${n(s.getHours())}:${n(s.getMinutes())}`;return u?g:`${s.getMonth()+1}-${s.getDate()} ${g}`}
116
+ `));let Ye=new Blob([Y],{type:Se}),he=await Tt(Ye,Me,!1);if(!he.ok){m({ok:!1,msg:o("exportFail")}),ue(!1);return}m({ok:!0,msg:o("exportedTo")+"\uFF1A"+o("defaultDownloads")+" \xB7 "+he.name})}catch(f){m({ok:!1,msg:o("exportFail")+" \xB7 "+(f.message||"")})}finally{ue(!1)}S.current&&clearTimeout(S.current),S.current=setTimeout(()=>m(null),2600)},a=async c=>{let v=c.target.files&&c.target.files[0];if(c.target.value="",!!v){try{let f=await v.text(),Y=await(await fetch(`${A}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:f})).json();Y.ok?(await te(),m({ok:!0,msg:o("importedVault")+"\uFF1A"+(Y.imported||0)+(Y.skipped?o("importedSkipped")+Y.skipped:"")})):m({ok:!1,msg:Y.error||o("importFail")})}catch{m({ok:!1,msg:o("importFail")})}S.current&&clearTimeout(S.current),S.current=setTimeout(()=>m(null),2400)}},N=(0,d.useMemo)(()=>{let c=M.slice();return de==="title"?c.sort((v,f)=>String(v.title||"").localeCompare(String(f.title||""))):de==="hot"?c.sort((v,f)=>(f.weight||f.links||0)-(v.weight||v.links||0)):c.sort((v,f)=>new Date(f.updated||0).getTime()-new Date(v.updated||0).getTime()),c},[M,de]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:ve}),K&&(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 "+(K.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:K.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:K.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:K.msg})]}),i&&(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)(at,{})}),(0,e.jsx)("h2",{children:o("memoryTitle")}),(0,e.jsx)("span",{children:o("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),h&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:h,"aria-label":o(n?"exitFull":"fullscreen"),children:n?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:g,"aria-label":o("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:"mc-viewbar",children:[(0,e.jsxs)("button",{type:"button",className:`mc-view${X==="cards"?" active":""}`,onClick:()=>le("cards"),children:["\u{1F4C7} ",o("cardsTab")]}),(0,e.jsxs)("button",{type:"button",className:`mc-view${X==="graph"?" active":""}`,onClick:()=>le("graph"),children:["\u{1F578} ",o("graphTab")]})]}),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ae,{label:o("total"),value:u?u.total:"\u2014"}),(0,e.jsx)(Ae,{label:o("recent"),value:u?u.recent:"\u2014"}),(0,e.jsx)(Ae,{label:o("tags"),value:u?u.tags:"\u2014"}),(0,e.jsx)(Ae,{label:o("cardCount"),value:u?u.byKind?.knowledge??0:"\u2014"})]}),(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:o("searchPlaceholder"),value:O,onChange:c=>W(c.target.value)}),(0,e.jsx)("input",{ref:B,type:"file",accept:".json,application/json",style:{display:"none"},onChange:a}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>B.current&&B.current.click(),children:o("importVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:L,onClick:()=>l("md"),children:o(L?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:L,onClick:()=>l("json"),children:o(L?"exporting":"exportJson")}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:ke,onChange:c=>re(c.target.checked)}),o("crossVault")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>_({tab:"stats"}),children:o("manage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>te(),children:o("refresh")})]}),X==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ht.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${V===c?" active":""}`,onClick:()=>Fe(c),children:o(c==="all"?"all":xe[c])},c)),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:o("sortRecent")},{key:"title",label:o("sortTitle")},{key:"hot",label:o("sortHot")}].map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${de===c.key?" active":""}`,onClick:()=>G(c.key),children:c.label},c.key))]}),ne&&(0,e.jsxs)("div",{className:"mc-empty",children:[o("error"),"\uFF1A",ne]}),X==="cards"?R&&!M.length?(0,e.jsx)("div",{className:"mc-empty",children:o("loading")}):M.length===0?(0,e.jsx)("div",{className:"mc-empty",children:o("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:N.slice(0,fe).map(c=>(0,e.jsx)(wt,{card:c,t:o,query:O.trim(),onOpen:J,onDelete:be},c.path))}),N.length>fe&&(0,e.jsx)("div",{ref:Ne,style:{height:1}})]}):(0,e.jsx)(Nt,{t:o,onOpen:J,all:ke}),Q&&(0,e.jsx)(Ct,{t:o,card:Q,onClose:()=>z(null),onDelete:c=>{z(null),be(c)}}),H&&(0,e.jsx)(kt,{t:o,tab:H.tab,onTab:c=>_({tab:c}),onClose:()=>_(null),onReload:()=>te()})]})]})}var Ae=({label:o,value:i})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:i}),(0,e.jsx)("span",{children:o})]}),wt=({card:o,t:i,onOpen:g,query:h,onDelete:n})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>g(o),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:We[o.kind]||We.other}}),h?ot(o.title,h):o.title,zt(o.updated)&&(0,e.jsx)("span",{className:"mc-new",children:i("newBadge")})]}),(0,e.jsx)("p",{children:h?ot(o.summary||"",h):o.summary||""}),o.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:o.tags.slice(0,4).map(u=>(0,e.jsx)("span",{className:"mc-tag",children:u},u))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:i(xe[o.kind])}),(0,e.jsx)("span",{children:rt(o.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:i("delete"),onClick:u=>{u.stopPropagation(),window.confirm(i("deleteConfirm"))&&n&&n(o.path)},children:"\u2715"})]})]});function kt({t:o,tab:i,onTab:g,onClose:h,onReload:n}){let[u,T]=(0,d.useState)(null),[M,D]=(0,d.useState)(null),[R,$]=(0,d.useState)(null),[ne,ee]=(0,d.useState)(""),[V,we]=(0,d.useState)(""),O=(0,d.useCallback)(async()=>{try{let m=await fetch(`${A}/todayBrief`).then(S=>S.json());ee(m.ok&&m.brief||"")}catch{}},[]),me=(0,d.useCallback)(async()=>{if(!(!M||!M.merge||!M.merge.length)&&window.confirm(o("mergeAllConfirm"))){we("merge");try{let m={},S=z=>m[z]===void 0?z:m[z]=S(m[z]),B=(z,H)=>{m[S(z)]=S(H)},L=new Set;for(let z of M.merge)L.add(z.a.path),L.add(z.b.path),B(z.a.path,z.b.path);let ue={};for(let z of L){let H=S(z);(ue[H]=ue[H]||[]).push(z)}let Q=0;for(let z of Object.values(ue)){if(z.length<2)continue;(await fetch(`${A}/merge?paths=${encodeURIComponent(z.join(","))}`).then(_=>_.json())).ok&&Q++}await X(),n&&n()}catch{}we("")}},[M,X,n,o]);async function X(){try{let[m,S,B]=await Promise.all([fetch(`${A}/stats`).then(L=>L.json()),fetch(`${A}/optimize`).then(L=>L.json()),fetch(`${A}/budget`).then(L=>L.json())]);m.ok&&T(m),S.ok&&D(S),B.ok&&$(B)}catch{}}(0,d.useEffect)(()=>{X()},[]);let le=async(m,S)=>{if(window.confirm(o("mergeConfirm")))try{(await fetch(`${A}/merge?paths=${encodeURIComponent(m+","+S)}`).then(L=>L.json())).ok&&(await X(),n&&n())}catch{}},de=async m=>{if(window.confirm(o("deleteConfirm")))try{(await fetch(`${A}/delete?path=${encodeURIComponent(m)}`).then(B=>B.json())).ok&&(await X(),n&&n())}catch{}},G=["project","knowledge","content","prompt","business","tool","mistake"],K=({title:m,kind:S,updated:B,path:L})=>(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:Le.colors[S]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:rt(B)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>de(L),children:[o("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"me-overlay",onClick:h,children:[(0,e.jsx)("style",{children:ve}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720,width:"94vw",maxHeight:"86vh"},onClick:m=>m.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="stats"?" active":""}`,onClick:()=>g("stats"),children:o("tabUsage")}),(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="optimize"?" active":""}`,onClick:()=>g("optimize"),children:o("tabOptimize")})]}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:h,children:o("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{overflow:"auto"},children:[i==="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:o("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:O,children:o("todayBrief")}),ne&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:ne})]}),u&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.total}),(0,e.jsx)("span",{children:o("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.today}),(0,e.jsx)("span",{children:o("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.week}),(0,e.jsx)("span",{children:o("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.tags}),(0,e.jsx)("span",{children:o("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:o("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:G.map(m=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Le.colors[m]||"#666"}}),o(xe[m]),": ",u.byKind?.[m]||0]},m))})]}),R&&(R.budgetChars||R.recallLimit||R.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:o("budgetLabel")}),"\uFF1A",o("budgetChars")," ",(0,e.jsx)("b",{children:R.budgetChars||8e4})," \xB7 ",o("recallLimitLabel")," ",(0,e.jsx)("b",{children:R.recallLimit||5})," \xB7 ",o("embeddingLabel")," ",R.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[o("todayList"),"\uFF08",u.todayCards?.length||0,"\uFF09"]}),u.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:u.todayCards.map(m=>(0,e.jsx)(K,{title:m.title,kind:m.kind,updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:o("noOptimize")})]})]})]}),i==="optimize"&&(0,e.jsx)("div",{children:M&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:M.merge?.length?o("mergePairs"):o("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),M.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!V,onClick:me,children:o(V==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:o("mergePairs")}),M.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:M.merge.map((m,S)=>(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:[m.a.title," \u21C4 ",m.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(m.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>le(m.a.path,m.b.path),children:o("mergeNow")})]},S))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:o("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[o("staleCards"),"\uFF08",M.stale?.length||0,"\uFF09"]}),M.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:M.stale.map(m=>(0,e.jsx)(K,{title:m.title,kind:"other",updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:o("noOptimize")})]})})]})]})]})}function Ct({t:o,card:i,onClose:g,onDelete:h}){(0,d.useEffect)(()=>{let M=D=>{D.key==="Escape"&&g()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[g]);let[n,u]=(0,d.useState)(!1),T=(i.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:g,children:[(0,e.jsx)("style",{children:ve}),(0,e.jsxs)("div",{className:"me-dialog",onClick:M=>M.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[T&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>u(M=>!M),children:o(n?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(o("deleteConfirm"))&&h&&h(i.path)},children:o("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:g,children:o("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:n?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Bt(i.text)}})]})]})}function Nt({t:o,onOpen:i,all:g}){let[h,n]=(0,d.useState)(null),[u,T]=(0,d.useState)(""),M=(0,d.useCallback)(async()=>{try{let $=await(await fetch(`${A}/graph${g?"?all=1":""}`)).json();n($.ok?$:null),T("")}catch(R){T(String(R&&R.message?R.message:R))}},[g]);(0,d.useEffect)(()=>{let R=!0;return fetch(`${A}/graph${g?"?all=1":""}`).then($=>$.json()).then($=>{R&&n($.ok?$:null)}).catch($=>{R&&T(String($&&$.message?$.message:$))}),()=>{R=!1}},[g]);let D=(0,d.useCallback)(async R=>{try{let ne=await(await fetch(`${A}/delete?path=${encodeURIComponent(R)}`)).json();return ne&&ne.ok?(await M(),!0):!1}catch{return!1}},[M]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:ve}),u&&(0,e.jsxs)("div",{className:"mc-empty",children:[o("error"),"\uFF1A",u]}),!h&&!u&&(0,e.jsx)("div",{className:"mc-empty",children:o("loading")}),h&&h.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:o("emptyGraph")}),h&&h.nodes.length>0&&(0,e.jsx)(St,{nodes:h.nodes,edges:h.edges,onOpen:i,onDelete:D,t:o,countLabel:`${h.nodes.length} ${o("nodes")} \xB7 ${Mt(h.edges)} ${o("edges")}`})]})}function Mt(o){let i=new Set;for(let g of o||[])i.add([g.source,g.target].sort().join("|"));return i.size}var Le={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 St({nodes:o,edges:i,onOpen:g,onDelete:h,t:n,countLabel:u}){let T=(0,d.useRef)(null),M=(0,d.useRef)(null),D=(0,d.useRef)(null),R=(0,d.useRef)(null),$=(0,d.useRef)(null),ne=(0,d.useRef)(g);(0,d.useEffect)(()=>{ne.current=g},[g]);let ee=(0,d.useRef)(h);(0,d.useEffect)(()=>{ee.current=h},[h]);let[V,we]=(0,d.useState)(""),[O,me]=(0,d.useState)(null),X=(0,d.useRef)("");(0,d.useEffect)(()=>{X.current=V.trim().toLowerCase()},[V]);let[le,de]=(0,d.useState)("all"),G=(0,d.useRef)("all"),[K,m]=(0,d.useState)(!1),S=(0,d.useRef)(!1),[B,L]=(0,d.useState)(null);(0,d.useEffect)(()=>{G.current=le},[le]),(0,d.useEffect)(()=>{S.current=K},[K]);let ue=(()=>{let l=V.trim().toLowerCase();return!!l&&!o.some(a=>(a.title||a.name||"").toLowerCase().includes(l)||String(a.kind||"").toLowerCase().includes(l)||String(xe[a.kind]||"").toLowerCase().includes(l))})();(0,d.useEffect)(()=>{let l=D.current;l&&l.wake&&l.wake()},[V]),(0,d.useEffect)(()=>{let l=D.current;l&&l.render&&l.render()},[le,K]);let Q=(0,d.useRef)(null),[z,H]=(0,d.useState)([]),[_,ke]=(0,d.useState)(null),[re,ce]=(0,d.useState)(!1),[fe,Ce]=(0,d.useState)(null),[Ne,Ee]=(0,d.useState)(""),te=(0,d.useRef)(null),be=(0,d.useRef)(null),W=(l,a=!0)=>{te.current&&clearTimeout(te.current),Ce({msg:l,ok:a}),te.current=setTimeout(()=>Ce(null),1900)},Fe=l=>{Ee(l),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>Ee(""),1600)};(0,d.useEffect)(()=>()=>{te.current&&clearTimeout(te.current),be.current&&clearTimeout(be.current)},[]);let J=(0,d.useMemo)(()=>o.reduce((l,a)=>(l[a.id]=a,l),{}),[o]);return(0,d.useEffect)(()=>{let l=T.current;if(!l||o.length===0)return;let a=l.getContext("2d");if(!a)return;let N=Math.max(1,window.devicePixelRatio||1),c=()=>document.documentElement.getAttribute("data-theme")==="dark",v={};i.forEach(r=>{v[r.source]=(v[r.source]||0)+1,v[r.target]=(v[r.target]||0)+1});let f=Math.max(1,...Object.values(v)),t={nodes:o.map(r=>({id:r.id,name:r.title||"",type:r.kind||"other",r:9+Math.min(10,(v[r.id]||0)/f*8),x:0,y:0,vx:0,vy:0})),edges:i.map(r=>({sourceNodeId:r.source,targetNodeId:r.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:N,ctx:a,multi:[],marquee:null};t.domain=o,t.domainById=o.reduce((r,b)=>(r[b.id]=b,r),{}),t.nodes.forEach((r,b)=>{let p=b/t.nodes.length*Math.PI*2-Math.PI/2;r.x=Math.cos(p)*60,r.y=Math.sin(p)*60});let Y=[...new Set(t.nodes.map(r=>r.type))];t.clustered=Y.length>1,t.typeCenters={},Y.forEach((r,b)=>{let p=b/Y.length*Math.PI*2-Math.PI/2;t.typeCenters[r]={x:Math.cos(p)*160,y:Math.sin(p)*160}}),D.current=t;let Me=()=>{let r=l.clientWidth,b=l.clientHeight;t.w=r,t.h=b,l.width=r*N,l.height=b*N,a.setTransform(N,0,0,N,0,0)};Me();let Se=new ResizeObserver(Me);Se.observe(l.parentElement);let Ye=(r,b)=>r&&r.length>b?r.slice(0,b)+"\u2026":r,he=(r,b,p,y)=>{if(a.beginPath(),y==="rect")a.rect(r-p,b-p*.75,p*2,p*1.5);else if(y==="diamond")a.moveTo(r,b-p),a.lineTo(r+p,b),a.lineTo(r,b+p),a.lineTo(r-p,b),a.closePath();else if(y==="hexagon"){for(let x=0;x<6;x++){let C=Math.PI/3*x-Math.PI/2,E=r+p*Math.cos(C),s=b+p*Math.sin(C);x===0?a.moveTo(E,s):a.lineTo(E,s)}a.closePath()}else a.arc(r,b,p,0,Math.PI*2)},ie=()=>{if(!t.nodes.length)return;let r=1/0,b=-1/0,p=1/0,y=-1/0;t.nodes.forEach(I=>{r=Math.min(r,I.x),b=Math.max(b,I.x),p=Math.min(p,I.y),y=Math.max(y,I.y)});let x=36,C=b-r+x*2,E=y-p+x*2,s=Math.min(t.w/C,t.h/E);t.zoom=Math.max(.45,Math.min(2.4,s*1.22)),t.panX=t.w/2-(r+b)/2*t.zoom,t.panY=t.h/2-(p+y)/2*t.zoom};R.current=ie;let qe=()=>{a.clearRect(0,0,t.w,t.h),t.searchTerm=X.current,t.kindFilter=G.current,t.timeMode=S.current;let r=t.kindFilter,b=s=>String(s||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.save(),a.strokeStyle=c()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",a.lineWidth=.5;for(let s=0;s<t.w;s+=24)a.beginPath(),a.moveTo(s,0),a.lineTo(s,t.h),a.stroke();for(let s=0;s<t.h;s+=24)a.beginPath(),a.moveTo(0,s),a.lineTo(t.w,s),a.stroke();a.restore(),a.save(),a.translate(t.panX,t.panY),a.scale(t.zoom,t.zoom);let p={};t.nodes.forEach(s=>p[s.id]=s);let y=t.nodes.length>40,x=y?1.5:.55,C=t.selectedId||t.hoverId;t.edges.forEach(s=>{let I=p[s.sourceNodeId],F=p[s.targetNodeId];if(!I||!F)return;if(r!=="all"){let Z=t.domainById[s.sourceNodeId]&&t.domainById[s.sourceNodeId].kind,Qe=t.domainById[s.targetNodeId]&&t.domainById[s.targetNodeId].kind;if(Z!==r&&Qe!==r)return}let w=F.x-I.x,k=F.y-I.y,j=Math.sqrt(w*w+k*k)||1,P=y?12:18,q=-k/j*P,oe=w/j*P,U=(I.x+F.x)/2+q,pe=(I.y+F.y)/2+oe,ae=Le.colors[t.domainById[I.id]&&t.domainById[I.id].kind||"other"],ge=C&&(s.sourceNodeId===C||s.targetNodeId===C),Ie=C?ge?.6:.08:y?.14:.24,je=parseInt(ae.slice(1,3),16),De=parseInt(ae.slice(3,5),16),Ze=parseInt(ae.slice(5,7),16);a.strokeStyle="rgba("+je+","+De+","+Ze+","+Ie+")",a.lineWidth=ge?1.6+(s.weight||1):.8+(s.weight||1)*.5,a.beginPath(),a.moveTo(I.x,I.y),a.quadraticCurveTo(U,pe,F.x,F.y),a.stroke()});let E=[];if(t.nodes.forEach(s=>{let I=t.domainById[s.id]||{},F=I.kind||"other",w=t.timeMode?It(I.updated):Le.colors[F],k=Le.shapes[F],j=t.selectedId===s.id,P=t.hoverId===s.id,q=t.searchTerm||"",oe=!q||(s.name||"").toLowerCase().includes(q)||String(xe[F]||"").toLowerCase().includes(q)||String(F).toLowerCase().includes(q),U=r==="all"||F===r,pe=C&&s.id!==C&&!t.edges.some(Z=>Z.sourceNodeId===C&&Z.targetNodeId===s.id||Z.targetNodeId===C&&Z.sourceNodeId===s.id)||q&&!oe||!U;a.save(),a.globalAlpha=pe?.08:1,(j||P)&&(a.shadowColor=w,a.shadowBlur=j?20:14),he(s.x,s.y,s.r,k);let ae=parseInt(w.slice(1,3),16),ge=parseInt(w.slice(3,5),16),Ie=parseInt(w.slice(5,7),16),je=a.createRadialGradient(s.x-s.r*.3,s.y-s.r*.3,0,s.x,s.y,s.r*1.2);je.addColorStop(0,"rgba("+Math.min(255,ae+70)+","+Math.min(255,ge+70)+","+Math.min(255,Ie+70)+",0.95)"),je.addColorStop(1,w),a.fillStyle=je,a.fill(),a.restore(),j?(a.save(),he(s.x,s.y,s.r+3,k),a.strokeStyle=w,a.lineWidth=3,a.shadowColor=w,a.shadowBlur=12,a.stroke(),a.restore()):P?(a.save(),he(s.x,s.y,s.r+2,k),a.strokeStyle=w,a.lineWidth=2,a.stroke(),a.restore()):q&&oe?(a.save(),he(s.x,s.y,s.r+2,k),a.strokeStyle="#e11d48",a.lineWidth=2,a.stroke(),a.restore()):t.multi.indexOf(s.id)>=0&&(a.save(),he(s.x,s.y,s.r+2,k),a.strokeStyle="#60a5fa",a.lineWidth=2,a.shadowColor="#60a5fa",a.shadowBlur=8,a.stroke(),a.restore());let De=Ye(s.name,16);if((j||P||t.zoom>x||!y&&t.zoom>.6)&&U){let Z=1/t.zoom;a.font="500 "+(12*Z).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let ye=a.measureText(De).width+16*Z,Oe=18*Z,ze=s.y+s.r+8*Z,et=!0;for(let Te of E)if(s.x-ye/2<Te.x+Te.w&&s.x+ye/2>Te.x&&ze<Te.y+Te.h&&ze+Oe>Te.y){et=!1;break}if(!et&&!j&&!P)return;E.push({x:s.x-ye/2,y:ze,w:ye,h:Oe}),a.fillStyle=c()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",a.beginPath(),a.roundRect?a.roundRect(s.x-ye/2,ze,ye,Oe,4*Z):a.rect(s.x-ye/2,ze,ye,Oe),a.fill(),a.strokeStyle=c()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",a.lineWidth=1*Z,a.stroke(),a.fillStyle=c()?j||P?"#eee":"#bbb":j||P?"#111":"#444",a.textAlign="center",a.fillText(De,s.x,ze+13*Z)}}),a.restore(),t.marquee){let s=t.marquee,I=Math.min(s.sx,s.ex),F=Math.min(s.sy,s.ey),w=Math.abs(s.ex-s.sx),k=Math.abs(s.ey-s.sy);a.save(),a.setLineDash([4,4]),a.strokeStyle="rgba(96,165,250,0.9)",a.lineWidth=1,a.fillStyle="rgba(96,165,250,0.12)",a.fillRect(I,F,w,k),a.strokeRect(I,F,w,k),a.restore()}if(t.hoverId&&Q.current){let s=t.domainById[t.hoverId],I=t.nodes.find(function(F){return F.id===t.hoverId});if(s&&I){let F=t.edges.filter(function(j){return j.sourceNodeId===s.id||j.targetNodeId===s.id}).length,w=I.x*t.zoom+t.panX,k=I.y*t.zoom+t.panY;Q.current.style.display="block",Q.current.style.left=w+14+"px",Q.current.style.top=k-6+"px",Q.current.innerHTML="<b>"+b(s.title||s.name||"")+'</b><br/><span style="opacity:.8">'+b(s.kind||"")+" \xB7 "+F+" \u8FDE\u63A5</span>"}}else Q.current&&(Q.current.style.display="none")},se=()=>{t.running=!0,t.raf||(t.raf=requestAnimationFrame(Xe))};t.wake=se,t.render=qe;let Ue=()=>{let r=t.nodes.length;t.tickCount++;let p=.9-Math.min(.4,t.tickCount/1500),y=r>1e3?3e3:r>100?2e3:r>50?1200:800,x=r>100?.002:.005,C=r>1e3?.012:r>100?.005:.01,E=r>1e3?6:r>200?12:24,s={};t.nodes.forEach(w=>s[w.id]=w);for(let w=0;w<r;w++){if(t.dragNode===t.nodes[w])continue;let k=t.nodes[w],j=0,P=0;for(let U=0;U<r;U++){if(w===U)continue;let pe=k.x-t.nodes[U].x,ae=k.y-t.nodes[U].y,ge=Math.sqrt(pe*pe+ae*ae)||1,Ie=y/(ge*ge);j+=pe/ge*Ie,P+=ae/ge*Ie}if(t.clustered&&t.typeCenters[k.type]){let U=t.typeCenters[k.type];j+=(U.x-k.x)*.006,P+=(U.y-k.y)*.006}else j-=k.x*C,P-=k.y*C;let q=(k.vx+j)*p,oe=(k.vy+P)*p;q=Math.max(-E,Math.min(E,q)),oe=Math.max(-E,Math.min(E,oe)),k.vx=q,k.vy=oe}t.edges.forEach(w=>{let k=s[w.sourceNodeId],j=s[w.targetNodeId];if(!k||!j)return;let P=j.x-k.x,q=j.y-k.y,oe=Math.sqrt(P*P+q*q)||1,U=(oe-100)*x,pe=P/oe*U,ae=q/oe*U;t.dragNode!==k&&(k.vx+=pe,k.vy+=ae),t.dragNode!==j&&(j.vx-=pe,j.vy-=ae)});let I=0;t.nodes.forEach(w=>{t.dragNode!==w&&(w.x+=w.vx,w.y+=w.vy,I+=w.vx*w.vx+w.vy*w.vy)}),t.autoFitPending&&t.tickCount>45&&(t.autoFitPending=!1,ie()),(r?Math.sqrt(I/r):0)<.05&&t.tickCount>60&&!t.dragNode?t.quietTicks=(t.quietTicks|0)+1:t.quietTicks=0},Xe=()=>{if(t.running){try{Ue(),qe()}catch{}if(t.quietTicks>30){t.raf=0;return}t.raf=requestAnimationFrame(Xe)}},Re=(r,b)=>{let p=l.getBoundingClientRect();return{x:(r-p.left-t.panX)/t.zoom,y:(b-p.top-t.panY)/t.zoom}},$e=(r,b,p)=>Math.max(b,Math.min(p,r)),Ke=r=>{t.mouseX=r.clientX,t.mouseY=r.clientY;let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(G.current!=="all"&&(t.domainById[x.id]&&t.domainById[x.id].kind)!==G.current)continue;let C=x.x-b.x,E=x.y-b.y;if(C*C+E*E<x.r*x.r+36){p=x.id;break}}p!==t.hoverId&&(t.hoverId=p,se())},He=r=>{if(r.button!==0)return;let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(G.current!=="all"&&(t.domainById[x.id]&&t.domainById[x.id].kind)!==G.current)continue;let C=x.x-b.x,E=x.y-b.y;if(C*C+E*E<x.r*x.r+25){p=x;break}}if(r.shiftKey){t.marquee={sx:r.clientX,sy:r.clientY,ex:r.clientX,ey:r.clientY};return}t.dragStart={x:r.clientX,y:r.clientY,px:t.panX,py:t.panY},t.dragging=!1,t.dragNode=p||null,p&&(t.dragOffset={dx:p.x-b.x,dy:p.y-b.y})},Ve=r=>{if(t.marquee){t.marquee.ex=r.clientX,t.marquee.ey=r.clientY,se();return}if(!t.dragStart)return;let b=r.clientX-t.dragStart.x,p=r.clientY-t.dragStart.y;if(Math.abs(b)+Math.abs(p)>3&&(t.dragging=!0),t.dragNode){let y=Re(r.clientX,r.clientY);t.dragNode.x=y.x+t.dragOffset.dx,t.dragNode.y=y.y+t.dragOffset.dy,se()}else t.dragging&&(t.panX=$e(t.dragStart.px+b,-1e5,1e5),t.panY=$e(t.dragStart.py+p,-1e5,1e5),se())},Ge=r=>{if(t.marquee){let p=t.marquee;t.marquee=null;let y=l.getBoundingClientRect(),x=Math.min(p.sx,p.ex)-y.left,C=Math.max(p.sx,p.ex)-y.left,E=Math.min(p.sy,p.ey)-y.top,s=Math.max(p.sy,p.ey)-y.top,I=t.nodes.filter(F=>{let w=F.x*t.zoom+t.panX,k=F.y*t.zoom+t.panY;return w>=x&&w<=C&&k>=E&&k<=s}).map(F=>F.id);t.multi=I,H(I),se();return}if(t.dragStart&&!t.dragging){let p=Re(r.clientX,r.clientY),y=null;for(let x=t.nodes.length-1;x>=0;x--){let C=t.nodes[x];if(G.current!=="all"&&(t.domainById[C.id]&&t.domainById[C.id].kind)!==G.current)continue;let E=C.x-p.x,s=C.y-p.y;if(E*E+s*s<C.r*C.r+20){y=C;break}}y?(t.selectedId=y.id,me(y.id),se()):(t.selectedId=null,t.hoverId=null,r.shiftKey||(t.multi=[],H([])),me(null),se())}t.dragStart=null,t.dragging=!1,t.dragNode=null},_e=r=>{r.preventDefault();let b=Re(r.clientX,r.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(G.current!=="all"&&(t.domainById[x.id]&&t.domainById[x.id].kind)!==G.current)continue;let C=x.x-b.x,E=x.y-b.y;if(C*C+E*E<x.r*x.r+25){p=x;break}}if(p){let y=t.domainById[p.id];y&&L({x:r.clientX,y:r.clientY,id:p.id,path:y.id,title:y.title})}else L(null)},Je=r=>{r.preventDefault();let b=l.getBoundingClientRect(),p=(r.clientX-b.left-t.panX)/t.zoom,y=(r.clientY-b.top-t.panY)/t.zoom,x=Math.max(.3,Math.min(3,t.zoom*(r.deltaY<0?1.1:1/1.1)));t.panX=$e(t.panX+p*(t.zoom-x),-1e5,1e5),t.panY=$e(t.panY+y*(t.zoom-x),-1e5,1e5),t.zoom=x,se()};l.addEventListener("mousemove",Ke),l.addEventListener("mousedown",He),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",Ge),l.addEventListener("wheel",Je,{passive:!1}),l.addEventListener("contextmenu",_e),$.current=()=>{t.selectedId=null,t.hoverId=null,t.multi=[],H([]),ie(),se()};for(let r=0;r<200;r++)Ue();return ie(),se(),()=>{t.running=!1,t.raf&&cancelAnimationFrame(t.raf),Se.disconnect(),l.removeEventListener("mousemove",Ke),l.removeEventListener("mousedown",He),window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",Ge),l.removeEventListener("wheel",Je),l.removeEventListener("contextmenu",_e)}},[o,i]),(0,e.jsxs)("div",{className:"me-graph",ref:M,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[o.length," ",n("nodes")," \xB7 ",i.length," ",n("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",className:"mc-btn",style:{padding:"6px 10px",minWidth:140},placeholder:n("search"),value:V,onChange:l=>we(l.target.value)}),(0,e.jsx)("button",{type:"button",className:`mc-btn${K?" me-on":""}`,onClick:()=>m(l=>!l),children:n("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=T.current;if(l)try{l.toBlob(a=>{a&&ke({url:URL.createObjectURL(a),blob:a})},"image/png")}catch{}},children:n("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>R.current&&R.current(),children:n("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{me(null),de("all"),$.current&&$.current()},children:n("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:T,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Q,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)"}}),(0,e.jsxs)("div",{className:"me-graph-legend",style:{position:"absolute",left:12,bottom:8,zIndex:2},children:[K?[{c:"#10b981",l:n("timeNew")},{c:"#f59e0b",l:n("timeRecent")},{c:"#f97316",l:n("timeMonth")},{c:"#94a3b8",l:n("timeOld")}].map(l=>(0,e.jsxs)("span",{className:"lg",children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:l.c}}),l.l]},l.c)):Object.keys(We).map(l=>(0,e.jsxs)("button",{type:"button",className:`lg${le===l?" active":""}`,onClick:()=>de(a=>a===l?"all":l),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Le.colors[l]||We[l]}}),n(xe[l])]},l)),!K&&le!=="all"&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",onClick:()=>de("all"),children:[n("clearFilter")," \u2715"]})]}),ue&&(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:n("noMatch")}),B&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>L(null)}),B&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:B.x,top:B.y,zIndex:31},onMouseDown:l=>l.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{ne.current({path:B.path,title:B.title}),L(null)},children:n("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{B.id&&(D.current.selectedId=B.id,me(B.id)),L(null);let l=D.current;l&&l.wake&&l.wake()},children:n("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(B.title||"")}catch{}L(null),W(n("copied"))},children:n("copyName")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let l=B.path;L(null),window.confirm(n("deleteConfirm"))&&(async()=>{try{(ee.current?await ee.current(l):!1)?W(n("deleted")):W(n("deleteFail"),!1)}catch{W(n("deleteFail"),!1)}})()},children:n("delete")})]}),z.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:[z.length," ",n("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let a=z.map(f=>J[f]).filter(Boolean).map(f=>f.title||f.name).join(`
117
+ `),N=new Blob([a],{type:"text/plain;charset=utf-8"}),c=URL.createObjectURL(N),v=document.createElement("a");v.href=c,v.download="memory-selected.txt",document.body.appendChild(v),v.click(),document.body.removeChild(v),setTimeout(()=>URL.revokeObjectURL(c),1e3),W(z.length+n("exportedSel"))},children:n("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(z.length<2){W(n("mergeNeed"),!1);return}let l=z.map(N=>J[N]?J[N].id:N);if(!window.confirm(n("mergeConfirm")))return;H([]);let a=D.current;a&&(a.multi=[]),fetch(`${A}/merge?paths=${encodeURIComponent(l.join(","))}`).then(N=>N.json()).then(N=>{N&&N.ok?W(n("merged")):W(n("mergeFail"),!1)}).catch(()=>W(n("mergeFail"),!1))},children:n("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(n("deleteConfirm")))return;let l=z.map(N=>J[N]?J[N].id:N);H([]);let a=D.current;a&&(a.multi=[]),(async()=>{let N=0;for(let c of l)try{(ee.current?await ee.current(c):!1)&&N++}catch{}W(N+n("deletedSelected"),N>0)})()},children:n("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=D.current;l&&(l.multi=[]),H([]);let a=D.current;a&&a.render&&a.render()},children:n("clearSelection")})]}),O&&(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:J[O]?J[O].title||J[O].name:O}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:J[O]?n(xe[J[O].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:n("graphHint")}),(i.filter(l=>l.source===O||l.target===O)||[]).slice(0,8).map((l,a)=>{let N=l.source===O?l.target:l.source,c=J[N];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:v=>{v.preventDefault();let f=D.current;f&&(f.selectedId=N,f.hoverId=N,f.wake&&f.wake()),me(N)},children:c?(c.title||c.name).slice(0,28):N},a)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:n("graphTip")}),fe&&(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 "+(fe.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:fe.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:fe.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:fe.msg})]}),_&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{_.url&&URL.revokeObjectURL(_.url),ke(null),ce(!1)},children:[(0,e.jsx)("style",{children:ve}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:re?"100vw":900,width:re?"100vw":"92vw",maxHeight:re?"100vh":"90vh",height:re?"100vh":void 0,borderRadius:re?0:14},onClick:l=>l.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:n("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:_.url,download:"memory-graph.png",onClick:()=>{Fe("download"),W(n("downloaded")+" \xB7 "+n("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:n(Ne==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Fe("full"),ce(l=>!l),W(n("fullscreen"))},children:n(Ne==="full"?"done":re?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=_.blob;l&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":l})]).then(()=>{Fe("copy"),W(n("copied"))}).catch(()=>{W(n("copyFail"),!1)}):W(n("copyFail"),!1)},children:n(Ne==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{_.url&&URL.revokeObjectURL(_.url),ke(null),ce(!1)},children:n("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:re?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:_.url,alt:n("exportGraph"),style:{maxWidth:"100%",maxHeight:re?"calc(100vh - 64px)":"70vh",borderRadius:re?0:8,cursor:"zoom-in"},onClick:()=>ce(l=>!l)})})]})]})]})}function It(o){let i=new Date(o||0).getTime();if(!i)return"#94a3b8";let g=(Date.now()-i)/864e5;return g<3?"#10b981":g<14?"#f59e0b":g<30?"#f97316":"#94a3b8"}function zt(o){let i=new Date(o||0).getTime();return!!i&&(Date.now()-i)/864e5<3}async function Tt(o,i,g){if(g&&typeof window.showSaveFilePicker=="function")try{let u=await window.showSaveFilePicker({suggestedName:i}),T=await u.createWritable();return await T.write(o),await T.close(),{ok:!0,picked:!0,name:u.name}}catch(u){return u&&u.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(u.message||u)}}let h=URL.createObjectURL(o),n=document.createElement("a");return n.href=h,n.download=i,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(h),1e3),{ok:!0,picked:!1,name:i}}function ot(o,i){if(!i||!o)return o;let g=o.toLowerCase(),h=i.toLowerCase(),n=[],u=0;for(;u<o.length;){let T=g.indexOf(h,u);if(T<0){n.push(o.slice(u));break}T>u&&n.push(o.slice(u,T)),n.push((0,e.jsx)("mark",{className:"mc-hl",children:o.slice(T,T+h.length)},T)),u=T+h.length}return n}function Bt(o){if(!o)return"";let i=String(o).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),g=[];return i=i.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(h,n,u){return g.push("<pre><code>"+u+"</code></pre>"),"\0"+(g.length-1)+"\0"}),i=i.replace(/^(#{1,3})\s+(.+)$/gm,function(h,n,u){return"<h"+n.length+">"+u+"</h"+n.length+">"}),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/`([^`\n]+)`/g,"<code>$1</code>"),i=i.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(h,n,u){return/^(https?:|\/)/.test(u)?'<a href="'+u+'" target="_blank" rel="noopener noreferrer">'+n+"</a>":n}),i=i.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),i=i.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),i=i.replace(/\n/g,"<br/>"),i=i.replace(/\u0000(\d+)\u0000/g,function(h,n){return g[n]}),i}function rt(o){if(!o)return"";let i=new Date(o);if(Number.isNaN(i.getTime()))return"";let g=new Date,h=i.toDateString()===g.toDateString(),n=T=>String(T).padStart(2,"0"),u=`${n(i.getHours())}:${n(i.getMinutes())}`;return h?u:`${i.getMonth()+1}-${i.getDate()} ${u}`}
114
118
 
115
119
  return module.exports;
116
120
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-memory-eternal",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {