diff --git a/README.md b/README.md index 0560888..832b0d6 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ Edit Markdown notes as interactive mind maps in Obsidian. linkmind renders headi 2. Click the brain icon in the left ribbon, or run **"Open current note as mind map"** from the command palette. 3. Edit nodes, restructure the tree, and export -- all changes are saved back to Markdown automatically. +## Screenshots + +![linkmind screenshot](./docs/5414.webp) + ## Settings | Setting | Default | Description | diff --git a/README.zh.md b/README.zh.md index 74d5195..1606656 100644 --- a/README.zh.md +++ b/README.zh.md @@ -54,6 +54,10 @@ 2. 点击左侧边栏脑图图标,或在命令面板执行 **“以思维导图打开当前笔记”**。 3. 直接编辑节点、调整结构、导出图片;所有修改都会自动写回 Markdown。 +## 截图 + +![linkmind 截图](./docs/5414.webp) + ## 设置项 | 设置项 | 默认值 | 说明 | diff --git a/docs/5414.webp b/docs/5414.webp new file mode 100644 index 0000000..a38b395 Binary files /dev/null and b/docs/5414.webp differ diff --git a/esbuild.config.mjs b/esbuild.config.mjs index dc9dd40..3d2026c 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -31,7 +31,7 @@ const context = await esbuild.context({ logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, - outfile: "plugin/main.js", + outfile: "main.js", minify: prod }); diff --git a/main.js b/main.js index 5aea739..3768ce5 100644 --- a/main.js +++ b/main.js @@ -1,19 +1,23 @@ /* linkmind - Obsidian mind map plugin */ -var Q=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var Tt=(o,s)=>{for(var t in s)Q(o,t,{get:s[t],enumerable:!0})},It=(o,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of Nt(s))!Ct.call(o,i)&&i!==t&&Q(o,i,{get:()=>s[i],enumerable:!(e=Et(s,i))||e.enumerable});return o};var Dt=o=>It(Q({},"__esModule",{value:!0}),o);var Wt={};Tt(Wt,{default:()=>z});module.exports=Dt(Wt);var h=require("obsidian"),D="linkmind-view",Pt=300,Lt=["\u{1F4A1}","\u2705","\u{1F525}","\u2B50","\u{1F3AF}","\u{1F680}","\u{1F4CC}","\u{1F4CE}","\u{1F9E0}","\u{1F4DD}","\u{1F4DA}","\u{1F50D}","\u26A1","\u2764\uFE0F","\u2753","\u26A0\uFE0F","\u{1F331}","\u{1F3C1}","\u{1F527}","\u{1F4AC}","\u{1F3A8}","\u{1F9E9}","\u{1F4CA}","\u{1F517}","\u{1F48E}","\u{1F3C6}","\u{1F3AA}","\u{1F31F}","\u{1F3A7}","\u{1F3AC}","\u{1F4F1}","\u{1F4BB}","\u{1F30D}","\u{1F3E0}","\u{1F3B5}","\u{1F3B2}","\u{1F9EA}","\u{1F6E0}","\u2728","\u{1F389}","\u{1F4CC}","\u{1F511}","\u{1F4E6}","\u{1F9F2}","\u{1F4B0}","\u{1F3AE}","\u{1F9D8}","\u{1F308}","\u{1F340}","\u{1F33A}","\u{1F98B}","\u{1F41D}","\u{1F431}","\u{1F436}","\u{1F98A}","\u{1F43C}","\u{1F981}","\u{1F428}","\u{1F438}","\u{1F984}"],$t=["#ffffff","#f8fafc","#fef3c7","#dcfce7","#dbeafe","#fce7f3","#ede9fe","#fee2e2"],O={autoSaveDelay:300,branchColors:["#5b8def","#45b36b","#e89b3c","#9b72e7","#df6f9f"],defaultExpandDepth:99,animations:!0,layoutDirection:"right",exportScale:2,exportTransparentBackground:!1,language:"zh",showAssociationLinks:!0,hideNodeBorders:!1,nodeBorderRadius:10,nodeBorderWidth:3,nodeBgColor:"transparent",mindMapFiles:[]},dt={en:{openRibbon:"Open linkmind",openMindMap:"Open current note as mind map",createMindMap:"Create new mind map",newMindMapTitle:"New mind map",mindMapNamePlaceholder:"Mind map name",createButton:"Create",createdMindMap:"Created mind map",returnMarkdown:"Return to Markdown editor",addChild:"Add child node",addSibling:"Add sibling node",duplicateNode:"Duplicate selected node",moveUp:"Move selected node up",moveDown:"Move selected node down",indentNode:"Indent selected node",outdentNode:"Outdent selected node",editNode:"Edit selected node",deleteNode:"Delete selected node",toggleNode:"Toggle selected node",setEmoji:"Set selected node emoji",clearEmoji:"Clear selected node emoji",addTag:"Add tag to selected nodes",clearTags:"Clear tags from selected nodes",copyBranch:"Copy selected branch as Markdown",pasteChild:"Paste Markdown as child nodes",pasteSibling:"Paste Markdown as sibling nodes",selectAll:"Select all nodes",expandAll:"Expand all nodes",collapseAll:"Collapse all nodes",fitMap:"Fit mind map to view",focusNode:"Focus selected node",searchNodes:"Search nodes",filterByTag:"Filter by tag",clearTagFilter:"Clear tag filter",toggleOutline:"Toggle outline",copyNodeLink:"Copy selected node link",exportSvg:"Export mind map as SVG",exportPng:"Export mind map as PNG",exportSelectedSvg:"Export selected branch as SVG",exportSelectedPng:"Export selected branch as PNG",markdown:"Markdown",addChildShort:"Add child",addSiblingShort:"Add sibling",duplicateShort:"Duplicate",setEmojiIcon:"Set emoji icon",addTagShort:"Add tag",deleteShort:"Delete",fitShort:"Fit",exportSvgShort:"Export SVG",exportPngShort:"Export PNG",copyLinkShort:"Copy node link",outline:"Outline",hideOutline:"Hide outline",openMarkdownFirst:"Open a Markdown note first.",emptyView:"Open a Markdown note to use linkmind.",reloadedExternal:"linkmind reloaded the external Markdown changes.",keptLocal:"linkmind kept the mind map edits and wrote them to Markdown.",exported:"Exported",copiedLink:"Copied linkmind node link.",copiedBranch:"Copied branch Markdown.",pastedMarkdown:"Pasted Markdown into linkmind.",clipboardEmpty:"Clipboard does not contain Markdown nodes.",tagFilterActive:"Tag filter",chooseEmoji:"Choose an emoji icon",enterTag:"Enter tag name",conflictTitle:"linkmind conflict",conflictBody:"This note changed on disk while the mind map has unsaved local edits. Choose which version should win.",reloadMarkdown:"Reload Markdown",keepEdits:"Keep linkmind edits",settingsTitle:"linkmind",language:"Language",languageDesc:"Choose the language used by linkmind UI.",english:"English",chinese:"\u4E2D\u6587",autoSaveDelay:"Auto-save delay",autoSaveDelayDesc:"Milliseconds to wait after a mind map edit before writing Markdown.",defaultExpandDepth:"Default expand depth",defaultExpandDepthDesc:"How many levels are expanded when a note opens. Use 99 for all.",layoutDirection:"Layout direction",layoutDirectionDesc:"Choose a classic right-facing tree or a balanced map with branches on both sides.",horizontalRight:"Horizontal right",balanced:"Balanced",layoutAnimation:"Layout animation",layoutAnimationDesc:"Animate node movement after edits.",branchColors:"Branch colors",branchColorsDesc:"Comma-separated CSS colors used for first-level branches.",resetBranchColors:"Reset branch colors",pngScale:"PNG export scale",pngScaleDesc:"Resolution multiplier used when exporting PNG files.",transparentPng:"Transparent PNG background",transparentPngDesc:"Leave PNG exports transparent instead of filling the Obsidian background color.",showAssociationLinks:"Show association links",showAssociationLinksDesc:"Draw dashed cross-branch links for local wikilinks like [[#Heading]] or [[Heading]].",hideNodeBorders:"Hide node borders",hideNodeBordersDesc:"Remove the colored border from nodes, leaving only the background fill.",nodeBorderRadius:"Node border radius",nodeBorderRadiusDesc:"Border corner radius in pixels. Use 0 for sharp corners, 999 for pill shape.",nodeBorderWidth:"Node border width",nodeBorderWidthDesc:"Border line thickness in pixels. Use 0 to hide borders.",borderWidthShort:"Border",borderRadiusShort:"Radius",nodeStyleShort:"Style",nodeBgColor:"Node background",nodeBgColorDesc:"CSS color for node background. Use 'transparent' for default theme background.",transparent:"Transparent",saved:"Saved",unsaved:"Unsaved",saving:"Saving",nodesLabel:"nodes",selectedLabel:"selected",zoomLabel:"zoom",openAsMindMap:"Open as mind map",newMindMapInFolder:"New mind map in folder",mindMapFiles:"Mind map files",mindMapFilesDesc:"Files that default to mind map view when opened.",clearMindMapFiles:"Clear list"},zh:{openRibbon:"\u6253\u5F00 linkmind",openMindMap:"\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00\u5F53\u524D\u7B14\u8BB0",createMindMap:"\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",newMindMapTitle:"\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",mindMapNamePlaceholder:"\u601D\u7EF4\u5BFC\u56FE\u540D\u79F0",createButton:"\u521B\u5EFA",createdMindMap:"\u5DF2\u521B\u5EFA\u601D\u7EF4\u5BFC\u56FE",returnMarkdown:"\u8FD4\u56DE Markdown \u7F16\u8F91\u5668",addChild:"\u6DFB\u52A0\u5B50\u8282\u70B9",addSibling:"\u6DFB\u52A0\u540C\u7EA7\u8282\u70B9",duplicateNode:"\u590D\u5236\u9009\u4E2D\u8282\u70B9",moveUp:"\u4E0A\u79FB\u9009\u4E2D\u8282\u70B9",moveDown:"\u4E0B\u79FB\u9009\u4E2D\u8282\u70B9",indentNode:"\u7F29\u8FDB\u9009\u4E2D\u8282\u70B9",outdentNode:"\u53D6\u6D88\u7F29\u8FDB\u9009\u4E2D\u8282\u70B9",editNode:"\u7F16\u8F91\u9009\u4E2D\u8282\u70B9",deleteNode:"\u5220\u9664\u9009\u4E2D\u8282\u70B9",toggleNode:"\u6298\u53E0/\u5C55\u5F00\u9009\u4E2D\u8282\u70B9",setEmoji:"\u8BBE\u7F6E\u9009\u4E2D\u8282\u70B9 Emoji",clearEmoji:"\u6E05\u9664\u9009\u4E2D\u8282\u70B9 Emoji",addTag:"\u7ED9\u9009\u4E2D\u8282\u70B9\u6DFB\u52A0\u6807\u7B7E",clearTags:"\u6E05\u9664\u9009\u4E2D\u8282\u70B9\u6807\u7B7E",copyBranch:"\u590D\u5236\u9009\u4E2D\u5206\u652F\u4E3A Markdown",pasteChild:"\u7C98\u8D34 Markdown \u4E3A\u5B50\u8282\u70B9",pasteSibling:"\u7C98\u8D34 Markdown \u4E3A\u540C\u7EA7\u8282\u70B9",selectAll:"\u9009\u62E9\u5168\u90E8\u8282\u70B9",expandAll:"\u5C55\u5F00\u5168\u90E8\u8282\u70B9",collapseAll:"\u6298\u53E0\u5168\u90E8\u8282\u70B9",fitMap:"\u9002\u5E94\u7A97\u53E3",focusNode:"\u805A\u7126\u9009\u4E2D\u8282\u70B9",searchNodes:"\u641C\u7D22\u8282\u70B9",filterByTag:"\u6309\u6807\u7B7E\u8FC7\u6EE4",clearTagFilter:"\u6E05\u9664\u6807\u7B7E\u8FC7\u6EE4",toggleOutline:"\u663E\u793A/\u9690\u85CF\u5927\u7EB2",copyNodeLink:"\u590D\u5236\u9009\u4E2D\u8282\u70B9\u94FE\u63A5",exportSvg:"\u5BFC\u51FA\u601D\u7EF4\u5BFC\u56FE\u4E3A SVG",exportPng:"\u5BFC\u51FA\u601D\u7EF4\u5BFC\u56FE\u4E3A PNG",exportSelectedSvg:"\u5BFC\u51FA\u9009\u4E2D\u5206\u652F\u4E3A SVG",exportSelectedPng:"\u5BFC\u51FA\u9009\u4E2D\u5206\u652F\u4E3A PNG",markdown:"Markdown",addChildShort:"\u6DFB\u52A0\u5B50\u8282\u70B9",addSiblingShort:"\u6DFB\u52A0\u540C\u7EA7",duplicateShort:"\u590D\u5236\u8282\u70B9",setEmojiIcon:"\u8BBE\u7F6E Emoji \u56FE\u6807",addTagShort:"\u6DFB\u52A0\u6807\u7B7E",deleteShort:"\u5220\u9664",fitShort:"\u9002\u5E94\u7A97\u53E3",exportSvgShort:"\u5BFC\u51FA SVG",exportPngShort:"\u5BFC\u51FA PNG",copyLinkShort:"\u590D\u5236\u8282\u70B9\u94FE\u63A5",outline:"\u5927\u7EB2",hideOutline:"\u9690\u85CF\u5927\u7EB2",openMarkdownFirst:"\u8BF7\u5148\u6253\u5F00\u4E00\u7BC7 Markdown \u7B14\u8BB0\u3002",emptyView:"\u6253\u5F00 Markdown \u7B14\u8BB0\u540E\u5373\u53EF\u4F7F\u7528 linkmind\u3002",reloadedExternal:"linkmind \u5DF2\u91CD\u65B0\u52A0\u8F7D\u5916\u90E8 Markdown \u4FEE\u6539\u3002",keptLocal:"linkmind \u5DF2\u4FDD\u7559\u5BFC\u56FE\u7F16\u8F91\u5E76\u5199\u56DE Markdown\u3002",exported:"\u5DF2\u5BFC\u51FA",copiedLink:"\u5DF2\u590D\u5236 linkmind \u8282\u70B9\u94FE\u63A5\u3002",copiedBranch:"\u5DF2\u590D\u5236\u5206\u652F Markdown\u3002",pastedMarkdown:"\u5DF2\u5C06 Markdown \u7C98\u8D34\u5230 linkmind\u3002",clipboardEmpty:"\u526A\u8D34\u677F\u91CC\u6CA1\u6709\u53EF\u7528\u7684 Markdown \u8282\u70B9\u3002",tagFilterActive:"\u6807\u7B7E\u8FC7\u6EE4",chooseEmoji:"\u9009\u62E9 Emoji \u56FE\u6807",enterTag:"\u8F93\u5165\u6807\u7B7E\u540D",conflictTitle:"linkmind \u51B2\u7A81",conflictBody:"\u8FD9\u7BC7\u7B14\u8BB0\u5728\u78C1\u76D8\u4E0A\u53D1\u751F\u4E86\u53D8\u5316\uFF0C\u540C\u65F6\u601D\u7EF4\u5BFC\u56FE\u91CC\u8FD8\u6709\u672A\u4FDD\u5B58\u7F16\u8F91\u3002\u8BF7\u9009\u62E9\u8981\u4FDD\u7559\u7684\u7248\u672C\u3002",reloadMarkdown:"\u91CD\u65B0\u52A0\u8F7D Markdown",keepEdits:"\u4FDD\u7559 linkmind \u7F16\u8F91",settingsTitle:"linkmind",language:"\u8BED\u8A00",languageDesc:"\u9009\u62E9 linkmind \u754C\u9762\u8BED\u8A00\u3002",english:"English",chinese:"\u4E2D\u6587",autoSaveDelay:"\u81EA\u52A8\u4FDD\u5B58\u5EF6\u8FDF",autoSaveDelayDesc:"\u5BFC\u56FE\u7F16\u8F91\u540E\u7B49\u5F85\u591A\u5C11\u6BEB\u79D2\u518D\u5199\u56DE Markdown\u3002",defaultExpandDepth:"\u9ED8\u8BA4\u5C55\u5F00\u6DF1\u5EA6",defaultExpandDepthDesc:"\u6253\u5F00\u7B14\u8BB0\u65F6\u9ED8\u8BA4\u5C55\u5F00\u7684\u5C42\u7EA7\u300299 \u8868\u793A\u5168\u90E8\u5C55\u5F00\u3002",layoutDirection:"\u5E03\u5C40\u65B9\u5411",layoutDirectionDesc:"\u9009\u62E9\u7ECF\u5178\u5411\u53F3\u6811\u5F62\u5E03\u5C40\uFF0C\u6216\u6839\u8282\u70B9\u5C45\u4E2D\u7684\u53CC\u5411\u5E73\u8861\u5E03\u5C40\u3002",horizontalRight:"\u6C34\u5E73\u5411\u53F3",balanced:"\u53CC\u5411\u5E73\u8861",layoutAnimation:"\u5E03\u5C40\u52A8\u753B",layoutAnimationDesc:"\u7F16\u8F91\u540E\u4E3A\u8282\u70B9\u79FB\u52A8\u6DFB\u52A0\u52A8\u753B\u3002",branchColors:"\u5206\u652F\u989C\u8272",branchColorsDesc:"\u4E00\u7EA7\u5206\u652F\u4F7F\u7528\u7684 CSS \u989C\u8272\uFF0C\u4F7F\u7528\u82F1\u6587\u9017\u53F7\u5206\u9694\u3002",resetBranchColors:"\u91CD\u7F6E\u5206\u652F\u989C\u8272",pngScale:"PNG \u5BFC\u51FA\u500D\u7387",pngScaleDesc:"\u5BFC\u51FA PNG \u6587\u4EF6\u65F6\u4F7F\u7528\u7684\u5206\u8FA8\u7387\u500D\u7387\u3002",transparentPng:"\u900F\u660E PNG \u80CC\u666F",transparentPngDesc:"\u5BFC\u51FA PNG \u65F6\u4FDD\u7559\u900F\u660E\u80CC\u666F\uFF0C\u800C\u4E0D\u662F\u586B\u5145 Obsidian \u80CC\u666F\u8272\u3002",showAssociationLinks:"\u663E\u793A\u5173\u8054\u7EBF",showAssociationLinksDesc:"\u4E3A [[#\u6807\u9898]] \u6216 [[\u6807\u9898]] \u8FD9\u7C7B\u672C\u5730 wikilink \u7ED8\u5236\u8DE8\u5206\u652F\u865A\u7EBF\u5173\u8054\u3002",hideNodeBorders:"\u9690\u85CF\u8282\u70B9\u8FB9\u6846",hideNodeBordersDesc:"\u9690\u85CF\u8282\u70B9\u7684\u5F69\u8272\u8FB9\u6846\uFF0C\u4EC5\u4FDD\u7559\u80CC\u666F\u586B\u5145\u3002",nodeBorderRadius:"\u8282\u70B9\u5706\u89D2",nodeBorderRadiusDesc:"\u8282\u70B9\u8FB9\u6846\u5706\u89D2\u5927\u5C0F\uFF08\u50CF\u7D20\uFF09\u30020 \u4E3A\u76F4\u89D2\uFF0C999 \u4E3A\u80F6\u56CA\u5F62\u3002",nodeBorderWidth:"\u8FB9\u6846\u7EBF\u7C97\u7EC6",nodeBorderWidthDesc:"\u8282\u70B9\u8FB9\u6846\u7EBF\u7C97\u7EC6\uFF08\u50CF\u7D20\uFF09\u30020 \u8868\u793A\u4E0D\u663E\u793A\u8FB9\u6846\u7EBF\u3002",borderWidthShort:"\u8FB9\u6846",borderRadiusShort:"\u5706\u89D2",nodeStyleShort:"\u6837\u5F0F",nodeBgColor:"\u8282\u70B9\u80CC\u666F\u8272",nodeBgColorDesc:"\u8282\u70B9\u80CC\u666F\u8272 CSS \u503C\u3002\u586B transparent \u8868\u793A\u9ED8\u8BA4\u900F\u660E\u3002",transparent:"\u900F\u660E",saved:"\u5DF2\u4FDD\u5B58",unsaved:"\u672A\u4FDD\u5B58",saving:"\u4FDD\u5B58\u4E2D",nodesLabel:"\u8282\u70B9",selectedLabel:"\u5DF2\u9009",zoomLabel:"\u7F29\u653E",openAsMindMap:"\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00",newMindMapInFolder:"\u5728\u6B64\u6587\u4EF6\u5939\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",mindMapFiles:"\u601D\u7EF4\u5BFC\u56FE\u6587\u4EF6",mindMapFilesDesc:"\u8FD9\u4E9B\u6587\u4EF6\u6253\u5F00\u65F6\u9ED8\u8BA4\u4F7F\u7528\u601D\u7EF4\u5BFC\u56FE\u89C6\u56FE\u3002",clearMindMapFiles:"\u6E05\u9664\u5217\u8868"}},At=180,x=42,q=230,P=18,Bt=4,z=class extends h.Plugin{constructor(){super(...arguments);this.settings=O;this.skipAutoSwitchUntil=0}async onload(){this.settings=Object.assign({},O,await this.loadData()),this.registerView(D,t=>new N(t,this)),this.addRibbonIcon("brain-circuit",this.t("openRibbon"),()=>{let t=this.getActiveMarkdownFile();t?(this.addMindMapFile(t.path),this.openMindMap(t,this.getActiveHeadingAnchor())):this.createMindMap()}),this.addCommand({id:"create-linkmind-note",name:this.t("createMindMap"),callback:()=>this.createMindMap()}),this.addCommand({id:"open-linkmind-view",name:this.t("openMindMap"),checkCallback:t=>{let e=this.getActiveMarkdownFile();return e?(t||(this.addMindMapFile(e.path),this.openMindMap(e,this.getActiveHeadingAnchor())),!0):!1}}),this.addCommand({id:"return-to-markdown",name:this.t("returnMarkdown"),callback:()=>{let t=this.app.workspace.getActiveViewOfType(N);t&&t.openMarkdown()}}),this.addMindMapCommand("add-child-node",this.t("addChild"),t=>t.addChildNode()),this.addMindMapCommand("add-sibling-node",this.t("addSibling"),t=>t.addSiblingNode()),this.addMindMapCommand("duplicate-node",this.t("duplicateNode"),t=>t.duplicateSelectedNode()),this.addMindMapCommand("move-node-up",this.t("moveUp"),t=>t.moveSelectedNode("up")),this.addMindMapCommand("move-node-down",this.t("moveDown"),t=>t.moveSelectedNode("down")),this.addMindMapCommand("indent-node",this.t("indentNode"),t=>t.moveSelectedNode("indent")),this.addMindMapCommand("outdent-node",this.t("outdentNode"),t=>t.moveSelectedNode("outdent")),this.addMindMapCommand("edit-selected-node",this.t("editNode"),t=>t.editSelectedNode()),this.addMindMapCommand("delete-selected-node",this.t("deleteNode"),t=>t.deleteSelectedNode()),this.addMindMapCommand("toggle-selected-node",this.t("toggleNode"),t=>t.toggleSelectedNode()),this.addMindMapCommand("set-node-emoji",this.t("setEmoji"),t=>t.openEmojiPicker()),this.addMindMapCommand("clear-node-emoji",this.t("clearEmoji"),t=>t.clearSelectedEmoji()),this.addMindMapCommand("add-node-tag",this.t("addTag"),t=>t.openTagModal()),this.addMindMapCommand("clear-node-tags",this.t("clearTags"),t=>t.clearSelectedTags()),this.addMindMapCommand("select-all-nodes",this.t("selectAll"),t=>t.selectAllNodes()),this.addMindMapCommand("expand-all-nodes",this.t("expandAll"),t=>t.expandAllNodes()),this.addMindMapCommand("collapse-all-nodes",this.t("collapseAll"),t=>t.collapseAllNodes()),this.addMindMapCommand("fit-mind-map",this.t("fitMap"),t=>t.fitToView()),this.addMindMapCommand("focus-selected-node",this.t("focusNode"),t=>t.focusSelected()),this.addMindMapCommand("search-nodes",this.t("searchNodes"),t=>t.focusSearch()),this.addMindMapCommand("filter-by-tag",this.t("filterByTag"),t=>t.openTagFilterModal()),this.addMindMapCommand("clear-tag-filter",this.t("clearTagFilter"),t=>t.clearTagFilter()),this.addMindMapCommand("toggle-outline",this.t("toggleOutline"),t=>t.toggleOutline()),this.addMindMapCommand("copy-node-link",this.t("copyNodeLink"),t=>void t.copySelectedNodeLink()),this.addMindMapCommand("copy-branch-markdown",this.t("copyBranch"),t=>void t.copySelectedBranchMarkdown()),this.addMindMapCommand("paste-markdown-child",this.t("pasteChild"),t=>void t.pasteMarkdownAsChild()),this.addMindMapCommand("paste-markdown-sibling",this.t("pasteSibling"),t=>void t.pasteMarkdownAsSibling()),this.addMindMapCommand("export-svg",this.t("exportSvg"),t=>void t.exportSvg()),this.addMindMapCommand("export-png",this.t("exportPng"),t=>void t.exportPng()),this.addMindMapCommand("export-selected-svg",this.t("exportSelectedSvg"),t=>void t.exportSelectedSvg()),this.addMindMapCommand("export-selected-png",this.t("exportSelectedPng"),t=>void t.exportSelectedPng()),this.addSettingTab(new Z(this.app,this)),this.registerEvent(this.app.workspace.on("file-menu",(t,e)=>{if(e instanceof h.TFolder){t.addItem(i=>i.setTitle(this.t("newMindMapInFolder")).setIcon("brain-circuit").onClick(()=>this.createMindMapInFolder(e)));return}!(e instanceof h.TFile)||e.extension!=="md"||t.addItem(i=>i.setTitle(this.t("openAsMindMap")).setIcon("brain-circuit").onClick(()=>{this.addMindMapFile(e.path),this.openMindMap(e)}))})),this.registerEvent(this.app.workspace.on("editor-menu",(t,e,i)=>{if(!(i instanceof h.MarkdownView))return;let n=i.file;n&&t.addItem(r=>r.setTitle(this.t("openMindMap")).setIcon("brain-circuit").onClick(()=>{this.addMindMapFile(n.path),this.openMindMap(n)}))})),this.registerEvent(this.app.workspace.on("active-leaf-change",t=>{if(Date.now(){let r=n.view;return r instanceof N&&r.getState().file===e.path});if(i&&i!==t){this.app.workspace.setActiveLeaf(i,{focus:!0}),this.app.workspace.revealLeaf(i);return}t.setViewState({type:D,state:{file:e.path},active:!0})}))}onunload(){this.app.workspace.detachLeavesOfType(D)}async saveSettings(){await this.saveData(this.settings)}t(t){var e,i;return(i=(e=dt[this.settings.language])==null?void 0:e[t])!=null?i:dt.en[t]}refreshOpenViews(){this.app.workspace.getLeavesOfType(D).forEach(t=>{let e=t.view;e instanceof N&&e.applySettings()})}addMindMapCommand(t,e,i){this.addCommand({id:t,name:e,checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(N);return r?(n||i(r),!0):!1}})}getActiveMarkdownFile(){var e;let t=this.app.workspace.getActiveViewOfType(h.MarkdownView);return(e=t==null?void 0:t.file)!=null?e:null}getActiveHeadingAnchor(){let t=this.app.workspace.getActiveViewOfType(h.MarkdownView);if(!t)return null;let e=t.editor.getCursor();for(let i=e.line;i>=0;i-=1){let n=/^(#{1,6})\s+(.+?)\s*$/.exec(t.editor.getLine(i));if(n)return T(n[2])}return null}async openMindMap(t=this.getActiveMarkdownFile(),e=null){var d;if(!t){new h.Notice(this.t("openMarkdownFirst"));return}let i=this.app.workspace.activeLeaf,n=i==null?void 0:i.view;await(i&&(n instanceof h.MarkdownView&&((d=n.file)==null?void 0:d.path)===t.path||n instanceof N&&n.getState().file===t.path)?i:this.app.workspace.getLeaf(!1)).setViewState({type:D,state:{file:t.path,heading:e!=null?e:void 0},active:!0})}createMindMap(){new U(this.app,this.t("createMindMap"),this.t("mindMapNamePlaceholder"),this.t("createButton"),this.t("newMindMapTitle"),async t=>{let e=await this.createMindMapFile(t);this.addMindMapFile(e.path),new h.Notice(`${this.t("createdMindMap")}: ${e.basename}`),await this.openMindMap(e)}).open()}async createMindMapFile(t){var l,p;let e=this.t("newMindMapTitle"),i=t.trim()||e,n=ht(i)||e,r=(p=(l=this.getActiveMarkdownFile())==null?void 0:l.parent)==null?void 0:p.path,a=r&&r!=="/"?`${r}/`:"",d=this.getAvailablePath(a,n);return await this.app.vault.create(d,`# ${i} +var Q=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Tt=Object.prototype.hasOwnProperty;var It=(o,s)=>{for(var t in s)Q(o,t,{get:s[t],enumerable:!0})},Dt=(o,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of Ct(s))!Tt.call(o,i)&&i!==t&&Q(o,i,{get:()=>s[i],enumerable:!(e=Nt(s,i))||e.enumerable});return o};var Pt=o=>Dt(Q({},"__esModule",{value:!0}),o);var _t={};It(_t,{default:()=>z});module.exports=Pt(_t);var c=require("obsidian"),P="linkmind-view",$t=300,Lt=["\u{1F4A1}","\u2705","\u{1F525}","\u2B50","\u{1F3AF}","\u{1F680}","\u{1F4CC}","\u{1F4CE}","\u{1F9E0}","\u{1F4DD}","\u{1F4DA}","\u{1F50D}","\u26A1","\u2764\uFE0F","\u2753","\u26A0\uFE0F","\u{1F331}","\u{1F3C1}","\u{1F527}","\u{1F4AC}","\u{1F3A8}","\u{1F9E9}","\u{1F4CA}","\u{1F517}","\u{1F48E}","\u{1F3C6}","\u{1F3AA}","\u{1F31F}","\u{1F3A7}","\u{1F3AC}","\u{1F4F1}","\u{1F4BB}","\u{1F30D}","\u{1F3E0}","\u{1F3B5}","\u{1F3B2}","\u{1F9EA}","\u{1F6E0}","\u2728","\u{1F389}","\u{1F4CC}","\u{1F511}","\u{1F4E6}","\u{1F9F2}","\u{1F4B0}","\u{1F3AE}","\u{1F9D8}","\u{1F308}","\u{1F340}","\u{1F33A}","\u{1F98B}","\u{1F41D}","\u{1F431}","\u{1F436}","\u{1F98A}","\u{1F43C}","\u{1F981}","\u{1F428}","\u{1F438}","\u{1F984}"],Bt=["#ffffff","#f8fafc","#fef3c7","#dcfce7","#dbeafe","#fce7f3","#ede9fe","#fee2e2"],O={autoSaveDelay:300,branchColors:["#5b8def","#45b36b","#e89b3c","#9b72e7","#df6f9f"],defaultExpandDepth:99,animations:!0,layoutDirection:"right",exportScale:2,exportTransparentBackground:!1,language:"zh",showAssociationLinks:!0,hideNodeBorders:!1,nodeBorderRadius:10,nodeBorderWidth:3,nodeBgColor:"transparent",mindMapFiles:[]},lt={en:{openRibbon:"Open linkmind",openMindMap:"Open current note as mind map",createMindMap:"Create new mind map",newMindMapTitle:"New mind map",mindMapNamePlaceholder:"Mind map name",createButton:"Create",createdMindMap:"Created mind map",returnMarkdown:"Return to Markdown editor",switchToNote:"Note view",switchToMindMap:"Mind map view",addChild:"Add child node",addSibling:"Add sibling node",duplicateNode:"Duplicate selected node",moveUp:"Move selected node up",moveDown:"Move selected node down",indentNode:"Indent selected node",outdentNode:"Outdent selected node",editNode:"Edit selected node",deleteNode:"Delete selected node",toggleNode:"Toggle selected node",setEmoji:"Set selected node emoji",clearEmoji:"Clear selected node emoji",addTag:"Add tag to selected nodes",clearTags:"Clear tags from selected nodes",copyBranch:"Copy selected branch as Markdown",pasteChild:"Paste Markdown as child nodes",pasteSibling:"Paste Markdown as sibling nodes",selectAll:"Select all nodes",expandAll:"Expand all nodes",collapseAll:"Collapse all nodes",fitMap:"Fit mind map to view",focusNode:"Focus selected node",searchNodes:"Search nodes",filterByTag:"Filter by tag",clearTagFilter:"Clear tag filter",toggleOutline:"Toggle outline",copyNodeLink:"Copy selected node link",exportSvg:"Export mind map as SVG",exportPng:"Export mind map as PNG",exportSelectedSvg:"Export selected branch as SVG",exportSelectedPng:"Export selected branch as PNG",markdown:"Markdown",addChildShort:"Add child",addSiblingShort:"Add sibling",duplicateShort:"Duplicate",setEmojiIcon:"Set emoji icon",addTagShort:"Add tag",deleteShort:"Delete",fitShort:"Fit",exportSvgShort:"Export SVG",exportPngShort:"Export PNG",copyLinkShort:"Copy node link",outline:"Outline",hideOutline:"Hide outline",openMarkdownFirst:"Open a Markdown note first.",switchConfirmTitle:"Switch to mind map view",switchConfirmBody:"This is not a mind map note. Content that cannot be displayed as a mind map will be preserved but hidden. Continue?",switchConfirm:"Switch",emptyView:"Open a Markdown note to use linkmind.",reloadedExternal:"linkmind reloaded the external Markdown changes.",keptLocal:"linkmind kept the mind map edits and wrote them to Markdown.",exported:"Exported",copiedLink:"Copied linkmind node link.",copiedBranch:"Copied branch Markdown.",pastedMarkdown:"Pasted Markdown into linkmind.",clipboardEmpty:"Clipboard does not contain Markdown nodes.",tagFilterActive:"Tag filter",chooseEmoji:"Choose an emoji icon",enterTag:"Enter tag name",conflictTitle:"linkmind conflict",conflictBody:"This note changed on disk while the mind map has unsaved local edits. Choose which version should win.",reloadMarkdown:"Reload Markdown",keepEdits:"Keep linkmind edits",settingsTitle:"linkmind",language:"Language",languageDesc:"Choose the language used by linkmind UI.",english:"English",chinese:"\u4E2D\u6587",autoSaveDelay:"Auto-save delay",autoSaveDelayDesc:"Milliseconds to wait after a mind map edit before writing Markdown.",defaultExpandDepth:"Default expand depth",defaultExpandDepthDesc:"How many levels are expanded when a note opens. Use 99 for all.",layoutDirection:"Layout direction",layoutDirectionDesc:"Choose a classic right-facing tree or a balanced map with branches on both sides.",horizontalRight:"Horizontal right",balanced:"Balanced",layoutAnimation:"Layout animation",layoutAnimationDesc:"Animate node movement after edits.",branchColors:"Branch colors",branchColorsDesc:"Comma-separated CSS colors used for first-level branches.",resetBranchColors:"Reset branch colors",pngScale:"PNG export scale",pngScaleDesc:"Resolution multiplier used when exporting PNG files.",transparentPng:"Transparent PNG background",transparentPngDesc:"Leave PNG exports transparent instead of filling the Obsidian background color.",showAssociationLinks:"Show association links",showAssociationLinksDesc:"Draw dashed cross-branch links for local wikilinks like [[#Heading]] or [[Heading]].",hideNodeBorders:"Hide node borders",hideNodeBordersDesc:"Remove the colored border from nodes, leaving only the background fill.",nodeBorderRadius:"Node border radius",nodeBorderRadiusDesc:"Border corner radius in pixels. Use 0 for sharp corners, 999 for pill shape.",nodeBorderWidth:"Node border width",nodeBorderWidthDesc:"Border line thickness in pixels. Use 0 to hide borders.",borderWidthShort:"Border",borderRadiusShort:"Radius",nodeStyleShort:"Style",nodeBgColor:"Node background",nodeBgColorDesc:"CSS color for node background. Use 'transparent' for default theme background.",transparent:"Transparent",saved:"Saved",unsaved:"Unsaved",saving:"Saving",nodesLabel:"nodes",selectedLabel:"selected",zoomLabel:"zoom",openAsMindMap:"Open as mind map",newMindMapInFolder:"New mind map in folder",mindMapFiles:"Mind map files",mindMapFilesDesc:"Files that default to mind map view when opened.",clearMindMapFiles:"Clear list"},zh:{openRibbon:"\u6253\u5F00 linkmind",openMindMap:"\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00\u5F53\u524D\u7B14\u8BB0",createMindMap:"\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",newMindMapTitle:"\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",mindMapNamePlaceholder:"\u601D\u7EF4\u5BFC\u56FE\u540D\u79F0",createButton:"\u521B\u5EFA",createdMindMap:"\u5DF2\u521B\u5EFA\u601D\u7EF4\u5BFC\u56FE",returnMarkdown:"\u8FD4\u56DE Markdown \u7F16\u8F91\u5668",switchToNote:"\u7B14\u8BB0\u89C6\u56FE",switchToMindMap:"\u601D\u7EF4\u5BFC\u56FE\u89C6\u56FE",addChild:"\u6DFB\u52A0\u5B50\u8282\u70B9",addSibling:"\u6DFB\u52A0\u540C\u7EA7\u8282\u70B9",duplicateNode:"\u590D\u5236\u9009\u4E2D\u8282\u70B9",moveUp:"\u4E0A\u79FB\u9009\u4E2D\u8282\u70B9",moveDown:"\u4E0B\u79FB\u9009\u4E2D\u8282\u70B9",indentNode:"\u7F29\u8FDB\u9009\u4E2D\u8282\u70B9",outdentNode:"\u53D6\u6D88\u7F29\u8FDB\u9009\u4E2D\u8282\u70B9",editNode:"\u7F16\u8F91\u9009\u4E2D\u8282\u70B9",deleteNode:"\u5220\u9664\u9009\u4E2D\u8282\u70B9",toggleNode:"\u6298\u53E0/\u5C55\u5F00\u9009\u4E2D\u8282\u70B9",setEmoji:"\u8BBE\u7F6E\u9009\u4E2D\u8282\u70B9 Emoji",clearEmoji:"\u6E05\u9664\u9009\u4E2D\u8282\u70B9 Emoji",addTag:"\u7ED9\u9009\u4E2D\u8282\u70B9\u6DFB\u52A0\u6807\u7B7E",clearTags:"\u6E05\u9664\u9009\u4E2D\u8282\u70B9\u6807\u7B7E",copyBranch:"\u590D\u5236\u9009\u4E2D\u5206\u652F\u4E3A Markdown",pasteChild:"\u7C98\u8D34 Markdown \u4E3A\u5B50\u8282\u70B9",pasteSibling:"\u7C98\u8D34 Markdown \u4E3A\u540C\u7EA7\u8282\u70B9",selectAll:"\u9009\u62E9\u5168\u90E8\u8282\u70B9",expandAll:"\u5C55\u5F00\u5168\u90E8\u8282\u70B9",collapseAll:"\u6298\u53E0\u5168\u90E8\u8282\u70B9",fitMap:"\u9002\u5E94\u7A97\u53E3",focusNode:"\u805A\u7126\u9009\u4E2D\u8282\u70B9",searchNodes:"\u641C\u7D22\u8282\u70B9",filterByTag:"\u6309\u6807\u7B7E\u8FC7\u6EE4",clearTagFilter:"\u6E05\u9664\u6807\u7B7E\u8FC7\u6EE4",toggleOutline:"\u663E\u793A/\u9690\u85CF\u5927\u7EB2",copyNodeLink:"\u590D\u5236\u9009\u4E2D\u8282\u70B9\u94FE\u63A5",exportSvg:"\u5BFC\u51FA\u601D\u7EF4\u5BFC\u56FE\u4E3A SVG",exportPng:"\u5BFC\u51FA\u601D\u7EF4\u5BFC\u56FE\u4E3A PNG",exportSelectedSvg:"\u5BFC\u51FA\u9009\u4E2D\u5206\u652F\u4E3A SVG",exportSelectedPng:"\u5BFC\u51FA\u9009\u4E2D\u5206\u652F\u4E3A PNG",markdown:"Markdown",addChildShort:"\u6DFB\u52A0\u5B50\u8282\u70B9",addSiblingShort:"\u6DFB\u52A0\u540C\u7EA7",duplicateShort:"\u590D\u5236\u8282\u70B9",setEmojiIcon:"\u8BBE\u7F6E Emoji \u56FE\u6807",addTagShort:"\u6DFB\u52A0\u6807\u7B7E",deleteShort:"\u5220\u9664",fitShort:"\u9002\u5E94\u7A97\u53E3",exportSvgShort:"\u5BFC\u51FA SVG",exportPngShort:"\u5BFC\u51FA PNG",copyLinkShort:"\u590D\u5236\u8282\u70B9\u94FE\u63A5",outline:"\u5927\u7EB2",hideOutline:"\u9690\u85CF\u5927\u7EB2",openMarkdownFirst:"\u8BF7\u5148\u6253\u5F00\u4E00\u7BC7 Markdown \u7B14\u8BB0\u3002",switchConfirmTitle:"\u5207\u6362\u5230\u601D\u7EF4\u5BFC\u56FE\u89C6\u56FE",switchConfirmBody:"\u8FD9\u4E0D\u662F\u601D\u7EF4\u5BFC\u56FE\u7B14\u8BB0\uFF0C\u8F6C\u6362\u540E\u65E0\u6CD5\u5C55\u793A\u7684\u5185\u5BB9\u4F1A\u88AB\u4FDD\u7559\u4F46\u4E0D\u4F1A\u663E\u793A\u3002\u786E\u8BA4\u5207\u6362\u5417\uFF1F",switchConfirm:"\u5207\u6362",emptyView:"\u6253\u5F00 Markdown \u7B14\u8BB0\u540E\u5373\u53EF\u4F7F\u7528 linkmind\u3002",reloadedExternal:"linkmind \u5DF2\u91CD\u65B0\u52A0\u8F7D\u5916\u90E8 Markdown \u4FEE\u6539\u3002",keptLocal:"linkmind \u5DF2\u4FDD\u7559\u5BFC\u56FE\u7F16\u8F91\u5E76\u5199\u56DE Markdown\u3002",exported:"\u5DF2\u5BFC\u51FA",copiedLink:"\u5DF2\u590D\u5236 linkmind \u8282\u70B9\u94FE\u63A5\u3002",copiedBranch:"\u5DF2\u590D\u5236\u5206\u652F Markdown\u3002",pastedMarkdown:"\u5DF2\u5C06 Markdown \u7C98\u8D34\u5230 linkmind\u3002",clipboardEmpty:"\u526A\u8D34\u677F\u91CC\u6CA1\u6709\u53EF\u7528\u7684 Markdown \u8282\u70B9\u3002",tagFilterActive:"\u6807\u7B7E\u8FC7\u6EE4",chooseEmoji:"\u9009\u62E9 Emoji \u56FE\u6807",enterTag:"\u8F93\u5165\u6807\u7B7E\u540D",conflictTitle:"linkmind \u51B2\u7A81",conflictBody:"\u8FD9\u7BC7\u7B14\u8BB0\u5728\u78C1\u76D8\u4E0A\u53D1\u751F\u4E86\u53D8\u5316\uFF0C\u540C\u65F6\u601D\u7EF4\u5BFC\u56FE\u91CC\u8FD8\u6709\u672A\u4FDD\u5B58\u7F16\u8F91\u3002\u8BF7\u9009\u62E9\u8981\u4FDD\u7559\u7684\u7248\u672C\u3002",reloadMarkdown:"\u91CD\u65B0\u52A0\u8F7D Markdown",keepEdits:"\u4FDD\u7559 linkmind \u7F16\u8F91",settingsTitle:"linkmind",language:"\u8BED\u8A00",languageDesc:"\u9009\u62E9 linkmind \u754C\u9762\u8BED\u8A00\u3002",english:"English",chinese:"\u4E2D\u6587",autoSaveDelay:"\u81EA\u52A8\u4FDD\u5B58\u5EF6\u8FDF",autoSaveDelayDesc:"\u5BFC\u56FE\u7F16\u8F91\u540E\u7B49\u5F85\u591A\u5C11\u6BEB\u79D2\u518D\u5199\u56DE Markdown\u3002",defaultExpandDepth:"\u9ED8\u8BA4\u5C55\u5F00\u6DF1\u5EA6",defaultExpandDepthDesc:"\u6253\u5F00\u7B14\u8BB0\u65F6\u9ED8\u8BA4\u5C55\u5F00\u7684\u5C42\u7EA7\u300299 \u8868\u793A\u5168\u90E8\u5C55\u5F00\u3002",layoutDirection:"\u5E03\u5C40\u65B9\u5411",layoutDirectionDesc:"\u9009\u62E9\u7ECF\u5178\u5411\u53F3\u6811\u5F62\u5E03\u5C40\uFF0C\u6216\u6839\u8282\u70B9\u5C45\u4E2D\u7684\u53CC\u5411\u5E73\u8861\u5E03\u5C40\u3002",horizontalRight:"\u6C34\u5E73\u5411\u53F3",balanced:"\u53CC\u5411\u5E73\u8861",layoutAnimation:"\u5E03\u5C40\u52A8\u753B",layoutAnimationDesc:"\u7F16\u8F91\u540E\u4E3A\u8282\u70B9\u79FB\u52A8\u6DFB\u52A0\u52A8\u753B\u3002",branchColors:"\u5206\u652F\u989C\u8272",branchColorsDesc:"\u4E00\u7EA7\u5206\u652F\u4F7F\u7528\u7684 CSS \u989C\u8272\uFF0C\u4F7F\u7528\u82F1\u6587\u9017\u53F7\u5206\u9694\u3002",resetBranchColors:"\u91CD\u7F6E\u5206\u652F\u989C\u8272",pngScale:"PNG \u5BFC\u51FA\u500D\u7387",pngScaleDesc:"\u5BFC\u51FA PNG \u6587\u4EF6\u65F6\u4F7F\u7528\u7684\u5206\u8FA8\u7387\u500D\u7387\u3002",transparentPng:"\u900F\u660E PNG \u80CC\u666F",transparentPngDesc:"\u5BFC\u51FA PNG \u65F6\u4FDD\u7559\u900F\u660E\u80CC\u666F\uFF0C\u800C\u4E0D\u662F\u586B\u5145 Obsidian \u80CC\u666F\u8272\u3002",showAssociationLinks:"\u663E\u793A\u5173\u8054\u7EBF",showAssociationLinksDesc:"\u4E3A [[#\u6807\u9898]] \u6216 [[\u6807\u9898]] \u8FD9\u7C7B\u672C\u5730 wikilink \u7ED8\u5236\u8DE8\u5206\u652F\u865A\u7EBF\u5173\u8054\u3002",hideNodeBorders:"\u9690\u85CF\u8282\u70B9\u8FB9\u6846",hideNodeBordersDesc:"\u9690\u85CF\u8282\u70B9\u7684\u5F69\u8272\u8FB9\u6846\uFF0C\u4EC5\u4FDD\u7559\u80CC\u666F\u586B\u5145\u3002",nodeBorderRadius:"\u8282\u70B9\u5706\u89D2",nodeBorderRadiusDesc:"\u8282\u70B9\u8FB9\u6846\u5706\u89D2\u5927\u5C0F\uFF08\u50CF\u7D20\uFF09\u30020 \u4E3A\u76F4\u89D2\uFF0C999 \u4E3A\u80F6\u56CA\u5F62\u3002",nodeBorderWidth:"\u8FB9\u6846\u7EBF\u7C97\u7EC6",nodeBorderWidthDesc:"\u8282\u70B9\u8FB9\u6846\u7EBF\u7C97\u7EC6\uFF08\u50CF\u7D20\uFF09\u30020 \u8868\u793A\u4E0D\u663E\u793A\u8FB9\u6846\u7EBF\u3002",borderWidthShort:"\u8FB9\u6846",borderRadiusShort:"\u5706\u89D2",nodeStyleShort:"\u6837\u5F0F",nodeBgColor:"\u8282\u70B9\u80CC\u666F\u8272",nodeBgColorDesc:"\u8282\u70B9\u80CC\u666F\u8272 CSS \u503C\u3002\u586B transparent \u8868\u793A\u9ED8\u8BA4\u900F\u660E\u3002",transparent:"\u900F\u660E",saved:"\u5DF2\u4FDD\u5B58",unsaved:"\u672A\u4FDD\u5B58",saving:"\u4FDD\u5B58\u4E2D",nodesLabel:"\u8282\u70B9",selectedLabel:"\u5DF2\u9009",zoomLabel:"\u7F29\u653E",openAsMindMap:"\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00",newMindMapInFolder:"\u5728\u6B64\u6587\u4EF6\u5939\u65B0\u5EFA\u601D\u7EF4\u5BFC\u56FE",mindMapFiles:"\u601D\u7EF4\u5BFC\u56FE\u6587\u4EF6",mindMapFilesDesc:"\u8FD9\u4E9B\u6587\u4EF6\u6253\u5F00\u65F6\u9ED8\u8BA4\u4F7F\u7528\u601D\u7EF4\u5BFC\u56FE\u89C6\u56FE\u3002",clearMindMapFiles:"\u6E05\u9664\u5217\u8868"}},At=220,k=42,J=270,x=18,Ft=4,z=class extends c.Plugin{constructor(){super(...arguments);this.settings=O;this.skipAutoSwitchUntil=0}async onload(){this.settings=Object.assign({},O,await this.loadData()),this.registerView(P,t=>new C(t,this)),this.addRibbonIcon("brain-circuit",this.t("openRibbon"),()=>{let t=this.getActiveMarkdownFile();if(!t){this.createMindMap();return}this.openMindMap(t,this.getActiveHeadingAnchor())}),this.addCommand({id:"create-linkmind-note",name:this.t("createMindMap"),callback:()=>this.createMindMap()}),this.addCommand({id:"open-linkmind-view",name:this.t("openMindMap"),checkCallback:t=>{let e=this.getActiveMarkdownFile();return e?(t||this.openMindMap(e,this.getActiveHeadingAnchor()),!0):!1}}),this.addCommand({id:"return-to-markdown",name:this.t("returnMarkdown"),callback:()=>{let t=this.app.workspace.getActiveViewOfType(C);t&&t.openMarkdown()}}),this.addMindMapCommand("add-child-node",this.t("addChild"),t=>t.addChildNode()),this.addMindMapCommand("add-sibling-node",this.t("addSibling"),t=>t.addSiblingNode()),this.addMindMapCommand("duplicate-node",this.t("duplicateNode"),t=>t.duplicateSelectedNode()),this.addMindMapCommand("move-node-up",this.t("moveUp"),t=>t.moveSelectedNode("up")),this.addMindMapCommand("move-node-down",this.t("moveDown"),t=>t.moveSelectedNode("down")),this.addMindMapCommand("indent-node",this.t("indentNode"),t=>t.moveSelectedNode("indent")),this.addMindMapCommand("outdent-node",this.t("outdentNode"),t=>t.moveSelectedNode("outdent")),this.addMindMapCommand("edit-selected-node",this.t("editNode"),t=>t.editSelectedNode()),this.addMindMapCommand("delete-selected-node",this.t("deleteNode"),t=>t.deleteSelectedNode()),this.addMindMapCommand("toggle-selected-node",this.t("toggleNode"),t=>t.toggleSelectedNode()),this.addMindMapCommand("set-node-emoji",this.t("setEmoji"),t=>t.openEmojiPicker()),this.addMindMapCommand("clear-node-emoji",this.t("clearEmoji"),t=>t.clearSelectedEmoji()),this.addMindMapCommand("add-node-tag",this.t("addTag"),t=>t.openTagModal()),this.addMindMapCommand("clear-node-tags",this.t("clearTags"),t=>t.clearSelectedTags()),this.addMindMapCommand("select-all-nodes",this.t("selectAll"),t=>t.selectAllNodes()),this.addMindMapCommand("expand-all-nodes",this.t("expandAll"),t=>t.expandAllNodes()),this.addMindMapCommand("collapse-all-nodes",this.t("collapseAll"),t=>t.collapseAllNodes()),this.addMindMapCommand("fit-mind-map",this.t("fitMap"),t=>t.fitToView()),this.addMindMapCommand("focus-selected-node",this.t("focusNode"),t=>t.focusSelected()),this.addMindMapCommand("search-nodes",this.t("searchNodes"),t=>t.focusSearch()),this.addMindMapCommand("filter-by-tag",this.t("filterByTag"),t=>t.openTagFilterModal()),this.addMindMapCommand("clear-tag-filter",this.t("clearTagFilter"),t=>t.clearTagFilter()),this.addMindMapCommand("toggle-outline",this.t("toggleOutline"),t=>t.toggleOutline()),this.addMindMapCommand("copy-node-link",this.t("copyNodeLink"),t=>void t.copySelectedNodeLink()),this.addMindMapCommand("copy-branch-markdown",this.t("copyBranch"),t=>void t.copySelectedBranchMarkdown()),this.addMindMapCommand("paste-markdown-child",this.t("pasteChild"),t=>void t.pasteMarkdownAsChild()),this.addMindMapCommand("paste-markdown-sibling",this.t("pasteSibling"),t=>void t.pasteMarkdownAsSibling()),this.addMindMapCommand("export-svg",this.t("exportSvg"),t=>void t.exportSvg()),this.addMindMapCommand("export-png",this.t("exportPng"),t=>void t.exportPng()),this.addMindMapCommand("export-selected-svg",this.t("exportSelectedSvg"),t=>void t.exportSelectedSvg()),this.addMindMapCommand("export-selected-png",this.t("exportSelectedPng"),t=>void t.exportSelectedPng()),this.addSettingTab(new tt(this.app,this)),this.registerEvent(this.app.workspace.on("file-menu",(t,e)=>{if(e instanceof c.TFolder){t.addItem(i=>i.setTitle(this.t("newMindMapInFolder")).setIcon("brain-circuit").onClick(()=>this.createMindMapInFolder(e)));return}!(e instanceof c.TFile)||e.extension!=="md"||t.addItem(i=>i.setTitle(this.t("openAsMindMap")).setIcon("brain-circuit").onClick(()=>{this.openMindMap(e)}))})),this.registerEvent(this.app.workspace.on("editor-menu",(t,e,i)=>{if(!(i instanceof c.MarkdownView))return;let n=i.file;n&&t.addItem(r=>r.setTitle(this.t("openMindMap")).setIcon("brain-circuit").onClick(()=>{this.openMindMap(n)}))})),this.registerEvent(this.app.workspace.on("active-leaf-change",t=>{if(Date.now(){let r=n.view;return r instanceof C&&r.getState().file===e.path});if(i&&i!==t){this.app.workspace.setActiveLeaf(i,{focus:!0}),this.app.workspace.revealLeaf(i);return}t.setViewState({type:P,state:{file:e.path},active:!0})}))}onunload(){this.app.workspace.detachLeavesOfType(P)}async saveSettings(){await this.saveData(this.settings)}t(t){var e,i;return(i=(e=lt[this.settings.language])==null?void 0:e[t])!=null?i:lt.en[t]}refreshOpenViews(){this.app.workspace.getLeavesOfType(P).forEach(t=>{let e=t.view;e instanceof C&&e.applySettings()})}addMindMapCommand(t,e,i){this.addCommand({id:t,name:e,checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(C);return r?(n||i(r),!0):!1}})}getActiveMarkdownFile(){var e;let t=this.app.workspace.getActiveViewOfType(c.MarkdownView);return(e=t==null?void 0:t.file)!=null?e:null}getActiveHeadingAnchor(){let t=this.app.workspace.getActiveViewOfType(c.MarkdownView);if(!t)return null;let e=t.editor.getCursor();for(let i=e.line;i>=0;i-=1){let n=/^(#{1,6})\s+(.+?)\s*$/.exec(t.editor.getLine(i));if(n)return I(n[2])}return null}async openMindMap(t=this.getActiveMarkdownFile(),e=null){if(!t){new c.Notice(this.t("openMarkdownFirst"));return}let i=async()=>{var l;let n=this.app.workspace.activeLeaf,r=n==null?void 0:n.view;await(n&&(r instanceof c.MarkdownView&&((l=r.file)==null?void 0:l.path)===t.path||r instanceof C&&r.getState().file===t.path)?n:this.app.workspace.getLeaf(!1)).setViewState({type:P,state:{file:t.path,heading:e!=null?e:void 0},active:!0})};if(this.settings.mindMapFiles.includes(t.path)){await i();return}new ot(this.app,{title:this.t("switchConfirmTitle"),body:this.t("switchConfirmBody"),confirm:this.t("switchConfirm")},async()=>{this.addMindMapFile(t.path),await i()}).open()}createMindMap(){new W(this.app,this.t("createMindMap"),this.t("mindMapNamePlaceholder"),this.t("createButton"),this.t("newMindMapTitle"),async t=>{let e=await this.createMindMapFile(t);this.addMindMapFile(e.path),new c.Notice(`${this.t("createdMindMap")}: ${e.basename}`),await this.openMindMap(e)}).open()}async createMindMapFile(t){var l,p;let e=this.t("newMindMapTitle"),i=t.trim()||e,n=ct(i)||e,r=(p=(l=this.getActiveMarkdownFile())==null?void 0:l.parent)==null?void 0:p.path,a=r&&r!=="/"?`${r}/`:"",d=this.getAvailablePath(a,n);return await this.app.vault.create(d,`# ${i} - New idea -`)}getAvailablePath(t,e){let i=0;for(;;){let n=i===0?"":` ${i+1}`,r=`${t}${e}${n}.md`;if(!this.app.vault.getAbstractFileByPath(r))return r;i+=1}}addMindMapFile(t){this.settings.mindMapFiles.includes(t)||(this.settings.mindMapFiles.push(t),this.saveSettings())}createMindMapInFolder(t){new U(this.app,this.t("createMindMap"),this.t("mindMapNamePlaceholder"),this.t("createButton"),this.t("newMindMapTitle"),async e=>{let i=await this.createMindMapFileInFolder(e,t);this.addMindMapFile(i.path),new h.Notice(`${this.t("createdMindMap")}: ${i.basename}`),await this.openMindMap(i)}).open()}async createMindMapFileInFolder(t,e){let i=this.t("newMindMapTitle"),n=t.trim()||i,r=ht(n)||i,a=e.path!=="/"?`${e.path}/`:"",d=this.getAvailablePath(a,r);return await this.app.vault.create(d,`# ${n} +`)}getAvailablePath(t,e){let i=0;for(;;){let n=i===0?"":` ${i+1}`,r=`${t}${e}${n}.md`;if(!this.app.vault.getAbstractFileByPath(r))return r;i+=1}}addMindMapFile(t){this.settings.mindMapFiles.includes(t)||(this.settings.mindMapFiles.push(t),this.saveSettings())}removeMindMapFile(t){let e=this.settings.mindMapFiles.filter(i=>i!==t);e.length!==this.settings.mindMapFiles.length&&(this.settings.mindMapFiles=e,this.saveSettings())}createMindMapInFolder(t){new W(this.app,this.t("createMindMap"),this.t("mindMapNamePlaceholder"),this.t("createButton"),this.t("newMindMapTitle"),async e=>{let i=await this.createMindMapFileInFolder(e,t);this.addMindMapFile(i.path),new c.Notice(`${this.t("createdMindMap")}: ${i.basename}`),await this.openMindMap(i)}).open()}async createMindMapFileInFolder(t,e){let i=this.t("newMindMapTitle"),n=t.trim()||i,r=ct(n)||i,a=e.path!=="/"?`${e.path}/`:"",d=this.getAvailablePath(a,r);return await this.app.vault.create(d,`# ${n} - New idea -`)}},N=class extends h.ItemView{constructor(t,e){super(t);this.file=null;this.root=null;this.selectedId=null;this.selectedIds=new Set;this.positions=[];this.searchQuery="";this.searchMatches=[];this.activeSearchIndex=-1;this.saveTimer=null;this.isSaving=!1;this.history=[];this.future=[];this.scale=1;this.panX=80;this.panY=80;this.panning=null;this.dragState=null;this.longPressTimer=null;this.dropTarget=null;this.dragMarkerEl=null;this.lastSavedMarkdown="";this.hasLocalUnsavedChange=!1;this.documentPrefix="";this.conflictModalOpen=!1;this.pendingFocus=null;this.outlineVisible=!0;this.tagFilter=null;this.plugin=e}getViewType(){return D}getDisplayText(){return this.file?`linkmind: ${this.file.basename}`:"linkmind"}getIcon(){return"brain-circuit"}async setState(t,e){await super.setState(t,e),this.file=t.file?this.app.vault.getAbstractFileByPath(t.file):null,this.pendingFocus={node:t.node,heading:t.heading},await this.loadFile()}getState(){var t,e,i;return{file:(e=(t=this.file)==null?void 0:t.path)!=null?e:"",node:(i=this.selectedId)!=null?i:void 0}}async onOpen(){this.contentEl.empty(),this.contentEl.addClass("linkmind-view"),this.contentEl.setAttr("tabindex","0"),this.contentEl.toggleClass("is-animation-disabled",!this.plugin.settings.animations);let t=this.contentEl.createDiv({cls:"linkmind-toolbar"});this.addIconButton(t,"file-text",this.plugin.t("markdown"),()=>void this.openMarkdown()),this.addIconButton(t,"plus",this.plugin.t("addChildShort"),()=>this.addChildNode()),this.addIconButton(t,"corner-down-right",this.plugin.t("addSiblingShort"),()=>this.addSiblingNode()),this.addIconButton(t,"copy-plus",this.plugin.t("duplicateShort"),()=>this.duplicateSelectedNode()),this.addIconButton(t,"smile",this.plugin.t("setEmojiIcon"),()=>this.openEmojiPicker()),this.addIconButton(t,"tag",this.plugin.t("addTagShort"),()=>this.openTagModal()),this.addIconButton(t,"filter",this.plugin.t("filterByTag"),()=>this.openTagFilterModal()),this.addIconButton(t,"trash-2",this.plugin.t("deleteShort"),()=>this.deleteSelectedNode()),this.addIconButton(t,"unfold-vertical",this.plugin.t("expandAll"),()=>this.expandAllNodes()),this.addIconButton(t,"fold-vertical",this.plugin.t("collapseAll"),()=>this.collapseAllNodes()),this.addIconButton(t,"minimize",this.plugin.t("fitShort"),()=>this.fitToView()),this.addIconButton(t,"download",this.plugin.t("exportSvgShort"),()=>void this.exportSvg()),this.addIconButton(t,"image",this.plugin.t("exportPngShort"),()=>void this.exportPng()),this.addIconButton(t,"link",this.plugin.t("copyLinkShort"),()=>void this.copySelectedNodeLink()),this.addIconButton(t,"copy",this.plugin.t("copyBranch"),()=>void this.copySelectedBranchMarkdown()),this.addIconButton(t,"list-tree",this.plugin.t("toggleOutline"),()=>this.toggleOutline()),this.addIconButton(t,"palette",this.plugin.t("nodeStyleShort"),()=>this.openStylePanel()),this.addIconButton(t,"search",this.plugin.t("searchNodes"),()=>this.searchInputEl.focus());let e=t.createDiv({cls:"linkmind-search"});this.searchInputEl=e.createEl("input",{cls:"linkmind-search-input",attr:{type:"search",placeholder:this.plugin.t("searchNodes"),"aria-label":this.plugin.t("searchNodes")}}),this.searchCountEl=e.createEl("span",{cls:"linkmind-search-count"}),this.searchInputEl.addEventListener("input",()=>this.updateSearch(this.searchInputEl.value)),this.searchInputEl.addEventListener("keydown",n=>this.onSearchKeyDown(n)),this.canvasEl=this.contentEl.createDiv({cls:"linkmind-canvas"}),this.canvasEl.setAttr("tabindex","0"),this.canvasEl.setAttr("aria-label","linkmind canvas"),this.sceneEl=this.canvasEl.createDiv({cls:"linkmind-scene"}),this.svgEl=J("svg"),this.svgEl.addClass("linkmind-links"),this.sceneEl.appendChild(this.svgEl),this.nodesEl=this.sceneEl.createDiv({cls:"linkmind-nodes"}),this.outlineEl=this.canvasEl.createDiv({cls:"linkmind-outline"});let i=this.outlineEl.createDiv({cls:"linkmind-outline-header"});i.createSpan({text:this.plugin.t("outline")}),this.addIconButton(i,"x",this.plugin.t("hideOutline"),()=>this.toggleOutline(!1)),this.outlineListEl=this.outlineEl.createDiv({cls:"linkmind-outline-list"}),this.statusEl=this.canvasEl.createDiv({cls:"linkmind-status"}),this.registerDomEvent(this.canvasEl,"wheel",n=>this.onWheel(n)),this.registerDomEvent(this.canvasEl,"pointerdown",n=>this.onPointerDown(n)),this.registerDomEvent(window,"pointermove",n=>this.onPointerMove(n)),this.registerDomEvent(window,"pointerup",n=>this.onPointerUp(n)),this.registerDomEvent(this.canvasEl,"keydown",n=>this.onKeyDown(n)),this.registerEvent(this.app.vault.on("modify",async n=>{if(!(!this.file||n.path!==this.file.path||this.isSaving)){if(this.hasLocalUnsavedChange){this.showConflictModal();return}this.loadFile()}})),await this.loadFile(),window.setTimeout(()=>this.focusCanvas(),0)}async openMarkdown(){this.file&&(this.plugin.skipAutoSwitchUntil=Date.now()+Pt,await this.leaf.setViewState({type:"markdown",state:{file:this.file.path},active:!0}))}applySettings(){this.contentEl.toggleClass("is-animation-disabled",!this.plugin.settings.animations),this.render()}addIconButton(t,e,i,n){let r=t.createEl("button",{cls:"clickable-icon linkmind-tool-button",attr:{"aria-label":i,title:i}});(0,h.setIcon)(r,e),r.onClickEvent(n)}addStyleControl(t,e,i,n,r,a,d){let l=t.createDiv({cls:"linkmind-style-ctrl"});l.createSpan({text:e,cls:"linkmind-style-label"});let p=l.createEl("input",{cls:"linkmind-style-input",attr:{type:n,value:i,...a!==void 0?{min:String(a)}:{},...d!==void 0?{max:String(d)}:{}}});p.addEventListener("change",()=>r(p.value))}openStylePanel(){new et(this.app,this.plugin,async()=>{await this.plugin.saveSettings(),this.render()}).open()}async loadFile(){if(!this.file||!(this.file instanceof h.TFile)){this.renderEmpty(this.plugin.t("emptyView"));return}let t=await this.app.vault.read(this.file),e=R(t,this.file.basename);this.root=e.root,this.documentPrefix=e.prefix,kt(this.root,this.plugin.settings.defaultExpandDepth),this.lastSavedMarkdown=t,this.hasLocalUnsavedChange=!1,this.history=[],this.future=[],this.selectedId=this.selectedId&&M(this.root,this.selectedId)?this.selectedId:this.root.id,this.selectedIds=new Set([this.selectedId]),this.render(),this.applyPendingFocus()}renderEmpty(t){var e,i;this.root=null,(e=this.nodesEl)==null||e.empty(),(i=this.svgEl)==null||i.empty(),this.contentEl.createDiv({cls:"linkmind-empty",text:t})}render(){if(!this.root)return;let t=this.tagFilter?wt(this.root,this.tagFilter):this.root;if(this.positions=t?pt(t,this.plugin.settings.branchColors,this.plugin.settings.layoutDirection):[],this.refreshSearchMatches(),this.nodesEl.empty(),this.svgEl.empty(),this.dragMarkerEl=null,this.positions.length===0){this.renderOutline(),this.applyTransform();return}let e=at(this.positions),i=80,n=Math.max(1,e.width+i*2),r=Math.max(1,e.height+i*2),a=e.minX-i,d=e.minY-i;this.svgEl.style.left=`${a}px`,this.svgEl.style.top=`${d}px`,this.svgEl.setAttrs({width:`${n}`,height:`${r}`,viewBox:`${a} ${d} ${n} ${r}`});for(let l of this.positions)this.renderNode(l);for(let l of this.positions){let p=this.nodesEl.querySelector(`[data-node-id="${l.node.id}"]`);p&&(l.height=p.offsetHeight)}for(let l of this.positions)l.parent&&this.drawLink(l);this.plugin.settings.showAssociationLinks&&this.drawAssociationLinks(),this.renderOutline(),this.updateStatus(),this.applyTransform()}focusCanvas(){!this.canvasEl||this.searchInputEl===document.activeElement||this.canvasEl.focus({preventScroll:!0})}renderOutline(){if(!this.root||!this.outlineListEl)return;if(this.outlineEl.toggleClass("is-hidden",!this.outlineVisible),this.outlineListEl.empty(),this.tagFilter){let e=this.outlineListEl.createDiv({cls:"linkmind-outline-filter"});e.createSpan({text:`${this.plugin.t("tagFilterActive")}: #${this.tagFilter}`}),e.createEl("button",{text:"x"}).onClickEvent(()=>this.clearTagFilter())}let t=(e,i)=>{if(this.tagFilter&&!yt(e,this.tagFilter))return;let n=this.outlineListEl.createDiv({cls:"linkmind-outline-row"});n.toggleClass("is-selected",this.selectedIds.has(e.id)),n.style.paddingLeft=`${8+i*14}px`;let r=E(e.text);if(r.emoji&&n.createSpan({cls:"linkmind-outline-emoji",text:r.emoji}),n.createSpan({cls:"linkmind-outline-label",text:W(r.displayLabel)}),e.collapsed&&e.children.length>0&&n.createSpan({cls:"linkmind-outline-count",text:`${e.children.length}`}),n.onClickEvent(a=>{a.stopPropagation(),this.selectAndFocusNode(e.id)}),!e.collapsed)for(let a of e.children)t(a,i+1)};t(this.root,0)}renderNode(t){let e=this.nodesEl.createDiv({cls:"linkmind-node"});e.toggleClass("is-root",t.depth===0),e.toggleClass("is-selected",this.selectedIds.has(t.node.id)),e.toggleClass("is-primary-selected",t.node.id===this.selectedId),e.toggleClass("is-search-match",this.searchMatches.includes(t.node.id)),e.toggleClass("is-active-search-match",this.activeSearchIndex>=0&&this.searchMatches[this.activeSearchIndex]===t.node.id),e.toggleClass("is-collapsed",t.node.collapsed),e.toggleClass("is-borderless",this.plugin.settings.hideNodeBorders),e.setAttr("data-node-id",t.node.id),e.setAttr("data-node-anchor",T(t.node.text)),e.setAttr("tabindex","0"),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.borderColor=t.color,e.style.borderWidth=`${this.plugin.settings.nodeBorderWidth}px`,e.style.borderRadius=`${this.plugin.settings.nodeBorderRadius}px`;let i=this.plugin.settings.nodeBgColor;e.style.background=i&&i!=="transparent"?i:"transparent";let n=E(t.node.text);n.emoji&&(e.createDiv({cls:"linkmind-node-emoji",text:n.emoji}),e.addClass("has-emoji"));let r=e.createDiv({cls:"linkmind-node-content"});if(Vt(r,n.displayLabel,this.app),n.tags.length>0){let a=e.createDiv({cls:"linkmind-node-tags"});for(let d of n.tags){let l=a.createSpan({cls:"linkmind-node-tag",text:`#${d}`});l.toggleClass("is-active",this.tagFilter===d),l.onClickEvent(p=>{p.stopPropagation(),this.setTagFilter(d)})}}if(t.node.children.length>0){let a=e.createDiv({cls:"linkmind-collapse"});(0,h.setIcon)(a,t.node.collapsed?"chevron-right":"chevron-down"),a.onClickEvent(d=>{d.stopPropagation(),this.toggleCollapse(t.node.id)})}e.onClickEvent(a=>this.handleNodeClick(a,t.node.id)),e.addEventListener("pointerdown",a=>this.onNodePointerDown(a,t)),e.addEventListener("pointermove",()=>this.clearLongPressTimer()),e.addEventListener("pointerleave",()=>this.clearLongPressTimer()),e.addEventListener("contextmenu",a=>this.openNodeMenu(a,t.node.id))}openNodeMenu(t,e){t.preventDefault(),t.stopPropagation(),this.selectedIds.has(e)||(this.selectedId=e,this.selectedIds=new Set([e]),this.render());let i=new h.Menu;i.addItem(n=>n.setTitle(this.plugin.t("addChild")).setIcon("plus").onClick(()=>this.addChildNode())),i.addItem(n=>n.setTitle(this.plugin.t("addSibling")).setIcon("corner-down-right").onClick(()=>this.addSiblingNode())),i.addItem(n=>n.setTitle(this.plugin.t("editNode")).setIcon("pencil").onClick(()=>this.editSelectedNode())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("duplicateNode")).setIcon("copy-plus").onClick(()=>this.duplicateSelectedNode())),i.addItem(n=>n.setTitle(this.plugin.t("copyBranch")).setIcon("copy").onClick(()=>void this.copySelectedBranchMarkdown())),i.addItem(n=>n.setTitle(this.plugin.t("copyNodeLink")).setIcon("link").onClick(()=>void this.copySelectedNodeLink())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("setEmoji")).setIcon("smile").onClick(()=>this.openEmojiPicker())),i.addItem(n=>n.setTitle(this.plugin.t("addTag")).setIcon("tag").onClick(()=>this.openTagModal())),i.addItem(n=>n.setTitle(this.plugin.t("clearTags")).setIcon("tag").onClick(()=>this.clearSelectedTags())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("exportSelectedSvg")).setIcon("download").onClick(()=>void this.exportSelectedSvg())),i.addItem(n=>n.setTitle(this.plugin.t("exportSelectedPng")).setIcon("image").onClick(()=>void this.exportSelectedPng())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("deleteNode")).setIcon("trash-2").onClick(()=>this.deleteSelectedNode())),i.showAtMouseEvent(t)}openNodeMenuAt(t,e,i){let n=new MouseEvent("contextmenu",{clientX:e,clientY:i,bubbles:!0,cancelable:!0});this.openNodeMenu(n,t)}drawLink(t){if(this.plugin.settings.nodeBorderWidth===0)return;let e=t.parent?this.positions.find(u=>{var f;return u.node.id===((f=t.parent)==null?void 0:f.id)}):null;if(!e)return;let i=J("path"),n=t.x>=e.x,r=n?1:-1,a=n?e.x+e.width:e.x,d=e.y+e.height/2,l=n?t.x:t.x+t.width,p=t.y+t.height/2,m=Math.abs(l-a),v=Math.max(20,m*.35)*r;i.setAttrs({d:`M ${a} ${d} C ${a+v} ${d}, ${l-v} ${p}, ${l} ${p}`,stroke:t.color,fill:"none","stroke-linecap":"round","stroke-width":`${this.plugin.settings.nodeBorderWidth}px`}),this.svgEl.appendChild(i)}drawAssociationLinks(){let t=new Map;for(let i of this.positions)t.set(T(i.node.text),i);let e=new Set;for(let i of this.positions){let n=mt(i.node.text,this.file);for(let r of n){let a=t.get(r);if(!a||a.node.id===i.node.id)continue;let d=[i.node.id,a.node.id].sort().join(":");e.has(d)||(e.add(d),this.drawAssociationLink(i,a))}}}drawAssociationLink(t,e){let i=J("path");i.addClass("linkmind-association-link");let n=t.x+t.width/2,r=t.y+t.height/2,a=e.x+e.width/2,d=e.y+e.height/2,l=(n+a)/2,p=Math.max(80,Math.abs(d-r)*.35),m=Math.min(r,d)-p;i.setAttrs({d:`M ${n} ${r} Q ${l} ${m}, ${a} ${d}`,fill:"none"}),this.svgEl.appendChild(i)}selectNode(t){this.selectedId=t,this.selectedIds=new Set([t]),this.render(),this.focusCanvas()}selectAndFocusNode(t){this.selectedId=t,this.selectedIds=new Set([t]),this.expandAncestors(t),this.render(),this.focusSelected(),this.focusCanvas()}applyPendingFocus(){if(!this.root||!this.pendingFocus)return;let t=this.resolveFocusTarget(this.pendingFocus);this.pendingFocus=null,t&&window.setTimeout(()=>this.selectAndFocusNode(t.id),0)}resolveFocusTarget(t){if(!this.root)return null;if(t.node){let e=M(this.root,t.node);if(e)return e;let i=rt(this.root,t.node);if(i)return i}return t.heading?rt(this.root,t.heading):null}handleNodeClick(t,e){if(this.focusCanvas(),t.metaKey||t.ctrlKey){this.toggleNodeSelection(e);return}if(t.shiftKey&&this.selectedId){this.selectRange(this.selectedId,e);return}this.selectedId=e,this.selectedIds=new Set([e]),this.editNode(e)}toggleNodeSelection(t){var e;this.selectedIds.has(t)&&this.selectedIds.size>1?(this.selectedIds.delete(t),this.selectedId===t&&(this.selectedId=(e=this.selectedIds.values().next().value)!=null?e:null)):(this.selectedIds.add(t),this.selectedId=t),this.render()}selectRange(t,e){let i=this.positions.map(l=>l.node.id),n=i.indexOf(t),r=i.indexOf(e);if(n===-1||r===-1){this.selectNode(e);return}let[a,d]=nthis.setSelectedEmoji(t)).open()}clearSelectedEmoji(){this.setSelectedEmoji(null)}openTagModal(){!this.root||this.selectedIds.size===0||new it(this.app,this.plugin.t("enterTag"),t=>this.addTagToSelected(t)).open()}openTagFilterModal(){this.root&&new nt(this.app,this.getAllTags(),this.plugin.t("filterByTag"),t=>this.setTagFilter(t)).open()}clearTagFilter(){this.tagFilter=null,this.render()}setTagFilter(t){let e=ot(t);if(!e)return;this.tagFilter=e,this.render();let i=this.positions.find(n=>E(n.node.text).tags.includes(e));i&&this.selectAndFocusNode(i.node.id)}getAllTags(){return this.root?[...new Set(Y(this.root).flatMap(t=>E(t.text).tags))].sort():[]}clearSelectedTags(){if(!this.root)return;let t=this.getSelectedNodes();if(t.length!==0){this.pushHistory();for(let e of t)e.text=Rt(e.text);this.scheduleSave(),this.render()}}addTagToSelected(t){if(!this.root)return;let e=ot(t);if(!e)return;let i=this.getSelectedNodes();if(i.length!==0){this.pushHistory();for(let n of i)n.text=Ht(n.text,e);this.scheduleSave(),this.render()}}setSelectedEmoji(t){if(!this.root)return;let e=this.getSelectedNodes();if(e.length!==0){this.pushHistory();for(let i of e){let n=gt(i.text);i.text=t?`${t} ${n.label}`:n.label}this.scheduleSave(),this.render()}}editNode(t){if(!this.root)return;let e=M(this.root,t),i=this.nodesEl.querySelector(`[data-node-id="${t}"]`);if(!e||!i)return;this.selectedId=t,i.empty(),i.addClass("is-editing");let n=i.createEl("textarea",{cls:"linkmind-editor"});n.value=e.text,n.focus(),n.select();let r=!1,a=()=>{if(r)return;r=!0;let d=n.value.trim()||"Untitled";this.pushHistory(),e.text=d,this.scheduleSave(),this.render(),this.focusCanvas()};n.addEventListener("keydown",d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),a()),d.key==="Escape"&&(d.preventDefault(),this.render())}),n.addEventListener("blur",a,{once:!0})}addChildNode(){var i,n;if(!this.root)return;let t=(n=M(this.root,(i=this.selectedId)!=null?i:this.root.id))!=null?n:this.root;this.pushHistory();let e=C("New idea",G(t,L(this.root,t.id)));t.children.push(e),t.collapsed=!1,this.selectedId=e.id,this.scheduleSave(),this.render(),window.setTimeout(()=>this.editNode(e.id),20)}addSiblingNode(){if(!this.root||!this.selectedId||this.selectedId===this.root.id){this.addChildNode();return}let t=b(this.root,this.selectedId),e=M(this.root,this.selectedId);if(!t||!e)return;this.pushHistory();let i=t.children.findIndex(r=>r.id===e.id),n=C("New idea",e.kind);t.children.splice(i+1,0,n),this.selectedId=n.id,this.scheduleSave(),this.render(),window.setTimeout(()=>this.editNode(n.id),20)}duplicateSelectedNode(){if(!this.root||!this.selectedId||this.selectedId===this.root.id)return;let t=b(this.root,this.selectedId),e=M(this.root,this.selectedId);if(!t||!e)return;this.pushHistory();let i=t.children.findIndex(r=>r.id===e.id),n=vt(e);t.children.splice(i+1,0,n),this.selectedId=n.id,this.selectedIds=new Set([n.id]),this.scheduleSave(),this.render(),this.focusSelected()}moveSelectedNode(t){if(!this.root||!this.selectedId||this.selectedId===this.root.id)return;if(this.pushHistory(),!zt(this.root,this.selectedId,t)){this.history.pop();return}this.scheduleSave(),this.render(),this.focusSelected()}deleteSelectedNode(){var i;if(!this.root)return;let t=this.getEditableSelectedIds();if(t.length===0)return;this.pushHistory();let e=this.selectedId?b(this.root,this.selectedId):null;St(this.root,new Set(t)),this.selectedId=(i=e==null?void 0:e.id)!=null?i:this.root.id,this.selectedIds=new Set([this.selectedId]),this.scheduleSave(),this.render()}toggleCollapse(t){if(!this.root)return;let e=M(this.root,t);e&&(e.collapsed=!e.collapsed,this.render())}toggleSelectedNode(){if(!this.root)return;let t=this.getSelectedNodes();if(t.length===0)return;let e=t.some(i=>!i.collapsed&&i.children.length>0);for(let i of t)i.children.length>0&&(i.collapsed=e);this.render()}expandAllNodes(){this.root&&(K(this.root,!1),this.render())}collapseAllNodes(){this.root&&(K(this.root,!0),this.root.collapsed=!1,this.selectedId=this.root.id,this.render(),this.focusSelected())}scheduleSave(){!this.root||!this.file||(this.hasLocalUnsavedChange=!0,this.updateStatus(),this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>void this.saveNow(),this.plugin.settings.autoSaveDelay))}showConflictModal(){this.conflictModalOpen||(this.conflictModalOpen=!0,new st(this.app,{title:this.plugin.t("conflictTitle"),body:this.plugin.t("conflictBody"),reload:this.plugin.t("reloadMarkdown"),keep:this.plugin.t("keepEdits")},async()=>{this.conflictModalOpen=!1,await this.loadFile(),new h.Notice(this.plugin.t("reloadedExternal"))},async()=>{this.conflictModalOpen=!1,await this.saveNow(),new h.Notice(this.plugin.t("keptLocal"))},()=>{this.conflictModalOpen=!1}).open())}async saveNow(){if(!this.root||!this.file)return;let t=this.serializeCurrentMarkdown();this.isSaving=!0,this.updateStatus(),await this.app.vault.modify(this.file,t),this.lastSavedMarkdown=t,this.hasLocalUnsavedChange=!1,this.isSaving=!1,this.updateStatus()}pushHistory(){this.root&&(this.history.push(this.serializeCurrentMarkdown()),this.history.length>80&&this.history.shift(),this.future=[])}undo(){var i,n;if(!this.root||this.history.length===0)return;this.future.push(this.serializeCurrentMarkdown());let t=this.history.pop();if(!t)return;let e=R(t,(n=(i=this.file)==null?void 0:i.basename)!=null?n:"Mind map");this.root=e.root,this.documentPrefix=e.prefix,this.selectedId=this.root.id,this.selectedIds=new Set([this.root.id]),this.render(),this.saveNow()}redo(){var i,n;if(!this.root)return;let t=this.future.pop();if(!t)return;this.history.push(this.serializeCurrentMarkdown());let e=R(t,(n=(i=this.file)==null?void 0:i.basename)!=null?n:"Mind map");this.root=e.root,this.documentPrefix=e.prefix,this.selectedId=this.root.id,this.selectedIds=new Set([this.root.id]),this.render(),this.saveNow()}onKeyDown(t){if(t.target instanceof HTMLTextAreaElement)return;let e=t.ctrlKey||t.metaKey;if(e&&t.key.toLowerCase()==="z"&&t.shiftKey){t.preventDefault(),this.redo();return}if(e&&t.key.toLowerCase()==="z"){t.preventDefault(),this.undo();return}if(e&&t.key.toLowerCase()==="a"){t.preventDefault(),this.selectAllNodes();return}if(e&&t.key==="="){t.preventDefault(),this.zoomAtCenter(1.1);return}if(e&&t.key==="-"){t.preventDefault(),this.zoomAtCenter(.9);return}if(e&&t.shiftKey&&t.key.toLowerCase()==="f"){t.preventDefault(),this.fitToView();return}if(e&&t.key.toLowerCase()==="f"){t.preventDefault(),this.focusSelected();return}if(t.altKey&&t.key==="ArrowUp"){t.preventDefault(),this.moveSelectedNode("up");return}if(t.altKey&&t.key==="ArrowDown"){t.preventDefault(),this.moveSelectedNode("down");return}if(t.altKey&&t.key==="ArrowRight"){t.preventDefault(),this.moveSelectedNode("indent");return}if(t.altKey&&t.key==="ArrowLeft"){t.preventDefault(),this.moveSelectedNode("outdent");return}t.key==="Tab"?(t.preventDefault(),this.addChildNode()):t.key==="/"?(t.preventDefault(),this.focusSearch()):t.key==="Enter"?(t.preventDefault(),this.addSiblingNode()):t.key==="F2"?(t.preventDefault(),this.selectedId&&this.editNode(this.selectedId)):t.key==="Delete"||t.key==="Backspace"?(t.preventDefault(),this.deleteSelectedNode()):t.key===" "?(t.preventDefault(),this.selectedId&&this.toggleCollapse(this.selectedId)):t.key.startsWith("Arrow")&&(t.preventDefault(),this.moveSelection(t.key))}onSearchKeyDown(t){t.key==="Enter"?(t.preventDefault(),this.jumpSearch(t.shiftKey?-1:1)):t.key==="Escape"?(t.preventDefault(),this.searchInputEl.value="",this.updateSearch(""),this.contentEl.focus()):(t.key==="ArrowDown"||t.key==="ArrowUp")&&(t.preventDefault(),this.jumpSearch(t.key==="ArrowDown"?1:-1))}focusSearch(){this.searchInputEl.focus(),this.searchInputEl.select()}toggleOutline(t){this.outlineVisible=t!=null?t:!this.outlineVisible,this.renderOutline()}selectAllNodes(){this.root&&(this.selectedIds=new Set(Y(this.root).map(t=>t.id)),this.selectedId=this.root.id,this.render())}async exportSvg(){!this.root||!this.file||this.positions.length===0||await this.exportSvgFromPositions(this.positions,this.file.basename,this.getExportPath("svg"))}async exportPng(){!this.root||!this.file||this.positions.length===0||await this.exportPngFromPositions(this.positions,this.file.basename,this.getExportPath("png"))}async exportSelectedSvg(){let t=this.getSelectedBranchExport();t&&await this.exportSvgFromPositions(t.positions,t.title,this.getExportPath("svg",t.slug))}async exportSelectedPng(){let t=this.getSelectedBranchExport();t&&await this.exportPngFromPositions(t.positions,t.title,this.getExportPath("png",t.slug))}async exportSvgFromPositions(t,e,i){let n=ct(t,e,this.plugin.settings.showAssociationLinks,this.plugin.settings.hideNodeBorders,this.plugin.settings.nodeBorderRadius,this.plugin.settings.nodeBorderWidth,this.plugin.settings.nodeBgColor);await this.writeTextFile(i,n),new h.Notice(`${this.plugin.t("exported")} ${i}`)}async exportPngFromPositions(t,e,i){let n=ct(t,e,this.plugin.settings.showAssociationLinks,this.plugin.settings.hideNodeBorders,this.plugin.settings.nodeBorderRadius,this.plugin.settings.nodeBorderWidth,this.plugin.settings.nodeBgColor),r=await Ot(n,this.plugin.settings.exportScale,this.plugin.settings.exportTransparentBackground),a=this.app.vault.getAbstractFileByPath(i);a instanceof h.TFile?await this.app.vault.modifyBinary(a,r):await this.app.vault.createBinary(i,r),new h.Notice(`${this.plugin.t("exported")} ${i}`)}getSelectedBranchExport(){if(!this.root||!this.selectedId)return null;let t=M(this.root,this.selectedId);if(!t)return null;let e=X(t);K(e,!1);let i=pt(e,this.plugin.settings.branchColors,this.plugin.settings.layoutDirection),n=ft(t.text);return{positions:i,title:n,slug:T(t.text)||"branch"}}async copySelectedNodeLink(){if(!this.file||!this.root||!this.selectedId)return;let t=M(this.root,this.selectedId);if(!t)return;let e=this.app.vault.getName(),i=this.file.path,n=T(t.text),r=`obsidian://open?vault=${encodeURIComponent(e)}&file=${encodeURIComponent(i)}#${encodeURIComponent(n)}`;await navigator.clipboard.writeText(r),new h.Notice(this.plugin.t("copiedLink"))}async copySelectedBranchMarkdown(){if(!this.root||!this.selectedId)return;let t=M(this.root,this.selectedId);t&&(await navigator.clipboard.writeText(lt(X(t))),new h.Notice(this.plugin.t("copiedBranch")))}async pasteMarkdownAsChild(){var i,n;if(!this.root)return;let t=(n=M(this.root,(i=this.selectedId)!=null?i:this.root.id))!=null?n:this.root,e=await this.readClipboardNodes(t.kind,L(this.root,t.id)+1);e.length!==0&&(this.pushHistory(),t.children.push(...e),t.collapsed=!1,this.selectedId=e[0].id,this.selectedIds=new Set([e[0].id]),this.scheduleSave(),this.render(),new h.Notice(this.plugin.t("pastedMarkdown")))}async pasteMarkdownAsSibling(){if(!this.root||!this.selectedId||this.selectedId===this.root.id){await this.pasteMarkdownAsChild();return}let t=M(this.root,this.selectedId),e=b(this.root,this.selectedId);if(!t||!e)return;let i=await this.readClipboardNodes(t.kind,L(this.root,t.id));if(i.length===0)return;this.pushHistory();let n=e.children.findIndex(r=>r.id===t.id);e.children.splice(n+1,0,...i),this.selectedId=i[0].id,this.selectedIds=new Set([i[0].id]),this.scheduleSave(),this.render(),new h.Notice(this.plugin.t("pastedMarkdown"))}async readClipboardNodes(t,e){let i=await navigator.clipboard.readText();if(!i.trim())return new h.Notice(this.plugin.t("clipboardEmpty")),[];let n=R(i,"Clipboard"),a=(n.root.text==="Clipboard"&&n.root.children.length>0?n.root.children:[n.root]).map(d=>X(d));for(let d of a)Mt(d,t,e);return a.length===0&&new h.Notice(this.plugin.t("clipboardEmpty")),a}updateSearch(t){if(this.searchQuery=t.trim().toLowerCase(),this.refreshSearchMatches(),this.activeSearchIndex=this.searchMatches.length>0?0:-1,this.activeSearchIndex>=0){let e=this.searchMatches[this.activeSearchIndex];e&&this.selectAndFocusNode(e)}else this.render();this.updateSearchCount()}refreshSearchMatches(){if(!this.root||this.searchQuery.length===0){this.searchMatches=[],this.activeSearchIndex=-1,this.updateSearchCount();return}this.searchMatches=Y(this.root).filter(t=>t.text.toLowerCase().includes(this.searchQuery)).map(t=>t.id),this.activeSearchIndex>=this.searchMatches.length&&(this.activeSearchIndex=this.searchMatches.length-1),this.searchMatches.length===0&&(this.activeSearchIndex=-1),this.updateSearchCount()}updateSearchCount(){if(!this.searchCountEl)return;if(this.searchQuery.length===0){this.searchCountEl.setText("");return}let t=this.activeSearchIndex>=0?this.activeSearchIndex+1:0;this.searchCountEl.setText(`${t}/${this.searchMatches.length}`)}jumpSearch(t){if(this.searchMatches.length===0)return;this.activeSearchIndex=(this.activeSearchIndex+t+this.searchMatches.length)%this.searchMatches.length;let e=this.searchMatches[this.activeSearchIndex];e&&this.selectAndFocusNode(e),this.updateSearchCount()}moveSelection(t){if(!this.root||!this.selectedId)return;let e=M(this.root,this.selectedId);if(!e)return;if(t==="ArrowRight"){if(e.collapsed&&e.children.length>0){this.toggleCollapse(e.id);return}let a=e.children[0];a&&this.selectAndFocusNode(a.id);return}if(t==="ArrowLeft"){let a=b(this.root,e.id);e.children.length>0&&!e.collapsed?this.toggleCollapse(e.id):a&&this.selectAndFocusNode(a.id);return}let i=this.positions.slice().sort((a,d)=>a.y-d.y||a.x-d.x),n=i.findIndex(a=>a.node.id===e.id),r=i[n+(t==="ArrowDown"?1:-1)];r&&this.selectAndFocusNode(r.node.id)}expandAncestors(t){if(!this.root)return;let e=xt(this.root,t);for(let i of e.slice(0,-1))i.collapsed=!1}getSelectedNodes(){return this.root?[...this.selectedIds].map(t=>M(this.root,t)).filter(t=>!!t):[]}getEditableSelectedNodes(){return this.root?this.getSelectedNodes().filter(t=>{var e;return t.id!==((e=this.root)==null?void 0:e.id)}):[]}getEditableSelectedIds(){return this.getEditableSelectedNodes().map(t=>t.id)}onWheel(t){t.preventDefault();let e=t.deltaY>0?.92:1.08;this.scale=$(this.scale*e,.35,2.2),this.applyTransform()}onPointerDown(t){let e=t.target;e.closest(".linkmind-node")||e.closest(".linkmind-toolbar")||e.closest(".linkmind-outline")||(this.focusCanvas(),this.panning={x:t.clientX,y:t.clientY,panX:this.panX,panY:this.panY},this.canvasEl.setPointerCapture(t.pointerId))}onPointerMove(t){if(this.dragState){this.onNodePointerMove(t);return}this.panning&&(this.panX=this.panning.panX+t.clientX-this.panning.x,this.panY=this.panning.panY+t.clientY-this.panning.y,this.applyTransform())}onPointerUp(t){if(this.dragState){this.finishNodeDrag(t);return}try{this.canvasEl.releasePointerCapture(t.pointerId)}catch(e){}this.stopPanning()}stopPanning(){this.panning=null}onNodePointerDown(t,e){var r;if(t.button!==0||t.target instanceof HTMLTextAreaElement)return;let i=t.target;if(i.closest(".linkmind-collapse")||i.closest(".linkmind-wikilink"))return;if(t.stopPropagation(),this.selectedId=e.node.id,this.selectedIds=new Set([e.node.id]),this.nodesEl.querySelectorAll(".is-selected").forEach(a=>a.removeClass("is-selected")),t.currentTarget.addClass("is-selected"),e.node.id===((r=this.root)==null?void 0:r.id)){this.focusCanvas(),this.panning={x:t.clientX,y:t.clientY,panX:this.panX,panY:this.panY},t.currentTarget.setPointerCapture(t.pointerId);return}let n=this.toScenePoint(t.clientX,t.clientY);this.dragState={nodeId:e.node.id,pointerId:t.pointerId,startClientX:t.clientX,startClientY:t.clientY,offsetX:n.x-e.x,offsetY:n.y-e.y,originalX:e.x,originalY:e.y,dragging:!1,el:t.currentTarget},this.dragState.el.setPointerCapture(t.pointerId),(t.pointerType==="touch"||t.pointerType==="pen")&&(this.longPressTimer=window.setTimeout(()=>{this.dragState=null,this.openNodeMenuAt(e.node.id,t.clientX,t.clientY)},560))}onNodePointerMove(t){if(!this.dragState)return;this.clearLongPressTimer();let e=t.clientX-this.dragState.startClientX,i=t.clientY-this.dragState.startClientY;if(!this.dragState.dragging&&Math.hypot(e,i)!n.has(u.node.id)),a=r.find(u=>t>=u.x&&t<=u.x+u.width&&e>=u.y&&e<=u.y+u.height);if(a)return{mode:"child",parentId:a.node.id,index:a.node.children.length,targetId:a.node.id};let d=null,l=Number.POSITIVE_INFINITY;for(let u of r){if(u.node.id===this.root.id)continue;let f=Math.hypot(t-(u.x+u.width/2),e-(u.y+u.height/2));fu.id===d.node.id),v=e{var a;return r.node.id===((a=this.dropTarget)==null?void 0:a.targetId)});if(!t)return;this.dragMarkerEl=this.nodesEl.createDiv({cls:"linkmind-drop-marker"});let e=this.dropTarget.index<=((n=(i=b(this.root,this.dropTarget.targetId))==null?void 0:i.children.findIndex(r=>{var a;return r.id===((a=this.dropTarget)==null?void 0:a.targetId)}))!=null?n:0);this.dragMarkerEl.style.left=`${t.x-10}px`,this.dragMarkerEl.style.top=`${e?t.y-P/2:t.y+t.height+P/2}px`,this.dragMarkerEl.style.width=`${t.width+20}px`}clearDropTarget(){var t;this.nodesEl.querySelectorAll(".is-drop-child").forEach(e=>e.removeClass("is-drop-child")),(t=this.dragMarkerEl)==null||t.remove(),this.dragMarkerEl=null}clearLongPressTimer(){this.longPressTimer&&(window.clearTimeout(this.longPressTimer),this.longPressTimer=null)}toScenePoint(t,e){let i=this.canvasEl.getBoundingClientRect();return{x:(t-i.left-this.panX)/this.scale,y:(e-i.top-this.panY)/this.scale}}serializeCurrentMarkdown(){return this.root?`${this.documentPrefix}${lt(this.root)}`:this.documentPrefix}getExportPath(t,e){var r,a,d,l;let i=(a=(r=this.file)==null?void 0:r.parent)!=null&&a.path&&this.file.parent.path!=="/"?`${this.file.parent.path}/`:"",n=e?`.${e}`:"";return`${i}${(l=(d=this.file)==null?void 0:d.basename)!=null?l:"mind-map"}.linkmind${n}.${t}`}async writeTextFile(t,e){let i=this.app.vault.getAbstractFileByPath(t);i instanceof h.TFile?await this.app.vault.modify(i,e):await this.app.vault.create(t,e)}zoomAtCenter(t){this.scale=$(this.scale*t,.35,2.2),this.applyTransform()}focusSelected(){let t=this.positions.find(i=>i.node.id===this.selectedId);if(!t)return;let e=this.canvasEl.getBoundingClientRect();this.panX=e.width/2-(t.x+t.width/2)*this.scale,this.panY=e.height/2-(t.y+x/2)*this.scale,this.applyTransform()}fitToView(){if(this.positions.length===0)return;let t=at(this.positions),e=this.canvasEl.getBoundingClientRect(),i=(e.width-120)/Math.max(t.width,1),n=(e.height-120)/Math.max(t.height,1);this.scale=$(Math.min(i,n),.35,1.4),this.panX=e.width/2-(t.minX+t.width/2)*this.scale,this.panY=e.height/2-(t.minY+t.height/2)*this.scale,this.applyTransform()}applyTransform(){this.sceneEl&&(this.sceneEl.style.transform=`translate(${this.panX}px, ${this.panY}px) scale(${this.scale})`,this.updateStatus())}updateStatus(){if(!this.statusEl)return;let t=this.root?Y(this.root).length:0,e=this.positions.length,i=this.isSaving?this.plugin.t("saving"):this.hasLocalUnsavedChange?this.plugin.t("unsaved"):this.plugin.t("saved"),n=this.tagFilter?`#${this.tagFilter}`:"";this.statusEl.setText([`${e}/${t} ${this.plugin.t("nodesLabel")}`,`${this.selectedIds.size} ${this.plugin.t("selectedLabel")}`,`${this.plugin.t("zoomLabel")} ${Math.round(this.scale*100)}%`,n,i].filter(Boolean).join(" \xB7 "))}},Z=class extends h.PluginSettingTab{constructor(s,t){super(s,t),this.plugin=t}display(){let{containerEl:s}=this;s.empty(),s.createEl("h2",{text:this.plugin.t("settingsTitle")}),new h.Setting(s).setName(this.plugin.t("language")).setDesc(this.plugin.t("languageDesc")).addDropdown(e=>{e.addOption("zh",this.plugin.t("chinese")).addOption("en",this.plugin.t("english")).setValue(this.plugin.settings.language).onChange(async i=>{this.plugin.settings.language=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews(),this.display()})}),new h.Setting(s).setName(this.plugin.t("autoSaveDelay")).setDesc(this.plugin.t("autoSaveDelayDesc")).addText(e=>{e.setPlaceholder("300").setValue(String(this.plugin.settings.autoSaveDelay)).onChange(async i=>{let n=Number.parseInt(i,10);this.plugin.settings.autoSaveDelay=Number.isFinite(n)?$(n,0,5e3):O.autoSaveDelay,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("defaultExpandDepth")).setDesc(this.plugin.t("defaultExpandDepthDesc")).addSlider(e=>{e.setLimits(1,99,1).setDynamicTooltip().setValue(this.plugin.settings.defaultExpandDepth).onChange(async i=>{this.plugin.settings.defaultExpandDepth=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("layoutDirection")).setDesc(this.plugin.t("layoutDirectionDesc")).addDropdown(e=>{e.addOption("right",this.plugin.t("horizontalRight")).addOption("balanced",this.plugin.t("balanced")).setValue(this.plugin.settings.layoutDirection).onChange(async i=>{this.plugin.settings.layoutDirection=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("layoutAnimation")).setDesc(this.plugin.t("layoutAnimationDesc")).addToggle(e=>{e.setValue(this.plugin.settings.animations).onChange(async i=>{this.plugin.settings.animations=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("showAssociationLinks")).setDesc(this.plugin.t("showAssociationLinksDesc")).addToggle(e=>{e.setValue(this.plugin.settings.showAssociationLinks).onChange(async i=>{this.plugin.settings.showAssociationLinks=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("hideNodeBorders")).setDesc(this.plugin.t("hideNodeBordersDesc")).addToggle(e=>{e.setValue(this.plugin.settings.hideNodeBorders).onChange(async i=>{this.plugin.settings.hideNodeBorders=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("nodeBorderRadius")).setDesc(this.plugin.t("nodeBorderRadiusDesc")).addSlider(e=>{e.setLimits(0,999,1).setDynamicTooltip().setValue(this.plugin.settings.nodeBorderRadius).onChange(async i=>{this.plugin.settings.nodeBorderRadius=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new h.Setting(s).setName(this.plugin.t("branchColors")).setDesc(this.plugin.t("branchColorsDesc")).addTextArea(e=>{e.setValue(this.plugin.settings.branchColors.join(", ")).onChange(async i=>{let n=i.split(",").map(r=>r.trim()).filter(Boolean);this.plugin.settings.branchColors=n.length>0?n:O.branchColors,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()}),e.inputEl.rows=2});let t=s.createDiv({cls:"linkmind-settings-palette"});this.plugin.settings.branchColors.forEach((e,i)=>{new h.Setting(t).setName(`${this.plugin.t("branchColors")} ${i+1}`).addColorPicker(n=>{n.setValue(e).onChange(async r=>{this.plugin.settings.branchColors[i]=r,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})})}),new h.Setting(s).setName(this.plugin.t("resetBranchColors")).addButton(e=>{e.setButtonText(this.plugin.t("resetBranchColors")).onClick(async()=>{this.plugin.settings.branchColors=[...O.branchColors],await this.plugin.saveSettings(),this.plugin.refreshOpenViews(),this.display()})}),new h.Setting(s).setName(this.plugin.t("pngScale")).setDesc(this.plugin.t("pngScaleDesc")).addSlider(e=>{e.setLimits(1,4,1).setDynamicTooltip().setValue(this.plugin.settings.exportScale).onChange(async i=>{this.plugin.settings.exportScale=i,await this.plugin.saveSettings()})}),new h.Setting(s).setName(this.plugin.t("transparentPng")).setDesc(this.plugin.t("transparentPngDesc")).addToggle(e=>{e.setValue(this.plugin.settings.exportTransparentBackground).onChange(async i=>{this.plugin.settings.exportTransparentBackground=i,await this.plugin.saveSettings()})}),new h.Setting(s).setName(this.plugin.t("mindMapFiles")).setDesc(`${this.plugin.t("mindMapFilesDesc")} ${this.plugin.settings.mindMapFiles.length}`).addButton(e=>{e.setButtonText(this.plugin.t("clearMindMapFiles")).onClick(async()=>{this.plugin.settings.mindMapFiles=[],await this.plugin.saveSettings(),this.display()})})}},tt=class extends h.Modal{constructor(s,t,e){super(s),this.title=t,this.onChoose=e}onOpen(){var t;this.contentEl.empty(),(t=this.titleEl)==null||t.setText(this.title);let s=this.contentEl.createDiv({cls:"linkmind-emoji-grid"});for(let e of Lt)s.createSpan({cls:"linkmind-emoji-suggestion",text:e}).onClickEvent(()=>{this.onChoose(e),this.close()})}onClose(){this.contentEl.empty()}},et=class extends h.Modal{constructor(s,t,e){super(s),this.plugin=t,this.onApply=e}onOpen(){var e;this.contentEl.empty(),(e=this.titleEl)==null||e.setText(this.plugin.t("nodeStyleShort")),this.modalEl.addClass("linkmind-style-modal");let s=(i,n,r,a,d)=>{let l=this.contentEl.createDiv({cls:"linkmind-style-row"});l.createDiv({cls:"linkmind-style-info"}).createDiv({cls:"linkmind-style-name",text:i});let m=l.createDiv({cls:"linkmind-style-control"}),v=m.createEl("input",{cls:"linkmind-style-slider",attr:{type:"range",min:String(r),max:String(a),value:String(n)}}),u=m.createSpan({cls:"linkmind-style-value",text:String(n)}),f=async w=>{let c=Number.parseInt(w,10);if(!Number.isFinite(c))return;let g=$(c,r,a);v.value=String(g),u.textContent=String(g),d(g),await this.onApply()};v.addEventListener("input",()=>void f(v.value))},t=(i,n,r)=>{let a=this.contentEl.createDiv({cls:"linkmind-style-row"});a.createDiv({cls:"linkmind-style-info"}).createDiv({cls:"linkmind-style-name",text:i});let l=a.createDiv({cls:"linkmind-style-color-controls"}),p=n,m=l.createEl("input",{cls:"linkmind-style-color-input",attr:{type:"color",value:ut(p)}}),v=l.createDiv({cls:"linkmind-style-presets"}),u=()=>{v.empty();for(let c of $t){let g=v.createDiv({cls:`linkmind-style-swatch${p===c?" is-active":""}`});g.style.background=c,g.addEventListener("click",()=>void f(c))}v.createDiv({cls:`linkmind-style-swatch linkmind-style-swatch-none${p==="transparent"?" is-active":""}`,attr:{title:this.plugin.t("transparent")}}).addEventListener("click",()=>void f("transparent"))},f=async w=>{p=w,r(w),m.value=ut(w),u(),await this.onApply()};m.addEventListener("input",()=>void f(m.value)),u()};s(this.plugin.t("borderWidthShort"),this.plugin.settings.nodeBorderWidth,0,8,i=>{this.plugin.settings.nodeBorderWidth=i}),s(this.plugin.t("borderRadiusShort"),this.plugin.settings.nodeBorderRadius,0,999,i=>{this.plugin.settings.nodeBorderRadius=i}),t(this.plugin.t("nodeBgColor"),this.plugin.settings.nodeBgColor,i=>{this.plugin.settings.nodeBgColor=i})}onClose(){this.modalEl.removeClass("linkmind-style-modal"),this.contentEl.empty()}},it=class extends h.Modal{constructor(s,t,e){super(s),this.placeholder=t,this.onSubmit=e}onOpen(){this.contentEl.empty();let s=this.contentEl.createEl("input",{cls:"linkmind-tag-input",attr:{type:"text",placeholder:this.placeholder}});s.focus(),s.addEventListener("keydown",t=>{t.key==="Enter"?(t.preventDefault(),this.onSubmit(s.value),this.close()):t.key==="Escape"&&(t.preventDefault(),this.close())})}onClose(){this.contentEl.empty()}},U=class extends h.Modal{constructor(s,t,e,i,n,r){super(s),this.title=t,this.placeholder=e,this.buttonText=i,this.defaultValue=n,this.onSubmit=r}onOpen(){this.contentEl.empty(),this.contentEl.createEl("h2",{text:this.title});let s=this.contentEl.createEl("input",{cls:"linkmind-tag-input",attr:{type:"text",placeholder:this.placeholder,value:this.defaultValue}}),e=this.contentEl.createDiv({cls:"linkmind-modal-actions"}).createEl("button",{cls:"mod-cta",text:this.buttonText}),i=()=>{this.onSubmit(s.value),this.close()};e.addEventListener("click",i),s.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),i()):n.key==="Escape"&&(n.preventDefault(),this.close())}),s.focus(),s.select()}onClose(){this.contentEl.empty()}},nt=class extends h.SuggestModal{constructor(s,t,e,i){super(s),this.tags=t,this.onChoose=i,this.setPlaceholder(e)}getSuggestions(s){let t=ot(s).toLowerCase(),e=t?this.tags.filter(i=>i.toLowerCase().includes(t)):this.tags;return t&&!e.includes(t)?[t,...e]:e}renderSuggestion(s,t){t.createSpan({cls:"linkmind-tag-suggestion",text:`#${s}`})}onChooseSuggestion(s){this.onChoose(s)}},st=class extends h.Modal{constructor(s,t,e,i,n){super(s),this.labels=t,this.onReload=e,this.onKeep=i,this.onCloseCallback=n}onOpen(){let{contentEl:s}=this;s.empty(),s.createEl("h2",{text:this.labels.title}),s.createEl("p",{text:this.labels.body});let t=s.createDiv({cls:"linkmind-modal-actions"});t.createEl("button",{text:this.labels.reload}).onClickEvent(async()=>{this.close(),await this.onReload()}),t.createEl("button",{cls:"mod-cta",text:this.labels.keep}).onClickEvent(async()=>{this.close(),await this.onKeep()})}onClose(){this.contentEl.empty(),this.onCloseCallback()}};function R(o,s){let t=o.split(/\r?\n/),e=0;if(t[0]==="---"){let d=t.findIndex((l,p)=>p>0&&l==="---");d>0&&(e=d+1)}for(;el0?`${t.slice(0,n).join(` +`)}},C=class extends c.ItemView{constructor(t,e){super(t);this.file=null;this.root=null;this.selectedId=null;this.selectedIds=new Set;this.positions=[];this.searchQuery="";this.searchMatches=[];this.activeSearchIndex=-1;this.saveTimer=null;this.isSaving=!1;this.history=[];this.future=[];this.scale=1;this.panX=80;this.panY=80;this.panning=null;this.dragState=null;this.longPressTimer=null;this.dropTarget=null;this.dragMarkerEl=null;this.lastSavedMarkdown="";this.hasLocalUnsavedChange=!1;this.documentPrefix="";this.documentSuffix="";this.conflictModalOpen=!1;this.pendingFocus=null;this.outlineVisible=!0;this.tagFilter=null;this.plugin=e}getViewType(){return P}getDisplayText(){return this.file?`linkmind: ${this.file.basename}`:"linkmind"}getIcon(){return"brain-circuit"}async setState(t,e){await super.setState(t,e),this.file=t.file?this.app.vault.getAbstractFileByPath(t.file):null,this.pendingFocus={node:t.node,heading:t.heading},await this.loadFile()}getState(){var t,e,i;return{file:(e=(t=this.file)==null?void 0:t.path)!=null?e:"",node:(i=this.selectedId)!=null?i:void 0}}async onOpen(){this.contentEl.empty(),this.contentEl.addClass("linkmind-view"),this.contentEl.setAttr("tabindex","0"),this.contentEl.toggleClass("is-animation-disabled",!this.plugin.settings.animations);let t=this.contentEl.createDiv({cls:"linkmind-toolbar"});this.addIconButton(t,"file-text",this.plugin.t("markdown"),()=>void this.openMarkdown()),this.addIconButton(t,"plus",this.plugin.t("addChildShort"),()=>this.addChildNode()),this.addIconButton(t,"corner-down-right",this.plugin.t("addSiblingShort"),()=>this.addSiblingNode()),this.addIconButton(t,"copy-plus",this.plugin.t("duplicateShort"),()=>this.duplicateSelectedNode()),this.addIconButton(t,"smile",this.plugin.t("setEmojiIcon"),()=>this.openEmojiPicker()),this.addIconButton(t,"tag",this.plugin.t("addTagShort"),()=>this.openTagModal()),this.addIconButton(t,"filter",this.plugin.t("filterByTag"),()=>this.openTagFilterModal()),this.addIconButton(t,"trash-2",this.plugin.t("deleteShort"),()=>this.deleteSelectedNode()),this.addIconButton(t,"unfold-vertical",this.plugin.t("expandAll"),()=>this.expandAllNodes()),this.addIconButton(t,"fold-vertical",this.plugin.t("collapseAll"),()=>this.collapseAllNodes()),this.addIconButton(t,"minimize",this.plugin.t("fitShort"),()=>this.fitToView()),this.addIconButton(t,"download",this.plugin.t("exportSvgShort"),()=>void this.exportSvg()),this.addIconButton(t,"image",this.plugin.t("exportPngShort"),()=>void this.exportPng()),this.addIconButton(t,"link",this.plugin.t("copyLinkShort"),()=>void this.copySelectedNodeLink()),this.addIconButton(t,"copy",this.plugin.t("copyBranch"),()=>void this.copySelectedBranchMarkdown()),this.addIconButton(t,"list-tree",this.plugin.t("toggleOutline"),()=>this.toggleOutline()),this.addIconButton(t,"palette",this.plugin.t("nodeStyleShort"),()=>this.openStylePanel()),this.addIconButton(t,"search",this.plugin.t("searchNodes"),()=>this.searchInputEl.focus());let e=t.createDiv({cls:"linkmind-search"});this.searchInputEl=e.createEl("input",{cls:"linkmind-search-input",attr:{type:"search",placeholder:this.plugin.t("searchNodes"),"aria-label":this.plugin.t("searchNodes")}}),this.searchCountEl=e.createEl("span",{cls:"linkmind-search-count"}),this.searchInputEl.addEventListener("input",()=>this.updateSearch(this.searchInputEl.value)),this.searchInputEl.addEventListener("keydown",n=>this.onSearchKeyDown(n)),this.canvasEl=this.contentEl.createDiv({cls:"linkmind-canvas"}),this.canvasEl.setAttr("tabindex","0"),this.canvasEl.setAttr("aria-label","linkmind canvas"),this.sceneEl=this.canvasEl.createDiv({cls:"linkmind-scene"}),this.svgEl=Z("svg"),this.svgEl.addClass("linkmind-links"),this.sceneEl.appendChild(this.svgEl),this.nodesEl=this.sceneEl.createDiv({cls:"linkmind-nodes"}),this.outlineEl=this.canvasEl.createDiv({cls:"linkmind-outline"});let i=this.outlineEl.createDiv({cls:"linkmind-outline-header"});i.createSpan({text:this.plugin.t("outline")}),this.addIconButton(i,"x",this.plugin.t("hideOutline"),()=>this.toggleOutline(!1)),this.outlineListEl=this.outlineEl.createDiv({cls:"linkmind-outline-list"}),this.statusEl=this.canvasEl.createDiv({cls:"linkmind-status"}),this.registerDomEvent(this.canvasEl,"wheel",n=>this.onWheel(n)),this.registerDomEvent(this.canvasEl,"pointerdown",n=>this.onPointerDown(n)),this.registerDomEvent(window,"pointermove",n=>this.onPointerMove(n)),this.registerDomEvent(window,"pointerup",n=>this.onPointerUp(n)),this.registerDomEvent(this.canvasEl,"keydown",n=>this.onKeyDown(n)),this.registerEvent(this.app.vault.on("modify",async n=>{if(!(!this.file||n.path!==this.file.path||this.isSaving)){if(this.hasLocalUnsavedChange){this.showConflictModal();return}this.loadFile()}})),await this.loadFile(),window.setTimeout(()=>this.focusCanvas(),0)}async openMarkdown(){this.file&&(this.plugin.removeMindMapFile(this.file.path),this.plugin.skipAutoSwitchUntil=Date.now()+$t,await this.leaf.setViewState({type:"markdown",state:{file:this.file.path},active:!0}))}onPaneMenu(t,e){super.onPaneMenu(t,e),t.addItem(i=>{i.setTitle(this.plugin.t("switchToNote")).setIcon("file-text").onClick(()=>void this.openMarkdown())})}applySettings(){this.contentEl.toggleClass("is-animation-disabled",!this.plugin.settings.animations),this.render()}addIconButton(t,e,i,n){let r=t.createEl("button",{cls:"clickable-icon linkmind-tool-button",attr:{"aria-label":i,title:i}});(0,c.setIcon)(r,e),r.onClickEvent(n)}addStyleControl(t,e,i,n,r,a,d){let l=t.createDiv({cls:"linkmind-style-ctrl"});l.createSpan({text:e,cls:"linkmind-style-label"});let p=l.createEl("input",{cls:"linkmind-style-input",attr:{type:n,value:i,...a!==void 0?{min:String(a)}:{},...d!==void 0?{max:String(d)}:{}}});p.addEventListener("change",()=>r(p.value))}openStylePanel(){new it(this.app,this.plugin,async()=>{await this.plugin.saveSettings(),this.render()}).open()}async loadFile(){if(!this.file||!(this.file instanceof c.TFile)){this.renderEmpty(this.plugin.t("emptyView"));return}let t=await this.app.vault.read(this.file),e=R(t,this.file.basename);this.root=e.root,this.documentPrefix=e.prefix,this.documentSuffix=e.suffix,kt(this.root,this.plugin.settings.defaultExpandDepth),this.lastSavedMarkdown=t,this.hasLocalUnsavedChange=!1,this.history=[],this.future=[],this.selectedId=this.selectedId&&M(this.root,this.selectedId)?this.selectedId:this.root.id,this.selectedIds=new Set([this.selectedId]),this.render(),this.applyPendingFocus()}renderEmpty(t){var e,i;this.root=null,(e=this.nodesEl)==null||e.empty(),(i=this.svgEl)==null||i.empty(),this.contentEl.createDiv({cls:"linkmind-empty",text:t})}render(){if(!this.root)return;let t=this.tagFilter?yt(this.root,this.tagFilter):this.root;if(this.positions=t?ut(t,this.plugin.settings.branchColors,this.plugin.settings.layoutDirection):[],this.refreshSearchMatches(),this.nodesEl.empty(),this.svgEl.empty(),this.dragMarkerEl=null,this.positions.length===0){this.renderOutline(),this.applyTransform();return}let e=U(this.positions),i=80,n=Math.max(1,e.width+i*2),r=Math.max(1,e.height+i*2),a=e.minX-i,d=e.minY-i;this.svgEl.style.left=`${a}px`,this.svgEl.style.top=`${d}px`,this.svgEl.setAttrs({width:`${n}`,height:`${r}`,viewBox:`${a} ${d} ${n} ${r}`});for(let f of this.positions)this.renderNode(f);for(let f of this.positions){let w=this.nodesEl.querySelector(`[data-node-id="${f.node.id}"]`);w&&(f.height=w.offsetHeight)}Vt(this.positions,this.plugin.settings.layoutDirection);for(let f of this.positions){let w=this.nodesEl.querySelector(`[data-node-id="${f.node.id}"]`);w&&(w.style.top=`${f.y}px`)}let l=U(this.positions),p=Math.max(1,l.width+i*2),m=Math.max(1,l.height+i*2),v=l.minX-i,u=l.minY-i;this.svgEl.style.left=`${v}px`,this.svgEl.style.top=`${u}px`,this.svgEl.setAttrs({width:`${p}`,height:`${m}`,viewBox:`${v} ${u} ${p} ${m}`});for(let f of this.positions)f.parent&&this.drawLink(f);this.plugin.settings.showAssociationLinks&&this.drawAssociationLinks(),this.renderOutline(),this.updateStatus(),this.applyTransform()}focusCanvas(){!this.canvasEl||this.searchInputEl===document.activeElement||this.canvasEl.focus({preventScroll:!0})}renderOutline(){if(!this.root||!this.outlineListEl)return;if(this.outlineEl.toggleClass("is-hidden",!this.outlineVisible),this.outlineListEl.empty(),this.tagFilter){let e=this.outlineListEl.createDiv({cls:"linkmind-outline-filter"});e.createSpan({text:`${this.plugin.t("tagFilterActive")}: #${this.tagFilter}`}),e.createEl("button",{text:"x"}).onClickEvent(()=>this.clearTagFilter())}let t=(e,i)=>{if(this.tagFilter&&!Mt(e,this.tagFilter))return;let n=this.outlineListEl.createDiv({cls:"linkmind-outline-row"});n.toggleClass("is-selected",this.selectedIds.has(e.id)),n.style.paddingLeft=`${8+i*14}px`;let r=N(e.text);if(r.emoji&&n.createSpan({cls:"linkmind-outline-emoji",text:r.emoji}),n.createSpan({cls:"linkmind-outline-label",text:G(r.displayLabel)}),e.collapsed&&e.children.length>0&&n.createSpan({cls:"linkmind-outline-count",text:`${e.children.length}`}),n.onClickEvent(a=>{a.stopPropagation(),this.selectAndFocusNode(e.id)}),!e.collapsed)for(let a of e.children)t(a,i+1)};t(this.root,0)}renderNode(t){let e=this.nodesEl.createDiv({cls:"linkmind-node"});e.toggleClass("is-root",t.depth===0),e.toggleClass("is-selected",this.selectedIds.has(t.node.id)),e.toggleClass("is-primary-selected",t.node.id===this.selectedId),e.toggleClass("is-search-match",this.searchMatches.includes(t.node.id)),e.toggleClass("is-active-search-match",this.activeSearchIndex>=0&&this.searchMatches[this.activeSearchIndex]===t.node.id),e.toggleClass("is-collapsed",t.node.collapsed),e.toggleClass("is-borderless",this.plugin.settings.hideNodeBorders),e.setAttr("data-node-id",t.node.id),e.setAttr("data-node-anchor",I(t.node.text)),e.setAttr("tabindex","0"),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.borderColor=t.color,e.style.borderWidth=`${this.plugin.settings.nodeBorderWidth}px`,e.style.borderRadius=`${this.plugin.settings.nodeBorderRadius}px`;let i=this.plugin.settings.nodeBgColor;e.style.background=i&&i!=="transparent"?i:"transparent";let n=N(t.node.text);n.emoji&&(e.createDiv({cls:"linkmind-node-emoji",text:n.emoji}),e.addClass("has-emoji"));let r=e.createDiv({cls:"linkmind-node-content"});if(Rt(r,n.displayLabel,this.app),n.tags.length>0){let a=e.createDiv({cls:"linkmind-node-tags"});for(let d of n.tags){let l=a.createSpan({cls:"linkmind-node-tag",text:`#${d}`});l.toggleClass("is-active",this.tagFilter===d),l.onClickEvent(p=>{p.stopPropagation(),this.setTagFilter(d)})}}if(t.node.children.length>0){let a=e.createDiv({cls:"linkmind-collapse"});(0,c.setIcon)(a,t.node.collapsed?"chevron-right":"chevron-down"),a.onClickEvent(d=>{d.stopPropagation(),this.toggleCollapse(t.node.id)})}e.onClickEvent(a=>this.handleNodeClick(a,t.node.id)),e.addEventListener("pointerdown",a=>this.onNodePointerDown(a,t)),e.addEventListener("pointermove",()=>this.clearLongPressTimer()),e.addEventListener("pointerleave",()=>this.clearLongPressTimer()),e.addEventListener("contextmenu",a=>this.openNodeMenu(a,t.node.id))}openNodeMenu(t,e){t.preventDefault(),t.stopPropagation(),this.selectedIds.has(e)||(this.selectedId=e,this.selectedIds=new Set([e]),this.render());let i=new c.Menu;i.addItem(n=>n.setTitle(this.plugin.t("addChild")).setIcon("plus").onClick(()=>this.addChildNode())),i.addItem(n=>n.setTitle(this.plugin.t("addSibling")).setIcon("corner-down-right").onClick(()=>this.addSiblingNode())),i.addItem(n=>n.setTitle(this.plugin.t("editNode")).setIcon("pencil").onClick(()=>this.editSelectedNode())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("duplicateNode")).setIcon("copy-plus").onClick(()=>this.duplicateSelectedNode())),i.addItem(n=>n.setTitle(this.plugin.t("copyBranch")).setIcon("copy").onClick(()=>void this.copySelectedBranchMarkdown())),i.addItem(n=>n.setTitle(this.plugin.t("copyNodeLink")).setIcon("link").onClick(()=>void this.copySelectedNodeLink())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("setEmoji")).setIcon("smile").onClick(()=>this.openEmojiPicker())),i.addItem(n=>n.setTitle(this.plugin.t("addTag")).setIcon("tag").onClick(()=>this.openTagModal())),i.addItem(n=>n.setTitle(this.plugin.t("clearTags")).setIcon("tag").onClick(()=>this.clearSelectedTags())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("exportSelectedSvg")).setIcon("download").onClick(()=>void this.exportSelectedSvg())),i.addItem(n=>n.setTitle(this.plugin.t("exportSelectedPng")).setIcon("image").onClick(()=>void this.exportSelectedPng())),i.addSeparator(),i.addItem(n=>n.setTitle(this.plugin.t("deleteNode")).setIcon("trash-2").onClick(()=>this.deleteSelectedNode())),i.showAtMouseEvent(t)}openNodeMenuAt(t,e,i){let n=new MouseEvent("contextmenu",{clientX:e,clientY:i,bubbles:!0,cancelable:!0});this.openNodeMenu(n,t)}drawLink(t){if(this.plugin.settings.nodeBorderWidth===0)return;let e=t.parent?this.positions.find(u=>{var f;return u.node.id===((f=t.parent)==null?void 0:f.id)}):null;if(!e)return;let i=Z("path"),n=t.x>=e.x,r=n?1:-1,a=n?e.x+e.width:e.x,d=e.y+e.height/2,l=n?t.x:t.x+t.width,p=t.y+t.height/2,m=Math.abs(l-a),v=Math.max(20,m*.35)*r;i.setAttrs({d:`M ${a} ${d} C ${a+v} ${d}, ${l-v} ${p}, ${l} ${p}`,stroke:t.color,fill:"none","stroke-linecap":"round","stroke-width":`${this.plugin.settings.nodeBorderWidth}px`}),this.svgEl.appendChild(i)}drawAssociationLinks(){let t=new Map;for(let i of this.positions)t.set(I(i.node.text),i);let e=new Set;for(let i of this.positions){let n=vt(i.node.text,this.file);for(let r of n){let a=t.get(r);if(!a||a.node.id===i.node.id)continue;let d=[i.node.id,a.node.id].sort().join(":");e.has(d)||(e.add(d),this.drawAssociationLink(i,a))}}}drawAssociationLink(t,e){let i=Z("path");i.addClass("linkmind-association-link");let n=t.x+t.width/2,r=t.y+t.height/2,a=e.x+e.width/2,d=e.y+e.height/2,l=(n+a)/2,p=Math.max(80,Math.abs(d-r)*.35),m=Math.min(r,d)-p;i.setAttrs({d:`M ${n} ${r} Q ${l} ${m}, ${a} ${d}`,fill:"none"}),this.svgEl.appendChild(i)}selectNode(t){this.selectedId=t,this.selectedIds=new Set([t]),this.render(),this.focusCanvas()}selectAndFocusNode(t){this.selectedId=t,this.selectedIds=new Set([t]),this.expandAncestors(t),this.render(),this.focusSelected(),this.focusCanvas()}applyPendingFocus(){if(!this.root||!this.pendingFocus)return;let t=this.resolveFocusTarget(this.pendingFocus);this.pendingFocus=null,t&&window.setTimeout(()=>this.selectAndFocusNode(t.id),0)}resolveFocusTarget(t){if(!this.root)return null;if(t.node){let e=M(this.root,t.node);if(e)return e;let i=dt(this.root,t.node);if(i)return i}return t.heading?dt(this.root,t.heading):null}handleNodeClick(t,e){if(this.focusCanvas(),t.metaKey||t.ctrlKey){this.toggleNodeSelection(e);return}if(t.shiftKey&&this.selectedId){this.selectRange(this.selectedId,e);return}this.selectedId=e,this.selectedIds=new Set([e]),this.editNode(e)}toggleNodeSelection(t){var e;this.selectedIds.has(t)&&this.selectedIds.size>1?(this.selectedIds.delete(t),this.selectedId===t&&(this.selectedId=(e=this.selectedIds.values().next().value)!=null?e:null)):(this.selectedIds.add(t),this.selectedId=t),this.render()}selectRange(t,e){let i=this.positions.map(l=>l.node.id),n=i.indexOf(t),r=i.indexOf(e);if(n===-1||r===-1){this.selectNode(e);return}let[a,d]=nthis.setSelectedEmoji(t)).open()}clearSelectedEmoji(){this.setSelectedEmoji(null)}openTagModal(){!this.root||this.selectedIds.size===0||new nt(this.app,this.plugin.t("enterTag"),t=>this.addTagToSelected(t)).open()}openTagFilterModal(){this.root&&new st(this.app,this.getAllTags(),this.plugin.t("filterByTag"),t=>this.setTagFilter(t)).open()}clearTagFilter(){this.tagFilter=null,this.render()}setTagFilter(t){let e=at(t);if(!e)return;this.tagFilter=e,this.render();let i=this.positions.find(n=>N(n.node.text).tags.includes(e));i&&this.selectAndFocusNode(i.node.id)}getAllTags(){return this.root?[...new Set(Y(this.root).flatMap(t=>N(t.text).tags))].sort():[]}clearSelectedTags(){if(!this.root)return;let t=this.getSelectedNodes();if(t.length!==0){this.pushHistory();for(let e of t)e.text=Xt(e.text);this.scheduleSave(),this.render()}}addTagToSelected(t){if(!this.root)return;let e=at(t);if(!e)return;let i=this.getSelectedNodes();if(i.length!==0){this.pushHistory();for(let n of i)n.text=Yt(n.text,e);this.scheduleSave(),this.render()}}setSelectedEmoji(t){if(!this.root)return;let e=this.getSelectedNodes();if(e.length!==0){this.pushHistory();for(let i of e){let n=ft(i.text);i.text=t?`${t} ${n.label}`:n.label}this.scheduleSave(),this.render()}}editNode(t){if(!this.root)return;let e=M(this.root,t),i=this.nodesEl.querySelector(`[data-node-id="${t}"]`);if(!e||!i)return;this.selectedId=t,i.empty(),i.addClass("is-editing");let n=i.createEl("textarea",{cls:"linkmind-editor"});n.value=e.text,n.focus(),n.select();let r=!1,a=()=>{if(r)return;r=!0;let d=n.value.trim()||"Untitled";this.pushHistory(),e.text=d,this.scheduleSave(),this.render(),this.focusCanvas()};n.addEventListener("keydown",d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),a()),d.key==="Escape"&&(d.preventDefault(),this.render())}),n.addEventListener("blur",a,{once:!0})}addChildNode(){var i,n;if(!this.root)return;let t=(n=M(this.root,(i=this.selectedId)!=null?i:this.root.id))!=null?n:this.root;this.pushHistory();let e=T("New idea",_(t,$(this.root,t.id)));t.children.push(e),t.collapsed=!1,this.selectedId=e.id,this.scheduleSave(),this.render(),window.setTimeout(()=>this.editNode(e.id),20)}addSiblingNode(){if(!this.root||!this.selectedId||this.selectedId===this.root.id){this.addChildNode();return}let t=E(this.root,this.selectedId),e=M(this.root,this.selectedId);if(!t||!e)return;this.pushHistory();let i=t.children.findIndex(r=>r.id===e.id),n=T("New idea",e.kind);t.children.splice(i+1,0,n),this.selectedId=n.id,this.scheduleSave(),this.render(),window.setTimeout(()=>this.editNode(n.id),20)}duplicateSelectedNode(){if(!this.root||!this.selectedId||this.selectedId===this.root.id)return;let t=E(this.root,this.selectedId),e=M(this.root,this.selectedId);if(!t||!e)return;this.pushHistory();let i=t.children.findIndex(r=>r.id===e.id),n=wt(e);t.children.splice(i+1,0,n),this.selectedId=n.id,this.selectedIds=new Set([n.id]),this.scheduleSave(),this.render(),this.focusSelected()}moveSelectedNode(t){if(!this.root||!this.selectedId||this.selectedId===this.root.id)return;if(this.pushHistory(),!Wt(this.root,this.selectedId,t)){this.history.pop();return}this.scheduleSave(),this.render(),this.focusSelected()}deleteSelectedNode(){var i;if(!this.root)return;let t=this.getEditableSelectedIds();if(t.length===0)return;this.pushHistory();let e=this.selectedId?E(this.root,this.selectedId):null;St(this.root,new Set(t)),this.selectedId=(i=e==null?void 0:e.id)!=null?i:this.root.id,this.selectedIds=new Set([this.selectedId]),this.scheduleSave(),this.render()}toggleCollapse(t){if(!this.root)return;let e=M(this.root,t);e&&(e.collapsed=!e.collapsed,this.render())}toggleSelectedNode(){if(!this.root)return;let t=this.getSelectedNodes();if(t.length===0)return;let e=t.some(i=>!i.collapsed&&i.children.length>0);for(let i of t)i.children.length>0&&(i.collapsed=e);this.render()}expandAllNodes(){this.root&&(K(this.root,!1),this.render())}collapseAllNodes(){this.root&&(K(this.root,!0),this.root.collapsed=!1,this.selectedId=this.root.id,this.render(),this.focusSelected())}scheduleSave(){!this.root||!this.file||(this.hasLocalUnsavedChange=!0,this.updateStatus(),this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>void this.saveNow(),this.plugin.settings.autoSaveDelay))}showConflictModal(){this.conflictModalOpen||(this.conflictModalOpen=!0,new rt(this.app,{title:this.plugin.t("conflictTitle"),body:this.plugin.t("conflictBody"),reload:this.plugin.t("reloadMarkdown"),keep:this.plugin.t("keepEdits")},async()=>{this.conflictModalOpen=!1,await this.loadFile(),new c.Notice(this.plugin.t("reloadedExternal"))},async()=>{this.conflictModalOpen=!1,await this.saveNow(),new c.Notice(this.plugin.t("keptLocal"))},()=>{this.conflictModalOpen=!1}).open())}async saveNow(){if(!this.root||!this.file)return;let t=this.serializeCurrentMarkdown();this.isSaving=!0,this.updateStatus(),await this.app.vault.modify(this.file,t),this.lastSavedMarkdown=t,this.hasLocalUnsavedChange=!1,this.isSaving=!1,this.updateStatus()}pushHistory(){this.root&&(this.history.push(this.serializeCurrentMarkdown()),this.history.length>80&&this.history.shift(),this.future=[])}undo(){var i,n;if(!this.root||this.history.length===0)return;this.future.push(this.serializeCurrentMarkdown());let t=this.history.pop();if(!t)return;let e=R(t,(n=(i=this.file)==null?void 0:i.basename)!=null?n:"Mind map");this.root=e.root,this.documentPrefix=e.prefix,this.documentSuffix=e.suffix,this.selectedId=this.root.id,this.selectedIds=new Set([this.root.id]),this.render(),this.saveNow()}redo(){var i,n;if(!this.root)return;let t=this.future.pop();if(!t)return;this.history.push(this.serializeCurrentMarkdown());let e=R(t,(n=(i=this.file)==null?void 0:i.basename)!=null?n:"Mind map");this.root=e.root,this.documentPrefix=e.prefix,this.documentSuffix=e.suffix,this.selectedId=this.root.id,this.selectedIds=new Set([this.root.id]),this.render(),this.saveNow()}onKeyDown(t){if(t.target instanceof HTMLTextAreaElement)return;let e=t.ctrlKey||t.metaKey;if(e&&t.key.toLowerCase()==="z"&&t.shiftKey){t.preventDefault(),this.redo();return}if(e&&t.key.toLowerCase()==="z"){t.preventDefault(),this.undo();return}if(e&&t.key.toLowerCase()==="a"){t.preventDefault(),this.selectAllNodes();return}if(e&&t.key==="="){t.preventDefault(),this.zoomAtCenter(1.1);return}if(e&&t.key==="-"){t.preventDefault(),this.zoomAtCenter(.9);return}if(e&&t.shiftKey&&t.key.toLowerCase()==="f"){t.preventDefault(),this.fitToView();return}if(e&&t.key.toLowerCase()==="f"){t.preventDefault(),this.focusSelected();return}if(t.altKey&&t.key==="ArrowUp"){t.preventDefault(),this.moveSelectedNode("up");return}if(t.altKey&&t.key==="ArrowDown"){t.preventDefault(),this.moveSelectedNode("down");return}if(t.altKey&&t.key==="ArrowRight"){t.preventDefault(),this.moveSelectedNode("indent");return}if(t.altKey&&t.key==="ArrowLeft"){t.preventDefault(),this.moveSelectedNode("outdent");return}t.key==="Tab"?(t.preventDefault(),this.addChildNode()):t.key==="/"?(t.preventDefault(),this.focusSearch()):t.key==="Enter"?(t.preventDefault(),this.addSiblingNode()):t.key==="F2"?(t.preventDefault(),this.selectedId&&this.editNode(this.selectedId)):t.key==="Delete"||t.key==="Backspace"?(t.preventDefault(),this.deleteSelectedNode()):t.key===" "?(t.preventDefault(),this.selectedId&&this.toggleCollapse(this.selectedId)):t.key.startsWith("Arrow")&&(t.preventDefault(),this.moveSelection(t.key))}onSearchKeyDown(t){t.key==="Enter"?(t.preventDefault(),this.jumpSearch(t.shiftKey?-1:1)):t.key==="Escape"?(t.preventDefault(),this.searchInputEl.value="",this.updateSearch(""),this.contentEl.focus()):(t.key==="ArrowDown"||t.key==="ArrowUp")&&(t.preventDefault(),this.jumpSearch(t.key==="ArrowDown"?1:-1))}focusSearch(){this.searchInputEl.focus(),this.searchInputEl.select()}toggleOutline(t){this.outlineVisible=t!=null?t:!this.outlineVisible,this.renderOutline()}selectAllNodes(){this.root&&(this.selectedIds=new Set(Y(this.root).map(t=>t.id)),this.selectedId=this.root.id,this.render())}async exportSvg(){!this.root||!this.file||this.positions.length===0||await this.exportSvgFromPositions(this.positions,this.file.basename,this.getExportPath("svg"))}async exportPng(){!this.root||!this.file||this.positions.length===0||await this.exportPngFromPositions(this.positions,this.file.basename,this.getExportPath("png"))}async exportSelectedSvg(){let t=this.getSelectedBranchExport();t&&await this.exportSvgFromPositions(t.positions,t.title,this.getExportPath("svg",t.slug))}async exportSelectedPng(){let t=this.getSelectedBranchExport();t&&await this.exportPngFromPositions(t.positions,t.title,this.getExportPath("png",t.slug))}async exportSvgFromPositions(t,e,i){let n=pt(t,e,this.plugin.settings.showAssociationLinks,this.plugin.settings.hideNodeBorders,this.plugin.settings.nodeBorderRadius,this.plugin.settings.nodeBorderWidth,this.plugin.settings.nodeBgColor);await this.writeTextFile(i,n),new c.Notice(`${this.plugin.t("exported")} ${i}`)}async exportPngFromPositions(t,e,i){let n=pt(t,e,this.plugin.settings.showAssociationLinks,this.plugin.settings.hideNodeBorders,this.plugin.settings.nodeBorderRadius,this.plugin.settings.nodeBorderWidth,this.plugin.settings.nodeBgColor),r=await Ht(n,this.plugin.settings.exportScale,this.plugin.settings.exportTransparentBackground),a=this.app.vault.getAbstractFileByPath(i);a instanceof c.TFile?await this.app.vault.modifyBinary(a,r):await this.app.vault.createBinary(i,r),new c.Notice(`${this.plugin.t("exported")} ${i}`)}getSelectedBranchExport(){if(!this.root||!this.selectedId)return null;let t=M(this.root,this.selectedId);if(!t)return null;let e=X(t);K(e,!1);let i=ut(e,this.plugin.settings.branchColors,this.plugin.settings.layoutDirection),n=mt(t.text);return{positions:i,title:n,slug:I(t.text)||"branch"}}async copySelectedNodeLink(){if(!this.file||!this.root||!this.selectedId)return;let t=M(this.root,this.selectedId);if(!t)return;let e=this.app.vault.getName(),i=this.file.path,n=I(t.text),r=`obsidian://open?vault=${encodeURIComponent(e)}&file=${encodeURIComponent(i)}#${encodeURIComponent(n)}`;await navigator.clipboard.writeText(r),new c.Notice(this.plugin.t("copiedLink"))}async copySelectedBranchMarkdown(){if(!this.root||!this.selectedId)return;let t=M(this.root,this.selectedId);t&&(await navigator.clipboard.writeText(ht(X(t))),new c.Notice(this.plugin.t("copiedBranch")))}async pasteMarkdownAsChild(){var i,n;if(!this.root)return;let t=(n=M(this.root,(i=this.selectedId)!=null?i:this.root.id))!=null?n:this.root,e=await this.readClipboardNodes(t.kind,$(this.root,t.id)+1);e.length!==0&&(this.pushHistory(),t.children.push(...e),t.collapsed=!1,this.selectedId=e[0].id,this.selectedIds=new Set([e[0].id]),this.scheduleSave(),this.render(),new c.Notice(this.plugin.t("pastedMarkdown")))}async pasteMarkdownAsSibling(){if(!this.root||!this.selectedId||this.selectedId===this.root.id){await this.pasteMarkdownAsChild();return}let t=M(this.root,this.selectedId),e=E(this.root,this.selectedId);if(!t||!e)return;let i=await this.readClipboardNodes(t.kind,$(this.root,t.id));if(i.length===0)return;this.pushHistory();let n=e.children.findIndex(r=>r.id===t.id);e.children.splice(n+1,0,...i),this.selectedId=i[0].id,this.selectedIds=new Set([i[0].id]),this.scheduleSave(),this.render(),new c.Notice(this.plugin.t("pastedMarkdown"))}async readClipboardNodes(t,e){let i=await navigator.clipboard.readText();if(!i.trim())return new c.Notice(this.plugin.t("clipboardEmpty")),[];let n=R(i,"Clipboard"),a=(n.root.text==="Clipboard"&&n.root.children.length>0?n.root.children:[n.root]).map(d=>X(d));for(let d of a)xt(d,t,e);return a.length===0&&new c.Notice(this.plugin.t("clipboardEmpty")),a}updateSearch(t){if(this.searchQuery=t.trim().toLowerCase(),this.refreshSearchMatches(),this.activeSearchIndex=this.searchMatches.length>0?0:-1,this.activeSearchIndex>=0){let e=this.searchMatches[this.activeSearchIndex];e&&this.selectAndFocusNode(e)}else this.render();this.updateSearchCount()}refreshSearchMatches(){if(!this.root||this.searchQuery.length===0){this.searchMatches=[],this.activeSearchIndex=-1,this.updateSearchCount();return}this.searchMatches=Y(this.root).filter(t=>t.text.toLowerCase().includes(this.searchQuery)).map(t=>t.id),this.activeSearchIndex>=this.searchMatches.length&&(this.activeSearchIndex=this.searchMatches.length-1),this.searchMatches.length===0&&(this.activeSearchIndex=-1),this.updateSearchCount()}updateSearchCount(){if(!this.searchCountEl)return;if(this.searchQuery.length===0){this.searchCountEl.setText("");return}let t=this.activeSearchIndex>=0?this.activeSearchIndex+1:0;this.searchCountEl.setText(`${t}/${this.searchMatches.length}`)}jumpSearch(t){if(this.searchMatches.length===0)return;this.activeSearchIndex=(this.activeSearchIndex+t+this.searchMatches.length)%this.searchMatches.length;let e=this.searchMatches[this.activeSearchIndex];e&&this.selectAndFocusNode(e),this.updateSearchCount()}moveSelection(t){if(!this.root||!this.selectedId)return;let e=M(this.root,this.selectedId);if(!e)return;if(t==="ArrowRight"){if(e.collapsed&&e.children.length>0){this.toggleCollapse(e.id);return}let a=e.children[0];a&&this.selectAndFocusNode(a.id);return}if(t==="ArrowLeft"){let a=E(this.root,e.id);e.children.length>0&&!e.collapsed?this.toggleCollapse(e.id):a&&this.selectAndFocusNode(a.id);return}let i=this.positions.slice().sort((a,d)=>a.y-d.y||a.x-d.x),n=i.findIndex(a=>a.node.id===e.id),r=i[n+(t==="ArrowDown"?1:-1)];r&&this.selectAndFocusNode(r.node.id)}expandAncestors(t){if(!this.root)return;let e=bt(this.root,t);for(let i of e.slice(0,-1))i.collapsed=!1}getSelectedNodes(){return this.root?[...this.selectedIds].map(t=>M(this.root,t)).filter(t=>!!t):[]}getEditableSelectedNodes(){return this.root?this.getSelectedNodes().filter(t=>{var e;return t.id!==((e=this.root)==null?void 0:e.id)}):[]}getEditableSelectedIds(){return this.getEditableSelectedNodes().map(t=>t.id)}onWheel(t){t.preventDefault();let e=t.deltaY>0?.92:1.08;this.scale=L(this.scale*e,.35,2.2),this.applyTransform()}onPointerDown(t){let e=t.target;e.closest(".linkmind-node")||e.closest(".linkmind-toolbar")||e.closest(".linkmind-outline")||(this.focusCanvas(),this.panning={x:t.clientX,y:t.clientY,panX:this.panX,panY:this.panY},this.canvasEl.setPointerCapture(t.pointerId))}onPointerMove(t){if(this.dragState){this.onNodePointerMove(t);return}this.panning&&(this.panX=this.panning.panX+t.clientX-this.panning.x,this.panY=this.panning.panY+t.clientY-this.panning.y,this.applyTransform())}onPointerUp(t){if(this.dragState){this.finishNodeDrag(t);return}try{this.canvasEl.releasePointerCapture(t.pointerId)}catch(e){}this.stopPanning()}stopPanning(){this.panning=null}onNodePointerDown(t,e){var r;if(t.button!==0||t.target instanceof HTMLTextAreaElement)return;let i=t.target;if(i.closest(".linkmind-collapse")||i.closest(".linkmind-wikilink"))return;if(t.stopPropagation(),this.selectedId=e.node.id,this.selectedIds=new Set([e.node.id]),this.nodesEl.querySelectorAll(".is-selected").forEach(a=>a.removeClass("is-selected")),t.currentTarget.addClass("is-selected"),e.node.id===((r=this.root)==null?void 0:r.id)){this.focusCanvas(),this.panning={x:t.clientX,y:t.clientY,panX:this.panX,panY:this.panY},t.currentTarget.setPointerCapture(t.pointerId);return}let n=this.toScenePoint(t.clientX,t.clientY);this.dragState={nodeId:e.node.id,pointerId:t.pointerId,startClientX:t.clientX,startClientY:t.clientY,offsetX:n.x-e.x,offsetY:n.y-e.y,originalX:e.x,originalY:e.y,dragging:!1,el:t.currentTarget},this.dragState.el.setPointerCapture(t.pointerId),(t.pointerType==="touch"||t.pointerType==="pen")&&(this.longPressTimer=window.setTimeout(()=>{this.dragState=null,this.openNodeMenuAt(e.node.id,t.clientX,t.clientY)},560))}onNodePointerMove(t){if(!this.dragState)return;this.clearLongPressTimer();let e=t.clientX-this.dragState.startClientX,i=t.clientY-this.dragState.startClientY;if(!this.dragState.dragging&&Math.hypot(e,i)!n.has(u.node.id)),a=r.find(u=>t>=u.x&&t<=u.x+u.width&&e>=u.y&&e<=u.y+u.height);if(a)return{mode:"child",parentId:a.node.id,index:a.node.children.length,targetId:a.node.id};let d=null,l=Number.POSITIVE_INFINITY;for(let u of r){if(u.node.id===this.root.id)continue;let f=Math.hypot(t-(u.x+u.width/2),e-(u.y+u.height/2));fu.id===d.node.id),v=e{var a;return r.node.id===((a=this.dropTarget)==null?void 0:a.targetId)});if(!t)return;this.dragMarkerEl=this.nodesEl.createDiv({cls:"linkmind-drop-marker"});let e=this.dropTarget.index<=((n=(i=E(this.root,this.dropTarget.targetId))==null?void 0:i.children.findIndex(r=>{var a;return r.id===((a=this.dropTarget)==null?void 0:a.targetId)}))!=null?n:0);this.dragMarkerEl.style.left=`${t.x-10}px`,this.dragMarkerEl.style.top=`${e?t.y-x/2:t.y+t.height+x/2}px`,this.dragMarkerEl.style.width=`${t.width+20}px`}clearDropTarget(){var t;this.nodesEl.querySelectorAll(".is-drop-child").forEach(e=>e.removeClass("is-drop-child")),(t=this.dragMarkerEl)==null||t.remove(),this.dragMarkerEl=null}clearLongPressTimer(){this.longPressTimer&&(window.clearTimeout(this.longPressTimer),this.longPressTimer=null)}toScenePoint(t,e){let i=this.canvasEl.getBoundingClientRect();return{x:(t-i.left-this.panX)/this.scale,y:(e-i.top-this.panY)/this.scale}}serializeCurrentMarkdown(){return this.root?`${this.documentPrefix}${ht(this.root)}${this.documentSuffix}`:`${this.documentPrefix}${this.documentSuffix}`}getExportPath(t,e){var r,a,d,l;let i=(a=(r=this.file)==null?void 0:r.parent)!=null&&a.path&&this.file.parent.path!=="/"?`${this.file.parent.path}/`:"",n=e?`.${e}`:"";return`${i}${(l=(d=this.file)==null?void 0:d.basename)!=null?l:"mind-map"}.linkmind${n}.${t}`}async writeTextFile(t,e){let i=this.app.vault.getAbstractFileByPath(t);i instanceof c.TFile?await this.app.vault.modify(i,e):await this.app.vault.create(t,e)}zoomAtCenter(t){this.scale=L(this.scale*t,.35,2.2),this.applyTransform()}focusSelected(){let t=this.positions.find(i=>i.node.id===this.selectedId);if(!t)return;let e=this.canvasEl.getBoundingClientRect();this.panX=e.width/2-(t.x+t.width/2)*this.scale,this.panY=e.height/2-(t.y+k/2)*this.scale,this.applyTransform()}fitToView(){if(this.positions.length===0)return;let t=U(this.positions),e=this.canvasEl.getBoundingClientRect(),i=(e.width-120)/Math.max(t.width,1),n=(e.height-120)/Math.max(t.height,1);this.scale=L(Math.min(i,n),.35,1.4),this.panX=e.width/2-(t.minX+t.width/2)*this.scale,this.panY=e.height/2-(t.minY+t.height/2)*this.scale,this.applyTransform()}applyTransform(){this.sceneEl&&(this.sceneEl.style.transform=`translate(${this.panX}px, ${this.panY}px) scale(${this.scale})`,this.updateStatus())}updateStatus(){if(!this.statusEl)return;let t=this.root?Y(this.root).length:0,e=this.positions.length,i=this.isSaving?this.plugin.t("saving"):this.hasLocalUnsavedChange?this.plugin.t("unsaved"):this.plugin.t("saved"),n=this.tagFilter?`#${this.tagFilter}`:"";this.statusEl.setText([`${e}/${t} ${this.plugin.t("nodesLabel")}`,`${this.selectedIds.size} ${this.plugin.t("selectedLabel")}`,`${this.plugin.t("zoomLabel")} ${Math.round(this.scale*100)}%`,n,i].filter(Boolean).join(" \xB7 "))}},tt=class extends c.PluginSettingTab{constructor(s,t){super(s,t),this.plugin=t}display(){let{containerEl:s}=this;s.empty(),s.createEl("h2",{text:this.plugin.t("settingsTitle")}),new c.Setting(s).setName(this.plugin.t("language")).setDesc(this.plugin.t("languageDesc")).addDropdown(e=>{e.addOption("zh",this.plugin.t("chinese")).addOption("en",this.plugin.t("english")).setValue(this.plugin.settings.language).onChange(async i=>{this.plugin.settings.language=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews(),this.display()})}),new c.Setting(s).setName(this.plugin.t("autoSaveDelay")).setDesc(this.plugin.t("autoSaveDelayDesc")).addText(e=>{e.setPlaceholder("300").setValue(String(this.plugin.settings.autoSaveDelay)).onChange(async i=>{let n=Number.parseInt(i,10);this.plugin.settings.autoSaveDelay=Number.isFinite(n)?L(n,0,5e3):O.autoSaveDelay,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("defaultExpandDepth")).setDesc(this.plugin.t("defaultExpandDepthDesc")).addSlider(e=>{e.setLimits(1,99,1).setDynamicTooltip().setValue(this.plugin.settings.defaultExpandDepth).onChange(async i=>{this.plugin.settings.defaultExpandDepth=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("layoutDirection")).setDesc(this.plugin.t("layoutDirectionDesc")).addDropdown(e=>{e.addOption("right",this.plugin.t("horizontalRight")).addOption("balanced",this.plugin.t("balanced")).setValue(this.plugin.settings.layoutDirection).onChange(async i=>{this.plugin.settings.layoutDirection=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("layoutAnimation")).setDesc(this.plugin.t("layoutAnimationDesc")).addToggle(e=>{e.setValue(this.plugin.settings.animations).onChange(async i=>{this.plugin.settings.animations=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("showAssociationLinks")).setDesc(this.plugin.t("showAssociationLinksDesc")).addToggle(e=>{e.setValue(this.plugin.settings.showAssociationLinks).onChange(async i=>{this.plugin.settings.showAssociationLinks=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("hideNodeBorders")).setDesc(this.plugin.t("hideNodeBordersDesc")).addToggle(e=>{e.setValue(this.plugin.settings.hideNodeBorders).onChange(async i=>{this.plugin.settings.hideNodeBorders=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("nodeBorderRadius")).setDesc(this.plugin.t("nodeBorderRadiusDesc")).addSlider(e=>{e.setLimits(0,999,1).setDynamicTooltip().setValue(this.plugin.settings.nodeBorderRadius).onChange(async i=>{this.plugin.settings.nodeBorderRadius=i,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})}),new c.Setting(s).setName(this.plugin.t("branchColors")).setDesc(this.plugin.t("branchColorsDesc")).addTextArea(e=>{e.setValue(this.plugin.settings.branchColors.join(", ")).onChange(async i=>{let n=i.split(",").map(r=>r.trim()).filter(Boolean);this.plugin.settings.branchColors=n.length>0?n:O.branchColors,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()}),e.inputEl.rows=2});let t=s.createDiv({cls:"linkmind-settings-palette"});this.plugin.settings.branchColors.forEach((e,i)=>{new c.Setting(t).setName(`${this.plugin.t("branchColors")} ${i+1}`).addColorPicker(n=>{n.setValue(e).onChange(async r=>{this.plugin.settings.branchColors[i]=r,await this.plugin.saveSettings(),this.plugin.refreshOpenViews()})})}),new c.Setting(s).setName(this.plugin.t("resetBranchColors")).addButton(e=>{e.setButtonText(this.plugin.t("resetBranchColors")).onClick(async()=>{this.plugin.settings.branchColors=[...O.branchColors],await this.plugin.saveSettings(),this.plugin.refreshOpenViews(),this.display()})}),new c.Setting(s).setName(this.plugin.t("pngScale")).setDesc(this.plugin.t("pngScaleDesc")).addSlider(e=>{e.setLimits(1,4,1).setDynamicTooltip().setValue(this.plugin.settings.exportScale).onChange(async i=>{this.plugin.settings.exportScale=i,await this.plugin.saveSettings()})}),new c.Setting(s).setName(this.plugin.t("transparentPng")).setDesc(this.plugin.t("transparentPngDesc")).addToggle(e=>{e.setValue(this.plugin.settings.exportTransparentBackground).onChange(async i=>{this.plugin.settings.exportTransparentBackground=i,await this.plugin.saveSettings()})}),new c.Setting(s).setName(this.plugin.t("mindMapFiles")).setDesc(`${this.plugin.t("mindMapFilesDesc")} ${this.plugin.settings.mindMapFiles.length}`).addButton(e=>{e.setButtonText(this.plugin.t("clearMindMapFiles")).onClick(async()=>{this.plugin.settings.mindMapFiles=[],await this.plugin.saveSettings(),this.display()})})}},et=class extends c.Modal{constructor(s,t,e){super(s),this.title=t,this.onChoose=e}onOpen(){var t;this.contentEl.empty(),(t=this.titleEl)==null||t.setText(this.title);let s=this.contentEl.createDiv({cls:"linkmind-emoji-grid"});for(let e of Lt)s.createSpan({cls:"linkmind-emoji-suggestion",text:e}).onClickEvent(()=>{this.onChoose(e),this.close()})}onClose(){this.contentEl.empty()}},it=class extends c.Modal{constructor(s,t,e){super(s),this.plugin=t,this.onApply=e}onOpen(){var e;this.contentEl.empty(),(e=this.titleEl)==null||e.setText(this.plugin.t("nodeStyleShort")),this.modalEl.addClass("linkmind-style-modal");let s=(i,n,r,a,d)=>{let l=this.contentEl.createDiv({cls:"linkmind-style-row"});l.createDiv({cls:"linkmind-style-info"}).createDiv({cls:"linkmind-style-name",text:i});let m=l.createDiv({cls:"linkmind-style-control"}),v=m.createEl("input",{cls:"linkmind-style-slider",attr:{type:"range",min:String(r),max:String(a),value:String(n)}}),u=m.createSpan({cls:"linkmind-style-value",text:String(n)}),f=async w=>{let h=Number.parseInt(w,10);if(!Number.isFinite(h))return;let g=L(h,r,a);v.value=String(g),u.textContent=String(g),d(g),await this.onApply()};v.addEventListener("input",()=>void f(v.value))},t=(i,n,r)=>{let a=this.contentEl.createDiv({cls:"linkmind-style-row"});a.createDiv({cls:"linkmind-style-info"}).createDiv({cls:"linkmind-style-name",text:i});let l=a.createDiv({cls:"linkmind-style-color-controls"}),p=n,m=l.createEl("input",{cls:"linkmind-style-color-input",attr:{type:"color",value:gt(p)}}),v=l.createDiv({cls:"linkmind-style-presets"}),u=()=>{v.empty();for(let h of Bt){let g=v.createDiv({cls:`linkmind-style-swatch${p===h?" is-active":""}`});g.style.background=h,g.addEventListener("click",()=>void f(h))}v.createDiv({cls:`linkmind-style-swatch linkmind-style-swatch-none${p==="transparent"?" is-active":""}`,attr:{title:this.plugin.t("transparent")}}).addEventListener("click",()=>void f("transparent"))},f=async w=>{p=w,r(w),m.value=gt(w),u(),await this.onApply()};m.addEventListener("input",()=>void f(m.value)),u()};s(this.plugin.t("borderWidthShort"),this.plugin.settings.nodeBorderWidth,0,8,i=>{this.plugin.settings.nodeBorderWidth=i}),s(this.plugin.t("borderRadiusShort"),this.plugin.settings.nodeBorderRadius,0,999,i=>{this.plugin.settings.nodeBorderRadius=i}),t(this.plugin.t("nodeBgColor"),this.plugin.settings.nodeBgColor,i=>{this.plugin.settings.nodeBgColor=i})}onClose(){this.modalEl.removeClass("linkmind-style-modal"),this.contentEl.empty()}},nt=class extends c.Modal{constructor(s,t,e){super(s),this.placeholder=t,this.onSubmit=e}onOpen(){this.contentEl.empty();let s=this.contentEl.createEl("input",{cls:"linkmind-tag-input",attr:{type:"text",placeholder:this.placeholder}});s.focus(),s.addEventListener("keydown",t=>{t.key==="Enter"?(t.preventDefault(),this.onSubmit(s.value),this.close()):t.key==="Escape"&&(t.preventDefault(),this.close())})}onClose(){this.contentEl.empty()}},W=class extends c.Modal{constructor(s,t,e,i,n,r){super(s),this.title=t,this.placeholder=e,this.buttonText=i,this.defaultValue=n,this.onSubmit=r}onOpen(){this.contentEl.empty(),this.contentEl.createEl("h2",{text:this.title});let s=this.contentEl.createEl("input",{cls:"linkmind-tag-input",attr:{type:"text",placeholder:this.placeholder,value:this.defaultValue}}),e=this.contentEl.createDiv({cls:"linkmind-modal-actions"}).createEl("button",{cls:"mod-cta",text:this.buttonText}),i=()=>{this.onSubmit(s.value),this.close()};e.addEventListener("click",i),s.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),i()):n.key==="Escape"&&(n.preventDefault(),this.close())}),s.focus(),s.select()}onClose(){this.contentEl.empty()}},st=class extends c.SuggestModal{constructor(s,t,e,i){super(s),this.tags=t,this.onChoose=i,this.setPlaceholder(e)}getSuggestions(s){let t=at(s).toLowerCase(),e=t?this.tags.filter(i=>i.toLowerCase().includes(t)):this.tags;return t&&!e.includes(t)?[t,...e]:e}renderSuggestion(s,t){t.createSpan({cls:"linkmind-tag-suggestion",text:`#${s}`})}onChooseSuggestion(s){this.onChoose(s)}},ot=class extends c.Modal{constructor(s,t,e){super(s),this.labels=t,this.onConfirm=e}onOpen(){let{contentEl:s}=this;s.empty(),s.createEl("h2",{text:this.labels.title}),s.createEl("p",{text:this.labels.body});let t=s.createDiv({cls:"linkmind-modal-actions"});t.createEl("button",{text:"Cancel"}).onClickEvent(()=>this.close()),t.createEl("button",{cls:"mod-cta",text:this.labels.confirm}).onClickEvent(async()=>{this.close(),await this.onConfirm()})}onClose(){this.contentEl.empty()}},rt=class extends c.Modal{constructor(s,t,e,i,n){super(s),this.labels=t,this.onReload=e,this.onKeep=i,this.onCloseCallback=n}onOpen(){let{contentEl:s}=this;s.empty(),s.createEl("h2",{text:this.labels.title}),s.createEl("p",{text:this.labels.body});let t=s.createDiv({cls:"linkmind-modal-actions"});t.createEl("button",{text:this.labels.reload}).onClickEvent(async()=>{this.close(),await this.onReload()}),t.createEl("button",{cls:"mod-cta",text:this.labels.keep}).onClickEvent(async()=>{this.close(),await this.onKeep()})}onClose(){this.contentEl.empty(),this.onCloseCallback()}};function R(o,s){let t=o.split(/\r?\n/),e=0;if(t[0]==="---"){let h=t.findIndex((g,y)=>y>0&&g==="---");h>0&&(e=h+1)}for(;e/^(#{1,6})\s+(.+?)\s*$/.test(h)||/^(\s*)[-*+]\s+(.+?)\s*$/.test(h),n=t.findIndex((h,g)=>g>=e&&i(h)),r=n===-1?t.length:n,a=t.slice(0,r),d=[],l=[],p=!1,m=!1,v=!1;for(let h=r;h0?`${a.join(` `).replace(/\s*$/,"")} -`:"",a=t.slice(n).join(` -`);return{root:Ft(a,s),prefix:r}}function Ft(o,s){var a,d,l,p;let t=o.split(/\r?\n/),e=null,i=1,n=[],r=()=>(e||(e=C(s||"Center topic","heading"),n.push({depth:1,node:e})),e);for(let m of t){let v=/^(#{1,6})\s+(.+?)\s*$/.exec(m);if(v){let f=v[1].length,w=C(v[2],"heading");if(!e&&f===1)e=w,n.length=0,n.push({depth:1,node:w});else{for(r();n.length>0&&n[n.length-1].depth>=f;)n.pop();((d=(a=n[n.length-1])==null?void 0:a.node)!=null?d:e).children.push(w),n.push({depth:f,node:w})}i=f;continue}let u=/^(\s*)[-*+]\s+(.+?)\s*$/.exec(m);if(u){r();let f=Math.floor(u[1].replace(/\t/g," ").length/2),w=i+f+1,c=C(u[2],"list");for(;n.length>0&&n[n.length-1].depth>=w;)n.pop();((p=(l=n[n.length-1])==null?void 0:l.node)!=null?p:e).children.push(c),n.push({depth:w,node:c})}}return e!=null?e:C(s||"Center topic","heading")}function lt(o){let s=[],t=(e,i,n)=>{let r=e.kind==="heading"&&!n&&i<=6;r?s.push(`${"#".repeat(i)} ${e.text}`):s.push(`${" ".repeat(Math.max(0,i-2))}- ${e.text}`);for(let a of e.children)t(a,i+1,n||!r)};return t(o,1,!1),`${s.join(` +`:"",f=l.join(` +`).trim().length>0?` + +${l.join(` +`).replace(/^\s*/,"")}`:"",w=d.join(` +`);return{root:jt(w,s),prefix:u,suffix:f}}function jt(o,s){var a,d,l,p;let t=o.split(/\r?\n/),e=null,i=1,n=[],r=()=>(e||(e=T(s||"Center topic","heading"),n.push({depth:1,node:e})),e);for(let m of t){let v=/^(#{1,6})\s+(.+?)\s*$/.exec(m);if(v){let f=v[1].length,w=T(v[2],"heading");if(!e&&f===1)e=w,n.length=0,n.push({depth:1,node:w});else{for(r();n.length>0&&n[n.length-1].depth>=f;)n.pop();((d=(a=n[n.length-1])==null?void 0:a.node)!=null?d:e).children.push(w),n.push({depth:f,node:w})}i=f;continue}let u=/^(\s*)[-*+]\s+(.+?)\s*$/.exec(m);if(u){r();let f=Math.floor(u[1].replace(/\t/g," ").length/2),w=i+f+1,h=T(u[2],"list");for(;n.length>0&&n[n.length-1].depth>=w;)n.pop();((p=(l=n[n.length-1])==null?void 0:l.node)!=null?p:e).children.push(h),n.push({depth:w,node:h})}}return e!=null?e:T(s||"Center topic","heading")}function ht(o){let s=[],t=(e,i,n)=>{let r=e.kind==="heading"&&!n&&i<=6;r?s.push(`${"#".repeat(i)} ${e.text}`):s.push(`${" ".repeat(Math.max(0,i-2))}- ${e.text}`);for(let a of e.children)t(a,i+1,n||!r)};return t(o,1,!1),`${s.join(` `)} -`}function ht(o){return o.replace(/[\\/:*?"<>|#^[\]]+/g," ").replace(/\s+/g," ").trim()}function ct(o,s,t=!0,e=!1,i=999,n=2,r="transparent"){let a=at(o),d=80,l=Math.ceil(a.width+d*2),p=Math.ceil(a.height+d*2),m=a.minX-d,v=a.minY-d,u=n===0?"":o.filter(c=>c.parent).map(c=>{let g=c.parent?o.find(F=>{var H;return F.node.id===((H=c.parent)==null?void 0:H.id)}):null;if(!g)return"";let y=c.x>=g.x,k=y?1:-1,I=y?g.x+g.width:g.x,S=g.y+g.height/2,A=y?c.x:c.x+c.width,B=c.y+c.height/2,_=Math.abs(A-I),V=Math.max(20,_*.35)*k;return``}).join(` -`),f=t?jt(o):"",w=o.map(c=>{let g=c.depth===0,y=c.width,k=g?18:14,I=g?700:400,S=E(c.node.text),A=[S.emoji?`${S.emoji} ${W(S.displayLabel)}`:W(S.displayLabel),S.tags.map(F=>`#${F}`).join(" ")].filter(Boolean).join(" "),B=Yt(A,g?20:22),_=B.map((F,H)=>{let bt=H===0?0:k+3;return`${j(F)}`}).join(""),V=Math.max(x,24+B.length*(k+3));return[``,`${_}`].join(` +`}function ct(o){return o.replace(/[\\/:*?"<>|#^[\]]+/g," ").replace(/\s+/g," ").trim()}function pt(o,s,t=!0,e=!1,i=999,n=2,r="transparent"){let a=U(o),d=80,l=Math.ceil(a.width+d*2),p=Math.ceil(a.height+d*2),m=a.minX-d,v=a.minY-d,u=n===0?"":o.filter(h=>h.parent).map(h=>{let g=h.parent?o.find(F=>{var V;return F.node.id===((V=h.parent)==null?void 0:V.id)}):null;if(!g)return"";let y=h.x>=g.x,S=y?1:-1,D=y?g.x+g.width:g.x,b=g.y+g.height/2,B=y?h.x:h.x+h.width,A=h.y+h.height/2,q=Math.abs(B-D),H=Math.max(20,q*.35)*S;return``}).join(` +`),f=t?Ot(o):"",w=o.map(h=>{let g=h.depth===0,y=h.width,S=g?18:14,D=g?700:400,b=N(h.node.text),B=[b.emoji?`${b.emoji} ${G(b.displayLabel)}`:G(b.displayLabel),b.tags.map(F=>`#${F}`).join(" ")].filter(Boolean).join(" "),A=Kt(B,g?20:22),q=A.map((F,V)=>{let Et=V===0?0:S+3;return`${j(F)}`}).join(""),H=Math.max(k,24+A.length*(S+3));return[``,`${q}`].join(` `)}).join(` `);return['',``,"",u,f,w,""].join(` -`)}function jt(o){let s=new Map;for(let e of o)s.set(T(e.node.text),e);let t=new Set;return o.flatMap(e=>mt(e.node.text,null).map(i=>{let n=s.get(i);if(!n||n.node.id===e.node.id)return"";let r=[e.node.id,n.node.id].sort().join(":");if(t.has(r))return"";t.add(r);let a=e.x+e.width/2,d=e.y+e.height/2,l=n.x+n.width/2,p=n.y+n.height/2,m=(a+l)/2,v=Math.max(80,Math.abs(p-d)*.35),u=Math.min(d,p)-v;return``})).filter(Boolean).join(` -`)}async function Ot(o,s,t){var d,l,p,m;let e=Number((l=(d=/width="(\d+)"/.exec(o))==null?void 0:d[1])!=null?l:1200),i=Number((m=(p=/height="(\d+)"/.exec(o))==null?void 0:p[1])!=null?m:800),n=$(Math.round(s),1,4),r=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(r);try{let v=await new Promise((c,g)=>{let y=new Image;y.onload=()=>c(y),y.onerror=()=>g(new Error("Could not render SVG export.")),y.src=a}),u=document.createElement("canvas");u.width=e*n,u.height=i*n;let f=u.getContext("2d");if(!f)throw new Error("Canvas is not available.");return t||(f.fillStyle=getComputedStyle(document.body).getPropertyValue("--background-primary").trim()||"#ffffff",f.fillRect(0,0,u.width,u.height)),f.scale(n,n),f.drawImage(v,0,0,e,i),await(await new Promise((c,g)=>{u.toBlob(y=>y?c(y):g(new Error("Could not encode PNG export.")),"image/png")})).arrayBuffer()}finally{URL.revokeObjectURL(a)}}function pt(o,s,t){let e=[],i=a=>a.collapsed?[]:a.children,n=a=>{let d=i(a);return d.length===0?x:Math.max(x,d.reduce((l,p)=>l+n(p),0)+P*(d.length-1))},r=(a,d,l,p,m,v,u)=>{let f=n(a),w=m+f/2-x/2,c=l===0?200:At;e.push({node:a,parent:d,depth:l,x:p,y:w,width:c,height:x,color:v,side:u});let g=m;i(a).forEach((k,I)=>{let S=l===0?s[I%s.length]:v;r(k,a,l+1,p+u*q,g,S,u),g+=n(k)+P})};if(t==="balanced"&&!o.collapsed&&o.children.length>1){let a=i(o),d=a.filter((c,g)=>g%2===1),l=a.filter((c,g)=>g%2===0),p=c=>c.length===0?x:c.reduce((g,y)=>g+n(y),0)+P*(c.length-1),m=p(d),v=p(l),u=Math.max(m,v,x);e.push({node:o,parent:null,depth:0,x:0,y:u/2-x/2,width:200,height:x,color:s[0],side:1});let f=u/2-m/2;d.forEach((c,g)=>{let y=a.findIndex(k=>k===c);r(c,o,1,-q,f,s[y%s.length],-1),f+=n(c)+P});let w=u/2-v/2;l.forEach(c=>{let g=a.findIndex(y=>y===c);r(c,o,1,q,w,s[g%s.length],1),w+=n(c)+P})}else r(o,null,0,0,0,s[0],1);return e}function Vt(o,s,t){let e=/(\[\[[^\]]+\]\]|`[^`]+`|\*\*[^*]+\*\*)/g,i=0;for(let n of s.matchAll(e)){if(n.index===void 0)continue;n.index>i&&o.appendText(s.slice(i,n.index));let r=n[0];if(r.startsWith("[[")){let a=r.slice(2,-2);o.createEl("span",{cls:"linkmind-wikilink",text:a}).onClickEvent(l=>{l.stopPropagation(),t.workspace.openLinkText(a,"",!1)})}else r.startsWith("`")?o.createEl("code",{text:r.slice(1,-1)}):o.createEl("strong",{text:r.slice(2,-2)});i=n.index+r.length}i(t.push(r),n)).replace(/\s{2,}/g," ").trim()||s.label;return{...s,tags:t,displayLabel:e}}function ot(o){return o.trim().replace(/^#/,"").replace(/[^\p{Letter}\p{Number}_/-]/gu,"")}function Ht(o,s){return E(o).tags.includes(s)?o:`${o.trim()} #${s}`}function Rt(o){let s=E(o);return`${s.emoji?`${s.emoji} `:""}${s.displayLabel}`.trim()||"Untitled"}function ft(o){let s=E(o);return W(`${s.emoji?`${s.emoji} `:""}${s.displayLabel}${s.tags.length>0?` ${s.tags.map(t=>`#${t}`).join(" ")}`:""}`)}function W(o){return o.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(s,t,e)=>e!=null?e:t).replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1")}function mt(o,s){let t=[],e=s==null?void 0:s.basename.toLowerCase(),i=s==null?void 0:s.path.replace(/\.md$/i,"").toLowerCase(),n=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g;for(let r of o.matchAll(n)){let a=r[1].trim();if(!a)continue;let[d,l]=a.includes("#")?a.split("#",2):["",a],p=d.trim().replace(/\.md$/i,"").toLowerCase();p&&p!==e&&p!==i||t.push(T(l))}return t.filter(Boolean)}function Yt(o,s){let t=o.trim().split(/\s+/).filter(Boolean);if(t.length===0)return["Untitled"];let e=[],i="";for(let n of t){if(n.length>s){i&&e.push(i);for(let a=0;as&&i?(e.push(i),i=n):i=r}return i&&e.push(i),e.slice(0,4)}function ut(o){if(!o||o==="transparent")return"#ffffff";if(/^#[0-9a-fA-F]{6}$/.test(o))return o;let s=document.createElement("div");s.style.color=o,document.body.appendChild(s);let t=getComputedStyle(s).color;document.body.removeChild(s);let e=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(t);return e?`#${[e[1],e[2],e[3]].map(i=>Number(i).toString(16).padStart(2,"0")).join("")}`:"#ffffff"}function j(o){return o.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function C(o,s){return{id:`node-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,text:o.trim()||"Untitled",kind:s,children:[],collapsed:!1}}function X(o){return{id:o.id,text:o.text,kind:o.kind,collapsed:o.collapsed,children:o.children.map(s=>X(s))}}function vt(o){return{id:C(o.text,o.kind).id,text:o.text,kind:o.kind,collapsed:o.collapsed,children:o.children.map(s=>vt(s))}}function wt(o,s){let t=o.children.map(e=>wt(e,s)).filter(e=>!!e);return E(o.text).tags.includes(s)||t.length>0?{...o,collapsed:!1,children:t}:null}function yt(o,s){return E(o.text).tags.includes(s)||o.children.some(t=>yt(t,s))}function Mt(o,s,t){o.id=C(o.text,o.kind).id,o.kind=s==="heading"&&t<=5?"heading":"list";for(let e of o.children)Mt(e,o.kind,t+1)}function kt(o,s,t=0){o.collapsed=t>=s;for(let e of o.children)kt(e,s,t+1)}function K(o,s){o.collapsed=s;for(let t of o.children)K(t,s)}function G(o,s){return o.kind==="heading"&&s<5?"heading":"list"}function M(o,s){if(o.id===s)return o;for(let t of o.children){let e=M(t,s);if(e)return e}return null}function rt(o,s){let t=Ut(s);if(T(o.text)===t)return o;for(let e of o.children){let i=rt(e,t);if(i)return i}return null}function b(o,s){for(let t of o.children){if(t.id===s)return o;let e=b(t,s);if(e)return e}return null}function St(o,s){o.children=o.children.filter(t=>!s.has(t.id));for(let t of o.children)St(t,s)}function Y(o){let s=[],t=e=>{s.push(e);for(let i of e.children)t(i)};return t(o),s}function xt(o,s){if(o.id===s)return[o];for(let t of o.children){let e=xt(t,s);if(e.length>0)return[o,...e]}return[]}function Xt(o){if(!o)return[];let s=[],t=e=>{for(let i of e.children)s.push(i.id),t(i)};return t(o),s}function Kt(o,s,t){if(s===o.id||s===t.parentId)return!1;let e=b(o,s),i=M(o,t.parentId);if(!e||!i)return!1;let n=e.children.findIndex(d=>d.id===s);if(n===-1)return!1;let[r]=e.children.splice(n,1);if(!r)return!1;let a=t.mode==="child"?i.children.length:t.index;return e.id===i.id&&nd.id===s);if(n===-1)return!1;if(t==="up")return n===0?!1:([e.children[n-1],e.children[n]]=[e.children[n],e.children[n-1]],!0);if(t==="down")return n>=e.children.length-1?!1:([e.children[n],e.children[n+1]]=[e.children[n+1],e.children[n]],!0);if(t==="indent"){if(n===0)return!1;let d=e.children[n-1];return e.children.splice(n,1),i.kind=G(d,L(o,d.id)),d.children.push(i),d.collapsed=!1,!0}let r=b(o,e.id);if(!r)return!1;e.children.splice(n,1);let a=r.children.findIndex(d=>d.id===e.id);return i.kind=G(r,L(o,r.id)),r.children.splice(a+1,0,i),!0}function Ut(o){return decodeURIComponent(o).replace(/^#+/,"").trim().toLowerCase().replace(/\s+/g,"-")}function T(o){return ft(o).trim().toLowerCase().replace(/[^\p{Letter}\p{Number}\p{Emoji_Presentation}\s-]/gu,"").replace(/\s+/g,"-")}function L(o,s,t=0){if(o.id===s)return t;for(let e of o.children){let i=L(e,s,t+1);if(i!==-1)return i}return-1}function at(o){let s=Math.min(...o.map(n=>n.x)),t=Math.min(...o.map(n=>n.y)),e=Math.max(...o.map(n=>n.x+n.width)),i=Math.max(...o.map(n=>n.y+n.height));return{minX:s,minY:t,width:e-s,height:i-t}}function $(o,s,t){return Math.max(s,Math.min(t,o))}function J(o){return document.createElementNS("http://www.w3.org/2000/svg",o)} +`)}function Ot(o){let s=new Map;for(let e of o)s.set(I(e.node.text),e);let t=new Set;return o.flatMap(e=>vt(e.node.text,null).map(i=>{let n=s.get(i);if(!n||n.node.id===e.node.id)return"";let r=[e.node.id,n.node.id].sort().join(":");if(t.has(r))return"";t.add(r);let a=e.x+e.width/2,d=e.y+e.height/2,l=n.x+n.width/2,p=n.y+n.height/2,m=(a+l)/2,v=Math.max(80,Math.abs(p-d)*.35),u=Math.min(d,p)-v;return``})).filter(Boolean).join(` +`)}async function Ht(o,s,t){var d,l,p,m;let e=Number((l=(d=/width="(\d+)"/.exec(o))==null?void 0:d[1])!=null?l:1200),i=Number((m=(p=/height="(\d+)"/.exec(o))==null?void 0:p[1])!=null?m:800),n=L(Math.round(s),1,4),r=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(r);try{let v=await new Promise((h,g)=>{let y=new Image;y.onload=()=>h(y),y.onerror=()=>g(new Error("Could not render SVG export.")),y.src=a}),u=document.createElement("canvas");u.width=e*n,u.height=i*n;let f=u.getContext("2d");if(!f)throw new Error("Canvas is not available.");return t||(f.fillStyle=getComputedStyle(document.body).getPropertyValue("--background-primary").trim()||"#ffffff",f.fillRect(0,0,u.width,u.height)),f.scale(n,n),f.drawImage(v,0,0,e,i),await(await new Promise((h,g)=>{u.toBlob(y=>y?h(y):g(new Error("Could not encode PNG export.")),"image/png")})).arrayBuffer()}finally{URL.revokeObjectURL(a)}}function ut(o,s,t){let e=[],i=a=>a.collapsed?[]:a.children,n=a=>{let d=i(a);return d.length===0?k:Math.max(k,d.reduce((l,p)=>l+n(p),0)+x*(d.length-1))},r=(a,d,l,p,m,v,u)=>{let f=n(a),w=m+f/2-k/2,h=l===0?240:At;e.push({node:a,parent:d,depth:l,x:p,y:w,width:h,height:k,color:v,side:u});let g=m;i(a).forEach((S,D)=>{let b=l===0?s[D%s.length]:v;r(S,a,l+1,p+u*J,g,b,u),g+=n(S)+x})};if(t==="balanced"&&!o.collapsed&&o.children.length>1){let a=i(o),d=a.filter((h,g)=>g%2===1),l=a.filter((h,g)=>g%2===0),p=h=>h.length===0?k:h.reduce((g,y)=>g+n(y),0)+x*(h.length-1),m=p(d),v=p(l),u=Math.max(m,v,k);e.push({node:o,parent:null,depth:0,x:0,y:u/2-k/2,width:240,height:k,color:s[0],side:1});let f=u/2-m/2;d.forEach((h,g)=>{let y=a.findIndex(S=>S===h);r(h,o,1,-J,f,s[y%s.length],-1),f+=n(h)+x});let w=u/2-v/2;l.forEach(h=>{let g=a.findIndex(y=>y===h);r(h,o,1,J,w,s[g%s.length],1),w+=n(h)+x})}else r(o,null,0,0,0,s[0],1);return e}function Vt(o,s){if(o.length===0)return;let t=new Map;for(let r of o)t.set(r.node.id,r);let e=r=>{let a=t.get(r.id);if(!a)return k;let d=r.collapsed?[]:r.children;if(d.length===0)return a.height;let l=d.reduce((p,m)=>p+e(m),0)+x*(d.length-1);return Math.max(a.height,l)},i=(r,a)=>{let d=t.get(r.id);if(!d)return;let l=e(r);d.y=a+l/2-d.height/2;let p=a,m=r.collapsed?[]:r.children;for(let v of m)i(v,p),p+=e(v)+x},n=o[0];if(s==="balanced"&&!n.node.collapsed&&n.node.children.length>1){let r=n.node.children,a=r.filter((w,h)=>h%2===1),d=r.filter((w,h)=>h%2===0),l=w=>w.length===0?n.height:w.reduce((h,g)=>h+e(g),0)+x*(w.length-1),p=l(a),m=l(d),v=Math.max(p,m,n.height);n.y=v/2-n.height/2;let u=v/2-p/2;for(let w of a)i(w,u),u+=e(w)+x;let f=v/2-m/2;for(let w of d)i(w,f),f+=e(w)+x}else{let r=e(n.node);n.y=r/2-n.height/2;let a=0,d=n.node.collapsed?[]:n.node.children;for(let l of d)i(l,a),a+=e(l)+x}}function Rt(o,s,t){let e=/(\[\[[^\]]+\]\]|`[^`]+`|\*\*[^*]+\*\*)/g,i=0;for(let n of s.matchAll(e)){if(n.index===void 0)continue;n.index>i&&o.appendText(s.slice(i,n.index));let r=n[0];if(r.startsWith("[[")){let a=r.slice(2,-2);o.createEl("span",{cls:"linkmind-wikilink",text:a}).onClickEvent(l=>{l.stopPropagation(),t.workspace.openLinkText(a,"",!1)})}else r.startsWith("`")?o.createEl("code",{text:r.slice(1,-1)}):o.createEl("strong",{text:r.slice(2,-2)});i=n.index+r.length}i(t.push(r),n)).replace(/\s{2,}/g," ").trim()||s.label;return{...s,tags:t,displayLabel:e}}function at(o){return o.trim().replace(/^#/,"").replace(/[^\p{Letter}\p{Number}_/-]/gu,"")}function Yt(o,s){return N(o).tags.includes(s)?o:`${o.trim()} #${s}`}function Xt(o){let s=N(o);return`${s.emoji?`${s.emoji} `:""}${s.displayLabel}`.trim()||"Untitled"}function mt(o){let s=N(o);return G(`${s.emoji?`${s.emoji} `:""}${s.displayLabel}${s.tags.length>0?` ${s.tags.map(t=>`#${t}`).join(" ")}`:""}`)}function G(o){return o.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(s,t,e)=>e!=null?e:t).replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1")}function vt(o,s){let t=[],e=s==null?void 0:s.basename.toLowerCase(),i=s==null?void 0:s.path.replace(/\.md$/i,"").toLowerCase(),n=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g;for(let r of o.matchAll(n)){let a=r[1].trim();if(!a)continue;let[d,l]=a.includes("#")?a.split("#",2):["",a],p=d.trim().replace(/\.md$/i,"").toLowerCase();p&&p!==e&&p!==i||t.push(I(l))}return t.filter(Boolean)}function Kt(o,s){let t=o.trim().split(/\s+/).filter(Boolean);if(t.length===0)return["Untitled"];let e=[],i="";for(let n of t){if(n.length>s){i&&e.push(i);for(let a=0;as&&i?(e.push(i),i=n):i=r}return i&&e.push(i),e.slice(0,4)}function gt(o){if(!o||o==="transparent")return"#ffffff";if(/^#[0-9a-fA-F]{6}$/.test(o))return o;let s=document.createElement("div");s.style.color=o,document.body.appendChild(s);let t=getComputedStyle(s).color;document.body.removeChild(s);let e=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(t);return e?`#${[e[1],e[2],e[3]].map(i=>Number(i).toString(16).padStart(2,"0")).join("")}`:"#ffffff"}function j(o){return o.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function T(o,s){return{id:`node-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,text:o.trim()||"Untitled",kind:s,children:[],collapsed:!1}}function X(o){return{id:o.id,text:o.text,kind:o.kind,collapsed:o.collapsed,children:o.children.map(s=>X(s))}}function wt(o){return{id:T(o.text,o.kind).id,text:o.text,kind:o.kind,collapsed:o.collapsed,children:o.children.map(s=>wt(s))}}function yt(o,s){let t=o.children.map(e=>yt(e,s)).filter(e=>!!e);return N(o.text).tags.includes(s)||t.length>0?{...o,collapsed:!1,children:t}:null}function Mt(o,s){return N(o.text).tags.includes(s)||o.children.some(t=>Mt(t,s))}function xt(o,s,t){o.id=T(o.text,o.kind).id,o.kind=s==="heading"&&t<=5?"heading":"list";for(let e of o.children)xt(e,o.kind,t+1)}function kt(o,s,t=0){o.collapsed=t>=s;for(let e of o.children)kt(e,s,t+1)}function K(o,s){o.collapsed=s;for(let t of o.children)K(t,s)}function _(o,s){return o.kind==="heading"&&s<5?"heading":"list"}function M(o,s){if(o.id===s)return o;for(let t of o.children){let e=M(t,s);if(e)return e}return null}function dt(o,s){let t=Gt(s);if(I(o.text)===t)return o;for(let e of o.children){let i=dt(e,t);if(i)return i}return null}function E(o,s){for(let t of o.children){if(t.id===s)return o;let e=E(t,s);if(e)return e}return null}function St(o,s){o.children=o.children.filter(t=>!s.has(t.id));for(let t of o.children)St(t,s)}function Y(o){let s=[],t=e=>{s.push(e);for(let i of e.children)t(i)};return t(o),s}function bt(o,s){if(o.id===s)return[o];for(let t of o.children){let e=bt(t,s);if(e.length>0)return[o,...e]}return[]}function Ut(o){if(!o)return[];let s=[],t=e=>{for(let i of e.children)s.push(i.id),t(i)};return t(o),s}function zt(o,s,t){if(s===o.id||s===t.parentId)return!1;let e=E(o,s),i=M(o,t.parentId);if(!e||!i)return!1;let n=e.children.findIndex(d=>d.id===s);if(n===-1)return!1;let[r]=e.children.splice(n,1);if(!r)return!1;let a=t.mode==="child"?i.children.length:t.index;return e.id===i.id&&nd.id===s);if(n===-1)return!1;if(t==="up")return n===0?!1:([e.children[n-1],e.children[n]]=[e.children[n],e.children[n-1]],!0);if(t==="down")return n>=e.children.length-1?!1:([e.children[n],e.children[n+1]]=[e.children[n+1],e.children[n]],!0);if(t==="indent"){if(n===0)return!1;let d=e.children[n-1];return e.children.splice(n,1),i.kind=_(d,$(o,d.id)),d.children.push(i),d.collapsed=!1,!0}let r=E(o,e.id);if(!r)return!1;e.children.splice(n,1);let a=r.children.findIndex(d=>d.id===e.id);return i.kind=_(r,$(o,r.id)),r.children.splice(a+1,0,i),!0}function Gt(o){return decodeURIComponent(o).replace(/^#+/,"").trim().toLowerCase().replace(/\s+/g,"-")}function I(o){return mt(o).trim().toLowerCase().replace(/[^\p{Letter}\p{Number}\p{Emoji_Presentation}\s-]/gu,"").replace(/\s+/g,"-")}function $(o,s,t=0){if(o.id===s)return t;for(let e of o.children){let i=$(e,s,t+1);if(i!==-1)return i}return-1}function U(o){let s=Math.min(...o.map(n=>n.x)),t=Math.min(...o.map(n=>n.y)),e=Math.max(...o.map(n=>n.x+n.width)),i=Math.max(...o.map(n=>n.y+n.height));return{minX:s,minY:t,width:e-s,height:i-t}}function L(o,s,t){return Math.max(s,Math.min(t,o))}function Z(o){return document.createElementNS("http://www.w3.org/2000/svg",o)} diff --git a/manifest.json b/manifest.json index a77e7a4..683a48d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "linkmind", "name": "linkmind", - "version": "0.2.0", + "version": "0.2.1", "minAppVersion": "1.5.0", "description": "Edit Markdown as a clean, keyboard-friendly mind map.", "author": "pikaqiu", diff --git a/package.json b/package.json index 2de1d8b..712efd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "linkmind", - "version": "0.2.0", + "version": "0.2.1", "description": "An editor-first mind map plugin for Obsidian that syncs with plain Markdown.", "main": "plugin/main.js", "scripts": { diff --git a/styles.css b/styles.css index 5b86816..2ede3a6 100644 --- a/styles.css +++ b/styles.css @@ -46,13 +46,13 @@ } .linkmind-node { - width: 168px; + width: 200px; padding-left: 12px; padding-right: 10px; } .linkmind-node.is-root { - width: 184px; + width: 220px; } .linkmind-outline { @@ -286,7 +286,7 @@ .linkmind-node { position: absolute; - width: 180px; + width: 220px; min-height: 42px; display: flex; align-items: center; @@ -314,7 +314,7 @@ } .linkmind-node.is-root { - width: 200px; + width: 240px; min-height: 48px; justify-content: center; border-width: 2.5px; diff --git a/versions.json b/versions.json index 17a47ae..a5c906b 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { "0.1.0": "1.5.0", - "0.2.0": "1.5.0" + "0.2.0": "1.5.0", + "0.2.1": "1.5.0" }