mind-elixir
Version:
Mind elixir is a free open source mind map core.
15 lines • 90.7 kB
JavaScript
var MindElixir=(function(F){"use strict";const ne={name:"Latte",type:"light",palette:["#dd7878","#ea76cb","#8839ef","#e64553","#fe640b","#df8e1d","#40a02b","#209fb5","#1e66f5","#7287fd"],cssVar:{"--node-gap-x":"30px","--node-gap-y":"10px","--main-gap-x":"65px","--main-gap-y":"45px","--root-radius":"30px","--main-radius":"20px","--root-color":"#ffffff","--root-bgcolor":"#4c4f69","--root-border-color":"rgba(0, 0, 0, 0)","--main-color":"#444446","--main-bgcolor":"#ffffff","--main-bgcolor-transparent":"rgba(255, 255, 255, 0.8)","--topic-padding":"3px","--color":"#777777","--bgcolor":"#f6f6f6","--selected":"#4dc4ff","--accent-color":"#e64553","--panel-color":"#444446","--panel-bgcolor":"#ffffff","--panel-border-color":"#eaeaea","--map-padding":"50px 80px"}},oe={name:"Dark",type:"dark",palette:["#848FA0","#748BE9","#D2F9FE","#4145A5","#789AFA","#706CF4","#EF987F","#775DD5","#FCEECF","#DA7FBC"],cssVar:{"--node-gap-x":"30px","--node-gap-y":"10px","--main-gap-x":"65px","--main-gap-y":"45px","--root-radius":"30px","--main-radius":"20px","--root-color":"#ffffff","--root-bgcolor":"#2d3748","--root-border-color":"rgba(255, 255, 255, 0.1)","--main-color":"#ffffff","--main-bgcolor":"#4c4f69","--main-bgcolor-transparent":"rgba(76, 79, 105, 0.8)","--topic-padding":"3px","--color":"#cccccc","--bgcolor":"#252526","--selected":"#4dc4ff","--accent-color":"#789AFA","--panel-color":"#ffffff","--panel-bgcolor":"#2d3748","--panel-border-color":"#696969","--map-padding":"50px 80px"}};function ye(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""")}const se=function(e,t){if(t.id===e)return t;if(t.children&&t.children.length){for(let n=0;n<t.children.length;n++){const o=se(e,t.children[n]);if(o)return o}return null}else return null},X=(e,t)=>{if(e.parent=t,e.children)for(let n=0;n<e.children.length;n++)X(e.children[n],e)},q=(e,t,n)=>{if(e.expanded=t,e.children)if(n===void 0||n>0){const o=n!==void 0?n-1:void 0;e.children.forEach(s=>{q(s,t,o)})}else e.children.forEach(o=>{q(o,!1)})};function ve(e){if(e.id=z(),e.children)for(let t=0;t<e.children.length;t++)ve(e.children[t])}function ie(e,t,n,o){const s=n-e,i=o-t,c=Math.atan2(i,s)*180/Math.PI,r=12,a=30,d=(c+180-a)*Math.PI/180,h=(c+180+a)*Math.PI/180;return{x1:n+Math.cos(d)*r,y1:o+Math.sin(d)*r,x2:n+Math.cos(h)*r,y2:o+Math.sin(h)*r}}function z(){return(new Date().getTime().toString(16)+Math.random().toString(16).substring(2)).substring(2,18)}const mt=function(){const e=z();return{topic:this.newTopicName,id:e}};function be(e){return JSON.parse(JSON.stringify(e,(n,o)=>{if(n!=="parent")return o}))}const $=(e,t)=>{let n=0,o=0;for(;t&&t!==e;)n+=t.offsetLeft,o+=t.offsetTop,t=t.offsetParent;return{offsetLeft:n,offsetTop:o}},A=(e,t)=>{for(const n in t)e.setAttribute(n,t[n])},re=e=>e?e.tagName==="ME-TPC":!1,we=e=>e.filter(t=>t.nodeObj.parent).filter((t,n,o)=>{for(let s=0;s<o.length;s++){if(t===o[s])continue;const{parent:i}=t.nodeObj;if(i===o[s].nodeObj)return!1}return!0}),xe=e=>{const t=/translate3d\(([^,]+),\s*([^,]+)/,n=e.match(t);return n?{x:parseFloat(n[1]),y:parseFloat(n[2])}:{x:0,y:0}},Oe=function(e){for(let t=0;t<e.length;t++){const{dom:n,evt:o,func:s}=e[t];n.addEventListener(o,s)}return function(){for(let n=0;n<e.length;n++){const{dom:o,evt:s,func:i}=e[n];o.removeEventListener(s,i)}}},$e=(e,t)=>{const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)},R={LHS:"lhs",RHS:"rhs"},yt=function(){this.nodes.innerHTML="";const e=this.createTopic(this.nodeData);Ce.call(this,e,this.nodeData),e.draggable=!1;const t=document.createElement("me-root");t.appendChild(e);const n=this.nodeData.children||[];if(this.direction===2){let o=0,s=0;n.map(i=>{i.direction===0?o+=1:i.direction===1?s+=1:o<=s?(i.direction=0,o+=1):(i.direction=1,s+=1)})}vt(this,n,t)},vt=function(e,t,n){const o=document.createElement("me-main");o.className=R.LHS;const s=document.createElement("me-main");s.className=R.RHS;for(let i=0;i<t.length;i++){const l=t[i],{grp:c}=e.createWrapper(l);e.direction===2?l.direction===0?o.appendChild(c):s.appendChild(c):e.direction===0?o.appendChild(c):s.appendChild(c)}e.nodes.appendChild(o),e.nodes.appendChild(n),e.nodes.appendChild(s),e.nodes.appendChild(e.lines),e.nodes.appendChild(e.labelContainer)},bt=function(e,t){const n=document.createElement("me-children");for(let o=0;o<t.length;o++){const s=t[o],{grp:i}=e.createWrapper(s);n.appendChild(i)}return n},je=function(e,t){const o=(this?.el?this.el:t||document).querySelector(`[data-nodeid="me${e}"]`);if(!o)throw new Error(`FindEle: Node ${e} not found, maybe it's collapsed.`);return o},Ce=function(e,t){if(e.innerHTML="",t.style){const n=t.style;for(const o in n)e.style[o]=n[o]}if(t.dangerouslySetInnerHTML){e.innerHTML=t.dangerouslySetInnerHTML;return}if(t.image){const n=t.image;if(n.url&&n.width&&n.height){const o=document.createElement("img");o.src=this.imageProxy?this.imageProxy(n.url):n.url,o.style.width=n.width+"px",o.style.height=n.height+"px",n.fit&&(o.style.objectFit=n.fit),e.appendChild(o),e.image=o}}else e.image&&(e.image=void 0);{const n=document.createElement("span");n.className="text",this.markdown?n.innerHTML=this.markdown(t.topic,t):n.textContent=t.topic,e.appendChild(n),e.text=n}if(t.hyperLink){const n=document.createElement("a");n.className="hyper-link",n.target="_blank",n.innerText="🔗",n.href=t.hyperLink,e.appendChild(n),e.link=n}else e.link&&(e.link=void 0);if(t.icons&&t.icons.length){const n=document.createElement("span");n.className="icons",n.innerHTML=t.icons.map(o=>`<span>${ye(o)}</span>`).join(""),e.appendChild(n),e.icons=n}else e.icons&&(e.icons=void 0);if(t.tags&&t.tags.length){const n=document.createElement("div");n.className="tags",t.tags.forEach(o=>{const s=document.createElement("span");typeof o=="string"?s.textContent=o:(s.textContent=o.text,o.className&&(s.className=o.className),o.style&&Object.assign(s.style,o.style)),n.appendChild(s)}),e.appendChild(n),e.tags=n}else e.tags&&(e.tags=void 0)},wt=function(e,t){const n=document.createElement("me-wrapper"),{p:o,tpc:s}=this.createParent(e);if(n.appendChild(o),!t&&e.children&&e.children.length>0){const i=Ee(e.expanded);if(o.appendChild(i),e.expanded!==!1){const l=bt(this,e.children);n.appendChild(l)}}return{grp:n,top:o,tpc:s}},xt=function(e){const t=document.createElement("me-parent"),n=this.createTopic(e);return Ce.call(this,n,e),t.appendChild(n),{p:t,tpc:n}},Ct=function(e){const t=document.createElement("me-children");return t.append(...e),t},Et=function(e){const t=document.createElement("me-tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t};function He(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const St=function(e){if(!e)return;const t=document.createElement("div"),n=e.nodeObj,o=n.topic,{offsetLeft:s,offsetTop:i}=$(this.nodes,e);this.nodes.appendChild(t),t.id="input-box",t.textContent=o,t.contentEditable="plaintext-only",t.spellcheck=!1;const l=getComputedStyle(e);t.style.cssText=`
left: ${s}px;
top: ${i}px;
min-width:${e.offsetWidth-8}px;
color:${l.color};
font-size:${l.fontSize};
padding:${l.padding};
margin:${l.margin};
background-color:${l.backgroundColor!=="rgba(0, 0, 0, 0)"&&l.backgroundColor};
border: ${l.border};
border-radius:${l.borderRadius}; `,this.direction===0&&(t.style.right="0"),He(t),this.bus.fire("operation",{name:"beginEdit",obj:e.nodeObj}),t.addEventListener("keydown",c=>{c.stopPropagation();const r=c.key;if(r==="Enter"||r==="Tab"){if(c.shiftKey)return;c.preventDefault(),t.blur(),this.container.focus()}else r==="Escape"&&(c.preventDefault(),t.textContent=o,t.blur(),this.container.focus())}),t.addEventListener("blur",()=>{if(!t)return;t.remove();const c=t.innerText?.trim()||"";c===o||c===""||(n.topic=c,this.markdown?e.text.innerHTML=this.markdown(n.topic,n):e.text.textContent=c,this.linkDiv(),this.bus.fire("operation",{name:"finishEdit",obj:n,origin:o}))})},Ee=function(e){const t=document.createElement("me-epd");return t.expanded=e!==!1,t.className=e!==!1?"minus":"",t},U=e=>{const t=e.parent?.children,n=t?.indexOf(e)??0;return{siblings:t,index:n}};function Nt(e){const{siblings:t,index:n}=U(e);if(t===void 0)return;const o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Tt(e){const{siblings:t,index:n}=U(e);if(t===void 0)return;const o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function Ie(e){const{siblings:t,index:n}=U(e);return t===void 0?0:(t.splice(n,1),t.length)}function kt(e,t,n){const{siblings:o,index:s}=U(n);o!==void 0&&(t==="before"?o.splice(s,0,e):o.splice(s+1,0,e))}function _t(e,t){const{siblings:n,index:o}=U(e);n!==void 0&&(n[o]=t,t.children=[e])}function Lt(e,t,n){if(Ie(t),n.parent?.parent||(t.direction=n.direction),e==="in")n.children?n.children.push(t):n.children=[t];else{t.direction!==void 0&&(t.direction=n.direction);const{siblings:o,index:s}=U(n);if(o===void 0)return;e==="before"?o.splice(s,0,t):o.splice(s+1,0,t)}}const At=function({map:e,direction:t},n){if(t===0)return 0;if(t===1)return 1;if(t===2){const o=e.querySelector(".lhs")?.childElementCount||0,s=e.querySelector(".rhs")?.childElementCount||0;return o<=s?(n.direction=0,0):(n.direction=1,1)}},Re=function(e,t,n){const o=n.children[0].children[0],s=t.parentElement;if(s.tagName==="ME-PARENT"){if(Q(o),s.children[1])s.nextSibling.appendChild(n);else{const i=e.createChildren([n]);s.appendChild(Ee(!0)),s.insertAdjacentElement("afterend",i)}e.linkDiv(n.offsetParent)}else s.tagName==="ME-ROOT"&&(At(e,o.nodeObj)===0?e.container.querySelector(".lhs")?.appendChild(n):e.container.querySelector(".rhs")?.appendChild(n),e.linkDiv())},Dt=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&(o.previousSibling.children[1].remove(),o.remove())}n.parentNode.remove()},Be={before:"beforebegin",after:"afterend"},Q=function(e){const n=e.parentElement.parentElement.lastElementChild;n?.tagName==="svg"&&n?.remove()},Mt=function(e,t){const n=e.nodeObj,o=be(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const s=Object.assign(n,t);Ce.call(this,e,s),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:s,origin:o})},Se=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=e.findEle(o.id));const s=n||e.generateNewObj();o.children?o.children.push(s):o.children=[s],X(e.nodeData);const{grp:i,top:l}=e.createWrapper(s);return Re(e,t,i),{newTop:l,newNodeObj:s}},Pt=function(e,t,n){const o=t||this.currentNode;if(!o)return;const s=o.nodeObj;if(s.parent){if(!s.parent?.parent&&this.direction===2){const a=this.map.querySelector(".lhs")?.childElementCount||0,d=this.map.querySelector(".rhs")?.childElementCount||0;if(!a||!d){this.addChild(this.findEle(s.parent.id),n);return}}}else{this.addChild();return}const i=n||this.generateNewObj();if(!s.parent?.parent){const a=o.closest("me-main").className===R.LHS?0:1;i.direction=a}kt(i,e,s),X(this.nodeData);const l=o.parentElement,{grp:c,top:r}=this.createWrapper(i);l.parentElement.insertAdjacentElement(Be[e],c),this.linkDiv(c.offsetParent),n||this.editTopic(r.firstChild),this.bus.fire("operation",{name:"insertSibling",type:e,obj:i}),this.selectNode(r.firstChild,!0)},Ot=function(e,t){const n=e||this.currentNode;if(!n)return;Q(n);const o=n.nodeObj;if(!o.parent)return;const s=t||this.generateNewObj();_t(o,s),X(this.nodeData);const i=n.parentElement.parentElement,{grp:l,top:c}=this.createWrapper(s,!0);c.appendChild(Ee(!0)),i.insertAdjacentElement("afterend",l);const r=this.createChildren([i]);c.insertAdjacentElement("afterend",r),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:s})},$t=function(e,t){const n=e||this.currentNode;if(!n)return;const o=Se(this,n,t);if(!o)return;const{newTop:s,newNodeObj:i}=o;this.bus.fire("operation",{name:"addChild",obj:i}),t||this.editTopic(s.firstChild),this.selectNode(s.firstChild,!0)},jt=function(e,t){const n=be(e.nodeObj);ve(n);const o=Se(this,t,n);if(!o)return;const{newNodeObj:s}=o;this.selectNode(this.findEle(s.id)),this.bus.fire("operation",{name:"copyNode",obj:s})},Ht=function(e,t){const n=[];for(let o=0;o<e.length;o++){const s=e[o],i=be(s.nodeObj);ve(i);const l=Se(this,t,i);if(!l)return;const{newNodeObj:c}=l;n.push(c)}this.unselectNodes(this.currentNodes),this.selectNodes(n.map(o=>this.findEle(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},It=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Nt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},Rt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Tt(n);const o=t.parentNode.parentNode;o.nextSibling?o.nextSibling.insertAdjacentElement("afterend",o):o.parentNode.prepend(o),this.linkDiv(),this.bus.fire("operation",{name:"moveDownNode",obj:n})},Bt=function(e){if(e=we(e),e.length===0)return;for(const n of e){const o=n.nodeObj,s=Ie(o);Dt(n,s)}const t=e[e.length-1];this.selectNode(this.findEle(t.nodeObj.parent.id)),this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(n=>n.nodeObj)})},Ne=(e,t,n,o)=>{e=we(e);let s=n.nodeObj;t==="in"&&s.expanded===!1&&(o.expandNode(n,!0),n=o.findEle(s.id),s=n.nodeObj),t==="after"&&(e=e.reverse());const i=[];for(const c of e){const r=c.nodeObj;if(Lt(t,r,s),X(o.nodeData),t==="in"){const a=c.parentElement;Re(o,n,a.parentElement)}else{Q(c);const a=c.parentElement.parentNode;i.includes(a.parentElement)||i.push(a.parentElement),n.parentElement.parentNode.insertAdjacentElement(Be[t],a)}}for(const c of i)c.childElementCount===0&&c.tagName!=="ME-MAIN"&&(c.previousSibling.children[1].remove(),c.remove());o.linkDiv(),o.scrollIntoView(e[e.length-1]);const l=t==="before"?"moveNodeBefore":t==="after"?"moveNodeAfter":"moveNodeIn";o.bus.fire("operation",{name:l,objs:e.map(c=>c.nodeObj),toObj:s})},Fe=Object.freeze(Object.defineProperty({__proto__:null,addChild:$t,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:jt,copyNodes:Ht,insertParent:Ot,insertSibling:Pt,moveDownNode:Rt,moveNodeAfter:function(e,t){Ne(e,"after",t,this)},moveNodeBefore:function(e,t){Ne(e,"before",t,this)},moveNodeIn:function(e,t){Ne(e,"in",t,this)},moveUpNode:It,removeNodes:Bt,reshapeNode:Mt,rmSubline:Q,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function Ft(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const Yt=function(e){const t=this.container,n=e.getBoundingClientRect(),o=t.getBoundingClientRect();if(n.top>o.bottom-50||n.bottom<o.top+50||n.left>o.right-50||n.right<o.left+50){const i=n.left+n.width/2,l=n.top+n.height/2,c=o.left+o.width/2,r=o.top+o.height/2,a=i-c,d=l-r;this.move(-a,-d,!0)}},Wt=function(e,t,n){this.clearSelection(),this.scrollIntoView(e),this.selection?.select(e),t&&this.bus.fire("selectNewNode",e.nodeObj)},Xt=function(e){this.selection?.select(e)},zt=function(e){this.selection?.deselect(e)},Gt=function(){this.unselectNodes(this.currentNodes),this.unselectSummary(),this.unselectArrow()},Te=function(e){return JSON.stringify(e,(t,n)=>{if(!(t==="parent"&&typeof n!="string"))return n})},Vt=function(){const e=Ft(this);return Te(e)},Kt=function(){return JSON.parse(this.getDataString())},qt=function(){this.editable=!0},Ut=function(){this.editable=!1},Jt=function(e,t={x:0,y:0}){if(e<this.scaleMin&&e<this.scaleVal||e>this.scaleMax&&e>this.scaleVal)return;const n=this.container.getBoundingClientRect(),o=t.x?t.x-n.left-n.width/2:0,s=t.y?t.y-n.top-n.height/2:0,{dx:i,dy:l}=ke(this),c=this.map.style.transform,{x:r,y:a}=xe(c),d=r-i,h=a-l,u=this.scaleVal,y=(-o+d)*(1-e/u),v=(-s+h)*(1-e/u);this.map.style.transform=`translate3d(${r-y}px, ${a-v}px, 0) scale(${e})`,this.scaleVal=e,this.bus.fire("scale",e)},Zt=function(){const e=this.nodes.offsetHeight/this.container.offsetHeight,t=this.nodes.offsetWidth/this.container.offsetWidth,n=1/Math.max(1,Math.max(e,t));this.scaleVal=n;const{dx:o,dy:s}=ke(this,!0);this.map.style.transform=`translate3d(${o}px, ${s}px, 0) scale(${n})`,this.bus.fire("scale",n)},Qt=function(e,t,n=!1){const{map:o,scaleVal:s,bus:i,container:l,nodes:c}=this;if(n&&o.style.transition==="transform 0.3s")return;const r=o.style.transform;let{x:a,y:d}=xe(r);const h=l.getBoundingClientRect(),u=c.getBoundingClientRect(),y=u.left<h.right&&u.right>h.left,v=u.top<h.bottom&&u.bottom>h.top;if(y){const p=u.left+e,g=u.right+e;(p>=h.right||g<=h.left)&&(e=0)}if(v){const p=u.top+t,g=u.bottom+t;(p>=h.bottom||g<=h.top)&&(t=0)}a+=e,d+=t,n&&(o.style.transition="transform 0.3s",setTimeout(()=>{o.style.transition="none"},300)),o.style.transform=`translate3d(${a}px, ${d}px, 0) scale(${s})`,i.fire("move",{dx:e,dy:t})},ke=(e,t=!1)=>{const{container:n,map:o,nodes:s}=e;let i,l;if(e.alignment==="nodes"||t)i=(n.offsetWidth-s.offsetWidth)/2,l=(n.offsetHeight-s.offsetHeight)/2,o.style.transformOrigin="50% 50%";else{const c=o.querySelector("me-root"),r=c.offsetTop,a=c.offsetLeft,d=c.offsetWidth,h=c.offsetHeight;i=n.offsetWidth/2-a-d/2,l=n.offsetHeight/2-r-h/2,o.style.transformOrigin=`${a+d/2}px 50%`}return{dx:i,dy:l}},en=Object.freeze(Object.defineProperty({__proto__:null,cancelFocus:function(){this.isFocusMode=!1,this.tempDirection!==null&&(this.nodeData=this.nodeDataBackup,this.direction=this.tempDirection,this.tempDirection=null,this.refresh(),this.toCenter())},clearSelection:Gt,disableEdit:Ut,enableEdit:qt,expandNode:function(e,t){const n=e.nodeObj;typeof t=="boolean"?n.expanded=t:n.expanded!==!1?n.expanded=!1:n.expanded=!0;const o=e.getBoundingClientRect(),s={x:o.left,y:o.top},i=e.parentNode,l=i.children[1];if(l.expanded=n.expanded,l.className=n.expanded?"minus":"",Q(e),n.expanded){const h=this.createChildren(n.children.map(u=>this.createWrapper(u).grp));i.parentNode.appendChild(h)}else i.parentNode.children[1].remove();this.linkDiv(e.closest("me-main > me-wrapper"));const c=e.getBoundingClientRect(),r={x:c.left,y:c.top},a=s.x-r.x,d=s.y-r.y;this.move(a,d),this.bus.fire("expandNode",n)},expandNodeAll:function(e,t){const n=e.nodeObj,o=e.getBoundingClientRect(),s={x:o.left,y:o.top};q(n,t??!n.expanded),this.refresh();const i=this.findEle(n.id).getBoundingClientRect(),l={x:i.left,y:i.top},c=s.x-l.x,r=s.y-l.y;this.move(c,r)},focusNode:function(e){e.nodeObj.parent&&(this.clearSelection(),this.tempDirection===null&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.initRight(),this.toCenter())},getData:Kt,getDataString:Vt,initLeft:function(){this.direction=0,this.refresh(),this.toCenter(),this.bus.fire("changeDirection",this.direction)},initRight:function(){this.direction=1,this.refresh(),this.toCenter(),this.bus.fire("changeDirection",this.direction)},initSide:function(){this.direction=2,this.refresh(),this.toCenter(),this.bus.fire("changeDirection",this.direction)},install:function(e){e(this)},move:Qt,refresh:function(e){this.clearSelection(),e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.arrows=e.arrows||[],this.summaries=e.summaries||[],e.theme&&this.changeTheme(e.theme)),X(this.nodeData),this.layout(),this.linkDiv()},scale:Jt,scaleFit:Zt,scrollIntoView:Yt,selectNode:Wt,selectNodes:Xt,setLocale:function(e){this.locale=e,this.refresh()},stringifyData:Te,toCenter:function(){const{map:e,container:t}=this,{dx:n,dy:o}=ke(this);t.scrollTop=0,t.scrollLeft=0,e.style.transform=`translate3d(${n}px, ${o}px, 0) scale(${this.scaleVal})`},unselectNodes:zt},Symbol.toStringTag,{value:"Module"})),Ye="MIND-ELIXIR-WAIT-COPY",tn=(e,t)=>{const n=e.map.querySelectorAll(`.${t}>me-wrapper>me-parent>me-tpc`);n.length!==0&&e.selectNode(n[Math.ceil(n.length/2)-1])},nn=e=>{e.selectNode(e.map.querySelector("me-root>me-tpc"))},on=function(e,t){const n=t.parentElement.parentElement.parentElement.previousSibling;if(n){const o=n.firstChild;e.selectNode(o)}},sn=function(e,t){const n=t.parentElement.nextSibling;if(n&&n.firstChild){const o=n.firstChild.firstChild.firstChild;e.selectNode(o)}},We=function(e,t){const n=e.currentNode||e.currentNodes?.[0];if(!n)return;const o=n.nodeObj,s=n.offsetParent.offsetParent.parentElement;o.parent?s.className===t?sn(e,n):o.parent?.parent?on(e,n):nn(e):tn(e,t)},Xe=function(e,t){const n=e.currentNode;if(!n||!n.nodeObj.parent)return;const s=t+"Sibling",i=n.parentElement.parentElement[s];i?e.selectNode(i.firstChild.firstChild):e.selectNode(n)},le=function(e,t,n){const{scaleVal:o,scaleSensitivity:s}=e;switch(t){case"in":e.scale(o+s,n);break;case"out":e.scale(o-s,n)}};function rn(e,t){t=t===!0?{}:t;const n=()=>{e.currentArrow?e.removeArrow():e.currentSummary?e.removeSummary(e.currentSummary.summaryObj.id):e.currentNodes&&e.removeNodes(e.currentNodes)};let o=!1,s=null;const i=r=>{const a=e.nodeData;if(r.key==="0")for(const d of a.children)q(d,!1);if(r.key==="=")for(const d of a.children)q(d,!0);if(["1","2","3","4","5","6","7","8","9"].includes(r.key))for(const d of a.children)q(d,!0,Number(r.key)-1);e.refresh(),e.toCenter(),o=!1,s&&(clearTimeout(s),s=null,e.container.removeEventListener("keydown",i))},l={Enter:r=>{r.shiftKey?e.insertSibling("before"):r.ctrlKey||r.metaKey?e.insertParent():e.insertSibling("after")},Tab:()=>{e.addChild()},F1:()=>{e.toCenter()},F2:()=>{e.currentSummary?e.editSummary(e.currentSummary):e.currentArrow?e.editArrowLabel(e.currentArrow):e.beginEdit()},ArrowUp:r=>{if(r.altKey)e.moveUpNode();else{if(r.metaKey||r.ctrlKey)return e.initSide();Xe(e,"previous")}},ArrowDown:r=>{r.altKey?e.moveDownNode():Xe(e,"next")},ArrowLeft:r=>{if(r.metaKey||r.ctrlKey)return e.initLeft();We(e,R.LHS)},ArrowRight:r=>{if(r.metaKey||r.ctrlKey)return e.initRight();We(e,R.RHS)},PageUp:()=>e.moveUpNode(),PageDown:()=>{e.moveDownNode()},"=":r=>{(r.metaKey||r.ctrlKey)&&le(e,"in")},"-":r=>{(r.metaKey||r.ctrlKey)&&le(e,"out")},0:r=>{if(r.metaKey||r.ctrlKey){if(o)return;e.scale(1)}},k:r=>{(r.metaKey||r.ctrlKey)&&(o=!0,s&&(clearTimeout(s),e.container.removeEventListener("keydown",i)),s=window.setTimeout(()=>{o=!1,s=null},2e3),e.container.addEventListener("keydown",i))},Delete:n,Backspace:n,...t};e.container.onkeydown=r=>{if((r.ctrlKey||r.metaKey)&&["c","v","x"].includes(r.key)||r.preventDefault(),!e.editable)return;const d=l[r.key];d&&d(r)};const c=r=>{if(r.target instanceof HTMLElement&&r.target.id==="input-box"||e.currentNodes.length===0)return!1;if(r.clipboardData){const a=we(e.currentNodes).map(h=>h.nodeObj),d=Te({magic:Ye,data:a});return r.clipboardData.setData("text/plain",d),r.preventDefault(),!0}return!1};e.container.addEventListener("copy",c),e.container.addEventListener("cut",r=>{c(r)&&n()}),e.container.addEventListener("paste",r=>{const a=r.clipboardData?.getData("text/plain");if(a)try{const d=JSON.parse(a);if(d&&d.magic===Ye&&Array.isArray(d.data)){const h=d.data,u=h.map(y=>({nodeObj:y}));h.length>0&&e.currentNode&&(e.copyNodes(u,e.currentNode),r.preventDefault());return}}catch{}e.pasteHandler&&e.pasteHandler(r)})}const ln=function(e,t){if(!t)return ce(e),e;let n=e.querySelector(".insert-preview");const o=`insert-preview ${t} show`;return n||(n=document.createElement("div"),e.appendChild(n)),n.className=o,e},ce=function(e){if(!e)return;const t=e.querySelectorAll(".insert-preview");for(const n of t||[])n.remove()},ze=function(e,t){for(const n of t){const o=n.parentElement.parentElement.contains(e);if(!(e&&e.tagName==="ME-TPC"&&e!==n&&!o&&e.nodeObj.parent))return!1}return!0},cn=function(e){const t=document.createElement("div");return t.className="mind-elixir-ghost",e.container.appendChild(t),t};class an{mind;isMoving=!1;interval=null;speed=20;constructor(t){this.mind=t}move(t,n){this.isMoving||(this.isMoving=!0,this.interval=setInterval(()=>{this.mind.move(t*this.speed*this.mind.scaleVal,n*this.speed*this.mind.scaleVal)},100))}stop(){this.isMoving=!1,this.interval&&(clearInterval(this.interval),this.interval=null)}}function dn(e){return{isDragging:!1,insertType:null,meet:null,ghost:cn(e),edgeMoveController:new an(e),startX:0,startY:0,pointerId:null}}const hn=5;function Ge(e,t,n,o=!1){if(e.spacePressed)return!1;const s=n.target;if(s?.tagName!=="ME-TPC"||!s.nodeObj.parent)return!1;t.startX=n.clientX,t.startY=n.clientY,t.pointerId=n.pointerId,e.selection?.cancel();let i=e.currentNodes;return i?.includes(s)||(e.selectNode(s),i=e.currentNodes),e.dragged=i,o&&Ke(e,t),!0}function Ve(e,t,n){e.style.transform=`translate(${t-10}px, ${n-10}px)`,e.style.display="block"}function Ke(e,t){const{dragged:n}=e;if(!n)return;const o=document.activeElement;o&&o.isContentEditable&&o.blur(),t.isDragging=!0,n.length>1?t.ghost.innerHTML=n.length+"":t.ghost.innerHTML=n[0].innerHTML;for(const s of n)s.parentElement.parentElement.style.opacity="0.5";e.dragMoveHelper.clear()}function fn(e,t,n){const{dragged:o}=e;if(!o||t.pointerId!==n.pointerId)return;const s=n.clientX-t.startX,i=n.clientY-t.startY,l=Math.sqrt(s*s+i*i);if(!t.isDragging&&l>hn&&Ke(e,t),!t.isDragging)return;const c=e.container.getBoundingClientRect();Ve(t.ghost,n.clientX-c.x,n.clientY-c.y),n.clientX<c.x+50?t.edgeMoveController.move(1,0):n.clientX>c.x+c.width-50?t.edgeMoveController.move(-1,0):n.clientY<c.y+50?t.edgeMoveController.move(0,1):n.clientY>c.y+c.height-50?t.edgeMoveController.move(0,-1):t.edgeMoveController.stop(),ce(t.meet);const r=12*e.scaleVal,a=document.elementFromPoint(n.clientX,n.clientY-r);if(ze(a,o)){t.meet=a;const d=a.getBoundingClientRect(),h=d.y;n.clientY>h+d.height?t.insertType="after":t.insertType="in"}else{const d=document.elementFromPoint(n.clientX,n.clientY+r);if(ze(d,o)){t.meet=d;const u=d.getBoundingClientRect().y;n.clientY<u?t.insertType="before":t.insertType="in"}else t.insertType=null,t.meet=null}t.meet&&ln(t.meet,t.insertType)}function un(e,t,n){const{dragged:o}=e;if(!(!o||t.pointerId!==n.pointerId)){t.edgeMoveController.stop();for(const s of o)s.parentElement.parentElement.style.opacity="1";t.ghost.style.display="none",t.ghost.innerHTML="",t.isDragging&&t.meet&&(ce(t.meet),t.insertType==="before"?e.moveNodeBefore(o,t.meet):t.insertType==="after"?e.moveNodeAfter(o,t.meet):t.insertType==="in"&&e.moveNodeIn(o,t.meet)),e.dragged=null,t.isDragging=!1,t.insertType=null,t.meet=null,t.pointerId=null}}function _e(e,t){const{dragged:n}=e;if(n){t.edgeMoveController.stop();for(const o of n)o.parentElement.parentElement.style.opacity="1";t.meet&&ce(t.meet),t.ghost.style.display="none",t.ghost.innerHTML="",e.dragged=null,t.isDragging=!1,t.insertType=null,t.meet=null,t.pointerId=null}}function pn(e){return()=>{}}function gn(e){const{dragMoveHelper:t}=e;let n=0;e.spacePressed=!1;let o=null;const s=new Map,i=dn(e);let l=null,c=null,r=null,a=null;const d=500,h=10,u=()=>{l!==null&&(clearTimeout(l),l=null,c=null,r=null,a=null)},y=(f,w)=>{f.hasPointerCapture&&f.hasPointerCapture(w)&&f.releasePointerCapture(w)},v=(f,w)=>{if(f.id==="input-box"||f.closest("#input-box"))return!1;const T=f.closest(".svg-label");if(T){const M=T.dataset.svgId,me=T.dataset.type,te=document.getElementById(M);if(te){if(me==="arrow")return w?e.editArrowLabel(te):e.selectArrow(te),!0;if(me==="summary")return w?e.editSummary(te):e.selectSummary(te),!0}}if(f.closest(".topiclinks")){const M=f.closest("g");if(M)return w?e.editArrowLabel(M):e.selectArrow(M),!0}if(f.closest(".summary")){const M=f.closest("g");if(M)return w?e.editSummary(M):e.selectSummary(M),!0}return!1},p=f=>{if(f.button!==0)return;if(e.helper1?.moved){e.helper1.clear();return}if(e.helper2?.moved){e.helper2.clear();return}if(t.moved){t.clear();return}if(i?.isDragging)return;const w=f.target;if(w.tagName==="ME-EPD")f.ctrlKey||f.metaKey?e.expandNodeAll(w.previousSibling):e.expandNode(w.previousSibling);else if(w.tagName==="ME-TPC"&&e.currentNodes.length>1)e.selectNode(w);else if(!e.editable)return;v(w,!1)},g=f=>{if(!e.editable)return;const w=f.target;re(w)&&e.beginEdit(w),v(w,!0)},m=f=>{if(f.pointerType==="mouse"||s.size>1)return;const w=new Date().getTime(),T=w-n;T<300&&T>0&&g(f),n=w},b=f=>{f.code==="Space"&&(e.spacePressed=!0,e.container.classList.add("space-pressed"))},x=f=>{f.code==="Space"&&(e.spacePressed=!1,e.container.classList.remove("space-pressed"))},L=f=>{if(f.pointerType==="touch"&&(s.set(f.pointerId,{x:f.clientX,y:f.clientY}),s.size===2)){const[M,me]=Array.from(s.values());o=$e(M,me),u()}t.moved=!1;const w=f.target,T=e.mouseSelectionButton===0?2:0;if(e.editable&&i&&(f.button===0||f.pointerType==="touch")){if(f.pointerType==="touch"&&s.size>1)(i.isDragging||i.pointerId!==null)&&_e(e,i);else if(f.pointerType==="touch"&&s.size===1)(re(w)||w.closest("me-tpc"))&&(c={x:f.clientX,y:f.clientY},r=w,a=f.pointerId,l=window.setTimeout(()=>{Ge(e,i,f,!0)&&(r&&r.setPointerCapture(f.pointerId),Ve(i.ghost,f.clientX,f.clientY)),l=null,c=null,r=null,a=null},d));else if(f.pointerType==="mouse"&&Ge(e,i,f,!1)){w.setPointerCapture(f.pointerId);return}}const O=e.spacePressed&&f.button===0&&f.pointerType==="mouse",K=!e.editable||f.button===T&&f.pointerType==="mouse"||f.pointerType==="touch";!O&&!K||(t.x=f.clientX,t.y=f.clientY,w.className!=="circle"&&w.contentEditable!=="plaintext-only"&&(t.mousedown=!0,w.setPointerCapture(f.pointerId)))},k=f=>{if(f.pointerType==="touch"&&s.has(f.pointerId)){if(s.set(f.pointerId,{x:f.clientX,y:f.clientY}),l!==null&&c!==null&&f.pointerId===a){const w=f.clientX-c.x,T=f.clientY-c.y;Math.sqrt(w*w+T*T)>h&&u()}if(s.size>=2){const[w,T]=Array.from(s.values()),O=$e(w,T);if(o==null)o=O;else{if(o>0){const K=O/o;e.scale(e.scaleVal*K,{x:(w.x+T.x)/2,y:(w.y+T.y)/2})}o=O}return}}if(!(i&&i.pointerId!==null&&(fn(e,i,f),i.isDragging))){if(f.target.contentEditable!=="plaintext-only"||e.spacePressed&&t.mousedown){const w=f.clientX-t.x,T=f.clientY-t.y;t.onMove(w,T)}t.x=f.clientX,t.y=f.clientY}},E=f=>{if(f.pointerType==="touch"&&(s.delete(f.pointerId),s.size<2&&(o=null),u()),i&&i.pointerId!==null){const w=i.isDragging;if(un(e,i,f),y(f.target,f.pointerId),w)return}t.mousedown&&(y(f.target,f.pointerId),t.clear())},C=()=>{u(),t.mousedown&&t.clear(),i&&(i.isDragging||i.pointerId!==null)&&_e(e,i)},S=f=>{f.pointerType==="touch"&&(s.delete(f.pointerId),s.size<2&&(o=null),u()),i&&i.pointerId===f.pointerId&&_e(e,i),E(f)},N=f=>{if(f.preventDefault(),f.button!==2||!e.editable)return;const w=f.target;re(w)&&!w.classList.contains("selected")&&e.selectNode(w),setTimeout(()=>{e.dragMoveHelper.moved||e.bus.fire("showContextMenu",f)},200)},D=f=>{f.stopPropagation(),f.preventDefault(),f.ctrlKey||f.metaKey?f.deltaY<0?le(e,"in",e.dragMoveHelper):e.scaleVal-e.scaleSensitivity>0&&le(e,"out",e.dragMoveHelper):f.shiftKey?e.move(-f.deltaY,0):e.move(-f.deltaX,-f.deltaY)},{container:_}=e;return Oe([{dom:_,evt:"pointerdown",func:L},{dom:_,evt:"pointermove",func:k},{dom:_,evt:"pointerup",func:E},{dom:_,evt:"pointercancel",func:S},{dom:_,evt:"pointerdown",func:m},{dom:_,evt:"click",func:p},{dom:_,evt:"dblclick",func:g},{dom:_,evt:"contextmenu",func:N},{dom:_,evt:"wheel",func:typeof e.handleWheel=="function"?e.handleWheel:D},{dom:_,evt:"blur",func:C},{dom:_,evt:"keydown",func:b},{dom:_,evt:"keyup",func:x}])}function mn(){return{handlers:{},addListener:function(e,t){this.handlers[e]===void 0&&(this.handlers[e]=[]),this.handlers[e].push(t)},fire:function(e,...t){if(this.handlers[e]instanceof Array){const n=this.handlers[e];for(let o=0;o<n.length;o++)n[o](...t)}},removeListener:function(e,t){if(!this.handlers[e])return;const n=this.handlers[e];if(!t)n.length=0;else if(n.length)for(let o=0;o<n.length;o++)n[o]===t&&this.handlers[e].splice(o,1)}}}const I="http://www.w3.org/2000/svg",ae=function(e){const t=e.clientWidth,n=e.clientHeight,o=e.dataset,s=Number(o.x),i=Number(o.y),l=o.anchor;let c=s;l==="middle"?c=s-t/2:l==="end"&&(c=s-t),e.style.left=`${c}px`,e.style.top=`${i-n/2}px`,e.style.visibility="visible"},Le=function(e,t,n,o){const{anchor:s="middle",color:i,dataType:l,svgId:c}=o,r=document.createElement("div");r.className="svg-label",r.style.color=i||"#666";const a="label-"+c;return r.id=a,r.innerHTML=e,r.dataset.type=l,r.dataset.svgId=c,r.dataset.x=t.toString(),r.dataset.y=n.toString(),r.dataset.anchor=s,r},qe=function(e,t,n){const o=document.createElementNS(I,"path");return A(o,{d:e,stroke:t||"#666",fill:"none","stroke-width":n}),o},ee=function(e){const t=document.createElementNS(I,"svg");return t.setAttribute("class",e),t.setAttribute("overflow","visible"),t},Ue=function(){const e=document.createElementNS(I,"line");return e.setAttribute("stroke","#4dc4ff"),e.setAttribute("fill","none"),e.setAttribute("stroke-width","2"),e.setAttribute("opacity","0.45"),e},yn=function(e,t,n,o){const s=document.createElementNS(I,"g");return[{name:"line",d:e},{name:"arrow1",d:t},{name:"arrow2",d:n}].forEach((l,c)=>{const r=l.d,a=document.createElementNS(I,"path"),d={d:r,stroke:o?.stroke||"rgb(227, 125, 116)",fill:"none","stroke-linecap":o?.strokeLinecap||"cap","stroke-width":String(o?.strokeWidth||"2")};o?.opacity!==void 0&&(d.opacity=String(o.opacity)),A(a,d),c===0&&a.setAttribute("stroke-dasharray",o?.strokeDasharray||"8,2");const h=document.createElementNS(I,"path");A(h,{d:r,stroke:"transparent",fill:"none","stroke-width":"15"}),s.appendChild(h),s.appendChild(a),s[l.name]=a}),s},Je=function(e,t,n){if(!t)return;const o=n.label,s=t.cloneNode(!0);e.nodes.appendChild(s),s.id="input-box",s.textContent=o,s.contentEditable="plaintext-only",s.spellcheck=!1,s.style.cssText=`
left:${t.style.left};
top:${t.style.top};
max-width: 200px;
`,He(s),e.scrollIntoView(s),s.addEventListener("keydown",i=>{i.stopPropagation();const l=i.key;if(l==="Enter"||l==="Tab"){if(i.shiftKey)return;i.preventDefault(),s.blur(),e.container.focus()}}),s.addEventListener("blur",()=>{if(!s)return;const i=s.innerText?.trim()||"";i===""?n.label=o:n.label=i,s.remove(),i!==o&&(e.markdown?t.innerHTML=e.markdown(n.label,n):t.textContent=n.label,ae(t),"parent"in n?e.bus.fire("operation",{name:"finishEditSummary",obj:n}):e.bus.fire("operation",{name:"finishEditArrowLabel",obj:n}))})},vn=function(e){const t=this.map.querySelector("me-root"),n=t.offsetTop,o=t.offsetLeft,s=t.offsetWidth,i=t.offsetHeight,l=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="";for(let c=0;c<l.length;c++){const r=l[c],a=r.querySelector("me-tpc"),{offsetLeft:d,offsetTop:h}=$(this.nodes,a),u=a.offsetWidth,y=a.offsetHeight,v=r.parentNode.className,p=this.generateMainBranch({pT:n,pL:o,pW:s,pH:i,cT:h,cL:d,cW:u,cH:y,direction:v,containerHeight:this.nodes.offsetHeight}),g=this.theme.palette,m=a.nodeObj.branchColor||g[c%g.length];if(a.style.borderColor=m,this.lines.appendChild(qe(p,m,"3")),e&&e!==r)continue;const b=ee("subLines"),x=r.lastChild;x.tagName==="svg"&&x.remove(),r.appendChild(b),Ze(this,b,m,r,v,!0)}this.labelContainer.innerHTML="",this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},Ze=function(e,t,n,o,s,i){const l=o.firstChild,c=o.children[1].children;if(c.length===0)return;const r=l.offsetTop,a=l.offsetLeft,d=l.offsetWidth,h=l.offsetHeight;for(let u=0;u<c.length;u++){const y=c[u],v=y.firstChild,p=v.offsetTop,g=v.offsetLeft,m=v.offsetWidth,b=v.offsetHeight,x=v.firstChild.nodeObj.branchColor||n,L=e.generateSubBranch({pT:r,pL:a,pW:d,pH:h,cT:p,cL:g,cW:m,cH:b,direction:s,isFirst:i});t.appendChild(qe(L,x,"2"));const k=v.children[1];if(k){if(!k.expanded)continue}else continue;Ze(e,t,x,y,s)}},Qe={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",linkBidirectional:"双向连接",clickTips:"请点击目标节点",summary:"摘要"},et={cn:Qe,zh_CN:Qe,zh_TW:{addChild:"插入子節點",addParent:"插入父節點",addSibling:"插入同級節點",removeNode:"刪除節點",focus:"專注",cancelFocus:"取消專注",moveUp:"上移",moveDown:"下移",link:"連接",linkBidirectional:"雙向連接",clickTips:"請點擊目標節點",summary:"摘要"},en:{addChild:"Add child",addParent:"Add parent",addSibling:"Add sibling",removeNode:"Remove node",focus:"Focus Mode",cancelFocus:"Cancel Focus Mode",moveUp:"Move up",moveDown:"Move down",link:"Link",linkBidirectional:"Bidirectional Link",clickTips:"Please click the target node",summary:"Summary"},ru:{addChild:"Добавить дочерний элемент",addParent:"Добавить родительский элемент",addSibling:"Добавить на этом уровне",removeNode:"Удалить узел",focus:"Режим фокусировки",cancelFocus:"Отменить режим фокусировки",moveUp:"Поднять выше",moveDown:"Опустить ниже",link:"Ссылка",linkBidirectional:"Двунаправленная ссылка",clickTips:"Пожалуйста, нажмите на целевой узел",summary:"Описание"},ja:{addChild:"子ノードを追加する",addParent:"親ノードを追加します",addSibling:"兄弟ノードを追加する",removeNode:"ノードを削除",focus:"集中",cancelFocus:"集中解除",moveUp:"上へ移動",moveDown:"下へ移動",link:"コネクト",linkBidirectional:"双方向リンク",clickTips:"ターゲットノードをクリックしてください",summary:"概要"},pt:{addChild:"Adicionar item filho",addParent:"Adicionar item pai",addSibling:"Adicionar item irmao",removeNode:"Remover item",focus:"Modo Foco",cancelFocus:"Cancelar Modo Foco",moveUp:"Mover para cima",moveDown:"Mover para baixo",link:"Link",linkBidirectional:"Link bidirecional",clickTips:"Favor clicar no item alvo",summary:"Resumo"},it:{addChild:"Aggiungi figlio",addParent:"Aggiungi genitore",addSibling:"Aggiungi fratello",removeNode:"Rimuovi nodo",focus:"Modalità Focus",cancelFocus:"Annulla Modalità Focus",moveUp:"Sposta su",moveDown:"Sposta giù",link:"Collega",linkBidirectional:"Collegamento bidirezionale",clickTips:"Si prega di fare clic sul nodo di destinazione",summary:"Unisci nodi"},es:{addChild:"Agregar hijo",addParent:"Agregar padre",addSibling:"Agregar hermano",removeNode:"Eliminar nodo",focus:"Modo Enfoque",cancelFocus:"Cancelar Modo Enfoque",moveUp:"Mover hacia arriba",moveDown:"Mover hacia abajo",link:"Enlace",linkBidirectional:"Enlace bidireccional",clickTips:"Por favor haga clic en el nodo de destino",summary:"Resumen"},fr:{addChild:"Ajout enfant",addParent:"Ajout parent",addSibling:"Ajout voisin",removeNode:"Supprimer",focus:"Cibler",cancelFocus:"Retour",moveUp:"Monter",moveDown:"Descendre",link:"Lier",linkBidirectional:"Lien bidirectionnel",clickTips:"Cliquer sur le noeud cible",summary:"Annoter"},ko:{addChild:"자식 추가",addParent:"부모 추가",addSibling:"형제 추가",removeNode:"노드 삭제",focus:"포커스 모드",cancelFocus:"포커스 모드 취소",moveUp:"위로 이동",moveDown:"아래로 이동",link:"연결",linkBidirectional:"양방향 연결",clickTips:"대상 노드를 클릭하십시오",summary:"요약"},ro:{addChild:"Adaugă sub-nod",addParent:"Adaugă nod părinte",addSibling:"Adaugă nod la același nivel",removeNode:"Șterge nodul",focus:"Focalizare",cancelFocus:"Anulează focalizarea",moveUp:"Mută în sus",moveDown:"Mută în jos",link:"Creează legătură",linkBidirectional:"Creează legătură bidirecțională",clickTips:"Click pe nodul țintă",summary:"Rezumat"}};function bn(e,t){t=t===!0?{focus:!0,link:!0}:t;const n=E=>{const C=document.createElement("div");return C.innerText=E,C.className="tips",C},o=(E,C,S)=>{const N=document.createElement("li");return N.id=E,N.innerHTML=`<span>${ye(C)}</span><span ${S?'class="key"':""}>${ye(S)}</span>`,N},s=et[e.locale]?e.locale:"en",i=et[s],l=o("cm-add_child",i.addChild,"Tab"),c=o("cm-add_parent",i.addParent,"Ctrl + Enter"),r=o("cm-add_sibling",i.addSibling,"Enter"),a=o("cm-remove_child",i.removeNode,"Delete"),d=o("cm-fucus",i.focus,""),h=o("cm-unfucus",i.cancelFocus,""),u=o("cm-up",i.moveUp,"PgUp"),y=o("cm-down",i.moveDown,"Pgdn"),v=o("cm-link",i.link,""),p=o("cm-link-bidirectional",i.linkBidirectional,""),g=o("cm-summary",i.summary,""),m=document.createElement("ul");if(m.className="menu-list",m.appendChild(l),m.appendChild(c),m.appendChild(r),m.appendChild(a),t.focus&&(m.appendChild(d),m.appendChild(h)),m.appendChild(u),m.appendChild(y),m.appendChild(g),t.link&&(m.appendChild(v),m.appendChild(p)),t&&t.extend)for(let E=0;E<t.extend.length;E++){const C=t.extend[E],S=o(C.name,C.name,C.key||"");m.appendChild(S),S.onclick=N=>{C.onclick(N)}}const b=document.createElement("div");b.className="context-menu",b.appendChild(m),b.hidden=!0,e.container.append(b);let x=!0;const L=E=>{const C=E.target;if(re(C)){C.parentElement.tagName==="ME-ROOT"?x=!0:x=!1,x?(d.className="disabled",u.className="disabled",y.className="disabled",c.className="disabled",r.className="disabled",a.className="disabled"):(d.className="",u.className="",y.className="",c.className="",r.className="",a.className=""),b.hidden=!1,m.style.top="",m.style.bottom="",m.style.left="",m.style.right="";const S=m.offsetHeight,N=m.offsetWidth,D=m.getBoundingClientRect(),_=E.clientY-D.top,B=E.clientX-D.left;S+_>window.innerHeight?(m.style.top="",m.style.bottom="0px"):(m.style.bottom="",m.style.top=_+15+"px"),N+B>window.innerWidth?(m.style.left="",m.style.right="0px"):(m.style.right="",m.style.left=B+10+"px")}};e.bus.addListener("showContextMenu",L),b.onclick=E=>{E.target===b&&(b.hidden=!0)},l.onclick=()=>{e.addChild(),b.hidden=!0},c.onclick=()=>{e.insertParent(),b.hidden=!0},r.onclick=()=>{x||(e.insertSibling("after"),b.hidden=!0)},a.onclick=()=>{x||(e.removeNodes(e.currentNodes||[]),b.hidden=!0)},d.onclick=()=>{x||(e.focusNode(e.currentNode),b.hidden=!0)},h.onclick=()=>{e.cancelFocus(),b.hidden=!0},u.onclick=()=>{x||(e.moveUpNode(),b.hidden=!0)},y.onclick=()=>{x||(e.moveDownNode(),b.hidden=!0)};const k=E=>{b.hidden=!0;const C=e.currentNode,S=n(i.clickTips);e.container.appendChild(S),e.map.addEventListener("click",N=>{N.preventDefault(),S.remove();const D=N.target;(D.parentElement.tagName==="ME-PARENT"||D.parentElement.tagName==="ME-ROOT")&&e.createArrow(C,D,E)},{once:!0})};return v.onclick=()=>k(),p.onclick=()=>k({bidirectional:!0}),g.onclick=()=>{b.hidden=!0,e.createSummary(),e.unselectNodes(e.currentNodes)},()=>{l.onclick=null,c.onclick=null,r.onclick=null,a.onclick=null,d.onclick=null,h.onclick=null,u.onclick=null,y.onclick=null,v.onclick=null,g.onclick=null,b.onclick=null,e.container.oncontextmenu=null}}const wn=function(e){return["createSummary","removeSummary","finishEditSummary"].includes(e.name)?{type:"summary",value:e.obj.id}:["createArrow","removeArrow","finishEditArrowLabel"].includes(e.name)?{type:"arrow",value:e.obj.id}:["removeNodes","copyNodes","moveNodeBefore","moveNodeAfter","moveNodeIn"].includes(e.name)?{type:"nodes",value:e.objs.map(t=>t.id)}:{type:"nodes",value:[e.obj.id]}};function xn(e){let t=[],n=-1,o=e.getData(),s=[];e.undo=function(){if(n>-1){const r=t[n];o=r.prev,e.refresh(r.prev);try{r.currentTarget.type==="nodes"&&(r.operation==="removeNodes"?e.selectNodes(r.currentTarget.value.map(a=>this.findEle(a))):e.selectNodes(r.currentSelected.map(a=>this.findEle(a))))}catch{}finally{n--}}},e.redo=function(){if(n<t.length-1){n++;const r=t[n];o=r.next,e.refresh(r.next);try{r.currentTarget.type==="nodes"&&(r.operation==="removeNodes"?e.selectNodes(r.currentSelected.map(a=>this.findEle(a))):e.selectNodes(r.currentTarget.value.map(a=>this.findEle(a))))}catch{}}};const i=function(r){if(r.name==="beginEdit")return;t=t.slice(0,n+1);const a=e.getData(),d={prev:o,operation:r.name,currentSelected:s.map(h=>h.id),currentTarget:wn(r),next:a};t.push(d),o=a,n=t.length-1},l=function(r){(r.metaKey||r.ctrlKey)&&(r.shiftKey&&r.key==="Z"||r.key==="y")?e.redo():(r.metaKey||r.ctrlKey)&&r.key==="z"&&e.undo()},c=function(){s=e.currentNodes.map(r=>r.nodeObj)};return e.bus.addListener("operation",i),e.bus.addListener("selectNodes",c),e.container.addEventListener("keydown",l),()=>{e.bus.removeListener("operation",i),e.bus.removeListener("selectNodes",c),e.container.removeEventListener("keydown",l)}}const Cn={side:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169394918" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2021" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M851.91168 328.45312c-59.97056 0-108.6208 48.47104-108.91264 108.36992l-137.92768 38.4a109.14304 109.14304 0 0 0-63.46752-46.58688l1.39264-137.11872c47.29344-11.86816 82.31936-54.66624 82.31936-105.64096 0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.76288-108.91776 108.91776c0 49.18784 32.60928 90.75712 77.38368 104.27392l-1.41312 138.87488a109.19936 109.19936 0 0 0-63.50336 48.55808l-138.93632-39.48544 0.01024-0.72704c0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.75776-108.91776 108.91776c0 60.15488 48.76288 108.91264 108.91776 108.91264 39.3984 0 73.91232-20.92032 93.03552-52.2496l139.19232 39.552-0.00512 0.2304c0 25.8304 9.00096 49.5616 24.02816 68.23424l-90.14272 132.63872a108.7488 108.7488 0 0 0-34.2528-5.504c-60.15488 0-108.91776 48.768-108.91776 108.91776 0 60.16 48.76288 108.91776 108.91776 108.91776 60.16 0 108.92288-48.75776 108.92288-108.91776 0-27.14624-9.9328-51.968-26.36288-71.04l89.04704-131.03104a108.544 108.544 0 0 0 37.6832 6.70208 108.672 108.672 0 0 0 36.48512-6.272l93.13792 132.57216a108.48256 108.48256 0 0 0-24.69888 69.0688c0 60.16 48.768 108.92288 108.91776 108.92288 60.16 0 108.91776-48.76288 108.91776-108.92288 0-60.14976-48.75776-108.91776-108.91776-108.91776a108.80512 108.80512 0 0 0-36.69504 6.3488l-93.07136-132.48a108.48768 108.48768 0 0 0 24.79616-72.22784l136.09984-37.888c18.99008 31.93856 53.84192 53.3504 93.69088 53.3504 60.16 0 108.92288-48.75776 108.92288-108.91264-0.00512-60.15488-48.77312-108.92288-108.92288-108.92288z" p-id="2022"></path></svg>',left:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169375313" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1775" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639 463.30000001L639 285.1c0-36.90000001-26.4-68.5-61.3-68.5l-150.2 0c-1.5 0-3 0.1-4.5 0.3-10.2-38.7-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c42 0 77.3-28.6 87.5-67.39999999 1.4 0.3 2.9 0.4 4.5 0.39999999L577.7 263.6c6.8 0 14.3 8.9 14.3 21.49999999l0 427.00000001c0 12.7-7.40000001 21.5-14.30000001 21.5l-150.19999999 0c-1.5 0-3 0.2-4.5 0.4-10.2-38.8-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.4 0 49.9 40.5 90.6 90.5 90.59999999 42 0 77.3-28.6 87.5-67.39999999 1.4 0.2 2.9 0.4 4.49999999 0.4L577.7 780.7c34.80000001 0 61.3-31.6 61.3-68.50000001L639 510.3l79.1 0c10.4 38.5 45.49999999 67 87.4 67 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-41.79999999 0-77.00000001 28.4-87.4 67L639 463.30000001z" fill="currentColor" p-id="1776"></path></svg>',right:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169667709" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3037" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M385 560.69999999L385 738.9c0 36.90000001 26.4 68.5 61.3 68.5l150.2 0c1.5 0 3-0.1 4.5-0.3 10.2 38.7 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-42 0-77.3 28.6-87.5 67.39999999-1.4-0.3-2.9-0.4-4.5-0.39999999L446.3 760.4c-6.8 0-14.3-8.9-14.3-21.49999999l0-427.00000001c0-12.7 7.40000001-21.5 14.30000001-21.5l150.19999999 0c1.5 0 3-0.2 4.5-0.4 10.2 38.8 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.4 0-49.9-40.5-90.6-90.5-90.59999999-42 0-77.3 28.6-87.5 67.39999999-1.4-0.2-2.9-0.4-4.49999999-0.4L446.3 243.3c-34.80000001 0-61.3 31.6-61.3 68.50000001L385 513.7l-79.1 0c-10.4-38.5-45.49999999-67-87.4-67-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c41.79999999 0 77.00000001-28.4 87.4-67L385 560.69999999z" fill="currentColor" p-id="3038"></path></svg>',full:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169402629" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2170" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639.328 416c8.032 0 16.096-3.008 22.304-9.056l202.624-197.184-0.8 143.808c-0.096 17.696 14.144 32.096 31.808 32.192 0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808l1.248-222.208c0-0.672-0.352-1.248-0.384-1.92 0.032-0.512 0.288-0.896 0.288-1.408 0.032-17.664-14.272-32-31.968-32.032L671.552 96l-0.032 0c-17.664 0-31.968 14.304-32 31.968C639.488 145.632 653.824 160 671.488 160l151.872 0.224-206.368 200.8c-12.672 12.32-12.928 32.608-0.64 45.248C622.656 412.736 630.976 416 639.328 416z" p-id="2171"></path><path d="M896.032 639.552 896.032 639.552c-17.696 0-32 14.304-32.032 31.968l-0.224 151.872-200.832-206.4c-12.32-12.64-32.576-12.96-45.248-0.64-12.672 12.352-12.928 32.608-0.64 45.248l197.184 202.624-143.808-0.8c-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808-0.096 17.696 14.144 32.096 31.808 32.192l222.24 1.248c0.064 0 0.128 0 0.192 0 0.64 0 1.12-0.32 1.76-0.352 0.512 0.032 0.896 0.288 1.408 0.288l0.032 0c17.664 0 31.968-14.304 32-31.968L928 671.584C928.032 653.952 913.728 639.584 896.032 639.552z" p-id="2172"></path><path d="M209.76 159.744l143.808 0.8c0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808 0.096-17.696-14.144-32.096-31.808-32.192L131.68 95.328c-0.064 0-0.128 0-0.192 0-0.672 0-1.248 0.352-1.888 0.384-0.448 0-0.8-0.256-1.248-0.256 0 0-0.032 0-0.032 0-17.664 0-31.968 14.304-32 31.968L96 352.448c-0.032 17.664 14.272 32 31.968 32.032 0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968l0.224-151.936 200.832 206.4c6.272 6.464 14.624 9.696 22.944 9.696 8.032 0 16.096-3.008 22.304-9.056 12.672-12.32 12.96-32.608 0.64-45.248L209.76 159.744z" p-id="2173"></path><path d="M362.368 617.056l-202.624 197.184 0.8-143.808c0.096-17.696-14.144-32.096-31.808-32.192-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808l-1.248 222.24c0 0.704 0.352 1.312 0.384 2.016 0 0.448-0.256 0.832-0.256 1.312-0.032 17.664 14.272 32 31.968 32.032L352.448 928c0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968s-14.272-32-31.968-32.032l-151.936-0.224 206.4-200.832c12.672-12.352 12.96-32.608 0.64-45.248S375.008 604.704 362.368 617.056z" p-id="2174"></path></svg>',living:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169573443" class="ic