@xiangfa/mindmap 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +106 -6
- package/README.zh-CN.md +106 -6
- package/dist/components/MindMapAIInput.d.ts +13 -0
- package/dist/components/MindMapContextMenu.d.ts +1 -1
- package/dist/components/MindMapControls.d.ts +1 -1
- package/dist/components/icons.d.ts +4 -0
- package/dist/esm/MindMap2.js +322 -320
- package/dist/esm/components/MindMapAIInput.js +199 -0
- package/dist/esm/components/MindMapContextMenu.js +28 -57
- package/dist/esm/components/MindMapControls.js +14 -27
- package/dist/esm/components/MindMapNode.js +8 -27
- package/dist/esm/components/icons.js +78 -1
- package/dist/esm/hooks/useNodeEdit.js +1 -1
- package/dist/esm/hooks/usePanZoom.js +3 -1
- package/dist/esm/plugins/tags.js +8 -8
- package/dist/esm/style.css +1 -1
- package/dist/esm/utils/export.js +25 -25
- package/dist/esm/utils/i18n.js +6 -0
- package/dist/esm/utils/layout.js +26 -18
- package/dist/esm/utils/markdown.js +1 -1
- package/dist/esm/utils/theme.js +44 -1
- package/dist/index.d.ts +1 -1
- package/dist/mindmap.umd.cjs +75 -16
- package/dist/plugins/tags.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/utils/export.d.ts +2 -1
- package/dist/utils/i18n.d.ts +3 -0
- package/dist/utils/theme.d.ts +10 -0
- package/package.json +2 -1
- package/dist/esm/logo.svg +0 -9
- package/dist/logo.svg +0 -9
package/dist/mindmap.umd.cjs
CHANGED
|
@@ -1,24 +1,83 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.OpenMindMap={},e.React,e.ReactJSXRuntime))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FFEAA7`,`#DDA0DD`,`#98D8C8`,`#F7DC6F`,`#BB8FCE`,`#F0B27A`],i={root:{fontSize:20,fontWeight:600,fontFamily:`system-ui, 'Segoe UI', Roboto, sans-serif`,paddingH:24,paddingV:12},node:{fontSize:15,fontWeight:400,fontFamily:`system-ui, 'Segoe UI', Roboto, sans-serif`,paddingH:8,paddingV:6},level1:{fontSize:16,fontWeight:500},connection:{strokeWidth:2.5},layout:{horizontalGap:80,verticalGap:16}},a={...i,root:{...i.root,bgColor:`#2C3E50`,textColor:`#FFFFFF`},node:{...i.node,textColor:`#333333`},canvas:{bgColor:`#fafafa`},controls:{bgColor:`rgba(255, 255, 255, 0.9)`,textColor:`#555`,hoverBg:`rgba(0, 0, 0, 0.08)`,activeBg:`rgba(0, 0, 0, 0.08)`},contextMenu:{bgColor:`rgba(255, 255, 255, 0.95)`,textColor:`#333`,hoverBg:`rgba(0, 0, 0, 0.06)`,borderColor:`rgba(0, 0, 0, 0.08)`,shadowColor:`rgba(0, 0, 0, 0.15)`},addBtn:{fill:`rgba(200, 200, 220, 0.6)`,hoverFill:`rgba(180, 180, 200, 0.8)`,iconColor:`#666`},selection:{strokeColor:`#4A90D9`,fillColor:`rgba(74, 144, 217, 0.08)`},highlight:{textColor:`#fac800`,bgColor:`rgba(252, 211, 77, 0.2)`}},o={...i,root:{...i.root,bgColor:`#4A6FA5`,textColor:`#FFFFFF`},node:{...i.node,textColor:`#E0E0E0`},canvas:{bgColor:`#1a1a2e`},controls:{bgColor:`rgba(30, 30, 45, 0.9)`,textColor:`#ccc`,hoverBg:`rgba(255, 255, 255, 0.1)`,activeBg:`rgba(255, 255, 255, 0.12)`},contextMenu:{bgColor:`rgba(35, 35, 50, 0.95)`,textColor:`#ddd`,hoverBg:`rgba(255, 255, 255, 0.08)`,borderColor:`rgba(255, 255, 255, 0.1)`,shadowColor:`rgba(0, 0, 0, 0.4)`},addBtn:{fill:`rgba(100, 100, 130, 0.6)`,hoverFill:`rgba(120, 120, 150, 0.8)`,iconColor:`#aaa`},selection:{strokeColor:`#5B9BD5`,fillColor:`rgba(91, 155, 213, 0.15)`},highlight:{textColor:`#fcd34d`,bgColor:`rgba(251, 191, 36, 0.2)`}};function s(e){return e===`dark`?o:a}var c=a,l="!\\[([^\\]]*)\\]\\(([^)]+)\\)|\\[([^\\]]+)\\]\\(([^)]+)\\)|`([^`]+)`|\\*\\*(.+?)\\*\\*|\\*(.+?)\\*|~~(.+?)~~|==(.+?)==";function u(e,t){let n=[],r=l,i=[];if(t&&t.length>0){let e=[];for(let n of t)if(n.inlineTokenPattern){let{pattern:t,priority:r}=n.inlineTokenPattern();e.push({plugin:n,pattern:t,priority:r})}e.sort((e,t)=>e.priority-t.priority);let n=0;for(let t of e){let e=d(t.pattern);i.push({plugin:t.plugin,groupOffset:n,pattern:t.pattern}),n+=e}i.length>0&&(r=i.map(e=>e.pattern).join(`|`)+"|!\\[([^\\]]*)\\]\\(([^)]+)\\)|\\[([^\\]]+)\\]\\(([^)]+)\\)|`([^`]+)`|\\*\\*(.+?)\\*\\*|\\*(.+?)\\*|~~(.+?)~~|==(.+?)==")}let a=new RegExp(r,`g`),o=i.reduce((e,t)=>e+d(t.pattern),0),s=0,c;for(;(c=a.exec(e))!==null;){c.index>s&&n.push({type:`text`,content:e.slice(s,c.index)});let t=!1;if(i.length>0)for(let e of i){let r=e.groupOffset+1,i=d(e.pattern),a=!1;for(let e=r;e<r+i;e++)if(c[e]!==void 0){a=!0;break}if(a&&e.plugin.createInlineToken){let r=e.plugin.createInlineToken(c,e.groupOffset);if(r){n.push(r),t=!0;break}}}if(!t){let e=o,t=t=>c[e+t];t(1)!==void 0||t(2)!==void 0?n.push({type:`image`,alt:t(1)??``,url:t(2)}):t(3)===void 0?t(5)===void 0?t(6)===void 0?t(7)===void 0?t(8)===void 0?t(9)!==void 0&&n.push({type:`highlight`,content:t(9)}):n.push({type:`strikethrough`,content:t(8)}):n.push({type:`italic`,content:t(7)}):n.push({type:`bold`,content:t(6)}):n.push({type:`code`,content:t(5)}):n.push({type:`link`,text:t(3),url:t(4)})}s=c.index+c[0].length}return s<e.length&&n.push({type:`text`,content:e.slice(s)}),n.length===0&&n.push({type:`text`,content:e}),n}function d(e){let t=0;for(let n=0;n<e.length;n++){if(e[n]===`\\`){n++;continue}e[n]===`(`&&e[n+1]!==`?`&&t++}return t}function f(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/~~(.+?)~~/g,`$1`).replace(/==(.+?)==/g,`$1`).replace(/\$\$(.+?)\$\$/g,`$1`).replace(/\$([^$]+?)\$/g,`$1`)}var p=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`,m=null;function h(){return m||=document.createElement(`canvas`).getContext(`2d`),m}function g(e,t,n,r){let i=h();return i.font=`${n} ${t}px ${r}`,i.measureText(e).width}function _(e,t,n,r){let i=[],a=0;for(let o of e){let e;switch(o.type){case`bold`:e=g(o.content,t,700,r);break;case`code`:e=g(o.content,t*.88,400,p);break;case`link`:e=g(o.text,t,n,r);break;case`image`:e=g(`[${o.alt||`image`}]`,t,n,r);break;case`latex-inline`:case`latex-block`:e=g(o.content,t*.9,n,p);break;default:e=g(`content`in o?o.content:``,t,n,r);break}i.push({token:o,x:a,width:e}),a+=e}return i}function v(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function y(e,t,n,r,i,a,o,s,c,l,d){let f=_(u(e,s),t,n,r),p=f.length>0?f[f.length-1].x+f[f.length-1].width:0,m=t*.85,h=a?m+(a?4:0):0,g=t*.7,v=o?4:0,y=o?g+v:0,S=-(h+p+y)/2,C=S+h,w=[];a&&(w.push(`<g transform="translate(${S}, ${-m/2})">`),w.push(x(a,m)),w.push(`</g>`));let T=-t/2-2,E=t+4;for(let e of f)e.token.type===`code`?w.push(`<rect x="${C+e.x-2}" y="${T}" width="${e.width+4}" height="${E}" rx="3" fill="rgba(128,128,128,0.12)"/>`):e.token.type===`highlight`&&w.push(`<rect x="${C+e.x-1}" y="${T}" width="${e.width+2}" height="${E}" rx="2" fill="${l||`rgba(255,213,79,0.3)`}"/>`);w.push(`<text text-anchor="start" dominant-baseline="central" x="${C}" fill="${i}" font-size="${t}" font-weight="${n}" font-family="${r}">`);for(let e of f)w.push(b(e.token,s,c,d));return w.push(`</text>`),o&&w.push(`<text x="${C+p+v}" text-anchor="start" dominant-baseline="central" font-size="${g}" opacity="0.5">💬</text>`),w.join(``)}function b(e,t,n,r){switch(e.type){case`bold`:return`<tspan font-weight="700">${v(e.content)}</tspan>`;case`italic`:return`<tspan font-style="italic">${v(e.content)}</tspan>`;case`strikethrough`:return`<tspan text-decoration="line-through" opacity="0.6">${v(e.content)}</tspan>`;case`code`:return`<tspan font-family="${p}" font-size="0.88em">${v(e.content)}</tspan>`;case`highlight`:return`<tspan fill="${n||`#FFEB3B`}">${v(e.content)}</tspan>`;case`link`:return`<a href="${v(e.url)}" target="_blank"><tspan fill="#2563EB" text-decoration="underline">${v(e.text)}</tspan></a>`;case`image`:return`<tspan font-style="italic">[${v(e.alt||`image`)}]</tspan>`;case`latex-inline`:case`latex-block`:if(t){for(let n of t)if(n.exportInlineToken){let t=n.exportInlineToken({token:e,x:0,width:0},r);if(t)return t}}return`<tspan font-family="${p}" font-style="italic" font-size="0.9em">${v(e.content)}</tspan>`;default:return v(e.content)}}function x(e,t){return e===`done`?`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="#22C55E"/><path d="M${t*.28} ${t*.5}L${t*.44} ${t*.66}L${t*.72} ${t*.34}" stroke="white" stroke-width="${t*.13}" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`:e===`doing`?`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="none" stroke="#FBBF24" stroke-width="${t*.1}"/><rect x="${t*.25}" y="${t*.25}" width="${t*.5}" height="${t*.5}" rx="${t*.1}" fill="#FBBF24" opacity="0.6"/>`:`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="none" stroke="#999" stroke-width="${t*.1}" opacity="0.4"/>`}function S(e,t,n,r,i,a,o,s,c,l){let d=_(u(e,o),t,n,r),f=-(d.length>0?d[d.length-1].x+d[d.length-1].width:0)/2,p=[],m=a-t/2-2,h=t+4;for(let e of d)e.token.type===`code`?p.push(`<rect x="${f+e.x-2}" y="${m}" width="${e.width+4}" height="${h}" rx="3" fill="rgba(128,128,128,0.12)"/>`):e.token.type===`highlight`&&p.push(`<rect x="${f+e.x-1}" y="${m}" width="${e.width+2}" height="${h}" rx="2" fill="${c||`rgba(255,213,79,0.3)`}"/>`);let g=l===void 0?``:` opacity="${l}"`;p.push(`<text x="${f}" y="${a}" text-anchor="start" dominant-baseline="central" fill="${i}" font-size="${t}" font-weight="${n}" font-family="${r}"${g}>`);for(let e of d)p.push(b(e.token,o,s));return p.push(`</text>`),p.join(``)}function C(e,t,n){for(let r of e)r.preParseMarkdown&&(t=r.preParseMarkdown(t,n));return t}function w(e,t,n,r){for(let i of e)if(i.parseLine){let e=i.parseLine(t,n,r);if(e)return e}return null}function T(e,t,n,r,i){let a=0;for(let o of e)if(o.collectFollowLines){let e=o.collectFollowLines(t,n+a,r,i);a+=e}return a}function E(e,t,n,r){for(let i of e)i.transformNodeData&&(t=i.transformNodeData(t,n,r));return t}function D(e,t,n){for(let r of e)r.postParseTree&&(t=r.postParseTree(t,n));return t}function O(e,t){let n=``;for(let r of e)if(r.serializePreamble){let e=r.serializePreamble(t);e&&(n+=e)}return n}function ee(e,t,n){let r=n;for(let n of e)if(n.serializeListMarker){let e=n.serializeListMarker(t,r);if(e!==r){r=e;break}}return r}function k(e,t,n){for(let r of e)r.serializeNodeText&&(n=r.serializeNodeText(t,n));return n}function te(e,t,n){let r=[];for(let i of e)if(i.serializeFollowLines){let e=i.serializeFollowLines(t,n);e&&r.push(...e)}return r}function A(e,t,n,r,i){for(let a of e)if(a.adjustNodeSize){let e=a.adjustNodeSize(t,n,r,i);n=e.width,r=e.height}return{width:n,height:r}}function j(e,t,n,r){for(let i of e)i.filterChildren&&(n=i.filterChildren(t,n,r));return n}function M(e,t,n,r){for(let i of e)i.transformEdge&&(t=i.transformEdge(t,n,r));return t}function N(e,t,n,r){let i=[];for(let a of e)a.generateExtraEdges&&i.push(...a.generateExtraEdges(t,n,r));return i}function P(e,t,n,r){let i={};for(let a of e)if(a.transformNodeColor){let e=a.transformNodeColor(t,n,r);i={...i,...e}}return i}function F(e,t,n){let r=[];for(let i of e)if(i.renderNodeDecoration){let e=i.renderNodeDecoration(t,n);e&&r.push(e)}return r}function I(e,t,n){for(let r of e)if(r.renderInlineToken){let e=r.renderInlineToken(t,n);if(e)return e}return null}function ne(e,t,n,r){let i=[];for(let a of e)if(a.renderOverlay){let e=a.renderOverlay(t,n,r);e&&i.push(e)}return i}function re(e,t,n,r,i){let a=``;for(let o of e)o.exportNodeDecoration&&(a+=o.exportNodeDecoration(t,n,r,i));return a}function ie(e,t,n,r){let i=``;for(let a of e)a.exportOverlay&&(i+=a.exportOverlay(t,n,r));return i}var ae=null;function oe(){return ae||=document.createElement(`canvas`).getContext(`2d`),ae}function se(e,t,n,r){let i=oe();return i.font=`${n} ${t}px ${r||c.root.fontFamily}`,i.measureText(e).width}var ce=4,L=20;function le(e,t,n,r,i){let a=se(f(e),t,n);return r&&(a+=t*.9+ce),i&&(a+=L),a}function R(e,t,n,i,a,o,s){let l=t===0,u=t===1,d=l?c.root.fontSize:u?c.level1.fontSize:c.node.fontSize,f=l?c.root.fontWeight:u?c.level1.fontWeight:c.node.fontWeight,p=l?c.root.paddingH:c.node.paddingH,m=l?c.root.paddingV:c.node.paddingV,h=le(e.text,d,f,e.taskStatus,!!e.remark)+p*2,g=d+m*2;if(o&&o.length>0){let t=A(o,e,h,g,d);h=t.width,g=t.height}let _=e.children||[];o&&o.length>0&&s&&(_=j(o,e,_,s));let v=i;if(o&&o.length>0){let r=P(o,{id:e.id,text:e.text,x:0,y:0,width:h,height:g,color:i,depth:t,side:n,parentId:a},e,i);r.color&&(v=r.color)}let y=_.map((i,a)=>{let c=l?r[a%r.length]:v;return R(i,t+1,n,c,e.id,o,s)});return{id:e.id,text:e.text,children:y,width:h,height:g,depth:t,side:n,color:v,x:0,y:0,subtreeHeight:0,parentId:a,remark:e.remark,taskStatus:e.taskStatus,dottedLine:e.dottedLine,multiLineContent:e.multiLineContent,tags:e.tags,anchorId:e.anchorId,crossLinks:e.crossLinks,collapsed:e.collapsed}}function z(e){if(e.children.length===0)return e.subtreeHeight=e.height,e.height;let t=e.children.reduce((e,t)=>e+z(t),0)+(e.children.length-1)*c.layout.verticalGap;return e.subtreeHeight=Math.max(e.height,t),e.subtreeHeight}function B(e,t,n){if(e.x=t,e.y=n,e.children.length===0)return;let r=e.side===`left`?-1:1,i=n-(e.children.reduce((e,t)=>e+t.subtreeHeight,0)+(e.children.length-1)*c.layout.verticalGap)/2;for(let n of e.children){let a=i+n.subtreeHeight/2;B(n,t+r*(e.width/2+c.layout.horizontalGap+n.width/2),a),i+=n.subtreeHeight+c.layout.verticalGap}}function ue(e,t){t.push({id:e.id,text:e.text,x:e.x,y:e.y,width:e.width,height:e.height,color:e.color,depth:e.depth,side:e.side,parentId:e.parentId,remark:e.remark,taskStatus:e.taskStatus,dottedLine:e.dottedLine,multiLineContent:e.multiLineContent,tags:e.tags,anchorId:e.anchorId,crossLinks:e.crossLinks,collapsed:e.collapsed});for(let n of e.children)ue(n,t)}function de(e,t,n,r,i,a,o){let s=o===`left`?-1:1,c=e+n/2*s,l=t,u=r-a/2*s,d=i,f=c+(u-c)*.5;return`M ${c},${l} C ${f},${l} ${f},${d} ${u},${d}`}function V(e,t,n,r){for(let i of e.children){let a={key:`${e.id}-${i.id}`,path:de(e.x,e.y,e.width,i.x,i.y,i.width,i.side),color:i.color,fromId:e.id,toId:i.id};if(r&&r.length>0){let t=n.find(t=>t.id===e.id),o=n.find(e=>e.id===i.id);t&&o&&(a=M(r,a,t,o))}t.push(a),V(i,t,n,r)}}function H(e,t=`both`,n,i,a,o,s){let l=a&&a.length>0?{direction:t,theme:c,readonly:!!o,foldOverrides:s||{}}:void 0,u=e.children||[],d,f,p;t===`right`?(d=u,f=[],p=u.length):t===`left`?(d=[],f=u,p=0):(p=i??Math.ceil(u.length/2),p=Math.min(Math.max(p,0),u.length),d=u.slice(0,p),f=u.slice(p));let m=R({...e,children:[]},0,`root`,c.root.bgColor,void 0,a,l),h=d.map((t,i)=>R(t,1,`right`,n?.[t.id]??r[i%r.length],e.id,a,l)),g=f.map((i,o)=>R(i,1,`left`,n?.[i.id]??r[((t===`left`?0:p)+o)%r.length],e.id,a,l));m.children=[...h,...g];for(let e of m.children)z(e);m.x=0,m.y=0;let _=m.children.filter(e=>e.side===`right`),v=m.children.filter(e=>e.side===`left`),y=(e,t)=>{let n=-(e.reduce((e,t)=>e+t.subtreeHeight,0)+Math.max(0,e.length-1)*c.layout.verticalGap)/2;for(let r of e){let e=n+r.subtreeHeight/2;B(r,t*(m.width/2+c.layout.horizontalGap+r.width/2),e),n+=r.subtreeHeight+c.layout.verticalGap}};y(_,1),y(v,-1);let b=[],x=[];if(ue(m,b),V(m,x,b,a),a&&a.length>0&&l){let t=N(a,b,[e],l);x.push(...t)}return{nodes:b,edges:x}}function fe(e,t=`both`,n,r,i,a,o){if(e.length===0)return{nodes:[],edges:[]};if(e.length===1)return H(e[0],t,n,r?.[e[0].id],i,a,o);let s=e.map(e=>H(e,t,n,r?.[e.id],i,a,o)),c=s.map(e=>{let t=1/0,n=-1/0;for(let r of e.nodes)t=Math.min(t,r.y-r.height/2),n=Math.max(n,r.y+r.height/2);return{minY:t,maxY:n}}),l=[],u=[],d=c[0].maxY;for(let e of s[0].nodes)l.push(e);for(let e of s[0].edges)u.push(e);for(let e=1;e<s.length;e++){let t=d+80-c[e].minY,n=l.length;for(let n of s[e].nodes)l.push({...n,y:n.y+t});for(let t of s[e].edges){let e=l.slice(n).find(e=>e.id===t.fromId),r=l.slice(n).find(e=>e.id===t.toId);e&&r?u.push({...t,path:de(e.x,e.y,e.width,r.x,r.y,r.width,r.side)}):u.push(t)}d=d+80+(c[e].maxY-c[e].minY)}let f=-(Math.min(...l.map(e=>e.y-e.height/2))+Math.max(...l.map(e=>e.y+e.height/2)))/2;if(Math.abs(f)>.1){for(let e of l)e.y+=f;for(let e=0;e<u.length;e++){let t=u[e];if(t.isCrossLink)continue;let n=l.find(e=>e.id===t.fromId),r=l.find(e=>e.id===t.toId);n&&r&&(u[e]={...t,path:de(n.x,n.y,n.width,r.x,r.y,r.width,r.side)})}}return{nodes:l,edges:u}}function pe(e,t,n={},r=c,i){let{padding:a=40,background:o=r.canvas.bgColor,pngSafe:s=!1}=n,l=1/0,u=-1/0,d=1/0,f=-1/0;for(let t of e)l=Math.min(l,t.x-t.width/2),u=Math.max(u,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),f=Math.max(f,t.y+t.height/2);let p=u-l+a*2,m=f-d+a*2,h=-l+a,g=-d+a,_=[];_.push(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${p}" height="${m}" viewBox="0 0 ${p} ${m}">`),t.some(e=>e.isCrossLink)&&(_.push(`<defs>`),_.push(`<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">`),_.push(`<path d="M0,0 L8,3 L0,6" fill="none" stroke="currentColor" stroke-width="1.5"/>`),_.push(`</marker>`),_.push(`</defs>`)),_.push(`<rect width="100%" height="100%" fill="${o}"/>`),_.push(`<g transform="translate(${h}, ${g})">`);for(let n of t){let t=`d="${n.path}" stroke="${n.color}" stroke-width="${r.connection.strokeWidth}" stroke-linecap="round" fill="none"`;if(n.strokeDasharray&&(t+=` stroke-dasharray="${n.strokeDasharray}"`),n.isCrossLink&&(t+=` marker-end="url(#arrowhead)" opacity="0.7"`),_.push(`<path ${t}/>`),n.label){let t=e.find(e=>e.id===n.fromId),i=e.find(e=>e.id===n.toId);if(t&&i){let e=(t.x+i.x)/2,a=(t.y+i.y)/2;_.push(`<text x="${e}" y="${a-6}" text-anchor="middle" font-size="11" fill="${n.color}" opacity="0.8" font-family="${r.node.fontFamily}">${n.label}</text>`)}}}for(let t of e){let e=t.x,n=t.y;if(t.depth===0){let{fontSize:a,fontWeight:o,fontFamily:c,textColor:l}=r.root,u=r.root.bgColor;_.push(`<g transform="translate(${e}, ${n})">`),_.push(`<rect x="${-t.width/2}" y="${-t.height/2}" width="${t.width}" height="${t.height}" rx="${t.height/2}" ry="${t.height/2}" fill="${u}"/>`),_.push(y(t.text,a,o,c,l,t.taskStatus,t.remark,i,r.highlight.textColor,r.highlight.bgColor,s)),i&&i.length>0&&_.push(re(i,t,r,i,s)),_.push(`</g>`)}else{let a=t.depth===1?r.level1.fontSize:r.node.fontSize,o=t.depth===1?r.level1.fontWeight:r.node.fontWeight,c=t.width-r.node.paddingH*2,l=a/2+4;_.push(`<g transform="translate(${e}, ${n})">`),_.push(y(t.text,a,o,r.node.fontFamily,r.node.textColor,t.taskStatus,t.remark,i,r.highlight.textColor,r.highlight.bgColor,s)),_.push(`<line x1="${-c/2}" y1="${l}" x2="${c/2}" y2="${l}" stroke="${t.color}" stroke-width="2.5" stroke-linecap="round"/>`),i&&i.length>0&&_.push(re(i,t,r,i,s)),_.push(`</g>`)}}return i&&i.length>0&&_.push(ie(i,e,t,r)),_.push(`</g>`),_.push(`</svg>`),_.join(`
|
|
2
|
-
`)}var me=pe;function he(e,t={}){let n=typeof window<`u`?Math.max(window.devicePixelRatio??1,2):2,{scale:r=n}=t;return new Promise((t,n)=>{let i=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,a=parseFloat(i.getAttribute(`width`)||`800`),o=parseFloat(i.getAttribute(`height`)||`600`),s=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),c=URL.createObjectURL(s),l=new Image;l.onload=()=>{let e=document.createElement(`canvas`);e.width=a*r,e.height=o*r;let i=e.getContext(`2d`);i.scale(r,r),i.drawImage(l,0,0,a,o),URL.revokeObjectURL(c),e.toBlob(e=>{e?t(e):n(Error(`Failed to create PNG blob`))},`image/png`)},l.onerror=()=>{URL.revokeObjectURL(c),n(Error(`Failed to load SVG image`))},l.src=c})}function U(e){let t=e.match(/^\[([ x\-])\]\s+(.*)/);if(!t)return{text:e};let n=t[1],r=t[2];return n===` `?{taskStatus:`todo`,text:r}:n===`x`?{taskStatus:`done`,text:r}:n===`-`?{taskStatus:`doing`,text:r}:{text:e}}function W(e,t){let n=t&&t.length>0?t:void 0,r=n?{lines:[],frontMatter:{}}:void 0,i=e;n&&r&&(i=C(n,i,r));let a=i.split(`
|
|
3
|
-
`)
|
|
4
|
-
`)
|
|
5
|
-
`)}:{}};
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.OpenMindMap={},e.React,e.ReactJSXRuntime))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FFEAA7`,`#DDA0DD`,`#98D8C8`,`#F7DC6F`,`#BB8FCE`,`#F0B27A`],i={root:{fontSize:20,fontWeight:600,fontFamily:`system-ui, 'Segoe UI', Roboto, sans-serif`,paddingH:24,paddingV:12},node:{fontSize:15,fontWeight:400,fontFamily:`system-ui, 'Segoe UI', Roboto, sans-serif`,paddingH:8,paddingV:6},level1:{fontSize:16,fontWeight:500},connection:{strokeWidth:2.5},layout:{horizontalGap:80,verticalGap:16}},a={...i,root:{...i.root,bgColor:`#2C3E50`,textColor:`#FFFFFF`},node:{...i.node,textColor:`#333333`},canvas:{bgColor:`#fafafa`},controls:{bgColor:`rgba(255, 255, 255, 0.9)`,textColor:`#555`,hoverBg:`rgba(0, 0, 0, 0.08)`,activeBg:`rgba(0, 0, 0, 0.08)`},contextMenu:{bgColor:`rgba(255, 255, 255, 0.95)`,textColor:`#333`,hoverBg:`rgba(0, 0, 0, 0.06)`,borderColor:`rgba(0, 0, 0, 0.08)`,shadowColor:`rgba(0, 0, 0, 0.15)`},addBtn:{fill:`rgba(200, 200, 220, 0.6)`,hoverFill:`rgba(180, 180, 200, 0.8)`,iconColor:`#666`},selection:{strokeColor:`#4A90D9`,fillColor:`rgba(74, 144, 217, 0.08)`},highlight:{textColor:`#fac800`,bgColor:`rgba(252, 211, 77, 0.2)`}},o={...i,root:{...i.root,bgColor:`#4A6FA5`,textColor:`#FFFFFF`},node:{...i.node,textColor:`#E0E0E0`},canvas:{bgColor:`#1a1a2e`},controls:{bgColor:`rgba(30, 30, 45, 0.9)`,textColor:`#ccc`,hoverBg:`rgba(255, 255, 255, 0.1)`,activeBg:`rgba(255, 255, 255, 0.12)`},contextMenu:{bgColor:`rgba(35, 35, 50, 0.95)`,textColor:`#ddd`,hoverBg:`rgba(255, 255, 255, 0.08)`,borderColor:`rgba(255, 255, 255, 0.1)`,shadowColor:`rgba(0, 0, 0, 0.4)`},addBtn:{fill:`rgba(100, 100, 130, 0.6)`,hoverFill:`rgba(120, 120, 150, 0.8)`,iconColor:`#aaa`},selection:{strokeColor:`#5B9BD5`,fillColor:`rgba(91, 155, 213, 0.15)`},highlight:{textColor:`#fcd34d`,bgColor:`rgba(251, 191, 36, 0.2)`}};function s(e){return e===`dark`?o:a}var c=a;function l(e,t=r){let n={"--mindmap-canvas-bg":e.canvas.bgColor,"--mindmap-root-bg":e.root.bgColor,"--mindmap-root-text":e.root.textColor,"--mindmap-root-font-size":`${e.root.fontSize}px`,"--mindmap-root-font-weight":String(e.root.fontWeight),"--mindmap-root-font-family":e.root.fontFamily,"--mindmap-node-text":e.node.textColor,"--mindmap-node-font-size":`${e.node.fontSize}px`,"--mindmap-node-font-weight":String(e.node.fontWeight),"--mindmap-node-font-family":e.node.fontFamily,"--mindmap-level1-font-size":`${e.level1.fontSize}px`,"--mindmap-level1-font-weight":String(e.level1.fontWeight),"--mindmap-edge-width":String(e.connection.strokeWidth),"--mindmap-selection-stroke":e.selection.strokeColor,"--mindmap-selection-fill":e.selection.fillColor,"--mindmap-highlight-text":e.highlight.textColor,"--mindmap-highlight-bg":e.highlight.bgColor,"--mindmap-addbtn-fill":e.addBtn.fill,"--mindmap-addbtn-hover":e.addBtn.hoverFill,"--mindmap-addbtn-icon":e.addBtn.iconColor,"--mindmap-controls-bg":e.controls.bgColor,"--mindmap-controls-text":e.controls.textColor,"--mindmap-controls-hover":e.controls.hoverBg,"--mindmap-ctx-bg":e.contextMenu.bgColor,"--mindmap-ctx-text":e.contextMenu.textColor,"--mindmap-ctx-hover":e.contextMenu.hoverBg,"--mindmap-ctx-border":e.contextMenu.borderColor,"--mindmap-ctx-shadow":e.contextMenu.shadowColor};for(let e=0;e<t.length;e++)n[`--mindmap-branch-${e}`]=t[e];return n}function u(e){return[`.mindmap-edge { stroke-width: ${e.connection.strokeWidth}; stroke-linecap: round; fill: none; }`,`.mindmap-node-underline { stroke-width: 2.5; stroke-linecap: round; }`,`.mindmap-code-bg { fill: rgba(128,128,128,0.12); }`,`.mindmap-highlight-bg { fill: ${e.highlight.bgColor}; }`,`.mindmap-edge-label { pointer-events: none; font-family: ${e.node.fontFamily}; }`].join(`
|
|
2
|
+
`)}var d="!\\[([^\\]]*)\\]\\(([^)]+)\\)|\\[([^\\]]+)\\]\\(([^)]+)\\)|`([^`]+)`|\\*\\*(.+?)\\*\\*|\\*(.+?)\\*|~~(.+?)~~|==(.+?)==";function f(e,t){let n=[],r=d,i=[];if(t&&t.length>0){let e=[];for(let n of t)if(n.inlineTokenPattern){let{pattern:t,priority:r}=n.inlineTokenPattern();e.push({plugin:n,pattern:t,priority:r})}e.sort((e,t)=>e.priority-t.priority);let n=0;for(let t of e){let e=p(t.pattern);i.push({plugin:t.plugin,groupOffset:n,pattern:t.pattern}),n+=e}i.length>0&&(r=i.map(e=>e.pattern).join(`|`)+"|!\\[([^\\]]*)\\]\\(([^)]+)\\)|\\[([^\\]]+)\\]\\(([^)]+)\\)|`([^`]+)`|\\*\\*(.+?)\\*\\*|\\*(.+?)\\*|~~(.+?)~~|==(.+?)==")}let a=new RegExp(r,`g`),o=i.reduce((e,t)=>e+p(t.pattern),0),s=0,c;for(;(c=a.exec(e))!==null;){c.index>s&&n.push({type:`text`,content:e.slice(s,c.index)});let t=!1;if(i.length>0)for(let e of i){let r=e.groupOffset+1,i=p(e.pattern),a=!1;for(let e=r;e<r+i;e++)if(c[e]!==void 0){a=!0;break}if(a&&e.plugin.createInlineToken){let r=e.plugin.createInlineToken(c,e.groupOffset);if(r){n.push(r),t=!0;break}}}if(!t){let e=o,t=t=>c[e+t];t(1)!==void 0||t(2)!==void 0?n.push({type:`image`,alt:t(1)??``,url:t(2)}):t(3)===void 0?t(5)===void 0?t(6)===void 0?t(7)===void 0?t(8)===void 0?t(9)!==void 0&&n.push({type:`highlight`,content:t(9)}):n.push({type:`strikethrough`,content:t(8)}):n.push({type:`italic`,content:t(7)}):n.push({type:`bold`,content:t(6)}):n.push({type:`code`,content:t(5)}):n.push({type:`link`,text:t(3),url:t(4)})}s=c.index+c[0].length}return s<e.length&&n.push({type:`text`,content:e.slice(s)}),n.length===0&&n.push({type:`text`,content:e}),n}function p(e){let t=0;for(let n=0;n<e.length;n++){if(e[n]===`\\`){n++;continue}e[n]===`(`&&e[n+1]!==`?`&&t++}return t}function m(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/~~(.+?)~~/g,`$1`).replace(/==(.+?)==/g,`$1`).replace(/\$\$(.+?)\$\$/g,`$1`).replace(/\$([^$]+?)\$/g,`$1`)}var h=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`,g=null;function _(){return g||=document.createElement(`canvas`).getContext(`2d`),g}function v(e,t,n,r){let i=_();return i.font=`${n} ${t}px ${r}`,i.measureText(e).width}function y(e,t,n,r){let i=[],a=0;for(let o of e){let e;switch(o.type){case`bold`:e=v(o.content,t,700,r);break;case`code`:e=v(o.content,t*.88,400,h);break;case`link`:e=v(o.text,t,n,r);break;case`image`:e=v(`[${o.alt||`image`}]`,t,n,r);break;case`latex-inline`:case`latex-block`:e=v(o.content,t*.9,n,h);break;default:e=v(`content`in o?o.content:``,t,n,r);break}i.push({token:o,x:a,width:e}),a+=e}return i}function b(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function x(e,t,n,r,i,a,o,s,c,l,u){let d=y(f(e,s),t,n,r),p=d.length>0?d[d.length-1].x+d[d.length-1].width:0,m=t*.85,h=a?m+(a?4:0):0,g=t*.7,_=o?4:0,v=o?g+_:0,b=-(h+p+v)/2,x=b+h,w=[];a&&(w.push(`<g transform="translate(${b}, ${-m/2})">`),w.push(C(a,m)),w.push(`</g>`));let T=-t/2-2,E=t+4;for(let e of d)e.token.type===`code`?w.push(`<rect x="${x+e.x-2}" y="${T}" width="${e.width+4}" height="${E}" rx="3" fill="rgba(128,128,128,0.12)"/>`):e.token.type===`highlight`&&w.push(`<rect x="${x+e.x-1}" y="${T}" width="${e.width+2}" height="${E}" rx="2" fill="${l||`rgba(255,213,79,0.3)`}"/>`);w.push(`<text text-anchor="start" dominant-baseline="central" x="${x}" fill="${i}" font-size="${t}" font-weight="${n}" font-family="${r}">`);for(let e of d)w.push(S(e.token,s,c,u));return w.push(`</text>`),o&&w.push(`<text x="${x+p+_}" text-anchor="start" dominant-baseline="central" font-size="${g}" opacity="0.5">💬</text>`),w.join(``)}function S(e,t,n,r){switch(e.type){case`bold`:return`<tspan font-weight="700">${b(e.content)}</tspan>`;case`italic`:return`<tspan font-style="italic">${b(e.content)}</tspan>`;case`strikethrough`:return`<tspan text-decoration="line-through" opacity="0.6">${b(e.content)}</tspan>`;case`code`:return`<tspan font-family="${h}" font-size="0.88em">${b(e.content)}</tspan>`;case`highlight`:return`<tspan fill="${n||`#FFEB3B`}">${b(e.content)}</tspan>`;case`link`:return`<a href="${b(e.url)}" target="_blank"><tspan fill="#2563EB" text-decoration="underline">${b(e.text)}</tspan></a>`;case`image`:return`<tspan font-style="italic">[${b(e.alt||`image`)}]</tspan>`;case`latex-inline`:case`latex-block`:if(t){for(let n of t)if(n.exportInlineToken){let t=n.exportInlineToken({token:e,x:0,width:0},r);if(t)return t}}return`<tspan font-family="${h}" font-style="italic" font-size="0.9em">${b(e.content)}</tspan>`;default:return b(e.content)}}function C(e,t){return e===`done`?`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="#22C55E"/><path d="M${t*.28} ${t*.5}L${t*.44} ${t*.66}L${t*.72} ${t*.34}" stroke="white" stroke-width="${t*.13}" stroke-linecap="round" stroke-linejoin="round" fill="none"/>`:e===`doing`?`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="none" stroke="#FBBF24" stroke-width="${t*.1}"/><rect x="${t*.25}" y="${t*.25}" width="${t*.5}" height="${t*.5}" rx="${t*.1}" fill="#FBBF24" opacity="0.6"/>`:`<rect x="0" y="0" width="${t}" height="${t}" rx="${t*.2}" fill="none" stroke="#999" stroke-width="${t*.1}" opacity="0.4"/>`}function w(e,t,n,r,i,a,o,s,c,l){let u=y(f(e,o),t,n,r),d=-(u.length>0?u[u.length-1].x+u[u.length-1].width:0)/2,p=[],m=a-t/2-2,h=t+4;for(let e of u)e.token.type===`code`?p.push(`<rect x="${d+e.x-2}" y="${m}" width="${e.width+4}" height="${h}" rx="3" fill="rgba(128,128,128,0.12)"/>`):e.token.type===`highlight`&&p.push(`<rect x="${d+e.x-1}" y="${m}" width="${e.width+2}" height="${h}" rx="2" fill="${c||`rgba(255,213,79,0.3)`}"/>`);let g=l===void 0?``:` opacity="${l}"`;p.push(`<text x="${d}" y="${a}" text-anchor="start" dominant-baseline="central" fill="${i}" font-size="${t}" font-weight="${n}" font-family="${r}"${g}>`);for(let e of u)p.push(S(e.token,o,s));return p.push(`</text>`),p.join(``)}function T(e,t,n){for(let r of e)r.preParseMarkdown&&(t=r.preParseMarkdown(t,n));return t}function E(e,t,n,r){for(let i of e)if(i.parseLine){let e=i.parseLine(t,n,r);if(e)return e}return null}function D(e,t,n,r,i){let a=0;for(let o of e)if(o.collectFollowLines){let e=o.collectFollowLines(t,n+a,r,i);a+=e}return a}function O(e,t,n,r){for(let i of e)i.transformNodeData&&(t=i.transformNodeData(t,n,r));return t}function k(e,t,n){for(let r of e)r.postParseTree&&(t=r.postParseTree(t,n));return t}function A(e,t){let n=``;for(let r of e)if(r.serializePreamble){let e=r.serializePreamble(t);e&&(n+=e)}return n}function ee(e,t,n){let r=n;for(let n of e)if(n.serializeListMarker){let e=n.serializeListMarker(t,r);if(e!==r){r=e;break}}return r}function j(e,t,n){for(let r of e)r.serializeNodeText&&(n=r.serializeNodeText(t,n));return n}function M(e,t,n){let r=[];for(let i of e)if(i.serializeFollowLines){let e=i.serializeFollowLines(t,n);e&&r.push(...e)}return r}function te(e,t,n,r,i){for(let a of e)if(a.adjustNodeSize){let e=a.adjustNodeSize(t,n,r,i);n=e.width,r=e.height}return{width:n,height:r}}function N(e,t,n,r){for(let i of e)i.filterChildren&&(n=i.filterChildren(t,n,r));return n}function ne(e,t,n,r){for(let i of e)i.transformEdge&&(t=i.transformEdge(t,n,r));return t}function P(e,t,n,r){let i=[];for(let a of e)a.generateExtraEdges&&i.push(...a.generateExtraEdges(t,n,r));return i}function F(e,t,n,r){let i={};for(let a of e)if(a.transformNodeColor){let e=a.transformNodeColor(t,n,r);i={...i,...e}}return i}function re(e,t,n){let r=[];for(let i of e)if(i.renderNodeDecoration){let e=i.renderNodeDecoration(t,n);e&&r.push(e)}return r}function ie(e,t,n){for(let r of e)if(r.renderInlineToken){let e=r.renderInlineToken(t,n);if(e)return e}return null}function ae(e,t,n,r){let i=[];for(let a of e)if(a.renderOverlay){let e=a.renderOverlay(t,n,r);e&&i.push(e)}return i}function oe(e,t,n,r,i){let a=``;for(let o of e)o.exportNodeDecoration&&(a+=o.exportNodeDecoration(t,n,r,i));return a}function se(e,t,n,r){let i=``;for(let a of e)a.exportOverlay&&(i+=a.exportOverlay(t,n,r));return i}var ce=null;function le(){return ce||=document.createElement(`canvas`).getContext(`2d`),ce}function ue(e,t,n,r){let i=le();return i.font=`${n} ${t}px ${r||c.root.fontFamily}`,i.measureText(e).width}var de=4,I=20;function fe(e,t,n,r,i){let a=ue(m(e),t,n);return r&&(a+=t*.9+de),i&&(a+=I),a}function L(e,t,n,i,a,o,s,l){let u=t===0,d=t===1,f=u?c.root.fontSize:d?c.level1.fontSize:c.node.fontSize,p=u?c.root.fontWeight:d?c.level1.fontWeight:c.node.fontWeight,m=u?c.root.paddingH:c.node.paddingH,h=u?c.root.paddingV:c.node.paddingV,g=fe(e.text,f,p,e.taskStatus,!!e.remark)+m*2,_=f+h*2;if(o&&o.length>0){let t=te(o,e,g,_,f);g=t.width,_=t.height}let v=e.children||[];o&&o.length>0&&s&&(v=N(o,e,v,s));let y=i;if(o&&o.length>0){let r=F(o,{id:e.id,text:e.text,x:0,y:0,width:g,height:_,color:i,depth:t,side:n,parentId:a},e,i);r.color&&(y=r.color)}let b=v.map((i,a)=>{let c=u?r[a%r.length]:y,d=u?a%r.length:l;return L(i,t+1,n,c,e.id,o,s,d)});return{id:e.id,text:e.text,children:b,width:g,height:_,depth:t,side:n,color:y,x:0,y:0,subtreeHeight:0,parentId:a,remark:e.remark,taskStatus:e.taskStatus,branchIndex:l,dottedLine:e.dottedLine,multiLineContent:e.multiLineContent,tags:e.tags,anchorId:e.anchorId,crossLinks:e.crossLinks,collapsed:e.collapsed}}function R(e){if(e.children.length===0)return e.subtreeHeight=e.height,e.height;let t=e.children.reduce((e,t)=>e+R(t),0)+(e.children.length-1)*c.layout.verticalGap;return e.subtreeHeight=Math.max(e.height,t),e.subtreeHeight}function z(e,t,n){if(e.x=t,e.y=n,e.children.length===0)return;let r=e.side===`left`?-1:1,i=n-(e.children.reduce((e,t)=>e+t.subtreeHeight,0)+(e.children.length-1)*c.layout.verticalGap)/2;for(let n of e.children){let a=i+n.subtreeHeight/2;z(n,t+r*(e.width/2+c.layout.horizontalGap+n.width/2),a),i+=n.subtreeHeight+c.layout.verticalGap}}function pe(e,t){t.push({id:e.id,text:e.text,x:e.x,y:e.y,width:e.width,height:e.height,color:e.color,depth:e.depth,side:e.side,parentId:e.parentId,remark:e.remark,taskStatus:e.taskStatus,branchIndex:e.branchIndex,dottedLine:e.dottedLine,multiLineContent:e.multiLineContent,tags:e.tags,anchorId:e.anchorId,crossLinks:e.crossLinks,collapsed:e.collapsed});for(let n of e.children)pe(n,t)}function me(e,t,n,r,i,a,o){let s=o===`left`?-1:1,c=e+n/2*s,l=t,u=r-a/2*s,d=i,f=c+(u-c)*.5;return`M ${c},${l} C ${f},${l} ${f},${d} ${u},${d}`}function B(e,t,n,r){for(let i of e.children){let a={key:`${e.id}-${i.id}`,path:me(e.x,e.y,e.width,i.x,i.y,i.width,i.side),color:i.color,fromId:e.id,toId:i.id};if(r&&r.length>0){let t=n.find(t=>t.id===e.id),o=n.find(e=>e.id===i.id);t&&o&&(a=ne(r,a,t,o))}t.push(a),B(i,t,n,r)}}function V(e,t=`both`,n,i,a,o,s){let l=a&&a.length>0?{direction:t,theme:c,readonly:!!o,foldOverrides:s||{}}:void 0,u=e.children||[],d,f,p;t===`right`?(d=u,f=[],p=u.length):t===`left`?(d=[],f=u,p=0):(p=i??Math.ceil(u.length/2),p=Math.min(Math.max(p,0),u.length),d=u.slice(0,p),f=u.slice(p));let m=L({...e,children:[]},0,`root`,c.root.bgColor,void 0,a,l),h=d.map((t,i)=>{let o=i%r.length;return L(t,1,`right`,n?.[t.id]??r[o],e.id,a,l,o)}),g=f.map((i,o)=>{let s=((t===`left`?0:p)+o)%r.length;return L(i,1,`left`,n?.[i.id]??r[s],e.id,a,l,s)});m.children=[...h,...g];for(let e of m.children)R(e);m.x=0,m.y=0;let _=m.children.filter(e=>e.side===`right`),v=m.children.filter(e=>e.side===`left`),y=(e,t)=>{let n=-(e.reduce((e,t)=>e+t.subtreeHeight,0)+Math.max(0,e.length-1)*c.layout.verticalGap)/2;for(let r of e){let e=n+r.subtreeHeight/2;z(r,t*(m.width/2+c.layout.horizontalGap+r.width/2),e),n+=r.subtreeHeight+c.layout.verticalGap}};y(_,1),y(v,-1);let b=[],x=[];if(pe(m,b),B(m,x,b,a),a&&a.length>0&&l){let t=P(a,b,[e],l);x.push(...t)}return{nodes:b,edges:x}}function he(e,t=`both`,n,r,i,a,o){if(e.length===0)return{nodes:[],edges:[]};if(e.length===1)return V(e[0],t,n,r?.[e[0].id],i,a,o);let s=e.map(e=>V(e,t,n,r?.[e.id],i,a,o)),c=s.map(e=>{let t=1/0,n=-1/0;for(let r of e.nodes)t=Math.min(t,r.y-r.height/2),n=Math.max(n,r.y+r.height/2);return{minY:t,maxY:n}}),l=[],u=[],d=c[0].maxY;for(let e of s[0].nodes)l.push(e);for(let e of s[0].edges)u.push(e);for(let e=1;e<s.length;e++){let t=d+80-c[e].minY,n=l.length;for(let n of s[e].nodes)l.push({...n,y:n.y+t});for(let t of s[e].edges){let e=l.slice(n).find(e=>e.id===t.fromId),r=l.slice(n).find(e=>e.id===t.toId);e&&r?u.push({...t,path:me(e.x,e.y,e.width,r.x,r.y,r.width,r.side)}):u.push(t)}d=d+80+(c[e].maxY-c[e].minY)}let f=-(Math.min(...l.map(e=>e.y-e.height/2))+Math.max(...l.map(e=>e.y+e.height/2)))/2;if(Math.abs(f)>.1){for(let e of l)e.y+=f;for(let e=0;e<u.length;e++){let t=u[e];if(t.isCrossLink)continue;let n=l.find(e=>e.id===t.fromId),r=l.find(e=>e.id===t.toId);n&&r&&(u[e]={...t,path:me(n.x,n.y,n.width,r.x,r.y,r.width,r.side)})}}return{nodes:l,edges:u}}function ge(e,t,n={},r=c,i){let{padding:a=40,background:o=r.canvas.bgColor,pngSafe:s=!1}=n,l=1/0,d=-1/0,f=1/0,p=-1/0;for(let t of e)l=Math.min(l,t.x-t.width/2),d=Math.max(d,t.x+t.width/2),f=Math.min(f,t.y-t.height/2),p=Math.max(p,t.y+t.height/2);let m=d-l+a*2,h=p-f+a*2,g=-l+a,_=-f+a,v=[];v.push(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${m}" height="${h}" viewBox="0 0 ${m} ${h}">`),v.push(`<defs>`),v.push(` <style>`),v.push(` ${u(r)}`),v.push(` </style>`),t.some(e=>e.isCrossLink)&&(v.push(`<marker id="arrowhead" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">`),v.push(`<path d="M0,0 L8,3 L0,6" fill="none" stroke="currentColor" stroke-width="1.5"/>`),v.push(`</marker>`)),v.push(`</defs>`),v.push(`<rect width="100%" height="100%" fill="${o}"/>`),v.push(`<g transform="translate(${g}, ${_})">`);for(let n of t){let t=e.find(e=>e.id===n.toId),r=t?.branchIndex===void 0?``:` data-branch-index="${t.branchIndex}"`,i=`class="mindmap-edge" d="${n.path}" stroke="${n.color}"${r}`;if(n.strokeDasharray&&(i+=` stroke-dasharray="${n.strokeDasharray}"`),n.isCrossLink&&(i+=` marker-end="url(#arrowhead)" opacity="0.7"`),v.push(`<path ${i}/>`),n.label){let r=e.find(e=>e.id===n.fromId);if(r&&t){let e=(r.x+t.x)/2,i=(r.y+t.y)/2;v.push(`<text class="mindmap-edge-label" x="${e}" y="${i-6}" text-anchor="middle" font-size="11" fill="${n.color}" opacity="0.8">${n.label}</text>`)}}}for(let t of e){let e=t.x,n=t.y,a=t.branchIndex===void 0?``:` data-branch-index="${t.branchIndex}"`;if(t.depth===0){let{fontSize:o,fontWeight:c,fontFamily:l,textColor:u}=r.root,d=r.root.bgColor;v.push(`<g class="mindmap-node-g mindmap-node-root" transform="translate(${e}, ${n})"${a}>`),v.push(`<rect class="mindmap-node-bg" x="${-t.width/2}" y="${-t.height/2}" width="${t.width}" height="${t.height}" rx="${t.height/2}" ry="${t.height/2}" fill="${d}"/>`),v.push(x(t.text,o,c,l,u,t.taskStatus,t.remark,i,r.highlight.textColor,r.highlight.bgColor,s)),i&&i.length>0&&v.push(oe(i,t,r,i,s)),v.push(`</g>`)}else{let o=t.depth===1?r.level1.fontSize:r.node.fontSize,c=t.depth===1?r.level1.fontWeight:r.node.fontWeight,l=t.width-r.node.paddingH*2,u=o/2+4;v.push(`<g class="mindmap-node-g mindmap-node-child" transform="translate(${e}, ${n})"${a}>`),v.push(x(t.text,o,c,r.node.fontFamily,r.node.textColor,t.taskStatus,t.remark,i,r.highlight.textColor,r.highlight.bgColor,s)),v.push(`<line class="mindmap-node-underline" x1="${-l/2}" y1="${u}" x2="${l/2}" y2="${u}" stroke="${t.color}"/>`),i&&i.length>0&&v.push(oe(i,t,r,i,s)),v.push(`</g>`)}}return i&&i.length>0&&v.push(se(i,e,t,r)),v.push(`</g>`),v.push(`</svg>`),v.join(`
|
|
3
|
+
`)}var _e=ge;function ve(e,t={}){let n=typeof window<`u`?Math.max(window.devicePixelRatio??1,2):2,{scale:r=n}=t;return new Promise((t,n)=>{let i=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,a=parseFloat(i.getAttribute(`width`)||`800`),o=parseFloat(i.getAttribute(`height`)||`600`),s=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),c=URL.createObjectURL(s),l=new Image;l.onload=()=>{let e=document.createElement(`canvas`);e.width=a*r,e.height=o*r;let i=e.getContext(`2d`);i.scale(r,r),i.drawImage(l,0,0,a,o),URL.revokeObjectURL(c),e.toBlob(e=>{e?t(e):n(Error(`Failed to create PNG blob`))},`image/png`)},l.onerror=()=>{URL.revokeObjectURL(c),n(Error(`Failed to load SVG image`))},l.src=c})}function H(e){let t=e.match(/^\[([ x-])\]\s+(.*)/);if(!t)return{text:e};let n=t[1],r=t[2];return n===` `?{taskStatus:`todo`,text:r}:n===`x`?{taskStatus:`done`,text:r}:n===`-`?{taskStatus:`doing`,text:r}:{text:e}}function ye(e,t){let n=t&&t.length>0?t:void 0,r=n?{lines:[],frontMatter:{}}:void 0,i=e;n&&r&&(i=T(n,i,r));let a=i.split(`
|
|
4
|
+
`);r&&(r.lines=a);let o=[],s=null,c=[],l=0;for(;l<a.length;){let e=a[l],t=n&&r?E(n,e,l,r):null;if(t){let e=t.text.trim(),i=t.taskStatus,{taskStatus:s,text:c}=i?{taskStatus:i,text:e}:H(e);if(c){let e={indent:t.indent,text:c,taskStatus:s,remarkLines:[],dottedLine:t.dottedLine,collapsed:t.collapsed},i=l+1;for(;i<a.length;){let t=a[i].match(/^(\s*)>\s?(.*)$/);if(t)e.remarkLines.push(t[2]),i++;else break}if(n&&r){let t={id:`temp`,text:c},o=D(n,a,i,t,r);Object.assign(e,{_pluginNode:t}),i+=o}o.push(e),l=i;continue}}let i=e.match(/^(\s*)[*-]\s+(.+)/);if(i){let e=i[1].replace(/\t/g,` `).length,{taskStatus:t,text:s}=H(i[2].trim());if(s){let i={indent:e,text:s,taskStatus:t,remarkLines:[]},c=l+1;for(;c<a.length;){let e=a[c].match(/^(\s*)>\s?(.*)$/);if(e)i.remarkLines.push(e[2]),c++;else break}if(n&&r){let e={id:`temp`,text:s},t=D(n,a,c,e,r);Object.assign(i,{_pluginNode:e}),c+=t}o.push(i),l=c;continue}}if(s===null&&o.length===0){let t=e.trim();if(t){s=t;let e=l+1;for(;e<a.length;){let t=a[e].match(/^(\s*)>\s?(.*)$/);if(t)c.push(t[2]),e++;else break}l=e;continue}}l++}if(o.length===0&&s===null)return{id:`md-0`,text:`Root`};let u=(e,t)=>{t.dottedLine&&(e={...e,dottedLine:!0}),t.collapsed&&(e={...e,collapsed:!0});let i=t._pluginNode;return i&&i.multiLineContent&&(e={...e,multiLineContent:i.multiLineContent}),n&&r&&(e=O(n,e,e.text,r)),e};if(s!==null){let e={id:`md-0`,text:s,children:[],...c.length>0?{remark:c.join(`
|
|
5
|
+
`)}:{}};if(n&&r&&(e=O(n,e,s,r)),o.length===0)return delete e.children,e;let t=2;for(let e of o)if(e.indent>0){t=e.indent;break}let i=o.map(e=>({level:e.indent>0?Math.round(e.indent/t):0,text:e.text,taskStatus:e.taskStatus,remarkLines:e.remarkLines,_item:e})),a=[[e,-1]];for(let e=0;e<i.length;e++){let{level:t,text:n,taskStatus:r,remarkLines:o,_item:s}=i[e],c={id:`md-tmp`,text:n,...r?{taskStatus:r}:{},...o.length>0?{remark:o.join(`
|
|
6
|
+
`)}:{}};for(;a.length>1&&a[a.length-1][1]>=t;)a.pop();let l=a[a.length-1][0];l.children||=[],c.id=`${l.id}-${l.children.length}`,c=u(c,s),l.children.push(c),a.push([c,t])}if(U(e),n&&r){let[t]=k(n,[e],r);return t}return e}let d=2;for(let e of o)if(e.indent>0){d=e.indent;break}let f=o.map(e=>({level:e.indent>0?Math.round(e.indent/d):0,text:e.text,taskStatus:e.taskStatus,remarkLines:e.remarkLines,_item:e})),p={id:`md-0`,text:f[0].text,children:[],...f[0].taskStatus?{taskStatus:f[0].taskStatus}:{},...f[0].remarkLines.length>0?{remark:f[0].remarkLines.join(`
|
|
6
7
|
`)}:{}};p=u(p,f[0]._item);let m=[[p,0]];for(let e=1;e<f.length;e++){let{level:t,text:n,taskStatus:r,remarkLines:i,_item:a}=f[e],o=t===0?1:t,s={id:`md-tmp`,text:n,...r?{taskStatus:r}:{},...i.length>0?{remark:i.join(`
|
|
7
|
-
`)}:{}};for(;m.length>1&&m[m.length-1][1]>=o;)m.pop();let c=m[m.length-1][0];c.children||=[];let l=c.children.length;s.id=`${c.id}-${l}`,s=u(s,a),c.children.push(s),m.push([s,o])}if(
|
|
8
|
-
`}else{let n=``;e.taskStatus&&(n={todo:`[ ]`,doing:`[-]`,done:`[x]`}[e.taskStatus]+` `);let a=`- `;r&&(a=ee(r,e,a));let o=e.text;r&&(o=
|
|
8
|
+
`)}:{}};for(;m.length>1&&m[m.length-1][1]>=o;)m.pop();let c=m[m.length-1][0];c.children||=[];let l=c.children.length;s.id=`${c.id}-${l}`,s=u(s,a),c.children.push(s),m.push([s,o])}if(U(p),n&&r){let[e]=k(n,[p],r);return e}return p}function U(e){if(e.children&&e.children.length===0)delete e.children;else if(e.children)for(let t of e.children)U(t)}function W(e,t=0,n){let r=n&&n.length>0?n:void 0,i;if(t===0){let t=e.text;r&&(t=j(r,e,t)),i=t+`
|
|
9
|
+
`}else{let n=``;e.taskStatus&&(n={todo:`[ ]`,doing:`[-]`,done:`[x]`}[e.taskStatus]+` `);let a=`- `;r&&(a=ee(r,e,a));let o=e.text;r&&(o=j(r,e,o)),i=` `.repeat(t-1)+a+n+o+`
|
|
9
10
|
`}if(e.remark){let n=t===0?` `:` `.repeat(t);for(let t of e.remark.split(`
|
|
10
11
|
`))i+=n+`> `+t+`
|
|
11
|
-
`}if(r){let n=
|
|
12
|
-
`}if(e.children)for(let r of e.children)i+=
|
|
12
|
+
`}if(r){let n=M(r,e,t),a=t===0?` `:` `.repeat(t);for(let e of n)i+=a+e+`
|
|
13
|
+
`}if(e.children)for(let r of e.children)i+=W(r,t+1,n);return i}function be(e,t){let n=t&&t.length>0?t:void 0,r=e,i=n?{lines:[],frontMatter:{}}:void 0;n&&i&&(r=T(n,r,i)),r=r.split(`
|
|
13
14
|
`).filter(e=>e.trim().length>0).join(`
|
|
14
|
-
`);let a=r.split(/\n[ \t]*\n/).filter(e=>e.trim());if(a.length===0)return[{id:`md-0`,text:`Root`}];let o=n?n.map(e=>({...e,preParseMarkdown:void 0})):void 0;if(a.length===1){let e=[
|
|
15
|
-
`);return r+i}function
|
|
15
|
+
`);let a=r.split(/\n[ \t]*\n/).filter(e=>e.trim());if(a.length===0)return[{id:`md-0`,text:`Root`}];let o=n?n.map(e=>({...e,preParseMarkdown:void 0})):void 0;if(a.length===1){let e=[ye(r,o)];return n&&i?k(n,e,i):e}let s=a.map((e,t)=>{let n=ye(e,o);return G(n,`md-${t}`),n});return n&&i?k(n,s,i):s}function G(e,t){if(e.id=t,e.children)for(let n=0;n<e.children.length;n++)G(e.children[n],`${t}-${n}`)}function xe(e,t){let n=t&&t.length>0?t:void 0,r=``;n&&(r=A(n,e));let i=e.map(e=>W(e,0,t)).join(`
|
|
16
|
+
`);return r+i}function Se(e,t){let n={lines:[],frontMatter:{}},r=T(t,e,n);r=r.split(`
|
|
16
17
|
`).filter(e=>e.trim().length>0).join(`
|
|
17
|
-
`);let i=t.map(e=>({...e,preParseMarkdown:void 0})),a=r.split(/\n[ \t]*\n/).filter(e=>e.trim());if(a.length===0)return{roots:[{id:`md-0`,text:`Root`}],frontMatter:n.frontMatter};let o;return o=a.length===1?[W(r,i)]:a.map((e,t)=>{let n=W(e,i);return q(n,`md-${t}`),n}),o=D(t,o,n),{roots:o,frontMatter:n.frontMatter}}var ye={newNode:`新节点`,zoomIn:`放大`,zoomOut:`缩小`,resetView:`重置视图`,layoutLeft:`向左排版`,layoutBoth:`左右排版`,layoutRight:`向右排版`,textMode:`文本模式`,viewMode:`视图模式`,fullscreen:`全屏`,exitFullscreen:`退出全屏`,newRootNode:`新建主节点`,export:`导出`,exportSVG:`导出为 SVG`,exportPNG:`导出为 PNG`,exportMarkdown:`导出为 Markdown`,layout:`布局`,close:`关闭`},be={newNode:`New Node`,zoomIn:`Zoom In`,zoomOut:`Zoom Out`,resetView:`Reset View`,layoutLeft:`Left Layout`,layoutBoth:`Both Layout`,layoutRight:`Right Layout`,textMode:`Text Mode`,viewMode:`View Mode`,fullscreen:`Fullscreen`,exitFullscreen:`Exit Fullscreen`,newRootNode:`New Root Node`,export:`Export`,exportSVG:`Export as SVG`,exportPNG:`Export as PNG`,exportMarkdown:`Export as Markdown`,layout:`Layout`,close:`Close`},xe={"zh-CN":ye,"en-US":be};function Se(){if(typeof navigator>`u`)return`en-US`;let e=navigator.language||``;if(xe[e])return e;if(e.startsWith(`zh`))return`zh-CN`;let t=e.split(`-`)[0];for(let e of Object.keys(xe))if(e.startsWith(t))return e;return`en-US`}function Ce(e=`zh-CN`,t){let n=xe[e]??ye;return t?{...n,...t}:n}function we(){return Date.now().toString(36)+Math.random().toString(36).slice(2,6)}function Te(e){return Array.isArray(e)?e:[e]}function Ee(e,t,n){if(e.id===t){let t={...e,...n};return`taskStatus`in n&&n.taskStatus===void 0&&delete t.taskStatus,`remark`in n&&n.remark===void 0&&delete t.remark,t}return e.children?{...e,children:e.children.map(e=>Ee(e,t,n))}:e}function De(e,t,n){return e.id===t?{...e,children:[...e.children||[],n]}:e.children?{...e,children:e.children.map(e=>De(e,t,n))}:e}function Oe(e,t){if(!e.children)return e;let n=e.children.filter(e=>e.id!==t).map(e=>Oe(e,t));return{...e,children:n.length>0?n:void 0}}function ke(e,t,n){if(!e.children)return e;let r=e.children.findIndex(e=>e.id===t),i=e.children.findIndex(e=>e.id===n);if(r!==-1&&i!==-1){let t=[...e.children];return[t[r],t[i]]=[t[i],t[r]],{...e,children:t}}return{...e,children:e.children.map(e=>ke(e,t,n))}}function Ae(e,t){if(e.id===t)return structuredClone(e);if(!e.children)return null;for(let n of e.children){let e=Ae(n,t);if(e)return e}return null}function je(e){return{...e,id:we(),children:e.children?.map(e=>je(e))}}function Me(e,t){let n={};for(let e of t)e.parentId&&(n[e.parentId]||(n[e.parentId]=[]),n[e.parentId].push(e.id));let r=[],i=[e];for(;i.length>0;){let e=n[i.pop()];if(e)for(let t of e)r.push(t),i.push(t)}return r}function Ne(e,t,n){return e.map(e=>Ee(e,t,n))}function Pe(e,t,n){return e.map(e=>De(e,t,n))}function Fe(e,t){let n=e.filter(e=>e.id!==t);return n.length<e.length?n:e.map(e=>Oe(e,t))}function J(e,t,n){return e.map(e=>ke(e,t,n))}function Ie(e,t){for(let n of e){let e=Ae(n,t);if(e)return e}return null}function Le(e,t,n,r){let i=[...e.children||[]],a=Math.min(r,i.length);return n===`right`?(i.splice(a,0,t),{data:{...e,children:i},newSplitIndex:a+1}):(i.push(t),{data:{...e,children:i},newSplitIndex:a})}function Re(e,t,n,r){let i=e.children||[],a=i.findIndex(e=>e.id===t);if(a===-1)return null;let o=Math.min(Math.max(r,0),i.length);if(n===`right`&&a<o||n===`left`&&a>=o)return null;let s=[...i],[c]=s.splice(a,1);return n===`left`?(s.push(c),{data:{...e,children:s},newSplitIndex:o-1}):(s.splice(o,0,c),{data:{...e,children:s},newSplitIndex:o+1})}var ze=typeof window<`u`?window.matchMedia(`(prefers-color-scheme: dark)`):null;function Be(e){return ze?.addEventListener(`change`,e),()=>ze?.removeEventListener(`change`,e)}function Ve(){return ze?.matches??!1}function He(e=`auto`){let n=(0,t.useSyncExternalStore)(Be,Ve,()=>!1),r=e===`auto`?n?`dark`:`light`:e;return(0,t.useMemo)(()=>s(r),[r])}function Ue(e,n){let[r,i]=(0,t.useState)({x:0,y:0}),[a,o]=(0,t.useState)(1),s=(0,t.useRef)(0),c=(0,t.useRef)(a),l=(0,t.useRef)(r);c.current=a,l.current=r;let u=(0,t.useMemo)(()=>{if(n.length===0)return{x:0,y:0};let e=1/0,t=-1/0,r=1/0,i=-1/0;for(let a of n)e=Math.min(e,a.x-a.width/2),t=Math.max(t,a.x+a.width/2),r=Math.min(r,a.y-a.height/2),i=Math.max(i,a.y+a.height/2);return{x:(e+t)/2,y:(r+i)/2}},[n]),d=(0,t.useCallback)((e,t,n)=>{cancelAnimationFrame(s.current);let r=c.current,a=l.current.x,u=l.current.y,d=performance.now(),f=c=>{let l=c-d,p=Math.min(l/200,1),m=1-(1-p)**3;o(r+(e-r)*m),i({x:a+(t-a)*m,y:u+(n-u)*m}),p<1&&(s.current=requestAnimationFrame(f))};s.current=requestAnimationFrame(f)},[]),f=(0,t.useCallback)(()=>{let t=e.current;if(!t||n.length===0)return;let r=t.clientWidth,i=t.clientHeight,a=1/0,o=-1/0,s=1/0,c=-1/0;for(let e of n)a=Math.min(a,e.x-e.width/2),o=Math.max(o,e.x+e.width/2),s=Math.min(s,e.y-e.height/2),c=Math.max(c,e.y+e.height/2);let l=o-a,u=c-s,d=Math.min((r-120)/l,(i-120)/u,1.5),f=(a+o)/2,p=(s+c)/2;return{zoom:d,panX:r/2-f*d,panY:i/2-p*d}},[e,n]);return(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientX-n.left,a=e.clientY-n.top,s=e.deltaY>0?.9:1.1,u=Math.min(Math.max(c.current*s,.1),5);i({x:r-(r-l.current.x)*(u/c.current),y:a-(a-l.current.y)*(u/c.current)}),o(u)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[e]),{pan:r,setPan:i,zoom:a,setZoom:o,animateTo:d,autoFit:f,zoomIn:(0,t.useCallback)(()=>{let t=Math.min(c.current*1.2,5),n=e.current,r=n.clientWidth/2,i=n.clientHeight/2;d(t,r-(r-l.current.x)*(t/c.current),i-(i-l.current.y)*(t/c.current))},[e,d]),zoomOut:(0,t.useCallback)(()=>{let t=Math.max(c.current*.8,.1),n=e.current,r=n.clientWidth/2,i=n.clientHeight/2;d(t,r-(r-l.current.x)*(t/c.current),i-(i-l.current.y)*(t/c.current))},[e,d]),contentCenter:u,panToNode:(0,t.useCallback)(t=>{let r=e.current;if(!r)return;let i=n.find(e=>e.id===t);if(!i)return;let a=r.clientWidth,o=r.clientHeight,s=i.x*c.current+l.current.x,u=i.y*c.current+l.current.y;s>100&&s<a-100&&u>100&&u<o-100||d(c.current,a/2-i.x*c.current,o/2-i.y*c.current)},[e,n,d])}}function We({svgRef:e,zoom:n,pan:r,setPan:i,setZoom:a,nodeMap:o,nodes:s,updateData:c,direction:l,splitIndices:u,setSplitIndices:d,mapData:f,contentCenter:p}){let[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)(null),b=(0,t.useRef)({x:0,y:0,panX:0,panY:0}),x=(0,t.useRef)({x:0,y:0}),S=(0,t.useRef)(!1),C=(0,t.useRef)(0),w=(0,t.useRef)({type:`none`,startPan:{x:0,y:0},startZoom:1,startTouches:[],pinchDistance:0,contentCenter:{x:0,y:0},touchNodeId:null}),T=(0,t.useMemo)(()=>{if(!g)return new Set;let e=new Set([g]);for(let t of Me(g,s))e.add(t);return e},[g,s]),E=(0,t.useCallback)((t,i)=>{let a=e.current.getBoundingClientRect();return{x:(t-a.left-r.x)/n,y:(i-a.top-r.y)/n}},[e,r,n]),D=(0,t.useCallback)((e,t,n)=>{let r=E(e,t),i={x:r.x+x.current.x,y:r.y+x.current.y};y(i);let a=Date.now();if(a-C.current>500){let e=o[n];if(e&&e.parentId){if(e.depth===1&&l===`both`){let t=e.side,r=t===`right`&&i.x<0,o=t===`left`&&i.x>0;if(r||o){let t=r?`left`:`right`,i=e.parentId,o=f.find(e=>e.id===i);if(o){let e=Re(o,n,t,u[i]??Math.ceil((o.children?.length??0)/2));if(e){C.current=a,d(t=>({...t,[i]:e.newSplitIndex})),c(t=>t.map(t=>t.id===i?e.data:t));return}}}}let t=s.filter(t=>t.parentId===e.parentId&&t.id!==n&&t.side===e.side);for(let r of t){let t=Math.max(e.height,r.height)*.6;if(Math.abs(i.y-r.y)<t){C.current=a,c(e=>J(e,n,r.id));break}}}}},[E,o,s,c,l,u,d,f]),O=(0,t.useCallback)(e=>{e.button===0&&(S.current=!1,h(!0),b.current={x:e.clientX,y:e.clientY,panX:r.x,panY:r.y})},[r]),ee=(0,t.useCallback)(e=>{m?(S.current=!0,i({x:b.current.panX+(e.clientX-b.current.x),y:b.current.panY+(e.clientY-b.current.y)})):g&&(S.current=!0,D(e.clientX,e.clientY,g))},[m,g,i,D]),k=(0,t.useCallback)(()=>{h(!1),_(null),y(null)},[]),te=(0,t.useCallback)((e,t)=>{if(e.stopPropagation(),e.button!==0)return;S.current=!1;let n=o[t];if(!n)return;_(t),y({x:n.x,y:n.y});let r=E(e.clientX,e.clientY);x.current={x:n.x-r.x,y:n.y-r.y}},[o,E]),A=(0,t.useRef)(r),j=(0,t.useRef)(n),M=(0,t.useRef)(o),N=(0,t.useRef)(p),P=(0,t.useRef)(g);(0,t.useEffect)(()=>{A.current=r,j.current=n,M.current=o,N.current=p,P.current=g});let F=(0,t.useCallback)(t=>{let n=t;for(;n&&n!==e.current;){if(n.classList?.contains(`mindmap-node-g`)){let e=n.getAttribute(`transform`);if(e)for(let t of s){let n=t.x,r=t.y;if(e.includes(`translate(${n}`)&&e.includes(`${r})`))return t.id}}n=n.parentElement}return null},[e,s]);return(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let n=t;function r(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)}function o(e){e.preventDefault();let t=e.touches;if(t.length===2){let e=r(t[0],t[1]);w.current={type:`pinch`,startPan:{...A.current},startZoom:j.current,startTouches:[{id:t[0].identifier,x:t[0].clientX,y:t[0].clientY},{id:t[1].identifier,x:t[1].clientX,y:t[1].clientY}],pinchDistance:e,contentCenter:{...N.current},touchNodeId:null},P.current&&(_(null),y(null)),h(!1);return}if(t.length===1){let r=t[0],i=F(e.target);if(i){let t=e.target;for(;t&&t!==n;){if(t.classList?.contains(`mindmap-add-btn`))return;t=t.parentElement}S.current=!1;let a=M.current[i];if(a){_(i),y({x:a.x,y:a.y});let e=n.getBoundingClientRect(),t=(r.clientX-e.left-A.current.x)/j.current,o=(r.clientY-e.top-A.current.y)/j.current;x.current={x:a.x-t,y:a.y-o},w.current={type:`node-drag`,startPan:{...A.current},startZoom:j.current,startTouches:[{id:r.identifier,x:r.clientX,y:r.clientY}],pinchDistance:0,contentCenter:{...N.current},touchNodeId:i}}}else S.current=!1,h(!0),b.current={x:r.clientX,y:r.clientY,panX:A.current.x,panY:A.current.y},w.current={type:`canvas-pan`,startPan:{...A.current},startZoom:j.current,startTouches:[{id:r.identifier,x:r.clientX,y:r.clientY}],pinchDistance:0,contentCenter:{...N.current},touchNodeId:null}}}function p(e){e.preventDefault();let t=w.current,o=e.touches;if(t.type===`pinch`&&o.length>=2){let e=r(o[0],o[1])/t.pinchDistance,s=Math.min(Math.max(t.startZoom*e,.1),5),c=n.clientWidth/2,l=n.clientHeight/2,u=t.contentCenter;a(s),i({x:c-u.x*s,y:l-u.y*s});return}if(t.type===`canvas-pan`&&o.length===1){S.current=!0;let e=o[0];i({x:b.current.panX+(e.clientX-b.current.x),y:b.current.panY+(e.clientY-b.current.y)});return}if(t.type===`node-drag`&&o.length===1&&t.touchNodeId){S.current=!0;let e=o[0],r=n.getBoundingClientRect(),i=(e.clientX-r.left-A.current.x)/j.current,a=(e.clientY-r.top-A.current.y)/j.current,p={x:i+x.current.x,y:a+x.current.y};y(p);let m=Date.now();if(m-C.current>500){let e=M.current[t.touchNodeId];if(e&&e.parentId){if(e.depth===1&&l===`both`){let n=e.side,r=n===`right`&&p.x<0,i=n===`left`&&p.x>0;if(r||i){let n=r?`left`:`right`,i=e.parentId,a=f.find(e=>e.id===i);if(a){let e=u[i]??Math.ceil((a.children?.length??0)/2),r=Re(a,t.touchNodeId,n,e);if(r){C.current=m,d(e=>({...e,[i]:r.newSplitIndex})),c(e=>e.map(e=>e.id===i?r.data:e));return}}}}let n=s.filter(n=>n.parentId===e.parentId&&n.id!==t.touchNodeId&&n.side===e.side);for(let r of n){let n=Math.max(e.height,r.height)*.6;if(Math.abs(p.y-r.y)<n){C.current=m,c(e=>J(e,t.touchNodeId,r.id));break}}}}return}}function m(e){e.preventDefault();let t=w.current,n=e.touches;if(t.type===`pinch`&&n.length===1){let e=n[0];b.current={x:e.clientX,y:e.clientY,panX:A.current.x,panY:A.current.y},h(!0),w.current={...t,type:`canvas-pan`,startTouches:[{id:e.identifier,x:e.clientX,y:e.clientY}]};return}n.length===0&&(h(!1),_(null),y(null),w.current={type:`none`,startPan:{x:0,y:0},startZoom:1,startTouches:[],pinchDistance:0,contentCenter:{x:0,y:0},touchNodeId:null})}return n.addEventListener(`touchstart`,o,{passive:!1}),n.addEventListener(`touchmove`,p,{passive:!1}),n.addEventListener(`touchend`,m,{passive:!1}),n.addEventListener(`touchcancel`,m,{passive:!1}),()=>{n.removeEventListener(`touchstart`,o),n.removeEventListener(`touchmove`,p),n.removeEventListener(`touchend`,m),n.removeEventListener(`touchcancel`,m)}},[e,i,a,F,l,f,u,d,c,s]),{draggingCanvas:m,floatingNodeId:g,floatingPos:v,floatingSubtreeIds:T,didDragRef:S,handleCanvasMouseDown:O,handleMouseMove:ee,handleMouseUp:k,handleNodeMouseDown:te}}function Ge(e){let t=e.match(/^\[([ x\-])\]\s+(.*)/);if(!t)return{text:e};let n=t[1],r=t[2];return n===` `?{taskStatus:`todo`,text:r}:n===`x`?{taskStatus:`done`,text:r}:n===`-`?{taskStatus:`doing`,text:r}:{text:e}}function Ke({nodeMap:e,updateData:n,onTextChange:r}){let[i,a]=(0,t.useState)(null),[o,s]=(0,t.useState)(``),[c,l]=(0,t.useState)(null);return(0,t.useEffect)(()=>{c&&e[c]&&(a(c),s(``),l(null))},[c,e]),{editingId:i,editText:o,setEditText:s,pendingEditId:c,setPendingEditId:l,handleNodeDoubleClick:(0,t.useCallback)((e,t,n)=>{e.stopPropagation(),a(t),s(n)},[]),commitEdit:(0,t.useCallback)(()=>{if(i){let t=o.trim();if(t){let a=e[i]?.text??``,{taskStatus:o,text:s}=Ge(t);n(e=>Ne(e,i,{text:s,taskStatus:o})),s!==a&&r?.(i,a,s)}}a(null)},[i,o,n,e,r]),cancelEdit:(0,t.useCallback)(()=>{a(null)},[])}}function qe(e){let[n,r]=(0,t.useState)(new Set),i=(0,t.useRef)(new Set);return(0,t.useEffect)(()=>{let t=new Set(e.map(e=>e.id));if(i.current.size>0){let e=new Set;for(let n of t)i.current.has(n)||e.add(n);if(e.size>0){r(e);let n=setTimeout(()=>r(new Set),350);return i.current=t,()=>clearTimeout(n)}}i.current=t},[e]),n}var Je=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`,Ye=null,Y=!1,X=null,Z=[];function Xe(){return X||(X=import(`katex`).then(e=>{Ye=e.default||e,Y=!0,$e();for(let e of Z)e();Z=[]}).catch(()=>{Y=!0}),X)}function Ze(){return Ye}function Qe(e){Y?e():Z.push(e)}Xe();function $e(){if(!(typeof document>`u`)&&!document.getElementById(`katex-style`)){let e=document.createElement(`link`);e.id=`katex-style`,e.rel=`stylesheet`,e.href=`https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css`,document.head.appendChild(e)}}function et(e,t){let n=Ze();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t})}catch{return null}}function tt(e,t){let n=Ze();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t,output:`mathml`})}catch{return null}}var nt={name:`latex`,inlineTokenPattern(){return{pattern:`\\$\\$(.+?)\\$\\$|\\$([^$]+?)\\$`,priority:3}},createInlineToken(e,t){let n=e[t+1],r=e[t+2];return n===void 0?r===void 0?null:{type:`latex-inline`,content:r}:{type:`latex-block`,content:n}},renderInlineToken(e,t){let{token:r}=e;return r.type!==`latex-inline`&&r.type!==`latex-block`?null:Ze()?(0,n.jsx)(`tspan`,{opacity:0,children:r.content},t):(0,n.jsx)(`tspan`,{fontFamily:Je,fontStyle:`italic`,fontSize:`0.9em`,children:r.content},t)},exportInlineToken(e,t){let{token:n}=e;if(n.type!==`latex-inline`&&n.type!==`latex-block`)return``;let r=n.content.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);return t?`<tspan font-family="${Je}" font-style="italic" font-size="0.9em">${r}</tspan>`:Ze()?`<tspan opacity="0">${r}</tspan>`:`<tspan font-family="${Je}" font-style="italic" font-size="0.9em">${r}</tspan>`},exportNodeDecoration(e,t,n,r){if(r||!Ze())return``;let i=[],a=(t,r,a,o,s,c)=>{let l=_(u(t,n),r,a,o),d=l.length>0?l[l.length-1].x+l[l.length-1].width:0,f=r*.85,p=e.taskStatus?4:0,m=e.taskStatus?f+p:0,h=r*.7,g=e.remark?4:0,v=e.remark?h+g:0,y=-(m+d+v)/2+m;for(let e of l){let{token:t}=e;if(t.type!==`latex-inline`&&t.type!==`latex-block`)continue;let n=tt(t.content,t.type===`latex-block`);if(!n)continue;let a=n.match(/<math[\s\S]*<\/math>/);if(!a)continue;let o=y+e.x+e.width/2,l=Math.max(e.width*2.5,120),u=r*2;i.push(`<foreignObject x="${o-l/2}" y="${c-u/2}" width="${l}" height="${u}" style="overflow:visible"><div xmlns="http://www.w3.org/1999/xhtml" style="font-size:${r*.75}px;line-height:${u}px;color:${s};white-space:nowrap;text-align:center">`+a[0]+`</div></foreignObject>`)}},o=(e,t,r,a,o,s)=>{let c=_(u(e,n),t,r,a),l=-(c.length>0?c[c.length-1].x+c[c.length-1].width:0)/2;for(let e of c){let{token:n}=e;if(n.type!==`latex-inline`&&n.type!==`latex-block`)continue;let r=tt(n.content,n.type===`latex-block`);if(!r)continue;let a=r.match(/<math[\s\S]*<\/math>/);if(!a)continue;let c=l+e.x+e.width/2,u=Math.max(e.width*2.5,120),d=t*2;i.push(`<foreignObject x="${c-u/2}" y="${s-d/2}" width="${u}" height="${d}" style="overflow:visible"><div xmlns="http://www.w3.org/1999/xhtml" style="font-size:${t*.75}px;line-height:${d}px;color:${o};white-space:nowrap;text-align:center;opacity:0.8">`+a[0]+`</div></foreignObject>`)}},s=e.depth===0?t.root.fontSize:e.depth===1?t.level1.fontSize:t.node.fontSize,c=e.depth===0?t.root.fontWeight:e.depth===1?t.level1.fontWeight:t.node.fontWeight,l=e.depth===0?t.root.fontFamily:t.node.fontFamily,d=e.depth===0?t.root.textColor:t.node.textColor;if(a(e.text,s,c,l,d,0),e.multiLineContent&&e.multiLineContent.length>0){let t=s*.85,n=s*1.4,r=s/2+8;for(let i=0;i<e.multiLineContent.length;i++){let a=r+i*n;o(e.multiLineContent[i],t,400,l,d,a)}}return i.join(``)},adjustNodeSize(e,t,n){return{width:t,height:n}}},rt=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`;function it(e,t,r,i){let{token:a}=e;if(a.type!==`text`&&a.type!==`bold`&&a.type!==`italic`&&a.type!==`strikethrough`&&a.type!==`code`&&a.type!==`highlight`&&a.type!==`link`&&a.type!==`image`&&r&&r.length>0){let n=I(r,e,t);if(n)return n}switch(a.type){case`bold`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-bold`,fontWeight:700,children:a.content},t);case`italic`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-italic`,fontStyle:`italic`,children:a.content},t);case`strikethrough`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-strikethrough`,textDecoration:`line-through`,opacity:.6,children:a.content},t);case`code`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-code`,fontFamily:rt,fontSize:`0.88em`,children:a.content},t);case`highlight`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-highlight`,fill:i||`#FFEB3B`,children:a.content},t);case`link`:return(0,n.jsx)(`a`,{className:`mindmap-text-link`,href:a.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,n.jsx)(`tspan`,{fill:`#2563EB`,textDecoration:`underline`,children:a.text})},t);case`image`:return(0,n.jsxs)(`tspan`,{className:`mindmap-text-image`,fontStyle:`italic`,children:[`[`,a.alt||`image`,`]`]},t);case`latex-inline`:case`latex-block`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-latex`,fontFamily:rt,fontStyle:`italic`,fontSize:`0.9em`,children:a.content},t);default:return(0,n.jsx)(`tspan`,{className:`mindmap-text-plain`,children:a.content},t)}}function at({status:e,size:t}){return e===`done`?(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`#22C55E`}),(0,n.jsx)(`path`,{d:`M${t*.28} ${t*.5}L${t*.44} ${t*.66}L${t*.72} ${t*.34}`,stroke:`white`,strokeWidth:t*.13,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})]}):e===`doing`?(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`none`,stroke:`#FBBF24`,strokeWidth:t*.1}),(0,n.jsx)(`rect`,{x:t*.25,y:t*.25,width:t*.5,height:t*.5,rx:t*.1,fill:`#FBBF24`,opacity:.6})]}):(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`none`,stroke:`#999`,strokeWidth:t*.1,opacity:.4})}function Q({node:e,fontSize:r,fontWeight:i,fontFamily:a,textColor:o,onRemarkHover:s,plugins:c,highlightTextColor:l,highlightBgColor:d}){let[f,p]=(0,t.useState)(()=>!!Ze());(0,t.useEffect)(()=>{f||Qe(()=>p(!0))},[f]);let{layouts:m,textContentWidth:h,taskIconWidth:g,totalWidth:v}=(0,t.useMemo)(()=>{let t=_(u(e.text,c),r,i,a),n=t.length>0?t[t.length-1].x+t[t.length-1].width:0,o=r*.85,s=e.taskStatus?4:0,l=e.taskStatus?o+s:0,d=r*.7,f=e.remark?4:0,p=e.remark?d+f:0;return{layouts:t,textContentWidth:n,taskIconWidth:l,totalWidth:l+n+p}},[e.text,e.taskStatus,e.remark,r,i,a,c]),y=-v/2,b=y+g,x=r*.85,S=-r/2-2,C=r+4,w=r*.7,T=e.multiLineContent,E=r*1.4,D=r/2+8;return(0,n.jsxs)(`g`,{className:`mindmap-node-content`,children:[e.taskStatus&&(0,n.jsx)(`g`,{className:`mindmap-task-icon mindmap-task-${e.taskStatus}`,transform:`translate(${y}, ${-x/2})`,children:(0,n.jsx)(at,{status:e.taskStatus,size:x})}),m.map((e,t)=>e.token.type===`code`?(0,n.jsx)(`rect`,{className:`mindmap-code-bg`,x:b+e.x-2,y:S,width:e.width+4,height:C,rx:3,fill:`rgba(128,128,128,0.12)`},`bg-${t}`):e.token.type===`highlight`?(0,n.jsx)(`rect`,{className:`mindmap-highlight-bg`,x:b+e.x-1,y:S,width:e.width+2,height:C,rx:2,fill:d||`rgba(255,213,79,0.3)`},`bg-${t}`):null),(0,n.jsx)(`text`,{className:`mindmap-node-text`,textAnchor:`start`,dominantBaseline:`central`,x:b,fill:o,fontSize:r,fontWeight:i,fontFamily:a,children:m.map((e,t)=>it(e,t,c,l))}),f&&m.map((e,t)=>{let{token:i}=e;if(i.type!==`latex-inline`&&i.type!==`latex-block`)return null;let a=et(i.content,i.type===`latex-block`);if(!a)return null;$e();let s=b+e.x+e.width/2,c=Math.max(e.width*2.5,120),l=r*2;return(0,n.jsx)(`foreignObject`,{className:`mindmap-latex`,x:s-c/2,y:-l/2,width:c,height:l,style:{overflow:`visible`,pointerEvents:`none`},children:(0,n.jsx)(`div`,{style:{fontSize:r*.75,lineHeight:`${l}px`,color:o,whiteSpace:`nowrap`,textAlign:`center`},dangerouslySetInnerHTML:{__html:a}})},`latex-fo-${t}`)}),T&&T.length>0&&T.map((e,t)=>{let i=r*.85,s=_(u(e,c),i,400,a),p=-(s.length>0?s[s.length-1].x+s[s.length-1].width:0)/2,m=D+t*E,h=m-i/2-2,g=i+4;return(0,n.jsxs)(`g`,{className:`mindmap-multiline`,children:[s.map((e,t)=>e.token.type===`code`?(0,n.jsx)(`rect`,{className:`mindmap-code-bg`,x:p+e.x-2,y:h,width:e.width+4,height:g,rx:3,fill:`rgba(128,128,128,0.12)`},`ml-bg-${t}`):e.token.type===`highlight`?(0,n.jsx)(`rect`,{className:`mindmap-highlight-bg`,x:p+e.x-1,y:h,width:e.width+2,height:g,rx:2,fill:d||`rgba(255,213,79,0.3)`},`ml-bg-${t}`):null),(0,n.jsx)(`text`,{className:`mindmap-multiline-text`,x:p,y:m,textAnchor:`start`,dominantBaseline:`central`,fill:o,fontSize:i,fontWeight:400,fontFamily:a,opacity:.8,children:s.map((e,t)=>it(e,t,c,l))}),f&&s.map((e,r)=>{let{token:a}=e;if(a.type!==`latex-inline`&&a.type!==`latex-block`)return null;let s=et(a.content,a.type===`latex-block`);if(!s)return null;$e();let c=p+e.x+e.width/2,l=Math.max(e.width*2.5,120),u=i*2;return(0,n.jsx)(`foreignObject`,{className:`mindmap-latex`,x:c-l/2,y:m-u/2,width:l,height:u,style:{overflow:`visible`,pointerEvents:`none`},children:(0,n.jsx)(`div`,{style:{fontSize:i*.75,lineHeight:`${u}px`,color:o,whiteSpace:`nowrap`,textAlign:`center`,opacity:.8},dangerouslySetInnerHTML:{__html:s}})},`ml-latex-fo-${t}-${r}`)})]},`ml-${t}`)}),e.tags&&e.tags.length>0&&(()=>{let t=r*.65,i=r/2+6+(T?T.length*E:0),o=-v/2;return e.tags.map((e,r)=>{let s=e.length*t*.65+10,c=o;o+=s+4;let l=[`#3B82F6`,`#8B5CF6`,`#EC4899`,`#F59E0B`,`#10B981`,`#6366F1`],u=l[r%l.length];return(0,n.jsxs)(`g`,{className:`mindmap-tag`,children:[(0,n.jsx)(`rect`,{className:`mindmap-tag-bg`,x:c,y:i,width:s,height:t+6,rx:3,fill:u,opacity:.15}),(0,n.jsx)(`text`,{className:`mindmap-tag-text`,x:c+s/2,y:i+(t+6)/2,textAnchor:`middle`,dominantBaseline:`central`,fontSize:t,fill:u,fontFamily:a,children:e})]},`tag-${r}`)})})(),e.remark&&(0,n.jsxs)(`text`,{className:`mindmap-remark-indicator`,x:b+h+4,textAnchor:`start`,dominantBaseline:`central`,fontSize:w,opacity:.5,style:{cursor:`help`},onMouseEnter:()=>s?.(e.id),onMouseLeave:()=>s?.(null),children:[(0,n.jsx)(`title`,{children:e.remark}),`💬`]})]})}function ot({node:e,offset:t,isEditing:r,isPendingEdit:i,isSelected:a,isNew:o,isGhost:s,animClass:c,editText:l,theme:u,direction:d,readonly:f,plugins:p,onMouseDown:m,onClick:h,onDoubleClick:g,onEditChange:_,onEditCommit:v,onEditCancel:y,onAddChild:b,onRemarkHover:x,onFoldToggle:S,expandDelay:C}){let w=e.x+(t?.x??0),T=e.y+(t?.y??0),E=r||i,D=i&&!r?``:l,O=o?`mindmap-node-new`:``,ee=C===void 0?``:`mindmap-node-expanding`,k=C===void 0?void 0:{animationDelay:`${C}ms`},te=(e.taskStatus===`done`?`[x] `:e.taskStatus===`doing`?`[-] `:e.taskStatus===`todo`?`[ ] `:``)+e.text,A=p&&p.length>0?F(p,e,u):null;if(e.depth===0){let t=u.root.bgColor;return(0,n.jsxs)(`g`,{transform:`translate(${w}, ${T})`,className:`mindmap-node-g mindmap-node-root ${c} ${O} ${ee}`,onMouseDown:t=>m(t,e.id),onClick:t=>h(t,e.id),onDoubleClick:t=>g(t,e.id,te),style:{cursor:`pointer`,opacity:s?.3:1,...k},children:[(0,n.jsx)(`rect`,{className:`mindmap-node-bg`,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,rx:e.height/2,ry:e.height/2,fill:t,stroke:a?u.selection.strokeColor:`none`,strokeWidth:a?2.5:0}),E?(0,n.jsx)(`foreignObject`,{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,children:(0,n.jsx)(`input`,{className:`mindmap-edit-input mindmap-edit-root`,value:D,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},onBlur:v,autoFocus:!0,style:{fontSize:u.root.fontSize,fontWeight:u.root.fontWeight,fontFamily:u.root.fontFamily}})}):(0,n.jsx)(Q,{node:e,fontSize:u.root.fontSize,fontWeight:u.root.fontWeight,fontFamily:u.root.fontFamily,textColor:u.root.textColor,onRemarkHover:x,plugins:p,highlightTextColor:u.highlight.textColor,highlightBgColor:u.highlight.bgColor}),A,!f&&!s&&(d===`right`||d===`both`)&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id,`right`),children:[(0,n.jsx)(`circle`,{cx:e.width/2+18,cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:e.width/2+14,y1:0,x2:e.width/2+22,y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:e.width/2+18,y1:-4,x2:e.width/2+18,y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),!f&&!s&&(d===`left`||d===`both`)&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id,`left`),children:[(0,n.jsx)(`circle`,{cx:-(e.width/2+18),cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:-(e.width/2+22),y1:0,x2:-(e.width/2+14),y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:-(e.width/2+18),y1:-4,x2:-(e.width/2+18),y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),e.collapsed!==void 0&&f&&S&&(0,n.jsx)(`g`,{className:`mindmap-fold-btn`,style:{cursor:`pointer`},onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),S(e.id)},children:(0,n.jsx)(`circle`,{cx:e.width/2+14,cy:0,r:6,fill:e.color})})]},e.id)}let j=e.depth===1?u.level1.fontSize:u.node.fontSize,M=e.depth===1?u.level1.fontWeight:u.node.fontWeight,N=e.width-u.node.paddingH*2,P=j/2+4,I=e.side===`left`?-e.width/2-18:e.width/2+18;return(0,n.jsxs)(`g`,{transform:`translate(${w}, ${T})`,className:`mindmap-node-g mindmap-node-child ${c} ${O}`,onMouseDown:t=>m(t,e.id),onClick:t=>h(t,e.id),onDoubleClick:t=>g(t,e.id,te),style:{cursor:`pointer`,opacity:s?.3:1},children:[(0,n.jsx)(`rect`,{className:`mindmap-node-bg`,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,fill:a?u.selection.fillColor:`transparent`,stroke:a?u.selection.strokeColor:`none`,strokeWidth:a?1.5:0,rx:4}),E?(0,n.jsx)(`foreignObject`,{x:-Math.max(e.width,80)/2,y:-e.height/2,width:Math.max(e.width,80),height:e.height,children:(0,n.jsx)(`input`,{className:`mindmap-edit-input mindmap-edit-child`,value:D,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&y()},onBlur:v,autoFocus:!0,style:{fontSize:j,fontWeight:M,fontFamily:u.node.fontFamily,color:u.node.textColor,textAlign:`center`,borderBottom:`2.5px solid ${e.color}`}})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Q,{node:e,fontSize:j,fontWeight:M,fontFamily:u.node.fontFamily,textColor:u.node.textColor,onRemarkHover:x,plugins:p,highlightTextColor:u.highlight.textColor,highlightBgColor:u.highlight.bgColor}),(0,n.jsx)(`line`,{className:`mindmap-node-underline`,x1:-N/2,y1:P,x2:N/2,y2:P,stroke:e.color,strokeWidth:2.5,strokeLinecap:`round`})]}),A,!f&&!s&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id),children:[(0,n.jsx)(`circle`,{cx:I,cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:I-4,y1:0,x2:I+4,y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:I,y1:-4,x2:I,y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),e.collapsed!==void 0&&f&&S&&(0,n.jsx)(`g`,{className:`mindmap-fold-btn`,style:{cursor:`pointer`},onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),S(e.id)},children:(0,n.jsx)(`circle`,{cx:I,cy:0,r:6,fill:e.color})})]},e.id)}function st({size:e=24,className:t}){return(0,n.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,className:t,children:[(0,n.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,n.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})}function ct({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,className:t,children:(0,n.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})})}function lt({zoom:e,theme:t,messages:r,showZoom:i=!0,mode:a,isFullscreen:o,onZoomIn:s,onZoomOut:c,onAutoFit:l,onModeToggle:u,onFullscreenToggle:d}){return(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsxs)(`div`,{className:`mindmap-zoom-controls`,style:{background:t.controls.bgColor,color:t.controls.textColor},children:[(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-zoom-out`,onClick:c,title:r.zoomOut,style:{color:t.controls.textColor},children:(0,n.jsx)(ct,{size:16})}),(0,n.jsxs)(`button`,{className:`mindmap-ctrl-pct`,onClick:l,title:r.resetView,style:{color:t.controls.textColor},children:[Math.round(e*100),`%`]}),(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-zoom-in`,onClick:s,title:r.zoomIn,style:{color:t.controls.textColor},children:(0,n.jsx)(st,{size:16})})]}),(0,n.jsxs)(`div`,{className:`mindmap-extra-controls`,style:{background:t.controls.bgColor,color:t.controls.textColor},children:[(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-mode`,onClick:u,title:a===`view`?r.textMode:r.viewMode,style:{color:t.controls.textColor},children:a===`view`?(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M6 5h12`}),(0,n.jsx)(`path`,{d:`M4 12h10`}),(0,n.jsx)(`path`,{d:`M12 19h8`})]}):(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}),(0,n.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}),(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-fullscreen`,onClick:d,title:o?r.exitFullscreen:r.fullscreen,style:{color:t.controls.textColor},children:o?(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}),(0,n.jsx)(`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}),(0,n.jsx)(`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}),(0,n.jsx)(`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`})]}):(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}),(0,n.jsx)(`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}),(0,n.jsx)(`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}),(0,n.jsx)(`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`})]})})]})]})}function ut({position:e,theme:r,messages:i,readonly:a,onNewRootNode:o,onExportSVG:s,onExportPNG:c,onExportMarkdown:l,onDirectionChange:u,onClose:d}){let[f,p]=(0,t.useState)(!1),[m,h]=(0,t.useState)(!1);return(0,n.jsxs)(`div`,{className:`mindmap-context-menu`,style:{left:e.x,top:e.y,background:r.contextMenu.bgColor,color:r.contextMenu.textColor,boxShadow:`0 4px 16px ${r.contextMenu.shadowColor}`,borderColor:r.contextMenu.borderColor},onClick:e=>e.stopPropagation(),children:[!a&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-new-root`,onClick:o,style:{color:r.contextMenu.textColor},children:i.newRootNode}),(0,n.jsx)(`div`,{className:`mindmap-ctx-divider`,style:{borderColor:r.contextMenu.borderColor}})]}),(0,n.jsxs)(`div`,{className:`mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-layout`,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{color:r.contextMenu.textColor},children:[i.layout,(0,n.jsx)(`span`,{className:`mindmap-ctx-arrow`,children:`▶`}),m&&(0,n.jsxs)(`div`,{className:`mindmap-ctx-submenu`,style:{background:r.contextMenu.bgColor,boxShadow:`0 4px 16px ${r.contextMenu.shadowColor}`,borderColor:r.contextMenu.borderColor},children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-left`,onClick:()=>{u(`left`),d()},style:{color:r.contextMenu.textColor},children:i.layoutLeft}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-both`,onClick:()=>{u(`both`),d()},style:{color:r.contextMenu.textColor},children:i.layoutBoth}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-right`,onClick:()=>{u(`right`),d()},style:{color:r.contextMenu.textColor},children:i.layoutRight})]})]}),(0,n.jsx)(`div`,{className:`mindmap-ctx-divider`,style:{borderColor:r.contextMenu.borderColor}}),(0,n.jsxs)(`div`,{className:`mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-export`,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{color:r.contextMenu.textColor},children:[i.export,(0,n.jsx)(`span`,{className:`mindmap-ctx-arrow`,children:`▶`}),f&&(0,n.jsxs)(`div`,{className:`mindmap-ctx-submenu`,style:{background:r.contextMenu.bgColor,boxShadow:`0 4px 16px ${r.contextMenu.shadowColor}`,borderColor:r.contextMenu.borderColor},children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-svg`,onClick:s,style:{color:r.contextMenu.textColor},children:i.exportSVG}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-png`,onClick:c,style:{color:r.contextMenu.textColor},children:i.exportPNG}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-md`,onClick:l,style:{color:r.contextMenu.textColor},children:i.exportMarkdown})]})]})]})}function dt(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}var ft=(0,t.forwardRef)(function({data:e,markdown:r,defaultDirection:i=`both`,theme:a=`auto`,locale:o,messages:s,readonly:c=!1,toolbar:l=!0,onDataChange:u,onEvent:d,plugins:f},p){let m=(0,t.useRef)(null),h=(0,t.useRef)(null),g=f&&f.length>0?f:void 0,_=(0,t.useMemo)(()=>{if(e||r===void 0)return null;if(g){let e=ve(r,g),t=e.frontMatter.direction,n=e.frontMatter.theme;return{roots:e.roots,direction:t===`left`||t===`right`||t===`both`?t:void 0,theme:n===`light`||n===`dark`||n===`auto`?n:void 0}}return{roots:ge(r),direction:void 0,theme:void 0}},[]),[v,y]=(0,t.useState)(()=>e?Te(e):_?_.roots:[{id:`md-0`,text:`Root`}]),[b,x]=(0,t.useState)(()=>_?.direction??i),[S,C]=(0,t.useState)({}),[w,T]=(0,t.useState)(null),[E,D]=(0,t.useState)(null),[O,ee]=(0,t.useState)({}),k=(0,t.useRef)(null),[te,A]=(0,t.useState)(`view`),[j,M]=(0,t.useState)(!1),[N,P]=(0,t.useState)(``),[F,I]=(0,t.useState)(null),[re,ie]=(0,t.useState)({}),[ae,oe]=(0,t.useState)(null),[se,ce]=(0,t.useState)(()=>_?.theme);(0,t.useEffect)(()=>{e&&y(Te(e))},[e]),(0,t.useEffect)(()=>{if(r!==void 0)if(g){let{roots:e,frontMatter:t}=ve(r,g);if(y(e),t.direction){let e=t.direction;(e===`left`||e===`right`||e===`both`)&&x(e)}if(t.theme){let e=t.theme;(e===`light`||e===`dark`||e===`auto`)&&ce(e)}}else y(ge(r))},[r,g]);let L=(0,t.useCallback)(e=>{y(t=>{let n=e(t);return u?.(n),n})},[u]),le=(0,t.useRef)(d);le.current=d;let R=(0,t.useCallback)(e=>{le.current?.(e)},[]),z=He(se??a),B=(0,t.useMemo)(()=>Ce(o??Se(),s),[o,s]),ue=(0,t.useMemo)(()=>l===!1?{zoom:!1}:l===!0||l===void 0?{zoom:!0}:{zoom:l.zoom??!0},[l]),{nodes:V,edges:H}=(0,t.useMemo)(()=>fe(v,b,O,S,g,c,re),[v,b,O,S,g,c,re]);(0,t.useEffect)(()=>{let e={},t=!1;for(let n of V)n.depth===1&&!O[n.id]&&(e[n.id]=n.color,t=!0);t&&ee(t=>({...t,...e}))},[V,O]);let U=(0,t.useMemo)(()=>{let e={};for(let t of V)e[t.id]=t;return e},[V]),W=(0,t.useMemo)(()=>{if(!ae)return{};let e={},t=[];for(let e of V)e.parentId===ae&&t.push({id:e.id,depth:1});for(;t.length>0;){let{id:n,depth:r}=t.shift();e[n]=r*100;for(let e of V)e.parentId===n&&t.push({id:e.id,depth:r+1})}return e},[ae,V]),{pan:G,setPan:K,zoom:q,setZoom:ye,animateTo:be,autoFit:xe,zoomIn:Ee,zoomOut:De,contentCenter:Oe,panToNode:ke}=Ue(h,V),{draggingCanvas:Ae,floatingNodeId:Me,floatingPos:Ne,floatingSubtreeIds:J,didDragRef:Re,handleCanvasMouseDown:ze,handleMouseMove:Be,handleMouseUp:Ve,handleNodeMouseDown:Ge}=We({svgRef:h,zoom:q,pan:G,setPan:K,setZoom:ye,nodeMap:U,nodes:V,updateData:L,direction:b,splitIndices:S,setSplitIndices:C,mapData:v,contentCenter:Oe}),{editingId:Je,editText:Ye,setEditText:Y,pendingEditId:X,setPendingEditId:Z,handleNodeDoubleClick:Xe,commitEdit:Ze,cancelEdit:Qe}=Ke({nodeMap:U,updateData:L,onTextChange:(e,t,n)=>{R({type:`nodeTextChange`,nodeId:e,oldText:t,newText:n})}}),$e=qe(V),[et,tt]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(Me||X)return;let e=xe();e?et?(ye(e.zoom),K({x:e.panX,y:e.panY})):(ye(e.zoom*.92),K({x:e.panX,y:e.panY}),requestAnimationFrame(()=>{tt(!0),be(e.zoom,e.panX,e.panY)})):et||requestAnimationFrame(()=>tt(!0))},[V,xe,Me,X,ye,K,et,be]),(0,t.useEffect)(()=>{X&&U[X]&&ke(X)},[X,U,ke]);let nt=(0,t.useCallback)(e=>{D(null),ze(e)},[ze]),rt=(0,t.useCallback)((e,t)=>{e.stopPropagation(),Re.current||(T(t),R({type:`nodeSelect`,nodeId:t}))},[Re,R]),it=(0,t.useCallback)(()=>{Re.current||(T(null),R({type:`nodeSelect`,nodeId:null}))},[Re,R]),at=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=m.current;if(!t)return;let n=t.getBoundingClientRect();D({x:e.clientX-n.left,y:e.clientY-n.top})},[]),Q=(0,t.useCallback)(()=>{D(null)},[]),st=(0,t.useCallback)(e=>{if(!e){I(null);return}let t=U[e];if(!t||!t.remark){I(null);return}let n=h.current;if(!n)return;let r=n.getBoundingClientRect(),i=(t.x+t.width/2)*q+G.x,a=(t.y-t.height/2)*q+G.y;I({nodeId:e,text:t.remark,x:Math.min(i,r.width-300),y:a-8})},[U,q,G]),ct=(0,t.useCallback)((e,t,n)=>{if(e.stopPropagation(),c)return;let r=we(),i={id:r,text:B.newNode};v.some(e=>e.id===t)&&n&&b===`both`?L(e=>e.map(e=>{if(e.id!==t)return e;let r=e.children||[],a=S[t]??Math.ceil(r.length/2),o=a,s=r.length-a,c=n;n===`right`&&o>=3*Math.max(s,1)?c=`left`:n===`left`&&s>=3*Math.max(o,1)&&(c=`right`);let l=Le(e,i,c,a);return C(e=>({...e,[t]:l.newSplitIndex})),l.data})):L(e=>Pe(e,t,i)),R({type:`nodeAdd`,node:i,parentId:t}),Z(r),Y(``)},[L,v,b,S,Z,Y,B,c,R]),ft=(0,t.useCallback)(()=>{if(c)return;let e=we(),t={id:e,text:B.newNode};L(e=>[...e,t]),R({type:`nodeAdd`,node:t,parentId:null}),Z(e),Y(``),Q()},[L,Q,Z,Y,B,c,R]),pt=(0,t.useCallback)(()=>{let e=pe(V,H,{},z,g);dt(new Blob([e],{type:`image/svg+xml;charset=utf-8`}),`mindmap.svg`),Q()},[V,H,z,Q,g]),mt=(0,t.useCallback)(async()=>{dt(await he(me(V,H,{pngSafe:!0},z,g)),`mindmap.png`),Q()},[V,H,z,Q,g]),ht=(0,t.useCallback)(()=>{let e=_e(v,g);dt(new Blob([e],{type:`text/markdown;charset=utf-8`}),`mindmap.md`),Q()},[v,Q,g]),gt=(0,t.useCallback)(()=>{let e=xe();e&&be(e.zoom,e.panX,e.panY)},[xe,be]),$=(0,t.useCallback)(e=>{x(e),C({}),R({type:`directionChange`,direction:e})},[R]),_t=(0,t.useCallback)(()=>{A(e=>{if(e===`view`)return P(_e(v,g)),R({type:`modeChange`,mode:`text`}),`text`;{let e=g?ve(N,g).roots:ge(N);return L(()=>e),C({}),R({type:`modeChange`,mode:`view`}),`view`}})},[v,N,L,g,R]),vt=(0,t.useCallback)(()=>{let e=m.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen())},[]);(0,t.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;M(e),R({type:`fullscreenChange`,fullscreen:e})};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[R]);let yt=(0,t.useRef)(q);(0,t.useEffect)(()=>{q!==yt.current&&(yt.current=q,R({type:`zoomChange`,zoom:q}))},[q,R]);let bt=(0,t.useCallback)(e=>{if(e.key===`Escape`&&E){e.preventDefault(),Q();return}if(Je)return;let t=e.metaKey||e.ctrlKey;if(e.shiftKey&&!t){if(e.code===`Equal`){e.preventDefault(),Ee();return}if(e.code===`Minus`){e.preventDefault(),De();return}if(e.code===`Digit0`){e.preventDefault(),gt();return}if(e.code===`KeyL`){e.preventDefault(),$(`left`);return}if(e.code===`KeyR`){e.preventDefault(),$(`right`);return}if(e.code===`KeyM`){e.preventDefault(),$(`both`);return}}if(e.key===`Enter`&&!t&&w&&!c){e.preventDefault();let t=we(),n={id:t,text:B.newNode};v.some(e=>e.id===w)&&b===`both`?L(e=>e.map(e=>{if(e.id!==w)return e;let t=e.children||[],r=Le(e,n,`right`,S[w]??Math.ceil(t.length/2));return C(e=>({...e,[w]:r.newSplitIndex})),r.data})):L(e=>Pe(e,w,n)),Z(t),Y(``),R({type:`nodeAdd`,node:n,parentId:w});return}if((e.key===`Delete`||e.key===`Backspace`)&&w&&!c){if(e.preventDefault(),v.some(e=>e.id===w)&&v.length<=1)return;R({type:`nodeDelete`,nodeId:w}),L(e=>Fe(e,w)),T(null);return}if(t&&e.key===`c`&&w){e.preventDefault(),k.current=Ie(v,w);return}if(t&&e.key===`x`&&w&&!c){if(e.preventDefault(),k.current=Ie(v,w),v.some(e=>e.id===w)&&v.length<=1)return;R({type:`nodeDelete`,nodeId:w}),L(e=>Fe(e,w)),T(null);return}if(t&&e.key===`v`&&w&&k.current&&!c){e.preventDefault();let t=je(k.current);L(e=>Pe(e,w,t)),R({type:`nodeAdd`,node:t,parentId:w});return}},[Je,w,v,b,S,L,E,Q,Z,Y,B,Ee,De,gt,$,c,R]);(0,t.useImperativeHandle)(p,()=>({exportToSVG(){return pe(V,H,{},z,g)},async exportToPNG(){return he(me(V,H,{},z,g))},exportToOutline(){return _e(v,g)},getData(){return v},setData(e){y(Te(e)),C({})},setMarkdown(e){y(g?ve(e,g).roots:ge(e)),C({})},fitView(){gt()},setDirection(e){$(e)}}),[V,H,v,g,gt,$,z]),(0,t.useEffect)(()=>{if(!E)return;let e=()=>Q();return window.addEventListener(`click`,e),()=>window.removeEventListener(`click`,e)},[E,Q]);let xt=(0,t.useCallback)(e=>{if(e.key!==`Tab`)return;e.preventDefault();let t=e.currentTarget,{selectionStart:n,selectionEnd:r,value:i}=t;if(e.shiftKey){let e=i.lastIndexOf(`
|
|
18
|
-
|
|
18
|
+
`);let i=t.map(e=>({...e,preParseMarkdown:void 0})),a=r.split(/\n[ \t]*\n/).filter(e=>e.trim());if(a.length===0)return{roots:[{id:`md-0`,text:`Root`}],frontMatter:n.frontMatter};let o;return o=a.length===1?[ye(r,i)]:a.map((e,t)=>{let n=ye(e,i);return G(n,`md-${t}`),n}),o=k(t,o,n),{roots:o,frontMatter:n.frontMatter}}var Ce={newNode:`新节点`,zoomIn:`放大`,zoomOut:`缩小`,resetView:`重置视图`,layoutLeft:`向左排版`,layoutBoth:`左右排版`,layoutRight:`向右排版`,textMode:`文本模式`,viewMode:`视图模式`,fullscreen:`全屏`,exitFullscreen:`退出全屏`,newRootNode:`新建主节点`,export:`导出`,exportSVG:`导出为 SVG`,exportPNG:`导出为 PNG`,exportMarkdown:`导出为 Markdown`,layout:`布局`,aiPlaceholder:`让 AI 生成思维导图...`,aiGenerating:`生成中...`,aiError:`生成失败`,close:`关闭`},we={newNode:`New Node`,zoomIn:`Zoom In`,zoomOut:`Zoom Out`,resetView:`Reset View`,layoutLeft:`Left Layout`,layoutBoth:`Both Layout`,layoutRight:`Right Layout`,textMode:`Text Mode`,viewMode:`View Mode`,fullscreen:`Fullscreen`,exitFullscreen:`Exit Fullscreen`,newRootNode:`New Root Node`,export:`Export`,exportSVG:`Export as SVG`,exportPNG:`Export as PNG`,exportMarkdown:`Export as Markdown`,layout:`Layout`,aiPlaceholder:`Ask AI to generate a mind map...`,aiGenerating:`Generating...`,aiError:`Generation failed`,close:`Close`},K={"zh-CN":Ce,"en-US":we};function Te(){if(typeof navigator>`u`)return`en-US`;let e=navigator.language||``;if(K[e])return e;if(e.startsWith(`zh`))return`zh-CN`;let t=e.split(`-`)[0];for(let e of Object.keys(K))if(e.startsWith(t))return e;return`en-US`}function Ee(e=`zh-CN`,t){let n=K[e]??Ce;return t?{...n,...t}:n}function De(){return Date.now().toString(36)+Math.random().toString(36).slice(2,6)}function Oe(e){return Array.isArray(e)?e:[e]}function ke(e,t,n){if(e.id===t){let t={...e,...n};return`taskStatus`in n&&n.taskStatus===void 0&&delete t.taskStatus,`remark`in n&&n.remark===void 0&&delete t.remark,t}return e.children?{...e,children:e.children.map(e=>ke(e,t,n))}:e}function Ae(e,t,n){return e.id===t?{...e,children:[...e.children||[],n]}:e.children?{...e,children:e.children.map(e=>Ae(e,t,n))}:e}function je(e,t){if(!e.children)return e;let n=e.children.filter(e=>e.id!==t).map(e=>je(e,t));return{...e,children:n.length>0?n:void 0}}function Me(e,t,n){if(!e.children)return e;let r=e.children.findIndex(e=>e.id===t),i=e.children.findIndex(e=>e.id===n);if(r!==-1&&i!==-1){let t=[...e.children];return[t[r],t[i]]=[t[i],t[r]],{...e,children:t}}return{...e,children:e.children.map(e=>Me(e,t,n))}}function Ne(e,t){if(e.id===t)return structuredClone(e);if(!e.children)return null;for(let n of e.children){let e=Ne(n,t);if(e)return e}return null}function Pe(e){return{...e,id:De(),children:e.children?.map(e=>Pe(e))}}function Fe(e,t){let n={};for(let e of t)e.parentId&&(n[e.parentId]||(n[e.parentId]=[]),n[e.parentId].push(e.id));let r=[],i=[e];for(;i.length>0;){let e=n[i.pop()];if(e)for(let t of e)r.push(t),i.push(t)}return r}function Ie(e,t,n){return e.map(e=>ke(e,t,n))}function Le(e,t,n){return e.map(e=>Ae(e,t,n))}function Re(e,t){let n=e.filter(e=>e.id!==t);return n.length<e.length?n:e.map(e=>je(e,t))}function q(e,t,n){return e.map(e=>Me(e,t,n))}function ze(e,t){for(let n of e){let e=Ne(n,t);if(e)return e}return null}function Be(e,t,n,r){let i=[...e.children||[]],a=Math.min(r,i.length);return n===`right`?(i.splice(a,0,t),{data:{...e,children:i},newSplitIndex:a+1}):(i.push(t),{data:{...e,children:i},newSplitIndex:a})}function Ve(e,t,n,r){let i=e.children||[],a=i.findIndex(e=>e.id===t);if(a===-1)return null;let o=Math.min(Math.max(r,0),i.length);if(n===`right`&&a<o||n===`left`&&a>=o)return null;let s=[...i],[c]=s.splice(a,1);return n===`left`?(s.push(c),{data:{...e,children:s},newSplitIndex:o-1}):(s.splice(o,0,c),{data:{...e,children:s},newSplitIndex:o+1})}var He=typeof window<`u`?window.matchMedia(`(prefers-color-scheme: dark)`):null;function Ue(e){return He?.addEventListener(`change`,e),()=>He?.removeEventListener(`change`,e)}function We(){return He?.matches??!1}function Ge(e=`auto`){let n=(0,t.useSyncExternalStore)(Ue,We,()=>!1),r=e===`auto`?n?`dark`:`light`:e;return(0,t.useMemo)(()=>s(r),[r])}function Ke(e,n){let[r,i]=(0,t.useState)({x:0,y:0}),[a,o]=(0,t.useState)(1),s=(0,t.useRef)(0),c=(0,t.useRef)(a),l=(0,t.useRef)(r);(0,t.useEffect)(()=>{c.current=a,l.current=r});let u=(0,t.useMemo)(()=>{if(n.length===0)return{x:0,y:0};let e=1/0,t=-1/0,r=1/0,i=-1/0;for(let a of n)e=Math.min(e,a.x-a.width/2),t=Math.max(t,a.x+a.width/2),r=Math.min(r,a.y-a.height/2),i=Math.max(i,a.y+a.height/2);return{x:(e+t)/2,y:(r+i)/2}},[n]),d=(0,t.useCallback)((e,t,n)=>{cancelAnimationFrame(s.current);let r=c.current,a=l.current.x,u=l.current.y,d=performance.now(),f=c=>{let l=c-d,p=Math.min(l/200,1),m=1-(1-p)**3;o(r+(e-r)*m),i({x:a+(t-a)*m,y:u+(n-u)*m}),p<1&&(s.current=requestAnimationFrame(f))};s.current=requestAnimationFrame(f)},[]),f=(0,t.useCallback)(()=>{let t=e.current;if(!t||n.length===0)return;let r=t.clientWidth,i=t.clientHeight,a=1/0,o=-1/0,s=1/0,c=-1/0;for(let e of n)a=Math.min(a,e.x-e.width/2),o=Math.max(o,e.x+e.width/2),s=Math.min(s,e.y-e.height/2),c=Math.max(c,e.y+e.height/2);let l=o-a,u=c-s,d=Math.min((r-120)/l,(i-120)/u,1.5),f=(a+o)/2,p=(s+c)/2;return{zoom:d,panX:r/2-f*d,panY:i/2-p*d}},[e,n]);return(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientX-n.left,a=e.clientY-n.top,s=e.deltaY>0?.9:1.1,u=Math.min(Math.max(c.current*s,.1),5);i({x:r-(r-l.current.x)*(u/c.current),y:a-(a-l.current.y)*(u/c.current)}),o(u)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[e]),{pan:r,setPan:i,zoom:a,setZoom:o,animateTo:d,autoFit:f,zoomIn:(0,t.useCallback)(()=>{let t=Math.min(c.current*1.2,5),n=e.current,r=n.clientWidth/2,i=n.clientHeight/2;d(t,r-(r-l.current.x)*(t/c.current),i-(i-l.current.y)*(t/c.current))},[e,d]),zoomOut:(0,t.useCallback)(()=>{let t=Math.max(c.current*.8,.1),n=e.current,r=n.clientWidth/2,i=n.clientHeight/2;d(t,r-(r-l.current.x)*(t/c.current),i-(i-l.current.y)*(t/c.current))},[e,d]),contentCenter:u,panToNode:(0,t.useCallback)(t=>{let r=e.current;if(!r)return;let i=n.find(e=>e.id===t);if(!i)return;let a=r.clientWidth,o=r.clientHeight,s=i.x*c.current+l.current.x,u=i.y*c.current+l.current.y;s>100&&s<a-100&&u>100&&u<o-100||d(c.current,a/2-i.x*c.current,o/2-i.y*c.current)},[e,n,d])}}function qe({svgRef:e,zoom:n,pan:r,setPan:i,setZoom:a,nodeMap:o,nodes:s,updateData:c,direction:l,splitIndices:u,setSplitIndices:d,mapData:f,contentCenter:p}){let[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)(null),b=(0,t.useRef)({x:0,y:0,panX:0,panY:0}),x=(0,t.useRef)({x:0,y:0}),S=(0,t.useRef)(!1),C=(0,t.useRef)(0),w=(0,t.useRef)({type:`none`,startPan:{x:0,y:0},startZoom:1,startTouches:[],pinchDistance:0,contentCenter:{x:0,y:0},touchNodeId:null}),T=(0,t.useMemo)(()=>{if(!g)return new Set;let e=new Set([g]);for(let t of Fe(g,s))e.add(t);return e},[g,s]),E=(0,t.useCallback)((t,i)=>{let a=e.current.getBoundingClientRect();return{x:(t-a.left-r.x)/n,y:(i-a.top-r.y)/n}},[e,r,n]),D=(0,t.useCallback)((e,t,n)=>{let r=E(e,t),i={x:r.x+x.current.x,y:r.y+x.current.y};y(i);let a=Date.now();if(a-C.current>500){let e=o[n];if(e&&e.parentId){if(e.depth===1&&l===`both`){let t=e.side,r=t===`right`&&i.x<0,o=t===`left`&&i.x>0;if(r||o){let t=r?`left`:`right`,i=e.parentId,o=f.find(e=>e.id===i);if(o){let e=Ve(o,n,t,u[i]??Math.ceil((o.children?.length??0)/2));if(e){C.current=a,d(t=>({...t,[i]:e.newSplitIndex})),c(t=>t.map(t=>t.id===i?e.data:t));return}}}}let t=s.filter(t=>t.parentId===e.parentId&&t.id!==n&&t.side===e.side);for(let r of t){let t=Math.max(e.height,r.height)*.6;if(Math.abs(i.y-r.y)<t){C.current=a,c(e=>q(e,n,r.id));break}}}}},[E,o,s,c,l,u,d,f]),O=(0,t.useCallback)(e=>{e.button===0&&(S.current=!1,h(!0),b.current={x:e.clientX,y:e.clientY,panX:r.x,panY:r.y})},[r]),k=(0,t.useCallback)(e=>{m?(S.current=!0,i({x:b.current.panX+(e.clientX-b.current.x),y:b.current.panY+(e.clientY-b.current.y)})):g&&(S.current=!0,D(e.clientX,e.clientY,g))},[m,g,i,D]),A=(0,t.useCallback)(()=>{h(!1),_(null),y(null)},[]),ee=(0,t.useCallback)((e,t)=>{if(e.stopPropagation(),e.button!==0)return;S.current=!1;let n=o[t];if(!n)return;_(t),y({x:n.x,y:n.y});let r=E(e.clientX,e.clientY);x.current={x:n.x-r.x,y:n.y-r.y}},[o,E]),j=(0,t.useRef)(r),M=(0,t.useRef)(n),te=(0,t.useRef)(o),N=(0,t.useRef)(p),ne=(0,t.useRef)(g);(0,t.useEffect)(()=>{j.current=r,M.current=n,te.current=o,N.current=p,ne.current=g});let P=(0,t.useCallback)(t=>{let n=t;for(;n&&n!==e.current;){if(n.classList?.contains(`mindmap-node-g`)){let e=n.getAttribute(`transform`);if(e)for(let t of s){let n=t.x,r=t.y;if(e.includes(`translate(${n}`)&&e.includes(`${r})`))return t.id}}n=n.parentElement}return null},[e,s]);return(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let n=t;function r(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)}function o(e){e.preventDefault();let t=e.touches;if(t.length===2){let e=r(t[0],t[1]);w.current={type:`pinch`,startPan:{...j.current},startZoom:M.current,startTouches:[{id:t[0].identifier,x:t[0].clientX,y:t[0].clientY},{id:t[1].identifier,x:t[1].clientX,y:t[1].clientY}],pinchDistance:e,contentCenter:{...N.current},touchNodeId:null},ne.current&&(_(null),y(null)),h(!1);return}if(t.length===1){let r=t[0],i=P(e.target);if(i){let t=e.target;for(;t&&t!==n;){if(t.classList?.contains(`mindmap-add-btn`))return;t=t.parentElement}S.current=!1;let a=te.current[i];if(a){_(i),y({x:a.x,y:a.y});let e=n.getBoundingClientRect(),t=(r.clientX-e.left-j.current.x)/M.current,o=(r.clientY-e.top-j.current.y)/M.current;x.current={x:a.x-t,y:a.y-o},w.current={type:`node-drag`,startPan:{...j.current},startZoom:M.current,startTouches:[{id:r.identifier,x:r.clientX,y:r.clientY}],pinchDistance:0,contentCenter:{...N.current},touchNodeId:i}}}else S.current=!1,h(!0),b.current={x:r.clientX,y:r.clientY,panX:j.current.x,panY:j.current.y},w.current={type:`canvas-pan`,startPan:{...j.current},startZoom:M.current,startTouches:[{id:r.identifier,x:r.clientX,y:r.clientY}],pinchDistance:0,contentCenter:{...N.current},touchNodeId:null}}}function p(e){e.preventDefault();let t=w.current,o=e.touches;if(t.type===`pinch`&&o.length>=2){let e=r(o[0],o[1])/t.pinchDistance,s=Math.min(Math.max(t.startZoom*e,.1),5),c=n.clientWidth/2,l=n.clientHeight/2,u=t.contentCenter;a(s),i({x:c-u.x*s,y:l-u.y*s});return}if(t.type===`canvas-pan`&&o.length===1){S.current=!0;let e=o[0];i({x:b.current.panX+(e.clientX-b.current.x),y:b.current.panY+(e.clientY-b.current.y)});return}if(t.type===`node-drag`&&o.length===1&&t.touchNodeId){S.current=!0;let e=o[0],r=n.getBoundingClientRect(),i=(e.clientX-r.left-j.current.x)/M.current,a=(e.clientY-r.top-j.current.y)/M.current,p={x:i+x.current.x,y:a+x.current.y};y(p);let m=Date.now();if(m-C.current>500){let e=te.current[t.touchNodeId];if(e&&e.parentId){if(e.depth===1&&l===`both`){let n=e.side,r=n===`right`&&p.x<0,i=n===`left`&&p.x>0;if(r||i){let n=r?`left`:`right`,i=e.parentId,a=f.find(e=>e.id===i);if(a){let e=u[i]??Math.ceil((a.children?.length??0)/2),r=Ve(a,t.touchNodeId,n,e);if(r){C.current=m,d(e=>({...e,[i]:r.newSplitIndex})),c(e=>e.map(e=>e.id===i?r.data:e));return}}}}let n=s.filter(n=>n.parentId===e.parentId&&n.id!==t.touchNodeId&&n.side===e.side);for(let r of n){let n=Math.max(e.height,r.height)*.6;if(Math.abs(p.y-r.y)<n){C.current=m,c(e=>q(e,t.touchNodeId,r.id));break}}}}return}}function m(e){e.preventDefault();let t=w.current,n=e.touches;if(t.type===`pinch`&&n.length===1){let e=n[0];b.current={x:e.clientX,y:e.clientY,panX:j.current.x,panY:j.current.y},h(!0),w.current={...t,type:`canvas-pan`,startTouches:[{id:e.identifier,x:e.clientX,y:e.clientY}]};return}n.length===0&&(h(!1),_(null),y(null),w.current={type:`none`,startPan:{x:0,y:0},startZoom:1,startTouches:[],pinchDistance:0,contentCenter:{x:0,y:0},touchNodeId:null})}return n.addEventListener(`touchstart`,o,{passive:!1}),n.addEventListener(`touchmove`,p,{passive:!1}),n.addEventListener(`touchend`,m,{passive:!1}),n.addEventListener(`touchcancel`,m,{passive:!1}),()=>{n.removeEventListener(`touchstart`,o),n.removeEventListener(`touchmove`,p),n.removeEventListener(`touchend`,m),n.removeEventListener(`touchcancel`,m)}},[e,i,a,P,l,f,u,d,c,s]),{draggingCanvas:m,floatingNodeId:g,floatingPos:v,floatingSubtreeIds:T,didDragRef:S,handleCanvasMouseDown:O,handleMouseMove:k,handleMouseUp:A,handleNodeMouseDown:ee}}function Je(e){let t=e.match(/^\[([ x-])\]\s+(.*)/);if(!t)return{text:e};let n=t[1],r=t[2];return n===` `?{taskStatus:`todo`,text:r}:n===`x`?{taskStatus:`done`,text:r}:n===`-`?{taskStatus:`doing`,text:r}:{text:e}}function Ye({nodeMap:e,updateData:n,onTextChange:r}){let[i,a]=(0,t.useState)(null),[o,s]=(0,t.useState)(``),[c,l]=(0,t.useState)(null);return(0,t.useEffect)(()=>{c&&e[c]&&(a(c),s(``),l(null))},[c,e]),{editingId:i,editText:o,setEditText:s,pendingEditId:c,setPendingEditId:l,handleNodeDoubleClick:(0,t.useCallback)((e,t,n)=>{e.stopPropagation(),a(t),s(n)},[]),commitEdit:(0,t.useCallback)(()=>{if(i){let t=o.trim();if(t){let a=e[i]?.text??``,{taskStatus:o,text:s}=Je(t);n(e=>Ie(e,i,{text:s,taskStatus:o})),s!==a&&r?.(i,a,s)}}a(null)},[i,o,n,e,r]),cancelEdit:(0,t.useCallback)(()=>{a(null)},[])}}function Xe(e){let[n,r]=(0,t.useState)(new Set),i=(0,t.useRef)(new Set);return(0,t.useEffect)(()=>{let t=new Set(e.map(e=>e.id));if(i.current.size>0){let e=new Set;for(let n of t)i.current.has(n)||e.add(n);if(e.size>0){r(e);let n=setTimeout(()=>r(new Set),350);return i.current=t,()=>clearTimeout(n)}}i.current=t},[e]),n}var Ze=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`,Qe=null,J=!1,Y=null,X=[];function $e(){return Y||(Y=import(`katex`).then(e=>{Qe=e.default||e,J=!0,nt();for(let e of X)e();X=[]}).catch(()=>{J=!0}),Y)}function et(){return Qe}function tt(e){J?e():X.push(e)}$e();function nt(){if(!(typeof document>`u`)&&!document.getElementById(`katex-style`)){let e=document.createElement(`link`);e.id=`katex-style`,e.rel=`stylesheet`,e.href=`https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css`,document.head.appendChild(e)}}function rt(e,t){let n=et();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t})}catch{return null}}function it(e,t){let n=et();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t,output:`mathml`})}catch{return null}}var at={name:`latex`,inlineTokenPattern(){return{pattern:`\\$\\$(.+?)\\$\\$|\\$([^$]+?)\\$`,priority:3}},createInlineToken(e,t){let n=e[t+1],r=e[t+2];return n===void 0?r===void 0?null:{type:`latex-inline`,content:r}:{type:`latex-block`,content:n}},renderInlineToken(e,t){let{token:r}=e;return r.type!==`latex-inline`&&r.type!==`latex-block`?null:et()?(0,n.jsx)(`tspan`,{opacity:0,children:r.content},t):(0,n.jsx)(`tspan`,{fontFamily:Ze,fontStyle:`italic`,fontSize:`0.9em`,children:r.content},t)},exportInlineToken(e,t){let{token:n}=e;if(n.type!==`latex-inline`&&n.type!==`latex-block`)return``;let r=n.content.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);return t?`<tspan font-family="${Ze}" font-style="italic" font-size="0.9em">${r}</tspan>`:et()?`<tspan opacity="0">${r}</tspan>`:`<tspan font-family="${Ze}" font-style="italic" font-size="0.9em">${r}</tspan>`},exportNodeDecoration(e,t,n,r){if(r||!et())return``;let i=[],a=(t,r,a,o,s,c)=>{let l=y(f(t,n),r,a,o),u=l.length>0?l[l.length-1].x+l[l.length-1].width:0,d=r*.85,p=e.taskStatus?4:0,m=e.taskStatus?d+p:0,h=r*.7,g=e.remark?4:0,_=e.remark?h+g:0,v=-(m+u+_)/2+m;for(let e of l){let{token:t}=e;if(t.type!==`latex-inline`&&t.type!==`latex-block`)continue;let n=it(t.content,t.type===`latex-block`);if(!n)continue;let a=n.match(/<math[\s\S]*<\/math>/);if(!a)continue;let o=v+e.x+e.width/2,l=Math.max(e.width*2.5,120),u=r*2;i.push(`<foreignObject x="${o-l/2}" y="${c-u/2}" width="${l}" height="${u}" style="overflow:visible"><div xmlns="http://www.w3.org/1999/xhtml" style="font-size:${r*.75}px;line-height:${u}px;color:${s};white-space:nowrap;text-align:center">`+a[0]+`</div></foreignObject>`)}},o=(e,t,r,a,o,s)=>{let c=y(f(e,n),t,r,a),l=-(c.length>0?c[c.length-1].x+c[c.length-1].width:0)/2;for(let e of c){let{token:n}=e;if(n.type!==`latex-inline`&&n.type!==`latex-block`)continue;let r=it(n.content,n.type===`latex-block`);if(!r)continue;let a=r.match(/<math[\s\S]*<\/math>/);if(!a)continue;let c=l+e.x+e.width/2,u=Math.max(e.width*2.5,120),d=t*2;i.push(`<foreignObject x="${c-u/2}" y="${s-d/2}" width="${u}" height="${d}" style="overflow:visible"><div xmlns="http://www.w3.org/1999/xhtml" style="font-size:${t*.75}px;line-height:${d}px;color:${o};white-space:nowrap;text-align:center;opacity:0.8">`+a[0]+`</div></foreignObject>`)}},s=e.depth===0?t.root.fontSize:e.depth===1?t.level1.fontSize:t.node.fontSize,c=e.depth===0?t.root.fontWeight:e.depth===1?t.level1.fontWeight:t.node.fontWeight,l=e.depth===0?t.root.fontFamily:t.node.fontFamily,u=e.depth===0?t.root.textColor:t.node.textColor;if(a(e.text,s,c,l,u,0),e.multiLineContent&&e.multiLineContent.length>0){let t=s*.85,n=s*1.4,r=s/2+8;for(let i=0;i<e.multiLineContent.length;i++){let a=r+i*n;o(e.multiLineContent[i],t,400,l,u,a)}}return i.join(``)},adjustNodeSize(e,t,n){return{width:t,height:n}}},ot=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`;function st(e,t,r,i){let{token:a}=e;if(a.type!==`text`&&a.type!==`bold`&&a.type!==`italic`&&a.type!==`strikethrough`&&a.type!==`code`&&a.type!==`highlight`&&a.type!==`link`&&a.type!==`image`&&r&&r.length>0){let n=ie(r,e,t);if(n)return n}switch(a.type){case`bold`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-bold`,fontWeight:700,children:a.content},t);case`italic`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-italic`,fontStyle:`italic`,children:a.content},t);case`strikethrough`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-strikethrough`,textDecoration:`line-through`,opacity:.6,children:a.content},t);case`code`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-code`,fontFamily:ot,fontSize:`0.88em`,children:a.content},t);case`highlight`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-highlight`,fill:i||`#FFEB3B`,children:a.content},t);case`link`:return(0,n.jsx)(`a`,{className:`mindmap-text-link`,href:a.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,n.jsx)(`tspan`,{fill:`#2563EB`,textDecoration:`underline`,children:a.text})},t);case`image`:return(0,n.jsxs)(`tspan`,{className:`mindmap-text-image`,fontStyle:`italic`,children:[`[`,a.alt||`image`,`]`]},t);case`latex-inline`:case`latex-block`:return(0,n.jsx)(`tspan`,{className:`mindmap-text-latex`,fontFamily:ot,fontStyle:`italic`,fontSize:`0.9em`,children:a.content},t);default:return(0,n.jsx)(`tspan`,{className:`mindmap-text-plain`,children:a.content},t)}}function ct({status:e,size:t}){return e===`done`?(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`#22C55E`}),(0,n.jsx)(`path`,{d:`M${t*.28} ${t*.5}L${t*.44} ${t*.66}L${t*.72} ${t*.34}`,stroke:`white`,strokeWidth:t*.13,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})]}):e===`doing`?(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`none`,stroke:`#FBBF24`,strokeWidth:t*.1}),(0,n.jsx)(`rect`,{x:t*.25,y:t*.25,width:t*.5,height:t*.5,rx:t*.1,fill:`#FBBF24`,opacity:.6})]}):(0,n.jsx)(`rect`,{x:0,y:0,width:t,height:t,rx:t*.2,fill:`none`,stroke:`#999`,strokeWidth:t*.1,opacity:.4})}function Z({node:e,fontSize:r,fontWeight:i,fontFamily:a,textColor:o,onRemarkHover:s,plugins:c,highlightTextColor:l,highlightBgColor:u}){let[d,p]=(0,t.useState)(()=>!!et());(0,t.useEffect)(()=>{d||tt(()=>p(!0))},[d]);let{layouts:m,textContentWidth:h,taskIconWidth:g,totalWidth:_}=(0,t.useMemo)(()=>{let t=y(f(e.text,c),r,i,a),n=t.length>0?t[t.length-1].x+t[t.length-1].width:0,o=r*.85,s=e.taskStatus?4:0,l=e.taskStatus?o+s:0,u=r*.7,d=e.remark?4:0,p=e.remark?u+d:0;return{layouts:t,textContentWidth:n,taskIconWidth:l,totalWidth:l+n+p}},[e.text,e.taskStatus,e.remark,r,i,a,c]),v=-_/2,b=v+g,x=r*.85,S=-r/2-2,C=r+4,w=r*.7,T=e.multiLineContent,E=r*1.4,D=r/2+8;return(0,n.jsxs)(`g`,{className:`mindmap-node-content`,children:[e.taskStatus&&(0,n.jsx)(`g`,{className:`mindmap-task-icon mindmap-task-${e.taskStatus}`,transform:`translate(${v}, ${-x/2})`,children:(0,n.jsx)(ct,{status:e.taskStatus,size:x})}),m.map((e,t)=>e.token.type===`code`?(0,n.jsx)(`rect`,{className:`mindmap-code-bg`,x:b+e.x-2,y:S,width:e.width+4,height:C,rx:3,fill:`rgba(128,128,128,0.12)`},`bg-${t}`):e.token.type===`highlight`?(0,n.jsx)(`rect`,{className:`mindmap-highlight-bg`,x:b+e.x-1,y:S,width:e.width+2,height:C,rx:2,fill:u||`rgba(255,213,79,0.3)`},`bg-${t}`):null),(0,n.jsx)(`text`,{className:`mindmap-node-text`,textAnchor:`start`,dominantBaseline:`central`,x:b,fill:o,fontSize:r,fontWeight:i,fontFamily:a,children:m.map((e,t)=>st(e,t,c,l))}),d&&m.map((e,t)=>{let{token:i}=e;if(i.type!==`latex-inline`&&i.type!==`latex-block`)return null;let a=rt(i.content,i.type===`latex-block`);if(!a)return null;nt();let s=b+e.x+e.width/2,c=Math.max(e.width*2.5,120),l=r*2;return(0,n.jsx)(`foreignObject`,{className:`mindmap-latex`,x:s-c/2,y:-l/2,width:c,height:l,children:(0,n.jsx)(`div`,{className:`mindmap-latex-content`,style:{fontSize:r*.75,lineHeight:`${l}px`,color:o},dangerouslySetInnerHTML:{__html:a}})},`latex-fo-${t}`)}),T&&T.length>0&&T.map((e,t)=>{let i=r*.85,s=y(f(e,c),i,400,a),p=-(s.length>0?s[s.length-1].x+s[s.length-1].width:0)/2,m=D+t*E,h=m-i/2-2,g=i+4;return(0,n.jsxs)(`g`,{className:`mindmap-multiline`,children:[s.map((e,t)=>e.token.type===`code`?(0,n.jsx)(`rect`,{className:`mindmap-code-bg`,x:p+e.x-2,y:h,width:e.width+4,height:g,rx:3,fill:`rgba(128,128,128,0.12)`},`ml-bg-${t}`):e.token.type===`highlight`?(0,n.jsx)(`rect`,{className:`mindmap-highlight-bg`,x:p+e.x-1,y:h,width:e.width+2,height:g,rx:2,fill:u||`rgba(255,213,79,0.3)`},`ml-bg-${t}`):null),(0,n.jsx)(`text`,{className:`mindmap-multiline-text`,x:p,y:m,textAnchor:`start`,dominantBaseline:`central`,fill:o,fontSize:i,fontWeight:400,fontFamily:a,opacity:.8,children:s.map((e,t)=>st(e,t,c,l))}),d&&s.map((e,r)=>{let{token:a}=e;if(a.type!==`latex-inline`&&a.type!==`latex-block`)return null;let s=rt(a.content,a.type===`latex-block`);if(!s)return null;nt();let c=p+e.x+e.width/2,l=Math.max(e.width*2.5,120),u=i*2;return(0,n.jsx)(`foreignObject`,{className:`mindmap-latex`,x:c-l/2,y:m-u/2,width:l,height:u,children:(0,n.jsx)(`div`,{className:`mindmap-latex-content`,style:{fontSize:i*.75,lineHeight:`${u}px`,color:o,opacity:.8},dangerouslySetInnerHTML:{__html:s}})},`ml-latex-fo-${t}-${r}`)})]},`ml-${t}`)}),e.tags&&e.tags.length>0&&(()=>{let t=r*.65,i=r/2+6+(T?T.length*E:0),o=-_/2;return e.tags.map((e,r)=>{let s=e.length*t*.65+10,c=o;o+=s+4;let l=[`#3B82F6`,`#8B5CF6`,`#EC4899`,`#F59E0B`,`#10B981`,`#6366F1`],u=l[r%l.length];return(0,n.jsxs)(`g`,{className:`mindmap-tag`,children:[(0,n.jsx)(`rect`,{className:`mindmap-tag-bg`,x:c,y:i,width:s,height:t+6,rx:3,fill:u,opacity:.15}),(0,n.jsx)(`text`,{className:`mindmap-tag-text`,x:c+s/2,y:i+(t+6)/2,textAnchor:`middle`,dominantBaseline:`central`,fontSize:t,fill:u,fontFamily:a,children:e})]},`tag-${r}`)})})(),e.remark&&(0,n.jsxs)(`text`,{className:`mindmap-remark-indicator`,x:b+h+4,textAnchor:`start`,dominantBaseline:`central`,fontSize:w,opacity:.5,onMouseEnter:()=>s?.(e.id),onMouseLeave:()=>s?.(null),children:[(0,n.jsx)(`title`,{children:e.remark}),`💬`]})]})}function lt({node:e,offset:t,isEditing:r,isPendingEdit:i,isSelected:a,isNew:o,isGhost:s,animClass:c,editText:l,theme:u,direction:d,readonly:f,plugins:p,onMouseDown:m,onClick:h,onDoubleClick:g,onEditChange:_,onEditCommit:v,onEditCancel:y,onAddChild:b,onRemarkHover:x,onFoldToggle:S,expandDelay:C}){let w=e.x+(t?.x??0),T=e.y+(t?.y??0),E=r||i,D=i&&!r?``:l,O=o?`mindmap-node-new`:``,k=C===void 0?``:`mindmap-node-expanding`,A=C===void 0?void 0:{animationDelay:`${C}ms`},ee=(e.taskStatus===`done`?`[x] `:e.taskStatus===`doing`?`[-] `:e.taskStatus===`todo`?`[ ] `:``)+e.text,j=p&&p.length>0?re(p,e,u):null;if(e.depth===0){let t=u.root.bgColor;return(0,n.jsxs)(`g`,{transform:`translate(${w}, ${T})`,className:`mindmap-node-g mindmap-node-root ${c} ${O} ${k}${s?` mindmap-node-ghost`:``}`,"data-branch-index":e.branchIndex,onMouseDown:t=>m(t,e.id),onClick:t=>h(t,e.id),onDoubleClick:t=>g(t,e.id,ee),style:A,children:[(0,n.jsx)(`rect`,{className:`mindmap-node-bg`,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,rx:e.height/2,ry:e.height/2,fill:t,stroke:a?u.selection.strokeColor:`none`,strokeWidth:a?2.5:0}),E?(0,n.jsx)(`foreignObject`,{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,children:(0,n.jsx)(`input`,{className:`mindmap-edit-input mindmap-edit-root`,value:D,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},onBlur:v,autoFocus:!0,style:{fontSize:u.root.fontSize,fontWeight:u.root.fontWeight,fontFamily:u.root.fontFamily}})}):(0,n.jsx)(Z,{node:e,fontSize:u.root.fontSize,fontWeight:u.root.fontWeight,fontFamily:u.root.fontFamily,textColor:u.root.textColor,onRemarkHover:x,plugins:p,highlightTextColor:u.highlight.textColor,highlightBgColor:u.highlight.bgColor}),j,!f&&!s&&(d===`right`||d===`both`)&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id,`right`),children:[(0,n.jsx)(`circle`,{cx:e.width/2+18,cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:e.width/2+14,y1:0,x2:e.width/2+22,y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:e.width/2+18,y1:-4,x2:e.width/2+18,y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),!f&&!s&&(d===`left`||d===`both`)&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id,`left`),children:[(0,n.jsx)(`circle`,{cx:-(e.width/2+18),cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:-(e.width/2+22),y1:0,x2:-(e.width/2+14),y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:-(e.width/2+18),y1:-4,x2:-(e.width/2+18),y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),e.collapsed!==void 0&&f&&S&&(0,n.jsx)(`g`,{className:`mindmap-fold-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),S(e.id)},children:(0,n.jsx)(`circle`,{cx:e.width/2+14,cy:0,r:6,fill:e.color})})]},e.id)}let M=e.depth===1?u.level1.fontSize:u.node.fontSize,te=e.depth===1?u.level1.fontWeight:u.node.fontWeight,N=e.width-u.node.paddingH*2,ne=M/2+4,P=e.side===`left`?-e.width/2-18:e.width/2+18;return(0,n.jsxs)(`g`,{transform:`translate(${w}, ${T})`,className:`mindmap-node-g mindmap-node-child ${c} ${O}${s?` mindmap-node-ghost`:``}`,"data-branch-index":e.branchIndex,onMouseDown:t=>m(t,e.id),onClick:t=>h(t,e.id),onDoubleClick:t=>g(t,e.id,ee),children:[(0,n.jsx)(`rect`,{className:`mindmap-node-bg`,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height,fill:a?u.selection.fillColor:`transparent`,stroke:a?u.selection.strokeColor:`none`,strokeWidth:a?1.5:0,rx:4}),E?(0,n.jsx)(`foreignObject`,{x:-Math.max(e.width,80)/2,y:-e.height/2,width:Math.max(e.width,80),height:e.height,children:(0,n.jsx)(`input`,{className:`mindmap-edit-input mindmap-edit-child`,value:D,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&y()},onBlur:v,autoFocus:!0,style:{fontSize:M,fontWeight:te,fontFamily:u.node.fontFamily,color:u.node.textColor,textAlign:`center`,borderBottom:`2.5px solid ${e.color}`}})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Z,{node:e,fontSize:M,fontWeight:te,fontFamily:u.node.fontFamily,textColor:u.node.textColor,onRemarkHover:x,plugins:p,highlightTextColor:u.highlight.textColor,highlightBgColor:u.highlight.bgColor}),(0,n.jsx)(`line`,{className:`mindmap-node-underline`,x1:-N/2,y1:ne,x2:N/2,y2:ne,stroke:e.color,strokeWidth:2.5,strokeLinecap:`round`})]}),j,!f&&!s&&(0,n.jsxs)(`g`,{className:`mindmap-add-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>b(t,e.id),children:[(0,n.jsx)(`circle`,{cx:P,cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:P-4,y1:0,x2:P+4,y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:P,y1:-4,x2:P,y2:4,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`})]}),e.collapsed!==void 0&&f&&S&&(0,n.jsx)(`g`,{className:`mindmap-fold-btn`,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),S(e.id)},children:(0,n.jsx)(`circle`,{cx:P,cy:0,r:6,fill:e.color})})]},e.id)}function ut({size:e=24,className:t}){return(0,n.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,className:t,children:[(0,n.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,n.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})}function dt({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,className:t,children:(0,n.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})})}function ft({size:e=24,className:t}){return(0,n.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,className:t,children:[(0,n.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,n.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})}function pt({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`currentColor`,className:t,children:(0,n.jsx)(`path`,{d:`M13 2L4.5 13.5H11L10 22L19.5 10.5H13L13 2Z`})})}function mt({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:(0,n.jsx)(`path`,{d:`M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48`})})}function ht({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`currentColor`,className:t,children:(0,n.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})})}function Q({size:e=24,className:t}){return(0,n.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:(0,n.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})})}function gt({zoom:e,messages:t,showZoom:r=!0,mode:i,isFullscreen:a,onZoomIn:o,onZoomOut:s,onAutoFit:c,onModeToggle:l,onFullscreenToggle:u}){return(0,n.jsxs)(n.Fragment,{children:[r&&(0,n.jsxs)(`div`,{className:`mindmap-zoom-controls`,children:[(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-zoom-out`,onClick:s,title:t.zoomOut,children:(0,n.jsx)(dt,{size:16})}),(0,n.jsxs)(`button`,{className:`mindmap-ctrl-pct`,onClick:c,title:t.resetView,children:[Math.round(e*100),`%`]}),(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-zoom-in`,onClick:o,title:t.zoomIn,children:(0,n.jsx)(ut,{size:16})})]}),(0,n.jsxs)(`div`,{className:`mindmap-extra-controls`,children:[(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-mode`,onClick:l,title:i===`view`?t.textMode:t.viewMode,children:i===`view`?(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M6 5h12`}),(0,n.jsx)(`path`,{d:`M4 12h10`}),(0,n.jsx)(`path`,{d:`M12 19h8`})]}):(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}),(0,n.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}),(0,n.jsx)(`button`,{className:`mindmap-ctrl-btn mindmap-ctrl-fullscreen`,onClick:u,title:a?t.exitFullscreen:t.fullscreen,children:a?(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}),(0,n.jsx)(`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}),(0,n.jsx)(`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}),(0,n.jsx)(`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`})]}):(0,n.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}),(0,n.jsx)(`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}),(0,n.jsx)(`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}),(0,n.jsx)(`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`})]})})]})]})}function _t({position:e,messages:r,readonly:i,onNewRootNode:a,onExportSVG:o,onExportPNG:s,onExportMarkdown:c,onDirectionChange:l,onClose:u}){let[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(!1);return(0,n.jsxs)(`div`,{className:`mindmap-context-menu`,style:{left:e.x,top:e.y},onClick:e=>e.stopPropagation(),children:[!i&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-new-root`,onClick:a,children:r.newRootNode}),(0,n.jsx)(`div`,{className:`mindmap-ctx-divider`})]}),(0,n.jsxs)(`div`,{className:`mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-layout`,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[r.layout,(0,n.jsx)(`span`,{className:`mindmap-ctx-arrow`,children:`▶`}),p&&(0,n.jsxs)(`div`,{className:`mindmap-ctx-submenu`,children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-left`,onClick:()=>{l(`left`),u()},children:r.layoutLeft}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-both`,onClick:()=>{l(`both`),u()},children:r.layoutBoth}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-layout-right`,onClick:()=>{l(`right`),u()},children:r.layoutRight})]})]}),(0,n.jsx)(`div`,{className:`mindmap-ctx-divider`}),(0,n.jsxs)(`div`,{className:`mindmap-ctx-item mindmap-ctx-has-sub mindmap-ctx-export`,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[r.export,(0,n.jsx)(`span`,{className:`mindmap-ctx-arrow`,children:`▶`}),d&&(0,n.jsxs)(`div`,{className:`mindmap-ctx-submenu`,children:[(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-svg`,onClick:o,children:r.exportSVG}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-png`,onClick:s,children:r.exportPNG}),(0,n.jsx)(`div`,{className:`mindmap-ctx-item mindmap-ctx-export-md`,onClick:c,children:r.exportMarkdown})]})]})]})}var $=`#Role
|
|
19
|
+
You are a professional Mind Map Generator specializing in hierarchical information architecture. Your objective is to deconstruct complex topics into a robust, visual Markdown outline.
|
|
20
|
+
|
|
21
|
+
#Logic and Structure
|
|
22
|
+
- Primary Branches: Use the MECE (Mutually Exclusive, Collectively Exhaustive) principle to ensure no overlap and complete coverage of the topic.
|
|
23
|
+
- Branching Density: Aim for 3-5 primary branches. For narrow topics that do not naturally yield five branches, provide at least 3 branches and prioritize hierarchical depth over breadth.
|
|
24
|
+
- Hierarchical Depth: The structure must not exceed a maximum depth of the Root + 3 levels.
|
|
25
|
+
- Logical Flow: Organize the sequence of branches and sub-nodes based on priority, moving from foundational concepts to advanced applications.
|
|
26
|
+
|
|
27
|
+
#Formatting Standards
|
|
28
|
+
- Root Node: Place the root node on the first line of the response with no prefix (no hyphen, bullet, or number).
|
|
29
|
+
- Indentation: Use exactly two spaces per level of hierarchy to define the structure.
|
|
30
|
+
- Child Node Prefix: Every child node must start with a hyphen followed by a space ("- ").
|
|
31
|
+
- Text Constraints: Each node must contain between 2 and 6 visible words. Markdown formatting characters (e.g., **, ==, \`) do not count toward this 2-6 word limit.
|
|
32
|
+
- Remarks: Insert contextual notes or brief explanations immediately after relevant nodes using the "> " prefix.
|
|
33
|
+
- Inline Styling: Use Obsidian-compatible Markdown for emphasis: **bold**, *italic*, \`code\`, ~~strikethrough~~, and ==highlighting==.
|
|
34
|
+
|
|
35
|
+
#Extended Syntax (Optional)
|
|
36
|
+
Use these features only when they naturally enhance the mind map's clarity or structure. Do not force them into every response.
|
|
37
|
+
- Dotted Lines: Use "-." instead of "-" for weak, optional, or tentative relationships. Example: "-. Optional Step"
|
|
38
|
+
- Multi-line Content: Use "|" prefix lines to append additional display lines to a node. Example:
|
|
39
|
+
- Main Point
|
|
40
|
+
| Supporting detail line 1
|
|
41
|
+
| Supporting detail line 2
|
|
42
|
+
- Tags: Add "#tag" at the end of node text for categorization. Example: "- React #frontend #framework"
|
|
43
|
+
- Cross-links: Define anchors with "{#id}" and link with "-> {#id}" to connect nodes across branches. Example:
|
|
44
|
+
- Node A {#a}
|
|
45
|
+
- Node B
|
|
46
|
+
-> {#a} "references"
|
|
47
|
+
- Folding: Use "+" instead of "-" to mark a node as initially collapsed (children hidden by default). Example: "+ Collapsed Section"
|
|
48
|
+
- LaTeX: Use "$...$" for inline math and "$$...$$" for display math. Example: "- Energy: $E = mc^2$"
|
|
49
|
+
- Frontmatter: Use a "---" block at the very top to set layout direction or theme:
|
|
50
|
+
---
|
|
51
|
+
direction: right
|
|
52
|
+
theme: dark
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
#Example Output
|
|
56
|
+
Project Management
|
|
57
|
+
- **Foundational Concepts** #core
|
|
58
|
+
- Project Life Cycle
|
|
59
|
+
> Initiation through closing phases
|
|
60
|
+
| Planning, executing, monitoring
|
|
61
|
+
- Stakeholder Identification
|
|
62
|
+
- *Execution Frameworks*
|
|
63
|
+
- ==Agile Methodologies==
|
|
64
|
+
-. Hybrid Approaches
|
|
65
|
+
- Advanced Optimization
|
|
66
|
+
- Resource Load Balancing
|
|
67
|
+
> Optimizing team allocation
|
|
68
|
+
- Portfolio Risk Mitigation
|
|
69
|
+
|
|
70
|
+
#Constraints
|
|
71
|
+
- Provide the raw Markdown output only.
|
|
72
|
+
- Do not include any introductory text, conversational fillers, or explanations.
|
|
73
|
+
- Do not include any concluding remarks or summaries.
|
|
74
|
+
- Use extended syntax features (dotted lines, tags, multi-line, cross-links, etc.) only when they genuinely improve the mind map's clarity or structure. Default to basic syntax.
|
|
75
|
+
- FINAL NEGATIVE CONSTRAINT: Do not wrap the output in markdown code fences. Provide the response as raw, plain text.`;function vt(e){if(!e||e.length===0)return``;let t=[];for(let n of e)n===`text`?t.push(`text/*,.json,.js,.ts,.xml,.yaml,.yml,.sql,.sh,.md`):n===`image`?t.push(`image/*`):n===`pdf`&&t.push(`application/pdf`);return t.join(`,`)}function yt(e,t){if(t.length===0)return e;let n=[{type:`text`,text:e}];for(let e of t)if(e.type.startsWith(`image/`))n.push({type:`image_url`,image_url:{url:e.base64}});else{let t=atob(e.base64.split(`,`)[1]||``);n.push({type:`text`,text:`[File: ${e.name}]\n${t}`})}return n}function bt(e){let t=e.replace(/<think>[\s\S]*?<\/think>/g,``);return t=t.replace(/<think>[\s\S]*$/,``),t}async function*xt(e){let t=new TextDecoder,n=``;for(;;){let{done:r,value:i}=await e.read();if(r)break;n+=t.decode(i,{stream:!0});let a=n.split(`
|
|
76
|
+
`);n=a.pop()||``;for(let e of a){let t=e.trim();if(t===`data: [DONE]`)return;if(t.startsWith(`data: `))try{let e=JSON.parse(t.slice(6)).choices?.[0]?.delta?.content;e&&(yield e)}catch{}}}}function St({config:e,theme:r,messages:i,currentMarkdown:a,onMarkdownStream:o,onComplete:s,onError:c}){let[l,u]=(0,t.useState)(``),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)([]),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null),v=(0,t.useRef)(null),y=(0,t.useRef)(0),b=e.attachments&&e.attachments.length>0,x=(0,t.useCallback)(async()=>{let t=l.trim();if(!t&&p.length===0||d)return;f(!0),g(null);let n=new AbortController;_.current=n;try{let r=yt(t,p),i=e.systemPrompt||$,c=a?.trim()?`${i}\n\n#Current Mind Map\nThe user already has the following mind map. They may ask you to modify, expand, or optimize it. If the user's request is about the existing content, use it as the base and output the updated version. If the request is about a new topic, generate a fresh mind map.\n\n\`\`\`\n${a.trim()}\n\`\`\``:i,l=JSON.stringify({model:e.model,messages:[{role:`system`,content:c},{role:`user`,content:r}],stream:!0}),d=await fetch(e.apiUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.apiKey}`},body:l,signal:n.signal});if(!d.ok)throw Error(`API error: ${d.status}`);let f=d.body?.getReader();if(!f)throw Error(`No response body`);let h=``,g=!1;for await(let e of xt(f))if(h+=e,!g){g=!0;let e=bt(h);y.current=requestAnimationFrame(()=>{o(e),g=!1})}cancelAnimationFrame(y.current),h&&o(bt(h)),u(``),m([]),s()}catch(e){if(e.name===`AbortError`)s();else{let t=e.message||i.aiError;g(t),c(t),setTimeout(()=>g(null),4e3)}}finally{f(!1),_.current=null}},[l,p,d,e,a,i,o,s,c]),S=(0,t.useCallback)(()=>{_.current?.abort()},[]),C=(0,t.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),x())},[x]),w=(0,t.useCallback)(e=>{let t=e.target.files;t&&(Array.from(t).forEach(e=>{let t=new FileReader;t.onload=()=>{m(n=>[...n,{name:e.name,type:e.type,base64:t.result}])},t.readAsDataURL(e)}),e.target.value=``)},[]),T=(0,t.useCallback)(e=>{m(t=>t.filter((t,n)=>n!==e))},[]);return(0,n.jsxs)(`div`,{className:`mindmap-ai-input`,children:[p.length>0&&(0,n.jsx)(`div`,{className:`mindmap-ai-file-previews`,children:p.map((e,t)=>(0,n.jsxs)(`span`,{className:`mindmap-ai-file-chip`,children:[(0,n.jsx)(`span`,{className:`mindmap-ai-file-name`,children:e.name}),(0,n.jsx)(`button`,{className:`mindmap-ai-file-remove`,onClick:()=>T(t),children:(0,n.jsx)(ft,{size:12})})]},t))}),(0,n.jsxs)(`div`,{className:`mindmap-ai-input-row`,children:[b&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{className:`mindmap-ai-attach-btn`,onClick:()=>v.current?.click(),disabled:d,title:i.aiPlaceholder,children:(0,n.jsx)(mt,{size:18})}),(0,n.jsx)(`input`,{ref:v,type:`file`,accept:vt(e.attachments),multiple:!0,style:{display:`none`},onChange:w})]}),(0,n.jsx)(`input`,{className:`mindmap-ai-input-field`,type:`text`,value:d?``:l,onChange:e=>u(e.target.value),onKeyDown:C,placeholder:d?i.aiGenerating:i.aiPlaceholder,disabled:d}),(0,n.jsx)(`button`,{className:`mindmap-ai-send-btn${d?` mindmap-ai-send-btn--loading`:``}`,onClick:d?S:x,disabled:!d&&!l.trim()&&p.length===0,style:{background:d?`transparent`:!l.trim()&&p.length===0?r.controls.hoverBg:r.root.bgColor,color:d||!l.trim()&&p.length===0?r.controls.textColor:r.root.textColor},children:d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`mindmap-ai-spinner`,children:(0,n.jsx)(Q,{size:20})}),(0,n.jsx)(`span`,{className:`mindmap-ai-stop-icon`,children:(0,n.jsx)(ht,{size:16})})]}):(0,n.jsx)(pt,{size:16})})]}),h&&(0,n.jsx)(`div`,{className:`mindmap-ai-error`,children:h})]})}function Ct(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}var wt=(0,t.forwardRef)(function({data:e,markdown:r,defaultDirection:i=`both`,theme:a=`auto`,locale:o,messages:s,readonly:c=!1,toolbar:u=!0,ai:d,onDataChange:f,onEvent:p,plugins:m},h){let g=(0,t.useRef)(null),_=(0,t.useRef)(null),v=m&&m.length>0?m:void 0,y=(0,t.useMemo)(()=>{if(e||r===void 0)return null;if(v){let e=Se(r,v),t=e.frontMatter.direction,n=e.frontMatter.theme;return{roots:e.roots,direction:t===`left`||t===`right`||t===`both`?t:void 0,theme:n===`light`||n===`dark`||n===`auto`?n:void 0}}return{roots:be(r),direction:void 0,theme:void 0}},[]),[b,x]=(0,t.useState)(()=>e?Oe(e):y?y.roots:[{id:`md-0`,text:`Root`}]),[S,C]=(0,t.useState)(()=>y?.direction??i),[w,T]=(0,t.useState)({}),[E,D]=(0,t.useState)(null),[O,k]=(0,t.useState)(null),[A,ee]=(0,t.useState)({}),j=(0,t.useRef)(null),[M,te]=(0,t.useState)(`view`),[N,ne]=(0,t.useState)(!1),[P,F]=(0,t.useState)(``),[re,ie]=(0,t.useState)(null),[oe,se]=(0,t.useState)({}),[ce,le]=(0,t.useState)(null),[ue,de]=(0,t.useState)(()=>y?.theme);(0,t.useEffect)(()=>{e&&x(Oe(e))},[e]),(0,t.useEffect)(()=>{if(r!==void 0)if(v){let{roots:e,frontMatter:t}=Se(r,v);if(x(e),t.direction){let e=t.direction;(e===`left`||e===`right`||e===`both`)&&C(e)}if(t.theme){let e=t.theme;(e===`light`||e===`dark`||e===`auto`)&&de(e)}}else x(be(r))},[r,v]);let I=(0,t.useCallback)(e=>{x(t=>{let n=e(t);return f?.(n),n})},[f]),fe=(0,t.useRef)(p);fe.current=p;let L=(0,t.useCallback)(e=>{fe.current?.(e)},[]),R=Ge(ue??a),z=(0,t.useMemo)(()=>Ee(o??Te(),s),[o,s]),pe=(0,t.useMemo)(()=>u===!1?{zoom:!1}:u===!0||u===void 0?{zoom:!0}:{zoom:u.zoom??!0},[u]),{nodes:B,edges:V}=(0,t.useMemo)(()=>he(b,S,A,w,v,c,oe),[b,S,A,w,v,c,oe]);(0,t.useEffect)(()=>{let e={},t=!1;for(let n of B)n.depth===1&&!A[n.id]&&(e[n.id]=n.color,t=!0);t&&ee(t=>({...t,...e}))},[B,A]);let H=(0,t.useMemo)(()=>{let e={};for(let t of B)e[t.id]=t;return e},[B]),ye=(0,t.useMemo)(()=>{if(!ce)return{};let e={},t=[];for(let e of B)e.parentId===ce&&t.push({id:e.id,depth:1});for(;t.length>0;){let{id:n,depth:r}=t.shift();e[n]=r*100;for(let e of B)e.parentId===n&&t.push({id:e.id,depth:r+1})}return e},[ce,B]),{pan:U,setPan:W,zoom:G,setZoom:Ce,animateTo:we,autoFit:K,zoomIn:ke,zoomOut:Ae,contentCenter:je,panToNode:Me}=Ke(_,B),{draggingCanvas:Ne,floatingNodeId:Fe,floatingPos:Ie,floatingSubtreeIds:q,didDragRef:Ve,handleCanvasMouseDown:He,handleMouseMove:Ue,handleMouseUp:We,handleNodeMouseDown:Je}=qe({svgRef:_,zoom:G,pan:U,setPan:W,setZoom:Ce,nodeMap:H,nodes:B,updateData:I,direction:S,splitIndices:w,setSplitIndices:T,mapData:b,contentCenter:je}),{editingId:Ze,editText:Qe,setEditText:J,pendingEditId:Y,setPendingEditId:X,handleNodeDoubleClick:$e,commitEdit:et,cancelEdit:tt}=Ye({nodeMap:H,updateData:I,onTextChange:(e,t,n)=>{L({type:`nodeTextChange`,nodeId:e,oldText:t,newText:n})}}),nt=Xe(B),[rt,it]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(Fe||Y)return;let e=K();e?rt?(Ce(e.zoom),W({x:e.panX,y:e.panY})):(Ce(e.zoom*.92),W({x:e.panX,y:e.panY}),requestAnimationFrame(()=>{it(!0),we(e.zoom,e.panX,e.panY)})):rt||requestAnimationFrame(()=>it(!0))},[B,K,Fe,Y,Ce,W,rt,we]),(0,t.useEffect)(()=>{Y&&H[Y]&&Me(Y)},[Y,H,Me]);let at=(0,t.useCallback)(e=>{k(null),He(e)},[He]),ot=(0,t.useCallback)((e,t)=>{e.stopPropagation(),Ve.current||(D(t),L({type:`nodeSelect`,nodeId:t}))},[Ve,L]),st=(0,t.useCallback)(()=>{Ve.current||(D(null),L({type:`nodeSelect`,nodeId:null}))},[Ve,L]),ct=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=g.current;if(!t)return;let n=t.getBoundingClientRect();k({x:e.clientX-n.left,y:e.clientY-n.top})},[]),Z=(0,t.useCallback)(()=>{k(null)},[]),ut=(0,t.useCallback)(e=>{if(!e){ie(null);return}let t=H[e];if(!t||!t.remark){ie(null);return}let n=_.current;if(!n)return;let r=n.getBoundingClientRect(),i=(t.x+t.width/2)*G+U.x,a=(t.y-t.height/2)*G+U.y;ie({nodeId:e,text:t.remark,x:Math.min(i,r.width-300),y:a-8})},[H,G,U]),dt=(0,t.useCallback)((e,t,n)=>{if(e.stopPropagation(),c)return;let r=De(),i={id:r,text:z.newNode};b.some(e=>e.id===t)&&n&&S===`both`?I(e=>e.map(e=>{if(e.id!==t)return e;let r=e.children||[],a=w[t]??Math.ceil(r.length/2),o=a,s=r.length-a,c=n;n===`right`&&o>=3*Math.max(s,1)?c=`left`:n===`left`&&s>=3*Math.max(o,1)&&(c=`right`);let l=Be(e,i,c,a);return T(e=>({...e,[t]:l.newSplitIndex})),l.data})):I(e=>Le(e,t,i)),L({type:`nodeAdd`,node:i,parentId:t}),X(r),J(``)},[I,b,S,w,X,J,z,c,L]),ft=(0,t.useCallback)(()=>{if(c)return;let e=De(),t={id:e,text:z.newNode};I(e=>[...e,t]),L({type:`nodeAdd`,node:t,parentId:null}),X(e),J(``),Z()},[I,Z,X,J,z,c,L]),pt=(0,t.useCallback)(()=>{let e=ge(B,V,{},R,v);Ct(new Blob([e],{type:`image/svg+xml;charset=utf-8`}),`mindmap.svg`),Z()},[B,V,R,Z,v]),mt=(0,t.useCallback)(async()=>{Ct(await ve(_e(B,V,{pngSafe:!0},R,v)),`mindmap.png`),Z()},[B,V,R,Z,v]),ht=(0,t.useCallback)(()=>{let e=xe(b,v);Ct(new Blob([e],{type:`text/markdown;charset=utf-8`}),`mindmap.md`),Z()},[b,Z,v]),Q=(0,t.useCallback)(()=>{let e=K();e&&we(e.zoom,e.panX,e.panY)},[K,we]),$=(0,t.useCallback)(e=>{C(e),T({}),L({type:`directionChange`,direction:e})},[L]),vt=(0,t.useCallback)(()=>{te(e=>{if(e===`view`)return F(xe(b,v)),L({type:`modeChange`,mode:`text`}),`text`;{let e=v?Se(P,v).roots:be(P);return I(()=>e),T({}),L({type:`modeChange`,mode:`view`}),`view`}})},[b,P,I,v,L]),yt=(0,t.useCallback)(()=>{let e=g.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen())},[]);(0,t.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;ne(e),L({type:`fullscreenChange`,fullscreen:e})};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[L]);let bt=(0,t.useRef)(G);(0,t.useEffect)(()=>{G!==bt.current&&(bt.current=G,L({type:`zoomChange`,zoom:G}))},[G,L]);let xt=(0,t.useCallback)(e=>{if(e.key===`Escape`&&O){e.preventDefault(),Z();return}if(Ze)return;let t=e.metaKey||e.ctrlKey;if(e.shiftKey&&!t){if(e.code===`Equal`){e.preventDefault(),ke();return}if(e.code===`Minus`){e.preventDefault(),Ae();return}if(e.code===`Digit0`){e.preventDefault(),Q();return}if(e.code===`KeyL`){e.preventDefault(),$(`left`);return}if(e.code===`KeyR`){e.preventDefault(),$(`right`);return}if(e.code===`KeyM`){e.preventDefault(),$(`both`);return}}if(e.key===`Enter`&&!t&&E&&!c){e.preventDefault();let t=De(),n={id:t,text:z.newNode};b.some(e=>e.id===E)&&S===`both`?I(e=>e.map(e=>{if(e.id!==E)return e;let t=e.children||[],r=Be(e,n,`right`,w[E]??Math.ceil(t.length/2));return T(e=>({...e,[E]:r.newSplitIndex})),r.data})):I(e=>Le(e,E,n)),X(t),J(``),L({type:`nodeAdd`,node:n,parentId:E});return}if((e.key===`Delete`||e.key===`Backspace`)&&E&&!c){if(e.preventDefault(),b.some(e=>e.id===E)&&b.length<=1)return;L({type:`nodeDelete`,nodeId:E}),I(e=>Re(e,E)),D(null);return}if(t&&e.key===`c`&&E){e.preventDefault(),j.current=ze(b,E);return}if(t&&e.key===`x`&&E&&!c){if(e.preventDefault(),j.current=ze(b,E),b.some(e=>e.id===E)&&b.length<=1)return;L({type:`nodeDelete`,nodeId:E}),I(e=>Re(e,E)),D(null);return}if(t&&e.key===`v`&&E&&j.current&&!c){e.preventDefault();let t=Pe(j.current);I(e=>Le(e,E,t)),L({type:`nodeAdd`,node:t,parentId:E});return}},[Ze,E,b,S,w,I,O,Z,X,J,z,ke,Ae,Q,$,c,L]);(0,t.useImperativeHandle)(h,()=>({exportToSVG(){return ge(B,V,{},R,v)},async exportToPNG(){return ve(_e(B,V,{},R,v))},exportToOutline(){return xe(b,v)},getData(){return b},setData(e){x(Oe(e)),T({})},setMarkdown(e){x(v?Se(e,v).roots:be(e)),T({})},fitView(){Q()},setDirection(e){$(e)}}),[B,V,b,v,Q,$,R]),(0,t.useEffect)(()=>{if(!O)return;let e=()=>Z();return window.addEventListener(`click`,e),()=>window.removeEventListener(`click`,e)},[O,Z]);let wt=(0,t.useCallback)(e=>{x(v?Se(e,v).roots:be(e)),T({})},[v]),Tt=(0,t.useCallback)(()=>{setTimeout(()=>Q(),100)},[Q]),Et=(0,t.useCallback)(()=>{},[]),Dt=(0,t.useCallback)(e=>{if(e.key!==`Tab`)return;e.preventDefault();let t=e.currentTarget,{selectionStart:n,selectionEnd:r,value:i}=t;if(e.shiftKey){let e=i.lastIndexOf(`
|
|
77
|
+
`,n-1)+1;if(n===r){let a=i.slice(e,r),o=a.match(/^ {1,2}/);if(!o)return;let s=o[0].length;F(i.slice(0,e)+a.slice(s)+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=Math.max(e,n-s)})}else{let a=i.slice(e,r).split(`
|
|
19
78
|
`),o=0,s=0,c=a.map((e,t)=>{let n=e.match(/^ {1,2}/),r=n?n[0].length:0;return o+=r,t===0&&(s=r),e.slice(r)}).join(`
|
|
20
|
-
`);
|
|
79
|
+
`);F(i.slice(0,e)+c+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=n-s,t.selectionEnd=r-o})}}else if(n===r)F(i.slice(0,n)+` `+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=n+2});else{let e=i.lastIndexOf(`
|
|
21
80
|
`,n-1)+1,a=i.slice(e,r).split(`
|
|
22
81
|
`),o=a.map(e=>` `+e).join(`
|
|
23
|
-
`);
|
|
24
|
-
`)){let n=e.match(/^(\w[\w-]*)\s*:\s*(.+)/);n&&(t.frontMatter[n[1].trim()]=n[2].trim())}return e.slice(n[0].length)},serializePreamble(e){return``}},
|
|
82
|
+
`);F(i.slice(0,e)+o+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=n+2,t.selectionEnd=r+a.length*2})}},[]);return(0,n.jsxs)(`div`,{ref:g,className:`mindmap-container`,style:l(R),children:[M===`text`&&(0,n.jsx)(`textarea`,{className:`mindmap-text-editor`,value:P,onChange:e=>F(e.target.value),onKeyDown:Dt,readOnly:c,style:c?{opacity:.7}:void 0}),(0,n.jsx)(`svg`,{ref:_,className:`mindmap-svg ${Ne?`dragging-canvas`:``} ${Fe?`dragging-node`:``}`,style:M===`text`?{display:`none`}:void 0,tabIndex:0,onMouseDown:at,onMouseMove:Ue,onMouseUp:We,onMouseLeave:We,onClick:st,onKeyDown:xt,onContextMenu:ct,children:(0,n.jsxs)(`g`,{className:`mindmap-canvas${rt?` mindmap-canvas-ready`:``}`,transform:`translate(${U.x}, ${U.y}) scale(${G})`,opacity:rt?1:0,children:[(0,n.jsxs)(`g`,{className:`mindmap-edges`,children:[V.some(e=>e.isCrossLink)&&(0,n.jsx)(`defs`,{children:(0,n.jsx)(`marker`,{id:`mindmap-arrowhead`,markerWidth:`8`,markerHeight:`6`,refX:`8`,refY:`3`,orient:`auto`,children:(0,n.jsx)(`path`,{d:`M0,0 L8,3 L0,6`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5})})}),V.map(e=>{let t=ye[e.toId],r=t!==void 0;return(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`path`,{d:e.path,stroke:e.color,strokeWidth:R.connection.strokeWidth,strokeLinecap:`round`,strokeDasharray:r?void 0:e.strokeDasharray,markerEnd:e.isCrossLink?`url(#mindmap-arrowhead)`:void 0,opacity:e.isCrossLink?.7:1,fill:`none`,"data-branch-index":H[e.toId]?.branchIndex,className:[`mindmap-edge`,e.isCrossLink?`mindmap-edge-cross-link`:``,r?`mindmap-edge-expanding`:Ne||q.has(e.fromId)||q.has(e.toId)?``:`mindmap-edge-animated`].filter(Boolean).join(` `),style:r?{animationDelay:`${t}ms`}:void 0}),e.label&&(()=>{let t=H[e.fromId],r=H[e.toId];return!t||!r?null:(0,n.jsx)(`text`,{className:`mindmap-edge-label`,x:(t.x+r.x)/2,y:(t.y+r.y)/2-6,textAnchor:`middle`,fontSize:11,fill:e.color,opacity:.8,fontFamily:R.node.fontFamily,children:e.label})})()]},e.key)})]}),(0,n.jsx)(`g`,{className:`mindmap-nodes`,children:B.map(e=>{let t=q.has(e.id),r=t||Ne?``:`mindmap-node-animated`;return(0,n.jsx)(lt,{node:e,isEditing:Ze===e.id,isPendingEdit:Y===e.id,isSelected:E===e.id,isNew:nt.has(e.id),isGhost:t,animClass:r,editText:Qe,theme:R,direction:S,onMouseDown:Je,onClick:ot,onDoubleClick:c?()=>{}:$e,onEditChange:J,onEditCommit:et,onEditCancel:tt,onAddChild:dt,onRemarkHover:ut,onFoldToggle:v?e=>{oe[e]||(le(e),setTimeout(()=>le(null),800)),se(t=>({...t,[e]:!t[e]}))}:void 0,expandDelay:ye[e.id],readonly:c,plugins:v},e.id)})}),Fe&&Ie&&(()=>{let e=H[Fe];if(!e)return null;let t=Ie.x-e.x,r=Ie.y-e.y,i=e.parentId?H[e.parentId]:null;return(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsx)(`path`,{className:`mindmap-floating-edge`,d:me(i.x,i.y,i.width,Ie.x,Ie.y,e.width,e.side),stroke:e.color,strokeWidth:R.connection.strokeWidth,strokeLinecap:`round`,fill:`none`}),(0,n.jsxs)(`g`,{className:`mindmap-floating`,transform:`translate(${t}, ${r})`,children:[V.filter(e=>q.has(e.fromId)&&q.has(e.toId)).map(e=>(0,n.jsx)(`path`,{className:`mindmap-floating-edge`,d:e.path,stroke:e.color,strokeWidth:R.connection.strokeWidth,strokeLinecap:`round`,fill:`none`},`fl-${e.key}`)),B.filter(e=>q.has(e.id)).map(e=>(0,n.jsx)(lt,{node:e,isEditing:!1,isPendingEdit:!1,isSelected:!1,isNew:!1,animClass:``,editText:``,theme:R,direction:S,onMouseDown:()=>{},onClick:()=>{},onDoubleClick:()=>{},onEditChange:()=>{},onEditCommit:()=>{},onEditCancel:()=>{},onAddChild:()=>{},readonly:!0},`fl-${e.id}`))]})]})})(),v&&ae(v,B,V,R).map((e,t)=>(0,n.jsx)(`g`,{className:`mindmap-plugin-overlay`,children:e},`plugin-overlay-${t}`))]})}),(0,n.jsx)(gt,{zoom:G,theme:R,messages:z,showZoom:pe.zoom,mode:M,isFullscreen:N,onZoomIn:ke,onZoomOut:Ae,onAutoFit:Q,onModeToggle:vt,onFullscreenToggle:yt}),d&&(0,n.jsx)(St,{config:d,theme:R,messages:z,currentMarkdown:xe(b,v),onMarkdownStream:wt,onComplete:Tt,onError:Et}),O&&(0,n.jsx)(_t,{position:O,theme:R,messages:z,direction:S,readonly:c,onNewRootNode:ft,onExportSVG:pt,onExportPNG:mt,onExportMarkdown:ht,onDirectionChange:$,onClose:Z}),re&&(0,n.jsx)(`div`,{className:`mindmap-remark-tooltip`,style:{left:re.x,top:re.y,transform:`translateY(-100%)`},children:re.text})]})}),Tt={name:`front-matter`,preParseMarkdown(e,t){let n=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!n)return e;let r=n[1];for(let e of r.split(`
|
|
83
|
+
`)){let n=e.match(/^(\w[\w-]*)\s*:\s*(.+)/);n&&(t.frontMatter[n[1].trim()]=n[2].trim())}return e.slice(n[0].length)},serializePreamble(e){return``}},Et={name:`dotted-line`,parseLine(e){let t=e.match(/^(\s*)-\.\s+(.+)/);return t?{indent:t[1].replace(/\t/g,` `).length,text:t[2].trim(),dottedLine:!0}:null},serializeListMarker(e,t){return e.dottedLine?`-. `:t},transformEdge(e,t,n){return n.dottedLine?{...e,strokeDasharray:`6 4`}:e}},Dt={name:`folding`,parseLine(e){let t=e.match(/^(\s*)\+\s+(.+)/);return t?{indent:t[1].replace(/\t/g,` `).length,text:t[2].trim(),collapsed:!0}:null},serializeListMarker(e,t){return e.collapsed?`+ `:t},filterChildren(e,t,n){return!n.readonly||!e.collapsed||n.foldOverrides[e.id]?t:[]}},Ot={name:`multi-line`,collectFollowLines(e,t,n){let r=0,i=[],a=t;for(;a<e.length;){let t=e[a].match(/^(\s*)\|\s?(.*)$/);if(t)i.push(t[2]),r++,a++;else break}return i.length>0&&(n.multiLineContent=i),r},serializeFollowLines(e,t){return!e.multiLineContent||e.multiLineContent.length===0?[]:e.multiLineContent.map(e=>`| ${e}`)},adjustNodeSize(e,t,n,r){if(!e.multiLineContent||e.multiLineContent.length===0)return{width:t,height:n};let i=r*1.4;return{width:t,height:n+e.multiLineContent.length*i}},exportNodeDecoration(e,t,n){if(!e.multiLineContent||e.multiLineContent.length===0)return``;let r=e.depth===0?t.root.fontSize:e.depth===1?t.level1.fontSize:t.node.fontSize,i=e.depth===0?t.root.fontFamily:t.node.fontFamily,a=e.depth===0?t.root.textColor:t.node.textColor,o=r*.85,s=r*1.4,c=r/2+8,l=[];for(let r=0;r<e.multiLineContent.length;r++){let u=c+r*s;l.push(w(e.multiLineContent[r],o,400,i,a,u,n,t.highlight.textColor,t.highlight.bgColor,.8))}return l.join(``)}},kt=/((?:\s+#[\w-]+)+)$/,At=[`#3B82F6`,`#8B5CF6`,`#EC4899`,`#F59E0B`,`#10B981`,`#6366F1`],jt={name:`tags`,transformNodeData(e){let t=e.text.match(kt);if(!t)return e;let n=t[1],r=e.text.slice(0,e.text.length-n.length).trim(),i=[],a=/#([\w-]+)/g,o;for(;(o=a.exec(n))!==null;)i.push(o[1]);return i.length>0?{...e,text:r,tags:i}:e},serializeNodeText(e,t){return!e.tags||e.tags.length===0?t:t+` `+e.tags.map(e=>`#`+e).join(` `)},adjustNodeSize(e,t,n,r){if(!e.tags||e.tags.length===0)return{width:t,height:n};let i=r*.65,a=0;for(let t of e.tags)a+=t.length*i*.65+10+4;return{width:Math.max(t,a+16),height:n+(i+10)}},exportNodeDecoration(e,t){if(!e.tags||e.tags.length===0)return``;let n=e.depth===0?t.root.fontSize:e.depth===1?t.level1.fontSize:t.node.fontSize,r=e.depth===0?t.root.fontFamily:t.node.fontFamily,i=n*.65,a=n*1.4,o=e.multiLineContent?e.multiLineContent.length*a:0,s=n/2+6+o,c=i+6,l=0,u=[];for(let t of e.tags){let e=t.length*i*.65+10;u.push(e),l+=e}l+=(e.tags.length-1)*4;let d=-l/2,f=[];for(let t=0;t<e.tags.length;t++){let n=e.tags[t],a=u[t],o=At[t%At.length];f.push(`<rect x="${d}" y="${s}" width="${a}" height="${c}" rx="3" fill="${o}" opacity="0.15"/>`),f.push(`<text x="${d+a/2}" y="${s+c/2}" text-anchor="middle" dominant-baseline="central" font-size="${i}" fill="${o}" font-family="${r}">${b(n)}</text>`),d+=a+4}return f.join(``)}},Mt=/\{#([\w-]+)\}/,Nt=/(-?\.?)>\s*\{#([\w-]+)\}(?:\s+"([^"]*)")?/g,Pt={name:`cross-link`,transformNodeData(e){let t=e.text,n,r=[],i=new RegExp(Nt.source,`g`),a;for(;(a=i.exec(t))!==null;){let e=a[1]===`-.`;r.push({targetAnchorId:a[2],label:a[3]||void 0,dotted:e})}t=t.replace(new RegExp(Nt.source,`g`),``).trim();let o=t.match(Mt);return o&&(n=o[1],t=t.replace(Mt,``).trim()),n||r.length>0?{...e,text:t,...n?{anchorId:n}:{},...r.length>0?{crossLinks:r}:{}}:e},serializeNodeText(e,t){let n=t;if(e.anchorId&&(n+=` {#${e.anchorId}}`),e.crossLinks)for(let t of e.crossLinks){let e=t.dotted?`-.>`:`->`;n+=` ${e} {#${t.targetAnchorId}}`,t.label&&(n+=` "${t.label}"`)}return n},generateExtraEdges(e,t){let n=[],r=new Map;for(let t of e)t.anchorId&&r.set(t.anchorId,t);function i(t){if(t.crossLinks){let i=e.find(e=>e.id===t.id);if(i)for(let e of t.crossLinks){let t=r.get(e.targetAnchorId);if(t){let r=Ft(i,t);n.push({key:`xlink-${i.id}-${t.id}`,path:r,color:i.color,fromId:i.id,toId:t.id,strokeDasharray:`6 4`,isCrossLink:!0,label:e.label})}}}if(t.children)for(let e of t.children)i(e)}for(let e of t)i(e);return n}};function Ft(e,t){let n=e.x,r=e.y,i=t.x,a=t.y,o=i-n,s=a-r,c=Math.sqrt(o*o+s*s),l=(n+i)/2,u=(r+a)/2,d=Math.min(c*.3,60),f=-s/c,p=o/c;return`M ${n},${r} Q ${l+f*d},${u+p*d} ${i},${a}`}var It=[Tt,Et,Dt,Ot,jt,Pt,at];e.MindMap=wt,e.allPlugins=It,e.buildExportSVG=ge,e.buildExportSVGForPNG=_e,e.crossLinkPlugin=Pt,e.detectLocale=Te,e.dottedLinePlugin=Et,e.exportToPNG=ve,e.foldingPlugin=Dt,e.frontMatterPlugin=Tt,e.latexPlugin=at,e.multiLinePlugin=Ot,e.parseInlineMarkdown=f,e.parseMarkdownList=ye,e.parseMarkdownMultiRoot=be,e.parseMarkdownWithFrontMatter=Se,e.resolveMessages=Ee,e.stripInlineMarkdown=m,e.tagsPlugin=jt,e.toMarkdownList=W,e.toMarkdownMultiRoot=xe});
|
package/dist/plugins/tags.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MindMapPlugin } from
|
|
1
|
+
import type { MindMapPlugin } from "./types";
|
|
2
2
|
export declare const tagsPlugin: MindMapPlugin;
|
package/dist/style.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.mindmap-container{width:100%;height:100%;position:relative;overflow:hidden}.mindmap-svg{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;width:100%;height:100%;display:block}.mindmap-svg:focus{outline:none}.mindmap-svg.dragging-canvas,.mindmap-svg.dragging-node{cursor:grabbing}.mindmap-node-animated{transition:transform .3s ease-out}.mindmap-edge-animated{transition:d .3s ease-out}@keyframes mindmap-node-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}.mindmap-node-new{animation:.3s ease-out mindmap-node-appear}@keyframes mindmap-expand-appear{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.mindmap-node-expanding{animation:.3s ease-out both mindmap-expand-appear}@keyframes mindmap-edge-draw{0%{stroke-dashoffset:300px}to{stroke-dashoffset:0}}.mindmap-edge-expanding{stroke-dasharray:300;animation:.3s ease-out both mindmap-edge-draw}.mindmap-edit-input{text-align:center;box-sizing:border-box;background:0 0;border:none;outline:none;width:100%;height:100%;margin:0;padding:0}.mindmap-edit-root{color:#fff;background:0 0}.mindmap-edit-child{color:inherit;background:0 0;border-radius:4px}.mindmap-zoom-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;left:16px;box-shadow:0 2px 8px #0000001a}.mindmap-ctrl-btn{cursor:pointer;width:32px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:background .15s,color .15s;display:flex}.mindmap-ctrl-btn:hover{background:#80808033}.mindmap-ctrl-pct{cursor:pointer;min-width:48px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:system-ui,sans-serif;font-size:13px;font-weight:500;transition:background .15s;display:flex}.mindmap-ctrl-pct:hover{background:#80808033}.mindmap-extra-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:20;border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;right:16px;box-shadow:0 2px 8px #0000001a}.mindmap-text-editor{resize:none;box-sizing:border-box;z-index:10;border:none;outline:none;width:100%;height:100%;padding:24px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:15px;line-height:1.7;position:absolute;inset:0}.mindmap-add-btn{opacity:0;cursor:pointer;transition:opacity .2s}.mindmap-node-g:hover .mindmap-add-btn{opacity:1}.mindmap-context-menu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;border:1px solid;border-radius:8px;min-width:150px;padding:4px 0;font-family:system-ui,-apple-system,sans-serif;position:absolute}.mindmap-ctx-item{cursor:pointer;white-space:nowrap;justify-content:space-between;align-items:center;padding:8px 16px;font-size:14px;display:flex;position:relative}.mindmap-ctx-item:hover{filter:brightness(.92);background:#8080801a}.mindmap-ctx-arrow{opacity:.5;margin-left:12px;font-size:8px}.mindmap-ctx-divider{opacity:.3;border-top:1px solid;height:0;margin:4px 8px}.mindmap-ctx-submenu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid;border-radius:8px;min-width:140px;padding:4px 0;position:absolute;top:-4px;left:100%}.mindmap-ctx-has-sub{position:relative}.mindmap-dialog-backdrop{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:2000;background:#0003;justify-content:center;align-items:center;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;display:flex;position:absolute;inset:0}@keyframes mindmap-fade-in{0%{opacity:0}to{opacity:1}}.mindmap-dialog-modal{border:1px solid;border-radius:12px;width:calc(100% - 32px);max-width:480px;max-height:80%;padding:24px;animation:.2s ease-out mindmap-dialog-enter;position:relative;overflow-y:auto;box-shadow:0 8px 32px #0003}@keyframes mindmap-dialog-enter{0%{opacity:0;transform:scale(.95)translateY(8px)}to{opacity:1;transform:scale(1)translateY(0)}}.mindmap-dialog-header{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.mindmap-dialog-title{margin:0;font-size:16px;font-weight:600}.mindmap-dialog-close{cursor:pointer;width:28px;height:28px;color:inherit;opacity:.5;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;transition:opacity .15s,background .15s;display:flex}.mindmap-dialog-close:hover{opacity:1;background:#80808033}@media (width<=500px){.mindmap-dialog-modal{max-height:90%;padding:16px}}@media (width<=768px){.mindmap-ctrl-btn{width:28px;height:28px}.mindmap-ctrl-btn svg{width:14px;height:14px}.mindmap-ctrl-pct{min-width:40px;height:28px;font-size:12px}.mindmap-zoom-controls,.mindmap-extra-controls{gap:1px;padding:3px;bottom:12px}.mindmap-zoom-controls{left:12px}.mindmap-extra-controls{right:12px}}.mindmap-node-content{white-space:nowrap;box-sizing:border-box;justify-content:center;align-items:center;gap:4px;line-height:1;display:flex;overflow:hidden}.mindmap-node-root-content{line-height:1}.mindmap-node-content strong{font-weight:700}.mindmap-node-content em{font-style:italic}.mindmap-node-content del{opacity:.6;text-decoration:line-through}.mindmap-node-content .mindmap-inline-code{background:#8080801f;border-radius:3px;padding:1px 4px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:.88em}.mindmap-node-content .mindmap-highlight{color:#fac800;background:#fcd34d33;border-radius:2px;padding:1px 2px}.mindmap-node-content .mindmap-link{color:#2563eb;cursor:pointer;text-decoration:none}.mindmap-node-content .mindmap-link:hover{text-decoration:underline}.mindmap-node-content .mindmap-inline-image{vertical-align:middle;border-radius:2px;max-width:80px;max-height:1.2em}.mindmap-node-root-content .mindmap-inline-code{background:#ffffff26}.mindmap-node-root-content .mindmap-highlight{color:#fcd34d;background:#fbbf2433}.mindmap-node-root-content .mindmap-link{color:#93c5fd}.mindmap-task-icon{vertical-align:middle;flex-shrink:0}.mindmap-remark-indicator{opacity:.5;cursor:help;flex-shrink:0;font-size:.7em;line-height:1;transition:opacity .15s}.mindmap-remark-indicator:hover{opacity:1}.mindmap-remark-tooltip{white-space:pre-wrap;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;pointer-events:none;border-radius:8px;max-width:280px;padding:8px 12px;font-family:system-ui,-apple-system,sans-serif;font-size:13px;line-height:1.5;animation:.15s ease-out mindmap-fade-in;position:absolute;box-shadow:0 4px 16px #00000026}
|
|
1
|
+
.mindmap-container{width:100%;height:100%;position:relative;overflow:hidden}.mindmap-svg{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;background:var(--mindmap-canvas-bg);width:100%;height:100%;display:block}.mindmap-svg:focus{outline:none}.mindmap-svg.dragging-canvas,.mindmap-svg.dragging-node{cursor:grabbing}.mindmap-node-g{cursor:pointer}.mindmap-node-ghost{opacity:.3}.mindmap-canvas-ready{transition:opacity .4s ease-out}.mindmap-floating,.mindmap-floating-edge,.mindmap-edge-label{pointer-events:none}.mindmap-fold-btn{cursor:pointer}.mindmap-latex{pointer-events:none;overflow:visible}.mindmap-latex-content{white-space:nowrap;text-align:center}.mindmap-node-animated{transition:transform .3s ease-out}.mindmap-edge-animated{transition:d .3s ease-out}@keyframes mindmap-node-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}.mindmap-node-new{animation:.3s ease-out mindmap-node-appear}@keyframes mindmap-expand-appear{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.mindmap-node-expanding{animation:.3s ease-out both mindmap-expand-appear}@keyframes mindmap-edge-draw{0%{stroke-dashoffset:300px}to{stroke-dashoffset:0}}.mindmap-edge-expanding{stroke-dasharray:300;animation:.3s ease-out both mindmap-edge-draw}.mindmap-edit-input{text-align:center;box-sizing:border-box;background:0 0;border:none;outline:none;width:100%;height:100%;margin:0;padding:0}.mindmap-edit-root{color:#fff;background:0 0}.mindmap-edit-child{color:inherit;background:0 0;border-radius:4px}.mindmap-zoom-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:var(--mindmap-controls-bg);color:var(--mindmap-controls-text);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;left:16px;box-shadow:0 2px 8px #0000001a}.mindmap-ctrl-btn{cursor:pointer;width:32px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:background .15s,color .15s;display:flex}.mindmap-ctrl-btn:hover{background:#80808033}.mindmap-ctrl-pct{cursor:pointer;min-width:48px;height:32px;color:inherit;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:system-ui,sans-serif;font-size:13px;font-weight:500;transition:background .15s;display:flex}.mindmap-ctrl-pct:hover{background:#80808033}.mindmap-extra-controls{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:20;background:var(--mindmap-controls-bg);color:var(--mindmap-controls-text);border-radius:8px;align-items:center;gap:2px;padding:4px;display:flex;position:absolute;bottom:16px;right:16px;box-shadow:0 2px 8px #0000001a}.mindmap-text-editor{resize:none;box-sizing:border-box;z-index:10;background:var(--mindmap-canvas-bg);width:100%;height:100%;color:var(--mindmap-node-text);border:none;outline:none;padding:24px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:15px;line-height:1.7;position:absolute;inset:0}.mindmap-add-btn{opacity:0;cursor:pointer;transition:opacity .2s}.mindmap-node-g:hover .mindmap-add-btn{opacity:1}.mindmap-context-menu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;background:var(--mindmap-ctx-bg);min-width:150px;color:var(--mindmap-ctx-text);border:1px solid;border-color:var(--mindmap-ctx-border);box-shadow:0 4px 16px var(--mindmap-ctx-shadow);border-radius:8px;padding:4px 0;font-family:system-ui,-apple-system,sans-serif;position:absolute}.mindmap-ctx-item{cursor:pointer;white-space:nowrap;justify-content:space-between;align-items:center;padding:8px 16px;font-size:14px;display:flex;position:relative}.mindmap-ctx-item:hover{filter:brightness(.92);background:#8080801a}.mindmap-ctx-arrow{opacity:.5;margin-left:12px;font-size:8px}.mindmap-ctx-divider{opacity:.3;border-top:1px solid;height:0;margin:4px 8px}.mindmap-ctx-submenu{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);background:var(--mindmap-ctx-bg);border:1px solid;border-color:var(--mindmap-ctx-border);min-width:140px;box-shadow:0 4px 16px var(--mindmap-ctx-shadow);border-radius:8px;padding:4px 0;position:absolute;top:-4px;left:100%}.mindmap-ctx-has-sub{position:relative}.mindmap-dialog-backdrop{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:2000;background:#0003;justify-content:center;align-items:center;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;display:flex;position:absolute;inset:0}@keyframes mindmap-fade-in{0%{opacity:0}to{opacity:1}}.mindmap-dialog-modal{border:1px solid;border-radius:12px;width:calc(100% - 32px);max-width:480px;max-height:80%;padding:24px;animation:.2s ease-out mindmap-dialog-enter;position:relative;overflow-y:auto;box-shadow:0 8px 32px #0003}@keyframes mindmap-dialog-enter{0%{opacity:0;transform:scale(.95)translateY(8px)}to{opacity:1;transform:scale(1)translateY(0)}}.mindmap-dialog-header{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.mindmap-dialog-title{margin:0;font-size:16px;font-weight:600}.mindmap-dialog-close{cursor:pointer;width:28px;height:28px;color:inherit;opacity:.5;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;transition:opacity .15s,background .15s;display:flex}.mindmap-dialog-close:hover{opacity:1;background:#80808033}@media (width<=500px){.mindmap-dialog-modal{max-height:90%;padding:16px}}@media (width<=768px){.mindmap-ctrl-btn{width:28px;height:28px}.mindmap-ctrl-btn svg{width:14px;height:14px}.mindmap-ctrl-pct{min-width:40px;height:28px;font-size:12px}.mindmap-zoom-controls,.mindmap-extra-controls{gap:1px;padding:3px;bottom:12px}.mindmap-zoom-controls{left:12px}.mindmap-extra-controls{right:12px}}.mindmap-node-content{white-space:nowrap;box-sizing:border-box;justify-content:center;align-items:center;gap:4px;line-height:1;display:flex;overflow:hidden}.mindmap-node-root-content{line-height:1}.mindmap-node-content strong{font-weight:700}.mindmap-node-content em{font-style:italic}.mindmap-node-content del{opacity:.6;text-decoration:line-through}.mindmap-node-content .mindmap-inline-code{background:#8080801f;border-radius:3px;padding:1px 4px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:.88em}.mindmap-node-content .mindmap-highlight{color:#fac800;background:#fcd34d33;border-radius:2px;padding:1px 2px}.mindmap-node-content .mindmap-link{color:#2563eb;cursor:pointer;text-decoration:none}.mindmap-node-content .mindmap-link:hover{text-decoration:underline}.mindmap-node-content .mindmap-inline-image{vertical-align:middle;border-radius:2px;max-width:80px;max-height:1.2em}.mindmap-node-root-content .mindmap-inline-code{background:#ffffff26}.mindmap-node-root-content .mindmap-highlight{color:#fcd34d;background:#fbbf2433}.mindmap-node-root-content .mindmap-link{color:#93c5fd}.mindmap-task-icon{vertical-align:middle;flex-shrink:0}.mindmap-remark-indicator{opacity:.5;cursor:help;flex-shrink:0;font-size:.7em;line-height:1;transition:opacity .15s}.mindmap-remark-indicator:hover{opacity:1}.mindmap-remark-tooltip{white-space:pre-wrap;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:1000;pointer-events:none;background:var(--mindmap-ctx-bg);max-width:280px;color:var(--mindmap-ctx-text);border:1px solid var(--mindmap-ctx-border);border-radius:8px;padding:8px 12px;font-family:system-ui,-apple-system,sans-serif;font-size:13px;line-height:1.5;animation:.15s ease-out mindmap-fade-in;position:absolute;box-shadow:0 4px 16px #00000026}.mindmap-ai-input{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:30;background:var(--mindmap-controls-bg);width:calc(100% - 32px);max-width:600px;color:var(--mindmap-controls-text);border:1px solid;border-color:var(--mindmap-ctx-border);border-radius:26px;outline:none;font-family:system-ui,-apple-system,sans-serif;animation:.15s ease-out mindmap-fade-in;position:absolute;bottom:56px;left:50%;transform:translate(-50%)}.mindmap-ai-input-row{align-items:center;gap:4px;padding:6px 6px 6px 16px;display:flex}.mindmap-ai-input-field{color:inherit;background:0 0;border:none;outline:none;flex:1;min-width:0;font-family:inherit;font-size:14px;line-height:1.5}.mindmap-ai-input-field:focus{box-shadow:none}.mindmap-ai-input-field::placeholder{opacity:.5}.mindmap-ai-input-field:disabled{opacity:.5;cursor:not-allowed}.mindmap-ai-send-btn{cursor:pointer;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:36px;height:36px;transition:background .15s,opacity .15s,transform .1s;display:flex;position:relative}.mindmap-ai-send-btn:hover:not(:disabled){opacity:.85;transform:scale(1.05)}.mindmap-ai-send-btn:disabled{cursor:not-allowed;opacity:.4}.mindmap-ai-send-btn--loading{cursor:pointer}@keyframes mindmap-ai-spin{to{transform:rotate(360deg)}}.mindmap-ai-spinner{justify-content:center;align-items:center;transition:opacity .2s;animation:.8s linear infinite mindmap-ai-spin;display:flex}.mindmap-ai-stop-icon{opacity:0;color:#ef4444;justify-content:center;align-items:center;transition:opacity .2s,transform .2s;display:flex;position:absolute;transform:scale(.5)}.mindmap-ai-send-btn--loading:hover .mindmap-ai-spinner{opacity:0}.mindmap-ai-send-btn--loading:hover .mindmap-ai-stop-icon{opacity:1;transform:scale(1)}.mindmap-ai-send-btn--loading:hover{background:#ef44441a!important}.mindmap-ai-attach-btn{cursor:pointer;opacity:.5;background:0 0;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;transition:opacity .15s,background .15s;display:flex}.mindmap-ai-attach-btn:hover:not(:disabled){opacity:1;background:#80808026}.mindmap-ai-attach-btn:disabled{cursor:not-allowed;opacity:.3}.mindmap-ai-file-previews{flex-wrap:wrap;gap:6px;padding:8px 12px 0;display:flex}.mindmap-ai-file-chip{background:var(--mindmap-controls-hover);border-radius:12px;align-items:center;gap:4px;max-width:160px;padding:3px 8px;font-size:12px;display:inline-flex}.mindmap-ai-file-name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mindmap-ai-file-remove{cursor:pointer;opacity:.5;background:0 0;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:16px;height:16px;padding:0;transition:opacity .15s;display:flex}.mindmap-ai-file-remove:hover{opacity:1}.mindmap-ai-error{color:#ef4444;padding:0 16px 8px;font-size:12px;animation:.15s ease-out mindmap-fade-in}@media (width<=768px){.mindmap-ai-input{border-radius:20px;max-width:calc(100% - 24px);bottom:48px}.mindmap-ai-input-row{padding:4px 4px 4px 12px}.mindmap-ai-send-btn{width:32px;height:32px}}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/types.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface LayoutNode {
|
|
|
35
35
|
parentId?: string;
|
|
36
36
|
remark?: string;
|
|
37
37
|
taskStatus?: TaskStatus;
|
|
38
|
+
branchIndex?: number;
|
|
38
39
|
dottedLine?: boolean;
|
|
39
40
|
multiLineContent?: string[];
|
|
40
41
|
tags?: string[];
|
|
@@ -80,6 +81,14 @@ export type MindMapEvent = {
|
|
|
80
81
|
type: 'fullscreenChange';
|
|
81
82
|
fullscreen: boolean;
|
|
82
83
|
};
|
|
84
|
+
export type AIAttachmentType = 'text' | 'image' | 'pdf';
|
|
85
|
+
export interface MindMapAIConfig {
|
|
86
|
+
apiUrl: string;
|
|
87
|
+
apiKey: string;
|
|
88
|
+
model: string;
|
|
89
|
+
systemPrompt?: string;
|
|
90
|
+
attachments?: AIAttachmentType[];
|
|
91
|
+
}
|
|
83
92
|
export interface MindMapProps {
|
|
84
93
|
data?: MindMapData | MindMapData[];
|
|
85
94
|
markdown?: string;
|
|
@@ -89,6 +98,7 @@ export interface MindMapProps {
|
|
|
89
98
|
messages?: Partial<import('./utils/i18n').MindMapMessages>;
|
|
90
99
|
readonly?: boolean;
|
|
91
100
|
toolbar?: boolean | ToolbarConfig;
|
|
101
|
+
ai?: MindMapAIConfig;
|
|
92
102
|
onDataChange?: (data: MindMapData[]) => void;
|
|
93
103
|
onEvent?: (event: MindMapEvent) => void;
|
|
94
104
|
plugins?: import('./plugins/types').MindMapPlugin[];
|
package/dist/utils/export.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ interface ExportOptions {
|
|
|
9
9
|
pngSafe?: boolean;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Build SVG string for export.
|
|
12
|
+
* Build SVG string for export. Embeds a <style> block with resolved values
|
|
13
|
+
* and applies semantic CSS classes to elements for external customization.
|
|
13
14
|
* Works for both SVG file export and PNG conversion.
|
|
14
15
|
*/
|
|
15
16
|
export declare function buildExportSVG(nodes: LayoutNode[], edges: Edge[], options?: ExportOptions, theme?: ThemeColors, plugins?: MindMapPlugin[]): string;
|
package/dist/utils/i18n.d.ts
CHANGED