dsh-memory-eternal 0.4.10 → 0.4.11

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 it=Object.create;var We=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var pt=(a,i)=>{for(var g in i)We(a,g,{get:i[g],enumerable:!0})},tt=(a,i,g,b)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of lt(i))!ct.call(a,n)&&n!==g&&We(a,n,{get:()=>i[n],enumerable:!(b=st(i,n))||b.enumerable});return a};var mt=(a,i,g)=>(g=a!=null?it(dt(a)):{},tt(i||!a||!a.__esModule?We(g,"default",{value:a,enumerable:!0}):g,a)),ut=a=>tt(We({},"__esModule",{value:!0}),a);var Lt={};pt(Lt,{apply:()=>yt,inject:()=>gt});module.exports=ut(Lt);var d=mt(require("react"),1),e=require("react/jsx-runtime"),Ee="memory-eternal",Y="/memory-eternal/api",gt=["settingsScope","slots","locale","connection","remote"],ft={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},bt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},ht=["all","project","knowledge","content","prompt","business","tool","mistake"],qe={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},we={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},ke=`
6
+ var lt=Object.create;var We=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var ut=(a,i)=>{for(var g in i)We(a,g,{get:i[g],enumerable:!0})},ot=(a,i,g,w)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of dt(i))!mt.call(a,n)&&n!==g&&We(a,n,{get:()=>i[n],enumerable:!(w=ct(i,n))||w.enumerable});return a};var gt=(a,i,g)=>(g=a!=null?lt(pt(a)):{},ot(i||!a||!a.__esModule?We(g,"default",{value:a,enumerable:!0}):g,a)),ft=a=>ot(We({},"__esModule",{value:!0}),a);var Ft={};ut(Ft,{apply:()=>vt,inject:()=>bt});module.exports=ft(Ft);var c=gt(require("react"),1),e=require("react/jsx-runtime"),Le="memory-eternal",A="/memory-eternal/api",bt=["settingsScope","slots","locale","connection","remote"],ht={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"},yt={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"},xt=["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; }
@@ -118,12 +118,12 @@ var it=Object.create;var We=Object.defineProperty;var st=Object.getOwnPropertyDe
118
118
  .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; }
119
119
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
120
120
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
121
- `;function yt(a){a.effect(()=>a.locale.register(Ee,{zh:ft,en:bt}),"memory-eternal: locale");let i=a.locale.bind(Ee);a.effect(()=>a.slots.inject("settings.section",()=>a.slots.register({name:"settings.section",id:Ee,order:25,label:()=>i("nav"),locale:Ee,inject:()=>({})},()=>d.default.createElement(nt,{t:i,inModal:!1}))),"memory-eternal: settings section"),a.effect(()=>a.slots.inject("sidebar.footer.action",()=>a.slots.register({name:"sidebar.footer.action",id:`${Ee}:footer`,order:100,label:()=>i("nav"),locale:Ee,inject:()=>({})},g=>d.default.createElement(xt,{t:i,wide:!(g&&g.wide===!1)}))),"memory-eternal: sidebar footer action")}function xt({t:a,wide:i}){let[g,b]=(0,d.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:ke}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>b(!0),"aria-label":a("nav"),title:a("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(ot,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:a("nav")})]}),g&&(0,e.jsx)(vt,{t:a,onClose:()=>b(!1)})]})}function ot(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}function vt({t:a,onClose:i}){let[g,b]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let n=m=>{m.key==="Escape"&&i()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[i]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:i,children:[(0,e.jsx)("style",{children:ke}),(0,e.jsx)("div",{className:"me-modal",onClick:n=>n.stopPropagation(),style:g?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(nt,{t:a,inModal:!0,onClose:i,onFull:()=>b(n=>!n),full:g})})]})}function nt({t:a,inModal:i,onClose:g,onFull:b,full:n}){let[m,z]=(0,d.useState)(null),[C,D]=(0,d.useState)([]),[F,j]=(0,d.useState)(!0),[re,ae]=(0,d.useState)(""),[_,Ne]=(0,d.useState)("all"),[O,me]=(0,d.useState)(""),[X,de]=(0,d.useState)("cards"),[ce,J]=(0,d.useState)("recent"),[K,u]=(0,d.useState)(null),M=(0,d.useRef)(null),T=(0,d.useRef)(null),[B,ue]=(0,d.useState)(!1),[ee,I]=(0,d.useState)(null),[H,Z]=(0,d.useState)(null),[Ce,ie]=(0,d.useState)(!1),[se,ve]=(0,d.useState)(!0),be=(0,d.useRef)(null),[Me,Se]=(0,d.useState)(24),he=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(X!=="cards")return;let c=he.current;if(!c)return;let t=new IntersectionObserver(x=>{x[0]&&x[0].isIntersecting&&Se(le=>le+24)},{rootMargin:"400px"});return t.observe(c),()=>t.disconnect()},[X,C,_,O]);let ye=(0,d.useCallback)(async(c=_,t=O)=>{try{j(!0),ae("");let x=new URLSearchParams;c&&c!=="all"&&x.set("kind",c),t.trim()&&x.set("q",t.trim());let G=await(await fetch(`${Y}/cards?${x.toString()}`)).json();G.ok&&(D(G.cards||[]),Se(24))}catch(x){ae(String(x&&x.message?x.message:x))}finally{j(!1)}},[_,O]),$=(0,d.useCallback)(async()=>{try{let[c,t]=await Promise.all([fetch(`${Y}/overview`).then(x=>x.json()),fetch(`${Y}/cards`).then(x=>x.json())]);c.ok&&z(c),t.ok&&(D(t.cards||[]),Se(24))}catch(c){ae(String(c&&c.message?c.message:c))}finally{j(!1)}},[]),Ie=async c=>{try{let x=await(await fetch(`${Y}/delete?path=${encodeURIComponent(c)}`)).json();x.ok?(u({ok:!0,msg:a("deleted")}),await $()):u({ok:!1,msg:x.error||a("deleteFail")})}catch{u({ok:!1,msg:a("deleteFail")})}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>u(null),2e3)};(0,d.useEffect)(()=>($(),()=>{be.current&&clearTimeout(be.current)}),[$]);let te=c=>{me(c),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>ye(_,c),280)},l=c=>{Ne(c),ye(c,O)},o=async c=>{try{let x=await(await fetch(`${Y}/card?path=${encodeURIComponent(c.path||c.id)}`)).json();x.ok&&I({path:x.path,title:c.title,text:x.text})}catch(t){ae(String(t&&t.message?t.message:t))}},N=async(c,t)=>{ue(!0);try{let x=await fetch(`${Y}/export`);if(!x.ok)throw new Error("HTTP "+x.status);let le=await x.json();if(!le.ok)throw new Error(le.error||"export failed");let G,Re,ge;c==="json"?(Re="memory-vault.json",ge="application/json",G=JSON.stringify(le.cards.map(A=>({path:A.path,title:A.title,kind:A.kind,text:A.text})),null,2)):(Re="memory-vault.md",ge="text/markdown;charset=utf-8",G=le.cards.map(A=>A.text.trim()).filter(Boolean).join(`
121
+ `;function vt(a){a.effect(()=>a.locale.register(Le,{zh:ht,en:yt}),"memory-eternal: locale");let i=a.locale.bind(Le);a.effect(()=>a.slots.inject("settings.section",()=>a.slots.register({name:"settings.section",id:Le,order:25,label:()=>i("nav"),locale:Le,inject:()=>({})},()=>c.default.createElement(it,{t:i,inModal:!1}))),"memory-eternal: settings section"),a.effect(()=>a.slots.inject("sidebar.footer.action",()=>a.slots.register({name:"sidebar.footer.action",id:`${Le}:footer`,order:100,label:()=>i("nav"),locale:Le,inject:()=>({})},g=>c.default.createElement(wt,{t:i,wide:!(g&&g.wide===!1)}))),"memory-eternal: sidebar footer action")}function wt({t:a,wide:i}){let[g,w]=(0,c.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>w(!0),"aria-label":a("nav"),title:a("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(rt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:a("nav")})]}),g&&(0,e.jsx)(kt,{t:a,onClose:()=>w(!1)})]})}function rt(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}function kt({t:a,onClose:i}){let[g,w]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let n=u=>{u.key==="Escape"&&i()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[i]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:i,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("div",{className:"me-modal",onClick:n=>n.stopPropagation(),style:g?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(it,{t:a,inModal:!0,onClose:i,onFull:()=>w(n=>!n),full:g})})]})}function it({t:a,inModal:i,onClose:g,onFull:w,full:n}){let[u,E]=(0,c.useState)(null),[C,G]=(0,c.useState)([]),[_,z]=(0,c.useState)(!0),[F,J]=(0,c.useState)(""),[ne,ce]=(0,c.useState)("all"),[K,Fe]=(0,c.useState)(""),[R,de]=(0,c.useState)("cards"),[ge,fe]=(0,c.useState)("recent"),[Q,p]=(0,c.useState)(null),M=(0,c.useRef)(null),Y=(0,c.useRef)(null),[$,D]=(0,c.useState)(!1),[ee,j]=(0,c.useState)(null),[O,Z]=(0,c.useState)(null),[he,pe]=(0,c.useState)(!1),[re,ie]=(0,c.useState)(!0),me=(0,c.useRef)(null),[ye,Ce]=(0,c.useState)(24),Me=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(R!=="cards")return;let d=Me.current;if(!d)return;let x=new IntersectionObserver(f=>{f[0]&&f[0].isIntersecting&&Ce(t=>t+24)},{rootMargin:"400px"});return x.observe(d),()=>x.disconnect()},[R,C,ne,K]);let Re=(0,c.useCallback)(async(d=ne,x=K)=>{try{z(!0),J("");let f=new URLSearchParams;d&&d!=="all"&&f.set("kind",d),x.trim()&&f.set("q",x.trim());let q=await(await fetch(`${A}/cards?${f.toString()}`)).json();q.ok&&(G(q.cards||[]),Ce(24))}catch(f){J(String(f&&f.message?f.message:f))}finally{z(!1)}},[ne,K]),te=(0,c.useCallback)(async()=>{try{let[d,x]=await Promise.all([fetch(`${A}/overview`).then(f=>f.json()),fetch(`${A}/cards`).then(f=>f.json())]);d.ok&&E(d),x.ok&&(G(x.cards||[]),Ce(24))}catch(d){J(String(d&&d.message?d.message:d))}finally{z(!1)}},[]),xe=async d=>{try{let f=await(await fetch(`${A}/delete?path=${encodeURIComponent(d)}`)).json();f.ok?(p({ok:!0,msg:a("deleted")}),await te()):p({ok:!1,msg:f.error||a("deleteFail")})}catch{p({ok:!1,msg:a("deleteFail")})}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>p(null),2e3)};(0,c.useEffect)(()=>(te(),()=>{me.current&&clearTimeout(me.current)}),[te]);let W=d=>{Fe(d),me.current&&clearTimeout(me.current),me.current=setTimeout(()=>Re(ne,d),280)},je=d=>{ce(d),Re(d,K)},H=async d=>{try{let f=await(await fetch(`${A}/card?path=${encodeURIComponent(d.path||d.id)}`)).json();f.ok&&j({path:f.path,title:d.title,text:f.text})}catch(x){J(String(x&&x.message?x.message:x))}},s=async(d,x)=>{D(!0);try{let f=await fetch(`${A}/export`);if(!f.ok)throw new Error("HTTP "+f.status);let t=await f.json();if(!t.ok)throw new Error(t.error||"export failed");let q,Se,Ie;d==="json"?(Se="memory-vault.json",Ie="application/json",q=JSON.stringify(t.cards.map(se=>({path:se.path,title:se.title,kind:se.kind,text:se.text})),null,2)):(Se="memory-vault.md",Ie="text/markdown;charset=utf-8",q=t.cards.map(se=>se.text.trim()).filter(Boolean).join(`
122
122
 
123
123
  ---
124
124
 
125
- `));let ze=new Blob([G],{type:ge}),je=await Tt(ze,Re,!1);if(!je.ok){u({ok:!1,msg:a("exportFail")}),ue(!1);return}u({ok:!0,msg:a("exportedTo")+"\uFF1A"+a("defaultDownloads")+" \xB7 "+je.name})}catch(x){u({ok:!1,msg:a("exportFail")+" \xB7 "+(x.message||"")})}finally{ue(!1)}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>u(null),2600)},V=async c=>{let t=c.target.files&&c.target.files[0];if(c.target.value="",!!t){try{let x=await t.text(),G=await(await fetch(`${Y}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:x})).json();G.ok?(await $(),u({ok:!0,msg:a("importedVault")+"\uFF1A"+(G.imported||0)+(G.skipped?a("importedSkipped")+G.skipped:"")})):u({ok:!1,msg:G.error||a("importFail")})}catch{u({ok:!1,msg:a("importFail")})}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>u(null),2400)}},P=(0,d.useMemo)(()=>{let c=C.slice();return ce==="title"?c.sort((t,x)=>String(t.title||"").localeCompare(String(x.title||""))):ce==="hot"?c.sort((t,x)=>(x.weight||x.links||0)-(t.weight||t.links||0)):c.sort((t,x)=>new Date(x.updated||0).getTime()-new Date(t.updated||0).getTime()),c},[C,ce]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:ke}),K&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(K.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:K.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:K.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:K.msg})]}),i&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(ot,{})}),(0,e.jsx)("h2",{children:a("memoryTitle")}),(0,e.jsx)("span",{children:a("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),b&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:b,"aria-label":a(n?"exitFull":"fullscreen"),children:n?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:g,"aria-label":a("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${se?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>ve(c=>!c),"aria-label":a(se?"collapse":"expand"),title:a(se?"collapse":"expand"),children:se?"\u25C0":"\u25B6"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${X==="cards"?" active":""}`,onClick:()=>de("cards"),title:a("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),se&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${X==="graph"?" active":""}`,onClick:()=>de("graph"),title:a("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),se&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("graphTab")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ye,{label:a("total"),value:m?m.total:"\u2014"}),(0,e.jsx)(Ye,{label:a("recent"),value:m?m.recent:"\u2014"}),(0,e.jsx)(Ye,{label:a("tags"),value:m?m.tags:"\u2014"}),(0,e.jsx)(Ye,{label:a("cardCount"),value:m?m.byKind?.knowledge??0:"\u2014"})]}),(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:a("searchPlaceholder"),value:O,onChange:c=>te(c.target.value)}),(0,e.jsx)("input",{ref:T,type:"file",accept:".json,application/json",style:{display:"none"},onChange:V}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>T.current&&T.current.click(),children:a("importVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:B,onClick:()=>N("md"),children:a(B?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:B,onClick:()=>N("json"),children:a(B?"exporting":"exportJson")}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:a("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:Ce,onChange:c=>ie(c.target.checked)}),a("crossVault")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Z({tab:"stats"}),children:a("manage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>$(),children:a("refresh")})]}),X==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ht.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${_===c?" active":""}`,onClick:()=>l(c),children:a(c==="all"?"all":we[c])},c)),(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(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${ce===c.key?" active":""}`,onClick:()=>J(c.key),children:c.label},c.key))]}),re&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",re]}),X==="cards"?F&&!C.length?(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}):C.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:P.slice(0,Me).map(c=>(0,e.jsx)(wt,{card:c,t:a,query:O.trim(),onOpen:o,onDelete:Ie},c.path))}),P.length>Me&&(0,e.jsx)("div",{ref:he,style:{height:1}})]}):(0,e.jsx)(Ct,{t:a,onOpen:o,all:Ce}),ee&&(0,e.jsx)(Nt,{t:a,card:ee,onClose:()=>I(null),onDelete:c=>{I(null),Ie(c)}}),H&&(0,e.jsx)(kt,{t:a,tab:H.tab,onTab:c=>Z({tab:c}),onClose:()=>Z(null),onReload:()=>$()})]})]})]})}var Ye=({label:a,value:i})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:i}),(0,e.jsx)("span",{children:a})]}),wt=({card:a,t:i,onOpen:g,query:b,onDelete:n})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>g(a),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:qe[a.kind]||qe.other}}),b?at(a.title,b):a.title,zt(a.updated)&&(0,e.jsx)("span",{className:"mc-new",children:i("newBadge")})]}),(0,e.jsx)("p",{children:b?at(a.summary||"",b):a.summary||""}),a.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:a.tags.slice(0,4).map(m=>(0,e.jsx)("span",{className:"mc-tag",children:m},m))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:i(we[a.kind])}),(0,e.jsx)("span",{children:rt(a.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:i("delete"),onClick:m=>{m.stopPropagation(),window.confirm(i("deleteConfirm"))&&n&&n(a.path)},children:"\u2715"})]})]});function kt({t:a,tab:i,onTab:g,onClose:b,onReload:n}){let[m,z]=(0,d.useState)(null),[C,D]=(0,d.useState)(null),[F,j]=(0,d.useState)(null),[re,ae]=(0,d.useState)(""),[_,Ne]=(0,d.useState)(""),O=(0,d.useCallback)(async()=>{try{let u=await fetch(`${Y}/todayBrief`).then(M=>M.json());ae(u.ok&&u.brief||"")}catch{}},[]),me=(0,d.useCallback)(async()=>{if(!(!C||!C.merge||!C.merge.length)&&window.confirm(a("mergeAllConfirm"))){Ne("merge");try{let u={},M=I=>u[I]===void 0?I:u[I]=M(u[I]),T=(I,H)=>{u[M(I)]=M(H)},B=new Set;for(let I of C.merge)B.add(I.a.path),B.add(I.b.path),T(I.a.path,I.b.path);let ue={};for(let I of B){let H=M(I);(ue[H]=ue[H]||[]).push(I)}let ee=0;for(let I of Object.values(ue)){if(I.length<2)continue;(await fetch(`${Y}/merge?paths=${encodeURIComponent(I.join(","))}`).then(Z=>Z.json())).ok&&ee++}await X(),n&&n()}catch{}Ne("")}},[C,X,n,a]);async function X(){try{let[u,M,T]=await Promise.all([fetch(`${Y}/stats`).then(B=>B.json()),fetch(`${Y}/optimize`).then(B=>B.json()),fetch(`${Y}/budget`).then(B=>B.json())]);u.ok&&z(u),M.ok&&D(M),T.ok&&j(T)}catch{}}(0,d.useEffect)(()=>{X()},[]);let de=async(u,M)=>{if(window.confirm(a("mergeConfirm")))try{(await fetch(`${Y}/merge?paths=${encodeURIComponent(u+","+M)}`).then(B=>B.json())).ok&&(await X(),n&&n())}catch{}},ce=async u=>{if(window.confirm(a("deleteConfirm")))try{(await fetch(`${Y}/delete?path=${encodeURIComponent(u)}`).then(T=>T.json())).ok&&(await X(),n&&n())}catch{}},J=["project","knowledge","content","prompt","business","tool","mistake"],K=({title:u,kind:M,updated:T,path:B})=>(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:Fe.colors[M]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:rt(T)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ce(B),children:[a("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"me-overlay",onClick:b,children:[(0,e.jsx)("style",{children:ke}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720,width:"94vw",maxHeight:"86vh"},onClick:u=>u.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="stats"?" active":""}`,onClick:()=>g("stats"),children:a("tabUsage")}),(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="optimize"?" active":""}`,onClick:()=>g("optimize"),children:a("tabOptimize")})]}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:b,children:a("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{overflow:"auto"},children:[!m&&!C&&(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}),i==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:a("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:O,children:a("todayBrief")}),re&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:re})]}),m&&(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:m.total}),(0,e.jsx)("span",{children:a("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.today}),(0,e.jsx)("span",{children:a("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.week}),(0,e.jsx)("span",{children:a("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.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:J.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Fe.colors[u]||"#666"}}),a(we[u]),": ",m.byKind?.[u]||0]},u))})]}),F&&(F.budgetChars||F.recallLimit||F.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:F.budgetChars||8e4})," \xB7 ",a("recallLimitLabel")," ",(0,e.jsx)("b",{children:F.recallLimit||5})," \xB7 ",a("embeddingLabel")," ",F.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",m.todayCards?.length||0,"\uFF09"]}),m.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:m.todayCards.map(u=>(0,e.jsx)(K,{title:u.title,kind:u.kind,updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})]})]}),i==="optimize"&&(0,e.jsx)("div",{children:C&&(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:C.merge?.length?a("mergePairs"):a("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),C.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!_,onClick:me,children:a(_==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:a("mergePairs")}),C.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:C.merge.map((u,M)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[u.a.title," \u21C4 ",u.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(u.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>de(u.a.path,u.b.path),children:a("mergeNow")})]},M))}):(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",C.stale?.length||0,"\uFF09"]}),C.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:C.stale.map(u=>(0,e.jsx)(K,{title:u.title,kind:"other",updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})})]})]})]})}function Nt({t:a,card:i,onClose:g,onDelete:b}){(0,d.useEffect)(()=>{let C=D=>{D.key==="Escape"&&g()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[g]);let[n,m]=(0,d.useState)(!1),z=(i.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:g,children:[(0,e.jsx)("style",{children:ke}),(0,e.jsxs)("div",{className:"me-dialog",onClick:C=>C.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[z&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>m(C=>!C),children:a(n?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(a("deleteConfirm"))&&b&&b(i.path)},children:a("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:g,children:a("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:n?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Bt(i.text)}})]})]})}function Ct({t:a,onOpen:i,all:g}){let[b,n]=(0,d.useState)(null),[m,z]=(0,d.useState)(""),C=(0,d.useCallback)(async()=>{try{let j=await(await fetch(`${Y}/graph${g?"?all=1":""}`)).json();n(j.ok?j:null),z("")}catch(F){z(String(F&&F.message?F.message:F))}},[g]);(0,d.useEffect)(()=>{let F=!0;return fetch(`${Y}/graph${g?"?all=1":""}`).then(j=>j.json()).then(j=>{F&&n(j.ok?j:null)}).catch(j=>{F&&z(String(j&&j.message?j.message:j))}),()=>{F=!1}},[g]);let D=(0,d.useCallback)(async F=>{try{let re=await(await fetch(`${Y}/delete?path=${encodeURIComponent(F)}`)).json();return re&&re.ok?(await C(),!0):!1}catch{return!1}},[C]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:ke}),m&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",m]}),!b&&!m&&(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}),b&&b.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:a("emptyGraph")}),b&&b.nodes.length>0&&(0,e.jsx)(St,{nodes:b.nodes,edges:b.edges,onOpen:i,onDelete:D,t:a,countLabel:`${b.nodes.length} ${a("nodes")} \xB7 ${Mt(b.edges)} ${a("edges")}`})]})}function Mt(a){let i=new Set;for(let g of a||[])i.add([g.source,g.target].sort().join("|"));return i.size}var Fe={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function St({nodes:a,edges:i,onOpen:g,onDelete:b,t:n,countLabel:m}){let z=(0,d.useRef)(null),C=(0,d.useRef)(null),D=(0,d.useRef)(null),F=(0,d.useRef)(null),j=(0,d.useRef)(null),re=(0,d.useRef)(g);(0,d.useEffect)(()=>{re.current=g},[g]);let ae=(0,d.useRef)(b);(0,d.useEffect)(()=>{ae.current=b},[b]);let[_,Ne]=(0,d.useState)(""),[O,me]=(0,d.useState)(null),X=(0,d.useRef)("");(0,d.useEffect)(()=>{X.current=_.trim().toLowerCase()},[_]);let[de,ce]=(0,d.useState)("all"),J=(0,d.useRef)("all"),[K,u]=(0,d.useState)(!1),M=(0,d.useRef)(!1),[T,B]=(0,d.useState)(null);(0,d.useEffect)(()=>{J.current=de},[de]),(0,d.useEffect)(()=>{M.current=K},[K]);let ue=(()=>{let l=_.trim().toLowerCase();return!!l&&!a.some(o=>(o.title||o.name||"").toLowerCase().includes(l)||String(o.kind||"").toLowerCase().includes(l)||String(we[o.kind]||"").toLowerCase().includes(l))})();(0,d.useEffect)(()=>{let l=D.current;l&&l.wake&&l.wake()},[_]),(0,d.useEffect)(()=>{let l=D.current;l&&l.render&&l.render()},[de,K]);let ee=(0,d.useRef)(null),[I,H]=(0,d.useState)([]),[Z,Ce]=(0,d.useState)(null),[ie,se]=(0,d.useState)(!1),[ve,be]=(0,d.useState)(null),[Me,Se]=(0,d.useState)(""),he=(0,d.useRef)(null),ye=(0,d.useRef)(null),$=(l,o=!0)=>{he.current&&clearTimeout(he.current),be({msg:l,ok:o}),he.current=setTimeout(()=>be(null),1900)},Ie=l=>{Se(l),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>Se(""),1600)};(0,d.useEffect)(()=>()=>{he.current&&clearTimeout(he.current),ye.current&&clearTimeout(ye.current)},[]);let te=(0,d.useMemo)(()=>a.reduce((l,o)=>(l[o.id]=o,l),{}),[a]);return(0,d.useEffect)(()=>{let l=z.current;if(!l||a.length===0)return;let o=l.getContext("2d");if(!o)return;let N=Math.max(1,window.devicePixelRatio||1),V=()=>document.documentElement.getAttribute("data-theme")==="dark",P={};i.forEach(r=>{P[r.source]=(P[r.source]||0)+1,P[r.target]=(P[r.target]||0)+1});let c=Math.max(1,...Object.values(P)),t={nodes:a.map(r=>({id:r.id,name:r.title||"",type:r.kind||"other",r:9+Math.min(10,(P[r.id]||0)/c*8),x:0,y:0,vx:0,vy:0})),edges:i.map(r=>({sourceNodeId:r.source,targetNodeId:r.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:N,ctx:o,multi:[],marquee:null};t.domain=a,t.domainById=a.reduce((r,f)=>(r[f.id]=f,r),{}),t.nodes.forEach((r,f)=>{let p=f/t.nodes.length*Math.PI*2-Math.PI/2;r.x=Math.cos(p)*60,r.y=Math.sin(p)*60});let x=[...new Set(t.nodes.map(r=>r.type))];t.clustered=x.length>1,t.typeCenters={},x.forEach((r,f)=>{let p=f/x.length*Math.PI*2-Math.PI/2;t.typeCenters[r]={x:Math.cos(p)*160,y:Math.sin(p)*160}}),D.current=t;let le=()=>{let r=l.clientWidth,f=l.clientHeight;t.w=r,t.h=f,l.width=r*N,l.height=f*N,o.setTransform(N,0,0,N,0,0)};le();let G=new ResizeObserver(le);G.observe(l.parentElement);let Re=(r,f)=>r&&r.length>f?r.slice(0,f)+"\u2026":r,ge=(r,f,p,h)=>{if(o.beginPath(),h==="rect")o.rect(r-p,f-p*.75,p*2,p*1.5);else if(h==="diamond")o.moveTo(r,f-p),o.lineTo(r+p,f),o.lineTo(r,f+p),o.lineTo(r-p,f),o.closePath();else if(h==="hexagon"){for(let y=0;y<6;y++){let k=Math.PI/3*y-Math.PI/2,L=r+p*Math.cos(k),s=f+p*Math.sin(k);y===0?o.moveTo(L,s):o.lineTo(L,s)}o.closePath()}else o.arc(r,f,p,0,Math.PI*2)},ze=()=>{if(!t.nodes.length)return;let r=1/0,f=-1/0,p=1/0,h=-1/0;t.nodes.forEach(S=>{r=Math.min(r,S.x),f=Math.max(f,S.x),p=Math.min(p,S.y),h=Math.max(h,S.y)});let y=20,k=f-r+y*2,L=h-p+y*2,s=Math.min(t.w/k,t.h/L);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-(p+h)/2*t.zoom};F.current=ze;let je=()=>{o.clearRect(0,0,t.w,t.h),t.searchTerm=X.current,t.kindFilter=J.current,t.timeMode=M.current;let r=t.kindFilter,f=s=>String(s||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=V()?"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 h=t.nodes.length>40,y=h?1.5:.55,k=t.selectedId||t.hoverId;t.edges.forEach(s=>{let S=p[s.sourceNodeId],E=p[s.targetNodeId];if(!S||!E)return;if(r!=="all"){let Q=t.domainById[s.sourceNodeId]&&t.domainById[s.sourceNodeId].kind,Qe=t.domainById[s.targetNodeId]&&t.domainById[s.targetNodeId].kind;if(Q!==r&&Qe!==r)return}let v=E.x-S.x,w=E.y-S.y,R=Math.sqrt(v*v+w*w)||1,W=h?12:18,q=-w/R*W,oe=v/R*W,U=(S.x+E.x)/2+q,pe=(S.y+E.y)/2+oe,ne=Fe.colors[t.domainById[S.id]&&t.domainById[S.id].kind||"other"],fe=k&&(s.sourceNodeId===k||s.targetNodeId===k),Te=k?fe?.6:.08:h?.14:.24,De=parseInt(ne.slice(1,3),16),Pe=parseInt(ne.slice(3,5),16),Ze=parseInt(ne.slice(5,7),16);o.strokeStyle="rgba("+De+","+Pe+","+Ze+","+Te+")",o.lineWidth=fe?1.6+(s.weight||1):.8+(s.weight||1)*.5,o.beginPath(),o.moveTo(S.x,S.y),o.quadraticCurveTo(U,pe,E.x,E.y),o.stroke()});let L=[];if(t.nodes.forEach(s=>{let S=t.domainById[s.id]||{},E=S.kind||"other",v=t.timeMode?It(S.updated):Fe.colors[E],w=Fe.shapes[E],R=t.selectedId===s.id,W=t.hoverId===s.id,q=t.searchTerm||"",oe=!q||(s.name||"").toLowerCase().includes(q)||String(we[E]||"").toLowerCase().includes(q)||String(E).toLowerCase().includes(q),U=r==="all"||E===r,pe=k&&s.id!==k&&!t.edges.some(Q=>Q.sourceNodeId===k&&Q.targetNodeId===s.id||Q.targetNodeId===k&&Q.sourceNodeId===s.id)||q&&!oe||!U;o.save(),o.globalAlpha=pe?.08:1,(R||W)&&(o.shadowColor=v,o.shadowBlur=R?20:14),ge(s.x,s.y,s.r,w);let ne=parseInt(v.slice(1,3),16),fe=parseInt(v.slice(3,5),16),Te=parseInt(v.slice(5,7),16),De=o.createRadialGradient(s.x-s.r*.3,s.y-s.r*.3,0,s.x,s.y,s.r*1.2);De.addColorStop(0,"rgba("+Math.min(255,ne+70)+","+Math.min(255,fe+70)+","+Math.min(255,Te+70)+",0.95)"),De.addColorStop(1,v),o.fillStyle=De,o.fill(),o.restore(),R?(o.save(),ge(s.x,s.y,s.r+3,w),o.strokeStyle=v,o.lineWidth=3,o.shadowColor=v,o.shadowBlur=12,o.stroke(),o.restore()):W?(o.save(),ge(s.x,s.y,s.r+2,w),o.strokeStyle=v,o.lineWidth=2,o.stroke(),o.restore()):q&&oe?(o.save(),ge(s.x,s.y,s.r+2,w),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):t.multi.indexOf(s.id)>=0&&(o.save(),ge(s.x,s.y,s.r+2,w),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let Pe=Re(s.name,16);if((R||W||t.zoom>y||!h&&t.zoom>.6)&&U){let Q=1/t.zoom;o.font="500 "+(12*Q).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let xe=o.measureText(Pe).width+16*Q,Ae=18*Q,Be=s.y+s.r+8*Q,et=!0;for(let Le of L)if(s.x-xe/2<Le.x+Le.w&&s.x+xe/2>Le.x&&Be<Le.y+Le.h&&Be+Ae>Le.y){et=!1;break}if(!et&&!R&&!W)return;L.push({x:s.x-xe/2,y:Be,w:xe,h:Ae}),o.fillStyle=V()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(s.x-xe/2,Be,xe,Ae,4*Q):o.rect(s.x-xe/2,Be,xe,Ae),o.fill(),o.strokeStyle=V()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*Q,o.stroke(),o.fillStyle=V()?R||W?"#eee":"#bbb":R||W?"#111":"#444",o.textAlign="center",o.fillText(Pe,s.x,Be+13*Q)}}),o.restore(),t.marquee){let s=t.marquee,S=Math.min(s.sx,s.ex),E=Math.min(s.sy,s.ey),v=Math.abs(s.ex-s.sx),w=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(S,E,v,w),o.strokeRect(S,E,v,w),o.restore()}if(t.hoverId&&ee.current){let s=t.domainById[t.hoverId],S=t.nodes.find(function(E){return E.id===t.hoverId});if(s&&S){let E=t.edges.filter(function(R){return R.sourceNodeId===s.id||R.targetNodeId===s.id}).length,v=S.x*t.zoom+t.panX,w=S.y*t.zoom+t.panY;ee.current.style.display="block",ee.current.style.left=v+14+"px",ee.current.style.top=w-6+"px",ee.current.innerHTML="<b>"+f(s.title||s.name||"")+'</b><br/><span style="opacity:.8">'+f(s.kind||"")+" \xB7 "+E+" \u8FDE\u63A5</span>"}}else ee.current&&(ee.current.style.display="none")},A=()=>{t.running=!0,t.raf||(t.raf=requestAnimationFrame(Xe))};t.wake=A,t.render=je;let Ue=()=>{let r=t.nodes.length;t.tickCount++;let p=.9-Math.min(.4,t.tickCount/1500),h=r>1e3?3e3:r>100?2e3:r>50?1200:800,y=r>100?.002:.005,k=r>1e3?.012:r>100?.005:.01,L=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],R=0,W=0;for(let U=0;U<r;U++){if(v===U)continue;let pe=w.x-t.nodes[U].x,ne=w.y-t.nodes[U].y,fe=Math.sqrt(pe*pe+ne*ne)||1,Te=h/(fe*fe);R+=pe/fe*Te,W+=ne/fe*Te}if(t.clustered&&t.typeCenters[w.type]){let U=t.typeCenters[w.type];R+=(U.x-w.x)*.006,W+=(U.y-w.y)*.006}else R-=w.x*k,W-=w.y*k;let q=(w.vx+R)*p,oe=(w.vy+W)*p;q=Math.max(-L,Math.min(L,q)),oe=Math.max(-L,Math.min(L,oe)),w.vx=q,w.vy=oe}t.edges.forEach(v=>{let w=s[v.sourceNodeId],R=s[v.targetNodeId];if(!w||!R)return;let W=R.x-w.x,q=R.y-w.y,oe=Math.sqrt(W*W+q*q)||1,U=(oe-100)*y,pe=W/oe*U,ne=q/oe*U;t.dragNode!==w&&(w.vx+=pe,w.vy+=ne),t.dragNode!==R&&(R.vx-=pe,R.vy-=ne)});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,ze()),(r?Math.sqrt(S/r):0)<.05&&t.tickCount>60&&!t.dragNode?t.quietTicks=(t.quietTicks|0)+1:t.quietTicks=0},Xe=()=>{if(t.running){try{Ue(),je()}catch{}if(t.quietTicks>30){t.raf=0;return}t.raf=requestAnimationFrame(Xe)}},$e=(r,f)=>{let p=l.getBoundingClientRect();return{x:(r-p.left-t.panX)/t.zoom,y:(f-p.top-t.panY)/t.zoom}},Oe=(r,f,p)=>Math.max(f,Math.min(p,r)),Ke=r=>{t.mouseX=r.clientX,t.mouseY=r.clientY;let f=$e(r.clientX,r.clientY),p=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(J.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==J.current)continue;let k=y.x-f.x,L=y.y-f.y;if(k*k+L*L<y.r*y.r+36){p=y.id;break}}p!==t.hoverId&&(t.hoverId=p,A())},He=r=>{if(r.button!==0)return;let f=$e(r.clientX,r.clientY),p=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(J.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==J.current)continue;let k=y.x-f.x,L=y.y-f.y;if(k*k+L*L<y.r*y.r+25){p=y;break}}if(r.shiftKey){t.marquee={sx:r.clientX,sy:r.clientY,ex:r.clientX,ey:r.clientY};return}t.dragStart={x:r.clientX,y:r.clientY,px:t.panX,py:t.panY},t.dragging=!1,t.dragNode=p||null,p&&(t.dragOffset={dx:p.x-f.x,dy:p.y-f.y})},Ve=r=>{if(t.marquee){t.marquee.ex=r.clientX,t.marquee.ey=r.clientY,A();return}if(!t.dragStart)return;let f=r.clientX-t.dragStart.x,p=r.clientY-t.dragStart.y;if(Math.abs(f)+Math.abs(p)>3&&(t.dragging=!0),t.dragNode){let h=$e(r.clientX,r.clientY);t.dragNode.x=h.x+t.dragOffset.dx,t.dragNode.y=h.y+t.dragOffset.dy,A()}else t.dragging&&(t.panX=Oe(t.dragStart.px+f,-1e5,1e5),t.panY=Oe(t.dragStart.py+p,-1e5,1e5),A())},Ge=r=>{if(t.marquee){let p=t.marquee;t.marquee=null;let h=l.getBoundingClientRect(),y=Math.min(p.sx,p.ex)-h.left,k=Math.max(p.sx,p.ex)-h.left,L=Math.min(p.sy,p.ey)-h.top,s=Math.max(p.sy,p.ey)-h.top,S=t.nodes.filter(E=>{let v=E.x*t.zoom+t.panX,w=E.y*t.zoom+t.panY;return v>=y&&v<=k&&w>=L&&w<=s}).map(E=>E.id);t.multi=S,H(S),A();return}if(t.dragStart&&!t.dragging){let p=$e(r.clientX,r.clientY),h=null;for(let y=t.nodes.length-1;y>=0;y--){let k=t.nodes[y];if(J.current!=="all"&&(t.domainById[k.id]&&t.domainById[k.id].kind)!==J.current)continue;let L=k.x-p.x,s=k.y-p.y;if(L*L+s*s<k.r*k.r+20){h=k;break}}h?(t.selectedId=h.id,me(h.id),A()):(t.selectedId=null,t.hoverId=null,r.shiftKey||(t.multi=[],H([])),me(null),A())}t.dragStart=null,t.dragging=!1,t.dragNode=null},_e=r=>{r.preventDefault();let f=$e(r.clientX,r.clientY),p=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(J.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==J.current)continue;let k=y.x-f.x,L=y.y-f.y;if(k*k+L*L<y.r*y.r+25){p=y;break}}if(p){let h=t.domainById[p.id];h&&B({x:r.clientX,y:r.clientY,id:p.id,path:h.id,title:h.title})}else B(null)},Je=r=>{r.preventDefault();let f=l.getBoundingClientRect(),p=(r.clientX-f.left-t.panX)/t.zoom,h=(r.clientY-f.top-t.panY)/t.zoom,y=Math.max(.3,Math.min(3,t.zoom*(r.deltaY<0?1.1:1/1.1)));t.panX=Oe(t.panX+p*(t.zoom-y),-1e5,1e5),t.panY=Oe(t.panY+h*(t.zoom-y),-1e5,1e5),t.zoom=y,A()};l.addEventListener("mousemove",Ke),l.addEventListener("mousedown",He),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",Ge),l.addEventListener("wheel",Je,{passive:!1}),l.addEventListener("contextmenu",_e),j.current=()=>{t.selectedId=null,t.hoverId=null,t.multi=[],H([]),ze(),A()};for(let r=0;r<200;r++)Ue();return ze(),A(),()=>{t.running=!1,t.raf&&cancelAnimationFrame(t.raf),G.disconnect(),l.removeEventListener("mousemove",Ke),l.removeEventListener("mousedown",He),window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",Ge),l.removeEventListener("wheel",Je),l.removeEventListener("contextmenu",_e)}},[a,i]),(0,e.jsxs)("div",{className:"me-graph",ref:C,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[a.length," ",n("nodes")," \xB7 ",i.length," ",n("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",className:"mc-btn",style:{padding:"6px 10px",minWidth:140},placeholder:n("search"),value:_,onChange:l=>Ne(l.target.value)}),(0,e.jsx)("button",{type:"button",className:`mc-btn${K?" me-on":""}`,onClick:()=>u(l=>!l),children:n("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=z.current;if(l)try{l.toBlob(o=>{o&&Ce({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:n("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>F.current&&F.current(),children:n("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{me(null),ce("all"),j.current&&j.current()},children:n("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:z,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ee,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),(0,e.jsxs)("div",{className:"me-graph-legend",style:{position:"absolute",left:12,bottom:8,zIndex:2},children:[K?[{c:"#10b981",l:n("timeNew")},{c:"#f59e0b",l:n("timeRecent")},{c:"#f97316",l:n("timeMonth")},{c:"#94a3b8",l:n("timeOld")}].map(l=>(0,e.jsxs)("span",{className:"lg",children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:l.c}}),l.l]},l.c)):Object.keys(qe).map(l=>(0,e.jsxs)("button",{type:"button",className:`lg${de===l?" active":""}`,onClick:()=>ce(o=>o===l?"all":l),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Fe.colors[l]||qe[l]}}),n(we[l])]},l)),!K&&de!=="all"&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",onClick:()=>ce("all"),children:[n("clearFilter")," \u2715"]})]}),ue&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:n("noMatch")}),T&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>B(null)}),T&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:T.x,top:T.y,zIndex:31},onMouseDown:l=>l.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{re.current({path:T.path,title:T.title}),B(null)},children:n("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{T.id&&(D.current.selectedId=T.id,me(T.id)),B(null);let l=D.current;l&&l.wake&&l.wake()},children:n("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(T.title||"")}catch{}B(null),$(n("copied"))},children:n("copyName")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let l=T.path;B(null),window.confirm(n("deleteConfirm"))&&(async()=>{try{(ae.current?await ae.current(l):!1)?$(n("deleted")):$(n("deleteFail"),!1)}catch{$(n("deleteFail"),!1)}})()},children:n("delete")})]}),I.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:[I.length," ",n("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=I.map(c=>te[c]).filter(Boolean).map(c=>c.title||c.name).join(`
126
- `),N=new Blob([o],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(N),P=document.createElement("a");P.href=V,P.download="memory-selected.txt",document.body.appendChild(P),P.click(),document.body.removeChild(P),setTimeout(()=>URL.revokeObjectURL(V),1e3),$(I.length+n("exportedSel"))},children:n("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(I.length<2){$(n("mergeNeed"),!1);return}let l=I.map(N=>te[N]?te[N].id:N);if(!window.confirm(n("mergeConfirm")))return;H([]);let o=D.current;o&&(o.multi=[]),fetch(`${Y}/merge?paths=${encodeURIComponent(l.join(","))}`).then(N=>N.json()).then(N=>{N&&N.ok?$(n("merged")):$(n("mergeFail"),!1)}).catch(()=>$(n("mergeFail"),!1))},children:n("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(n("deleteConfirm")))return;let l=I.map(N=>te[N]?te[N].id:N);H([]);let o=D.current;o&&(o.multi=[]),(async()=>{let N=0;for(let V of l)try{(ae.current?await ae.current(V):!1)&&N++}catch{}$(N+n("deletedSelected"),N>0)})()},children:n("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=D.current;l&&(l.multi=[]),H([]);let o=D.current;o&&o.render&&o.render()},children:n("clearSelection")})]}),O&&(0,e.jsxs)("div",{className:"me-graph-sidebar",style:{position:"absolute",right:10,top:10,zIndex:3,maxWidth:240,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:12,fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:te[O]?te[O].title||te[O].name:O}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:te[O]?n(we[te[O].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:n("graphHint")}),(i.filter(l=>l.source===O||l.target===O)||[]).slice(0,8).map((l,o)=>{let N=l.source===O?l.target:l.source,V=te[N];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:P=>{P.preventDefault();let c=D.current;c&&(c.selectedId=N,c.hoverId=N,c.wake&&c.wake()),me(N)},children:V?(V.title||V.name).slice(0,28):N},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:n("graphTip")}),ve&&(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 "+(ve.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ve.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ve.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ve.msg})]}),Z&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{Z.url&&URL.revokeObjectURL(Z.url),Ce(null),se(!1)},children:[(0,e.jsx)("style",{children:ke}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:ie?"100vw":900,width:ie?"100vw":"92vw",maxHeight:ie?"100vh":"90vh",height:ie?"100vh":void 0,borderRadius:ie?0:14},onClick:l=>l.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:n("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:Z.url,download:"memory-graph.png",onClick:()=>{Ie("download"),$(n("downloaded")+" \xB7 "+n("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:n(Me==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ie("full"),se(l=>!l),$(n("fullscreen"))},children:n(Me==="full"?"done":ie?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let l=Z.blob;l&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":l})]).then(()=>{Ie("copy"),$(n("copied"))}).catch(()=>{$(n("copyFail"),!1)}):$(n("copyFail"),!1)},children:n(Me==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Z.url&&URL.revokeObjectURL(Z.url),Ce(null),se(!1)},children:n("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:ie?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:Z.url,alt:n("exportGraph"),style:{maxWidth:"100%",maxHeight:ie?"calc(100vh - 64px)":"70vh",borderRadius:ie?0:8,cursor:"zoom-in"},onClick:()=>se(l=>!l)})})]})]})]})}function It(a){let i=new Date(a||0).getTime();if(!i)return"#94a3b8";let g=(Date.now()-i)/864e5;return g<3?"#10b981":g<14?"#f59e0b":g<30?"#f97316":"#94a3b8"}function zt(a){let i=new Date(a||0).getTime();return!!i&&(Date.now()-i)/864e5<3}async function Tt(a,i,g){if(g&&typeof window.showSaveFilePicker=="function")try{let m=await window.showSaveFilePicker({suggestedName:i}),z=await m.createWritable();return await z.write(a),await z.close(),{ok:!0,picked:!0,name:m.name}}catch(m){return m&&m.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(m.message||m)}}let b=URL.createObjectURL(a),n=document.createElement("a");return n.href=b,n.download=i,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(b),1e3),{ok:!0,picked:!1,name:i}}function at(a,i){if(!i||!a)return a;let g=a.toLowerCase(),b=i.toLowerCase(),n=[],m=0;for(;m<a.length;){let z=g.indexOf(b,m);if(z<0){n.push(a.slice(m));break}z>m&&n.push(a.slice(m,z)),n.push((0,e.jsx)("mark",{className:"mc-hl",children:a.slice(z,z+b.length)},z)),m=z+b.length}return n}function Bt(a){if(!a)return"";let i=String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),g=[];return i=i.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(b,n,m){return g.push("<pre><code>"+m+"</code></pre>"),"\0"+(g.length-1)+"\0"}),i=i.replace(/^(#{1,3})\s+(.+)$/gm,function(b,n,m){return"<h"+n.length+">"+m+"</h"+n.length+">"}),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/`([^`\n]+)`/g,"<code>$1</code>"),i=i.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(b,n,m){return/^(https?:|\/)/.test(m)?'<a href="'+m+'" target="_blank" rel="noopener noreferrer">'+n+"</a>":n}),i=i.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),i=i.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),i=i.replace(/\n/g,"<br/>"),i=i.replace(/\u0000(\d+)\u0000/g,function(b,n){return g[n]}),i}function rt(a){if(!a)return"";let i=new Date(a);if(Number.isNaN(i.getTime()))return"";let g=new Date,b=i.toDateString()===g.toDateString(),n=z=>String(z).padStart(2,"0"),m=`${n(i.getHours())}:${n(i.getMinutes())}`;return b?m:`${i.getMonth()+1}-${i.getDate()} ${m}`}
125
+ `));let Ue=new Blob([q],{type:Ie}),ve=await Lt(Ue,Se,!1);if(!ve.ok){p({ok:!1,msg:a("exportFail")}),D(!1);return}p({ok:!0,msg:a("exportedTo")+"\uFF1A"+a("defaultDownloads")+" \xB7 "+ve.name})}catch(f){p({ok:!1,msg:a("exportFail")+" \xB7 "+(f.message||"")})}finally{D(!1)}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>p(null),2600)},o=async d=>{let x=d.target.files&&d.target.files[0];if(d.target.value="",!!x){try{let f=await x.text(),q=await(await fetch(`${A}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:f})).json();q.ok?(await te(),p({ok:!0,msg:a("importedVault")+"\uFF1A"+(q.imported||0)+(q.skipped?a("importedSkipped")+q.skipped:"")})):p({ok:!1,msg:q.error||a("importFail")})}catch{p({ok:!1,msg:a("importFail")})}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>p(null),2400)}},S=(0,c.useMemo)(()=>{let d=C.slice();return ge==="title"?d.sort((x,f)=>String(x.title||"").localeCompare(String(f.title||""))):ge==="hot"?d.sort((x,f)=>(f.weight||f.links||0)-(x.weight||x.links||0)):d.sort((x,f)=>new Date(f.updated||0).getTime()-new Date(x.updated||0).getTime()),d},[C,ge]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ne}),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",{children:Q.msg})]}),i&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(rt,{})}),(0,e.jsx)("h2",{children:a("memoryTitle")}),(0,e.jsx)("span",{children:a("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),w&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:w,"aria-label":a(n?"exitFull":"fullscreen"),children:n?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:g,"aria-label":a("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${re?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>ie(d=>!d),"aria-label":a(re?"collapse":"expand"),title:a(re?"collapse":"expand"),children:re?"\u25C0":"\u25B6"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="cards"?" active":""}`,onClick:()=>de("cards"),title:a("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="graph"?" active":""}`,onClick:()=>de("graph"),title:a("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${O?" active":""}`,onClick:()=>Z({tab:"stats"}),title:a("manage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("manage")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ye,{label:a("total"),value:u?u.total:"\u2014"}),(0,e.jsx)(Ye,{label:a("recent"),value:u?u.recent:"\u2014"}),(0,e.jsx)(Ye,{label:a("tags"),value:u?u.tags:"\u2014"}),(0,e.jsx)(Ye,{label:a("cardCount"),value:u?u.byKind?.knowledge??0:"\u2014"})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:a("searchPlaceholder"),value:K,onChange:d=>W(d.target.value)}),(0,e.jsx)("input",{ref:Y,type:"file",accept:".json,application/json",style:{display:"none"},onChange:o}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Y.current&&Y.current.click(),children:a("importVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:$,onClick:()=>s("md"),children:a($?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:$,onClick:()=>s("json"),children:a($?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>te(),children:a("refresh")})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[xt.map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${ne===d?" active":""}`,onClick:()=>je(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${ge===d.key?" active":""}`,onClick:()=>fe(d.key),children:d.label},d.key))]}),F&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",F]}),R==="cards"?_&&!C.length?(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}):C.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:S.slice(0,ye).map(d=>(0,e.jsx)(Nt,{card:d,t:a,query:K.trim(),onOpen:H,onDelete:xe},d.path))}),S.length>ye&&(0,e.jsx)("div",{ref:Me,style:{height:1}})]}):(0,e.jsx)(St,{t:a,onOpen:H,all:he,onAllChange:pe}),ee&&(0,e.jsx)(Mt,{t:a,card:ee,onClose:()=>j(null),onDelete:d=>{j(null),xe(d)}}),O&&(0,e.jsx)(Ct,{t:a,tab:O.tab,onTab:d=>Z({tab:d}),onClose:()=>Z(null),onReload:()=>te()})]})]})]})}var Ye=({label:a,value:i})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:i}),(0,e.jsx)("span",{children:a})]}),Nt=({card:a,t:i,onOpen:g,query:w,onDelete:n})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>g(a),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:qe[a.kind]||qe.other}}),w?nt(a.title,w):a.title,Bt(a.updated)&&(0,e.jsx)("span",{className:"mc-new",children:i("newBadge")})]}),(0,e.jsx)("p",{children:w?nt(a.summary||"",w):a.summary||""}),a.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:a.tags.slice(0,4).map(u=>(0,e.jsx)("span",{className:"mc-tag",children:u},u))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:i(ke[a.kind])}),(0,e.jsx)("span",{children:st(a.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:i("delete"),onClick:u=>{u.stopPropagation(),window.confirm(i("deleteConfirm"))&&n&&n(a.path)},children:"\u2715"})]})]});function Ct({t:a,tab:i,onTab:g,onClose:w,onReload:n}){let[u,E]=(0,c.useState)(null),[C,G]=(0,c.useState)(null),[_,z]=(0,c.useState)(null),[F,J]=(0,c.useState)(""),[ne,ce]=(0,c.useState)(""),K=(0,c.useCallback)(async()=>{try{let p=await fetch(`${A}/todayBrief`).then(M=>M.json());J(p.ok&&p.brief||"")}catch{}},[]),Fe=(0,c.useCallback)(async()=>{if(!(!C||!C.merge||!C.merge.length)&&window.confirm(a("mergeAllConfirm"))){ce("merge");try{let p={},M=j=>p[j]===void 0?j:p[j]=M(p[j]),Y=(j,O)=>{p[M(j)]=M(O)},$=new Set;for(let j of C.merge)$.add(j.a.path),$.add(j.b.path),Y(j.a.path,j.b.path);let D={};for(let j of $){let O=M(j);(D[O]=D[O]||[]).push(j)}let ee=0;for(let j of Object.values(D)){if(j.length<2)continue;(await fetch(`${A}/merge?paths=${encodeURIComponent(j.join(","))}`).then(Z=>Z.json())).ok&&ee++}await R(),n&&n()}catch{}ce("")}},[C,R,n,a]);async function R(){try{let[p,M,Y]=await Promise.all([fetch(`${A}/stats`).then($=>$.json()),fetch(`${A}/optimize`).then($=>$.json()),fetch(`${A}/budget`).then($=>$.json())]);p.ok&&E(p),M.ok&&G(M),Y.ok&&z(Y)}catch{}}(0,c.useEffect)(()=>{R()},[]);let de=async(p,M)=>{if(window.confirm(a("mergeConfirm")))try{(await fetch(`${A}/merge?paths=${encodeURIComponent(p+","+M)}`).then($=>$.json())).ok&&(await R(),n&&n())}catch{}},ge=async p=>{if(window.confirm(a("deleteConfirm")))try{(await fetch(`${A}/delete?path=${encodeURIComponent(p)}`).then(Y=>Y.json())).ok&&(await R(),n&&n())}catch{}},fe=["project","knowledge","content","prompt","business","tool","mistake"],Q=({title:p,kind:M,updated:Y,path:$})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[M]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:st(Y)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ge($),children:[a("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"me-overlay",onClick:w,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720,width:"94vw",maxHeight:"86vh"},onClick:p=>p.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="stats"?" active":""}`,onClick:()=>g("stats"),children:a("tabUsage")}),(0,e.jsx)("button",{type:"button",className:`mc-tab${i==="optimize"?" active":""}`,onClick:()=>g("optimize"),children:a("tabOptimize")})]}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:w,children:a("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{overflow:"auto"},children:[!u&&!C&&(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}),i==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:a("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:K,children:a("todayBrief")}),F&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:F})]}),u&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.total}),(0,e.jsx)("span",{children:a("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.today}),(0,e.jsx)("span",{children:a("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.week}),(0,e.jsx)("span",{children:a("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.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:fe.map(p=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[p]||"#666"}}),a(ke[p]),": ",u.byKind?.[p]||0]},p))})]}),_&&(_.budgetChars||_.recallLimit||_.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:_.budgetChars||8e4})," \xB7 ",a("recallLimitLabel")," ",(0,e.jsx)("b",{children:_.recallLimit||5})," \xB7 ",a("embeddingLabel")," ",_.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",u.todayCards?.length||0,"\uFF09"]}),u.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:u.todayCards.map(p=>(0,e.jsx)(Q,{title:p.title,kind:p.kind,updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})]})]}),i==="optimize"&&(0,e.jsx)("div",{children:C&&(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:C.merge?.length?a("mergePairs"):a("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),C.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!ne,onClick:Fe,children:a(ne==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:a("mergePairs")}),C.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:C.merge.map((p,M)=>(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:[p.a.title," \u21C4 ",p.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(p.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>de(p.a.path,p.b.path),children:a("mergeNow")})]},M))}):(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",C.stale?.length||0,"\uFF09"]}),C.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:C.stale.map(p=>(0,e.jsx)(Q,{title:p.title,kind:"other",updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})})]})]})]})}function Mt({t:a,card:i,onClose:g,onDelete:w}){(0,c.useEffect)(()=>{let C=G=>{G.key==="Escape"&&g()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[g]);let[n,u]=(0,c.useState)(!1),E=(i.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:g,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",onClick:C=>C.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[E&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>u(C=>!C),children:a(n?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(a("deleteConfirm"))&&w&&w(i.path)},children:a("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:g,children:a("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:n?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Et(i.text)}})]})]})}function St({t:a,onOpen:i,all:g,onAllChange:w}){let[n,u]=(0,c.useState)(null),[E,C]=(0,c.useState)(""),G=(0,c.useCallback)(async()=>{try{let F=await(await fetch(`${A}/graph${g?"?all=1":""}`)).json();u(F.ok?F:null),C("")}catch(z){C(String(z&&z.message?z.message:z))}},[g]);(0,c.useEffect)(()=>{let z=!0;return fetch(`${A}/graph${g?"?all=1":""}`).then(F=>F.json()).then(F=>{z&&u(F.ok?F:null)}).catch(F=>{z&&C(String(F&&F.message?F.message:F))}),()=>{z=!1}},[g]);let _=(0,c.useCallback)(async z=>{try{let J=await(await fetch(`${A}/delete?path=${encodeURIComponent(z)}`)).json();return J&&J.ok?(await G(),!0):!1}catch{return!1}},[G]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ne}),E&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",E]}),!n&&!E&&(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}),n&&n.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:a("emptyGraph")}),n&&n.nodes.length>0&&(0,e.jsx)(zt,{nodes:n.nodes,edges:n.edges,onOpen:i,onDelete:_,t:a,all:g,onAllChange:w,countLabel:`${n.nodes.length} ${a("nodes")} \xB7 ${It(n.edges)} ${a("edges")}`})]})}function It(a){let i=new Set;for(let g of a||[])i.add([g.source,g.target].sort().join("|"));return i.size}var Ee={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function zt({nodes:a,edges:i,onOpen:g,onDelete:w,t:n,countLabel:u,all:E,onAllChange:C}){let G=(0,c.useRef)(null),_=(0,c.useRef)(null),z=(0,c.useRef)(null),F=(0,c.useRef)(null),J=(0,c.useRef)(null),ne=(0,c.useRef)(g);(0,c.useEffect)(()=>{ne.current=g},[g]);let ce=(0,c.useRef)(w);(0,c.useEffect)(()=>{ce.current=w},[w]);let[K,Fe]=(0,c.useState)(""),[R,de]=(0,c.useState)(null),ge=(0,c.useRef)("");(0,c.useEffect)(()=>{ge.current=K.trim().toLowerCase()},[K]);let[fe,Q]=(0,c.useState)("all"),p=(0,c.useRef)("all"),[M,Y]=(0,c.useState)(!1),$=(0,c.useRef)(!1),[D,ee]=(0,c.useState)(null);(0,c.useEffect)(()=>{p.current=fe},[fe]),(0,c.useEffect)(()=>{$.current=M},[M]);let j=(()=>{let s=K.trim().toLowerCase();return!!s&&!a.some(o=>(o.title||o.name||"").toLowerCase().includes(s)||String(o.kind||"").toLowerCase().includes(s)||String(ke[o.kind]||"").toLowerCase().includes(s))})();(0,c.useEffect)(()=>{let s=z.current;s&&s.wake&&s.wake()},[K]),(0,c.useEffect)(()=>{let s=z.current;s&&s.render&&s.render()},[fe,M]);let O=(0,c.useRef)(null),[Z,he]=(0,c.useState)([]),[pe,re]=(0,c.useState)(null),[ie,me]=(0,c.useState)(!1),[ye,Ce]=(0,c.useState)(null),[Me,Re]=(0,c.useState)(""),te=(0,c.useRef)(null),xe=(0,c.useRef)(null),W=(s,o=!0)=>{te.current&&clearTimeout(te.current),Ce({msg:s,ok:o}),te.current=setTimeout(()=>Ce(null),1900)},je=s=>{Re(s),xe.current&&clearTimeout(xe.current),xe.current=setTimeout(()=>Re(""),1600)};(0,c.useEffect)(()=>()=>{te.current&&clearTimeout(te.current),xe.current&&clearTimeout(xe.current)},[]);let H=(0,c.useMemo)(()=>a.reduce((s,o)=>(s[o.id]=o,s),{}),[a]);return(0,c.useEffect)(()=>{let s=G.current;if(!s||a.length===0)return;let o=s.getContext("2d");if(!o)return;let S=Math.max(1,window.devicePixelRatio||1),d=()=>document.documentElement.getAttribute("data-theme")==="dark",x={};i.forEach(r=>{x[r.source]=(x[r.source]||0)+1,x[r.target]=(x[r.target]||0)+1});let f=Math.max(1,...Object.values(x)),t={nodes:a.map(r=>({id:r.id,name:r.title||"",type:r.kind||"other",r:9+Math.min(10,(x[r.id]||0)/f*8),x:0,y:0,vx:0,vy:0})),edges:i.map(r=>({sourceNodeId:r.source,targetNodeId:r.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:S,ctx:o,multi:[],marquee:null};t.domain=a,t.domainById=a.reduce((r,b)=>(r[b.id]=b,r),{}),t.nodes.forEach((r,b)=>{let m=b/t.nodes.length*Math.PI*2-Math.PI/2;r.x=Math.cos(m)*60,r.y=Math.sin(m)*60});let q=[...new Set(t.nodes.map(r=>r.type))];t.clustered=q.length>1,t.typeCenters={},q.forEach((r,b)=>{let m=b/q.length*Math.PI*2-Math.PI/2;t.typeCenters[r]={x:Math.cos(m)*160,y:Math.sin(m)*160}}),z.current=t;let Se=()=>{let r=s.clientWidth,b=s.clientHeight;t.w=r,t.h=b,s.width=r*S,s.height=b*S,o.setTransform(S,0,0,S,0,0)};Se();let Ie=new ResizeObserver(Se);Ie.observe(s.parentElement);let Ue=(r,b)=>r&&r.length>b?r.slice(0,b)+"\u2026":r,ve=(r,b,m,h)=>{if(o.beginPath(),h==="rect")o.rect(r-m,b-m*.75,m*2,m*1.5);else if(h==="diamond")o.moveTo(r,b-m),o.lineTo(r+m,b),o.lineTo(r,b+m),o.lineTo(r-m,b),o.closePath();else if(h==="hexagon"){for(let y=0;y<6;y++){let N=Math.PI/3*y-Math.PI/2,T=r+m*Math.cos(N),l=b+m*Math.sin(N);y===0?o.moveTo(T,l):o.lineTo(T,l)}o.closePath()}else o.arc(r,b,m,0,Math.PI*2)},se=()=>{if(!t.nodes.length)return;let r=1/0,b=-1/0,m=1/0,h=-1/0;t.nodes.forEach(I=>{r=Math.min(r,I.x),b=Math.max(b,I.x),m=Math.min(m,I.y),h=Math.max(h,I.y)});let y=20,N=b-r+y*2,T=h-m+y*2,l=Math.min(t.w/N,t.h/T);t.zoom=Math.max(.35,Math.min(1.8,l)),t.panX=t.w/2-(r+b)/2*t.zoom,t.panY=t.h/2-(m+h)/2*t.zoom};F.current=se;let Xe=()=>{o.clearRect(0,0,t.w,t.h),t.searchTerm=ge.current,t.kindFilter=p.current,t.timeMode=$.current;let r=t.kindFilter,b=l=>String(l||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=d()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let l=0;l<t.w;l+=24)o.beginPath(),o.moveTo(l,0),o.lineTo(l,t.h),o.stroke();for(let l=0;l<t.h;l+=24)o.beginPath(),o.moveTo(0,l),o.lineTo(t.w,l),o.stroke();o.restore(),o.save(),o.translate(t.panX,t.panY),o.scale(t.zoom,t.zoom);let m={};t.nodes.forEach(l=>m[l.id]=l);let h=t.nodes.length>40,y=h?1.5:.55,N=t.selectedId||t.hoverId;t.edges.forEach(l=>{let I=m[l.sourceNodeId],B=m[l.targetNodeId];if(!I||!B)return;if(r!=="all"){let V=t.domainById[l.sourceNodeId]&&t.domainById[l.sourceNodeId].kind,tt=t.domainById[l.targetNodeId]&&t.domainById[l.targetNodeId].kind;if(V!==r&&tt!==r)return}let v=B.x-I.x,k=B.y-I.y,L=Math.sqrt(v*v+k*k)||1,P=h?12:18,U=-k/L*P,ae=v/L*P,X=(I.x+B.x)/2+U,ue=(I.y+B.y)/2+ae,oe=Ee.colors[t.domainById[I.id]&&t.domainById[I.id].kind||"other"],be=N&&(l.sourceNodeId===N||l.targetNodeId===N),ze=N?be?.6:.08:h?.14:.24,De=parseInt(oe.slice(1,3),16),Pe=parseInt(oe.slice(3,5),16),et=parseInt(oe.slice(5,7),16);o.strokeStyle="rgba("+De+","+Pe+","+et+","+ze+")",o.lineWidth=be?1.6+(l.weight||1):.8+(l.weight||1)*.5,o.beginPath(),o.moveTo(I.x,I.y),o.quadraticCurveTo(X,ue,B.x,B.y),o.stroke()});let T=[];if(t.nodes.forEach(l=>{let I=t.domainById[l.id]||{},B=I.kind||"other",v=t.timeMode?Tt(I.updated):Ee.colors[B],k=Ee.shapes[B],L=t.selectedId===l.id,P=t.hoverId===l.id,U=t.searchTerm||"",ae=!U||(l.name||"").toLowerCase().includes(U)||String(ke[B]||"").toLowerCase().includes(U)||String(B).toLowerCase().includes(U),X=r==="all"||B===r,ue=N&&l.id!==N&&!t.edges.some(V=>V.sourceNodeId===N&&V.targetNodeId===l.id||V.targetNodeId===N&&V.sourceNodeId===l.id)||U&&!ae||!X;o.save(),o.globalAlpha=ue?.08:1,(L||P)&&(o.shadowColor=v,o.shadowBlur=L?20:14),ve(l.x,l.y,l.r,k);let oe=parseInt(v.slice(1,3),16),be=parseInt(v.slice(3,5),16),ze=parseInt(v.slice(5,7),16),De=o.createRadialGradient(l.x-l.r*.3,l.y-l.r*.3,0,l.x,l.y,l.r*1.2);De.addColorStop(0,"rgba("+Math.min(255,oe+70)+","+Math.min(255,be+70)+","+Math.min(255,ze+70)+",0.95)"),De.addColorStop(1,v),o.fillStyle=De,o.fill(),o.restore(),L?(o.save(),ve(l.x,l.y,l.r+3,k),o.strokeStyle=v,o.lineWidth=3,o.shadowColor=v,o.shadowBlur=12,o.stroke(),o.restore()):P?(o.save(),ve(l.x,l.y,l.r+2,k),o.strokeStyle=v,o.lineWidth=2,o.stroke(),o.restore()):U&&ae?(o.save(),ve(l.x,l.y,l.r+2,k),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):t.multi.indexOf(l.id)>=0&&(o.save(),ve(l.x,l.y,l.r+2,k),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let Pe=Ue(l.name,16);if((L||P||t.zoom>y||!h&&t.zoom>.6)&&X){let V=1/t.zoom;o.font="500 "+(12*V).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let we=o.measureText(Pe).width+16*V,Ae=18*V,Te=l.y+l.r+8*V,at=!0;for(let Be of T)if(l.x-we/2<Be.x+Be.w&&l.x+we/2>Be.x&&Te<Be.y+Be.h&&Te+Ae>Be.y){at=!1;break}if(!at&&!L&&!P)return;T.push({x:l.x-we/2,y:Te,w:we,h:Ae}),o.fillStyle=d()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(l.x-we/2,Te,we,Ae,4*V):o.rect(l.x-we/2,Te,we,Ae),o.fill(),o.strokeStyle=d()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*V,o.stroke(),o.fillStyle=d()?L||P?"#eee":"#bbb":L||P?"#111":"#444",o.textAlign="center",o.fillText(Pe,l.x,Te+13*V)}}),o.restore(),t.marquee){let l=t.marquee,I=Math.min(l.sx,l.ex),B=Math.min(l.sy,l.ey),v=Math.abs(l.ex-l.sx),k=Math.abs(l.ey-l.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(I,B,v,k),o.strokeRect(I,B,v,k),o.restore()}if(t.hoverId&&O.current){let l=t.domainById[t.hoverId],I=t.nodes.find(function(B){return B.id===t.hoverId});if(l&&I){let B=t.edges.filter(function(L){return L.sourceNodeId===l.id||L.targetNodeId===l.id}).length,v=I.x*t.zoom+t.panX,k=I.y*t.zoom+t.panY;O.current.style.display="block",O.current.style.left=v+14+"px",O.current.style.top=k-6+"px",O.current.innerHTML="<b>"+b(l.title||l.name||"")+'</b><br/><span style="opacity:.8">'+b(l.kind||"")+" \xB7 "+B+" \u8FDE\u63A5</span>"}}else O.current&&(O.current.style.display="none")},le=()=>{t.running=!0,t.raf||(t.raf=requestAnimationFrame(He))};t.wake=le,t.render=Xe;let Ke=()=>{let r=t.nodes.length;t.tickCount++;let m=.9-Math.min(.4,t.tickCount/1500),h=r>1e3?3e3:r>100?2e3:r>50?1200:800,y=r>100?.002:.005,N=r>1e3?.012:r>100?.005:.01,T=r>1e3?6:r>200?12:24,l={};t.nodes.forEach(v=>l[v.id]=v);for(let v=0;v<r;v++){if(t.dragNode===t.nodes[v])continue;let k=t.nodes[v],L=0,P=0;for(let X=0;X<r;X++){if(v===X)continue;let ue=k.x-t.nodes[X].x,oe=k.y-t.nodes[X].y,be=Math.sqrt(ue*ue+oe*oe)||1,ze=h/(be*be);L+=ue/be*ze,P+=oe/be*ze}if(t.clustered&&t.typeCenters[k.type]){let X=t.typeCenters[k.type];L+=(X.x-k.x)*.006,P+=(X.y-k.y)*.006}else L-=k.x*N,P-=k.y*N;let U=(k.vx+L)*m,ae=(k.vy+P)*m;U=Math.max(-T,Math.min(T,U)),ae=Math.max(-T,Math.min(T,ae)),k.vx=U,k.vy=ae}t.edges.forEach(v=>{let k=l[v.sourceNodeId],L=l[v.targetNodeId];if(!k||!L)return;let P=L.x-k.x,U=L.y-k.y,ae=Math.sqrt(P*P+U*U)||1,X=(ae-100)*y,ue=P/ae*X,oe=U/ae*X;t.dragNode!==k&&(k.vx+=ue,k.vy+=oe),t.dragNode!==L&&(L.vx-=ue,L.vy-=oe)});let I=0;t.nodes.forEach(v=>{t.dragNode!==v&&(v.x+=v.vx,v.y+=v.vy,I+=v.vx*v.vx+v.vy*v.vy)}),t.autoFitPending&&t.tickCount>45&&(t.autoFitPending=!1,se()),(r?Math.sqrt(I/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)}},$e=(r,b)=>{let m=s.getBoundingClientRect();return{x:(r-m.left-t.panX)/t.zoom,y:(b-m.top-t.panY)/t.zoom}},Oe=(r,b,m)=>Math.max(b,Math.min(m,r)),Ve=r=>{t.mouseX=r.clientX,t.mouseY=r.clientY;let b=$e(r.clientX,r.clientY),m=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(p.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==p.current)continue;let N=y.x-b.x,T=y.y-b.y;if(N*N+T*T<y.r*y.r+36){m=y.id;break}}m!==t.hoverId&&(t.hoverId=m,le())},Ge=r=>{if(r.button!==0)return;let b=$e(r.clientX,r.clientY),m=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(p.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==p.current)continue;let N=y.x-b.x,T=y.y-b.y;if(N*N+T*T<y.r*y.r+25){m=y;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=m||null,m&&(t.dragOffset={dx:m.x-b.x,dy:m.y-b.y})},_e=r=>{if(t.marquee){t.marquee.ex=r.clientX,t.marquee.ey=r.clientY,le();return}if(!t.dragStart)return;let b=r.clientX-t.dragStart.x,m=r.clientY-t.dragStart.y;if(Math.abs(b)+Math.abs(m)>3&&(t.dragging=!0),t.dragNode){let h=$e(r.clientX,r.clientY);t.dragNode.x=h.x+t.dragOffset.dx,t.dragNode.y=h.y+t.dragOffset.dy,le()}else t.dragging&&(t.panX=Oe(t.dragStart.px+b,-1e5,1e5),t.panY=Oe(t.dragStart.py+m,-1e5,1e5),le())},Je=r=>{if(t.marquee){let m=t.marquee;t.marquee=null;let h=s.getBoundingClientRect(),y=Math.min(m.sx,m.ex)-h.left,N=Math.max(m.sx,m.ex)-h.left,T=Math.min(m.sy,m.ey)-h.top,l=Math.max(m.sy,m.ey)-h.top,I=t.nodes.filter(B=>{let v=B.x*t.zoom+t.panX,k=B.y*t.zoom+t.panY;return v>=y&&v<=N&&k>=T&&k<=l}).map(B=>B.id);t.multi=I,he(I),le();return}if(t.dragStart&&!t.dragging){let m=$e(r.clientX,r.clientY),h=null;for(let y=t.nodes.length-1;y>=0;y--){let N=t.nodes[y];if(p.current!=="all"&&(t.domainById[N.id]&&t.domainById[N.id].kind)!==p.current)continue;let T=N.x-m.x,l=N.y-m.y;if(T*T+l*l<N.r*N.r+20){h=N;break}}h?(t.selectedId=h.id,de(h.id),le()):(t.selectedId=null,t.hoverId=null,r.shiftKey||(t.multi=[],he([])),de(null),le())}t.dragStart=null,t.dragging=!1,t.dragNode=null},Ze=r=>{r.preventDefault();let b=$e(r.clientX,r.clientY),m=null;for(let h=t.nodes.length-1;h>=0;h--){let y=t.nodes[h];if(p.current!=="all"&&(t.domainById[y.id]&&t.domainById[y.id].kind)!==p.current)continue;let N=y.x-b.x,T=y.y-b.y;if(N*N+T*T<y.r*y.r+25){m=y;break}}if(m){let h=t.domainById[m.id];h&&ee({x:r.clientX,y:r.clientY,id:m.id,path:h.id,title:h.title})}else ee(null)},Qe=r=>{r.preventDefault();let b=s.getBoundingClientRect(),m=(r.clientX-b.left-t.panX)/t.zoom,h=(r.clientY-b.top-t.panY)/t.zoom,y=Math.max(.3,Math.min(3,t.zoom*(r.deltaY<0?1.1:1/1.1)));t.panX=Oe(t.panX+m*(t.zoom-y),-1e5,1e5),t.panY=Oe(t.panY+h*(t.zoom-y),-1e5,1e5),t.zoom=y,le()};s.addEventListener("mousemove",Ve),s.addEventListener("mousedown",Ge),window.addEventListener("mousemove",_e),window.addEventListener("mouseup",Je),s.addEventListener("wheel",Qe,{passive:!1}),s.addEventListener("contextmenu",Ze),J.current=()=>{t.selectedId=null,t.hoverId=null,t.multi=[],he([]),se(),le()};for(let r=0;r<200;r++)Ke();return se(),le(),()=>{t.running=!1,t.raf&&cancelAnimationFrame(t.raf),Ie.disconnect(),s.removeEventListener("mousemove",Ve),s.removeEventListener("mousedown",Ge),window.removeEventListener("mousemove",_e),window.removeEventListener("mouseup",Je),s.removeEventListener("wheel",Qe),s.removeEventListener("contextmenu",Ze)}},[a,i]),(0,e.jsxs)("div",{className:"me-graph",ref:_,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[a.length," ",n("nodes")," \xB7 ",i.length," ",n("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",className:"mc-btn",style:{padding:"6px 10px",minWidth:140},placeholder:n("search"),value:K,onChange:s=>Fe(s.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:!!E,onChange:s=>C&&C(s.target.checked)}),n("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${M?" me-on":""}`,onClick:()=>Y(s=>!s),children:n("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=G.current;if(s)try{s.toBlob(o=>{o&&re({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:n("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>F.current&&F.current(),children:n("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{de(null),Q("all"),J.current&&J.current()},children:n("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:G,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:O,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(s=>(0,e.jsxs)("span",{className:"lg",children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:s.c}}),s.l]},s.c)):Object.keys(qe).map(s=>(0,e.jsxs)("button",{type:"button",className:`lg${fe===s?" active":""}`,onClick:()=>Q(o=>o===s?"all":s),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[s]||qe[s]}}),n(ke[s])]},s)),!M&&fe!=="all"&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",onClick:()=>Q("all"),children:[n("clearFilter")," \u2715"]})]}),j&&(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")}),D&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ee(null)}),D&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:D.x,top:D.y,zIndex:31},onMouseDown:s=>s.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{ne.current({path:D.path,title:D.title}),ee(null)},children:n("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{D.id&&(z.current.selectedId=D.id,de(D.id)),ee(null);let s=z.current;s&&s.wake&&s.wake()},children:n("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(D.title||"")}catch{}ee(null),W(n("copied"))},children:n("copyName")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let s=D.path;ee(null),window.confirm(n("deleteConfirm"))&&(async()=>{try{(ce.current?await ce.current(s):!1)?W(n("deleted")):W(n("deleteFail"),!1)}catch{W(n("deleteFail"),!1)}})()},children:n("delete")})]}),Z.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[Z.length," ",n("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=Z.map(f=>H[f]).filter(Boolean).map(f=>f.title||f.name).join(`
126
+ `),S=new Blob([o],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(S),x=document.createElement("a");x.href=d,x.download="memory-selected.txt",document.body.appendChild(x),x.click(),document.body.removeChild(x),setTimeout(()=>URL.revokeObjectURL(d),1e3),W(Z.length+n("exportedSel"))},children:n("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(Z.length<2){W(n("mergeNeed"),!1);return}let s=Z.map(S=>H[S]?H[S].id:S);if(!window.confirm(n("mergeConfirm")))return;he([]);let o=z.current;o&&(o.multi=[]),fetch(`${A}/merge?paths=${encodeURIComponent(s.join(","))}`).then(S=>S.json()).then(S=>{S&&S.ok?W(n("merged")):W(n("mergeFail"),!1)}).catch(()=>W(n("mergeFail"),!1))},children:n("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(n("deleteConfirm")))return;let s=Z.map(S=>H[S]?H[S].id:S);he([]);let o=z.current;o&&(o.multi=[]),(async()=>{let S=0;for(let d of s)try{(ce.current?await ce.current(d):!1)&&S++}catch{}W(S+n("deletedSelected"),S>0)})()},children:n("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=z.current;s&&(s.multi=[]),he([]);let o=z.current;o&&o.render&&o.render()},children:n("clearSelection")})]}),R&&(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:H[R]?H[R].title||H[R].name:R}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:H[R]?n(ke[H[R].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:n("graphHint")}),(i.filter(s=>s.source===R||s.target===R)||[]).slice(0,8).map((s,o)=>{let S=s.source===R?s.target:s.source,d=H[S];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:x=>{x.preventDefault();let f=z.current;f&&(f.selectedId=S,f.hoverId=S,f.wake&&f.wake()),de(S)},children:d?(d.title||d.name).slice(0,28):S},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:n("graphTip")}),ye&&(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 "+(ye.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ye.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ye.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ye.msg})]}),pe&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{pe.url&&URL.revokeObjectURL(pe.url),re(null),me(!1)},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:ie?"100vw":900,width:ie?"100vw":"92vw",maxHeight:ie?"100vh":"90vh",height:ie?"100vh":void 0,borderRadius:ie?0:14},onClick:s=>s.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:pe.url,download:"memory-graph.png",onClick:()=>{je("download"),W(n("downloaded")+" \xB7 "+n("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:n(Me==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{je("full"),me(s=>!s),W(n("fullscreen"))},children:n(Me==="full"?"done":ie?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=pe.blob;s&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":s})]).then(()=>{je("copy"),W(n("copied"))}).catch(()=>{W(n("copyFail"),!1)}):W(n("copyFail"),!1)},children:n(Me==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{pe.url&&URL.revokeObjectURL(pe.url),re(null),me(!1)},children:n("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:ie?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:pe.url,alt:n("exportGraph"),style:{maxWidth:"100%",maxHeight:ie?"calc(100vh - 64px)":"70vh",borderRadius:ie?0:8,cursor:"zoom-in"},onClick:()=>me(s=>!s)})})]})]})]})}function Tt(a){let i=new Date(a||0).getTime();if(!i)return"#94a3b8";let g=(Date.now()-i)/864e5;return g<3?"#10b981":g<14?"#f59e0b":g<30?"#f97316":"#94a3b8"}function Bt(a){let i=new Date(a||0).getTime();return!!i&&(Date.now()-i)/864e5<3}async function Lt(a,i,g){if(g&&typeof window.showSaveFilePicker=="function")try{let u=await window.showSaveFilePicker({suggestedName:i}),E=await u.createWritable();return await E.write(a),await E.close(),{ok:!0,picked:!0,name:u.name}}catch(u){return u&&u.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(u.message||u)}}let w=URL.createObjectURL(a),n=document.createElement("a");return n.href=w,n.download=i,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(w),1e3),{ok:!0,picked:!1,name:i}}function nt(a,i){if(!i||!a)return a;let g=a.toLowerCase(),w=i.toLowerCase(),n=[],u=0;for(;u<a.length;){let E=g.indexOf(w,u);if(E<0){n.push(a.slice(u));break}E>u&&n.push(a.slice(u,E)),n.push((0,e.jsx)("mark",{className:"mc-hl",children:a.slice(E,E+w.length)},E)),u=E+w.length}return n}function Et(a){if(!a)return"";let i=String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),g=[];return i=i.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(w,n,u){return g.push("<pre><code>"+u+"</code></pre>"),"\0"+(g.length-1)+"\0"}),i=i.replace(/^(#{1,3})\s+(.+)$/gm,function(w,n,u){return"<h"+n.length+">"+u+"</h"+n.length+">"}),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/`([^`\n]+)`/g,"<code>$1</code>"),i=i.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(w,n,u){return/^(https?:|\/)/.test(u)?'<a href="'+u+'" target="_blank" rel="noopener noreferrer">'+n+"</a>":n}),i=i.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),i=i.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),i=i.replace(/\n/g,"<br/>"),i=i.replace(/\u0000(\d+)\u0000/g,function(w,n){return g[n]}),i}function st(a){if(!a)return"";let i=new Date(a);if(Number.isNaN(i.getTime()))return"";let g=new Date,w=i.toDateString()===g.toDateString(),n=E=>String(E).padStart(2,"0"),u=`${n(i.getHours())}:${n(i.getMinutes())}`;return w?u:`${i.getMonth()+1}-${i.getDate()} ${u}`}
127
127
 
128
128
  return module.exports;
129
129
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-memory-eternal",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {