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