dsh-memory-eternal 0.6.0 → 0.6.2-beta.1

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
@@ -58,7 +58,7 @@ export const Config = z.object({
58
58
  // init = DSH 激活时拉起一次(默认;最低开销,DSH 死后 web 仍活但无人看守)
59
59
  // interval= DSH 进程内 setInterval 周期探活+自动拉起(额外 0 内存;DSH 死则停保活)
60
60
  // manual = 完全不自动拉起;只在 `dsh-memory open` 时 ensure-alive(最保守)
61
- autoWebMode: z.enum(['init', 'interval', 'manual']).default('init'),
61
+ autoWebMode: z.union([z.const('init'), z.const('interval'), z.const('manual')]).default('init'),
62
62
  webPort: z.number().min(1).max(65535).default(7999),
63
63
  webCheckIntervalMs: z.number().min(1000).max(600000).default(5000),
64
64
  webMaxRestart: z.number().min(1).max(1000).default(10),
package/lib/api.js CHANGED
@@ -170,10 +170,24 @@ export function createApi(deps = {}) {
170
170
  case '/budget': {
171
171
  try {
172
172
  const cfg = getSettings() ?? {}
173
- json(res, 200, { ok: true, budgetChars: cfg.sessionBudgetChars ?? 80000, recallLimit: cfg.recallLimit ?? 5, embedding: cfg.recallEmbedding || '' })
173
+ const env = typeof process !== 'undefined' ? process.env : {}
174
+ json(res, 200, {
175
+ ok: true,
176
+ budgetChars: cfg.sessionBudgetChars ?? 80000,
177
+ recallLimit: cfg.recallLimit ?? 5,
178
+ embedding: cfg.recallEmbedding || '',
179
+ // 服务自管理配置(DSH host 从 settings 读;独立 web server 从 env 兜底)
180
+ autoWeb: cfg.autoWeb ?? env.MEMORY_AUTO_WEB !== '0',
181
+ autoWebMode: cfg.autoWebMode || 'init',
182
+ webPort: Number(cfg.webPort) || Number(env.MEMORY_WEB_PORT) || 7999,
183
+ webCheckIntervalMs: Number(cfg.webCheckIntervalMs) || 5000,
184
+ webMaxRestart: Number(cfg.webMaxRestart) || 10,
185
+ watchdogAutoSpawn: cfg.watchdogAutoSpawn ?? env.MEMORY_WATCHDOG === '1',
186
+ autoMcpSetup: cfg.autoMcpSetup ?? false,
187
+ })
174
188
  } catch (e) {
175
189
  // 配置读取异常时降级返回默认值,避免面板整块红屏
176
- json(res, 200, { ok: true, budgetChars: 80000, recallLimit: 5, embedding: '' })
190
+ json(res, 200, { ok: true, budgetChars: 80000, recallLimit: 5, embedding: '', autoWeb: true, autoWebMode: 'init', webPort: 7999, webCheckIntervalMs: 5000, webMaxRestart: 10, watchdogAutoSpawn: true, autoMcpSetup: false })
177
191
  }
178
192
  return
179
193
  }
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 Ct=Object.create;var Ge=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var Mt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var It=(t,l)=>{for(var d in l)Ge(t,d,{get:l[d],enumerable:!0})},gt=(t,l,d,k)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of St(l))!zt.call(t,m)&&m!==d&&Ge(t,m,{get:()=>l[m],enumerable:!(k=Nt(l,m))||k.enumerable});return t};var Tt=(t,l,d)=>(d=t!=null?Ct(Mt(t)):{},gt(l||!t||!t.__esModule?Ge(d,"default",{value:t,enumerable:!0}):d,t)),Lt=t=>gt(Ge({},"__esModule",{value:!0}),t);var Vt={};It(Vt,{EN:()=>yt,MemoryLibrary:()=>Rt,ZH:()=>ht,apply:()=>$t,inject:()=>Bt});module.exports=Lt(Vt);var s=Tt(require("react"),1),e=require("react/jsx-runtime"),De="memory-eternal",R="/memory-eternal/api",Bt=["settingsScope","slots","locale","connection","remote"],ht={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"\u5916\u90E8 Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u91CC\u7684 autoMcpSetup \u63A7\u5236\u81EA\u52A8\u6302\u8F7D\uFF1B\u624B\u52A8\u8DD1 dsh-memory setup --dry-run \u9884\u89C8\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},yt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"External Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",healthy:"healthy",mcpSetupHint:"Settings \u2192 Memory \u2192 autoMcpSetup controls auto-mount; run dsh-memory setup --dry-run to preview.",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"},Ft=["all","project","knowledge","content","prompt","business","tool","mistake"],Je={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Be={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Ne=`
6
+ var Nt=Object.create;var Ve=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var Tt=(t,i)=>{for(var d in i)Ve(t,d,{get:i[d],enumerable:!0})},gt=(t,i,d,b)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of Mt(i))!zt.call(t,p)&&p!==d&&Ve(t,p,{get:()=>i[p],enumerable:!(b=St(i,p))||b.enumerable});return t};var Lt=(t,i,d)=>(d=t!=null?Nt(It(t)):{},gt(i||!t||!t.__esModule?Ve(d,"default",{value:t,enumerable:!0}):d,t)),Bt=t=>gt(Ve({},"__esModule",{value:!0}),t);var Jt={};Tt(Jt,{EN:()=>ht,MemoryLibrary:()=>Pt,ZH:()=>yt,apply:()=>jt,inject:()=>Ft});module.exports=Bt(Jt);var s=Lt(require("react"),1),e=require("react/jsx-runtime"),Ie="memory-eternal",W="/memory-eternal/api",Ft=["settingsScope","slots","locale","connection","remote"],yt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"\u5916\u90E8 Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u8BBE\u7F6E \u2192 \u8BB0\u5FC6\u91CC\u7684 autoMcpSetup \u63A7\u5236\u81EA\u52A8\u6302\u8F7D\uFF1B\u624B\u52A8\u8DD1 dsh-memory setup --dry-run \u9884\u89C8\u3002",tabConfig:"\u914D\u7F6E",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},ht={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"External Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",healthy:"healthy",mcpSetupHint:"Settings \u2192 Memory \u2192 autoMcpSetup controls auto-mount; run dsh-memory setup --dry-run to preview.",tabConfig:"Config",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",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"},$t=["all","project","knowledge","content","prompt","business","tool","mistake"],_e={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Le={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},he=`
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; }
@@ -122,11 +122,11 @@ var Ct=Object.create;var Ge=Object.defineProperty;var Nt=Object.getOwnPropertyDe
122
122
  .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; }
123
123
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
124
124
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
125
- `;function $t(t){t.effect(()=>t.locale.register(De,{zh:ht,en:yt}),"memory-eternal: locale");let l=t.locale.bind(De);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:De,order:25,label:()=>l("nav"),locale:De,inject:()=>({})},()=>s.default.createElement(jt,{t:l,height:"78vh"}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${De}:footer`,order:100,label:()=>l("nav"),locale:De,inject:()=>({})},d=>s.default.createElement(Dt,{t:l,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function xt(){let[t,l]=(0,s.useState)("http://127.0.0.1:7999/");return(0,s.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&l(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function jt({t,height:l}){let d=xt();return(0,e.jsxs)("div",{style:{width:"100%",height:l||"72vh",display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("iframe",{src:d,title:"memory-eternal",style:{width:"100%",flex:1,border:"1px solid var(--dsw-alias-border-l1, #e5e7eb)",borderRadius:12,background:"var(--dsw-alias-bg-base, #fff)"}})]})}function Dt({t,wide:l}){let[d,k]=(0,s.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${l?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>k(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(vt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(Et,{t,onClose:()=>k(!1)})]})}function Et({t,onClose:l}){let[d,k]=(0,s.useState)(!1),m=xt();return(0,s.useEffect)(()=>{let r=T=>{T.key==="Escape"&&l()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[l]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:l,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("div",{className:"me-modal",onClick:r=>r.stopPropagation(),style:d?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(r=>!r),"aria-label":t(d?"exitFullscreen":"enterFullscreen"),title:t(d?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:d?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:l,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{src:m,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function vt(){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 Rt({t,inModal:l,onClose:d,onFull:k,full:m}){let[r,T]=(0,s.useState)(null),[V,z]=(0,s.useState)([]),[X,G]=(0,s.useState)(!0),[y,h]=(0,s.useState)(""),[S,me]=(0,s.useState)("all"),[_,ue]=(0,s.useState)(""),[O,le]=(0,s.useState)("cards"),[W,se]=(0,s.useState)("recent"),[he,$]=(0,s.useState)(null),U=(0,s.useRef)(null),oe=(0,s.useRef)(null),[we,ye]=(0,s.useState)(!1),[ce,Se]=(0,s.useState)(null),[ke,p]=(0,s.useState)(!1),[M,E]=(0,s.useState)(!0),[L,Y]=(0,s.useState)(null),[Z,P]=(0,s.useState)(0),K=(0,s.useCallback)(()=>P(u=>u+1),[]),ne=(0,s.useRef)(null),[Ce,de]=(0,s.useState)(24),Fe=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(O!=="cards")return;let u=Fe.current;if(!u)return;let C=new IntersectionObserver(o=>{o[0]&&o[0].isIntersecting&&de(n=>n+24)},{rootMargin:"400px"});return C.observe(u),()=>C.disconnect()},[O,V,S,_]);let pe=(0,s.useCallback)(async(u=S,C=_)=>{try{G(!0),h("");let o=new URLSearchParams;u&&u!=="all"&&o.set("kind",u),C.trim()&&o.set("q",C.trim());let f=await(await fetch(`${R}/cards?${o.toString()}`)).json();f.ok&&(z(f.cards||[]),de(24))}catch(o){h(String(o&&o.message?o.message:o))}finally{G(!1)}},[S,_]),ie=(0,s.useCallback)(async()=>{try{let[u,C]=await Promise.all([fetch(`${R}/overview`).then(o=>o.json()),fetch(`${R}/cards`).then(o=>o.json())]);u.ok&&T(u),C.ok&&(z(C.cards||[]),de(24))}catch(u){h(String(u&&u.message?u.message:u))}finally{G(!1)}},[]),Me=async u=>{try{let o=await(await fetch(`${R}/delete?path=${encodeURIComponent(u)}`)).json();o.ok?($({ok:!0,msg:t("deleted")}),await ie()):$({ok:!1,msg:o.error||t("deleteFail")})}catch{$({ok:!1,msg:t("deleteFail")})}U.current&&clearTimeout(U.current),U.current=setTimeout(()=>$(null),2e3)};(0,s.useEffect)(()=>(ie(),()=>{ne.current&&clearTimeout(ne.current)}),[ie]);let Ue=u=>{ue(u),ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>pe(S,u),280)},Re=u=>{me(u),pe(u,_)},Oe=async u=>{try{let o=await(await fetch(`${R}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();o.ok&&Se({path:o.path,title:u.title,text:o.text})}catch(C){h(String(C&&C.message?C.message:C))}},ze=async(u,C)=>{ye(!0);try{let o=await fetch(`${R}/export`);if(!o.ok)throw new Error("HTTP "+o.status);let n=await o.json();if(!n.ok)throw new Error(n.error||"export failed");let f,B,q;u==="json"?(B="memory-vault.json",q="application/json",f=JSON.stringify(n.cards.map(xe=>({path:xe.path,title:xe.title,kind:xe.kind,text:xe.text})),null,2)):(B="memory-vault.md",q="text/markdown;charset=utf-8",f=n.cards.map(xe=>xe.text.trim()).filter(Boolean).join(`
125
+ `;function jt(t){t.effect(()=>t.locale.register(Ie,{zh:yt,en:ht}),"memory-eternal: locale");let i=t.locale.bind(Ie);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Ie,order:25,label:()=>i("nav"),locale:Ie,inject:()=>({})},()=>s.default.createElement(Rt,{t:i,height:"78vh"}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ie}:footer`,order:100,label:()=>i("nav"),locale:Ie,inject:()=>({})},d=>s.default.createElement(Dt,{t:i,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ie}:footer-config`,order:101,label:()=>i("tabConfig"),locale:Ie,inject:()=>({})},d=>s.default.createElement(Et,{t:i,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer config")}function xt(){let[t,i]=(0,s.useState)("http://127.0.0.1:7999/");return(0,s.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&i(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function Rt({t,height:i}){let d=xt();return(0,e.jsxs)("div",{style:{width:"100%",height:i||"72vh",display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)("style",{children:he}),(0,e.jsx)("iframe",{src:d,title:"memory-eternal",style:{width:"100%",flex:1,border:"1px solid var(--dsw-alias-border-l1, #e5e7eb)",borderRadius:12,background:"var(--dsw-alias-bg-base, #fff)"}})]})}function Dt({t,wide:i}){let[d,b]=(0,s.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:he}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>b(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(wt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(vt,{t,onClose:()=>b(!1)})]})}function Et({t,wide:i}){let[d,b]=(0,s.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:he}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>b(!0),"aria-label":t("tabConfig"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Ot,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("tabConfig")})]}),d&&(0,e.jsx)(vt,{t,tab:"config",onClose:()=>b(!1)})]})}function Ot(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",fill:"none",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3.2",stroke:"currentColor",strokeWidth:"1.6"}),(0,e.jsx)("path",{d:"M19.4 12a7.4 7.4 0 0 0-.1-1.1l2-1.5-2-3.4-2.3.9a7.4 7.4 0 0 0-1.9-1.1L14.6 3h-5.2l-.5 2.8a7.4 7.4 0 0 0-1.9 1.1l-2.3-.9-2 3.4 2 1.5a7.4 7.4 0 0 0 0 2.2l-2 1.5 2 3.4 2.3-.9a7.4 7.4 0 0 0 1.9 1.1l.5 2.8h5.2l.5-2.8a7.4 7.4 0 0 0 1.9-1.1l2.3.9 2-3.4-2-1.5c.06-.36.1-.73.1-1.1Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}function vt({t,onClose:i,tab:d}){let[b,p]=(0,s.useState)(!1),r=xt(),T=d?`${r.replace(/\/$/,"")}/?tab=${d}`:r;return(0,s.useEffect)(()=>{let j=I=>{I.key==="Escape"&&i()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[i]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:i,children:[(0,e.jsx)("style",{children:he}),(0,e.jsx)("div",{className:"me-modal",onClick:j=>j.stopPropagation(),style:b?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>p(j=>!j),"aria-label":t(b?"exitFullscreen":"enterFullscreen"),title:t(b?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:b?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:i,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{src:T,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function wt(){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 Pt({t,inModal:i,onClose:d,onFull:b,full:p}){let[r,T]=(0,s.useState)(null),[j,I]=(0,s.useState)([]),[A,X]=(0,s.useState)(!0),[x,h]=(0,s.useState)(""),[v,G]=(0,s.useState)("all"),[N,Q]=(0,s.useState)(""),[F,ie]=(0,s.useState)(()=>{try{if(new URLSearchParams(typeof location<"u"?location.search:"").get("tab")==="config")return"config"}catch{}return"cards"}),[_,J]=(0,s.useState)("recent"),[xe,E]=(0,s.useState)(null),Y=(0,s.useRef)(null),ke=(0,s.useRef)(null),[g,L]=(0,s.useState)(!1),[$,K]=(0,s.useState)(null),[re,V]=(0,s.useState)(!1),[z,ce]=(0,s.useState)(!0),[ee,ue]=(0,s.useState)(null),[Be,Je]=(0,s.useState)(0),ge=(0,s.useCallback)(()=>Je(m=>m+1),[]),de=(0,s.useRef)(null),[Ce,pe]=(0,s.useState)(24),Fe=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(F!=="cards")return;let m=Fe.current;if(!m)return;let S=new IntersectionObserver(o=>{o[0]&&o[0].isIntersecting&&pe(n=>n+24)},{rootMargin:"400px"});return S.observe(m),()=>S.disconnect()},[F,j,v,N]);let me=(0,s.useCallback)(async(m=v,S=N)=>{try{X(!0),h("");let o=new URLSearchParams;m&&m!=="all"&&o.set("kind",m),S.trim()&&o.set("q",S.trim());let f=await(await fetch(`${W}/cards?${o.toString()}`)).json();f.ok&&(I(f.cards||[]),pe(24))}catch(o){h(String(o&&o.message?o.message:o))}finally{X(!1)}},[v,N]),le=(0,s.useCallback)(async()=>{try{let[m,S]=await Promise.all([fetch(`${W}/overview`).then(o=>o.json()),fetch(`${W}/cards`).then(o=>o.json())]);m.ok&&T(m),S.ok&&(I(S.cards||[]),pe(24))}catch(m){h(String(m&&m.message?m.message:m))}finally{X(!1)}},[]),Ne=async m=>{try{let o=await(await fetch(`${W}/delete?path=${encodeURIComponent(m)}`)).json();o.ok?(E({ok:!0,msg:t("deleted")}),await le()):E({ok:!1,msg:o.error||t("deleteFail")})}catch{E({ok:!1,msg:t("deleteFail")})}Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),2e3)};(0,s.useEffect)(()=>(le(),()=>{de.current&&clearTimeout(de.current)}),[le]);let Ae=m=>{Q(m),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>me(v,m),280)},De=m=>{G(m),me(m,N)},Ee=async m=>{try{let o=await(await fetch(`${W}/card?path=${encodeURIComponent(m.path||m.id)}`)).json();o.ok&&K({path:o.path,title:m.title,text:o.text})}catch(S){h(String(S&&S.message?S.message:S))}},Se=async(m,S)=>{L(!0);try{let o=await fetch(`${W}/export`);if(!o.ok)throw new Error("HTTP "+o.status);let n=await o.json();if(!n.ok)throw new Error(n.error||"export failed");let f,R,H;m==="json"?(R="memory-vault.json",H="application/json",f=JSON.stringify(n.cards.map(ve=>({path:ve.path,title:ve.title,kind:ve.kind,text:ve.text})),null,2)):(R="memory-vault.md",H="text/markdown;charset=utf-8",f=n.cards.map(ve=>ve.text.trim()).filter(Boolean).join(`
126
126
 
127
127
  ---
128
128
 
129
- `));let re=new Blob([f],{type:q}),a=await Xt(re,B,!1);if(!a.ok){$({ok:!1,msg:t("exportFail")}),ye(!1);return}$({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+a.name})}catch(o){$({ok:!1,msg:t("exportFail")+" \xB7 "+(o.message||"")})}finally{ye(!1)}U.current&&clearTimeout(U.current),U.current=setTimeout(()=>$(null),2600)},Te=async u=>{let C=u.target.files&&u.target.files[0];if(u.target.value="",!!C){try{let o=await C.text(),f=await(await fetch(`${R}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:o})).json();f.ok?(await ie(),$({ok:!0,msg:t("importedVault")+"\uFF1A"+(f.imported||0)+(f.skipped?t("importedSkipped")+f.skipped:"")})):$({ok:!1,msg:f.error||t("importFail")})}catch{$({ok:!1,msg:t("importFail")})}U.current&&clearTimeout(U.current),U.current=setTimeout(()=>$(null),2400)}},A=(0,s.useMemo)(()=>{let u=V.slice();return W==="title"?u.sort((C,o)=>String(C.title||"").localeCompare(String(o.title||""))):W==="hot"?u.sort((C,o)=>(o.weight||o.links||0)-(C.weight||C.links||0)):u.sort((C,o)=>new Date(o.updated||0).getTime()-new Date(C.updated||0).getTime()),u},[V,W]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ne}),he&&(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 "+(he.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:he.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:he.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:he.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)(vt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),k&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:k,"aria-label":t(m?"exitFull":"fullscreen"),children:m?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${M?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>E(u=>!u),"aria-label":t(M?"collapse":"expand"),title:t(M?"collapse":"expand"),children:M?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${O==="cards"?" active":""}`,onClick:()=>le("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),M&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${O==="graph"?" active":""}`,onClick:()=>le("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),M&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${O==="stats"?" active":""}`,onClick:()=>le("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),M&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${O==="optimize"?" active":""}`,onClick:()=>le("optimize"),title:t("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),M&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabOptimize")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[O==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(_e,{label:t("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(_e,{label:t("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(_e,{label:t("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(_e,{label:t("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),O==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:_,onChange:u=>Ue(u.target.value)}),(0,e.jsx)("input",{ref:oe,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Te}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>oe.current&&oe.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>Y({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:we,onClick:()=>ze("md"),children:t(we?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:we,onClick:()=>ze("json"),children:t(we?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ie(),children:t("refresh")})]}),O==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Ft.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${S===u?" active":""}`,onClick:()=>Re(u),children:t(u==="all"?"all":Be[u])},u)),(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(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${W===u.key?" active":""}`,onClick:()=>se(u.key),children:u.label},u.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),O==="cards"?X&&!V.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):V.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:A.slice(0,Ce).map(u=>(0,e.jsx)(Ot,{card:u,t,query:_.trim(),onOpen:Oe,onDelete:Me},u.path))}),A.length>Ce&&(0,e.jsx)("div",{ref:Fe,style:{height:1}})]}):O==="graph"?(0,e.jsx)(Wt,{t,onOpen:Oe,all:ke,onAllChange:p,onMutate:K}):O==="stats"?(0,e.jsx)(ft,{t,tab:"stats",onReload:()=>ie(),version:Z}):(0,e.jsx)(ft,{t,tab:"optimize",onReload:()=>ie(),version:Z}),ce&&(0,e.jsx)(At,{t,card:ce,query:_.trim(),onClose:()=>Se(null),onDelete:u=>{Se(null),Me(u)},onFeedback:u=>{let C=ce.path;fetch(`${R}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:_.trim(),path:C,useful:u})}).then(()=>$({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>$(null),2e3)}}),(0,e.jsx)(Pt,{t,newCard:L,setNewCard:Y,onCreated:()=>{ie(),K(),$({ok:!0,msg:t("created")}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>$(null),2e3)}})]})]})]})}var _e=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]}),Ot=({card:t,t:l,onOpen:d,query:k,onDelete:m})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Je[t.kind]||Je.other}}),k?bt(t.title,k):t.title,Ht(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")})]}),(0,e.jsx)("p",{children:k?bt(t.summary||"",k):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:l(Be[t.kind])}),(0,e.jsx)("span",{children:wt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:r=>{r.stopPropagation(),window.confirm(l("deleteConfirm"))&&m&&m(t.path)},children:"\u2715"})]})]});function ft({t,tab:l,onReload:d,version:k}){let[m,r]=(0,s.useState)(null),[T,V]=(0,s.useState)(""),[z,X]=(0,s.useState)(null),[G,y]=(0,s.useState)(null),[h,S]=(0,s.useState)(null),[me,_]=(0,s.useState)(!1),[ue,O]=(0,s.useState)(""),[le,W]=(0,s.useState)(""),[se,he]=(0,s.useState)(!1),$=(0,s.useCallback)(async()=>{if(ue){O("");return}try{let p=await fetch(`${R}/todayBrief`).then(M=>M.json());O(p.ok&&p.brief||"")}catch{}},[ue]),U=(0,s.useCallback)(async()=>{if(!(!z||!z.merge||!z.merge.length)&&window.confirm(t("mergeAllConfirm"))){W("merge");try{let p={},M=P=>p[P]===void 0?P:p[P]=M(p[P]),E=(P,K)=>{p[M(P)]=M(K)},L=new Set;for(let P of z.merge)L.add(P.a.path),L.add(P.b.path),E(P.a.path,P.b.path);let Y={};for(let P of L){let K=M(P);(Y[K]=Y[K]||[]).push(P)}let Z=0;for(let P of Object.values(Y)){if(P.length<2)continue;(await fetch(`${R}/merge?paths=${encodeURIComponent(P.join(","))}`).then(ne=>ne.json())).ok&&Z++}await oe(),d&&d()}catch{}W("")}},[z,oe,d,t]);async function oe(){try{let p=await Promise.all([fetch(`${R}/stats`),fetch(`${R}/optimize`),fetch(`${R}/budget`),fetch(`${R}/setup-status`)]),[M,E,L,Y]=await Promise.all(p.map(Z=>Z.json()));M.ok&&r(M),E.ok&&X(E),L.ok&&y(L),Y&&Y.ok&&S(Y),V(M.ok&&E.ok?"":t("adminLoadFail"))}catch{V(t("adminLoadFail"))}}let we=(0,s.useCallback)(async p=>{_(!0);try{window.prompt(t("setupRunInTerminal"),"dsh-memory setup"+(p&&p.length?" --"+p.join("-only --")+"-only":""))}finally{_(!1)}},[t]);(0,s.useEffect)(()=>{oe()},[k]);let ye=async(p,M)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${R}/merge?paths=${encodeURIComponent(p+","+M)}`).then(L=>L.json())).ok&&(await oe(),d&&d())}catch{}},ce=async p=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${R}/delete?path=${encodeURIComponent(p)}`).then(E=>E.json())).ok&&(await oe(),d&&d())}catch{}},Se=["project","knowledge","content","prompt","business","tool","mistake"],ke=({title:p,kind:M,updated:E,path:L})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[M]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:wt(E)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ce(L),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:Ne}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[T&&(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 ",T]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:oe,children:["\u21BB ",t("retry")]})]}),h&&h.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",disabled:!!me,onClick:()=>we(),children:["\u21BB ",t("rerunSetup")]})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:h.agents.map(p=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:p.name}),!p.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),p.installed&&p.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("noMcpEntry"),")"]}),p.mcpConfigured===!0&&p.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["\u26A0 ",t("nodePathMismatch")]}),p.mcpMatchesCurrentNode===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]})]}),p.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",p.hook]})]},p.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:$,children:ue?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),ue&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:ue})]}),m&&(0,e.jsxs)(e.Fragment,{children:[m.trend&&m.trend.length>0&&(()=>{let p=m.trend,M=Math.max(...p.map(Z=>Z.count),1),E=260,L=50,Y=E/p.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:E,height:L,style:{display:"block",width:"100%",height:50},children:p.map((Z,P)=>{let K=Math.round(Z.count/M*(L-4));return(0,e.jsx)("rect",{x:P*Y+1,y:L-K,width:Math.max(Y-2,2),height:K,rx:1.5,fill:Z.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:Z.count>0?.85:.35},Z.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.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:Se.map(p=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[p]||"#666"}}),t(Be[p]),": ",m.byKind?.[p]||0]},p))})]}),G&&(G.budgetChars||G.recallLimit||G.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:G.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:G.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",G.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",m.todayCards?.length||0,"\uFF09"]}),m.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:m.todayCards.map(p=>(0,e.jsx)(ke,{title:p.title,kind:p.kind,updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("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",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),z.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!le,onClick:U,children:t(le==="merge"?"exporting":"batchMerge")})]}),z.merge?.length>0&&(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",borderTop:"1px solid rgba(127,127,127,0.12)",paddingTop:8,flexWrap:"wrap"},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!le,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){W("oneclick");try{let p=JSON.stringify({cleanupStale:se}),E=await(await fetch(`${R}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:p})).json();E&&E.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${E.plan.merged} ${t("optimizedMerged")}${se?` \xB7 ${E.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await oe(),d&&d()):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{W("")}}},children:le==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:se,onChange:p=>he(p.target.checked)}),t("oneClickAlsoStale")]})]})]}),(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((p,M)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.a.title," \u21C4 ",p.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(p.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ye(p.a.path,p.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&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!le,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;W("clean");let p=0;for(let M of z.stale)try{await fetch(`${R}/delete?path=${encodeURIComponent(M.path)}`),p++}catch{}W(""),notify(`${p} ${t("deletedStale")}`),await oe(),d&&d()},children:t("cleanStale")})}),z.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.stale.map(p=>(0,e.jsx)(ke,{title:p.title,kind:"other",updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})}var et=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
129
+ `));let se=new Blob([f],{type:H}),a=await Gt(se,R,!1);if(!a.ok){E({ok:!1,msg:t("exportFail")}),L(!1);return}E({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+a.name})}catch(o){E({ok:!1,msg:t("exportFail")+" \xB7 "+(o.message||"")})}finally{L(!1)}Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),2600)},ze=async m=>{let S=m.target.files&&m.target.files[0];if(m.target.value="",!!S){try{let o=await S.text(),f=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:o})).json();f.ok?(await le(),E({ok:!0,msg:t("importedVault")+"\uFF1A"+(f.imported||0)+(f.skipped?t("importedSkipped")+f.skipped:"")})):E({ok:!1,msg:f.error||t("importFail")})}catch{E({ok:!1,msg:t("importFail")})}Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),2400)}},U=(0,s.useMemo)(()=>{let m=j.slice();return _==="title"?m.sort((S,o)=>String(S.title||"").localeCompare(String(o.title||""))):_==="hot"?m.sort((S,o)=>(o.weight||o.links||0)-(S.weight||S.links||0)):m.sort((S,o)=>new Date(o.updated||0).getTime()-new Date(S.updated||0).getTime()),m},[j,_]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:he}),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",{children:xe.msg})]}),i&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(wt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),b&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:b,"aria-label":t(p?"exitFull":"fullscreen"),children:p?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${z?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>ce(m=>!m),"aria-label":t(z?"collapse":"expand"),title:t(z?"collapse":"expand"),children:z?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="cards"?" active":""}`,onClick:()=>ie("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="graph"?" active":""}`,onClick:()=>ie("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="stats"?" active":""}`,onClick:()=>ie("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="optimize"?" active":""}`,onClick:()=>ie("optimize"),title:t("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabOptimize")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="config"?" active":""}`,onClick:()=>ie("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[F==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ge,{label:t("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(Ge,{label:t("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(Ge,{label:t("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(Ge,{label:t("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:N,onChange:m=>Ae(m.target.value)}),(0,e.jsx)("input",{ref:ke,type:"file",accept:".json,application/json",style:{display:"none"},onChange:ze}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ke.current&&ke.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ue({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:g,onClick:()=>Se("md"),children:t(g?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:g,onClick:()=>Se("json"),children:t(g?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>le(),children:t("refresh")})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[$t.map(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${v===m?" active":""}`,onClick:()=>De(m),children:t(m==="all"?"all":Le[m])},m)),(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(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${_===m.key?" active":""}`,onClick:()=>J(m.key),children:m.label},m.key))]}),x&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",x]}),F==="cards"?A&&!j.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):j.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:U.slice(0,Ce).map(m=>(0,e.jsx)(At,{card:m,t,query:N.trim(),onOpen:Ee,onDelete:Ne},m.path))}),U.length>Ce&&(0,e.jsx)("div",{ref:Fe,style:{height:1}})]}):F==="graph"?(0,e.jsx)(Ht,{t,onOpen:Ee,all:re,onAllChange:V,onMutate:ge}):F==="stats"?(0,e.jsx)(ft,{t,tab:"stats",onReload:()=>le(),version:Be}):F==="config"?(0,e.jsx)(Wt,{t,onReload:()=>le(),version:Be}):(0,e.jsx)(ft,{t,tab:"optimize",onReload:()=>le(),version:Be}),$&&(0,e.jsx)(Yt,{t,card:$,query:N.trim(),onClose:()=>K(null),onDelete:m=>{K(null),Ne(m)},onFeedback:m=>{let S=$.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:N.trim(),path:S,useful:m})}).then(()=>E({ok:!0,msg:t(m?"fbUseful":"fbIrr")})).catch(()=>{}),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),2e3)}}),(0,e.jsx)(Ut,{t,newCard:ee,setNewCard:ue,onCreated:()=>{le(),ge(),E({ok:!0,msg:t("created")}),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),2e3)}})]})]})]})}var Ge=({label:t,value:i})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:i}),(0,e.jsx)("span",{children:t})]});function Wt({t,onReload:i,version:d}){let[b,p]=(0,s.useState)(null),[r,T]=(0,s.useState)(null),[j,I]=(0,s.useState)(""),[A,X]=(0,s.useState)(""),[x,h]=(0,s.useState)(""),v=(0,s.useCallback)(async()=>{try{let[N,Q]=await Promise.all([fetch(`${W}/budget`).then(F=>F.json()),fetch(`${W}/setup-status`).then(F=>F.json())]);N.ok&&p(N),Q&&Q.ok&&T(Q)}catch{X(t("adminLoadFail"))}},[t]);(0,s.useEffect)(()=>{v()},[d,v]);let G=N=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[N]||N;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:he}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[A&&(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 ",A]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:v,children:["\u21BB ",t("retry")]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("editInSetting")})]}),b?(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8,fontSize:12},children:[["autoWeb",t("autoWeb")],["autoWebMode",G(b.autoWebMode)],["webPort",String(b.webPort)],["webCheckIntervalMs",`${b.webCheckIntervalMs}ms`],["webMaxRestart",String(b.webMaxRestart)],["watchdogAutoSpawn",b.watchdogAutoSpawn?t("enabled"):t("disabled")],["autoMcpSetup",b.autoMcpSetup?t("enabled"):t("disabled")]].map(([N,Q])=>(0,e.jsxs)("div",{style:{padding:"6px 8px",border:"1px solid var(--dsw-alias-border-l1, #e5e7eb)",borderRadius:8,background:"var(--dsw-alias-bg-base, #f9fafb)"},children:[(0,e.jsx)("div",{style:{opacity:.6,fontSize:11,marginBottom:2},children:N}),(0,e.jsx)("div",{style:{fontWeight:600},children:Q})]},N))}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]}),r&&r.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!x,onClick:async()=>{h("setup"),I("dsh-memory setup");let N="";try{let F=await(await fetch(`${W}/setup-status`,{method:"GET"})).json();N=F.agents?F.agents.filter(ie=>ie.installed&&!ie.mcpConfigured).map(ie=>ie.name):[]}finally{h(""),i&&i(),v()}},children:t("rerunSetup")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.agents.map(N=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:N.name}),!N.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),N.installed&&N.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("noMcpEntry"),")"]}),N.mcpConfigured===!0&&N.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["\u26A0 ",t("nodePathMismatch")]}),N.mcpMatchesCurrentNode===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]})]}),N.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",N.hook]})]},N.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),j&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:j})})]})]})]})}var At=({card:t,t:i,onOpen:d,query:b,onDelete:p})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[t.kind]||_e.other}}),b?bt(t.title,b):t.title,Vt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:i("newBadge")})]}),(0,e.jsx)("p",{children:b?bt(t.summary||"",b):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:i(Le[t.kind])}),(0,e.jsx)("span",{children:kt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:i("delete"),onClick:r=>{r.stopPropagation(),window.confirm(i("deleteConfirm"))&&p&&p(t.path)},children:"\u2715"})]})]});function ft({t,tab:i,onReload:d,version:b}){let[p,r]=(0,s.useState)(null),[T,j]=(0,s.useState)(""),[I,A]=(0,s.useState)(null),[X,x]=(0,s.useState)(null),[h,v]=(0,s.useState)(""),[G,N]=(0,s.useState)(""),[Q,F]=(0,s.useState)(!1),ie=(0,s.useCallback)(async()=>{if(h){v("");return}try{let g=await fetch(`${W}/todayBrief`).then(L=>L.json());v(g.ok&&g.brief||"")}catch{}},[h]),_=(0,s.useCallback)(async()=>{if(!(!I||!I.merge||!I.merge.length)&&window.confirm(t("mergeAllConfirm"))){N("merge");try{let g={},L=z=>g[z]===void 0?z:g[z]=L(g[z]),$=(z,ce)=>{g[L(z)]=L(ce)},K=new Set;for(let z of I.merge)K.add(z.a.path),K.add(z.b.path),$(z.a.path,z.b.path);let re={};for(let z of K){let ce=L(z);(re[ce]=re[ce]||[]).push(z)}let V=0;for(let z of Object.values(re)){if(z.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(z.join(","))}`).then(ee=>ee.json())).ok&&V++}await J(),d&&d()}catch{}N("")}},[I,J,d,t]);async function J(){try{let g=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/optimize`),fetch(`${W}/budget`)]),[L,$,K]=await Promise.all(g.map(re=>re.json()));L.ok&&r(L),$.ok&&A($),K.ok&&x(K),j(L.ok&&$.ok?"":t("adminLoadFail"))}catch{j(t("adminLoadFail"))}}(0,s.useEffect)(()=>{J()},[b]);let xe=async(g,L)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(g+","+L)}`).then(K=>K.json())).ok&&(await J(),d&&d())}catch{}},E=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(g)}`).then($=>$.json())).ok&&(await J(),d&&d())}catch{}},Y=["project","knowledge","content","prompt","business","tool","mistake"],ke=({title:g,kind:L,updated:$,path:K})=>(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:Re.colors[L]||"#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:kt($)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>E(K),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:he}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[T&&(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 ",T]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:J,children:["\u21BB ",t("retry")]})]}),i==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:ie,children:h?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),h&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:h})]}),p&&(0,e.jsxs)(e.Fragment,{children:[p.trend&&p.trend.length>0&&(()=>{let g=p.trend,L=Math.max(...g.map(V=>V.count),1),$=260,K=50,re=$/g.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:$,height:K,style:{display:"block",width:"100%",height:50},children:g.map((V,z)=>{let ce=Math.round(V.count/L*(K-4));return(0,e.jsx)("rect",{x:z*re+1,y:K-ce,width:Math.max(re-2,2),height:ce,rx:1.5,fill:V.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:V.count>0?.85:.35},V.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.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:Y.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Re.colors[g]||"#666"}}),t(Le[g]),": ",p.byKind?.[g]||0]},g))})]}),X&&(X.budgetChars||X.recallLimit||X.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:X.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:X.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",X.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",p.todayCards?.length||0,"\uFF09"]}),p.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:p.todayCards.map(g=>(0,e.jsx)(ke,{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")})]})]})]}),i==="optimize"&&(0,e.jsx)("div",{children:I&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!G,onClick:_,children:t(G==="merge"?"exporting":"batchMerge")})]}),I.merge?.length>0&&(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",borderTop:"1px solid rgba(127,127,127,0.12)",paddingTop:8,flexWrap:"wrap"},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!G,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){N("oneclick");try{let g=JSON.stringify({cleanupStale:Q}),$=await(await fetch(`${W}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();$&&$.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${$.plan.merged} ${t("optimizedMerged")}${Q?` \xB7 ${$.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await J(),d&&d()):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{N("")}}},children:G==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:Q,onChange:g=>F(g.target.checked)}),t("oneClickAlsoStale")]})]})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),I.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:I.merge.map((g,L)=>(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:()=>xe(g.a.path,g.b.path),children:t("mergeNow")})]},L))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",I.stale?.length||0,"\uFF09"]}),I.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!G,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;N("clean");let g=0;for(let L of I.stale)try{await fetch(`${W}/delete?path=${encodeURIComponent(L.path)}`),g++}catch{}N(""),notify(`${g} ${t("deletedStale")}`),await J(),d&&d()},children:t("cleanStale")})}),I.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.stale.map(g=>(0,e.jsx)(ke,{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")})]})})]})]})}var et=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
130
130
 
131
131
  ## \u80CC\u666F
132
132
  - \u95EE\u9898\u63CF\u8FF0
@@ -171,8 +171,8 @@ var Ct=Object.create;var Ge=Object.defineProperty;var Nt=Object.getOwnPropertyDe
171
171
  -
172
172
 
173
173
  ## \u98CE\u9669/\u963B\u585E
174
- - `}];function Pt({t,newCard:l,setNewCard:d,onCreated:k}){if(!l)return null;let m=et.find(y=>y.key===l.template),r=l.body||(m?m.body:""),T=l.kind||(m?m.kind:"knowledge"),V=l.tags||(m?m.tags.join(", "):""),z=l._creating,X=y=>{let h=et.find(S=>S.key===y);d(S=>({...S,template:y,kind:h?h.kind:S.kind,body:h?h.body:S.body,tags:h?h.tags.join(", "):S.tags}))},G=async()=>{if(!(!l.title&&!r)){d(y=>({...y,_creating:!0}));try{(await fetch(`${R}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||"\u65E0\u6807\u9898",kind:T,tags:V.split(",").map(h=>h.trim()).filter(Boolean),body:r,source:"manual"})}).then(h=>h.json())).ok?(d(null),k&&k()):d(h=>({...h,_creating:!1}))}catch{d(h=>({...h,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[et.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>X(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:T,onChange:y=>d(h=>({...h,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(h=>({...h,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:V,onChange:y=>d(h=>({...h,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:r,onChange:y=>d(h=>({...h,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:z,onClick:G,children:t(z?"exporting":"createCard")})})]})]})]})}function At({t,card:l,query:d,onClose:k,onDelete:m,onFeedback:r}){(0,s.useEffect)(()=>{let X=G=>{G.key==="Escape"&&k()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[k]);let[T,V]=(0,s.useState)(!1),z=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:k,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",onClick:X=>X.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:[d&&(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")]})]}),z&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>V(X=>!X),children:t(T?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&m&&m(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:k,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:T?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Kt(l.text)}})]})]})}function Wt({t,onOpen:l,all:d,onAllChange:k,onMutate:m}){let[r,T]=(0,s.useState)(null),[V,z]=(0,s.useState)(""),X=(0,s.useCallback)(async()=>{try{let S=await(await fetch(`${R}/graph${d?"?all=1":""}`)).json();S.ok?(T(S),z("")):(T(null),z(S.error||t("error")))}catch(h){z(String(h&&h.message?h.message:h))}},[d,t]);(0,s.useEffect)(()=>{let h=!0;return fetch(`${R}/graph${d?"?all=1":""}`).then(S=>S.json()).then(S=>{h&&(S.ok?(T(S),z("")):(T(null),z(S.error||t("error"))))}).catch(S=>{h&&z(String(S&&S.message?S.message:S))}),()=>{h=!1}},[d,t]);let G=(0,s.useCallback)(async h=>{try{let me=await(await fetch(`${R}/delete?path=${encodeURIComponent(h)}`)).json();return me&&me.ok?(await X(),m&&m(),!0):!1}catch{return!1}},[X]),y=(0,s.useCallback)(async h=>{if(!h||h.length<2)return!1;try{let S=await fetch(`${R}/merge?paths=${encodeURIComponent(h.join(","))}`).then(me=>me.json());return S&&S.ok?(await X(),m&&m(),!0):!1}catch{return!1}},[X,m]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ne}),V&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",V]}),!r&&!V&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),r&&r.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),r&&r.nodes.length>0&&(0,e.jsx)(Yt,{nodes:r.nodes,edges:r.edges,onOpen:l,onDelete:G,onMerge:y,t,all:d,onAllChange:k,countLabel:`${r.nodes.length} ${t("nodes")} \xB7 ${Ut(r.edges)} ${t("edges")}`})]})}function Ut(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var Ee={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Yt({nodes:t,edges:l,onOpen:d,onDelete:k,onMerge:m,t:r,countLabel:T,all:V,onAllChange:z}){let X=(0,s.useRef)(null),G=(0,s.useRef)(null),y=(0,s.useRef)(null),h=(0,s.useRef)(null),S=(0,s.useRef)(null),me=(0,s.useRef)(d);(0,s.useEffect)(()=>{me.current=d},[d]);let _=(0,s.useRef)(k);(0,s.useEffect)(()=>{_.current=k},[k]);let ue=(0,s.useRef)(m);(0,s.useEffect)(()=>{ue.current=m},[m]);let[O,le]=(0,s.useState)(""),[W,se]=(0,s.useState)(null),he=(0,s.useRef)("");(0,s.useEffect)(()=>{he.current=O.trim().toLowerCase()},[O]),(0,s.useEffect)(()=>{let o=y.current;if(!o)return;let n=O.trim().toLowerCase();if(!n)return;let f=o.nodes.find(B=>(B.name||"").toLowerCase().includes(n));f&&(y.current.selectedId=f.id,se(f.id),o.panX=o.w/2-f.x*o.zoom,o.panY=o.h/2-f.y*o.zoom,o.render&&o.render())},[O]);let[$,U]=(0,s.useState)("all"),[oe,we]=(0,s.useState)(!1),ye=(0,s.useRef)("all"),[ce,Se]=(0,s.useState)(""),ke=(0,s.useRef)(""),[p,M]=(0,s.useState)(!1),E=(0,s.useRef)(!1),[L,Y]=(0,s.useState)(null);(0,s.useEffect)(()=>{ye.current=$},[$]),(0,s.useEffect)(()=>{ke.current=ce},[ce]),(0,s.useEffect)(()=>{E.current=p},[p]);let Z=(0,s.useMemo)(()=>{let o=new Map;for(let n of t)for(let f of n.tags||[]){let B=String(f).trim();B&&o.set(B,(o.get(B)||0)+1)}return[...o.entries()].sort((n,f)=>f[1]-n[1]).slice(0,24).map(([n,f])=>({tag:n,n:f}))},[t]),P=(()=>{let o=O.trim().toLowerCase();return!!o&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(o)||String(n.kind||"").toLowerCase().includes(o)||String(Be[n.kind]||"").toLowerCase().includes(o))})();(0,s.useEffect)(()=>{let o=y.current;o&&o.wake&&o.wake()},[O]),(0,s.useEffect)(()=>{let o=y.current;o&&o.render&&o.render()},[$,ce,p]);let K=(0,s.useRef)(null),[ne,Ce]=(0,s.useState)([]),[de,Fe]=(0,s.useState)(null),[pe,ie]=(0,s.useState)(!1),[Me,Ue]=(0,s.useState)(null),[Re,Oe]=(0,s.useState)(""),ze=(0,s.useRef)(null),Te=(0,s.useRef)(null),A=(o,n=!0)=>{ze.current&&clearTimeout(ze.current),Ue({msg:o,ok:n}),ze.current=setTimeout(()=>Ue(null),1900)},u=o=>{Oe(o),Te.current&&clearTimeout(Te.current),Te.current=setTimeout(()=>Oe(""),1600)};(0,s.useEffect)(()=>()=>{ze.current&&clearTimeout(ze.current),Te.current&&clearTimeout(Te.current)},[]);let C=(0,s.useMemo)(()=>t.reduce((o,n)=>(o[n.id]=n,o),{}),[t]);return(0,s.useEffect)(()=>{let o=X.current;if(!o||t.length===0)return;let n=o.getContext("2d");if(!n)return;let f=Math.max(1,window.devicePixelRatio||1),B=()=>document.documentElement.getAttribute("data-theme")==="dark",q={};l.forEach(i=>{q[i.source]=(q[i.source]||0)+1,q[i.target]=(q[i.target]||0)+1});let re=Math.max(1,...Object.values(q)),a={nodes:t.map(i=>({id:i.id,name:i.title||"",type:i.kind||"other",r:9+Math.min(10,(q[i.id]||0)/re*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:f,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((i,b)=>(i[b.id]=b,i),{}),a.nodes.forEach((i,b)=>{let g=b/a.nodes.length*Math.PI*2-Math.PI/2;i.x=Math.cos(g)*60,i.y=Math.sin(g)*60});let xe=[...new Set(a.nodes.map(i=>i.type))];a.clustered=xe.length>1,a.typeCenters={},xe.forEach((i,b)=>{let g=b/xe.length*Math.PI*2-Math.PI/2;a.typeCenters[i]={x:Math.cos(g)*160,y:Math.sin(g)*160}}),y.current=a;let tt=()=>{let i=o.clientWidth,b=o.clientHeight;a.w=i,a.h=b,o.width=i*f,o.height=b*f,n.setTransform(f,0,0,f,0,0)};tt();let at=new ResizeObserver(tt);at.observe(o.parentElement);let kt=(i,b)=>i&&i.length>b?i.slice(0,b)+"\u2026":i,Pe=(i,b,g,x)=>{if(n.beginPath(),x==="rect")n.rect(i-g,b-g*.75,g*2,g*1.5);else if(x==="diamond")n.moveTo(i,b-g),n.lineTo(i+g,b),n.lineTo(i,b+g),n.lineTo(i-g,b),n.closePath();else if(x==="hexagon"){for(let v=0;v<6;v++){let F=Math.PI/3*v-Math.PI/2,I=i+g*Math.cos(F),Q=b+g*Math.sin(F);v===0?n.moveTo(I,Q):n.lineTo(I,Q)}n.closePath()}else n.arc(i,b,g,0,Math.PI*2)},Ye=()=>{if(!a.nodes.length)return;let i=1/0,b=-1/0,g=1/0,x=-1/0;a.nodes.forEach(c=>{i=Math.min(i,c.x),b=Math.max(b,c.x),g=Math.min(g,c.y),x=Math.max(x,c.y)});let v=20,F=b-i+v*2,I=x-g+v*2,Q=Math.min(a.w/F,a.h/I);a.zoom=Math.max(.35,Math.min(1.8,Q)),a.panX=a.w/2-(i+b)/2*a.zoom,a.panY=a.h/2-(g+x)/2*a.zoom};h.current=Ye;let ot=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=he.current,a.kindFilter=ye.current,a.timeMode=E.current,a.tagFilter=ke.current;let i=a.tagFilter,b=a.kindFilter,g=c=>String(c||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.save(),n.strokeStyle=B()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let c=0;c<a.w;c+=24)n.beginPath(),n.moveTo(c,0),n.lineTo(c,a.h),n.stroke();for(let c=0;c<a.h;c+=24)n.beginPath(),n.moveTo(0,c),n.lineTo(a.w,c),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let x={};a.nodes.forEach(c=>x[c.id]=c);let v=a.nodes.length>40,F=v?1.5:.55,I=a.selectedId||a.hoverId;a.edges.forEach(c=>{let j=x[c.sourceNodeId],w=x[c.targetNodeId];if(!j||!w)return;if(b!=="all"){let Ke=a.domainById[c.sourceNodeId]&&a.domainById[c.sourceNodeId].kind,ae=a.domainById[c.targetNodeId]&&a.domainById[c.targetNodeId].kind;if(Ke!==b&&ae!==b)return}if(i){let Ke=a.domainById[c.sourceNodeId]&&(a.domainById[c.sourceNodeId].tags||[]).includes(i),ae=a.domainById[c.targetNodeId]&&(a.domainById[c.targetNodeId].tags||[]).includes(i);if(!Ke&&!ae)return}let N=w.x-j.x,D=w.y-j.y,H=Math.sqrt(N*N+D*D)||1,J=v?12:18,ee=-D/H*J,te=N/H*J,fe=(j.x+w.x)/2+ee,be=(j.y+w.y)/2+te,ve=Ee.colors[a.domainById[j.id]&&a.domainById[j.id].kind||"other"],Le=I&&(c.sourceNodeId===I||c.targetNodeId===I),Ze=I?Le?.6:.08:v?.14:.24,Qe=parseInt(ve.slice(1,3),16),We=parseInt(ve.slice(3,5),16),Xe=parseInt(ve.slice(5,7),16);n.strokeStyle="rgba("+Qe+","+We+","+Xe+","+Ze+")",n.lineWidth=Le?1.6+(c.weight||1):.8+(c.weight||1)*.5,n.beginPath(),n.moveTo(j.x,j.y),n.quadraticCurveTo(fe,be,w.x,w.y),n.stroke()});let Q=[];if(a.nodes.forEach(c=>{let j=a.domainById[c.id]||{},w=j.kind||"other",N=a.timeMode?qt(j.updated):Ee.colors[w],D=Ee.shapes[w],H=a.selectedId===c.id,J=a.hoverId===c.id,ee=a.searchTerm||"",te=!ee||(c.name||"").toLowerCase().includes(ee)||String(Be[w]||"").toLowerCase().includes(ee)||String(w).toLowerCase().includes(ee),fe=b==="all"||w===b,be=!i||(j.tags||[]).includes(i),ve=I&&c.id!==I&&!a.edges.some(ae=>ae.sourceNodeId===I&&ae.targetNodeId===c.id||ae.targetNodeId===I&&ae.sourceNodeId===c.id)||ee&&!te||!fe||!be;n.save(),n.globalAlpha=ve?.08:1,(H||J)&&(n.shadowColor=N,n.shadowBlur=H?20:14),Pe(c.x,c.y,c.r,D);let Le=parseInt(N.slice(1,3),16),Ze=parseInt(N.slice(3,5),16),Qe=parseInt(N.slice(5,7),16),We=n.createRadialGradient(c.x-c.r*.3,c.y-c.r*.3,0,c.x,c.y,c.r*1.2);We.addColorStop(0,"rgba("+Math.min(255,Le+70)+","+Math.min(255,Ze+70)+","+Math.min(255,Qe+70)+",0.95)"),We.addColorStop(1,N),n.fillStyle=We,n.fill(),n.restore(),H?(n.save(),Pe(c.x,c.y,c.r+3,D),n.strokeStyle=N,n.lineWidth=3,n.shadowColor=N,n.shadowBlur=12,n.stroke(),n.restore()):J?(n.save(),Pe(c.x,c.y,c.r+2,D),n.strokeStyle=N,n.lineWidth=2,n.stroke(),n.restore()):ee&&te?(n.save(),Pe(c.x,c.y,c.r+2,D),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(c.id)>=0&&(n.save(),Pe(c.x,c.y,c.r+2,D),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Xe=kt(c.name,16);if((H||J||a.zoom>F||!v&&a.zoom>.6)&&fe&&be){let ae=1/a.zoom;n.font="500 "+(12*ae).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ie=n.measureText(Xe).width+16*ae,Ve=18*ae,$e=c.y+c.r+8*ae,ut=!0;for(let je of Q)if(c.x-Ie/2<je.x+je.w&&c.x+Ie/2>je.x&&$e<je.y+je.h&&$e+Ve>je.y){ut=!1;break}if(!ut&&!H&&!J)return;Q.push({x:c.x-Ie/2,y:$e,w:Ie,h:Ve}),n.fillStyle=B()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(c.x-Ie/2,$e,Ie,Ve,4*ae):n.rect(c.x-Ie/2,$e,Ie,Ve),n.fill(),n.strokeStyle=B()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*ae,n.stroke(),n.fillStyle=B()?H||J?"#eee":"#bbb":H||J?"#111":"#444",n.textAlign="center",n.fillText(Xe,c.x,$e+13*ae)}}),n.restore(),a.marquee){let c=a.marquee,j=Math.min(c.sx,c.ex),w=Math.min(c.sy,c.ey),N=Math.abs(c.ex-c.sx),D=Math.abs(c.ey-c.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(j,w,N,D),n.strokeRect(j,w,N,D),n.restore()}if(a.hoverId&&K.current){let c=a.domainById[a.hoverId],j=a.nodes.find(function(w){return w.id===a.hoverId});if(c&&j){let w=a.edges.filter(function(H){return H.sourceNodeId===c.id||H.targetNodeId===c.id}).length,N=j.x*a.zoom+a.panX,D=j.y*a.zoom+a.panY;K.current.style.display="block",K.current.style.left=N+14+"px",K.current.style.top=D-6+"px",K.current.innerHTML="<b>"+g(c.title||c.name||"")+'</b><br/><span style="opacity:.8">'+g(c.kind||"")+" \xB7 "+w+" \u8FDE\u63A5</span>"}}else K.current&&(K.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(rt))};a.wake=ge,a.render=ot;let nt=()=>{let i=a.nodes.length;a.tickCount++;let g=.9-Math.min(.4,a.tickCount/1500),x=i>1e3?3e3:i>100?2e3:i>50?1200:800,v=i>100?.002:.005,F=i>1e3?.012:i>100?.005:.01,I=i>1e3?6:i>200?12:24,Q={};a.nodes.forEach(w=>Q[w.id]=w);for(let w=0;w<i;w++){if(a.dragNode===a.nodes[w])continue;let N=a.nodes[w],D=0,H=0;for(let te=0;te<i;te++){if(w===te)continue;let fe=N.x-a.nodes[te].x,be=N.y-a.nodes[te].y,ve=Math.sqrt(fe*fe+be*be)||1,Le=x/(ve*ve);D+=fe/ve*Le,H+=be/ve*Le}if(a.clustered&&a.typeCenters[N.type]){let te=a.typeCenters[N.type];D+=(te.x-N.x)*.006,H+=(te.y-N.y)*.006}else D-=N.x*F,H-=N.y*F;let J=(N.vx+D)*g,ee=(N.vy+H)*g;J=Math.max(-I,Math.min(I,J)),ee=Math.max(-I,Math.min(I,ee)),N.vx=J,N.vy=ee}a.edges.forEach(w=>{let N=Q[w.sourceNodeId],D=Q[w.targetNodeId];if(!N||!D)return;let H=D.x-N.x,J=D.y-N.y,ee=Math.sqrt(H*H+J*J)||1,te=(ee-100)*v,fe=H/ee*te,be=J/ee*te;a.dragNode!==N&&(N.vx+=fe,N.vy+=be),a.dragNode!==D&&(D.vx-=fe,D.vy-=be)});let c=0;a.nodes.forEach(w=>{a.dragNode!==w&&(w.x+=w.vx,w.y+=w.vy,c+=w.vx*w.vx+w.vy*w.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ye()),(i?Math.sqrt(c/i):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},rt=()=>{if(a.running){try{nt(),ot()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(rt)}},Ae=(i,b)=>{let g=o.getBoundingClientRect();return{x:(i-g.left-a.panX)/a.zoom,y:(b-g.top-a.panY)/a.zoom}},qe=i=>{let b=a.domainById[i];return!(!b||ye.current!=="all"&&b.kind!==ye.current||ke.current&&!(b.tags||[]).includes(ke.current))},He=(i,b,g)=>Math.max(b,Math.min(g,i)),it=i=>{a.mouseX=i.clientX,a.mouseY=i.clientY;let b=Ae(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!qe(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+36){g=v.id;break}}g!==a.hoverId&&(a.hoverId=g,ge())},lt=i=>{if(i.button!==0)return;let b=Ae(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!qe(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+25){g=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=g||null,g&&(a.dragOffset={dx:g.x-b.x,dy:g.y-b.y})},st=i=>{if(a.marquee){a.marquee.ex=i.clientX,a.marquee.ey=i.clientY,ge();return}if(!a.dragStart)return;let b=i.clientX-a.dragStart.x,g=i.clientY-a.dragStart.y;if(Math.abs(b)+Math.abs(g)>3&&(a.dragging=!0),a.dragNode){let x=Ae(i.clientX,i.clientY);a.dragNode.x=x.x+a.dragOffset.dx,a.dragNode.y=x.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=He(a.dragStart.px+b,-1e5,1e5),a.panY=He(a.dragStart.py+g,-1e5,1e5),ge())},ct=i=>{if(a.marquee){let g=a.marquee;a.marquee=null;let x=o.getBoundingClientRect(),v=Math.min(g.sx,g.ex)-x.left,F=Math.max(g.sx,g.ex)-x.left,I=Math.min(g.sy,g.ey)-x.top,Q=Math.max(g.sy,g.ey)-x.top,c=a.nodes.filter(j=>{let w=j.x*a.zoom+a.panX,N=j.y*a.zoom+a.panY;return w>=v&&w<=F&&N>=I&&N<=Q}).map(j=>j.id);a.multi=c,Ce(c),ge();return}if(a.dragStart&&!a.dragging){let g=Ae(i.clientX,i.clientY),x=null;for(let v=a.nodes.length-1;v>=0;v--){let F=a.nodes[v];if(!qe(F.id))continue;let I=F.x-g.x,Q=F.y-g.y;if(I*I+Q*Q<F.r*F.r+20){x=F;break}}x?(a.selectedId=x.id,se(x.id),ge()):(a.selectedId=null,a.hoverId=null,i.shiftKey||(a.multi=[],Ce([])),se(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},dt=i=>{i.preventDefault();let b=Ae(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!qe(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+25){g=v;break}}if(g){let x=a.domainById[g.id];x&&Y({x:i.clientX,y:i.clientY,id:g.id,path:x.id,title:x.title})}else Y(null)},pt=i=>{i.preventDefault();let b=o.getBoundingClientRect(),g=(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=He(a.panX+g*(a.zoom-v),-1e5,1e5),a.panY=He(a.panY+x*(a.zoom-v),-1e5,1e5),a.zoom=v,ge()};o.addEventListener("mousemove",it),o.addEventListener("mousedown",lt),window.addEventListener("mousemove",st),window.addEventListener("mouseup",ct),o.addEventListener("wheel",pt,{passive:!1}),o.addEventListener("contextmenu",dt),S.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Ce([]),Ye(),ge()};for(let i=0;i<200;i++)nt();Ye(),ge();let mt=()=>we(!1);return window.addEventListener("mousedown",mt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),at.disconnect(),o.removeEventListener("mousemove",it),o.removeEventListener("mousedown",lt),window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",ct),o.removeEventListener("wheel",pt),o.removeEventListener("contextmenu",dt),window.removeEventListener("mousedown",mt)}},[t,l]),(0,e.jsxs)("div",{className:"me-graph",ref:G,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.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:O,onChange:o=>le(o.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>we(o=>!o),"aria-expanded":oe,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",$!=="all"||p||ce?"\u25CF":"\u25BE"]}),oe&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:o=>o.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${$==="all"&&!p?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{U("all"),M(!1)},children:r("all")}),Object.keys(Je).map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${$===o?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>U(n=>n===o?"all":o),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ee.colors[o]||Je[o]}}),r(Be[o])]},o)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${p?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>M(o=>!o),children:["\u23F1 ",r("timeDim")]}),Z.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:Z.map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${ce===o.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>Se(n=>n===o.tag?"":o.tag),title:o.tag,children:["#",o.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:o.n})]},o.tag))})]}),($!=="all"||p||ce)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{U("all"),M(!1),Se("")},children:[r("clearFilter")," \u2715"]})]})})]}),(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:!!V,onChange:o=>z&&z(o.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${p?" me-on":""}`,onClick:()=>M(o=>!o),children:r("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=X.current;if(o)try{o.toBlob(n=>{n&&Fe({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h.current&&h.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{se(null),U("all"),S.current&&S.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:X,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:K,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)"}}),P&&(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")}),L&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>Y(null)}),L&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:L.x,top:L.y,zIndex:31},onMouseDown:o=>o.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{me.current({path:L.path,title:L.title}),Y(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{L.id&&(y.current.selectedId=L.id,se(L.id)),Y(null);let o=y.current;o&&o.wake&&o.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(L.title||"")}catch{}Y(null),A(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let o=y.current,n=o&&Array.isArray(o.multi)?o.multi.slice():[],f=L.id;if(f&&!n.includes(f)&&n.push(f),Y(null),n.length<2){A(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let B=ue.current&&ue.current(n);B&&B.then?B.then(q=>q?A(r("merged")):A(r("mergeFail"),!1)).catch(()=>A(r("mergeFail"),!1)):B&&A(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let o=L.path;Y(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(_.current?await _.current(o):!1)?A(r("deleted")):A(r("deleteFail"),!1)}catch{A(r("deleteFail"),!1)}})()},children:r("delete")})]}),ne.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:[ne.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=ne.map(re=>C[re]).filter(Boolean).map(re=>re.title||re.name).join(`
175
- `),f=new Blob([n],{type:"text/plain;charset=utf-8"}),B=URL.createObjectURL(f),q=document.createElement("a");q.href=B,q.download="memory-selected.txt",document.body.appendChild(q),q.click(),document.body.removeChild(q),setTimeout(()=>URL.revokeObjectURL(B),1e3),A(ne.length+r("exportedSel"))},children:r("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(ne.length<2){A(r("mergeNeed"),!1);return}let o=ne.map(f=>C[f]?C[f].id:f);if(!window.confirm(r("mergeConfirm")))return;Ce([]);let n=y.current;n&&(n.multi=[]),fetch(`${R}/merge?paths=${encodeURIComponent(o.join(","))}`).then(f=>f.json()).then(f=>{f&&f.ok?A(r("merged")):A(r("mergeFail"),!1)}).catch(()=>A(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 o=ne.map(f=>C[f]?C[f].id:f);Ce([]);let n=y.current;n&&(n.multi=[]),(async()=>{let f=0;for(let B of o)try{(_.current?await _.current(B):!1)&&f++}catch{}A(f+r("deletedSelected"),f>0)})()},children:r("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=y.current;o&&(o.multi=[]),Ce([]);let n=y.current;n&&n.render&&n.render()},children:r("clearSelection")})]}),W&&(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:C[W]?C[W].title||C[W].name:W}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:C[W]?r(Be[C[W].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:r("graphHint")}),(l.filter(o=>o.source===W||o.target===W)||[]).slice(0,8).map((o,n)=>{let f=o.source===W?o.target:o.source,B=C[f];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:q=>{q.preventDefault();let re=y.current;re&&(re.selectedId=f,re.hoverId=f,re.wake&&re.wake()),se(f)},children:B?(B.title||B.name).slice(0,28):f},n)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:r("graphTip")}),Me&&(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 "+(Me.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Me.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Me.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Me.msg})]}),de&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{de.url&&URL.revokeObjectURL(de.url),Fe(null),ie(!1)},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:pe?"100vw":900,width:pe?"100vw":"92vw",maxHeight:pe?"100vh":"90vh",height:pe?"100vh":void 0,borderRadius:pe?0:14},onClick:o=>o.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:de.url,download:"memory-graph.png",onClick:()=>{u("download"),A(r("downloaded")+" \xB7 "+r("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:r(Re==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{u("full"),ie(o=>!o),A(r("fullscreen"))},children:r(Re==="full"?"done":pe?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=de.blob;o&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":o})]).then(()=>{u("copy"),A(r("copied"))}).catch(()=>{A(r("copyFail"),!1)}):A(r("copyFail"),!1)},children:r(Re==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{de.url&&URL.revokeObjectURL(de.url),Fe(null),ie(!1)},children:r("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:pe?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:de.url,alt:r("exportGraph"),style:{maxWidth:"100%",maxHeight:pe?"calc(100vh - 64px)":"70vh",borderRadius:pe?0:8,cursor:"zoom-in"},onClick:()=>ie(o=>!o)})})]})]})]})}function qt(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let d=(Date.now()-l)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function Ht(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function Xt(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let r=await window.showSaveFilePicker({suggestedName:l}),T=await r.createWritable();return await T.write(t),await T.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 k=URL.createObjectURL(t),m=document.createElement("a");return m.href=k,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>URL.revokeObjectURL(k),1e3),{ok:!0,picked:!1,name:l}}function bt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),k=l.toLowerCase(),m=[],r=0;for(;r<t.length;){let T=d.indexOf(k,r);if(T<0){m.push(t.slice(r));break}T>r&&m.push(t.slice(r,T)),m.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(T,T+k.length)},T)),r=T+k.length}return m}function Kt(t){if(!t)return"";let l=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),d=[];return l=l.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(k,m,r){return d.push("<pre><code>"+r+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(k,m,r){return"<h"+m.length+">"+r+"</h"+m.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(k,m,r){return/^(https?:|\/)/.test(r)?'<a href="'+r+'" target="_blank" rel="noopener noreferrer">'+m+"</a>":m}),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(k,m){return d[m]}),l}function wt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,k=l.toDateString()===d.toDateString(),m=T=>String(T).padStart(2,"0"),r=`${m(l.getHours())}:${m(l.getMinutes())}`;return k?r:`${l.getMonth()+1}-${l.getDate()} ${r}`}
174
+ - `}];function Ut({t,newCard:i,setNewCard:d,onCreated:b}){if(!i)return null;let p=et.find(x=>x.key===i.template),r=i.body||(p?p.body:""),T=i.kind||(p?p.kind:"knowledge"),j=i.tags||(p?p.tags.join(", "):""),I=i._creating,A=x=>{let h=et.find(v=>v.key===x);d(v=>({...v,template:x,kind:h?h.kind:v.kind,body:h?h.body:v.body,tags:h?h.tags.join(", "):v.tags}))},X=async()=>{if(!(!i.title&&!r)){d(x=>({...x,_creating:!0}));try{(await fetch(`${W}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:i.title||"\u65E0\u6807\u9898",kind:T,tags:j.split(",").map(h=>h.trim()).filter(Boolean),body:r,source:"manual"})}).then(h=>h.json())).ok?(d(null),b&&b()):d(h=>({...h,_creating:!1}))}catch{d(h=>({...h,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:he}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:x=>x.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[et.map(x=>(0,e.jsx)("button",{type:"button",className:`mc-btn${i.template===x.key?" me-on":""}`,onClick:()=>A(x.key),children:t(x.label)},x.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${i.template===""?" me-on":""}`,onClick:()=>d(x=>({...x,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:T,onChange:x=>d(h=>({...h,kind:x.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(x=>(0,e.jsx)("option",{value:x,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:x},x))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:i.title||"",onChange:x=>d(h=>({...h,title:x.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:j,onChange:x=>d(h=>({...h,tags:x.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:r,onChange:x=>d(h=>({...h,body:x.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:I,onClick:X,children:t(I?"exporting":"createCard")})})]})]})]})}function Yt({t,card:i,query:d,onClose:b,onDelete:p,onFeedback:r}){(0,s.useEffect)(()=>{let A=X=>{X.key==="Escape"&&b()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[b]);let[T,j]=(0,s.useState)(!1),I=(i.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:b,children:[(0,e.jsx)("style",{children:he}),(0,e.jsxs)("div",{className:"me-dialog",onClick:A=>A.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(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")]})]}),I&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>j(A=>!A),children:t(T?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&p&&p(i.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:b,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:T?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:_t(i.text)}})]})]})}function Ht({t,onOpen:i,all:d,onAllChange:b,onMutate:p}){let[r,T]=(0,s.useState)(null),[j,I]=(0,s.useState)(""),A=(0,s.useCallback)(async()=>{try{let v=await(await fetch(`${W}/graph${d?"?all=1":""}`)).json();v.ok?(T(v),I("")):(T(null),I(v.error||t("error")))}catch(h){I(String(h&&h.message?h.message:h))}},[d,t]);(0,s.useEffect)(()=>{let h=!0;return fetch(`${W}/graph${d?"?all=1":""}`).then(v=>v.json()).then(v=>{h&&(v.ok?(T(v),I("")):(T(null),I(v.error||t("error"))))}).catch(v=>{h&&I(String(v&&v.message?v.message:v))}),()=>{h=!1}},[d,t]);let X=(0,s.useCallback)(async h=>{try{let G=await(await fetch(`${W}/delete?path=${encodeURIComponent(h)}`)).json();return G&&G.ok?(await A(),p&&p(),!0):!1}catch{return!1}},[A]),x=(0,s.useCallback)(async h=>{if(!h||h.length<2)return!1;try{let v=await fetch(`${W}/merge?paths=${encodeURIComponent(h.join(","))}`).then(G=>G.json());return v&&v.ok?(await A(),p&&p(),!0):!1}catch{return!1}},[A,p]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:he}),j&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",j]}),!r&&!j&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),r&&r.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),r&&r.nodes.length>0&&(0,e.jsx)(Xt,{nodes:r.nodes,edges:r.edges,onOpen:i,onDelete:X,onMerge:x,t,all:d,onAllChange:b,countLabel:`${r.nodes.length} ${t("nodes")} \xB7 ${qt(r.edges)} ${t("edges")}`})]})}function qt(t){let i=new Set;for(let d of t||[])i.add([d.source,d.target].sort().join("|"));return i.size}var Re={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 Xt({nodes:t,edges:i,onOpen:d,onDelete:b,onMerge:p,t:r,countLabel:T,all:j,onAllChange:I}){let A=(0,s.useRef)(null),X=(0,s.useRef)(null),x=(0,s.useRef)(null),h=(0,s.useRef)(null),v=(0,s.useRef)(null),G=(0,s.useRef)(d);(0,s.useEffect)(()=>{G.current=d},[d]);let N=(0,s.useRef)(b);(0,s.useEffect)(()=>{N.current=b},[b]);let Q=(0,s.useRef)(p);(0,s.useEffect)(()=>{Q.current=p},[p]);let[F,ie]=(0,s.useState)(""),[_,J]=(0,s.useState)(null),xe=(0,s.useRef)("");(0,s.useEffect)(()=>{xe.current=F.trim().toLowerCase()},[F]),(0,s.useEffect)(()=>{let o=x.current;if(!o)return;let n=F.trim().toLowerCase();if(!n)return;let f=o.nodes.find(R=>(R.name||"").toLowerCase().includes(n));f&&(x.current.selectedId=f.id,J(f.id),o.panX=o.w/2-f.x*o.zoom,o.panY=o.h/2-f.y*o.zoom,o.render&&o.render())},[F]);let[E,Y]=(0,s.useState)("all"),[ke,g]=(0,s.useState)(!1),L=(0,s.useRef)("all"),[$,K]=(0,s.useState)(""),re=(0,s.useRef)(""),[V,z]=(0,s.useState)(!1),ce=(0,s.useRef)(!1),[ee,ue]=(0,s.useState)(null);(0,s.useEffect)(()=>{L.current=E},[E]),(0,s.useEffect)(()=>{re.current=$},[$]),(0,s.useEffect)(()=>{ce.current=V},[V]);let Be=(0,s.useMemo)(()=>{let o=new Map;for(let n of t)for(let f of n.tags||[]){let R=String(f).trim();R&&o.set(R,(o.get(R)||0)+1)}return[...o.entries()].sort((n,f)=>f[1]-n[1]).slice(0,24).map(([n,f])=>({tag:n,n:f}))},[t]),Je=(()=>{let o=F.trim().toLowerCase();return!!o&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(o)||String(n.kind||"").toLowerCase().includes(o)||String(Le[n.kind]||"").toLowerCase().includes(o))})();(0,s.useEffect)(()=>{let o=x.current;o&&o.wake&&o.wake()},[F]),(0,s.useEffect)(()=>{let o=x.current;o&&o.render&&o.render()},[E,$,V]);let ge=(0,s.useRef)(null),[de,Ce]=(0,s.useState)([]),[pe,Fe]=(0,s.useState)(null),[me,le]=(0,s.useState)(!1),[Ne,Ae]=(0,s.useState)(null),[De,Ee]=(0,s.useState)(""),Se=(0,s.useRef)(null),ze=(0,s.useRef)(null),U=(o,n=!0)=>{Se.current&&clearTimeout(Se.current),Ae({msg:o,ok:n}),Se.current=setTimeout(()=>Ae(null),1900)},m=o=>{Ee(o),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>Ee(""),1600)};(0,s.useEffect)(()=>()=>{Se.current&&clearTimeout(Se.current),ze.current&&clearTimeout(ze.current)},[]);let S=(0,s.useMemo)(()=>t.reduce((o,n)=>(o[n.id]=n,o),{}),[t]);return(0,s.useEffect)(()=>{let o=A.current;if(!o||t.length===0)return;let n=o.getContext("2d");if(!n)return;let f=Math.max(1,window.devicePixelRatio||1),R=()=>document.documentElement.getAttribute("data-theme")==="dark",H={};i.forEach(l=>{H[l.source]=(H[l.source]||0)+1,H[l.target]=(H[l.target]||0)+1});let se=Math.max(1,...Object.values(H)),a={nodes:t.map(l=>({id:l.id,name:l.title||"",type:l.kind||"other",r:9+Math.min(10,(H[l.id]||0)/se*8),x:0,y:0,vx:0,vy:0})),edges:i.map(l=>({sourceNodeId:l.source,targetNodeId:l.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:f,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((l,y)=>(l[y.id]=y,l),{}),a.nodes.forEach((l,y)=>{let u=y/a.nodes.length*Math.PI*2-Math.PI/2;l.x=Math.cos(u)*60,l.y=Math.sin(u)*60});let ve=[...new Set(a.nodes.map(l=>l.type))];a.clustered=ve.length>1,a.typeCenters={},ve.forEach((l,y)=>{let u=y/ve.length*Math.PI*2-Math.PI/2;a.typeCenters[l]={x:Math.cos(u)*160,y:Math.sin(u)*160}}),x.current=a;let tt=()=>{let l=o.clientWidth,y=o.clientHeight;a.w=l,a.h=y,o.width=l*f,o.height=y*f,n.setTransform(f,0,0,f,0,0)};tt();let at=new ResizeObserver(tt);at.observe(o.parentElement);let Ct=(l,y)=>l&&l.length>y?l.slice(0,y)+"\u2026":l,Oe=(l,y,u,w)=>{if(n.beginPath(),w==="rect")n.rect(l-u,y-u*.75,u*2,u*1.5);else if(w==="diamond")n.moveTo(l,y-u),n.lineTo(l+u,y),n.lineTo(l,y+u),n.lineTo(l-u,y),n.closePath();else if(w==="hexagon"){for(let k=0;k<6;k++){let D=Math.PI/3*k-Math.PI/2,B=l+u*Math.cos(D),te=y+u*Math.sin(D);k===0?n.moveTo(B,te):n.lineTo(B,te)}n.closePath()}else n.arc(l,y,u,0,Math.PI*2)},Ue=()=>{if(!a.nodes.length)return;let l=1/0,y=-1/0,u=1/0,w=-1/0;a.nodes.forEach(c=>{l=Math.min(l,c.x),y=Math.max(y,c.x),u=Math.min(u,c.y),w=Math.max(w,c.y)});let k=20,D=y-l+k*2,B=w-u+k*2,te=Math.min(a.w/D,a.h/B);a.zoom=Math.max(.35,Math.min(1.8,te)),a.panX=a.w/2-(l+y)/2*a.zoom,a.panY=a.h/2-(u+w)/2*a.zoom};h.current=Ue;let ot=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=xe.current,a.kindFilter=L.current,a.timeMode=ce.current,a.tagFilter=re.current;let l=a.tagFilter,y=a.kindFilter,u=c=>String(c||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.save(),n.strokeStyle=R()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let c=0;c<a.w;c+=24)n.beginPath(),n.moveTo(c,0),n.lineTo(c,a.h),n.stroke();for(let c=0;c<a.h;c+=24)n.beginPath(),n.moveTo(0,c),n.lineTo(a.w,c),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let w={};a.nodes.forEach(c=>w[c.id]=c);let k=a.nodes.length>40,D=k?1.5:.55,B=a.selectedId||a.hoverId;a.edges.forEach(c=>{let O=w[c.sourceNodeId],C=w[c.targetNodeId];if(!O||!C)return;if(y!=="all"){let Xe=a.domainById[c.sourceNodeId]&&a.domainById[c.sourceNodeId].kind,ne=a.domainById[c.targetNodeId]&&a.domainById[c.targetNodeId].kind;if(Xe!==y&&ne!==y)return}if(l){let Xe=a.domainById[c.sourceNodeId]&&(a.domainById[c.sourceNodeId].tags||[]).includes(l),ne=a.domainById[c.targetNodeId]&&(a.domainById[c.targetNodeId].tags||[]).includes(l);if(!Xe&&!ne)return}let M=C.x-O.x,P=C.y-O.y,q=Math.sqrt(M*M+P*P)||1,Z=k?12:18,ae=-P/q*Z,oe=M/q*Z,be=(O.x+C.x)/2+ae,ye=(O.y+C.y)/2+oe,we=Re.colors[a.domainById[O.id]&&a.domainById[O.id].kind||"other"],Te=B&&(c.sourceNodeId===B||c.targetNodeId===B),Ze=B?Te?.6:.08:k?.14:.24,Qe=parseInt(we.slice(1,3),16),We=parseInt(we.slice(3,5),16),qe=parseInt(we.slice(5,7),16);n.strokeStyle="rgba("+Qe+","+We+","+qe+","+Ze+")",n.lineWidth=Te?1.6+(c.weight||1):.8+(c.weight||1)*.5,n.beginPath(),n.moveTo(O.x,O.y),n.quadraticCurveTo(be,ye,C.x,C.y),n.stroke()});let te=[];if(a.nodes.forEach(c=>{let O=a.domainById[c.id]||{},C=O.kind||"other",M=a.timeMode?Kt(O.updated):Re.colors[C],P=Re.shapes[C],q=a.selectedId===c.id,Z=a.hoverId===c.id,ae=a.searchTerm||"",oe=!ae||(c.name||"").toLowerCase().includes(ae)||String(Le[C]||"").toLowerCase().includes(ae)||String(C).toLowerCase().includes(ae),be=y==="all"||C===y,ye=!l||(O.tags||[]).includes(l),we=B&&c.id!==B&&!a.edges.some(ne=>ne.sourceNodeId===B&&ne.targetNodeId===c.id||ne.targetNodeId===B&&ne.sourceNodeId===c.id)||ae&&!oe||!be||!ye;n.save(),n.globalAlpha=we?.08:1,(q||Z)&&(n.shadowColor=M,n.shadowBlur=q?20:14),Oe(c.x,c.y,c.r,P);let Te=parseInt(M.slice(1,3),16),Ze=parseInt(M.slice(3,5),16),Qe=parseInt(M.slice(5,7),16),We=n.createRadialGradient(c.x-c.r*.3,c.y-c.r*.3,0,c.x,c.y,c.r*1.2);We.addColorStop(0,"rgba("+Math.min(255,Te+70)+","+Math.min(255,Ze+70)+","+Math.min(255,Qe+70)+",0.95)"),We.addColorStop(1,M),n.fillStyle=We,n.fill(),n.restore(),q?(n.save(),Oe(c.x,c.y,c.r+3,P),n.strokeStyle=M,n.lineWidth=3,n.shadowColor=M,n.shadowBlur=12,n.stroke(),n.restore()):Z?(n.save(),Oe(c.x,c.y,c.r+2,P),n.strokeStyle=M,n.lineWidth=2,n.stroke(),n.restore()):ae&&oe?(n.save(),Oe(c.x,c.y,c.r+2,P),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(c.id)>=0&&(n.save(),Oe(c.x,c.y,c.r+2,P),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let qe=Ct(c.name,16);if((q||Z||a.zoom>D||!k&&a.zoom>.6)&&be&&ye){let ne=1/a.zoom;n.font="500 "+(12*ne).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Me=n.measureText(qe).width+16*ne,Ke=18*ne,$e=c.y+c.r+8*ne,ut=!0;for(let je of te)if(c.x-Me/2<je.x+je.w&&c.x+Me/2>je.x&&$e<je.y+je.h&&$e+Ke>je.y){ut=!1;break}if(!ut&&!q&&!Z)return;te.push({x:c.x-Me/2,y:$e,w:Me,h:Ke}),n.fillStyle=R()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(c.x-Me/2,$e,Me,Ke,4*ne):n.rect(c.x-Me/2,$e,Me,Ke),n.fill(),n.strokeStyle=R()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*ne,n.stroke(),n.fillStyle=R()?q||Z?"#eee":"#bbb":q||Z?"#111":"#444",n.textAlign="center",n.fillText(qe,c.x,$e+13*ne)}}),n.restore(),a.marquee){let c=a.marquee,O=Math.min(c.sx,c.ex),C=Math.min(c.sy,c.ey),M=Math.abs(c.ex-c.sx),P=Math.abs(c.ey-c.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(O,C,M,P),n.strokeRect(O,C,M,P),n.restore()}if(a.hoverId&&ge.current){let c=a.domainById[a.hoverId],O=a.nodes.find(function(C){return C.id===a.hoverId});if(c&&O){let C=a.edges.filter(function(q){return q.sourceNodeId===c.id||q.targetNodeId===c.id}).length,M=O.x*a.zoom+a.panX,P=O.y*a.zoom+a.panY;ge.current.style.display="block",ge.current.style.left=M+14+"px",ge.current.style.top=P-6+"px",ge.current.innerHTML="<b>"+u(c.title||c.name||"")+'</b><br/><span style="opacity:.8">'+u(c.kind||"")+" \xB7 "+C+" \u8FDE\u63A5</span>"}}else ge.current&&(ge.current.style.display="none")},fe=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(rt))};a.wake=fe,a.render=ot;let nt=()=>{let l=a.nodes.length;a.tickCount++;let u=.9-Math.min(.4,a.tickCount/1500),w=l>1e3?3e3:l>100?2e3:l>50?1200:800,k=l>100?.002:.005,D=l>1e3?.012:l>100?.005:.01,B=l>1e3?6:l>200?12:24,te={};a.nodes.forEach(C=>te[C.id]=C);for(let C=0;C<l;C++){if(a.dragNode===a.nodes[C])continue;let M=a.nodes[C],P=0,q=0;for(let oe=0;oe<l;oe++){if(C===oe)continue;let be=M.x-a.nodes[oe].x,ye=M.y-a.nodes[oe].y,we=Math.sqrt(be*be+ye*ye)||1,Te=w/(we*we);P+=be/we*Te,q+=ye/we*Te}if(a.clustered&&a.typeCenters[M.type]){let oe=a.typeCenters[M.type];P+=(oe.x-M.x)*.006,q+=(oe.y-M.y)*.006}else P-=M.x*D,q-=M.y*D;let Z=(M.vx+P)*u,ae=(M.vy+q)*u;Z=Math.max(-B,Math.min(B,Z)),ae=Math.max(-B,Math.min(B,ae)),M.vx=Z,M.vy=ae}a.edges.forEach(C=>{let M=te[C.sourceNodeId],P=te[C.targetNodeId];if(!M||!P)return;let q=P.x-M.x,Z=P.y-M.y,ae=Math.sqrt(q*q+Z*Z)||1,oe=(ae-100)*k,be=q/ae*oe,ye=Z/ae*oe;a.dragNode!==M&&(M.vx+=be,M.vy+=ye),a.dragNode!==P&&(P.vx-=be,P.vy-=ye)});let c=0;a.nodes.forEach(C=>{a.dragNode!==C&&(C.x+=C.vx,C.y+=C.vy,c+=C.vx*C.vx+C.vy*C.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ue()),(l?Math.sqrt(c/l):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},rt=()=>{if(a.running){try{nt(),ot()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(rt)}},Pe=(l,y)=>{let u=o.getBoundingClientRect();return{x:(l-u.left-a.panX)/a.zoom,y:(y-u.top-a.panY)/a.zoom}},Ye=l=>{let y=a.domainById[l];return!(!y||L.current!=="all"&&y.kind!==L.current||re.current&&!(y.tags||[]).includes(re.current))},He=(l,y,u)=>Math.max(y,Math.min(u,l)),it=l=>{a.mouseX=l.clientX,a.mouseY=l.clientY;let y=Pe(l.clientX,l.clientY),u=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let D=k.x-y.x,B=k.y-y.y;if(D*D+B*B<k.r*k.r+36){u=k.id;break}}u!==a.hoverId&&(a.hoverId=u,fe())},lt=l=>{if(l.button!==0)return;let y=Pe(l.clientX,l.clientY),u=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let D=k.x-y.x,B=k.y-y.y;if(D*D+B*B<k.r*k.r+25){u=k;break}}if(l.shiftKey){a.marquee={sx:l.clientX,sy:l.clientY,ex:l.clientX,ey:l.clientY};return}a.dragStart={x:l.clientX,y:l.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=u||null,u&&(a.dragOffset={dx:u.x-y.x,dy:u.y-y.y})},st=l=>{if(a.marquee){a.marquee.ex=l.clientX,a.marquee.ey=l.clientY,fe();return}if(!a.dragStart)return;let y=l.clientX-a.dragStart.x,u=l.clientY-a.dragStart.y;if(Math.abs(y)+Math.abs(u)>3&&(a.dragging=!0),a.dragNode){let w=Pe(l.clientX,l.clientY);a.dragNode.x=w.x+a.dragOffset.dx,a.dragNode.y=w.y+a.dragOffset.dy,fe()}else a.dragging&&(a.panX=He(a.dragStart.px+y,-1e5,1e5),a.panY=He(a.dragStart.py+u,-1e5,1e5),fe())},ct=l=>{if(a.marquee){let u=a.marquee;a.marquee=null;let w=o.getBoundingClientRect(),k=Math.min(u.sx,u.ex)-w.left,D=Math.max(u.sx,u.ex)-w.left,B=Math.min(u.sy,u.ey)-w.top,te=Math.max(u.sy,u.ey)-w.top,c=a.nodes.filter(O=>{let C=O.x*a.zoom+a.panX,M=O.y*a.zoom+a.panY;return C>=k&&C<=D&&M>=B&&M<=te}).map(O=>O.id);a.multi=c,Ce(c),fe();return}if(a.dragStart&&!a.dragging){let u=Pe(l.clientX,l.clientY),w=null;for(let k=a.nodes.length-1;k>=0;k--){let D=a.nodes[k];if(!Ye(D.id))continue;let B=D.x-u.x,te=D.y-u.y;if(B*B+te*te<D.r*D.r+20){w=D;break}}w?(a.selectedId=w.id,J(w.id),fe()):(a.selectedId=null,a.hoverId=null,l.shiftKey||(a.multi=[],Ce([])),J(null),fe())}a.dragStart=null,a.dragging=!1,a.dragNode=null},dt=l=>{l.preventDefault();let y=Pe(l.clientX,l.clientY),u=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let D=k.x-y.x,B=k.y-y.y;if(D*D+B*B<k.r*k.r+25){u=k;break}}if(u){let w=a.domainById[u.id];w&&ue({x:l.clientX,y:l.clientY,id:u.id,path:w.id,title:w.title})}else ue(null)},pt=l=>{l.preventDefault();let y=o.getBoundingClientRect(),u=(l.clientX-y.left-a.panX)/a.zoom,w=(l.clientY-y.top-a.panY)/a.zoom,k=Math.max(.3,Math.min(3,a.zoom*(l.deltaY<0?1.1:1/1.1)));a.panX=He(a.panX+u*(a.zoom-k),-1e5,1e5),a.panY=He(a.panY+w*(a.zoom-k),-1e5,1e5),a.zoom=k,fe()};o.addEventListener("mousemove",it),o.addEventListener("mousedown",lt),window.addEventListener("mousemove",st),window.addEventListener("mouseup",ct),o.addEventListener("wheel",pt,{passive:!1}),o.addEventListener("contextmenu",dt),v.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Ce([]),Ue(),fe()};for(let l=0;l<200;l++)nt();Ue(),fe();let mt=()=>g(!1);return window.addEventListener("mousedown",mt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),at.disconnect(),o.removeEventListener("mousemove",it),o.removeEventListener("mousedown",lt),window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",ct),o.removeEventListener("wheel",pt),o.removeEventListener("contextmenu",dt),window.removeEventListener("mousedown",mt)}},[t,i]),(0,e.jsxs)("div",{className:"me-graph",ref:X,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",r("nodes")," \xB7 ",i.length," ",r("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:r("search"),value:F,onChange:o=>ie(o.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>g(o=>!o),"aria-expanded":ke,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",E!=="all"||V||$?"\u25CF":"\u25BE"]}),ke&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:o=>o.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${E==="all"&&!V?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{Y("all"),z(!1)},children:r("all")}),Object.keys(_e).map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${E===o?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>Y(n=>n===o?"all":o),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Re.colors[o]||_e[o]}}),r(Le[o])]},o)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${V?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>z(o=>!o),children:["\u23F1 ",r("timeDim")]}),Be.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:Be.map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${$===o.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>K(n=>n===o.tag?"":o.tag),title:o.tag,children:["#",o.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:o.n})]},o.tag))})]}),(E!=="all"||V||$)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{Y("all"),z(!1),K("")},children:[r("clearFilter")," \u2715"]})]})})]}),(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:!!j,onChange:o=>I&&I(o.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${V?" me-on":""}`,onClick:()=>z(o=>!o),children:r("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=A.current;if(o)try{o.toBlob(n=>{n&&Fe({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h.current&&h.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{J(null),Y("all"),v.current&&v.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:A,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ge,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)"}}),Je&&(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")}),ee&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ue(null)}),ee&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:ee.x,top:ee.y,zIndex:31},onMouseDown:o=>o.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{G.current({path:ee.path,title:ee.title}),ue(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{ee.id&&(x.current.selectedId=ee.id,J(ee.id)),ue(null);let o=x.current;o&&o.wake&&o.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(ee.title||"")}catch{}ue(null),U(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let o=x.current,n=o&&Array.isArray(o.multi)?o.multi.slice():[],f=ee.id;if(f&&!n.includes(f)&&n.push(f),ue(null),n.length<2){U(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let R=Q.current&&Q.current(n);R&&R.then?R.then(H=>H?U(r("merged")):U(r("mergeFail"),!1)).catch(()=>U(r("mergeFail"),!1)):R&&U(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let o=ee.path;ue(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(N.current?await N.current(o):!1)?U(r("deleted")):U(r("deleteFail"),!1)}catch{U(r("deleteFail"),!1)}})()},children:r("delete")})]}),de.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[de.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=de.map(se=>S[se]).filter(Boolean).map(se=>se.title||se.name).join(`
175
+ `),f=new Blob([n],{type:"text/plain;charset=utf-8"}),R=URL.createObjectURL(f),H=document.createElement("a");H.href=R,H.download="memory-selected.txt",document.body.appendChild(H),H.click(),document.body.removeChild(H),setTimeout(()=>URL.revokeObjectURL(R),1e3),U(de.length+r("exportedSel"))},children:r("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(de.length<2){U(r("mergeNeed"),!1);return}let o=de.map(f=>S[f]?S[f].id:f);if(!window.confirm(r("mergeConfirm")))return;Ce([]);let n=x.current;n&&(n.multi=[]),fetch(`${W}/merge?paths=${encodeURIComponent(o.join(","))}`).then(f=>f.json()).then(f=>{f&&f.ok?U(r("merged")):U(r("mergeFail"),!1)}).catch(()=>U(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 o=de.map(f=>S[f]?S[f].id:f);Ce([]);let n=x.current;n&&(n.multi=[]),(async()=>{let f=0;for(let R of o)try{(N.current?await N.current(R):!1)&&f++}catch{}U(f+r("deletedSelected"),f>0)})()},children:r("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=x.current;o&&(o.multi=[]),Ce([]);let n=x.current;n&&n.render&&n.render()},children:r("clearSelection")})]}),_&&(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:S[_]?S[_].title||S[_].name:_}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:S[_]?r(Le[S[_].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:r("graphHint")}),(i.filter(o=>o.source===_||o.target===_)||[]).slice(0,8).map((o,n)=>{let f=o.source===_?o.target:o.source,R=S[f];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:H=>{H.preventDefault();let se=x.current;se&&(se.selectedId=f,se.hoverId=f,se.wake&&se.wake()),J(f)},children:R?(R.title||R.name).slice(0,28):f},n)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:r("graphTip")}),Ne&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(Ne.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Ne.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Ne.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Ne.msg})]}),pe&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{pe.url&&URL.revokeObjectURL(pe.url),Fe(null),le(!1)},children:[(0,e.jsx)("style",{children:he}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:me?"100vw":900,width:me?"100vw":"92vw",maxHeight:me?"100vh":"90vh",height:me?"100vh":void 0,borderRadius:me?0:14},onClick:o=>o.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:pe.url,download:"memory-graph.png",onClick:()=>{m("download"),U(r("downloaded")+" \xB7 "+r("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:r(De==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{m("full"),le(o=>!o),U(r("fullscreen"))},children:r(De==="full"?"done":me?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=pe.blob;o&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":o})]).then(()=>{m("copy"),U(r("copied"))}).catch(()=>{U(r("copyFail"),!1)}):U(r("copyFail"),!1)},children:r(De==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{pe.url&&URL.revokeObjectURL(pe.url),Fe(null),le(!1)},children:r("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:me?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:pe.url,alt:r("exportGraph"),style:{maxWidth:"100%",maxHeight:me?"calc(100vh - 64px)":"70vh",borderRadius:me?0:8,cursor:"zoom-in"},onClick:()=>le(o=>!o)})})]})]})]})}function Kt(t){let i=new Date(t||0).getTime();if(!i)return"#94a3b8";let d=(Date.now()-i)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function Vt(t){let i=new Date(t||0).getTime();return!!i&&(Date.now()-i)/864e5<3}async function Gt(t,i,d){if(d&&typeof window.showSaveFilePicker=="function")try{let r=await window.showSaveFilePicker({suggestedName:i}),T=await r.createWritable();return await T.write(t),await T.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 b=URL.createObjectURL(t),p=document.createElement("a");return p.href=b,p.download=i,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(b),1e3),{ok:!0,picked:!1,name:i}}function bt(t,i){if(!i||!t)return t;let d=t.toLowerCase(),b=i.toLowerCase(),p=[],r=0;for(;r<t.length;){let T=d.indexOf(b,r);if(T<0){p.push(t.slice(r));break}T>r&&p.push(t.slice(r,T)),p.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(T,T+b.length)},T)),r=T+b.length}return p}function _t(t){if(!t)return"";let i=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),d=[];return i=i.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(b,p,r){return d.push("<pre><code>"+r+"</code></pre>"),"\0"+(d.length-1)+"\0"}),i=i.replace(/^(#{1,3})\s+(.+)$/gm,function(b,p,r){return"<h"+p.length+">"+r+"</h"+p.length+">"}),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/`([^`\n]+)`/g,"<code>$1</code>"),i=i.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(b,p,r){return/^(https?:|\/)/.test(r)?'<a href="'+r+'" target="_blank" rel="noopener noreferrer">'+p+"</a>":p}),i=i.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),i=i.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),i=i.replace(/\n/g,"<br/>"),i=i.replace(/\u0000(\d+)\u0000/g,function(b,p){return d[p]}),i}function kt(t){if(!t)return"";let i=new Date(t);if(Number.isNaN(i.getTime()))return"";let d=new Date,b=i.toDateString()===d.toDateString(),p=T=>String(T).padStart(2,"0"),r=`${p(i.getHours())}:${p(i.getMinutes())}`;return b?r:`${i.getMonth()+1}-${i.getDate()} ${r}`}
176
176
 
177
177
  return module.exports;
178
178
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-memory-eternal",
3
- "version": "0.6.0",
3
+ "version": "0.6.2-beta.1",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {