dsh-memory-eternal 0.4.13 → 0.4.15

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