flow-mindmap 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flow-mindmap.js +695 -750
- package/dist/flow-mindmap.umd.cjs +9 -13
- package/package.json +1 -1
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
(function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.FlowMind={},T.Vue))})(this,function(T,e){"use strict";const Rt=["width","height","stroke-width"],Lt={key:4,points:"6 9 12 15 18 9"},Tt={key:5,points:"9 6 15 12 9 18"},H=e.defineComponent({__name:"Icon",props:{name:{},size:{},stroke:{}},setup(i){return(s,l)=>(e.openBlock(),e.createElementBlock("svg",{width:i.size??16,height:i.size??16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":i.stroke??1.8,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[i.name==="add"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[0]||(l[0]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[1]||(l[1]=e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"16"},null,-1)),l[2]||(l[2]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):i.name==="minus"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[4]||(l[4]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):i.name==="delete"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createStaticVNode('<polyline points="4 7 20 7"></polyline><path d="M9 7 V5 a1 1 0 0 1 1 -1 h4 a1 1 0 0 1 1 1 V7"></path><path d="M6 7 l1 12 a1 1 0 0 0 1 1 h8 a1 1 0 0 0 1 -1 l1 -12"></path><line x1="10" y1="11" x2="10" y2="18"></line><line x1="14" y1="11" x2="14" y2="18"></line>',5))],64)):i.name==="edit"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[l[6]||(l[6]=e.createElementVNode("path",{d:"M4 20 l4 -1 11 -11 -3 -3 -11 11 z"},null,-1)),l[7]||(l[7]=e.createElementVNode("line",{x1:"14",y1:"6",x2:"18",y2:"10"},null,-1))],64)):i.name==="collapse"?(e.openBlock(),e.createElementBlock("polyline",Lt)):i.name==="expand"?(e.openBlock(),e.createElementBlock("polyline",Tt)):i.name==="zoom-in"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[l[8]||(l[8]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[9]||(l[9]=e.createElementVNode("line",{x1:"11",y1:"8",x2:"11",y2:"14"},null,-1)),l[10]||(l[10]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[11]||(l[11]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):i.name==="zoom-out"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[l[12]||(l[12]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[13]||(l[13]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[14]||(l[14]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):i.name==="reset"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:8},[l[15]||(l[15]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[16]||(l[16]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"4"},null,-1)),l[17]||(l[17]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"0.8",fill:"currentColor"},null,-1))],64)):i.name==="logo"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:9},[l[18]||(l[18]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2"></circle><circle cx="4" cy="5" r="1.6"></circle><circle cx="20" cy="5" r="1.6"></circle><circle cx="4" cy="19" r="1.6"></circle><circle cx="20" cy="19" r="1.6"></circle><line x1="10.5" y1="10.8" x2="5.2" y2="6.4"></line><line x1="13.5" y1="10.8" x2="18.8" y2="6.4"></line><line x1="10.5" y1="13.2" x2="5.2" y2="17.6"></line><line x1="13.5" y1="13.2" x2="18.8" y2="17.6"></line>',9))],64)):i.name==="import"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:10},[l[19]||(l[19]=e.createElementVNode("path",{d:"M12 4 V15"},null,-1)),l[20]||(l[20]=e.createElementVNode("polyline",{points:"7 10 12 15 17 10"},null,-1)),l[21]||(l[21]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):i.name==="export"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:11},[l[22]||(l[22]=e.createElementVNode("path",{d:"M12 15 V4"},null,-1)),l[23]||(l[23]=e.createElementVNode("polyline",{points:"7 9 12 4 17 9"},null,-1)),l[24]||(l[24]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):i.name==="balance"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:12},[l[25]||(l[25]=e.createStaticVNode('<line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line><polyline points="9 4 5 6 9 8"></polyline><polyline points="15 4 19 6 15 8"></polyline><polyline points="9 10 5 12 9 14"></polyline><polyline points="15 10 19 12 15 14"></polyline><polyline points="9 16 5 18 9 20"></polyline><polyline points="15 16 19 18 15 20"></polyline>',9))],64)):i.name==="mindmap"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:13},[l[26]||(l[26]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none"></circle><line x1="13" y1="11" x2="19" y2="6"></line><line x1="13" y1="13" x2="19" y2="18"></line><line x1="11" y1="11" x2="5" y2="6"></line><line x1="11" y1="13" x2="5" y2="18"></line>',5))],64)):i.name==="tree"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:14},[l[27]||(l[27]=e.createStaticVNode('<circle cx="6" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="6" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="18" r="2" fill="currentColor" stroke="none"></circle><line x1="8" y1="12" x2="16" y2="6"></line><line x1="8" y1="12" x2="16" y2="12"></line><line x1="8" y1="12" x2="16" y2="18"></line>',7))],64)):i.name==="org"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:15},[l[28]||(l[28]=e.createStaticVNode('<circle cx="12" cy="5" r="2" fill="currentColor" stroke="none"></circle><circle cx="6" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="12" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="19" r="2" fill="currentColor" stroke="none"></circle><line x1="12" y1="7" x2="12" y2="13"></line><line x1="6" y1="13" x2="18" y2="13"></line><line x1="6" y1="13" x2="6" y2="17"></line><line x1="12" y1="13" x2="12" y2="17"></line><line x1="18" y1="13" x2="18" y2="17"></line>',9))],64)):i.name==="image"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:16},[l[29]||(l[29]=e.createElementVNode("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"},null,-1)),l[30]||(l[30]=e.createElementVNode("circle",{cx:"9",cy:"11",r:"1.6"},null,-1)),l[31]||(l[31]=e.createElementVNode("polyline",{points:"3 17 9 12 13 15 16 13 21 17"},null,-1))],64)):i.name==="x"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:17},[l[32]||(l[32]=e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),l[33]||(l[33]=e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1))],64)):i.name==="link"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:18},[l[34]||(l[34]=e.createElementVNode("path",{d:"M10 13 a4 4 0 0 0 5.66 0 l3 -3 a4 4 0 1 0 -5.66 -5.66 l-1 1"},null,-1)),l[35]||(l[35]=e.createElementVNode("path",{d:"M14 11 a4 4 0 0 0 -5.66 0 l-3 3 a4 4 0 1 0 5.66 5.66 l1 -1"},null,-1))],64)):i.name==="note"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:19},[l[36]||(l[36]=e.createElementVNode("path",{d:"M6 4 h9 l3 3 v13 a1 1 0 0 1 -1 1 h-11 a1 1 0 0 1 -1 -1 v-15 a1 1 0 0 1 1 -1 z"},null,-1)),l[37]||(l[37]=e.createElementVNode("line",{x1:"8",y1:"10",x2:"16",y2:"10"},null,-1)),l[38]||(l[38]=e.createElementVNode("line",{x1:"8",y1:"13",x2:"16",y2:"13"},null,-1)),l[39]||(l[39]=e.createElementVNode("line",{x1:"8",y1:"16",x2:"13",y2:"16"},null,-1))],64)):e.createCommentVNode("",!0)],8,Rt))}}),Dt="data:image/svg+xml,%3csvg%20t='1780822312364'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='7459'%20width='200'%20height='200'%3e%3cpath%20d='M329.16%20292.571h658.286V512H329.16zM329.16%200h658.286v219.429H329.16z'%20fill='%239AA1A2'%20p-id='7460'%3e%3c/path%3e%3cpath%20d='M44.927%20146.286a46.519%2046.519%200%200%201%2038.107-73.143h319.269v73.143H109.73V791.99l-48.713%205.705-24.43-651.41h8.339z'%20fill='%239AA1A2'%20p-id='7461'%3e%3c/path%3e%3cpath%20d='M363.83%20877.714H179.51c-78.775%200-142.921-66.12-142.921-147.31V112.787c0-21.943%2017.188-39.643%2038.473-39.643%2021.211%200%2033.5%2017.774%2033.5%2039.643v617.619c0%2037.522%2028.013%2076.58%2064.438%2076.58h190.903c21.211%200%2038.766%2013.97%2038.766%2035.84%200%2021.943-17.555%2034.89-38.766%2034.89z'%20fill='%239AA1A2'%20p-id='7462'%3e%3c/path%3e%3cpath%20d='M432.95%20438.857H179.51c-78.775%200-81.043-18.578-81.043-62.903l10.094-90.624c0%2020.48%2013.458%2080.677%2049.884%2080.677h210.139c21.211%200%20120.613%204.023%20120.613%2016.018%200%2011.922-35.036%2056.832-56.32%2056.832zM640.017%20749.714V640a54.857%2054.857%200%200%201%20109.714%200v109.714h109.715a54.857%2054.857%200%200%201%200%20109.715H749.73v109.714a54.857%2054.857%200%200%201-109.714%200V859.429H530.303a54.857%2054.857%200%200%201%200-109.715h109.714z'%20fill='%239AA1A2'%20p-id='7463'%3e%3c/path%3e%3c/svg%3e",At="data:image/svg+xml,%3csvg%20t='1780822464335'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='8457'%20width='200'%20height='200'%3e%3cpath%20d='M512%20804.571h512V1024H512V804.571zM0%200h658.286v219.429H0V0z'%20fill='%239AA1A2'%20p-id='8458'%3e%3c/path%3e%3cpath%20d='M619.813%20950.857h-184.32c-78.775%200-142.922-66.121-142.922-147.31V185.93c0-21.943%2017.189-39.643%2038.474-39.643%2021.211%200%2033.353%2017.773%2033.353%2039.643v617.618c0%2037.523%2034.743%2073.728%2071.095%2073.728h184.32c21.211%200%2038.473%2012.069%2038.473%2033.939%200%2021.943-17.189%2039.643-38.473%2039.643z'%20fill='%239AA1A2'%20p-id='8459'%3e%3c/path%3e%3cpath%20d='M676.571%20457.143V347.429a54.857%2054.857%200%200%201%20109.715%200v109.714H896a54.857%2054.857%200%200%201%200%20109.714H786.286v109.714a54.857%2054.857%200%200%201-109.715%200V566.857H566.857a54.857%2054.857%200%200%201%200-109.714h109.714z'%20fill='%239AA1A2'%20p-id='8460'%3e%3c/path%3e%3c/svg%3e",Je=[18,15,13,12],Ht=[700,600,500,400],Ft=[52,40,32,28],Pt=[120,80,60,44],Ot=[.8,.8,.8,.8],Xt=Je.length-1;function qt(i,s){return Math.round(De(i,s)*Ot[Ce(i)])}function Ce(i){return Math.min(Xt,Math.max(0,i))}function De(i,s=14){return Math.round(Je[Ce(i)]*s/14*10)/10}function Kt(i,s=14){return Math.round(Ft[Ce(i)]*s/14)}const Se=60,ue=14,G=24;let Ae=null;function Ut(){if(Ae)return Ae;const i=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;return i?(Ae=i,i):{font:"",measureText:()=>({width:0})}}const Ze=new Map;function jt(i,s,l){const o=`${l}|${s}|${i}`,a=Ze.get(o);if(a!==void 0)return a;const u=Ut();u.font=`${l} ${s}px "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif`;const f=u.measureText(i).width;return Ze.set(o,f),f}const Yt=24,Gt=400,Jt=8,Qe=16,Zt=4,Qt=200;function _t(i,s,l){return Math.min(l,Math.max(s,i))}function en(i,s,l){const o=Ce(s),a=De(s,l),u=Math.min(jt(i.text||"",a,Ht[o]),Qt),f=qt(s,l),k=Math.ceil(u+f*2),m=Kt(s,l);let g=0;if(i.link&&(g+=Qe),i.note&&(g+=Qe),g>0){const F=(i.link?1:0)+(i.note?1:0);g+=Zt*F}const d=k+g,x=Math.round(Pt[o]*l/14),E=i.richContent?Math.min(160,Math.ceil(a*6.5)):0,w=E>0?6:0;if(!i.image)return{w:Math.max(x,d),h:m+w+E};const W=_t(i.image.width,Yt,Gt),P=Math.max(x,d,Math.ceil(W+f*2)),K=Math.ceil(i.image.height+Jt+m+w+E);return{w:P,h:K}}function tn(i,s={}){const l=s.mode??"mindmap",o=s.preservePositions===!0,a=s.baseFontSize??14,u=et(i,0,null,1,"right",a);return on(u),nn(u,l,o),u.x=0,u.y=0,ln(u,o)}function nn(i,s,l=!1){if(s==="mindmap"){const o=i.children;if(o.length!==0)if(o.length===1)o[0]._dir="right",o[0].side=1,o[0]._dirRight=1;else{const k=o.reduce((x,E)=>x+E._subtreeH,0);let m=1,g=Math.abs(o[0]._subtreeH-(k-o[0]._subtreeH)),d=0;for(let x=0;x<o.length-1;x++){d+=o[x]._subtreeH;const E=Math.abs(d-(k-d));E<g&&(g=E,m=x+1)}for(let x=0;x<m;x++)o[x]._dir="right",o[x].side=1,o[x]._dirRight=1;for(let x=m;x<o.length;x++)o[x]._dir="left",o[x].side=-1,o[x]._dirRight=-1}const a=i.children.filter(k=>k.side===1),u=i.children.filter(k=>k.side===-1),f=(k,m)=>{const g=m==="right"?1:-1;k._dir=m,k.side=g,k._dirRight=g;for(const d of k.children)f(d,m)};for(const k of a)f(k,"right");for(const k of u)f(k,"left");if(a.length>0){const k={...i,children:a};ve(k,"right",Se,!0,l)}if(u.length>0){const k={...i,children:u};ve(k,"left",Se,!0,l)}}else if(s==="tree"){const o=a=>{a.side=1,a._dir="right";for(const u of a.children)o(u)};for(const a of i.children)a._dir="right";ve(i,"right",Se,!0,l),o(i)}else{for(const o of i.children)o._dir="down";_e(i,Se,l)}}function ve(i,s,l,o,a=!1){if(i.children.length===0)return;const u=i.children.reduce((g,d,x)=>g+d._subtreeH+(x>0?ue:0),0),f=s==="right"?1:-1,k=o?f:1;let m=i.y-k*u/2;i.children.forEach(g=>{a||(g.x=i.x+f*(i.width/2+l+g.width/2),g.y=m+k*g._subtreeH/2),g._dir=s,m+=k*(g._subtreeH+ue),ve(g,s,l,!1,a)})}function _e(i,s,l=!1){if(i.children.length===0)return;const o=i.children.reduce((u,f,k)=>u+f._subtreeW+(k>0?ue*2:0),0);let a=i.x-o/2;i.children.forEach(u=>{l||(u.x=a+u._subtreeW/2,u.y=i.y+i.height/2+s+u.height/2),u._dir="down",a+=u._subtreeW+ue*2,_e(u,s,l)})}function et(i,s,l,o,a,u){const f=en(i,s,u),k={id:i.id,text:i.text,depth:s,x:i._x??0,y:i._y??0,width:f.w,height:f.h,fontSize:De(s,u),isRoot:s===0,collapsed:i.collapsed,side:o,_dir:a,_dirRight:o,_subtreeH:f.h,_subtreeW:f.w,image:i.image?{...i.image}:void 0,link:i.link?{url:i.link.url}:void 0,note:i.note?{text:i.note.text}:void 0,richContent:i.richContent?{kind:i.richContent.kind,raw:i.richContent.raw,lang:i.richContent.lang}:void 0,children:[],parent:l};if(i.collapsed)return k;const m=i.children.length,g=Math.ceil(m/2);return k.children=i.children.map((d,x)=>{const E=s===0?x<g?1:-1:o;return et(d,s+1,k,E,a,u)}),k}function on(i){const s=[i];for(let l=0;l<s.length;l++){const o=s[l];for(const a of o.children)s.push(a)}for(let l=s.length-1;l>=0;l--){const o=s[l];if(o.collapsed||o.children.length===0){o._subtreeH=o.height,o._subtreeW=o.width;continue}let a=0,u=0;for(const f of o.children)a+=f._subtreeH,u+=f._subtreeW;o.children.length>1&&(a+=ue*(o.children.length-1),u+=ue*2*(o.children.length-1)),o._subtreeH=Math.max(o.height,a),o._subtreeW=Math.max(o.width,u)}}function ln(i,s=!1){const l=[i];let o=1/0,a=-1/0,u=1/0,f=-1/0;for(;l.length;){const g=l.pop(),d=g.width/2,x=g.height/2;g.x-d<o&&(o=g.x-d),g.x+d>a&&(a=g.x+d),g.y-x<u&&(u=g.y-x),g.y+x>f&&(f=g.y+x),l.push(...g.children)}if(s)return{root:i,width:a-o+G*2,height:f-u+G*2,vbX:o-G,vbY:u-G,vbW:a-o+G*2,vbH:f-u+G*2};const k=G-u,m=[i];for(;m.length;){const g=m.pop();g.y+=k,m.push(...g.children)}return u+=k,f+=k,{root:i,width:a-o+G*2,height:f+G,vbX:o-G,vbY:0,vbW:a-o+G*2,vbH:f+G}}const ke=[{id:"default",name:"默认",colors:["#f87171","#fb923c","#fbbf24","#a3e635","#34d399","#22d3ee","#818cf8","#c084fc"]},{id:"classic",name:"经典",colors:["#ef4444","#f59e0b","#10b981","#3b82f6","#6366f1","#8b5cf6","#ec4899","#14b8a6"]},{id:"vivid",name:"活力",colors:["#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"]},{id:"dev",name:"代码",colors:["#f472b6","#a78bfa","#60a5fa","#38bdf8","#22d3ee","#34d399","#facc15","#fb923c"]},{id:"mint",name:"薄荷",colors:["#5eead4","#67e8f9","#93c5fd","#c4b5fd","#fbcfe8","#fde68a","#a7f3d0","#bae6fd"]}];function rn(i,s=[]){return[...ke,...s].find(o=>o.id===i)??ke[0]}function J(){return"n_"+Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4)}function ne(i){return JSON.parse(JSON.stringify(i))}function $(i,s){if(i.id===s)return i;for(const l of i.children){const o=$(l,s);if(o)return o}return null}function Z(i,s,l=null){if(i.id===s)return l;for(const o of i.children){const a=Z(o,s,i);if(a!==null)return a}return null}function He(i,s){const l=i.children.findIndex(o=>o.id===s);if(l>=0)return i.children.splice(l,1),!0;for(const o of i.children)if(He(o,s))return!0;return!1}function an(i,s,l){const o=$(i,s);return!o||o.text===l?!1:(o.text=l,!0)}function cn(i,s,l,o){if(!Z(i,s)||s===l||$($(i,s),l))return!1;const a=Z(i,s),u=a.children.findIndex(g=>g.id===s);if(u<0)return!1;const[f]=a.children.splice(u,1);if(o==="child"){const g=$(i,l);return g?(g.children.push(f),!0):(a.children.splice(u,0,f),!1)}const k=Z(i,l);if(!k)return a.children.splice(u,0,f),!1;let m=k.children.findIndex(g=>g.id===l);return m<0?(a.children.splice(u,0,f),!1):(o==="after"&&(m+=1),k.children.splice(m,0,f),!0)}function tt(i){const s=/^新节点(?:\s+(\d+))?$/;let l=0,o=!1;for(const a of i.children){const u=a.text.match(s);if(u)if(u[1]){const f=parseInt(u[1],10);f>l&&(l=f)}else o=!0}return l===0&&!o?Ve:l>0?`新节点 ${l+1}`:"新节点 2"}function nt(i,s,l){const o=$(i,s);if(!o)return null;const a={id:J(),text:l??tt(o),children:[]};return o.children.push(a),a}function ot(i,s,l){const o=Z(i,s);if(!o)return null;const a=o.children.findIndex(f=>f.id===s);if(a<0)return null;const u={id:J(),text:l??tt(o),children:[]};return o.children.splice(a+1,0,u),u}function sn(i,s,l){const o=Z(i,s);if(!o)return null;const a=o.children.findIndex(f=>f.id===s);if(a<0)return null;const u={id:J(),text:l,children:[]};return o.children.splice(a,0,u),u}function dn(i,s){const l=Z(i,s);if(!l)return null;const o=l.children.findIndex(f=>f.id===s);if(o<0)return null;const a=l.children[o],u=ne(a);return it(u),l.children.splice(o+1,0,u),u}function it(i){i.id=J();for(const s of i.children)it(s)}const Ve="新节点";function Fe(i,s="导入的导图"){const l=i.split(/\r?\n/),o={id:J(),text:s,children:[]},a=[o],u=[-1/0],f=[],k=/^(#{1,6})\s+(.+?)\s*#*\s*$/,m=/^!\[([^\]]*)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,g=/^\[([^\]]+)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,d=/^(`{3,}|~{3,})\s*(\S+)?\s*$/;let x=!1,E=[],w=null;function W(b){E.push(b)}function P(){if(w&&E.length>0){for(;E.length>0&&E[0].trim()==="";)E.shift();for(;E.length>0&&E[E.length-1].trim()==="";)E.pop();const b=E.join(`
|
|
2
|
-
`);b&&(w.note={text:b})}
|
|
1
|
+
(function(L,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(L=typeof globalThis<"u"?globalThis:L||self,e(L.FlowMind={},L.Vue))})(this,function(L,e){"use strict";const Rt=["width","height","stroke-width"],Tt={key:4,points:"6 9 12 15 18 9"},Lt={key:5,points:"9 6 15 12 9 18"},H=e.defineComponent({__name:"Icon",props:{name:{},size:{},stroke:{}},setup(i){return(s,l)=>(e.openBlock(),e.createElementBlock("svg",{width:i.size??16,height:i.size??16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":i.stroke??1.8,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[i.name==="add"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[0]||(l[0]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[1]||(l[1]=e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"16"},null,-1)),l[2]||(l[2]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):i.name==="minus"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[4]||(l[4]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):i.name==="delete"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createStaticVNode('<polyline points="4 7 20 7"></polyline><path d="M9 7 V5 a1 1 0 0 1 1 -1 h4 a1 1 0 0 1 1 1 V7"></path><path d="M6 7 l1 12 a1 1 0 0 0 1 1 h8 a1 1 0 0 0 1 -1 l1 -12"></path><line x1="10" y1="11" x2="10" y2="18"></line><line x1="14" y1="11" x2="14" y2="18"></line>',5))],64)):i.name==="edit"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[l[6]||(l[6]=e.createElementVNode("path",{d:"M4 20 l4 -1 11 -11 -3 -3 -11 11 z"},null,-1)),l[7]||(l[7]=e.createElementVNode("line",{x1:"14",y1:"6",x2:"18",y2:"10"},null,-1))],64)):i.name==="collapse"?(e.openBlock(),e.createElementBlock("polyline",Tt)):i.name==="expand"?(e.openBlock(),e.createElementBlock("polyline",Lt)):i.name==="zoom-in"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[l[8]||(l[8]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[9]||(l[9]=e.createElementVNode("line",{x1:"11",y1:"8",x2:"11",y2:"14"},null,-1)),l[10]||(l[10]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[11]||(l[11]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):i.name==="zoom-out"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[l[12]||(l[12]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[13]||(l[13]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[14]||(l[14]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):i.name==="reset"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:8},[l[15]||(l[15]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[16]||(l[16]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"4"},null,-1)),l[17]||(l[17]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"0.8",fill:"currentColor"},null,-1))],64)):i.name==="logo"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:9},[l[18]||(l[18]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2"></circle><circle cx="4" cy="5" r="1.6"></circle><circle cx="20" cy="5" r="1.6"></circle><circle cx="4" cy="19" r="1.6"></circle><circle cx="20" cy="19" r="1.6"></circle><line x1="10.5" y1="10.8" x2="5.2" y2="6.4"></line><line x1="13.5" y1="10.8" x2="18.8" y2="6.4"></line><line x1="10.5" y1="13.2" x2="5.2" y2="17.6"></line><line x1="13.5" y1="13.2" x2="18.8" y2="17.6"></line>',9))],64)):i.name==="import"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:10},[l[19]||(l[19]=e.createElementVNode("path",{d:"M12 4 V15"},null,-1)),l[20]||(l[20]=e.createElementVNode("polyline",{points:"7 10 12 15 17 10"},null,-1)),l[21]||(l[21]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):i.name==="export"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:11},[l[22]||(l[22]=e.createElementVNode("path",{d:"M12 15 V4"},null,-1)),l[23]||(l[23]=e.createElementVNode("polyline",{points:"7 9 12 4 17 9"},null,-1)),l[24]||(l[24]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):i.name==="balance"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:12},[l[25]||(l[25]=e.createStaticVNode('<line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line><polyline points="9 4 5 6 9 8"></polyline><polyline points="15 4 19 6 15 8"></polyline><polyline points="9 10 5 12 9 14"></polyline><polyline points="15 10 19 12 15 14"></polyline><polyline points="9 16 5 18 9 20"></polyline><polyline points="15 16 19 18 15 20"></polyline>',9))],64)):i.name==="mindmap"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:13},[l[26]||(l[26]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none"></circle><line x1="13" y1="11" x2="19" y2="6"></line><line x1="13" y1="13" x2="19" y2="18"></line><line x1="11" y1="11" x2="5" y2="6"></line><line x1="11" y1="13" x2="5" y2="18"></line>',5))],64)):i.name==="tree"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:14},[l[27]||(l[27]=e.createStaticVNode('<circle cx="6" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="6" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="18" r="2" fill="currentColor" stroke="none"></circle><line x1="8" y1="12" x2="16" y2="6"></line><line x1="8" y1="12" x2="16" y2="12"></line><line x1="8" y1="12" x2="16" y2="18"></line>',7))],64)):i.name==="org"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:15},[l[28]||(l[28]=e.createStaticVNode('<circle cx="12" cy="5" r="2" fill="currentColor" stroke="none"></circle><circle cx="6" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="12" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="19" r="2" fill="currentColor" stroke="none"></circle><line x1="12" y1="7" x2="12" y2="13"></line><line x1="6" y1="13" x2="18" y2="13"></line><line x1="6" y1="13" x2="6" y2="17"></line><line x1="12" y1="13" x2="12" y2="17"></line><line x1="18" y1="13" x2="18" y2="17"></line>',9))],64)):i.name==="image"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:16},[l[29]||(l[29]=e.createElementVNode("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"},null,-1)),l[30]||(l[30]=e.createElementVNode("circle",{cx:"9",cy:"11",r:"1.6"},null,-1)),l[31]||(l[31]=e.createElementVNode("polyline",{points:"3 17 9 12 13 15 16 13 21 17"},null,-1))],64)):i.name==="x"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:17},[l[32]||(l[32]=e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),l[33]||(l[33]=e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1))],64)):i.name==="link"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:18},[l[34]||(l[34]=e.createElementVNode("path",{d:"M10 13 a4 4 0 0 0 5.66 0 l3 -3 a4 4 0 1 0 -5.66 -5.66 l-1 1"},null,-1)),l[35]||(l[35]=e.createElementVNode("path",{d:"M14 11 a4 4 0 0 0 -5.66 0 l-3 3 a4 4 0 1 0 5.66 5.66 l1 -1"},null,-1))],64)):i.name==="note"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:19},[l[36]||(l[36]=e.createElementVNode("path",{d:"M6 4 h9 l3 3 v13 a1 1 0 0 1 -1 1 h-11 a1 1 0 0 1 -1 -1 v-15 a1 1 0 0 1 1 -1 z"},null,-1)),l[37]||(l[37]=e.createElementVNode("line",{x1:"8",y1:"10",x2:"16",y2:"10"},null,-1)),l[38]||(l[38]=e.createElementVNode("line",{x1:"8",y1:"13",x2:"16",y2:"13"},null,-1)),l[39]||(l[39]=e.createElementVNode("line",{x1:"8",y1:"16",x2:"13",y2:"16"},null,-1))],64)):e.createCommentVNode("",!0)],8,Rt))}}),At="data:image/svg+xml,%3csvg%20t='1780822312364'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='7459'%20width='200'%20height='200'%3e%3cpath%20d='M329.16%20292.571h658.286V512H329.16zM329.16%200h658.286v219.429H329.16z'%20fill='%239AA1A2'%20p-id='7460'%3e%3c/path%3e%3cpath%20d='M44.927%20146.286a46.519%2046.519%200%200%201%2038.107-73.143h319.269v73.143H109.73V791.99l-48.713%205.705-24.43-651.41h8.339z'%20fill='%239AA1A2'%20p-id='7461'%3e%3c/path%3e%3cpath%20d='M363.83%20877.714H179.51c-78.775%200-142.921-66.12-142.921-147.31V112.787c0-21.943%2017.188-39.643%2038.473-39.643%2021.211%200%2033.5%2017.774%2033.5%2039.643v617.619c0%2037.522%2028.013%2076.58%2064.438%2076.58h190.903c21.211%200%2038.766%2013.97%2038.766%2035.84%200%2021.943-17.555%2034.89-38.766%2034.89z'%20fill='%239AA1A2'%20p-id='7462'%3e%3c/path%3e%3cpath%20d='M432.95%20438.857H179.51c-78.775%200-81.043-18.578-81.043-62.903l10.094-90.624c0%2020.48%2013.458%2080.677%2049.884%2080.677h210.139c21.211%200%20120.613%204.023%20120.613%2016.018%200%2011.922-35.036%2056.832-56.32%2056.832zM640.017%20749.714V640a54.857%2054.857%200%200%201%20109.714%200v109.714h109.715a54.857%2054.857%200%200%201%200%20109.715H749.73v109.714a54.857%2054.857%200%200%201-109.714%200V859.429H530.303a54.857%2054.857%200%200%201%200-109.715h109.714z'%20fill='%239AA1A2'%20p-id='7463'%3e%3c/path%3e%3c/svg%3e",Ht="data:image/svg+xml,%3csvg%20t='1780822464335'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='8457'%20width='200'%20height='200'%3e%3cpath%20d='M512%20804.571h512V1024H512V804.571zM0%200h658.286v219.429H0V0z'%20fill='%239AA1A2'%20p-id='8458'%3e%3c/path%3e%3cpath%20d='M619.813%20950.857h-184.32c-78.775%200-142.922-66.121-142.922-147.31V185.93c0-21.943%2017.189-39.643%2038.474-39.643%2021.211%200%2033.353%2017.773%2033.353%2039.643v617.618c0%2037.523%2034.743%2073.728%2071.095%2073.728h184.32c21.211%200%2038.473%2012.069%2038.473%2033.939%200%2021.943-17.189%2039.643-38.473%2039.643z'%20fill='%239AA1A2'%20p-id='8459'%3e%3c/path%3e%3cpath%20d='M676.571%20457.143V347.429a54.857%2054.857%200%200%201%20109.715%200v109.714H896a54.857%2054.857%200%200%201%200%20109.714H786.286v109.714a54.857%2054.857%200%200%201-109.715%200V566.857H566.857a54.857%2054.857%200%200%201%200-109.714h109.714z'%20fill='%239AA1A2'%20p-id='8460'%3e%3c/path%3e%3c/svg%3e",Je=[18,15,13,12],Dt=[700,600,500,400],Pt=[52,40,32,28],Ft=[120,80,60,44],Ot=[.8,.8,.8,.8],Xt=Je.length-1;function qt(i,s){return Math.round(Ae(i,s)*Ot[ve(i)])}function ve(i){return Math.min(Xt,Math.max(0,i))}function Ae(i,s=14){return Math.round(Je[ve(i)]*s/14*10)/10}function Kt(i,s=14){return Math.round(Pt[ve(i)]*s/14)}const Ce=60,ue=14,G=24;let He=null;function Ut(){if(He)return He;const i=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;return i?(He=i,i):{font:"",measureText:()=>({width:0})}}const Ze=new Map;function Yt(i,s,l){const o=`${l}|${s}|${i}`,a=Ze.get(o);if(a!==void 0)return a;const u=Ut();u.font=`${l} ${s}px "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif`;const f=u.measureText(i).width;return Ze.set(o,f),f}const jt=24,Gt=400,Jt=8,Qe=16,Zt=4,Qt=200;function _t(i,s,l){return Math.min(l,Math.max(s,i))}function en(i,s,l){const o=ve(s),a=Ae(s,l),u=Math.min(Yt(i.text||"",a,Dt[o]),Qt),f=qt(s,l),k=Math.ceil(u+f*2),m=Kt(s,l);let g=0;if(i.link&&(g+=Qe),i.note&&(g+=Qe),g>0){const D=(i.link?1:0)+(i.note?1:0);g+=Zt*D}const d=k+g,p=Math.round(Ft[o]*l/14),N=0,w=0;if(!i.image)return{w:Math.max(p,d),h:m+w+N};const $=_t(i.image.width,jt,Gt),F=Math.max(p,d,Math.ceil($+f*2)),q=Math.ceil(i.image.height+Jt+m+w+N);return{w:F,h:q}}function tn(i,s={}){const l=s.mode??"mindmap",o=s.preservePositions===!0,a=s.baseFontSize??14,u=et(i,0,null,1,"right",a);return on(u),nn(u,l,o),u.x=0,u.y=0,ln(u,o)}function nn(i,s,l=!1){if(s==="mindmap"){const o=i.children;if(o.length!==0)if(o.length===1)o[0]._dir="right",o[0].side=1,o[0]._dirRight=1;else{const k=o.reduce((p,N)=>p+N._subtreeH,0);let m=1,g=Math.abs(o[0]._subtreeH-(k-o[0]._subtreeH)),d=0;for(let p=0;p<o.length-1;p++){d+=o[p]._subtreeH;const N=Math.abs(d-(k-d));N<g&&(g=N,m=p+1)}for(let p=0;p<m;p++)o[p]._dir="right",o[p].side=1,o[p]._dirRight=1;for(let p=m;p<o.length;p++)o[p]._dir="left",o[p].side=-1,o[p]._dirRight=-1}const a=i.children.filter(k=>k.side===1),u=i.children.filter(k=>k.side===-1),f=(k,m)=>{const g=m==="right"?1:-1;k._dir=m,k.side=g,k._dirRight=g;for(const d of k.children)f(d,m)};for(const k of a)f(k,"right");for(const k of u)f(k,"left");if(a.length>0){const k={...i,children:a};Se(k,"right",Ce,!0,l)}if(u.length>0){const k={...i,children:u};Se(k,"left",Ce,!0,l)}}else if(s==="tree"){const o=a=>{a.side=1,a._dir="right";for(const u of a.children)o(u)};for(const a of i.children)a._dir="right";Se(i,"right",Ce,!0,l),o(i)}else{for(const o of i.children)o._dir="down";_e(i,Ce,l)}}function Se(i,s,l,o,a=!1){if(i.children.length===0)return;const u=i.children.reduce((g,d,p)=>g+d._subtreeH+(p>0?ue:0),0),f=s==="right"?1:-1,k=o?f:1;let m=i.y-k*u/2;i.children.forEach(g=>{a||(g.x=i.x+f*(i.width/2+l+g.width/2),g.y=m+k*g._subtreeH/2),g._dir=s,m+=k*(g._subtreeH+ue),Se(g,s,l,!1,a)})}function _e(i,s,l=!1){if(i.children.length===0)return;const o=i.children.reduce((u,f,k)=>u+f._subtreeW+(k>0?ue*2:0),0);let a=i.x-o/2;i.children.forEach(u=>{l||(u.x=a+u._subtreeW/2,u.y=i.y+i.height/2+s+u.height/2),u._dir="down",a+=u._subtreeW+ue*2,_e(u,s,l)})}function et(i,s,l,o,a,u){const f=en(i,s,u),k={id:i.id,text:i.text,depth:s,x:i._x??0,y:i._y??0,width:f.w,height:f.h,fontSize:Ae(s,u),isRoot:s===0,collapsed:i.collapsed,side:o,_dir:a,_dirRight:o,_subtreeH:f.h,_subtreeW:f.w,image:i.image?{...i.image}:void 0,link:i.link?{url:i.link.url}:void 0,note:i.note?{text:i.note.text}:void 0,richContent:i.richContent?{kind:i.richContent.kind,raw:i.richContent.raw,lang:i.richContent.lang}:void 0,children:[],parent:l};if(i.collapsed)return k;const m=i.children.length,g=Math.ceil(m/2);return k.children=i.children.map((d,p)=>{const N=s===0?p<g?1:-1:o;return et(d,s+1,k,N,a,u)}),k}function on(i){const s=[i];for(let l=0;l<s.length;l++){const o=s[l];for(const a of o.children)s.push(a)}for(let l=s.length-1;l>=0;l--){const o=s[l];if(o.collapsed||o.children.length===0){o._subtreeH=o.height,o._subtreeW=o.width;continue}let a=0,u=0;for(const f of o.children)a+=f._subtreeH,u+=f._subtreeW;o.children.length>1&&(a+=ue*(o.children.length-1),u+=ue*2*(o.children.length-1)),o._subtreeH=Math.max(o.height,a),o._subtreeW=Math.max(o.width,u)}}function ln(i,s=!1){const l=[i];let o=1/0,a=-1/0,u=1/0,f=-1/0;for(;l.length;){const g=l.pop(),d=g.width/2,p=g.height/2;g.x-d<o&&(o=g.x-d),g.x+d>a&&(a=g.x+d),g.y-p<u&&(u=g.y-p),g.y+p>f&&(f=g.y+p),l.push(...g.children)}if(s)return{root:i,width:a-o+G*2,height:f-u+G*2,vbX:o-G,vbY:u-G,vbW:a-o+G*2,vbH:f-u+G*2};const k=G-u,m=[i];for(;m.length;){const g=m.pop();g.y+=k,m.push(...g.children)}return u+=k,f+=k,{root:i,width:a-o+G*2,height:f+G,vbX:o-G,vbY:0,vbW:a-o+G*2,vbH:f+G}}const ke=[{id:"default",name:"默认",colors:["#f87171","#fb923c","#fbbf24","#a3e635","#34d399","#22d3ee","#818cf8","#c084fc"]},{id:"classic",name:"经典",colors:["#ef4444","#f59e0b","#10b981","#3b82f6","#6366f1","#8b5cf6","#ec4899","#14b8a6"]},{id:"vivid",name:"活力",colors:["#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"]},{id:"dev",name:"代码",colors:["#f472b6","#a78bfa","#60a5fa","#38bdf8","#22d3ee","#34d399","#facc15","#fb923c"]},{id:"mint",name:"薄荷",colors:["#5eead4","#67e8f9","#93c5fd","#c4b5fd","#fbcfe8","#fde68a","#a7f3d0","#bae6fd"]}];function rn(i,s=[]){return[...ke,...s].find(o=>o.id===i)??ke[0]}function J(){return"n_"+Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4)}function ne(i){return JSON.parse(JSON.stringify(i))}function z(i,s){if(i.id===s)return i;for(const l of i.children){const o=z(l,s);if(o)return o}return null}function Z(i,s,l=null){if(i.id===s)return l;for(const o of i.children){const a=Z(o,s,i);if(a!==null)return a}return null}function De(i,s){const l=i.children.findIndex(o=>o.id===s);if(l>=0)return i.children.splice(l,1),!0;for(const o of i.children)if(De(o,s))return!0;return!1}function an(i,s,l){const o=z(i,s);return!o||o.text===l?!1:(o.text=l,!0)}function cn(i,s,l,o){if(!Z(i,s)||s===l||z(z(i,s),l))return!1;const a=Z(i,s),u=a.children.findIndex(g=>g.id===s);if(u<0)return!1;const[f]=a.children.splice(u,1);if(o==="child"){const g=z(i,l);return g?(g.children.push(f),!0):(a.children.splice(u,0,f),!1)}const k=Z(i,l);if(!k)return a.children.splice(u,0,f),!1;let m=k.children.findIndex(g=>g.id===l);return m<0?(a.children.splice(u,0,f),!1):(o==="after"&&(m+=1),k.children.splice(m,0,f),!0)}function tt(i){const s=/^新节点(?:\s+(\d+))?$/;let l=0,o=!1;for(const a of i.children){const u=a.text.match(s);if(u)if(u[1]){const f=parseInt(u[1],10);f>l&&(l=f)}else o=!0}return l===0&&!o?Ve:l>0?`新节点 ${l+1}`:"新节点 2"}function nt(i,s,l){const o=z(i,s);if(!o)return null;const a={id:J(),text:l??tt(o),children:[]};return o.children.push(a),a}function ot(i,s,l){const o=Z(i,s);if(!o)return null;const a=o.children.findIndex(f=>f.id===s);if(a<0)return null;const u={id:J(),text:l??tt(o),children:[]};return o.children.splice(a+1,0,u),u}function sn(i,s,l){const o=Z(i,s);if(!o)return null;const a=o.children.findIndex(f=>f.id===s);if(a<0)return null;const u={id:J(),text:l,children:[]};return o.children.splice(a,0,u),u}function dn(i,s){const l=Z(i,s);if(!l)return null;const o=l.children.findIndex(f=>f.id===s);if(o<0)return null;const a=l.children[o],u=ne(a);return it(u),l.children.splice(o+1,0,u),u}function it(i){i.id=J();for(const s of i.children)it(s)}const Ve="新节点";function Pe(i,s="导入的导图"){const l=i.split(/\r?\n/),o={id:J(),text:s,children:[]},a=[o],u=[-1/0],f=[],k=/^(#{1,6})\s+(.+?)\s*#*\s*$/,m=/^!\[([^\]]*)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,g=/^\[([^\]]+)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,d=/^(`{3,}|~{3,})\s*(\S+)?\s*$/;let p=!1,N=[],w=null;function $(b){N.push(b)}function F(){if(w&&N.length>0){for(;N.length>0&&N[0].trim()==="";)N.shift();for(;N.length>0&&N[N.length-1].trim()==="";)N.pop();const b=N.join(`
|
|
2
|
+
`);b&&(w.note={text:b})}p=!1,N=[]}for(const b of l){if(p){const A=b.match(d);if(A&&A[1][0]==="`"){F();continue}$(b);continue}const B=b.match(k);if(B){const A=B[1].length,te=B[2].trim();f.push({level:A,text:te,body:""}),w=f[f.length-1];continue}const W=b.match(d);if(W&&W[2]==="note"){p=!0,N=[];continue}const S=b.match(m);if(S&&w){const A=S[2],te=160,ae=120;w.image={src:A,naturalW:te,naturalH:ae,width:te,height:ae};continue}const X=b.match(g);if(X&&w){w.link={url:X[2]},w.text=X[1];continue}b.trim().length>0&&w&&(w.body=w.body?w.body+" "+b.trim():b.trim())}p&&F();function q(b){for(;a.length>1;){const X=a.length-1,A=u[X];if(A!==void 0&&A<b.level)break;a.pop(),u.pop()}const B=a[a.length-1],W=b.text,S={id:J(),text:W,children:[]};b.image&&(S.image={...b.image}),b.link&&(S.link={url:b.link.url}),b.note&&(S.note={text:b.note.text}),b.body&&D(b,f,f.indexOf(b))&&S.children.push({id:J(),text:b.body,children:[]}),B.children.push(S),a.push(S),u.push(b.level)}function D(b,B,W){for(let S=W+1;S<B.length;S++){if(B[S].level<=b.level)return!0;if(B[S].level>b.level)return!1}return!0}for(const b of f)q(b);if(f.length>0&&f[0].level===1){const b=o.children[0];b&&(o.text=b.text,o.id=b.id,b.image&&(o.image={...b.image}),b.link&&(o.link={url:b.link.url}),b.note&&(o.note={text:b.note.text}),o.children=b.children)}return o}function ze(i,s=1){let l="#".repeat(s)+" "+(i.text||"")+`
|
|
3
3
|
`;i.link&&(l+=`[${i.text||"link"}](${i.link.url})
|
|
4
4
|
`),i.image&&(l+=`
|
|
5
5
|
`),i.note&&(l+="```note\n"+i.note.text+"\n```\n"),i.richContent&&(l+=i.richContent.raw+`
|
|
6
|
-
`);for(const o of i.children)l+=ze(o,s+1);return l}function un(i){var g,d;const s=i.split(/\r?\n/),l=[];let o=0;const a=/^(#{1,6})\s+(.+?)\s*#*\s*$/,u=/^(`{3,}|~{3,})\s*(\S+)?\s*$/,f=/^\s*\|?\s*(:?-+:?\s*\|\s*)+(:?-+:?)(\s*\|)?\s*$/,k=/^(\s*)[-*+]\s+(.*)$/,m=/^(\s*)\d+\.\s+(.*)$/;for(;o<s.length;){const
|
|
7
|
-
`).trim();l.push({kind:"code",text:((g=
|
|
8
|
-
`)[0])==null?void 0:g.slice(0,80))||"(空代码块)",raw:
|
|
9
|
-
`),lang:
|
|
10
|
-
`)}),o=
|
|
11
|
-
`)}),o=
|
|
12
|
-
`:""}function hn(i){const s=i.minScale??.2,l=i.maxScale??3,o=i.step??1.2,a=e.ref(1),u=e.ref(0),f=e.ref(0),k=e.ref(!1),m=e.reactive({x:0,y:0,ox:0,oy:0}),g=e.ref(!1),d=e.reactive({x:0,y:0}),x=e.reactive({x:0,y:0,width:0,height:0}),E=e.ref(0);let w=null;function W(v){w=v}function P(v){v.preventDefault();const z=i.getContainer();if(!z)return;const U=-v.deltaY*.001,j=Math.min(l,Math.max(s,a.value*(1+U))),Q=z.getBoundingClientRect(),_=v.clientX-Q.left,me=v.clientY-Q.top,be=(_-u.value)/a.value,he=(me-f.value)/a.value;a.value=j,u.value=_-be*j,f.value=me-he*j}function K(){a.value=Math.min(l,a.value*o)}function F(){a.value=Math.max(s,a.value/o)}function b(v){var U;v.target.closest(".zm-node, .zm-toolbar, button, input, textarea")||(k.value=!0,m.x=v.clientX,m.y=v.clientY,m.ox=u.value,m.oy=f.value,window.addEventListener("mousemove",B),window.addEventListener("mouseup",I),(U=v.preventDefault)==null||U.call(v))}function B(v){k.value&&(u.value=m.ox+(v.clientX-m.x),f.value=m.oy+(v.clientY-m.y))}function I(){k.value=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",I)}function V(v,z){g.value=!0,d.x=v,d.y=z,x.x=v,x.y=z,x.width=0,x.height=0,E.value++,window.addEventListener("mousemove",te),window.addEventListener("mouseup",D)}function q(v,z){if(!g.value)return;const U=Math.min(d.x,v),j=Math.min(d.y,z),Q=Math.max(d.x,v),_=Math.max(d.y,z);x.x=U,x.y=j,x.width=Q-U,x.height=_-j,E.value++}function D(){g.value=!1,window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",D),w&&w()}function te(v){if(!g.value)return;const z=i.getContainer();if(!z)return;const U=z.getBoundingClientRect(),j=(v.clientX-U.left-u.value)/a.value,Q=(v.clientY-U.top-f.value)/a.value;q(j,Q)}function ae(v,z,U,j=60){const Q=i.getContainer();if(!Q)return;const _=Q.getBoundingClientRect(),me=(_.width-j*2)/v,be=(_.height-j*2)/z,he=Math.min(1,Math.max(.3,Math.min(me,be)));a.value=he,u.value=_.width/2,f.value=_.height/2-U*he}return{scale:a,offsetX:u,offsetY:f,isPanning:k,onWheel:P,zoomIn:K,zoomOut:F,startPan:b,startMarquee:V,updateMarquee:q,isMarquee:g,marquee:x,marqueeVersion:E,setOnMarqueeEnd:W,resetView:ae}}const gn=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function lt(i){return gn?i.metaKey:i.ctrlKey}function yn(i){function s(){const o=i.getSelectedId();return o||(i.defaultTargetId?i.defaultTargetId():i.getRootId())}function l(o){const a=o.target;if(a&&(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)||i.isReadonly()||i.isEditing())return;const u=i.getSelectedId(),f=s();if(f){if(lt(o)&&!o.shiftKey){if(o.key==="d"||o.key==="D"){u&&u!==i.getRootId()&&(o.preventDefault(),i.onDuplicate(u));return}if(o.key==="z"||o.key==="Z"){o.preventDefault(),i.onUndo();return}if(o.key==="y"||o.key==="Y"){o.preventDefault(),i.onRedo();return}if(o.key==="Home"){o.preventDefault(),i.onSelectRoot();return}}if(lt(o)&&o.shiftKey&&(o.key==="Z"||o.key==="z")){o.preventDefault(),i.onRedo();return}o.key==="Tab"?(o.preventDefault(),i.onAddChild(f)):o.key==="Enter"?(o.preventDefault(),o.shiftKey?u&&u!==i.getRootId()&&i.onAddSiblingBefore(u):i.onAddSibling(f)):(o.key==="Delete"||o.key==="Backspace")&&u&&u!==i.getRootId()?(o.preventDefault(),i.onRemove(u)):o.key==="F2"&&u?(o.preventDefault(),i.onStartEdit(u)):o.key==="Escape"?(o.preventDefault(),i.onClearSelection()):o.key==="ArrowDown"?(o.preventDefault(),i.onNavigate(0,1)):o.key==="ArrowUp"?(o.preventDefault(),i.onNavigate(0,-1)):o.key==="ArrowRight"?(o.preventDefault(),i.onNavigate(1,0)):o.key==="ArrowLeft"&&(o.preventDefault(),i.onNavigate(-1,0))}}e.onMounted(()=>{window.addEventListener("keydown",l)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",l)})}function pn(i=100){const s=e.ref([]);let l=-1;function o(){return l>0}function a(){return l<s.value.length-1}function u(g){const d=JSON.stringify(g);for(l<s.value.length-1&&(s.value=s.value.slice(0,l+1)),s.value.push(d),l=s.value.length-1;s.value.length>i;)s.value.shift(),l--}function f(){return o()?(l--,JSON.parse(s.value[l])):null}function k(){return a()?(l++,JSON.parse(s.value[l])):null}function m(){s.value=[],l=-1}return{canUndo:o,canRedo:a,record:u,undo:f,redo:k,reset:m}}const xn=["disabled"],kn=["disabled"],wn=["disabled"],bn=["disabled"],En=["disabled"],Nn=["disabled"],Mn=e.defineComponent({__name:"NodeContextMenu",props:{x:{},y:{},container:{},hasImage:{type:Boolean,default:!1},hasLink:{type:Boolean,default:!1},hasNote:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},emits:["pickImage","setLink","removeLink","editNote","removeNote","removeImage","close"],setup(i,{emit:s}){const l=i,o=s,a=e.computed(()=>{let E=l.x+2,w=l.y+2;if(l.container){const W=l.container.getBoundingClientRect(),P=180,K=u.value?f.value?184:160:136;E+P>W.right&&(E=Math.max(W.left+4,l.x-P-2)),w+K>W.bottom&&(w=Math.max(W.top+4,l.y-K-2)),E<W.left+2&&(E=W.left+2),w<W.top+2&&(w=W.top+2)}return{left:E,top:w}}),u=e.computed(()=>l.hasImage),f=e.computed(()=>l.hasLink),k=e.computed(()=>l.hasNote);function m(E){const w=E.target;w&&w.closest(".zm-node-menu")||o("close")}function g(E){E.key==="Escape"&&o("close")}function d(){o("close")}window.addEventListener("mousedown",m,!0),window.addEventListener("keydown",g,!0),window.addEventListener("wheel",d,!0),window.addEventListener("scroll",d,!0),e.onBeforeUnmount(()=>{window.removeEventListener("mousedown",m,!0),window.removeEventListener("keydown",g,!0),window.removeEventListener("wheel",d,!0),window.removeEventListener("scroll",d,!0)});function x(E){l.readonly||(E(),o("close"))}return(E,w)=>(e.openBlock(),e.createElementBlock("div",{class:"zm-node-menu",style:e.normalizeStyle({left:a.value.left+"px",top:a.value.top+"px"}),onContextmenu:w[6]||(w[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[0]||(w[0]=e.withModifiers(W=>x(()=>o("pickImage")),["stop"]))},[e.createVNode(H,{name:"image",size:13}),e.createElementVNode("span",null,e.toDisplayString(u.value?"替换图片":"添加图片"),1)],8,xn),u.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[1]||(w[1]=e.withModifiers(W=>x(()=>o("removeImage")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[7]||(w[7]=e.createElementVNode("span",null,"移除图片",-1))],8,kn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[2]||(w[2]=e.withModifiers(W=>x(()=>o("setLink")),["stop"]))},[e.createVNode(H,{name:"link",size:13}),e.createElementVNode("span",null,e.toDisplayString(f.value?"编辑链接":"添加链接"),1)],8,wn),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[3]||(w[3]=e.withModifiers(W=>x(()=>o("removeLink")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[8]||(w[8]=e.createElementVNode("span",null,"移除链接",-1))],8,bn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[4]||(w[4]=e.withModifiers(W=>x(()=>o("editNote")),["stop"]))},[e.createVNode(H,{name:"note",size:13}),e.createElementVNode("span",null,e.toDisplayString(k.value?"编辑笔记":"添加笔记"),1)],8,En),k.value?(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[5]||(w[5]=e.withModifiers(W=>x(()=>o("removeNote")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[9]||(w[9]=e.createElementVNode("span",null,"移除笔记",-1))],8,Nn)):e.createCommentVNode("",!0)],36))}}),Bn=["viewBox","width","height"],Cn={class:"zm-edges"},Sn=["d","fill"],vn=["data-node-id","onClick","onDblclick","onContextmenu","onMouseenter","onMouseleave"],Vn=["src","width","height","alt"],zn={key:1,class:"zm-text"},$n={class:"zm-text-label"},In=["href","title"],Wn=["title","onClick"],Rn={key:0,class:"zm-rich-code"},Ln={key:1,class:"zm-rich-list"},Tn={key:2,class:"zm-rich-table"},Dn={key:3,class:"zm-rich-paragraph"},An=["title"],Hn=["title","onClick"],Fn=["onClick"],Pn=["onMousedown"],On=["onClick"],Xn={key:0,class:"zm-toolbar"},qn=["src"],Kn=["src"],Un={class:"zm-tb-tip"},fe=24,we=400,re=160,rt=e.defineComponent({__name:"MindMap",props:{data:{},readonly:{type:Boolean,default:!1},theme:{},previewMode:{type:Boolean,default:!1},markdown:{},lineColors:{}},emits:["change","select","edit-note","markdownChange"],setup(i,{expose:s,emit:l}){const o=i,a=l,u=e.ref(null),f=e.ref(null),k=e.ref(""),m=e.ref(null),g=e.ref(new Set),d=e.ref(ne(o.data)),x=e.ref(o.markdown!==void 0);let E=!1;e.watch(()=>o.markdown,t=>{if(t===void 0){x.value=!1;return}x.value=!0;const n=Fe(t||"");E=!0,d.value=ne(n),m.value=null,g.value=new Set,L(),e.nextTick(()=>{E=!1,oe()})}),e.watch(d,()=>{x.value&&!E&&a("markdownChange",ze(d.value))},{deep:!0});const w=e.computed(()=>N.showOrderBadge===!0),W=e.ref(new Map),P=W.value;function K(t,n){const c={};n.bg&&(c.bg=n.bg),n.textColor&&(c.textColor=n.textColor),n.borderColor&&(c.borderColor=n.borderColor),n.fontWeight&&(c.fontWeight=n.fontWeight),Object.keys(c).length===0?P.delete(t):P.set(t,c),W.value=new Map(P)}function F(t){return P.get(t)??{}}function b(t,n){const c=$(d.value,t);c&&(c.image={src:n.src,naturalW:n.naturalW,naturalH:n.naturalH,width:I(n.width,fe,we),height:I(n.height,fe,we)},O(),L(),a("change",d.value))}function B(t){const n=$(d.value,t);!n||!n.image||(delete n.image,O(),L(),a("change",d.value))}function I(t,n,c){return Math.min(c,Math.max(n,t))}function V(t,n){const c=new FileReader;c.onload=()=>{if(typeof c.result!="string")return;const y=c.result,h=new window.Image;h.onload=()=>{const r=h.naturalWidth||re,p=h.naturalHeight||re,C=I(r,fe,re),A=I(Math.round(p*C/r),fe,we);n({src:y,naturalW:r,naturalH:p,width:C,height:A})},h.onerror=()=>{n({src:y,naturalW:re,naturalH:re,width:re,height:re})},h.src=y},c.readAsDataURL(t)}function q(t){const n=document.createElement("input");n.type="file",n.accept="image/*",n.style.display="none",n.onchange=()=>{var y;const c=(y=n.files)==null?void 0:y[0];c&&(V(c,h=>b(t,h)),document.body.removeChild(n))},document.body.appendChild(n),n.click()}function D(t,n){const c=n.trim(),y=$(d.value,t);y&&(c?y.link={url:c}:delete y.link,O(),L(),a("change",d.value))}function te(t){D(t,"")}function ae(t,n){const c=$(d.value,t);c&&(n?c.note={text:n}:delete c.note,O(),L(),a("change",d.value))}function v(t){ae(t,"")}const z=e.ref(null);function U(t,n){o.readonly||(t.preventDefault(),t.stopPropagation(),m.value=n.id,a("select",$(d.value,n.id)),z.value={nodeId:n.id,x:t.clientX,y:t.clientY})}function j(){z.value=null}function Q(){var n;const t=(n=z.value)==null?void 0:n.nodeId;t&&q(t)}function _(){var y,h,r;const t=(y=z.value)==null?void 0:y.nodeId;if(!t)return;const n=((r=(h=$(d.value,t))==null?void 0:h.link)==null?void 0:r.url)??"",c=window.prompt("输入链接 URL(留空取消)",n);c!==null&&D(t,c)}function me(){var n;const t=(n=z.value)==null?void 0:n.nodeId;t&&te(t)}function be(){var n;const t=(n=z.value)==null?void 0:n.nodeId;t&&at(t)}function he(){var n;const t=(n=z.value)==null?void 0:n.nodeId;t&&v(t)}function Yn(){var n;const t=(n=z.value)==null?void 0:n.nodeId;t&&B(t)}function at(t){o.readonly||a("edit-note",t)}function Gn(t,n=60){const c=t.replace(/\s+/g," ").trim();return c.length<=n?c||"点击编辑笔记":c.slice(0,n)+"…"}function ct(t){var h;if(o.readonly||f.value)return;const n=t.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const c=m.value;if(!c)return;const y=(h=t.clipboardData)==null?void 0:h.items;if(y)for(let r=0;r<y.length;r++){const p=y[r];if(p.kind==="file"&&p.type.startsWith("image/")){const C=p.getAsFile();if(!C)continue;t.preventDefault();const A=$(d.value,c);if(A!=null&&A.image&&!window.confirm("该节点已有图片,要用剪贴板里的图片替换吗?"))return;V(C,X=>b(c,X));return}}}e.onMounted(()=>{window.addEventListener("paste",ct)}),e.onBeforeUnmount(()=>{window.removeEventListener("paste",ct)});const Ee=e.ref(null),Jn=e.computed(()=>{var t;return((t=Ee.value)==null?void 0:t.nodeId)??null});function Zn(t,n){if(!n.image)return;t.preventDefault(),t.stopPropagation();const c=n.image.naturalW||n.image.width,y=n.image.naturalH||n.image.height,h=y>0?y/c:1;Ee.value={nodeId:n.id,startX:t.clientX,startY:t.clientY,startW:n.image.width,startH:n.image.height,naturalW:c,naturalH:y,ratio:h,pendingW:n.image.width,pendingH:n.image.height},window.addEventListener("mousemove",st),window.addEventListener("mouseup",dt)}function st(t){var A,X;const n=Ee.value;if(!n)return;const c=M.scale.value||1,y=t.clientX-n.startX,h=I(n.startW+y/c,fe,we),r=I(h*n.ratio,fe,we);n.pendingW=h,n.pendingH=r;const p=(A=u.value)==null?void 0:A.querySelector(`[data-node-id="${n.nodeId}"] .zm-node-img`);p&&(p.style.width=`${h}px`,p.style.height=`${r}px`);const C=(X=u.value)==null?void 0:X.querySelector(`[data-node-id="${n.nodeId}"]`);C&&(C.style.minWidth=`${Math.max(80,Math.ceil(h+28))}px`,C.style.height=`${Math.ceil(r+8+30)}px`)}function dt(){const t=Ee.value;if(window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",dt),Ee.value=null,!t)return;const n=$(d.value,t.nodeId);!n||!n.image||(b(t.nodeId,{src:n.image.src,naturalW:n.image.naturalW,naturalH:n.image.naturalH,width:t.pendingW,height:t.pendingH}),m.value=t.nodeId,a("select",n),Oe=!0)}const Pe=e.ref(null);let Oe=!1;function Qn(t){Pe.value=t}function _n(t){Pe.value===t&&(Pe.value=null)}const ut=e.ref(0),Xe=e.ref(!1),le=pn(100);function O(){le.record({data:d.value})}function L(){g.value=new Set(g.value),ut.value++}const ee=e.computed(()=>{var t,n,c,y,h,r,p,C,A,X;return{rootBg:((t=o.theme)==null?void 0:t.rootBg)??"#1f2937",rootText:((n=o.theme)==null?void 0:n.rootText)??"#ffffff",branchBg:((c=o.theme)==null?void 0:c.branchBg)??"#ffffff",branchText:((y=o.theme)==null?void 0:y.branchText)??"#1f2937",lineColor:((h=o.theme)==null?void 0:h.lineColor)??"#94a3b8",bgColor:((r=o.theme)==null?void 0:r.bgColor)??"#f8fafc",fontSize:((p=o.theme)==null?void 0:p.fontSize)??14,lineWidthStart:((C=o.theme)==null?void 0:C.lineWidthStart)??2.2,lineWidthEnd:((A=o.theme)==null?void 0:A.lineWidthEnd)??.8,rainbowBranch:((X=o.theme)==null?void 0:X.rainbowBranch)??!1}}),N=e.reactive({autoBalanceOnChange:!0,lineWidthStart:12,lineWidthEnd:3.6,rainbowBranch:!0,branchPaletteId:"default",customPalettes:[],lineStyle:"curve",layoutMode:"mindmap",taperedEdge:!0,showOrderBadge:!1});function ft(t){return N.taperedEdge?eo(t):ht(t)}function mt(t){return N.taperedEdge?N.lineWidthEnd:ht(t)}function eo(t){return t<=0?N.lineWidthStart:t===1?Math.max(1.5,N.lineWidthStart*.67):t===2?Math.max(.8,N.lineWidthStart*.42):N.lineWidthEnd}function ht(t){if(t<=0)return N.lineWidthStart;if(t>=3)return N.lineWidthEnd;const n=t/3;return N.lineWidthStart+(N.lineWidthEnd-N.lineWidthStart)*n}function to(t,n,c,y){const h=1-t,r=h*h*h*n.x+3*h*h*t*c.x1+3*h*t*t*c.x2+t*t*t*y.x,p=h*h*h*n.y+3*h*h*t*c.y1+3*h*t*t*c.y2+t*t*t*y.y;return{x:r,y:p}}function no(t,n,c,y,h=32,r="curve",p="right"){if(r==="curve"){let de;if(p==="right"||p==="left"){const R=Math.abs(n.x-t.x)*.45,ie=p==="right"?1:-1;de={x1:t.x+ie*R,y1:t.y,x2:n.x-ie*R,y2:n.y}}else{const R=Math.abs(n.y-t.y)*.45;de={x1:t.x,y1:t.y+R,x2:n.x,y2:n.y-R}}const zo=S=>{const R=1-S,ie=-3*R*R*t.x+3*(R*R-2*R*S)*de.x1+3*(2*R*S-S*S)*de.x2+3*S*S*n.x,xe=-3*R*R*t.y+3*(R*R-2*R*S)*de.y1+3*(2*R*S-S*S)*de.y2+3*S*S*n.y;return{dx:ie,dy:xe}},Be=[],Ge=[];for(let S=0;S<=h;S++){const R=S/h,ie=S===0?t:S===h?n:to(R,t,de,n),xe=zo(R);let Le=Math.hypot(xe.dx,xe.dy);Le<1e-6&&(Le=1);const It=-xe.dy/Le,Wt=xe.dx/Le,Te=(c+(y-c)*R)/2;Be.push({x:ie.x+It*Te,y:ie.y+Wt*Te}),Ge.push({x:ie.x-It*Te,y:ie.y-Wt*Te})}let Re=`M ${Be[0].x.toFixed(2)} ${Be[0].y.toFixed(2)}`;for(let S=1;S<=h;S++)Re+=` L ${Be[S].x.toFixed(2)} ${Be[S].y.toFixed(2)}`;for(let S=h;S>=0;S--)Re+=` L ${Ge[S].x.toFixed(2)} ${Ge[S].y.toFixed(2)}`;return Re+=" Z",Re}const C=n.x-t.x,A=n.y-t.y;let X=Math.hypot(C,A);X<1e-6&&(X=1);const se=-A/X,ye=C/X,pe=c/2,Me=y/2,vt={x:t.x+se*pe,y:t.y+ye*pe},Vt={x:t.x-se*pe,y:t.y-ye*pe},zt={x:n.x-se*Me,y:n.y-ye*Me},$t={x:n.x+se*Me,y:n.y+ye*Me};return`M ${vt.x.toFixed(2)} ${vt.y.toFixed(2)} L ${$t.x.toFixed(2)} ${$t.y.toFixed(2)} L ${zt.x.toFixed(2)} ${zt.y.toFixed(2)} L ${Vt.x.toFixed(2)} ${Vt.y.toFixed(2)} Z`}const $e=e.computed(()=>Y.value.root.children),oo=ke[0].colors,gt=e.computed(()=>rn(N.branchPaletteId,N.customPalettes)),ce=e.computed(()=>{const t=new Map;if(!N.rainbowBranch)return t;const n=o.lineColors,c=n&&n.length>0?n:gt.value.colors.length>0?gt.value.colors:oo;for(let h=0;h<$e.value.length;h++){const r=$e.value[h];t.set(r.id,c[h%c.length])}const y=(h,r)=>{t.set(h.id,r);for(const p of h.children)y(p,r)};for(let h=0;h<$e.value.length;h++){const r=$e.value[h];y(r,c[h%c.length])}return t});function io(t,n){return N.rainbowBranch?ce.value.get(n.id)??ee.value.lineColor:ee.value.lineColor}function lo(t){const n=F(t.id);if(n.bg)return n.bg;if(t.isRoot)return ee.value.rootBg;if(N.rainbowBranch){const c=ce.value.get(t.id);if(c)return so(c,.18)}return ee.value.branchBg}function ro(t){const n=F(t.id);if(n.textColor)return n.textColor;if(t.isRoot)return ee.value.rootText;if(N.rainbowBranch){const c=ce.value.get(t.id);if(c)return yt(c,.55)}return ee.value.branchText}function ao(t){const n=F(t.id);if(n.borderColor)return n.borderColor;if(t.isRoot)return ee.value.rootBg;if(N.rainbowBranch){const c=ce.value.get(t.id);if(c)return yt(c,.3)}return ee.value.lineColor}function co(t){return F(t.id).fontWeight??(t.isRoot?600:400)}function so(t,n){const c=t.replace("#",""),y=c.length===6?c:c.split("").map(C=>C+C).join(""),h=parseInt(y.slice(0,2),16),r=parseInt(y.slice(2,4),16),p=parseInt(y.slice(4,6),16);return`rgba(${h}, ${r}, ${p}, ${n})`}function yt(t,n){const c=t.replace("#",""),y=c.length===6?c:c.split("").map(C=>C+C).join(""),h=Math.round(parseInt(y.slice(0,2),16)*(1-n)),r=Math.round(parseInt(y.slice(2,4),16)*(1-n)),p=Math.round(parseInt(y.slice(4,6),16)*(1-n));return`rgb(${h}, ${r}, ${p})`}const M=hn({getContainer:()=>u.value});M.setOnMarqueeEnd(Bo),yn({isEditing:()=>f.value!==null,isReadonly:()=>o.readonly,getSelectedId:()=>m.value,getRootId:()=>d.value.id,defaultTargetId:()=>d.value.id,onAddChild:ge,onAddSibling:We,onAddSiblingBefore:kt,onRemove:bt,onStartEdit:Ne,onClearSelection:()=>{m.value=null,a("select",null)},onDuplicate:wt,onUndo:Ke,onRedo:Ue,onNavigate:go,onSelectRoot:()=>{m.value=d.value.id;const t=$(d.value,d.value.id);t&&a("select",t)}});const Y=e.computed(()=>{const t=ne(d.value);return xt(t),tn(t,{mode:N.layoutMode,baseFontSize:ee.value.fontSize})}),pt=e.ref([]),qe=e.computed(()=>(ut.value,pt.value));e.watch(Y,t=>{const n=[],c=y=>{n.push(y);for(const h of y.children)c(h)};c(t.root),pt.value=n},{immediate:!0});const uo=e.computed(()=>{const t=[];for(const n of qe.value)for(const c of n.children)t.push({from:n,to:c,key:`${n.id}->${c.id}`});return t}),fo=e.computed(()=>`${Y.value.vbX} ${Y.value.vbY} ${Y.value.vbW} ${Y.value.vbH}`);function xt(t){if(g.value.has(t.id)){t.children=[],t.collapsed=!0;return}t.collapsed=!1;for(const n of t.children)xt(n)}function Ne(t){const n=$(d.value,t);n&&(f.value=t,k.value=n.text,e.nextTick(()=>{const c=document.querySelector(".zm-input");c==null||c.focus(),c==null||c.select()}))}function Ie(t={}){if(!f.value)return;const n=$(d.value,f.value);n&&n.text!==(k.value.trim()||" ")&&(n.text=k.value.trim()||" ",O(),a("change",d.value));const c=f.value;f.value=null,t.addChild?e.nextTick(()=>ge(c)):t.addSibling==="after"?e.nextTick(()=>We(c)):t.addSibling==="before"&&e.nextTick(()=>kt(c))}function mo(){f.value=null}function ho(t){const n=t.metaKey||t.ctrlKey;n&&(t.key==="z"||t.key==="Z")&&!t.shiftKey?(t.preventDefault(),Ke()):(n&&t.shiftKey&&(t.key==="z"||t.key==="Z")||n&&(t.key==="y"||t.key==="Y")&&!t.shiftKey)&&(t.preventDefault(),Ue())}function ge(t){const n=nt(d.value,t,Ve);n&&(O(),L(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function We(t){if(t===d.value.id){ge(t);return}const n=ot(d.value,t,Ve);n&&(O(),L(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function kt(t){if(t===d.value.id){ge(t);return}const n=sn(d.value,t,Ve);n&&(O(),L(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function wt(t){if(t===d.value.id)return;const n=dn(d.value,t);n&&(O(),m.value=n.id,a("change",d.value),L())}function Ke(){const t=le.undo();t&&(d.value=t.data,m.value=null,a("select",null),L(),a("change",d.value))}function Ue(){const t=le.redo();t&&(d.value=t.data,m.value=null,a("select",null),L(),a("change",d.value))}function go(t,n){const c=m.value??d.value.id,y=$(d.value,c);if(!y)return;let h=null;if(n===1){const r=Z(d.value,y.id);if(r){const p=r.children.findIndex(C=>C.id===y.id);p>=0&&p<r.children.length-1&&(h=r.children[p+1].id)}}else if(n===-1){const r=Z(d.value,y.id);if(r){const p=r.children.findIndex(C=>C.id===y.id);p>0&&(h=r.children[p-1].id)}}else if(t===1){const r=Z(d.value,y.id);r&&(h=r.id)}else t===-1&&y.children.length>0&&(h=y.children[0].id);if(h){m.value=h;const r=$(d.value,h);r&&a("select",r)}}function yo(t){const n=t.split(`
|
|
13
|
-
`);return/^(`{3,}|~{3,})/.test(n[0]??"")&&n.shift(),/^(`{3,}|~{3,})\s*$/.test(n[n.length-1]??"")&&n.pop(),n.join(`
|
|
14
|
-
`).replace(/\n+$/,"")}function po(t){return t.split(`
|
|
15
|
-
`).map(n=>n.replace(/^\s*[-*+]\s+/,"").replace(/^\s*\d+\.\s+/,"").trim()).filter(n=>n.length>0)}function xo(t){return t.split(`
|
|
16
|
-
`).filter(n=>n.trim().length>0).filter(n=>!/^\s*\|?\s*(:?-+:?\s*\|\s*)+(:?-+:?)(\s*\|)?\s*$/.test(n)).map(n=>n.replace(/^\s*\|/,"").replace(/\|\s*$/,"").split("|").map(c=>c.trim()))}function ko(t){return t.replace(/\s+/g," ").trim()}function bt(t){t!==d.value.id&&He(d.value,t)&&(O(),m.value===t&&(m.value=null),L(),a("change",d.value))}function Et(t){g.value.has(t)?g.value.delete(t):g.value.add(t),L()}function wo(t,n){an(d.value,t,n)&&(O(),L(),a("change",d.value))}function bo(t,n,c){return cn(d.value,t,n,c)?(O(),L(),a("change",d.value),!0):!1}function Eo(t,n){t.stopPropagation(),m.value=n.id;const c=$(d.value,n.id);a("select",c)}function No(t){const n=t.target;if(!n||n.closest(".zm-node, .zm-toolbar, button, input, textarea"))return;if(t.button===2){M.startPan(t);return}if(t.button!==0)return;const c=u.value.getBoundingClientRect(),y=(t.clientX-c.left-M.offsetX.value)/M.scale.value,h=(t.clientY-c.top-M.offsetY.value)/M.scale.value;M.startMarquee(y,h)}function Mo(t){if(Oe){Oe=!1;return}const n=t.target;if(!n||n.closest(".zm-node"))return;const c=M.marquee;c.width>=4||c.height>=4||m.value!==null&&(m.value=null,a("select",null))}function Bo(){const t=M.marquee;if(t.width<4&&t.height<4)return;const n=t.x,c=t.y,y=t.x+t.width,h=t.y+t.height,r=[];for(const p of qe.value){const C=p.width/2,A=p.height/2,X=p.x-C,se=p.x+C,ye=p.y-A,pe=p.y+A;X<=y&&se>=n&&ye<=h&&pe>=c&&r.push(p.id)}if(r.length>0){m.value=r[0];const p=$(d.value,r[0]);p&&a("select",p)}}function Nt(t){return g.value.has(t)}function Co(t){const n=$(d.value,t.id);return!!n&&n.children.length>0}function je(t){const n=$(d.value,t);return n?n.children.length:0}function Mt(t){if(!$(d.value,t))return 0;const y=[d.value];for(;y.length;){const h=y.pop(),r=h.children.findIndex(p=>p.id===t);if(r>=0)return r;for(const p of h.children)y.push(p)}return 0}function Bt(t,n,c,y){if(((y==null?void 0:y._dir)??t._dir)==="down")return n==="out"?{x:t.x,y:t.y+t.height/2}:{x:t.x,y:t.y-t.height/2};let r;return n==="in"?r=-t.side:c!==void 0?r=c:r=t.side,{x:t.x+r*(t.width/2),y:t.y}}function oe(){const t=Y.value;M.resetView(t.width,t.height,t.root.y)}function So(){Xe.value=!0,O(),L(),e.nextTick(()=>oe())}function Ye(t){N.layoutMode!==t&&(N.layoutMode=t,L(),e.nextTick(()=>oe()))}function Ct(){return JSON.stringify(d.value,null,2)}function St(t){try{const n=JSON.parse(t);return!n.id||!Array.isArray(n.children)?!1:(le.reset(),d.value=ne(n),m.value=null,g.value=new Set,L(),e.nextTick(()=>oe()),a("change",d.value),!0)}catch{return!1}}function vo(){const t=document.createElement("input");t.type="file",t.accept="application/json",t.onchange=()=>{var y;const n=(y=t.files)==null?void 0:y[0];if(!n)return;const c=new FileReader;c.onload=()=>{typeof c.result=="string"&&(St(c.result)||alert("导入失败:JSON 格式无效"))},c.readAsText(n)},t.click()}function Vo(){const t=new Blob([Ct()],{type:"application/json"}),n=URL.createObjectURL(t),c=document.createElement("a");c.href=n,c.download=`${d.value.text||"mindmap"}.json`,c.click(),URL.revokeObjectURL(n)}return s({addChild:t=>ge(t),addSibling:t=>We(t),removeNode:t=>bt(t),duplicateNode:t=>wt(t),setNodeText:(t,n)=>wo(t,n),moveNode:(t,n,c)=>bo(t,n,c),lineWidthForDepth:ft,endWidthForDepth:mt,getData:()=>d.value,setData:t=>{le.reset(),d.value=ne(t),m.value=null,g.value=new Set,L(),O(),e.nextTick(()=>oe())},resetView:()=>oe(),exportData:Ct,importData:St,getMarkdown:()=>ze(d.value),setMarkdown:(t,n=!0)=>{const c=Fe(t||"");n&&(x.value=!0),E=!n,le.reset(),d.value=ne(c),m.value=null,g.value=new Set,L(),O(),e.nextTick(()=>{E=!1,oe()}),a("change",d.value)},setBalanced:t=>{Xe.value=t},isBalanced:()=>Xe.value,balance:()=>So(),applyNodeStyle:(t,n)=>K(t,n),getNodeStyle:t=>F(t),applyNodeLink:(t,n)=>D(t,n),removeNodeLink:t=>te(t),applyNodeNote:(t,n)=>ae(t,n),removeNodeNote:t=>v(t),undo:()=>Ke(),redo:()=>Ue(),canUndo:()=>le.canUndo(),canRedo:()=>le.canRedo(),applySettings:t=>{t.autoBalanceOnChange!==void 0&&(N.autoBalanceOnChange=t.autoBalanceOnChange),t.lineWidthStart!==void 0&&(N.lineWidthStart=Math.max(.5,Math.min(20,t.lineWidthStart))),t.lineWidthEnd!==void 0&&(N.lineWidthEnd=Math.max(.3,Math.min(10,t.lineWidthEnd))),t.rainbowBranch!==void 0&&(N.rainbowBranch=t.rainbowBranch),t.branchPaletteId!==void 0&&(N.branchPaletteId=t.branchPaletteId),t.customPalettes!==void 0&&(N.customPalettes=t.customPalettes),t.lineStyle!==void 0&&(N.lineStyle=t.lineStyle),t.taperedEdge!==void 0&&(N.taperedEdge=t.taperedEdge),t.showOrderBadge!==void 0&&(N.showOrderBadge=t.showOrderBadge)},getSettings:()=>({autoBalanceOnChange:N.autoBalanceOnChange,lineWidthStart:N.lineWidthStart,lineWidthEnd:N.lineWidthEnd,rainbowBranch:N.rainbowBranch,branchPaletteId:N.branchPaletteId,customPalettes:N.customPalettes,lineStyle:N.lineStyle,layoutMode:N.layoutMode,taperedEdge:N.taperedEdge,showOrderBadge:N.showOrderBadge}),setBranchPalette:t=>{if(!t)return;[...ke,...N.customPalettes].find(c=>c.id===t)&&(N.branchPaletteId=t)},getBranchPalette:()=>N.branchPaletteId,getBranchPalettes:()=>[...ke,...N.customPalettes]}),e.watch(()=>o.data,t=>{d.value=ne(t),L()},{deep:!1}),e.onMounted(()=>{O(),e.nextTick(()=>oe())}),(t,n)=>{var c,y,h;return e.openBlock(),e.createElementBlock("div",{class:"zm-mindmap",style:e.normalizeStyle({background:ee.value.bgColor,fontSize:ee.value.fontSize+"px"})},[e.createElementVNode("div",{ref_key:"wrapperRef",ref:u,class:"zm-canvas",onMousedown:No,onContextmenu:n[16]||(n[16]=e.withModifiers(()=>{},["prevent"])),onWheel:n[17]||(n[17]=(...r)=>e.unref(M).onWheel&&e.unref(M).onWheel(...r)),onClick:Mo},[e.createElementVNode("div",{class:"zm-svg-layer",style:e.normalizeStyle({left:Y.value.vbX*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:Y.value.vbY*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:Y.value.vbW*e.unref(M).scale.value+"px",height:Y.value.vbH*e.unref(M).scale.value+"px"})},[(e.openBlock(),e.createElementBlock("svg",{class:"zm-svg",viewBox:fo.value,preserveAspectRatio:"xMinYMin meet",width:Y.value.vbW*e.unref(M).scale.value,height:Y.value.vbH*e.unref(M).scale.value},[e.createElementVNode("g",Cn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(uo.value,r=>(e.openBlock(),e.createElementBlock("path",{key:r.key,d:no(Bt(r.from,"out",r.to.side,r.to),Bt(r.to,"in"),ft(r.from.depth),mt(r.to.depth),32,N.lineStyle,r.to._dir),fill:io(r.from,r.to),stroke:"none"},null,8,Sn))),128))])],8,Bn))],4),e.unref(M).isMarquee.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zm-marquee",style:e.normalizeStyle({left:e.unref(M).marquee.x*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:e.unref(M).marquee.y*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:e.unref(M).marquee.width*e.unref(M).scale.value+"px",height:e.unref(M).marquee.height*e.unref(M).scale.value+"px"})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"zm-world",style:e.normalizeStyle({transform:`translate(${e.unref(M).offsetX.value}px, ${e.unref(M).offsetY.value}px) scale(${e.unref(M).scale.value})`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(qe.value,r=>(e.openBlock(),e.createElementBlock("div",{key:r.id,class:e.normalizeClass(["zm-node",{"is-root":r.isRoot,"is-selected":m.value===r.id,"is-editing":f.value===r.id,"has-image":!!r.image,"is-resizing":Jn.value===r.id}]),"data-node-id":r.id,style:e.normalizeStyle({left:r.x+"px",top:r.y+"px",minWidth:r.width+"px",height:r.height+"px",fontSize:r.fontSize+"px",background:lo(r),color:ro(r),borderColor:ao(r),fontWeight:co(r),transform:"translate(-50%, -50%)"}),onClick:p=>Eo(p,r),onDblclick:p=>{p.stopPropagation(),i.readonly||Ne(r.id)},onContextmenu:p=>U(p,r),onMouseenter:p=>Qn(r.id),onMouseleave:p=>_n(r.id)},[r.image?(e.openBlock(),e.createElementBlock("img",{key:0,class:"zm-node-img",src:r.image.src,width:r.image.width,height:r.image.height,alt:r.text,draggable:"false"},null,8,Vn)):e.createCommentVNode("",!0),f.value!==r.id?(e.openBlock(),e.createElementBlock("span",zn,[e.createElementVNode("span",$n,e.toDisplayString(r.text),1),r.link&&!f.value?(e.openBlock(),e.createElementBlock("a",{key:0,class:"zm-node-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开链接:${r.link.url}`,onClick:n[0]||(n[0]=e.withModifiers(()=>{},["stop"])),onMousedown:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(H,{name:"link",size:11,stroke:2})],40,In)):e.createCommentVNode("",!0),r.note&&!f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-note-btn",type:"button",title:Gn(r.note.text),onClick:e.withModifiers(p=>at(r.id),["stop"]),onMousedown:n[2]||(n[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(H,{name:"note",size:11,stroke:2})],40,Wn)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.richContent&&f.value!==r.id?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["zm-rich",`zm-rich-${r.richContent.kind}`]),onClick:n[3]||(n[3]=e.withModifiers(()=>{},["stop"])),onDblclick:n[4]||(n[4]=e.withModifiers(()=>{},["stop"])),onMousedown:n[5]||(n[5]=e.withModifiers(()=>{},["stop"]))},[r.richContent.kind==="code"?(e.openBlock(),e.createElementBlock("pre",Rn,[e.createElementVNode("code",{class:e.normalizeClass(r.richContent.lang?`language-${r.richContent.lang}`:"")},e.toDisplayString(yo(r.richContent.raw)),3)])):r.richContent.kind==="list"?(e.openBlock(),e.createElementBlock("ul",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(po(r.richContent.raw),(p,C)=>(e.openBlock(),e.createElementBlock("li",{key:C},e.toDisplayString(p),1))),128))])):r.richContent.kind==="table"?(e.openBlock(),e.createElementBlock("table",Tn,[e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(xo(r.richContent.raw),(p,C)=>(e.openBlock(),e.createElementBlock("tr",{key:C},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p,(A,X)=>(e.openBlock(),e.createElementBlock("td",{key:X},e.toDisplayString(A),1))),128))]))),128))])])):(e.openBlock(),e.createElementBlock("div",Dn,e.toDisplayString(ko(r.richContent.raw)),1))],34)):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,class:"zm-input","onUpdate:modelValue":n[6]||(n[6]=p=>k.value=p),autofocus:"",onBlur:n[7]||(n[7]=p=>Ie()),onKeydown:[n[8]||(n[8]=e.withKeys(e.withModifiers(p=>Ie({addSibling:"after"}),["exact"]),["enter"])),n[9]||(n[9]=e.withKeys(e.withModifiers(p=>Ie({addSibling:"before"}),["shift","prevent","exact"]),["enter"])),n[10]||(n[10]=e.withKeys(e.withModifiers(p=>Ie({addChild:!0}),["prevent"]),["tab"])),e.withKeys(mo,["esc"]),ho],onMousedown:n[11]||(n[11]=e.withModifiers(()=>{},["stop"])),onClick:n[12]||(n[12]=e.withModifiers(()=>{},["stop"]))},null,544)),[[e.vModelText,k.value]]),w.value?(e.openBlock(),e.createElementBlock("span",{key:4,class:"zm-order-badge",title:`数据顺序:第 ${Mt(r.id)+1} 个`},e.toDisplayString(Mt(r.id)+1),9,An)):e.createCommentVNode("",!0),Nt(r.id)&&!r.isRoot&&je(r.id)>0?(e.openBlock(),e.createElementBlock("span",{key:5,class:e.normalizeClass(["zm-collapse-badge",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({background:ce.value.get(r.id)??"#64748b"}),title:`展开 ${je(r.id)} 个子节点`,onMousedown:n[13]||(n[13]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(p=>Et(r.id),["stop"])},e.toDisplayString(je(r.id)),47,Hn)):e.createCommentVNode("",!0),!i.readonly&&!r.isRoot&&Co(r)&&!Nt(r.id)?(e.openBlock(),e.createElementBlock("button",{key:6,class:e.normalizeClass(["zm-btn zm-collapse",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({color:ce.value.get(r.id)??"#64748b",borderColor:ce.value.get(r.id)??"#64748b"}),title:"折叠",onMousedown:n[14]||(n[14]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(p=>Et(r.id),["stop"])},[e.createVNode(H,{name:"minus",size:10,stroke:2.4})],46,Fn)):e.createCommentVNode("",!0),r.image&&m.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("span",{key:7,class:"zm-img-resize-handle",title:"拖动调整图片大小",onMousedown:e.withModifiers(p=>Zn(p,r),["stop"])},null,40,Pn)):e.createCommentVNode("",!0),r.image&&m.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("button",{key:8,class:"zm-img-remove-btn",title:"移除图片",onMousedown:n[15]||(n[15]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(p=>B(r.id),["stop"])},[e.createVNode(H,{name:"x",size:9,stroke:2.2})],40,On)):e.createCommentVNode("",!0)],46,vn))),128))],4),z.value?(e.openBlock(),e.createBlock(Mn,{key:1,x:z.value.x,y:z.value.y,container:u.value,"has-image":!!((c=e.unref($)(d.value,z.value.nodeId))!=null&&c.image),"has-link":!!((y=e.unref($)(d.value,z.value.nodeId))!=null&&y.link),"has-note":!!((h=e.unref($)(d.value,z.value.nodeId))!=null&&h.note),readonly:o.readonly,onPickImage:Q,onRemoveImage:Yn,onSetLink:_,onRemoveLink:me,onEditNote:be,onRemoveNote:he,onClose:j},null,8,["x","y","container","has-image","has-link","has-note","readonly"])):e.createCommentVNode("",!0)],544),o.previewMode?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Xn,[e.createElementVNode("button",{class:"zm-tb-btn",title:"放大",onClick:n[18]||(n[18]=(...r)=>e.unref(M).zoomIn&&e.unref(M).zoomIn(...r))},[e.createVNode(H,{name:"zoom-in"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"缩小",onClick:n[19]||(n[19]=(...r)=>e.unref(M).zoomOut&&e.unref(M).zoomOut(...r))},[e.createVNode(H,{name:"zoom-out"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"重置视图",onClick:oe},[e.createVNode(H,{name:"reset"})]),n[25]||(n[25]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-tb-btn",title:"添加子节点 (Tab)",onClick:n[20]||(n[20]=r=>m.value&&ge(m.value))},[e.createElementVNode("img",{src:e.unref(At),width:"14",height:"14",alt:"添加子节点",draggable:"false"},null,8,qn)])),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-tb-btn",title:"添加同级 (Enter)",onClick:n[21]||(n[21]=r=>m.value&&We(m.value))},[e.createElementVNode("img",{src:e.unref(Dt),width:"14",height:"14",alt:"添加同级",draggable:"false"},null,8,Kn)])),n[26]||(n[26]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:N.layoutMode==="mindmap"}]),title:"思维导图布局 (中心辐射)",onClick:n[22]||(n[22]=r=>Ye("mindmap"))},[e.createVNode(H,{name:"mindmap"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:N.layoutMode==="tree"}]),title:"树形布局 (向右展开)",onClick:n[23]||(n[23]=r=>Ye("tree"))},[e.createVNode(H,{name:"tree"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:N.layoutMode==="org"}]),title:"组织结构布局 (向下展开)",onClick:n[24]||(n[24]=r=>Ye("org"))},[e.createVNode(H,{name:"org"})],2),n[27]||(n[27]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-tb-btn",title:"导入 JSON",onClick:vo},[e.createVNode(H,{name:"import"})])),e.createElementVNode("button",{class:"zm-tb-btn",title:"导出 JSON",onClick:Vo},[e.createVNode(H,{name:"export"})]),e.createElementVNode("span",Un,e.toDisplayString(Math.round(e.unref(M).scale.value*100))+"%",1)]))],4)}}}),jn={install(i){i.component("FlowMindMap",rt)}};T.MindMap=rt,T.addChild=nt,T.addSibling=ot,T.clone=ne,T.default=jn,T.findNode=$,T.findParent=Z,T.markdownToMindMap=Fe,T.markdownToRichMindMap=fn,T.mindMapToMarkdown=ze,T.removeNode=He,T.richBlockToMarkdown=mn,T.uid=J,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
6
|
+
`);for(const o of i.children)l+=ze(o,s+1);return l}function un(i){var g,d;const s=i.split(/\r?\n/),l=[];let o=0;const a=/^(#{1,6})\s+(.+?)\s*#*\s*$/,u=/^(`{3,}|~{3,})\s*(\S+)?\s*$/,f=/^\s*\|?\s*(:?-+:?\s*\|\s*)+(:?-+:?)(\s*\|)?\s*$/,k=/^(\s*)[-*+]\s+(.*)$/,m=/^(\s*)\d+\.\s+(.*)$/;for(;o<s.length;){const p=s[o],N=p.match(u);if(N){const B=N[1][0],W=N[2]||"",S=[p];for(o++;o<s.length;){const A=s[o].match(u);if(A&&A[1][0]===B){S.push(s[o]),o++;break}S.push(s[o]),o++}const X=S.slice(1,-1).join(`
|
|
7
|
+
`).trim();l.push({kind:"code",text:((g=X.split(`
|
|
8
|
+
`)[0])==null?void 0:g.slice(0,80))||"(空代码块)",raw:S.join(`
|
|
9
|
+
`),lang:W});continue}const w=p.match(a);if(w){l.push({kind:"heading",level:w[1].length,text:w[2].trim(),raw:p}),o++;continue}if(/^\s*\|/.test(p)){const B=[];let W=o,S=!1;for(;W<s.length&&/^\s*\|/.test(s[W]);)B.push(s[W]),f.test(s[W])&&(S=!0),W++;if(S&&B.length>=2){l.push({kind:"table",text:((d=B[0].replace(/^\s*\|/,"").replace(/\|\s*$/,"").split("|")[0])==null?void 0:d.trim())||"表格",raw:B.join(`
|
|
10
|
+
`)}),o=W;continue}}const $=p.match(k),F=p.match(m);if($||F){let B=o;for(;B<s.length;){const W=s[B].match(k),S=s[B].match(m);if(!(W||S))break;const X=s[B].replace(/^\s*[-*+]\s+/,"").replace(/^\s*\d+\.\s+/,"").trim();X.length>0&&l.push({kind:"list",text:X.slice(0,80)||"(列表项)",raw:s[B]}),B++}o=B;continue}if(p.trim()===""){o++;continue}const q=[p];let D=o+1;for(;D<s.length;){const B=s[D];if(B.trim()===""||a.test(B)||u.test(B)||k.test(B)||m.test(B)||/^\s*\|/.test(B))break;q.push(B),D++}const b=q.join(" ").trim();l.push({kind:"paragraph",text:b.slice(0,80)||"(空段落)",raw:q.join(`
|
|
11
|
+
`)}),o=D}return l}function fn(i,s="导入的导图"){const l=un(i||""),o={id:J(),text:s,children:[]},a=[o],u=[0];let f=!1;function k(m){if(m.kind==="heading"){const d=m.level;for(;a.length>1&&u[u.length-1]>=d;)a.pop(),u.pop();if(!f&&d===1){f=!0,o.text=m.text,u[0]=1;return}const p={id:J(),text:m.text,children:[]};a[a.length-1].children.push(p),a.push(p),u.push(d);return}const g={id:J(),text:m.text,children:[],richContent:{kind:m.kind,raw:m.raw,lang:m.lang}};a[a.length-1].children.push(g)}for(const m of l)k(m);return o}function mn(i){return i.richContent?i.richContent.raw+`
|
|
12
|
+
`:""}function hn(i){const s=i.minScale??.2,l=i.maxScale??3,o=i.step??1.2,a=e.ref(1),u=e.ref(0),f=e.ref(0),k=e.ref(!1),m=e.reactive({x:0,y:0,ox:0,oy:0}),g=e.ref(!1),d=e.reactive({x:0,y:0}),p=e.reactive({x:0,y:0,width:0,height:0}),N=e.ref(0);let w=null;function $(C){w=C}function F(C){C.preventDefault();const V=i.getContainer();if(!V)return;const K=-C.deltaY*.001,Y=Math.min(l,Math.max(s,a.value*(1+K))),Q=V.getBoundingClientRect(),_=C.clientX-Q.left,me=C.clientY-Q.top,be=(_-u.value)/a.value,he=(me-f.value)/a.value;a.value=Y,u.value=_-be*Y,f.value=me-he*Y}function q(){a.value=Math.min(l,a.value*o)}function D(){a.value=Math.max(s,a.value/o)}function b(C){var K;C.target.closest(".zm-node, .zm-toolbar, button, input, textarea")||(k.value=!0,m.x=C.clientX,m.y=C.clientY,m.ox=u.value,m.oy=f.value,window.addEventListener("mousemove",B),window.addEventListener("mouseup",W),(K=C.preventDefault)==null||K.call(C))}function B(C){k.value&&(u.value=m.ox+(C.clientX-m.x),f.value=m.oy+(C.clientY-m.y))}function W(){k.value=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",W)}function S(C,V){g.value=!0,d.x=C,d.y=V,p.x=C,p.y=V,p.width=0,p.height=0,N.value++,window.addEventListener("mousemove",te),window.addEventListener("mouseup",A)}function X(C,V){if(!g.value)return;const K=Math.min(d.x,C),Y=Math.min(d.y,V),Q=Math.max(d.x,C),_=Math.max(d.y,V);p.x=K,p.y=Y,p.width=Q-K,p.height=_-Y,N.value++}function A(){g.value=!1,window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",A),w&&w()}function te(C){if(!g.value)return;const V=i.getContainer();if(!V)return;const K=V.getBoundingClientRect(),Y=(C.clientX-K.left-u.value)/a.value,Q=(C.clientY-K.top-f.value)/a.value;X(Y,Q)}function ae(C,V,K,Y=60){const Q=i.getContainer();if(!Q)return;const _=Q.getBoundingClientRect(),me=(_.width-Y*2)/C,be=(_.height-Y*2)/V,he=Math.min(1,Math.max(.3,Math.min(me,be)));a.value=he,u.value=_.width/2,f.value=_.height/2-K*he}return{scale:a,offsetX:u,offsetY:f,isPanning:k,onWheel:F,zoomIn:q,zoomOut:D,startPan:b,startMarquee:S,updateMarquee:X,isMarquee:g,marquee:p,marqueeVersion:N,setOnMarqueeEnd:$,resetView:ae}}const gn=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function lt(i){return gn?i.metaKey:i.ctrlKey}function yn(i){function s(){const o=i.getSelectedId();return o||(i.defaultTargetId?i.defaultTargetId():i.getRootId())}function l(o){const a=o.target;if(a&&(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)||i.isReadonly()||i.isEditing())return;const u=i.getSelectedId(),f=s();if(f){if(lt(o)&&!o.shiftKey){if(o.key==="d"||o.key==="D"){u&&u!==i.getRootId()&&(o.preventDefault(),i.onDuplicate(u));return}if(o.key==="z"||o.key==="Z"){o.preventDefault(),i.onUndo();return}if(o.key==="y"||o.key==="Y"){o.preventDefault(),i.onRedo();return}if(o.key==="Home"){o.preventDefault(),i.onSelectRoot();return}}if(lt(o)&&o.shiftKey&&(o.key==="Z"||o.key==="z")){o.preventDefault(),i.onRedo();return}o.key==="Tab"?(o.preventDefault(),i.onAddChild(f)):o.key==="Enter"?(o.preventDefault(),o.shiftKey?u&&u!==i.getRootId()&&i.onAddSiblingBefore(u):i.onAddSibling(f)):(o.key==="Delete"||o.key==="Backspace")&&u&&u!==i.getRootId()?(o.preventDefault(),i.onRemove(u)):o.key==="F2"&&u?(o.preventDefault(),i.onStartEdit(u)):o.key==="Escape"?(o.preventDefault(),i.onClearSelection()):o.key==="ArrowDown"?(o.preventDefault(),i.onNavigate(0,1)):o.key==="ArrowUp"?(o.preventDefault(),i.onNavigate(0,-1)):o.key==="ArrowRight"?(o.preventDefault(),i.onNavigate(1,0)):o.key==="ArrowLeft"&&(o.preventDefault(),i.onNavigate(-1,0))}}e.onMounted(()=>{window.addEventListener("keydown",l)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",l)})}function pn(i=100){const s=e.ref([]);let l=-1;function o(){return l>0}function a(){return l<s.value.length-1}function u(g){const d=JSON.stringify(g);for(l<s.value.length-1&&(s.value=s.value.slice(0,l+1)),s.value.push(d),l=s.value.length-1;s.value.length>i;)s.value.shift(),l--}function f(){return o()?(l--,JSON.parse(s.value[l])):null}function k(){return a()?(l++,JSON.parse(s.value[l])):null}function m(){s.value=[],l=-1}return{canUndo:o,canRedo:a,record:u,undo:f,redo:k,reset:m}}const xn=["disabled"],kn=["disabled"],wn=["disabled"],bn=["disabled"],En=["disabled"],Nn=["disabled"],Mn=e.defineComponent({__name:"NodeContextMenu",props:{x:{},y:{},container:{},hasImage:{type:Boolean,default:!1},hasLink:{type:Boolean,default:!1},hasNote:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},emits:["pickImage","setLink","removeLink","editNote","removeNote","removeImage","close"],setup(i,{emit:s}){const l=i,o=s,a=e.computed(()=>{let N=l.x+2,w=l.y+2;if(l.container){const $=l.container.getBoundingClientRect(),F=180,q=u.value?f.value?184:160:136;N+F>$.right&&(N=Math.max($.left+4,l.x-F-2)),w+q>$.bottom&&(w=Math.max($.top+4,l.y-q-2)),N<$.left+2&&(N=$.left+2),w<$.top+2&&(w=$.top+2)}return{left:N,top:w}}),u=e.computed(()=>l.hasImage),f=e.computed(()=>l.hasLink),k=e.computed(()=>l.hasNote);function m(N){const w=N.target;w&&w.closest(".zm-node-menu")||o("close")}function g(N){N.key==="Escape"&&o("close")}function d(){o("close")}window.addEventListener("mousedown",m,!0),window.addEventListener("keydown",g,!0),window.addEventListener("wheel",d,!0),window.addEventListener("scroll",d,!0),e.onBeforeUnmount(()=>{window.removeEventListener("mousedown",m,!0),window.removeEventListener("keydown",g,!0),window.removeEventListener("wheel",d,!0),window.removeEventListener("scroll",d,!0)});function p(N){l.readonly||(N(),o("close"))}return(N,w)=>(e.openBlock(),e.createElementBlock("div",{class:"zm-node-menu",style:e.normalizeStyle({left:a.value.left+"px",top:a.value.top+"px"}),onContextmenu:w[6]||(w[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[0]||(w[0]=e.withModifiers($=>p(()=>o("pickImage")),["stop"]))},[e.createVNode(H,{name:"image",size:13}),e.createElementVNode("span",null,e.toDisplayString(u.value?"替换图片":"添加图片"),1)],8,xn),u.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[1]||(w[1]=e.withModifiers($=>p(()=>o("removeImage")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[7]||(w[7]=e.createElementVNode("span",null,"移除图片",-1))],8,kn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[2]||(w[2]=e.withModifiers($=>p(()=>o("setLink")),["stop"]))},[e.createVNode(H,{name:"link",size:13}),e.createElementVNode("span",null,e.toDisplayString(f.value?"编辑链接":"添加链接"),1)],8,wn),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[3]||(w[3]=e.withModifiers($=>p(()=>o("removeLink")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[8]||(w[8]=e.createElementVNode("span",null,"移除链接",-1))],8,bn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:i.readonly,onClick:w[4]||(w[4]=e.withModifiers($=>p(()=>o("editNote")),["stop"]))},[e.createVNode(H,{name:"note",size:13}),e.createElementVNode("span",null,e.toDisplayString(k.value?"编辑笔记":"添加笔记"),1)],8,En),k.value?(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-node-menu-item",disabled:i.readonly,onClick:w[5]||(w[5]=e.withModifiers($=>p(()=>o("removeNote")),["stop"]))},[e.createVNode(H,{name:"x",size:13}),w[9]||(w[9]=e.createElementVNode("span",null,"移除笔记",-1))],8,Nn)):e.createCommentVNode("",!0)],36))}}),Bn=["viewBox","width","height"],vn={class:"zm-edges"},Cn=["d","fill"],Sn=["data-node-id","onClick","onDblclick","onContextmenu","onMouseenter","onMouseleave"],Vn=["src","width","height","alt"],zn={key:1,class:"zm-text"},In={class:"zm-text-label"},Wn=["href","title"],$n=["title","onClick"],Rn=["title"],Tn=["title","onClick"],Ln=["onClick"],An=["onMousedown"],Hn=["onClick"],Dn={key:0,class:"zm-toolbar"},Pn=["src"],Fn=["src"],On={class:"zm-tb-tip"},fe=24,we=400,re=160,rt=e.defineComponent({__name:"MindMap",props:{data:{},readonly:{type:Boolean,default:!1},theme:{},previewMode:{type:Boolean,default:!1},markdown:{},lineColors:{}},emits:["change","select","edit-note","markdownChange"],setup(i,{expose:s,emit:l}){const o=i,a=l,u=e.ref(null),f=e.ref(null),k=e.ref(""),m=e.ref(null),g=e.ref(new Set),d=e.ref(ne(o.data)),p=e.ref(o.markdown!==void 0);let N=!1;e.watch(()=>o.markdown,t=>{if(t===void 0){p.value=!1;return}p.value=!0;const n=Pe(t||"");N=!0,d.value=ne(n),m.value=null,g.value=new Set,T(),e.nextTick(()=>{N=!1,oe()})}),e.watch(d,()=>{p.value&&!N&&a("markdownChange",ze(d.value))},{deep:!0});const w=e.computed(()=>E.showOrderBadge===!0),$=e.ref(new Map),F=$.value;function q(t,n){const c={};n.bg&&(c.bg=n.bg),n.textColor&&(c.textColor=n.textColor),n.borderColor&&(c.borderColor=n.borderColor),n.fontWeight&&(c.fontWeight=n.fontWeight),Object.keys(c).length===0?F.delete(t):F.set(t,c),$.value=new Map(F)}function D(t){return F.get(t)??{}}function b(t,n){const c=z(d.value,t);c&&(c.image={src:n.src,naturalW:n.naturalW,naturalH:n.naturalH,width:W(n.width,fe,we),height:W(n.height,fe,we)},O(),T(),a("change",d.value))}function B(t){const n=z(d.value,t);!n||!n.image||(delete n.image,O(),T(),a("change",d.value))}function W(t,n,c){return Math.min(c,Math.max(n,t))}function S(t,n){const c=new FileReader;c.onload=()=>{if(typeof c.result!="string")return;const y=c.result,h=new window.Image;h.onload=()=>{const r=h.naturalWidth||re,x=h.naturalHeight||re,I=W(r,fe,re),P=W(Math.round(x*I/r),fe,we);n({src:y,naturalW:r,naturalH:x,width:I,height:P})},h.onerror=()=>{n({src:y,naturalW:re,naturalH:re,width:re,height:re})},h.src=y},c.readAsDataURL(t)}function X(t){const n=document.createElement("input");n.type="file",n.accept="image/*",n.style.display="none",n.onchange=()=>{var y;const c=(y=n.files)==null?void 0:y[0];c&&(S(c,h=>b(t,h)),document.body.removeChild(n))},document.body.appendChild(n),n.click()}function A(t,n){const c=n.trim(),y=z(d.value,t);y&&(c?y.link={url:c}:delete y.link,O(),T(),a("change",d.value))}function te(t){A(t,"")}function ae(t,n){const c=z(d.value,t);c&&(n?c.note={text:n}:delete c.note,O(),T(),a("change",d.value))}function C(t){ae(t,"")}const V=e.ref(null);function K(t,n){o.readonly||(t.preventDefault(),t.stopPropagation(),m.value=n.id,a("select",z(d.value,n.id)),V.value={nodeId:n.id,x:t.clientX,y:t.clientY})}function Y(){V.value=null}function Q(){var n;const t=(n=V.value)==null?void 0:n.nodeId;t&&X(t)}function _(){var y,h,r;const t=(y=V.value)==null?void 0:y.nodeId;if(!t)return;const n=((r=(h=z(d.value,t))==null?void 0:h.link)==null?void 0:r.url)??"",c=window.prompt("输入链接 URL(留空取消)",n);c!==null&&A(t,c)}function me(){var n;const t=(n=V.value)==null?void 0:n.nodeId;t&&te(t)}function be(){var n;const t=(n=V.value)==null?void 0:n.nodeId;t&&at(t)}function he(){var n;const t=(n=V.value)==null?void 0:n.nodeId;t&&C(t)}function qn(){var n;const t=(n=V.value)==null?void 0:n.nodeId;t&&B(t)}function at(t){o.readonly||a("edit-note",t)}function Kn(t,n=60){const c=t.replace(/\s+/g," ").trim();return c.length<=n?c||"点击编辑笔记":c.slice(0,n)+"…"}function ct(t){var h;if(o.readonly||f.value)return;const n=t.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const c=m.value;if(!c)return;const y=(h=t.clipboardData)==null?void 0:h.items;if(y)for(let r=0;r<y.length;r++){const x=y[r];if(x.kind==="file"&&x.type.startsWith("image/")){const I=x.getAsFile();if(!I)continue;t.preventDefault();const P=z(d.value,c);if(P!=null&&P.image&&!window.confirm("该节点已有图片,要用剪贴板里的图片替换吗?"))return;S(I,U=>b(c,U));return}}}e.onMounted(()=>{window.addEventListener("paste",ct)}),e.onBeforeUnmount(()=>{window.removeEventListener("paste",ct)});const Ee=e.ref(null),Un=e.computed(()=>{var t;return((t=Ee.value)==null?void 0:t.nodeId)??null});function Yn(t,n){if(!n.image)return;t.preventDefault(),t.stopPropagation();const c=n.image.naturalW||n.image.width,y=n.image.naturalH||n.image.height,h=y>0?y/c:1;Ee.value={nodeId:n.id,startX:t.clientX,startY:t.clientY,startW:n.image.width,startH:n.image.height,naturalW:c,naturalH:y,ratio:h,pendingW:n.image.width,pendingH:n.image.height},window.addEventListener("mousemove",st),window.addEventListener("mouseup",dt)}function st(t){var P,U;const n=Ee.value;if(!n)return;const c=M.scale.value||1,y=t.clientX-n.startX,h=W(n.startW+y/c,fe,we),r=W(h*n.ratio,fe,we);n.pendingW=h,n.pendingH=r;const x=(P=u.value)==null?void 0:P.querySelector(`[data-node-id="${n.nodeId}"] .zm-node-img`);x&&(x.style.width=`${h}px`,x.style.height=`${r}px`);const I=(U=u.value)==null?void 0:U.querySelector(`[data-node-id="${n.nodeId}"]`);I&&(I.style.minWidth=`${Math.max(80,Math.ceil(h+28))}px`,I.style.height=`${Math.ceil(r+8+30)}px`)}function dt(){const t=Ee.value;if(window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",dt),Ee.value=null,!t)return;const n=z(d.value,t.nodeId);!n||!n.image||(b(t.nodeId,{src:n.image.src,naturalW:n.image.naturalW,naturalH:n.image.naturalH,width:t.pendingW,height:t.pendingH}),m.value=t.nodeId,a("select",n),Oe=!0)}const Fe=e.ref(null);let Oe=!1;function jn(t){Fe.value=t}function Gn(t){Fe.value===t&&(Fe.value=null)}const ut=e.ref(0),Xe=e.ref(!1),le=pn(100);function O(){le.record({data:d.value})}function T(){g.value=new Set(g.value),ut.value++}const ee=e.computed(()=>{var t,n,c,y,h,r,x,I,P,U;return{rootBg:((t=o.theme)==null?void 0:t.rootBg)??"#1f2937",rootText:((n=o.theme)==null?void 0:n.rootText)??"#ffffff",branchBg:((c=o.theme)==null?void 0:c.branchBg)??"#ffffff",branchText:((y=o.theme)==null?void 0:y.branchText)??"#1f2937",lineColor:((h=o.theme)==null?void 0:h.lineColor)??"#94a3b8",bgColor:((r=o.theme)==null?void 0:r.bgColor)??"#f8fafc",fontSize:((x=o.theme)==null?void 0:x.fontSize)??14,lineWidthStart:((I=o.theme)==null?void 0:I.lineWidthStart)??2.2,lineWidthEnd:((P=o.theme)==null?void 0:P.lineWidthEnd)??.8,rainbowBranch:((U=o.theme)==null?void 0:U.rainbowBranch)??!1}}),E=e.reactive({autoBalanceOnChange:!0,lineWidthStart:12,lineWidthEnd:3.6,rainbowBranch:!0,branchPaletteId:"default",customPalettes:[],lineStyle:"curve",layoutMode:"mindmap",taperedEdge:!0,showOrderBadge:!1});function ft(t){return E.taperedEdge?Jn(t):ht(t)}function mt(t){return E.taperedEdge?E.lineWidthEnd:ht(t)}function Jn(t){return t<=0?E.lineWidthStart:t===1?Math.max(1.5,E.lineWidthStart*.67):t===2?Math.max(.8,E.lineWidthStart*.42):E.lineWidthEnd}function ht(t){if(t<=0)return E.lineWidthStart;if(t>=3)return E.lineWidthEnd;const n=t/3;return E.lineWidthStart+(E.lineWidthEnd-E.lineWidthStart)*n}function Zn(t,n,c,y){const h=1-t,r=h*h*h*n.x+3*h*h*t*c.x1+3*h*t*t*c.x2+t*t*t*y.x,x=h*h*h*n.y+3*h*h*t*c.y1+3*h*t*t*c.y2+t*t*t*y.y;return{x:r,y:x}}function Qn(t,n,c,y,h=32,r="curve",x="right"){if(r==="curve"){let de;if(x==="right"||x==="left"){const R=Math.abs(n.x-t.x)*.45,ie=x==="right"?1:-1;de={x1:t.x+ie*R,y1:t.y,x2:n.x-ie*R,y2:n.y}}else{const R=Math.abs(n.y-t.y)*.45;de={x1:t.x,y1:t.y+R,x2:n.x,y2:n.y-R}}const Eo=v=>{const R=1-v,ie=-3*R*R*t.x+3*(R*R-2*R*v)*de.x1+3*(2*R*v-v*v)*de.x2+3*v*v*n.x,xe=-3*R*R*t.y+3*(R*R-2*R*v)*de.y1+3*(2*R*v-v*v)*de.y2+3*v*v*n.y;return{dx:ie,dy:xe}},Be=[],Ge=[];for(let v=0;v<=h;v++){const R=v/h,ie=v===0?t:v===h?n:Zn(R,t,de,n),xe=Eo(R);let Te=Math.hypot(xe.dx,xe.dy);Te<1e-6&&(Te=1);const Wt=-xe.dy/Te,$t=xe.dx/Te,Le=(c+(y-c)*R)/2;Be.push({x:ie.x+Wt*Le,y:ie.y+$t*Le}),Ge.push({x:ie.x-Wt*Le,y:ie.y-$t*Le})}let Re=`M ${Be[0].x.toFixed(2)} ${Be[0].y.toFixed(2)}`;for(let v=1;v<=h;v++)Re+=` L ${Be[v].x.toFixed(2)} ${Be[v].y.toFixed(2)}`;for(let v=h;v>=0;v--)Re+=` L ${Ge[v].x.toFixed(2)} ${Ge[v].y.toFixed(2)}`;return Re+=" Z",Re}const I=n.x-t.x,P=n.y-t.y;let U=Math.hypot(I,P);U<1e-6&&(U=1);const se=-P/U,ye=I/U,pe=c/2,Me=y/2,St={x:t.x+se*pe,y:t.y+ye*pe},Vt={x:t.x-se*pe,y:t.y-ye*pe},zt={x:n.x-se*Me,y:n.y-ye*Me},It={x:n.x+se*Me,y:n.y+ye*Me};return`M ${St.x.toFixed(2)} ${St.y.toFixed(2)} L ${It.x.toFixed(2)} ${It.y.toFixed(2)} L ${zt.x.toFixed(2)} ${zt.y.toFixed(2)} L ${Vt.x.toFixed(2)} ${Vt.y.toFixed(2)} Z`}const Ie=e.computed(()=>j.value.root.children),_n=ke[0].colors,gt=e.computed(()=>rn(E.branchPaletteId,E.customPalettes)),ce=e.computed(()=>{const t=new Map;if(!E.rainbowBranch)return t;const n=o.lineColors,c=n&&n.length>0?n:gt.value.colors.length>0?gt.value.colors:_n;for(let h=0;h<Ie.value.length;h++){const r=Ie.value[h];t.set(r.id,c[h%c.length])}const y=(h,r)=>{t.set(h.id,r);for(const x of h.children)y(x,r)};for(let h=0;h<Ie.value.length;h++){const r=Ie.value[h];y(r,c[h%c.length])}return t});function eo(t,n){return E.rainbowBranch?ce.value.get(n.id)??ee.value.lineColor:ee.value.lineColor}function to(t){const n=D(t.id);if(n.bg)return n.bg;if(t.isRoot)return ee.value.rootBg;if(E.rainbowBranch){const c=ce.value.get(t.id);if(c)return lo(c,.18)}return ee.value.branchBg}function no(t){const n=D(t.id);if(n.textColor)return n.textColor;if(t.isRoot)return ee.value.rootText;if(E.rainbowBranch){const c=ce.value.get(t.id);if(c)return yt(c,.55)}return ee.value.branchText}function oo(t){const n=D(t.id);if(n.borderColor)return n.borderColor;if(t.isRoot)return ee.value.rootBg;if(E.rainbowBranch){const c=ce.value.get(t.id);if(c)return yt(c,.3)}return ee.value.lineColor}function io(t){return D(t.id).fontWeight??(t.isRoot?600:400)}function lo(t,n){const c=t.replace("#",""),y=c.length===6?c:c.split("").map(I=>I+I).join(""),h=parseInt(y.slice(0,2),16),r=parseInt(y.slice(2,4),16),x=parseInt(y.slice(4,6),16);return`rgba(${h}, ${r}, ${x}, ${n})`}function yt(t,n){const c=t.replace("#",""),y=c.length===6?c:c.split("").map(I=>I+I).join(""),h=Math.round(parseInt(y.slice(0,2),16)*(1-n)),r=Math.round(parseInt(y.slice(2,4),16)*(1-n)),x=Math.round(parseInt(y.slice(4,6),16)*(1-n));return`rgb(${h}, ${r}, ${x})`}const M=hn({getContainer:()=>u.value});M.setOnMarqueeEnd(po),yn({isEditing:()=>f.value!==null,isReadonly:()=>o.readonly,getSelectedId:()=>m.value,getRootId:()=>d.value.id,defaultTargetId:()=>d.value.id,onAddChild:ge,onAddSibling:$e,onAddSiblingBefore:kt,onRemove:bt,onStartEdit:Ne,onClearSelection:()=>{m.value=null,a("select",null)},onDuplicate:wt,onUndo:Ke,onRedo:Ue,onNavigate:uo,onSelectRoot:()=>{m.value=d.value.id;const t=z(d.value,d.value.id);t&&a("select",t)}});const j=e.computed(()=>{const t=ne(d.value);return xt(t),tn(t,{mode:E.layoutMode,baseFontSize:ee.value.fontSize})}),pt=e.ref([]),qe=e.computed(()=>(ut.value,pt.value));e.watch(j,t=>{const n=[],c=y=>{n.push(y);for(const h of y.children)c(h)};c(t.root),pt.value=n},{immediate:!0});const ro=e.computed(()=>{const t=[];for(const n of qe.value)for(const c of n.children)t.push({from:n,to:c,key:`${n.id}->${c.id}`});return t}),ao=e.computed(()=>`${j.value.vbX} ${j.value.vbY} ${j.value.vbW} ${j.value.vbH}`);function xt(t){if(g.value.has(t.id)){t.children=[],t.collapsed=!0;return}t.collapsed=!1;for(const n of t.children)xt(n)}function Ne(t){const n=z(d.value,t);n&&(f.value=t,k.value=n.text,e.nextTick(()=>{const c=document.querySelector(".zm-input");c==null||c.focus(),c==null||c.select()}))}function We(t={}){if(!f.value)return;const n=z(d.value,f.value);n&&n.text!==(k.value.trim()||" ")&&(n.text=k.value.trim()||" ",O(),a("change",d.value));const c=f.value;f.value=null,t.addChild?e.nextTick(()=>ge(c)):t.addSibling==="after"?e.nextTick(()=>$e(c)):t.addSibling==="before"&&e.nextTick(()=>kt(c))}function co(){f.value=null}function so(t){const n=t.metaKey||t.ctrlKey;n&&(t.key==="z"||t.key==="Z")&&!t.shiftKey?(t.preventDefault(),Ke()):(n&&t.shiftKey&&(t.key==="z"||t.key==="Z")||n&&(t.key==="y"||t.key==="Y")&&!t.shiftKey)&&(t.preventDefault(),Ue())}function ge(t){const n=nt(d.value,t,Ve);n&&(O(),T(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function $e(t){if(t===d.value.id){ge(t);return}const n=ot(d.value,t,Ve);n&&(O(),T(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function kt(t){if(t===d.value.id){ge(t);return}const n=sn(d.value,t,Ve);n&&(O(),T(),a("change",d.value),e.nextTick(()=>Ne(n.id)))}function wt(t){if(t===d.value.id)return;const n=dn(d.value,t);n&&(O(),m.value=n.id,a("change",d.value),T())}function Ke(){const t=le.undo();t&&(d.value=t.data,m.value=null,a("select",null),T(),a("change",d.value))}function Ue(){const t=le.redo();t&&(d.value=t.data,m.value=null,a("select",null),T(),a("change",d.value))}function uo(t,n){const c=m.value??d.value.id,y=z(d.value,c);if(!y)return;let h=null;if(n===1){const r=Z(d.value,y.id);if(r){const x=r.children.findIndex(I=>I.id===y.id);x>=0&&x<r.children.length-1&&(h=r.children[x+1].id)}}else if(n===-1){const r=Z(d.value,y.id);if(r){const x=r.children.findIndex(I=>I.id===y.id);x>0&&(h=r.children[x-1].id)}}else if(t===1){const r=Z(d.value,y.id);r&&(h=r.id)}else t===-1&&y.children.length>0&&(h=y.children[0].id);if(h){m.value=h;const r=z(d.value,h);r&&a("select",r)}}function bt(t){t!==d.value.id&&De(d.value,t)&&(O(),m.value===t&&(m.value=null),T(),a("change",d.value))}function Et(t){g.value.has(t)?g.value.delete(t):g.value.add(t),T()}function fo(t,n){an(d.value,t,n)&&(O(),T(),a("change",d.value))}function mo(t,n,c){return cn(d.value,t,n,c)?(O(),T(),a("change",d.value),!0):!1}function ho(t,n){t.stopPropagation(),m.value=n.id;const c=z(d.value,n.id);a("select",c)}function go(t){const n=t.target;if(!n||n.closest(".zm-node, .zm-toolbar, button, input, textarea"))return;if(t.button===2){M.startPan(t);return}if(t.button!==0)return;const c=u.value.getBoundingClientRect(),y=(t.clientX-c.left-M.offsetX.value)/M.scale.value,h=(t.clientY-c.top-M.offsetY.value)/M.scale.value;M.startMarquee(y,h)}function yo(t){if(Oe){Oe=!1;return}const n=t.target;if(!n||n.closest(".zm-node"))return;const c=M.marquee;c.width>=4||c.height>=4||m.value!==null&&(m.value=null,a("select",null))}function po(){const t=M.marquee;if(t.width<4&&t.height<4)return;const n=t.x,c=t.y,y=t.x+t.width,h=t.y+t.height,r=[];for(const x of qe.value){const I=x.width/2,P=x.height/2,U=x.x-I,se=x.x+I,ye=x.y-P,pe=x.y+P;U<=y&&se>=n&&ye<=h&&pe>=c&&r.push(x.id)}if(r.length>0){m.value=r[0];const x=z(d.value,r[0]);x&&a("select",x)}}function Nt(t){return g.value.has(t)}function xo(t){const n=z(d.value,t.id);return!!n&&n.children.length>0}function Ye(t){const n=z(d.value,t);return n?n.children.length:0}function Mt(t){if(!z(d.value,t))return 0;const y=[d.value];for(;y.length;){const h=y.pop(),r=h.children.findIndex(x=>x.id===t);if(r>=0)return r;for(const x of h.children)y.push(x)}return 0}function Bt(t,n,c,y){if(((y==null?void 0:y._dir)??t._dir)==="down")return n==="out"?{x:t.x,y:t.y+t.height/2}:{x:t.x,y:t.y-t.height/2};let r;return n==="in"?r=-t.side:c!==void 0?r=c:r=t.side,{x:t.x+r*(t.width/2),y:t.y}}function oe(){const t=j.value;M.resetView(t.width,t.height,t.root.y)}function ko(){Xe.value=!0,O(),T(),e.nextTick(()=>oe())}function je(t){E.layoutMode!==t&&(E.layoutMode=t,T(),e.nextTick(()=>oe()))}function vt(){return JSON.stringify(d.value,null,2)}function Ct(t){try{const n=JSON.parse(t);return!n.id||!Array.isArray(n.children)?!1:(le.reset(),d.value=ne(n),m.value=null,g.value=new Set,T(),e.nextTick(()=>oe()),a("change",d.value),!0)}catch{return!1}}function wo(){const t=document.createElement("input");t.type="file",t.accept="application/json",t.onchange=()=>{var y;const n=(y=t.files)==null?void 0:y[0];if(!n)return;const c=new FileReader;c.onload=()=>{typeof c.result=="string"&&(Ct(c.result)||alert("导入失败:JSON 格式无效"))},c.readAsText(n)},t.click()}function bo(){const t=new Blob([vt()],{type:"application/json"}),n=URL.createObjectURL(t),c=document.createElement("a");c.href=n,c.download=`${d.value.text||"mindmap"}.json`,c.click(),URL.revokeObjectURL(n)}return s({addChild:t=>ge(t),addSibling:t=>$e(t),removeNode:t=>bt(t),duplicateNode:t=>wt(t),setNodeText:(t,n)=>fo(t,n),moveNode:(t,n,c)=>mo(t,n,c),lineWidthForDepth:ft,endWidthForDepth:mt,getData:()=>d.value,setData:t=>{le.reset(),d.value=ne(t),m.value=null,g.value=new Set,T(),O(),e.nextTick(()=>oe())},resetView:()=>oe(),exportData:vt,importData:Ct,getMarkdown:()=>ze(d.value),setMarkdown:(t,n=!0)=>{const c=Pe(t||"");n&&(p.value=!0),N=!n,le.reset(),d.value=ne(c),m.value=null,g.value=new Set,T(),O(),e.nextTick(()=>{N=!1,oe()}),a("change",d.value)},setBalanced:t=>{Xe.value=t},isBalanced:()=>Xe.value,balance:()=>ko(),applyNodeStyle:(t,n)=>q(t,n),getNodeStyle:t=>D(t),applyNodeLink:(t,n)=>A(t,n),removeNodeLink:t=>te(t),applyNodeNote:(t,n)=>ae(t,n),removeNodeNote:t=>C(t),undo:()=>Ke(),redo:()=>Ue(),canUndo:()=>le.canUndo(),canRedo:()=>le.canRedo(),applySettings:t=>{t.autoBalanceOnChange!==void 0&&(E.autoBalanceOnChange=t.autoBalanceOnChange),t.lineWidthStart!==void 0&&(E.lineWidthStart=Math.max(.5,Math.min(20,t.lineWidthStart))),t.lineWidthEnd!==void 0&&(E.lineWidthEnd=Math.max(.3,Math.min(10,t.lineWidthEnd))),t.rainbowBranch!==void 0&&(E.rainbowBranch=t.rainbowBranch),t.branchPaletteId!==void 0&&(E.branchPaletteId=t.branchPaletteId),t.customPalettes!==void 0&&(E.customPalettes=t.customPalettes),t.lineStyle!==void 0&&(E.lineStyle=t.lineStyle),t.taperedEdge!==void 0&&(E.taperedEdge=t.taperedEdge),t.showOrderBadge!==void 0&&(E.showOrderBadge=t.showOrderBadge)},getSettings:()=>({autoBalanceOnChange:E.autoBalanceOnChange,lineWidthStart:E.lineWidthStart,lineWidthEnd:E.lineWidthEnd,rainbowBranch:E.rainbowBranch,branchPaletteId:E.branchPaletteId,customPalettes:E.customPalettes,lineStyle:E.lineStyle,layoutMode:E.layoutMode,taperedEdge:E.taperedEdge,showOrderBadge:E.showOrderBadge}),setBranchPalette:t=>{if(!t)return;[...ke,...E.customPalettes].find(c=>c.id===t)&&(E.branchPaletteId=t)},getBranchPalette:()=>E.branchPaletteId,getBranchPalettes:()=>[...ke,...E.customPalettes]}),e.watch(()=>o.data,t=>{d.value=ne(t),T()},{deep:!1}),e.onMounted(()=>{O(),e.nextTick(()=>oe())}),(t,n)=>{var c,y,h;return e.openBlock(),e.createElementBlock("div",{class:"zm-mindmap",style:e.normalizeStyle({background:ee.value.bgColor,fontSize:ee.value.fontSize+"px"})},[e.createElementVNode("div",{ref_key:"wrapperRef",ref:u,class:"zm-canvas",onMousedown:go,onContextmenu:n[13]||(n[13]=e.withModifiers(()=>{},["prevent"])),onWheel:n[14]||(n[14]=(...r)=>e.unref(M).onWheel&&e.unref(M).onWheel(...r)),onClick:yo},[e.createElementVNode("div",{class:"zm-svg-layer",style:e.normalizeStyle({left:j.value.vbX*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:j.value.vbY*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:j.value.vbW*e.unref(M).scale.value+"px",height:j.value.vbH*e.unref(M).scale.value+"px"})},[(e.openBlock(),e.createElementBlock("svg",{class:"zm-svg",viewBox:ao.value,preserveAspectRatio:"xMinYMin meet",width:j.value.vbW*e.unref(M).scale.value,height:j.value.vbH*e.unref(M).scale.value},[e.createElementVNode("g",vn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ro.value,r=>(e.openBlock(),e.createElementBlock("path",{key:r.key,d:Qn(Bt(r.from,"out",r.to.side,r.to),Bt(r.to,"in"),ft(r.from.depth),mt(r.to.depth),32,E.lineStyle,r.to._dir),fill:eo(r.from,r.to),stroke:"none"},null,8,Cn))),128))])],8,Bn))],4),e.unref(M).isMarquee.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zm-marquee",style:e.normalizeStyle({left:e.unref(M).marquee.x*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:e.unref(M).marquee.y*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:e.unref(M).marquee.width*e.unref(M).scale.value+"px",height:e.unref(M).marquee.height*e.unref(M).scale.value+"px"})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"zm-world",style:e.normalizeStyle({transform:`translate(${e.unref(M).offsetX.value}px, ${e.unref(M).offsetY.value}px) scale(${e.unref(M).scale.value})`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(qe.value,r=>(e.openBlock(),e.createElementBlock("div",{key:r.id,class:e.normalizeClass(["zm-node",{"is-root":r.isRoot,"is-selected":m.value===r.id,"is-editing":f.value===r.id,"has-image":!!r.image,"is-resizing":Un.value===r.id}]),"data-node-id":r.id,style:e.normalizeStyle({left:r.x+"px",top:r.y+"px",minWidth:r.width+"px",height:r.height+"px",fontSize:r.fontSize+"px",background:to(r),color:no(r),borderColor:oo(r),fontWeight:io(r),transform:"translate(-50%, -50%)"}),onClick:x=>ho(x,r),onDblclick:x=>{x.stopPropagation(),i.readonly||Ne(r.id)},onContextmenu:x=>K(x,r),onMouseenter:x=>jn(r.id),onMouseleave:x=>Gn(r.id)},[r.image?(e.openBlock(),e.createElementBlock("img",{key:0,class:"zm-node-img",src:r.image.src,width:r.image.width,height:r.image.height,alt:r.text,draggable:"false"},null,8,Vn)):e.createCommentVNode("",!0),f.value!==r.id?(e.openBlock(),e.createElementBlock("span",zn,[e.createElementVNode("span",In,e.toDisplayString(r.text),1),r.link&&!f.value?(e.openBlock(),e.createElementBlock("a",{key:0,class:"zm-node-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开链接:${r.link.url}`,onClick:n[0]||(n[0]=e.withModifiers(()=>{},["stop"])),onMousedown:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(H,{name:"link",size:11,stroke:2})],40,Wn)):e.createCommentVNode("",!0),r.note&&!f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-note-btn",type:"button",title:Kn(r.note.text),onClick:e.withModifiers(x=>at(r.id),["stop"]),onMousedown:n[2]||(n[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(H,{name:"note",size:11,stroke:2})],40,$n)):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,class:"zm-input","onUpdate:modelValue":n[3]||(n[3]=x=>k.value=x),autofocus:"",onBlur:n[4]||(n[4]=x=>We()),onKeydown:[n[5]||(n[5]=e.withKeys(e.withModifiers(x=>We({addSibling:"after"}),["exact"]),["enter"])),n[6]||(n[6]=e.withKeys(e.withModifiers(x=>We({addSibling:"before"}),["shift","prevent","exact"]),["enter"])),n[7]||(n[7]=e.withKeys(e.withModifiers(x=>We({addChild:!0}),["prevent"]),["tab"])),e.withKeys(co,["esc"]),so],onMousedown:n[8]||(n[8]=e.withModifiers(()=>{},["stop"])),onClick:n[9]||(n[9]=e.withModifiers(()=>{},["stop"]))},null,544)),[[e.vModelText,k.value]]),w.value?(e.openBlock(),e.createElementBlock("span",{key:3,class:"zm-order-badge",title:`数据顺序:第 ${Mt(r.id)+1} 个`},e.toDisplayString(Mt(r.id)+1),9,Rn)):e.createCommentVNode("",!0),Nt(r.id)&&!r.isRoot&&Ye(r.id)>0?(e.openBlock(),e.createElementBlock("span",{key:4,class:e.normalizeClass(["zm-collapse-badge",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({background:ce.value.get(r.id)??"#64748b"}),title:`展开 ${Ye(r.id)} 个子节点`,onMousedown:n[10]||(n[10]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},e.toDisplayString(Ye(r.id)),47,Tn)):e.createCommentVNode("",!0),!i.readonly&&!r.isRoot&&xo(r)&&!Nt(r.id)?(e.openBlock(),e.createElementBlock("button",{key:5,class:e.normalizeClass(["zm-btn zm-collapse",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({color:ce.value.get(r.id)??"#64748b",borderColor:ce.value.get(r.id)??"#64748b"}),title:"折叠",onMousedown:n[11]||(n[11]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},[e.createVNode(H,{name:"minus",size:10,stroke:2.4})],46,Ln)):e.createCommentVNode("",!0),r.image&&m.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("span",{key:6,class:"zm-img-resize-handle",title:"拖动调整图片大小",onMousedown:e.withModifiers(x=>Yn(x,r),["stop"])},null,40,An)):e.createCommentVNode("",!0),r.image&&m.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("button",{key:7,class:"zm-img-remove-btn",title:"移除图片",onMousedown:n[12]||(n[12]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>B(r.id),["stop"])},[e.createVNode(H,{name:"x",size:9,stroke:2.2})],40,Hn)):e.createCommentVNode("",!0)],46,Sn))),128))],4),V.value?(e.openBlock(),e.createBlock(Mn,{key:1,x:V.value.x,y:V.value.y,container:u.value,"has-image":!!((c=e.unref(z)(d.value,V.value.nodeId))!=null&&c.image),"has-link":!!((y=e.unref(z)(d.value,V.value.nodeId))!=null&&y.link),"has-note":!!((h=e.unref(z)(d.value,V.value.nodeId))!=null&&h.note),readonly:o.readonly,onPickImage:Q,onRemoveImage:qn,onSetLink:_,onRemoveLink:me,onEditNote:be,onRemoveNote:he,onClose:Y},null,8,["x","y","container","has-image","has-link","has-note","readonly"])):e.createCommentVNode("",!0)],544),o.previewMode?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Dn,[e.createElementVNode("button",{class:"zm-tb-btn",title:"放大",onClick:n[15]||(n[15]=(...r)=>e.unref(M).zoomIn&&e.unref(M).zoomIn(...r))},[e.createVNode(H,{name:"zoom-in"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"缩小",onClick:n[16]||(n[16]=(...r)=>e.unref(M).zoomOut&&e.unref(M).zoomOut(...r))},[e.createVNode(H,{name:"zoom-out"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"重置视图",onClick:oe},[e.createVNode(H,{name:"reset"})]),n[22]||(n[22]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-tb-btn",title:"添加子节点 (Tab)",onClick:n[17]||(n[17]=r=>m.value&&ge(m.value))},[e.createElementVNode("img",{src:e.unref(Ht),width:"14",height:"14",alt:"添加子节点",draggable:"false"},null,8,Pn)])),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-tb-btn",title:"添加同级 (Enter)",onClick:n[18]||(n[18]=r=>m.value&&$e(m.value))},[e.createElementVNode("img",{src:e.unref(At),width:"14",height:"14",alt:"添加同级",draggable:"false"},null,8,Fn)])),n[23]||(n[23]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="mindmap"}]),title:"思维导图布局 (中心辐射)",onClick:n[19]||(n[19]=r=>je("mindmap"))},[e.createVNode(H,{name:"mindmap"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="tree"}]),title:"树形布局 (向右展开)",onClick:n[20]||(n[20]=r=>je("tree"))},[e.createVNode(H,{name:"tree"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="org"}]),title:"组织结构布局 (向下展开)",onClick:n[21]||(n[21]=r=>je("org"))},[e.createVNode(H,{name:"org"})],2),n[24]||(n[24]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),i.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-tb-btn",title:"导入 JSON",onClick:wo},[e.createVNode(H,{name:"import"})])),e.createElementVNode("button",{class:"zm-tb-btn",title:"导出 JSON",onClick:bo},[e.createVNode(H,{name:"export"})]),e.createElementVNode("span",On,e.toDisplayString(Math.round(e.unref(M).scale.value*100))+"%",1)]))],4)}}}),Xn={install(i){i.component("FlowMindMap",rt)}};L.MindMap=rt,L.addChild=nt,L.addSibling=ot,L.clone=ne,L.default=Xn,L.findNode=z,L.findParent=Z,L.markdownToMindMap=Pe,L.markdownToRichMindMap=fn,L.mindMapToMarkdown=ze,L.removeNode=De,L.richBlockToMarkdown=mn,L.uid=J,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|