dsh-memory-eternal 0.4.16 → 0.4.18

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