@xiangfa/mindmap 0.3.0 → 0.4.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 +74 -6
- package/README.zh-CN.md +74 -6
- package/dist/components/MindMapAIInput.d.ts +13 -0
- package/dist/components/icons.d.ts +4 -0
- package/dist/esm/MindMap2.js +289 -275
- package/dist/esm/components/MindMapAIInput.js +209 -0
- 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/i18n.js +6 -0
- package/dist/esm/utils/markdown.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mindmap.umd.cjs +76 -14
- package/dist/plugins/tags.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/utils/i18n.d.ts +3 -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,86 @@
|
|
|
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
|
|
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 k(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 ee(e,t,n){for(let r of e)r.serializeNodeText&&(n=r.serializeNodeText(t,n));return n}function A(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 j(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 M(e,t,n,r){for(let i of e)i.filterChildren&&(n=i.filterChildren(t,n,r));return n}function N(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 I(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 L(e,t,n){for(let r of e)if(r.renderInlineToken){let e=r.renderInlineToken(t,n);if(e)return e}return null}function te(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 ne(e,t,n,r,i){let a=``;for(let o of e)o.exportNodeDecoration&&(a+=o.exportNodeDecoration(t,n,r,i));return a}function re(e,t,n,r){let i=``;for(let a of e)a.exportOverlay&&(i+=a.exportOverlay(t,n,r));return i}var ie=null;function ae(){return ie||=document.createElement(`canvas`).getContext(`2d`),ie}function oe(e,t,n,r){let i=ae();return i.font=`${n} ${t}px ${r||c.root.fontFamily}`,i.measureText(e).width}var se=4,ce=20;function R(e,t,n,r,i){let a=oe(f(e),t,n);return r&&(a+=t*.9+se),i&&(a+=ce),a}function le(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=R(e.text,d,f,e.taskStatus,!!e.remark)+p*2,g=d+m*2;if(o&&o.length>0){let t=j(o,e,h,g,d);h=t.width,g=t.height}let _=e.children||[];o&&o.length>0&&s&&(_=M(o,e,_,s));let v=i;if(o&&o.length>0){let r=F(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 le(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 V(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)V(n,t)}function ue(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 de(e,t,n,r){for(let i of e.children){let a={key:`${e.id}-${i.id}`,path:ue(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=N(r,a,t,o))}t.push(a),de(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=le({...e,children:[]},0,`root`,c.root.bgColor,void 0,a,l),h=d.map((t,i)=>le(t,1,`right`,n?.[t.id]??r[i%r.length],e.id,a,l)),g=f.map((i,o)=>le(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(V(m,b),de(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 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:ue(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:ue(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(ne(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(ne(i,t,r,i,s)),_.push(`</g>`)}}return i&&i.length>0&&_.push(re(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
3
|
`);r&&(r.lines=a);let o=[],s=null,c=[],l=0;for(;l<a.length;){let e=a[l],t=n&&r?w(n,e,l,r):null;if(t){let e=t.text.trim(),i=t.taskStatus,{taskStatus:s,text:c}=i?{taskStatus:i,text:e}:U(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=T(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}=U(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=T(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=E(n,e,e.text,r)),e};if(s!==null){let e={id:`md-0`,text:s,children:[],...c.length>0?{remark:c.join(`
|
|
4
4
|
`)}:{}};if(n&&r&&(e=E(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(`
|
|
5
|
-
`)}:{}};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(
|
|
5
|
+
`)}:{}};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(ge(e),n&&r){let[t]=D(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
6
|
`)}:{}};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=
|
|
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(ge(p),n&&r){let[e]=D(n,[p],r);return e}return p}function ge(e){if(e.children&&e.children.length===0)delete e.children;else if(e.children)for(let t of e.children)ge(t)}function G(e,t=0,n){let r=n&&n.length>0?n:void 0,i;if(t===0){let t=e.text;r&&(t=ee(r,e,t)),i=t+`
|
|
8
|
+
`}else{let n=``;e.taskStatus&&(n={todo:`[ ]`,doing:`[-]`,done:`[x]`}[e.taskStatus]+` `);let a=`- `;r&&(a=k(r,e,a));let o=e.text;r&&(o=ee(r,e,o)),i=` `.repeat(t-1)+a+n+o+`
|
|
9
9
|
`}if(e.remark){let n=t===0?` `:` `.repeat(t);for(let t of e.remark.split(`
|
|
10
10
|
`))i+=n+`> `+t+`
|
|
11
|
-
`}if(r){let n=
|
|
12
|
-
`}if(e.children)for(let r of e.children)i+=
|
|
11
|
+
`}if(r){let n=A(r,e,t),a=t===0?` `:` `.repeat(t);for(let e of n)i+=a+e+`
|
|
12
|
+
`}if(e.children)for(let r of e.children)i+=G(r,t+1,n);return i}function _e(e,t){let n=t&&t.length>0?t:void 0,r=e,i=n?{lines:[],frontMatter:{}}:void 0;n&&i&&(r=C(n,r,i)),r=r.split(`
|
|
13
13
|
`).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=[W(r,o)];return n&&i?D(n,e,i):e}let s=a.map((e,t)=>{let n=W(e,o);return
|
|
15
|
-
`);return r+i}function
|
|
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=[W(r,o)];return n&&i?D(n,e,i):e}let s=a.map((e,t)=>{let n=W(e,o);return K(n,`md-${t}`),n});return n&&i?D(n,s,i):s}function K(e,t){if(e.id=t,e.children)for(let n=0;n<e.children.length;n++)K(e.children[n],`${t}-${n}`)}function ve(e,t){let n=t&&t.length>0?t:void 0,r=``;n&&(r=O(n,e));let i=e.map(e=>G(e,0,t)).join(`
|
|
15
|
+
`);return r+i}function ye(e,t){let n={lines:[],frontMatter:{}},r=C(t,e,n);r=r.split(`
|
|
16
16
|
`).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
|
-
|
|
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 K(n,`md-${t}`),n}),o=D(t,o,n),{roots:o,frontMatter:n.frontMatter}}var q={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:`关闭`},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`,aiPlaceholder:`Ask AI to generate a mind map...`,aiGenerating:`Generating...`,aiError:`Generation failed`,close:`Close`},xe={"zh-CN":q,"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]??q;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 Ie(e,t,n){return e.map(e=>ke(e,t,n))}function Le(e,t){for(let n of e){let e=Ae(n,t);if(e)return e}return null}function Re(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 J(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);(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 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=J(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=>Ie(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]),ee=(0,t.useCallback)(()=>{h(!1),_(null),y(null)},[]),A=(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),N=(0,t.useRef)(o),P=(0,t.useRef)(p),F=(0,t.useRef)(g);(0,t.useEffect)(()=>{j.current=r,M.current=n,N.current=o,P.current=p,F.current=g});let I=(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:{...P.current},touchNodeId:null},F.current&&(_(null),y(null)),h(!1);return}if(t.length===1){let r=t[0],i=I(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=N.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:{...P.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:{...P.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=N.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=J(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=>Ie(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,I,l,f,u,d,c,s]),{draggingCanvas:m,floatingNodeId:g,floatingPos:v,floatingSubtreeIds:T,didDragRef:S,handleCanvasMouseDown:O,handleMouseMove:k,handleMouseUp:ee,handleNodeMouseDown:A}}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,Xe=!1,Y=null,X=[];function Ze(){return Y||(Y=import(`katex`).then(e=>{Ye=e.default||e,Xe=!0,et();for(let e of X)e();X=[]}).catch(()=>{Xe=!0}),Y)}function Qe(){return Ye}function $e(e){Xe?e():X.push(e)}Ze();function et(){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 tt(e,t){let n=Qe();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t})}catch{return null}}function nt(e,t){let n=Qe();if(!n)return null;try{return n.renderToString(e,{throwOnError:!1,displayMode:t,output:`mathml`})}catch{return null}}var rt={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:Qe()?(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>`:Qe()?`<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||!Qe())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=nt(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=nt(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}}},it=`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace`;function at(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=L(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:it,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:it,fontStyle:`italic`,fontSize:`0.9em`,children:a.content},t);default:return(0,n.jsx)(`tspan`,{className:`mindmap-text-plain`,children:a.content},t)}}function ot({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 st({node:e,fontSize:r,fontWeight:i,fontFamily:a,textColor:o,onRemarkHover:s,plugins:c,highlightTextColor:l,highlightBgColor:d}){let[f,p]=(0,t.useState)(()=>!!Qe());(0,t.useEffect)(()=>{f||$e(()=>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)(ot,{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)=>at(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=tt(i.content,i.type===`latex-block`);if(!a)return null;et();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)=>at(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=tt(a.content,a.type===`latex-block`);if(!s)return null;et();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 ct({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`,ee=C===void 0?void 0:{animationDelay:`${C}ms`},A=(e.taskStatus===`done`?`[x] `:e.taskStatus===`doing`?`[-] `:e.taskStatus===`todo`?`[ ] `:``)+e.text,j=p&&p.length>0?I(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}`,onMouseDown:t=>m(t,e.id),onClick:t=>h(t,e.id),onDoubleClick:t=>g(t,e.id,A),style:{cursor:`pointer`,opacity:s?.3:1,...ee},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)(st,{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`,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 M=e.depth===1?u.level1.fontSize:u.node.fontSize,N=e.depth===1?u.level1.fontWeight:u.node.fontWeight,P=e.width-u.node.paddingH*2,F=M/2+4,L=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,A),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:M,fontWeight:N,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)(st,{node:e,fontSize:M,fontWeight:N,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:-P/2,y1:F,x2:P/2,y2:F,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:L,cy:0,r:11,fill:u.addBtn.fill}),(0,n.jsx)(`line`,{x1:L-4,y1:0,x2:L+4,y2:0,stroke:u.addBtn.iconColor,strokeWidth:2,strokeLinecap:`round`}),(0,n.jsx)(`line`,{x1:L,y1:-4,x2:L,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:L,cy:0,r:6,fill:e.color})})]},e.id)}function Z({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 lt({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 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:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,n.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})}function dt({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 ft({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 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)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})})}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 12a9 9 0 1 1-6.219-8.56`})})}function ht({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)(lt,{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)(Z,{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 gt({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})]})]})]})}var Q=`#Role
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
#Logic and Structure
|
|
21
|
+
- Primary Branches: Use the MECE (Mutually Exclusive, Collectively Exhaustive) principle to ensure no overlap and complete coverage of the topic.
|
|
22
|
+
- 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.
|
|
23
|
+
- Hierarchical Depth: The structure must not exceed a maximum depth of the Root + 3 levels.
|
|
24
|
+
- Logical Flow: Organize the sequence of branches and sub-nodes based on priority, moving from foundational concepts to advanced applications.
|
|
25
|
+
- Task Status Logic:
|
|
26
|
+
- \`- [x] \` : Assigned to foundational, prerequisite, or essential concepts.
|
|
27
|
+
- \`- [-] \` : Assigned to intermediate, active, or transitional concepts.
|
|
28
|
+
- \`- [ ] \` : Assigned to advanced, future-state, or specialized concepts.
|
|
29
|
+
|
|
30
|
+
#Formatting Standards
|
|
31
|
+
- Root Node: Place the root node on the first line of the response with no prefix (no hyphen, bullet, or number).
|
|
32
|
+
- Indentation: Use exactly two spaces per level of hierarchy to define the structure.
|
|
33
|
+
- Child Node Prefix: Every child node must start with a hyphen followed by a space ("- ").
|
|
34
|
+
- 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.
|
|
35
|
+
- Remarks: Insert contextual notes or brief explanations immediately after relevant nodes using the "> " prefix.
|
|
36
|
+
- Inline Styling: Use Obsidian-compatible Markdown for emphasis: **bold**, *italic*, \`code\`, ~~strikethrough~~, and ==highlighting==.
|
|
37
|
+
|
|
38
|
+
#Extended Syntax (Optional)
|
|
39
|
+
Use these features only when they naturally enhance the mind map's clarity or structure. Do not force them into every response.
|
|
40
|
+
- Dotted Lines: Use "-." instead of "-" for weak, optional, or tentative relationships. Example: "-. Optional Step"
|
|
41
|
+
- Multi-line Content: Use "|" prefix lines to append additional display lines to a node. Example:
|
|
42
|
+
- Main Point
|
|
43
|
+
| Supporting detail line 1
|
|
44
|
+
| Supporting detail line 2
|
|
45
|
+
- Tags: Add "#tag" at the end of node text for categorization. Example: "- React #frontend #framework"
|
|
46
|
+
- Cross-links: Define anchors with "{#id}" and link with "-> {#id}" to connect nodes across branches. Example:
|
|
47
|
+
- Node A {#a}
|
|
48
|
+
- Node B
|
|
49
|
+
-> {#a} "references"
|
|
50
|
+
- Folding: Use "+" instead of "-" to mark a node as initially collapsed (children hidden by default). Example: "+ Collapsed Section"
|
|
51
|
+
- LaTeX: Use "$...$" for inline math and "$$...$$" for display math. Example: "- Energy: $E = mc^2$"
|
|
52
|
+
- Frontmatter: Use a "---" block at the very top to set layout direction or theme:
|
|
53
|
+
---
|
|
54
|
+
direction: right
|
|
55
|
+
theme: dark
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
#Example Output
|
|
59
|
+
Project Management
|
|
60
|
+
- [x] **Foundational Concepts** #core
|
|
61
|
+
- Project Life Cycle
|
|
62
|
+
> Initiation through closing phases
|
|
63
|
+
| Planning, executing, monitoring
|
|
64
|
+
- Stakeholder Identification
|
|
65
|
+
- [-] *Execution Frameworks*
|
|
66
|
+
- ==Agile Methodologies==
|
|
67
|
+
-. Hybrid Approaches
|
|
68
|
+
- [ ] Advanced Optimization
|
|
69
|
+
- Resource Load Balancing
|
|
70
|
+
> Optimizing team allocation
|
|
71
|
+
- Portfolio Risk Mitigation
|
|
72
|
+
|
|
73
|
+
#Constraints
|
|
74
|
+
- Provide the raw Markdown output only.
|
|
75
|
+
- Do not include any introductory text, conversational fillers, or explanations.
|
|
76
|
+
- Do not include any concluding remarks or summaries.
|
|
77
|
+
- 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.
|
|
78
|
+
- FINAL NEGATIVE CONSTRAINT: Do not wrap the output in markdown code fences. Provide the response as raw, plain text.`;function $(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 _t(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 vt(e){let t=e.replace(/<think>[\s\S]*?<\/think>/g,``);return t=t.replace(/<think>[\s\S]*$/,``),t}async function*yt(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(`
|
|
79
|
+
`);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 bt({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=_t(t,p),i=e.systemPrompt||Q,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 yt(f))if(h+=e,!g){g=!0;let e=vt(h);y.current=requestAnimationFrame(()=>{o(e),g=!1})}cancelAnimationFrame(y.current),h&&o(vt(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`,style:{background:r.controls.bgColor,color:r.controls.textColor,borderColor:r.contextMenu.borderColor},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`,style:{background:r.controls.hoverBg},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),style:{color:r.controls.textColor},children:(0,n.jsx)(ut,{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,style:{color:r.controls.textColor},children:(0,n.jsx)(ft,{size:18})}),(0,n.jsx)(`input`,{ref:v,type:`file`,accept:$(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,style:{color:r.controls.textColor}}),(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)(mt,{size:20})}),(0,n.jsx)(`span`,{className:`mindmap-ai-stop-icon`,children:(0,n.jsx)(pt,{size:16})})]}):(0,n.jsx)(dt,{size:16})})]}),h&&(0,n.jsx)(`div`,{className:`mindmap-ai-error`,style:{color:`#ef4444`},children:h})]})}function xt(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 St=(0,t.forwardRef)(function({data:e,markdown:r,defaultDirection:i=`both`,theme:a=`auto`,locale:o,messages:s,readonly:c=!1,toolbar:l=!0,ai:u,onDataChange:d,onEvent:f,plugins:p},m){let h=(0,t.useRef)(null),g=(0,t.useRef)(null),_=p&&p.length>0?p:void 0,v=(0,t.useMemo)(()=>{if(e||r===void 0)return null;if(_){let e=ye(r,_),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:_e(r),direction:void 0,theme:void 0}},[]),[y,b]=(0,t.useState)(()=>e?Te(e):v?v.roots:[{id:`md-0`,text:`Root`}]),[x,S]=(0,t.useState)(()=>v?.direction??i),[C,w]=(0,t.useState)({}),[T,E]=(0,t.useState)(null),[D,O]=(0,t.useState)(null),[k,ee]=(0,t.useState)({}),A=(0,t.useRef)(null),[j,M]=(0,t.useState)(`view`),[N,P]=(0,t.useState)(!1),[F,I]=(0,t.useState)(``),[L,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)({}),[ae,oe]=(0,t.useState)(null),[se,ce]=(0,t.useState)(()=>v?.theme);(0,t.useEffect)(()=>{e&&b(Te(e))},[e]),(0,t.useEffect)(()=>{if(r!==void 0)if(_){let{roots:e,frontMatter:t}=ye(r,_);if(b(e),t.direction){let e=t.direction;(e===`left`||e===`right`||e===`both`)&&S(e)}if(t.theme){let e=t.theme;(e===`light`||e===`dark`||e===`auto`)&&ce(e)}}else b(_e(r))},[r,_]);let R=(0,t.useCallback)(e=>{b(t=>{let n=e(t);return d?.(n),n})},[d]),le=(0,t.useRef)(f);le.current=f;let z=(0,t.useCallback)(e=>{le.current?.(e)},[]),B=He(se??a),V=(0,t.useMemo)(()=>Ce(o??Se(),s),[o,s]),de=(0,t.useMemo)(()=>l===!1?{zoom:!1}:l===!0||l===void 0?{zoom:!0}:{zoom:l.zoom??!0},[l]),{nodes:H,edges:U}=(0,t.useMemo)(()=>fe(y,x,k,C,_,c,re),[y,x,k,C,_,c,re]);(0,t.useEffect)(()=>{let e={},t=!1;for(let n of H)n.depth===1&&!k[n.id]&&(e[n.id]=n.color,t=!0);t&&ee(t=>({...t,...e}))},[H,k]);let W=(0,t.useMemo)(()=>{let e={};for(let t of H)e[t.id]=t;return e},[H]),ge=(0,t.useMemo)(()=>{if(!ae)return{};let e={},t=[];for(let e of H)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 H)e.parentId===n&&t.push({id:e.id,depth:r+1})}return e},[ae,H]),{pan:G,setPan:K,zoom:q,setZoom:be,animateTo:xe,autoFit:Ee,zoomIn:De,zoomOut:Oe,contentCenter:ke,panToNode:Ae}=Ue(g,H),{draggingCanvas:Me,floatingNodeId:Ne,floatingPos:Ie,floatingSubtreeIds:J,didDragRef:ze,handleCanvasMouseDown:Be,handleMouseMove:Ve,handleMouseUp:Ge,handleNodeMouseDown:Je}=We({svgRef:g,zoom:q,pan:G,setPan:K,setZoom:be,nodeMap:W,nodes:H,updateData:R,direction:x,splitIndices:C,setSplitIndices:w,mapData:y,contentCenter:ke}),{editingId:Ye,editText:Xe,setEditText:Y,pendingEditId:X,setPendingEditId:Ze,handleNodeDoubleClick:Qe,commitEdit:$e,cancelEdit:et}=Ke({nodeMap:W,updateData:R,onTextChange:(e,t,n)=>{z({type:`nodeTextChange`,nodeId:e,oldText:t,newText:n})}}),tt=qe(H),[nt,rt]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(Ne||X)return;let e=Ee();e?nt?(be(e.zoom),K({x:e.panX,y:e.panY})):(be(e.zoom*.92),K({x:e.panX,y:e.panY}),requestAnimationFrame(()=>{rt(!0),xe(e.zoom,e.panX,e.panY)})):nt||requestAnimationFrame(()=>rt(!0))},[H,Ee,Ne,X,be,K,nt,xe]),(0,t.useEffect)(()=>{X&&W[X]&&Ae(X)},[X,W,Ae]);let it=(0,t.useCallback)(e=>{O(null),Be(e)},[Be]),at=(0,t.useCallback)((e,t)=>{e.stopPropagation(),ze.current||(E(t),z({type:`nodeSelect`,nodeId:t}))},[ze,z]),ot=(0,t.useCallback)(()=>{ze.current||(E(null),z({type:`nodeSelect`,nodeId:null}))},[ze,z]),st=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=h.current;if(!t)return;let n=t.getBoundingClientRect();O({x:e.clientX-n.left,y:e.clientY-n.top})},[]),Z=(0,t.useCallback)(()=>{O(null)},[]),lt=(0,t.useCallback)(e=>{if(!e){ne(null);return}let t=W[e];if(!t||!t.remark){ne(null);return}let n=g.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;ne({nodeId:e,text:t.remark,x:Math.min(i,r.width-300),y:a-8})},[W,q,G]),ut=(0,t.useCallback)((e,t,n)=>{if(e.stopPropagation(),c)return;let r=we(),i={id:r,text:V.newNode};y.some(e=>e.id===t)&&n&&x===`both`?R(e=>e.map(e=>{if(e.id!==t)return e;let r=e.children||[],a=C[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=Re(e,i,c,a);return w(e=>({...e,[t]:l.newSplitIndex})),l.data})):R(e=>Pe(e,t,i)),z({type:`nodeAdd`,node:i,parentId:t}),Ze(r),Y(``)},[R,y,x,C,Ze,Y,V,c,z]),dt=(0,t.useCallback)(()=>{if(c)return;let e=we(),t={id:e,text:V.newNode};R(e=>[...e,t]),z({type:`nodeAdd`,node:t,parentId:null}),Ze(e),Y(``),Z()},[R,Z,Ze,Y,V,c,z]),ft=(0,t.useCallback)(()=>{let e=pe(H,U,{},B,_);xt(new Blob([e],{type:`image/svg+xml;charset=utf-8`}),`mindmap.svg`),Z()},[H,U,B,Z,_]),pt=(0,t.useCallback)(async()=>{xt(await he(me(H,U,{pngSafe:!0},B,_)),`mindmap.png`),Z()},[H,U,B,Z,_]),mt=(0,t.useCallback)(()=>{let e=ve(y,_);xt(new Blob([e],{type:`text/markdown;charset=utf-8`}),`mindmap.md`),Z()},[y,Z,_]),Q=(0,t.useCallback)(()=>{let e=Ee();e&&xe(e.zoom,e.panX,e.panY)},[Ee,xe]),$=(0,t.useCallback)(e=>{S(e),w({}),z({type:`directionChange`,direction:e})},[z]),_t=(0,t.useCallback)(()=>{M(e=>{if(e===`view`)return I(ve(y,_)),z({type:`modeChange`,mode:`text`}),`text`;{let e=_?ye(F,_).roots:_e(F);return R(()=>e),w({}),z({type:`modeChange`,mode:`view`}),`view`}})},[y,F,R,_,z]),vt=(0,t.useCallback)(()=>{let e=h.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen())},[]);(0,t.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;P(e),z({type:`fullscreenChange`,fullscreen:e})};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[z]);let yt=(0,t.useRef)(q);(0,t.useEffect)(()=>{q!==yt.current&&(yt.current=q,z({type:`zoomChange`,zoom:q}))},[q,z]);let St=(0,t.useCallback)(e=>{if(e.key===`Escape`&&D){e.preventDefault(),Z();return}if(Ye)return;let t=e.metaKey||e.ctrlKey;if(e.shiftKey&&!t){if(e.code===`Equal`){e.preventDefault(),De();return}if(e.code===`Minus`){e.preventDefault(),Oe();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&&T&&!c){e.preventDefault();let t=we(),n={id:t,text:V.newNode};y.some(e=>e.id===T)&&x===`both`?R(e=>e.map(e=>{if(e.id!==T)return e;let t=e.children||[],r=Re(e,n,`right`,C[T]??Math.ceil(t.length/2));return w(e=>({...e,[T]:r.newSplitIndex})),r.data})):R(e=>Pe(e,T,n)),Ze(t),Y(``),z({type:`nodeAdd`,node:n,parentId:T});return}if((e.key===`Delete`||e.key===`Backspace`)&&T&&!c){if(e.preventDefault(),y.some(e=>e.id===T)&&y.length<=1)return;z({type:`nodeDelete`,nodeId:T}),R(e=>Fe(e,T)),E(null);return}if(t&&e.key===`c`&&T){e.preventDefault(),A.current=Le(y,T);return}if(t&&e.key===`x`&&T&&!c){if(e.preventDefault(),A.current=Le(y,T),y.some(e=>e.id===T)&&y.length<=1)return;z({type:`nodeDelete`,nodeId:T}),R(e=>Fe(e,T)),E(null);return}if(t&&e.key===`v`&&T&&A.current&&!c){e.preventDefault();let t=je(A.current);R(e=>Pe(e,T,t)),z({type:`nodeAdd`,node:t,parentId:T});return}},[Ye,T,y,x,C,R,D,Z,Ze,Y,V,De,Oe,Q,$,c,z]);(0,t.useImperativeHandle)(m,()=>({exportToSVG(){return pe(H,U,{},B,_)},async exportToPNG(){return he(me(H,U,{},B,_))},exportToOutline(){return ve(y,_)},getData(){return y},setData(e){b(Te(e)),w({})},setMarkdown(e){b(_?ye(e,_).roots:_e(e)),w({})},fitView(){Q()},setDirection(e){$(e)}}),[H,U,y,_,Q,$,B]),(0,t.useEffect)(()=>{if(!D)return;let e=()=>Z();return window.addEventListener(`click`,e),()=>window.removeEventListener(`click`,e)},[D,Z]);let Ct=(0,t.useCallback)(e=>{b(_?ye(e,_).roots:_e(e)),w({})},[_]),wt=(0,t.useCallback)(()=>{setTimeout(()=>Q(),100)},[Q]),Tt=(0,t.useCallback)(()=>{},[]),Et=(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(`
|
|
80
|
+
`,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;I(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
81
|
`),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
|
-
`);
|
|
82
|
+
`);I(i.slice(0,e)+c+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=n-s,t.selectionEnd=r-o})}}else if(n===r)I(i.slice(0,n)+` `+i.slice(r)),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=n+2});else{let e=i.lastIndexOf(`
|
|
21
83
|
`,n-1)+1,a=i.slice(e,r).split(`
|
|
22
84
|
`),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``}},
|
|
85
|
+
`);I(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:h,className:`mindmap-container`,children:[j===`text`&&(0,n.jsx)(`textarea`,{className:`mindmap-text-editor`,value:F,onChange:e=>I(e.target.value),onKeyDown:Et,readOnly:c,style:{background:B.canvas.bgColor,color:B.node.textColor,opacity:c?.7:1}}),(0,n.jsx)(`svg`,{ref:g,className:`mindmap-svg ${Me?`dragging-canvas`:``} ${Ne?`dragging-node`:``}`,style:{background:B.canvas.bgColor,display:j===`text`?`none`:`block`},tabIndex:0,onMouseDown:it,onMouseMove:Ve,onMouseUp:Ge,onMouseLeave:Ge,onClick:ot,onKeyDown:St,onContextMenu:st,children:(0,n.jsxs)(`g`,{className:`mindmap-canvas`,transform:`translate(${G.x}, ${G.y}) scale(${q})`,opacity:nt?1:0,style:{transition:nt?`opacity 0.4s ease-out`:`none`},children:[(0,n.jsxs)(`g`,{className:`mindmap-edges`,children:[U.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})})}),U.map(e=>{let t=ge[e.toId],r=t!==void 0;return(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`path`,{d:e.path,stroke:e.color,strokeWidth:B.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`,className:[`mindmap-edge`,e.isCrossLink?`mindmap-edge-cross-link`:``,r?`mindmap-edge-expanding`:Me||J.has(e.fromId)||J.has(e.toId)?``:`mindmap-edge-animated`].filter(Boolean).join(` `),style:r?{animationDelay:`${t}ms`}:void 0}),e.label&&(()=>{let t=W[e.fromId],r=W[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:B.node.fontFamily,style:{pointerEvents:`none`},children:e.label})})()]},e.key)})]}),(0,n.jsx)(`g`,{className:`mindmap-nodes`,children:H.map(e=>{let t=J.has(e.id),r=t||Me?``:`mindmap-node-animated`;return(0,n.jsx)(ct,{node:e,isEditing:Ye===e.id,isPendingEdit:X===e.id,isSelected:T===e.id,isNew:tt.has(e.id),isGhost:t,animClass:r,editText:Xe,theme:B,direction:x,onMouseDown:Je,onClick:at,onDoubleClick:c?()=>{}:Qe,onEditChange:Y,onEditCommit:$e,onEditCancel:et,onAddChild:ut,onRemarkHover:lt,onFoldToggle:_?e=>{re[e]||(oe(e),setTimeout(()=>oe(null),800)),ie(t=>({...t,[e]:!t[e]}))}:void 0,expandDelay:ge[e.id],readonly:c,plugins:_},e.id)})}),Ne&&Ie&&(()=>{let e=W[Ne];if(!e)return null;let t=Ie.x-e.x,r=Ie.y-e.y,i=e.parentId?W[e.parentId]:null;return(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsx)(`path`,{className:`mindmap-floating-edge`,d:ue(i.x,i.y,i.width,Ie.x,Ie.y,e.width,e.side),stroke:e.color,strokeWidth:B.connection.strokeWidth,strokeLinecap:`round`,fill:`none`,style:{pointerEvents:`none`}}),(0,n.jsxs)(`g`,{className:`mindmap-floating`,transform:`translate(${t}, ${r})`,style:{pointerEvents:`none`},children:[U.filter(e=>J.has(e.fromId)&&J.has(e.toId)).map(e=>(0,n.jsx)(`path`,{className:`mindmap-floating-edge`,d:e.path,stroke:e.color,strokeWidth:B.connection.strokeWidth,strokeLinecap:`round`,fill:`none`},`fl-${e.key}`)),H.filter(e=>J.has(e.id)).map(e=>(0,n.jsx)(ct,{node:e,isEditing:!1,isPendingEdit:!1,isSelected:!1,isNew:!1,animClass:``,editText:``,theme:B,direction:x,onMouseDown:()=>{},onClick:()=>{},onDoubleClick:()=>{},onEditChange:()=>{},onEditCommit:()=>{},onEditCancel:()=>{},onAddChild:()=>{},readonly:!0},`fl-${e.id}`))]})]})})(),_&&te(_,H,U,B).map((e,t)=>(0,n.jsx)(`g`,{className:`mindmap-plugin-overlay`,children:e},`plugin-overlay-${t}`))]})}),(0,n.jsx)(ht,{zoom:q,theme:B,messages:V,showZoom:de.zoom,mode:j,isFullscreen:N,onZoomIn:De,onZoomOut:Oe,onAutoFit:Q,onModeToggle:_t,onFullscreenToggle:vt}),u&&(0,n.jsx)(bt,{config:u,theme:B,messages:V,currentMarkdown:ve(y,_),onMarkdownStream:Ct,onComplete:wt,onError:Tt}),D&&(0,n.jsx)(gt,{position:D,theme:B,messages:V,direction:x,readonly:c,onNewRootNode:dt,onExportSVG:ft,onExportPNG:pt,onExportMarkdown:mt,onDirectionChange:$,onClose:Z}),L&&(0,n.jsx)(`div`,{className:`mindmap-remark-tooltip`,style:{left:L.x,top:L.y,transform:`translateY(-100%)`,background:B.contextMenu.bgColor,color:B.contextMenu.textColor,borderColor:B.contextMenu.borderColor,border:`1px solid ${B.contextMenu.borderColor}`},children:L.text})]})}),Ct={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(`
|
|
86
|
+
`)){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``}},wt={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}},Tt={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:[]}},Et={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(S(e.multiLineContent[r],o,400,i,a,u,n,t.highlight.textColor,t.highlight.bgColor,.8))}return l.join(``)}},Dt=/((?:\s+#[\w-]+)+)$/,Ot=[`#3B82F6`,`#8B5CF6`,`#EC4899`,`#F59E0B`,`#10B981`,`#6366F1`],kt={name:`tags`,transformNodeData(e){let t=e.text.match(Dt);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=Ot[t%Ot.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}">${v(n)}</text>`),d+=a+4}return f.join(``)}},At=/\{#([\w-]+)\}/,jt=/(-?\.?)>\s*\{#([\w-]+)\}(?:\s+"([^"]*)")?/g,Mt={name:`cross-link`,transformNodeData(e){let t=e.text,n,r=[],i=new RegExp(jt.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(jt.source,`g`),``).trim();let o=t.match(At);return o&&(n=o[1],t=t.replace(At,``).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=Nt(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 Nt(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 Pt=[Ct,wt,Tt,Et,kt,Mt,rt];e.MindMap=St,e.allPlugins=Pt,e.buildExportSVG=pe,e.buildExportSVGForPNG=me,e.crossLinkPlugin=Mt,e.detectLocale=Se,e.dottedLinePlugin=wt,e.exportToPNG=he,e.foldingPlugin=Tt,e.frontMatterPlugin=Ct,e.latexPlugin=rt,e.multiLinePlugin=Et,e.parseInlineMarkdown=u,e.parseMarkdownList=W,e.parseMarkdownMultiRoot=_e,e.parseMarkdownWithFrontMatter=ye,e.resolveMessages=Ce,e.stripInlineMarkdown=f,e.tagsPlugin=kt,e.toMarkdownList=G,e.toMarkdownMultiRoot=ve});
|
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;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}.mindmap-ai-input{-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);z-index:30;border:1px solid;border-radius:26px;outline:none;width:calc(100% - 32px);max-width:600px;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{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{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
|
@@ -80,6 +80,14 @@ export type MindMapEvent = {
|
|
|
80
80
|
type: 'fullscreenChange';
|
|
81
81
|
fullscreen: boolean;
|
|
82
82
|
};
|
|
83
|
+
export type AIAttachmentType = 'text' | 'image' | 'pdf';
|
|
84
|
+
export interface MindMapAIConfig {
|
|
85
|
+
apiUrl: string;
|
|
86
|
+
apiKey: string;
|
|
87
|
+
model: string;
|
|
88
|
+
systemPrompt?: string;
|
|
89
|
+
attachments?: AIAttachmentType[];
|
|
90
|
+
}
|
|
83
91
|
export interface MindMapProps {
|
|
84
92
|
data?: MindMapData | MindMapData[];
|
|
85
93
|
markdown?: string;
|
|
@@ -89,6 +97,7 @@ export interface MindMapProps {
|
|
|
89
97
|
messages?: Partial<import('./utils/i18n').MindMapMessages>;
|
|
90
98
|
readonly?: boolean;
|
|
91
99
|
toolbar?: boolean | ToolbarConfig;
|
|
100
|
+
ai?: MindMapAIConfig;
|
|
92
101
|
onDataChange?: (data: MindMapData[]) => void;
|
|
93
102
|
onEvent?: (event: MindMapEvent) => void;
|
|
94
103
|
plugins?: import('./plugins/types').MindMapPlugin[];
|
package/dist/utils/i18n.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiangfa/mindmap",
|
|
3
3
|
"description": "A beautiful, interactive mind map component for React.",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"main": "dist/mindmap.umd.cjs",
|
|
8
9
|
"module": "dist/esm/index.js",
|
package/dist/esm/logo.svg
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<svg width="192px" height="192px" viewBox="0 0 192 192" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
-
<title>192x192@1x</title>
|
|
4
|
-
<g id="192x192" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
-
<g id="open-mindmap" transform="translate(27, 34)" fill="#FF6B6B">
|
|
6
|
-
<path d="M65.2942453,0.192083517 C59.8455194,1.55726816 56.0732557,5.16121182 54.5364241,10.4696141 C52.70243,16.8043764 55.6897191,23.6276034 61.685779,26.7992536 C63.6786478,27.8534745 64.4640698,27.9981715 68.203216,28 C72.0828879,28.0022158 72.664682,27.8853798 74.8553607,26.6671389 C84.6626198,21.2131409 84.2960895,6.40731353 74.2314984,1.46290056 C71.8349541,0.28555238 67.4240594,-0.341318119 65.2942453,0.192083517 M66.6757112,8.41163667 C65.2714183,8.9725578 63.4030866,11.3751699 63.0901196,13.0223193 C62.4389317,16.4479447 65.4121182,20 68.9305166,20 C73.5641418,20 76.2676535,15.7120696 74.4060861,11.3146261 C73.2746248,8.64134723 69.5776458,7.25284486 66.6757112,8.41163667 M26.9077072,14.3521949 C22.6763866,15.428857 18.6913715,18.6921892 16.9676837,22.4922536 C16.2247148,24.129858 16.0031749,25.5048062 16,28.4986303 C15.9946195,33.1761949 16.9424678,35.5035573 20.1669528,38.728062 C23.1446822,41.7063551 26.2156204,42.8131656 30.6297563,42.4984349 C32.4871786,42.3659648 34.6872671,42.1160988 35.5184918,41.9425173 C36.9400389,41.6465152 37.1885958,41.799541 39.6993805,44.5174618 C42.7000743,47.7670902 44.8141586,51.7407361 45.4868832,55.3973674 C45.7358903,56.7508463 45.9394188,61.1611867 45.9394188,65.1978702 L45.9394188,72.5380836 L56.0118258,82.7844167 C69.0714182,96.0702533 67.1149334,95.8400294 77.5363107,85.3173362 C81.7379125,81.0750958 86.2254447,76.3865681 87.5087547,74.8992488 L89.8421274,72.1941181 L90.0672695,62.9970395 L90.2924116,53.799504 L91.9526094,50.3941091 C93.000871,48.2435257 94.5710119,46.0079787 96.2136487,44.3283493 C98.6429319,41.8443067 98.9203069,41.6876266 100.407596,41.9548507 C101.283398,42.1124445 103.549679,42.3559154 105.444024,42.4966077 C108.535676,42.7254612 109.170126,42.6235963 111.640835,41.4985141 C120.764944,37.3448916 122.890285,25.0562351 115.670429,18.2052474 C112.571122,15.2644114 109.955872,14.1653664 106.017686,14.1484651 C101.716572,14.1301933 97.6009742,16.1053681 95.0095887,19.4308241 C91.9719716,23.329556 91.2299032,27.5160676 92.6302871,32.848674 L93.3926182,35.7502258 L90.041153,39.3186959 C83.8781133,45.8823605 81.9644054,51.3136343 81.9585518,62.2602317 L81.9553998,68.9248477 L77.6434784,73.6069802 C75.2722818,76.1819247 73.0510299,78.2891127 72.7074631,78.2891127 C72.1864842,78.2891127 72.0622058,74.9663974 71.9568393,58.2267458 L71.8307597,38.1639222 L70.7392709,36.9858519 C69.2506313,35.3788527 66.6097145,35.3523587 65.0562341,36.9287528 L63.9507864,38.0497238 L63.9507864,58.1696467 C63.9507864,74.1195024 63.8323617,78.2891127 63.3793758,78.2891127 C63.0650774,78.2891127 60.8555329,76.28516 58.4694769,73.8353769 L54.1305385,69.3816411 L53.9171038,61.616153 C53.7468964,55.4097008 53.5145497,53.2545495 52.7603237,50.8815077 C51.3968632,46.5903903 48.8554592,42.4861015 45.3454939,38.9066683 L42.275006,35.7758062 L43.0630034,33.3936285 C44.9024143,27.8307983 43.5596668,21.9884105 39.5724003,18.2052474 C35.8913271,14.7121481 31.1552379,13.2714217 26.9077072,14.3521949 M27.235249,23.6088612 C21.7500564,26.3640569 23.6694642,35 29.7671564,35 C33.6469267,35 35.9981786,32.7733704 36,29.0976786 C36.001819,25.7316654 33.9099466,23.427279 30.4966042,23.0348995 C29.411761,22.9103989 28.2031438,23.1229939 27.235249,23.6088612 M103.103845,23.7565027 C100.88837,24.9235968 99.7892725,27.0996711 100.033466,29.8358433 C100.197626,31.6746976 100.503208,32.2870535 101.873784,33.5206982 C103.241176,34.7516631 103.871895,35 105.629906,35 C108.463368,35 110.501041,33.7199037 111.475541,31.3276513 C112.365915,29.1421973 112.120812,27.1398695 110.753874,25.4332234 C108.774407,22.9614673 105.835901,22.3173994 103.103845,23.7565027 M11.3176117,51.4490768 C6.67273908,52.3691606 2.55622295,55.8705277 0.905221,60.3055025 C-3.25973528,71.4939189 7.67518117,82.5448412 18.842431,78.4330903 C20.1992038,77.9336034 21.6232547,77.4196909 22.0067392,77.2912128 C22.6216601,77.0851969 37.1940734,87.8210097 51.0802511,98.7109962 L54.9482872,101.744432 L55.1725472,111.557908 L55.3968072,121.370932 L56.8616733,122.685466 L58.3265395,124 L68.6007861,124 L78.8754811,124 L80.2551285,122.832878 L81.6352244,121.665755 L81.6352244,112.019527 L81.6352244,102.373299 L84.8869941,99.6950936 C86.6752431,98.2218777 93.9919491,92.5300712 101.145842,87.0460837 C110.655362,79.7561896 114.394225,77.1338834 115.049961,77.293016 C115.543333,77.4129289 117.158005,77.9511846 118.638121,78.4889896 C125.471322,80.9724492 132.927069,77.708654 136.064915,70.8605443 C136.795554,69.2669647 137.015329,67.9285382 137,65.170541 C136.97541,60.9925224 135.846037,58.2534589 132.953532,55.3584184 C126.117191,48.5166199 114.810003,50.5718192 110.475057,59.4440229 C109.336714,61.7742104 109.225929,62.427871 109.290516,66.4237663 L109.361831,70.8325947 L101.665677,76.6691081 C88.1522193,86.9171548 74.7011059,97.4266657 74.1225152,98.1889693 C73.7197443,98.7191106 73.5618653,101.317975 73.5618653,107.406486 L73.5618653,115.885592 L68.4038858,115.885592 L63.2459063,115.885592 L63.2459063,107.345628 C63.2459063,99.1248311 63.2082307,98.7632891 62.2367364,97.674606 C61.3612255,96.6936642 49.3826031,87.3566852 32.3926673,74.4119503 L27.3629645,70.5801464 L27.7002515,68.7769446 C28.238924,65.8931741 27.9254085,61.9495718 26.9875533,59.818638 C25.889128,57.3234575 23.2634921,54.3869434 20.8984464,53.0088464 C19.4030809,52.1374491 14.5047945,50.8224642 13.4897938,51.0199148 C13.3503041,51.0469628 12.3725306,51.2399054 11.3176117,51.4490768 M10.2857859,59.7135188 C8.1500563,60.7305963 7.00185926,62.7045033 7,65.3625611 C6.99816582,67.2918398 7.19853475,67.7283039 8.79040584,69.2675318 C10.4159795,70.8388921 10.8079455,71 13,71 C15.1920545,71 15.5840205,70.8388921 17.2095942,69.2675318 C18.8014653,67.7283039 19.0018342,67.2918398 19,65.3625611 C18.9981407,62.6696932 17.8300915,60.7006954 15.639422,59.6956675 C13.6057236,58.7629373 12.2728547,58.7674002 10.2857859,59.7135188 M120.527041,59.6974997 C117.432794,61.2687562 116.166924,64.6438655 117.568696,67.5851537 C119.606327,71.8619653 125.604018,72.1945016 128.101556,68.1695572 C129.309374,66.2236371 129.299474,64.1903254 128.071405,62.0144981 C126.449581,59.1408823 123.441735,58.21722 120.527041,59.6974997" id="形状"></path>
|
|
7
|
-
</g>
|
|
8
|
-
</g>
|
|
9
|
-
</svg>
|