mind-elixir
Version:
Mind elixir is a free open source mind map core.
16 lines (15 loc) • 48 kB
JavaScript
var MindElixirLite=function(){"use strict";const Xe="",U={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","--topic-padding":"3px","--color":"#777777","--bgcolor":"#f6f6f6","--selected":"#4dc4ff","--panel-color":"#444446","--panel-bgcolor":"#ffffff","--panel-border-color":"#eaeaea","--map-padding":"50px"}},K={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","--topic-padding":"3px","--color":"#cccccc","--bgcolor":"#252526","--selected":"#4dc4ff","--panel-color":"#ffffff","--panel-bgcolor":"#2d3748","--panel-border-color":"#696969","--map-padding":"50px 80px"}};function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""")}const G=function(t,e){if(e.id===t)return e;if(e.children&&e.children.length){for(let n=0;n<e.children.length;n++){const o=G(t,e.children[n]);if(o)return o}return null}else return null},J=(t,e)=>{if(t.parent=e,t.children)for(let n=0;n<t.children.length;n++)J(t.children[n],t)};function I(t,e,n,o){const i=o-e,s=t-n;let r=Math.atan(Math.abs(i)/Math.abs(s))/3.14*180;if(isNaN(r))return;s<0&&i>0&&(r=180-r),s<0&&i<0&&(r=180+r),s>0&&i<0&&(r=360-r);const a=12,f=30,d=r+f,p=r-f;return{x1:n+Math.cos(Math.PI*d/180)*a,y1:o-Math.sin(Math.PI*d/180)*a,x2:n+Math.cos(Math.PI*p/180)*a,y2:o-Math.sin(Math.PI*p/180)*a}}function B(){return(new Date().getTime().toString(16)+Math.random().toString(16).substr(2)).substr(2,16)}const St=function(){const t=B();return{topic:this.newTopicName,id:t}},A=(t,e)=>{let n=0,o=0;for(;e&&e!==t;)n+=e.offsetLeft,o+=e.offsetTop,e=e.offsetParent;return{offsetLeft:n,offsetTop:o}},v=(t,e)=>{for(const n in e)t.setAttribute(n,e[n])},nt=t=>t?t.tagName==="ME-TPC":!1,ot=t=>{const e=/translate\(([^,]+),\s*([^)]+)\)/,n=t.match(e);return n?{x:parseFloat(n[1]),y:parseFloat(n[2])}:{x:0,y:0}},it=function(t){for(let e=0;e<t.length;e++){const{dom:n,evt:o,func:i}=t[e];n.addEventListener(o,i)}return function(){for(let n=0;n<t.length;n++){const{dom:o,evt:i,func:s}=t[n];o.removeEventListener(i,s)}}};var M=(t=>(t.LHS="lhs",t.RHS="rhs",t))(M||{});const st=function(t,e,n){const{scaleVal:o,scaleSensitivity:i}=t;switch(e){case"in":if(o>1.6)return;t.scale(o+i,n);break;case"out":if(o<.6)return;t.scale(o-i,n)}};function Et(t){const{dragMoveHelper:e}=t,n=l=>{var m,w,x;if(l.button!==0)return;if((m=t.helper1)!=null&&m.moved){t.helper1.clear();return}if((w=t.helper2)!=null&&w.moved){t.helper2.clear();return}if(e.moved){e.clear();return}const c=l.target;if(c.tagName==="ME-EPD")l.ctrlKey||l.metaKey?t.expandNodeAll(c.previousSibling):t.expandNode(c.previousSibling);else if(c.tagName==="ME-TPC"&&t.currentNodes.length>1)t.selectNode(c);else if(!t.editable)return;const h=(x=c.parentElement)==null?void 0:x.parentElement;h.getAttribute("class")==="topiclinks"?t.selectArrow(c.parentElement):h.getAttribute("class")==="summary"&&t.selectSummary(c.parentElement)},o=l=>{var m;if(!t.editable)return;const c=l.target;nt(c)&&t.beginEdit(c);const h=(m=c.parentElement)==null?void 0:m.parentElement;h.getAttribute("class")==="topiclinks"?t.editArrowLabel(c.parentElement):h.getAttribute("class")==="summary"&&t.editSummary(c.parentElement)};let i=0;const s=l=>{if(l.pointerType==="mouse")return;const c=new Date().getTime(),h=c-i;h<300&&h>0&&o(l),i=c},r=l=>{e.moved=!1;const c=t.mouseSelectionButton===0?2:0;if(l.button!==c&&l.pointerType==="mouse")return;e.x=l.clientX,e.y=l.clientY;const h=l.target;h.className!=="circle"&&h.contentEditable!=="plaintext-only"&&(e.mousedown=!0,t.map.style.transition="none",h.setPointerCapture(l.pointerId))},a=l=>{if(l.target.contentEditable!=="plaintext-only"){const c=l.clientX-e.x,h=l.clientY-e.y;e.onMove(c,h)}e.x=l.clientX,e.y=l.clientY},f=l=>{const c=t.mouseSelectionButton===0?2:0;if(l.button!==c&&l.pointerType==="mouse")return;const h=l.target;h.hasPointerCapture&&h.hasPointerCapture(l.pointerId)&&h.releasePointerCapture(l.pointerId),e.clear()},d=l=>{if(l.preventDefault(),l.button!==2||!t.editable)return;const c=l.target;nt(c)&&!c.classList.contains("selected")&&t.selectNode(c),setTimeout(()=>{t.dragMoveHelper.moved||t.bus.fire("showContextMenu",l)},200)},p=l=>{l.stopPropagation(),l.preventDefault(),l.ctrlKey||l.metaKey?l.deltaY<0?st(t,"in",t.dragMoveHelper):t.scaleVal-t.scaleSensitivity>0&&st(t,"out",t.dragMoveHelper):l.shiftKey?t.move(-l.deltaY,0):(t.map.style.transition="none",t.move(-l.deltaX,-l.deltaY),t.map.style.transition="transform 0.3s")},{container:u}=t;return it([{dom:u,evt:"pointerdown",func:r},{dom:u,evt:"pointermove",func:a},{dom:u,evt:"pointerup",func:f},{dom:u,evt:"pointerup",func:s},{dom:u,evt:"click",func:n},{dom:u,evt:"dblclick",func:o},{dom:u,evt:"contextmenu",func:d},{dom:u,evt:"wheel",func:p}])}function Lt(){return{handlers:{},addListener:function(t,e){this.handlers[t]===void 0&&(this.handlers[t]=[]),this.handlers[t].push(e)},fire:function(t,...e){if(this.handlers[t]instanceof Array){const n=this.handlers[t];for(let o=0;o<n.length;o++)n[o](...e)}},removeListener:function(t,e){if(!this.handlers[t])return;const n=this.handlers[t];if(!e)n.length=0;else if(n.length)for(let o=0;o<n.length;o++)n[o]===e&&this.handlers[t].splice(o,1)}}}const F=document,Tt=function(){this.nodes.innerHTML="";const t=this.createTopic(this.nodeData);ct(t,this.nodeData),t.draggable=!1;const e=F.createElement("me-root");e.appendChild(t);const n=this.nodeData.children||[];if(this.direction===2){let o=0,i=0;n.map(s=>{s.direction===0?o+=1:s.direction===1?i+=1:o<=i?(s.direction=0,o+=1):(s.direction=1,i+=1)})}kt(this,n,e)},kt=function(t,e,n){const o=F.createElement("me-main");o.className=M.LHS;const i=F.createElement("me-main");i.className=M.RHS;for(let s=0;s<e.length;s++){const r=e[s],{grp:a}=t.createWrapper(r);t.direction===2?r.direction===0?o.appendChild(a):i.appendChild(a):t.direction===0?o.appendChild(a):i.appendChild(a)}t.nodes.appendChild(o),t.nodes.appendChild(n),t.nodes.appendChild(i),t.nodes.appendChild(t.lines)},$t=function(t,e){const n=F.createElement("me-children");for(let o=0;o<e.length;o++){const i=e[o],{grp:s}=t.createWrapper(i);n.appendChild(s)}return n},k=document,rt=function(t,e){const o=(this!=null&&this.el?this.el:e||document).querySelector(`[data-nodeid="me${t}"]`);if(!o)throw new Error(`FindEle: Node ${t} not found, maybe it's collapsed.`);return o},ct=function(t,e){if(t.innerHTML="",e.style){const n=e.style;for(const o in n)t.style[o]=n[o]}if(e.dangerouslySetInnerHTML){t.innerHTML=e.dangerouslySetInnerHTML;return}if(e.image){const n=e.image;if(n.url&&n.width&&n.height){const o=k.createElement("img");o.src=n.url,o.style.width=n.width+"px",o.style.height=n.height+"px",n.fit&&(o.style.objectFit=n.fit),t.appendChild(o),t.image=o}}else t.image&&(t.image=void 0);{const n=k.createElement("span");n.className="text",n.textContent=e.topic,t.appendChild(n),t.text=n}if(e.hyperLink){const n=k.createElement("a");n.className="hyper-link",n.target="_blank",n.innerText="🔗",n.href=e.hyperLink,t.appendChild(n),t.link=n}else t.link&&(t.link=void 0);if(e.icons&&e.icons.length){const n=k.createElement("span");n.className="icons",n.innerHTML=e.icons.map(o=>`<span>${et(o)}</span>`).join(""),t.appendChild(n),t.icons=n}else t.icons&&(t.icons=void 0);if(e.tags&&e.tags.length){const n=k.createElement("div");n.className="tags",n.innerHTML=e.tags.map(o=>`<span>${et(o)}</span>`).join(""),t.appendChild(n),t.tags=n}else t.tags&&(t.tags=void 0)},At=function(t,e){const n=k.createElement("me-wrapper"),{p:o,tpc:i}=this.createParent(t);if(n.appendChild(o),!e&&t.children&&t.children.length>0){const s=Ht(t.expanded);if(o.appendChild(s),t.expanded!==!1){const r=$t(this,t.children);n.appendChild(r)}}return{grp:n,top:o,tpc:i}},Dt=function(t){const e=k.createElement("me-parent"),n=this.createTopic(t);return ct(n,t),e.appendChild(n),{p:e,tpc:n}},Mt=function(t){const e=k.createElement("me-children");return e.append(...t),e},Nt=function(t){const e=k.createElement("me-tpc");return e.nodeObj=t,e.dataset.nodeid="me"+t.id,e.draggable=this.draggable,e};function lt(t){const e=k.createRange();e.selectNodeContents(t);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}const Pt=function(t){if(!t)return;const e=k.createElement("div"),n=t.text.textContent;t.appendChild(e),e.id="input-box",e.textContent=n,e.contentEditable="plaintext-only",e.spellcheck=!1;const o=getComputedStyle(t);e.style.cssText=`min-width:${t.offsetWidth-8}px;
color:${o.color};
padding:${o.padding};
margin:${o.margin};
font:${o.font};
background-color:${o.backgroundColor!=="rgba(0, 0, 0, 0)"&&o.backgroundColor};
border-radius:${o.borderRadius};`,this.direction===0&&(e.style.right="0"),lt(e),this.bus.fire("operation",{name:"beginEdit",obj:t.nodeObj}),e.addEventListener("keydown",i=>{i.stopPropagation();const s=i.key;if(s==="Enter"||s==="Tab"){if(i.shiftKey)return;i.preventDefault(),e.blur(),this.container.focus()}}),e.addEventListener("blur",()=>{var r;if(!e)return;const i=t.nodeObj,s=((r=e.textContent)==null?void 0:r.trim())||"";s===""?i.topic=n:i.topic=s,e.remove(),s!==n&&(t.text.textContent=i.topic,this.linkDiv(),this.bus.fire("operation",{name:"finishEdit",obj:i,origin:n}))})},Ht=function(t){const e=k.createElement("me-epd");return e.expanded=t!==!1,e.className=t!==!1?"minus":"",e},N=document,L="http://www.w3.org/2000/svg",at=function(t,e,n){const o=N.createElementNS(L,"path");return v(o,{d:t,stroke:e||"#666",fill:"none","stroke-width":n}),o},O=function(t){const e=N.createElementNS(L,"svg");return e.setAttribute("class",t),e.setAttribute("overflow","visible"),e},ht=function(){const t=N.createElementNS(L,"line");return t.setAttribute("stroke","#4dc4ff"),t.setAttribute("fill","none"),t.setAttribute("stroke-width","2"),t.setAttribute("opacity","0.45"),t},Bt=function(t,e,n,o){const i=N.createElementNS(L,"g");return[{name:"line",d:t},{name:"arrow1",d:e},{name:"arrow2",d:n}].forEach((r,a)=>{const f=r.d,d=N.createElementNS(L,"path"),p={d:f,stroke:(o==null?void 0:o.stroke)||"rgb(235, 95, 82)",fill:"none","stroke-linecap":(o==null?void 0:o.strokeLinecap)||"cap","stroke-width":String((o==null?void 0:o.strokeWidth)||"2")};(o==null?void 0:o.opacity)!==void 0&&(p.opacity=String(o.opacity)),v(d,p),a===0&&d.setAttribute("stroke-dasharray",(o==null?void 0:o.strokeDasharray)||"8,2");const u=N.createElementNS(L,"path");v(u,{d:f,stroke:"transparent",fill:"none","stroke-width":"15"}),i.appendChild(u),i.appendChild(d),i[r.name]=d}),i},dt=function(t,e,n){if(!e)return;const o=N.createElement("div");t.nodes.appendChild(o);const i=e.innerHTML;o.id="input-box",o.textContent=i,o.contentEditable="plaintext-only",o.spellcheck=!1;const s=e.getBBox();o.style.cssText=`
min-width:${Math.max(88,s.width)}px;
position:absolute;
left:${s.x}px;
top:${s.y}px;
padding: 2px 4px;
margin: -2px -4px;
`,lt(o),t.scrollIntoView(o),o.addEventListener("keydown",r=>{r.stopPropagation();const a=r.key;if(a==="Enter"||a==="Tab"){if(r.shiftKey)return;r.preventDefault(),o.blur(),t.container.focus()}}),o.addEventListener("blur",()=>{var a;if(!o)return;const r=((a=o.textContent)==null?void 0:a.trim())||"";r===""?n.label=i:n.label=r,o.remove(),r!==i&&(e.innerHTML=n.label,t.linkDiv(),"parent"in n?t.bus.fire("operation",{name:"finishEditSummary",obj:n}):t.bus.fire("operation",{name:"finishEditArrowLabel",obj:n}))})},Ot=function(t){const e=this.map.querySelector("me-root"),n=e.offsetTop,o=e.offsetLeft,i=e.offsetWidth,s=e.offsetHeight,r=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="";for(let a=0;a<r.length;a++){const f=r[a],d=f.querySelector("me-tpc"),{offsetLeft:p,offsetTop:u}=A(this.nodes,d),g=d.offsetWidth,l=d.offsetHeight,c=f.parentNode.className,h=this.generateMainBranch({pT:n,pL:o,pW:i,pH:s,cT:u,cL:p,cW:g,cH:l,direction:c,containerHeight:this.nodes.offsetHeight}),m=this.theme.palette,w=d.nodeObj.branchColor||m[a%m.length];if(d.style.borderColor=w,this.lines.appendChild(at(h,w,"3")),t&&t!==f)continue;const x=O("subLines"),y=f.lastChild;y.tagName==="svg"&&y.remove(),f.appendChild(x),ft(this,x,w,f,c,!0)}this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},ft=function(t,e,n,o,i,s){const r=o.firstChild,a=o.children[1].children;if(a.length===0)return;const f=r.offsetTop,d=r.offsetLeft,p=r.offsetWidth,u=r.offsetHeight;for(let g=0;g<a.length;g++){const l=a[g],c=l.firstChild,h=c.offsetTop,m=c.offsetLeft,w=c.offsetWidth,x=c.offsetHeight,y=c.firstChild.nodeObj.branchColor||n,b=t.generateSubBranch({pT:f,pL:d,pW:p,pH:u,cT:h,cL:m,cW:w,cH:x,direction:i,isFirst:s});e.appendChild(at(b,y,"2"));const C=c.children[1];if(C){if(!C.expanded)continue}else continue;ft(t,e,y,l,i)}},Ke="",Vt='<?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>',Wt='<?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>',Gt='<?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>',It='<?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>',Ft='<?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="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2883" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M514.133333 488.533333m-106.666666 0a106.666667 106.666667 0 1 0 213.333333 0 106.666667 106.666667 0 1 0-213.333333 0Z" fill="currentColor" p-id="2884"></path><path d="M512 64C264.533333 64 64 264.533333 64 512c0 236.8 183.466667 428.8 416 445.866667v-134.4c-53.333333-59.733333-200.533333-230.4-200.533333-334.933334 0-130.133333 104.533333-234.666667 234.666666-234.666666s234.666667 104.533333 234.666667 234.666666c0 61.866667-49.066667 153.6-145.066667 270.933334l-59.733333 68.266666V960C776.533333 942.933333 960 748.8 960 512c0-247.466667-200.533333-448-448-448z" fill="currentColor" p-id="2885"></path></svg>',jt='<?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="1750169419447" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2480" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.328 482.56l-317.344-1.12L545.984 162.816c0-17.664-14.336-32-32-32s-32 14.336-32 32l0 318.4L159.616 480.064c-0.032 0-0.064 0-0.096 0-17.632 0-31.936 14.24-32 31.904C127.424 529.632 141.728 544 159.392 544.064l322.592 1.152 0 319.168c0 17.696 14.336 32 32 32s32-14.304 32-32l0-318.944 317.088 1.12c0.064 0 0.096 0 0.128 0 17.632 0 31.936-14.24 32-31.904C895.264 496.992 880.96 482.624 863.328 482.56z" p-id="2481"></path></svg>',zt='<?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="1750169426515" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2730" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.744 544 163.424 544c-17.664 0-32-14.336-32-32s14.336-32 32-32l700.32 0c17.696 0 32 14.336 32 32S881.44 544 863.744 544z" p-id="2731"></path></svg>',Je="",Yt={side:Vt,left:Wt,right:Gt,full:It,living:Ft,zoomin:jt,zoomout:zt},P=(t,e)=>{const n=document.createElement("span");return n.id=t,n.innerHTML=Yt[e],n};function Rt(t){const e=document.createElement("div"),n=P("fullscreen","full"),o=P("toCenter","living"),i=P("zoomout","zoomout"),s=P("zoomin","zoomin"),r=document.createElement("span");return r.innerText="100%",e.appendChild(n),e.appendChild(o),e.appendChild(i),e.appendChild(s),e.className="mind-elixir-toolbar rb",n.onclick=()=>{document.fullscreenElement===t.el?document.exitFullscreen():t.el.requestFullscreen()},o.onclick=()=>{t.toCenter()},i.onclick=()=>{t.scaleVal<.6||t.scale(t.scaleVal-t.scaleSensitivity)},s.onclick=()=>{t.scaleVal>1.6||t.scale(t.scaleVal+t.scaleSensitivity)},e}function Xt(t){const e=document.createElement("div"),n=P("tbltl","left"),o=P("tbltr","right"),i=P("tblts","side");return e.appendChild(n),e.appendChild(o),e.appendChild(i),e.className="mind-elixir-toolbar lt",n.onclick=()=>{t.initLeft()},o.onclick=()=>{t.initRight()},i.onclick=()=>{t.initSide()},e}function qt(t){t.container.append(Rt(t)),t.container.append(Xt(t))}const _t=function(t,e=!0){this.theme=t;const o={...(t.type==="dark"?K:U).cssVar,...t.cssVar},i=Object.keys(o);for(let s=0;s<i.length;s++){const r=i[s];this.container.style.setProperty(r,o[r])}e&&this.refresh()},Ut=function(t){const n=t.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())};function Kt(t){return{nodeData:t.isFocusMode?t.nodeDataBackup:t.nodeData,arrows:t.arrows,summaries:t.summaries,direction:t.direction,theme:t.theme}}const Jt=function(t){const e=this.container,n=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(n.top>o.bottom||n.bottom<o.top||n.left>o.right||n.right<o.left){const s=n.left+n.width/2,r=n.top+n.height/2,a=o.left+o.width/2,f=o.top+o.height/2,d=s-a,p=r-f;this.move(-d,-p)}},Qt=function(t,e,n){this.clearSelection(),this.scrollIntoView(t),this.selection.select(t),e&&this.bus.fire("selectNewNode",t.nodeObj)},Zt=function(t){this.selection.select(t)},te=function(t){this.selection.deselect(t)},ee=function(){this.unselectNodes(this.currentNodes),this.unselectSummary(),this.unselectArrow()},ne=function(){const t=Kt(this);return JSON.stringify(t,(e,n)=>{if(!(e==="parent"&&typeof n!="string"))return n})},oe=function(){return JSON.parse(this.getDataString())},ie=function(){this.editable=!0},se=function(){this.editable=!1},re=function(t,e={x:0,y:0}){const n=this.container.getBoundingClientRect(),o=e.x?e.x-n.left-n.width/2:0,i=e.y?e.y-n.top-n.height/2:0,{dx:s,dy:r}=pt(this),a=this.map.style.transform,{x:f,y:d}=ot(a),p=f-s,u=d-r,g=this.scaleVal,l=(-o+p)*(1-t/g),c=(-i+u)*(1-t/g);this.map.style.transform=`translate(${f-l}px, ${d-c}px) scale(${t})`,this.scaleVal=t,this.bus.fire("scale",t)},ce=function(){const t=this.nodes.offsetHeight/this.container.offsetHeight,e=this.nodes.offsetWidth/this.container.offsetWidth,n=1/Math.max(1,Math.max(t,e));this.scaleVal=n,this.map.style.transform="scale("+n+")",this.bus.fire("scale",n)},le=function(t,e){const{map:n,scaleVal:o,bus:i}=this,s=n.style.transform;let{x:r,y:a}=ot(s);r+=t,a+=e,n.style.transform=`translate(${r}px, ${a}px) scale(${o})`,i.fire("move",{dx:t,dy:e})},pt=t=>{const{container:e,map:n,nodes:o}=t,i=n.querySelector("me-root"),s=i.offsetTop,r=i.offsetLeft,a=i.offsetWidth,f=i.offsetHeight;let d,p;return t.alignment==="root"?(d=e.offsetWidth/2-r-a/2,p=e.offsetHeight/2-s-f/2,n.style.transformOrigin=`${r+a/2}px 50%`):(d=(e.offsetWidth-o.offsetWidth)/2,p=(e.offsetHeight-o.offsetHeight)/2,n.style.transformOrigin="50% 50%"),{dx:d,dy:p}},ae=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:ee,disableEdit:se,enableEdit:ie,expandNode:function(t,e){const n=t.nodeObj;typeof e=="boolean"?n.expanded=e:n.expanded!==!1?n.expanded=!1:n.expanded=!0;const o=t.parentNode,i=o.children[1];if(i.expanded=n.expanded,i.className=n.expanded?"minus":"",Ut(t),n.expanded){const f=this.createChildren(n.children.map(d=>this.createWrapper(d).grp));o.parentNode.appendChild(f)}else o.parentNode.children[1].remove();this.linkDiv(t.closest("me-main > me-wrapper"));const s=t.getBoundingClientRect(),r=this.container.getBoundingClientRect();(s.bottom>r.bottom||s.top<r.top||s.right>r.right||s.left<r.left)&&this.scrollIntoView(t),this.bus.fire("expandNode",n)},expandNodeAll:function(t,e){const n=t.nodeObj,o=(i,s)=>{i.expanded=s,i.children&&i.children.forEach(r=>{o(r,s)})};typeof e=="boolean"?o(n,e):n.expanded!==!1?o(n,!1):o(n,!0),this.refresh()},focusNode:function(t){t.nodeObj.parent&&(this.clearSelection(),this.tempDirection===null&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=t.nodeObj,this.initRight(),this.toCenter())},getData:oe,getDataString:ne,initLeft:function(){this.direction=0,this.refresh(),this.toCenter()},initRight:function(){this.direction=1,this.refresh(),this.toCenter()},initSide:function(){this.direction=2,this.refresh(),this.toCenter()},install:function(t){t(this)},move:le,refresh:function(t){t&&(t=JSON.parse(JSON.stringify(t)),this.nodeData=t.nodeData,this.arrows=t.arrows||[],this.summaries=t.summaries||[]),J(this.nodeData),this.layout(),this.linkDiv()},scale:re,scaleFit:ce,scrollIntoView:Jt,selectNode:Qt,selectNodes:Zt,setLocale:function(t){this.locale=t,this.refresh()},toCenter:function(){const{map:t}=this,{dx:e,dy:n}=pt(this);t.style.transform=`translate(${e}px, ${n}px) scale(${this.scaleVal})`},unselectNodes:te},Symbol.toStringTag,{value:"Module"})),ut={create:function(t){return{dom:t,moved:!1,pointerdown:!1,lastX:0,lastY:0,handlePointerMove(e){if(this.pointerdown){this.moved=!0;const n=e.clientX-this.lastX,o=e.clientY-this.lastY;this.lastX=e.clientX,this.lastY=e.clientY,this.cb&&this.cb(n,o)}},handlePointerDown(e){e.button===0&&(this.pointerdown=!0,this.lastX=e.clientX,this.lastY=e.clientY,this.dom.setPointerCapture(e.pointerId))},handleClear(e){this.pointerdown=!1,e.pointerId!==void 0&&this.dom.releasePointerCapture(e.pointerId)},cb:null,init(e,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handlePointerMove=this.handlePointerMove.bind(this),this.handlePointerDown=this.handlePointerDown.bind(this),this.destroy=it([{dom:e,evt:"pointermove",func:this.handlePointerMove},{dom:e,evt:"pointerleave",func:this.handleClear},{dom:e,evt:"pointerup",func:this.handleClear},{dom:this.dom,evt:"pointerdown",func:this.handlePointerDown}])},destroy:null,clear(){this.moved=!1,this.pointerdown=!1}}}},he="#4dc4ff";function gt(t,e,n,o,i,s,r,a){return{x:t/8+n*3/8+i*3/8+r/8,y:e/8+o*3/8+s*3/8+a/8}}function de(t,e,n){v(t,{x:e+"",y:n+""})}function j(t,e,n,o,i){v(t,{x1:e+"",y1:n+"",x2:o+"",y2:i+""})}function mt(t,e,n,o,i,s,r,a,f,d){var l;if(t.line.setAttribute("d",`M ${e} ${n} C ${o} ${i} ${s} ${r} ${a} ${f}`),d.style){const c=d.style;c.stroke&&t.line.setAttribute("stroke",c.stroke),c.strokeWidth&&t.line.setAttribute("stroke-width",String(c.strokeWidth)),c.strokeDasharray&&t.line.setAttribute("stroke-dasharray",c.strokeDasharray),c.strokeLinecap&&t.line.setAttribute("stroke-linecap",c.strokeLinecap),c.opacity!==void 0&&t.line.setAttribute("opacity",String(c.opacity))}const p=I(s,r,a,f);if(p&&(t.arrow1.setAttribute("d",`M ${p.x1} ${p.y1} L ${a} ${f} L ${p.x2} ${p.y2}`),d.style)){const c=d.style;c.stroke&&t.arrow1.setAttribute("stroke",c.stroke),c.strokeWidth&&t.arrow1.setAttribute("stroke-width",String(c.strokeWidth)),c.strokeLinecap&&t.arrow1.setAttribute("stroke-linecap",c.strokeLinecap),c.opacity!==void 0&&t.arrow1.setAttribute("opacity",String(c.opacity))}if(d.bidirectional){const c=I(o,i,e,n);if(c&&(t.arrow2.setAttribute("d",`M ${c.x1} ${c.y1} L ${e} ${n} L ${c.x2} ${c.y2}`),d.style)){const h=d.style;h.stroke&&t.arrow2.setAttribute("stroke",h.stroke),h.strokeWidth&&t.arrow2.setAttribute("stroke-width",String(h.strokeWidth)),h.strokeLinecap&&t.arrow2.setAttribute("stroke-linecap",h.strokeLinecap),h.opacity!==void 0&&t.arrow2.setAttribute("opacity",String(h.opacity))}}const{x:u,y:g}=gt(e,n,o,i,s,r,a,f);de(t.label,u,g),(l=d.style)!=null&&l.labelColor&&t.label.setAttribute("fill",d.style.labelColor),ve(t)}function z(t,e,n){const{offsetLeft:o,offsetTop:i}=A(t.nodes,e),s=e.offsetWidth,r=e.offsetHeight,a=o+s/2,f=i+r/2,d=a+n.x,p=f+n.y;return{w:s,h:r,cx:a,cy:f,ctrlX:d,ctrlY:p}}function H(t){let e,n;const o=(t.cy-t.ctrlY)/(t.ctrlX-t.cx);return o>t.h/t.w||o<-t.h/t.w?t.cy-t.ctrlY<0?(e=t.cx-t.h/2/o,n=t.cy+t.h/2):(e=t.cx+t.h/2/o,n=t.cy-t.h/2):t.cx-t.ctrlX<0?(e=t.cx+t.w/2,n=t.cy-t.w*o/2):(e=t.cx-t.w/2,n=t.cy+t.w*o/2),{x:e,y:n}}const fe=function(t,e,n,o){const i=document.createElementNS(L,"text");return v(i,{"text-anchor":"middle",x:e+"",y:n+"",fill:o||"rgb(235, 95, 82)"}),i.dataset.type="custom-link",i.innerHTML=t,i},Q=function(t,e,n,o,i){var E;if(!e||!n)return;const s=z(t,e,o.delta1),r=z(t,n,o.delta2),{x:a,y:f}=H(s),{ctrlX:d,ctrlY:p}=s,{ctrlX:u,ctrlY:g}=r,{x:l,y:c}=H(r),h=I(u,g,l,c);if(!h)return;const m=`M ${h.x1} ${h.y1} L ${l} ${c} L ${h.x2} ${h.y2}`;let w="";if(o.bidirectional){const D=I(d,p,a,f);if(!D)return;w=`M ${D.x1} ${D.y1} L ${a} ${f} L ${D.x2} ${D.y2}`}const x=Bt(`M ${a} ${f} C ${d} ${p} ${u} ${g} ${l} ${c}`,m,w,o.style),{x:y,y:b}=gt(a,f,d,p,u,g,l,c),C=(E=o.style)==null?void 0:E.labelColor,S=fe(o.label,y,b,C);x.appendChild(S),x.label=S,x.arrowObj=o,x.dataset.linkid=o.id,t.linkSvgGroup.appendChild(x),i||(t.arrows.push(o),t.currentArrow=x,wt(t,o,s,r))},pe=function(t,e,n={}){const o={id:B(),label:"Custom Link",from:t.nodeObj.id,to:e.nodeObj.id,delta1:{x:t.offsetWidth/2+100,y:0},delta2:{x:e.offsetWidth/2+100,y:0},...n};Q(this,t,e,o),this.bus.fire("operation",{name:"createArrow",obj:o})},ue=function(t){Y(this);const e={...t,id:B()};Q(this,this.findEle(e.from),this.findEle(e.to),e),this.bus.fire("operation",{name:"createArrow",obj:e})},ge=function(t){let e;if(t?e=t:e=this.currentArrow,!e)return;Y(this);const n=e.arrowObj.id;this.arrows=this.arrows.filter(o=>o.id!==n),e.remove(),this.bus.fire("operation",{name:"removeArrow",obj:{id:n}})},me=function(t){this.currentArrow=t;const e=t.arrowObj,n=this.findEle(e.from),o=this.findEle(e.to),i=z(this,n,e.delta1),s=z(this,o,e.delta2);wt(this,e,i,s)},we=function(){Y(this),this.currentArrow=null},Z=function(t,e){const n=document.createElementNS(L,"path");return v(n,{d:t,stroke:e,fill:"none","stroke-width":"6","stroke-linecap":"round","stroke-linejoin":"round"}),n},xe=function(t,e){const n=document.createElementNS(L,"g");n.setAttribute("class","arrow-highlight"),n.setAttribute("opacity","0.45");const o=Z(t.line.getAttribute("d"),e);n.appendChild(o);const i=Z(t.arrow1.getAttribute("d"),e);if(n.appendChild(i),t.arrow2.getAttribute("d")){const s=Z(t.arrow2.getAttribute("d"),e);n.appendChild(s)}t.insertBefore(n,t.firstChild)},ye=function(t){const e=t.querySelector(".arrow-highlight");e&&e.remove()},ve=function(t){const e=t.querySelector(".arrow-highlight");if(!e)return;const n=e.querySelectorAll("path");n.length>=1&&n[0].setAttribute("d",t.line.getAttribute("d")),n.length>=2&&n[1].setAttribute("d",t.arrow1.getAttribute("d")),n.length>=3&&t.arrow2.getAttribute("d")&&n[2].setAttribute("d",t.arrow2.getAttribute("d"))},Y=function(t){var e,n;(e=t.helper1)==null||e.destroy(),(n=t.helper2)==null||n.destroy(),t.linkController.style.display="none",t.P2.style.display="none",t.P3.style.display="none",t.currentArrow&&ye(t.currentArrow)},wt=function(t,e,n,o){const{linkController:i,P2:s,P3:r,line1:a,line2:f,nodes:d,map:p,currentArrow:u,bus:g}=t;if(!u)return;i.style.display="initial",s.style.display="initial",r.style.display="initial",d.appendChild(i),d.appendChild(s),d.appendChild(r),xe(u,he);let{x:l,y:c}=H(n),{ctrlX:h,ctrlY:m}=n,{ctrlX:w,ctrlY:x}=o,{x:y,y:b}=H(o);s.style.cssText=`top:${m}px;left:${h}px;`,r.style.cssText=`top:${x}px;left:${w}px;`,j(a,l,c,h,m),j(f,w,x,y,b),t.helper1=ut.create(s),t.helper2=ut.create(r),t.helper1.init(p,(C,S)=>{h=h+C/t.scaleVal,m=m+S/t.scaleVal;const E=H({...n,ctrlX:h,ctrlY:m});l=E.x,c=E.y,s.style.top=m+"px",s.style.left=h+"px",mt(u,l,c,h,m,w,x,y,b,e),j(a,l,c,h,m),e.delta1.x=h-n.cx,e.delta1.y=m-n.cy,g.fire("updateArrowDelta",e)}),t.helper2.init(p,(C,S)=>{w=w+C/t.scaleVal,x=x+S/t.scaleVal;const E=H({...o,ctrlX:w,ctrlY:x});y=E.x,b=E.y,r.style.top=x+"px",r.style.left=w+"px",mt(u,l,c,h,m,w,x,y,b,e),j(f,w,x,y,b),e.delta2.x=w-o.cx,e.delta2.y=x-o.cy,g.fire("updateArrowDelta",e)})};function be(){this.linkSvgGroup.innerHTML="";for(let t=0;t<this.arrows.length;t++){const e=this.arrows[t];try{Q(this,this.findEle(e.from),this.findEle(e.to),e,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function Ce(t){if(Y(this),!t)return;const e=t.label;dt(this,e,t.arrowObj)}function Se(){this.arrows=this.arrows.filter(t=>G(t.from,this.nodeData)&&G(t.to,this.nodeData))}const Ee=Object.freeze(Object.defineProperty({__proto__:null,createArrow:pe,createArrowFrom:ue,editArrowLabel:Ce,removeArrow:ge,renderArrow:be,selectArrow:me,tidyArrow:Se,unselectArrow:we},Symbol.toStringTag,{value:"Module"})),Le=function(t){var f,d;if(t.length===0)throw new Error("No selected node.");if(t.length===1){const p=t[0].nodeObj,u=t[0].nodeObj.parent;if(!u)throw new Error("Can not select root node.");const g=u.children.findIndex(l=>p===l);return{parent:u.id,start:g,end:g}}let e=0;const n=t.map(p=>{let u=p.nodeObj;const g=[];for(;u.parent;){const l=u.parent,c=l.children,h=c==null?void 0:c.indexOf(u);u=l,g.unshift({node:u,index:h})}return g.length>e&&(e=g.length),g});let o=0;t:for(;o<e;o++){const p=(f=n[0][o])==null?void 0:f.node;for(let u=1;u<n.length;u++)if(((d=n[u][o])==null?void 0:d.node)!==p)break t}if(!o)throw new Error("Can not select root node.");const i=n.map(p=>p[o-1].index).sort(),s=i[0]||0,r=i[i.length-1]||0,a=n[0][o-1].node;if(!a.parent)throw new Error("Please select nodes in the same main topic.");return{parent:a.id,start:s,end:r}},Te=function(t){const e=document.createElementNS(L,"g");return e.setAttribute("id",t),e},xt=function(t,e){const n=document.createElementNS(L,"path");return v(n,{d:t,stroke:e||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},yt=function(t,e,n,o,i){const s=document.createElementNS(L,"text");return v(s,{"text-anchor":o,x:e+"",y:n+"",fill:i||"#666"}),s.innerHTML=t,s},ke=t=>t.parentElement.parentElement,$e=function(t,{parent:e,start:n}){const o=t.findEle(e),i=o.nodeObj;let s;return i.parent?s=o.closest("me-main").className:s=t.findEle(i.children[n].id).closest("me-main").className,s},tt=function(t,e){var D;const{id:n,label:o,parent:i,start:s,end:r}=e,{nodes:a,theme:f,summarySvg:d}=t,u=t.findEle(i).nodeObj,g=$e(t,e);let l=1/0,c=0,h=0,m=0;for(let W=s;W<=r;W++){const vt=(D=u.children)==null?void 0:D[W];if(!vt)return t.removeSummary(n),null;const q=ke(t.findEle(vt.id)),{offsetLeft:_,offsetTop:bt}=A(a,q),Ct=s===r?10:20;W===s&&(h=bt+Ct),W===r&&(m=bt+q.offsetHeight-Ct),_<l&&(l=_),q.offsetWidth+_>c&&(c=q.offsetWidth+_)}let w,x;const y=h+10,b=m+10,C=(y+b)/2,S=f.cssVar["--color"];g===M.LHS?(w=xt(`M ${l+10} ${y} c -5 0 -10 5 -10 10 L ${l} ${b-10} c 0 5 5 10 10 10 M ${l} ${C} h -10`,S),x=yt(o,l-20,C+6,"end",S)):(w=xt(`M ${c-10} ${y} c 5 0 10 5 10 10 L ${c} ${b-10} c 0 5 -5 10 -10 10 M ${c} ${C} h 10`,S),x=yt(o,c+20,C+6,"start",S));const E=Te("s-"+n);return E.appendChild(w),E.appendChild(x),E.summaryObj=e,d.appendChild(E),E},Ae=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){if(!this.currentNodes)return;const{currentNodes:t,summaries:e,bus:n}=this,{parent:o,start:i,end:s}=Le(t),r={id:B(),parent:o,start:i,end:s,label:"summary"},a=tt(this,r);e.push(r),this.editSummary(a),n.fire("operation",{name:"createSummary",obj:r})},createSummaryFrom:function(t){const e=B(),n={...t,id:e};tt(this,n),this.summaries.push(n),this.bus.fire("operation",{name:"createSummary",obj:n})},editSummary:function(t){if(!t)return;const e=t.childNodes[1];dt(this,e,t.summaryObj)},removeSummary:function(t){var n;const e=this.summaries.findIndex(o=>o.id===t);e>-1&&(this.summaries.splice(e,1),(n=document.querySelector("#s-"+t))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:t}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(t=>{try{tt(this,t)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(t){const e=t.children[1].getBBox(),n=6,o=3,i=document.createElementNS(L,"rect");v(i,{x:e.x-n+"",y:e.y-n+"",width:e.width+n*2+"",height:e.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),t.appendChild(i),this.currentSummary=t},unselectSummary:function(){var t,e;(e=(t=this.currentSummary)==null?void 0:t.querySelector("rect"))==null||e.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"})),T="http://www.w3.org/2000/svg";function De(t,e){const n=document.createElementNS(T,"svg");return v(n,{version:"1.1",xmlns:T,height:t,width:e}),n}function Me(t,e){return(parseInt(t)-parseInt(e))/2}function Ne(t,e,n,o){const i=document.createElementNS(T,"g");let s="";return t.text?s=t.text.textContent:s=t.childNodes[0].textContent,s.split(`
`).forEach((a,f)=>{const d=document.createElementNS(T,"text");v(d,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+Me(e.lineHeight,e.fontSize)*(f+1)+parseFloat(e.fontSize)*(f+1)+"","text-anchor":"start","font-family":e.fontFamily,"font-size":`${e.fontSize}`,"font-weight":`${e.fontWeight}`,fill:`${e.color}`}),d.innerHTML=a,i.appendChild(d)}),i}function Pe(t,e,n,o){var a;let i="";(a=t.nodeObj)!=null&&a.dangerouslySetInnerHTML?i=t.nodeObj.dangerouslySetInnerHTML:t.text?i=t.text.textContent:i=t.childNodes[0].textContent;const s=document.createElementNS(T,"foreignObject");v(s,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+"",width:e.width,height:e.height});const r=document.createElement("div");return v(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`}),r.innerHTML=i,s.appendChild(r),s}function He(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:i}=A(t.nodes,e),s=document.createElementNS(T,"rect");return v(s,{x:o+"",y:i+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),s}function R(t,e,n=!1){const o=getComputedStyle(e),{offsetLeft:i,offsetTop:s}=A(t.nodes,e),r=document.createElementNS(T,"rect");v(r,{x:i+"",y:s+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const a=document.createElementNS(T,"g");a.appendChild(r);let f;return n?f=Pe(e,o,i,s):f=Ne(e,o,i,s),a.appendChild(f),a}function Be(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:i}=A(t.nodes,e),s=document.createElementNS(T,"a"),r=document.createElementNS(T,"text");return v(r,{x:o+"",y:i+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=e.textContent,s.appendChild(r),s.setAttribute("href",e.href),s}function Oe(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:i}=A(t.nodes,e),s=document.createElementNS(T,"image");return v(s,{x:o+"",y:i+"",width:n.width+"",height:n.height+"",href:e.src}),s}const X=100,Ve='<?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">',We=(t,e=!1)=>{var u,g,l;const n=t.nodes,o=n.offsetHeight+X*2,i=n.offsetWidth+X*2,s=De(o+"px",i+"px"),r=document.createElementNS(T,"svg"),a=document.createElementNS(T,"rect");v(a,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:t.theme.cssVar["--bgcolor"]}),s.appendChild(a),n.querySelectorAll(".subLines").forEach(c=>{const h=c.cloneNode(!0),{offsetLeft:m,offsetTop:w}=A(n,c.parentElement);h.setAttribute("x",`${m}`),h.setAttribute("y",`${w}`),r.appendChild(h)});const f=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);f&&r.appendChild(f);const d=(g=n.querySelector(".topiclinks"))==null?void 0:g.cloneNode(!0);d&&r.appendChild(d);const p=(l=n.querySelector(".summary"))==null?void 0:l.cloneNode(!0);return p&&r.appendChild(p),n.querySelectorAll("me-tpc").forEach(c=>{c.nodeObj.dangerouslySetInnerHTML?r.appendChild(R(t,c,!e)):(r.appendChild(He(t,c)),r.appendChild(R(t,c.text,!e)))}),n.querySelectorAll(".tags > span").forEach(c=>{r.appendChild(R(t,c))}),n.querySelectorAll(".icons > span").forEach(c=>{r.appendChild(R(t,c))}),n.querySelectorAll(".hyper-link").forEach(c=>{r.appendChild(Be(t,c))}),n.querySelectorAll("img").forEach(c=>{r.appendChild(Oe(t,c))}),v(r,{x:X+"",y:X+"",overflow:"visible"}),s.appendChild(r),s},Ge=(t,e)=>(e&&t.insertAdjacentHTML("afterbegin","<style>"+e+"</style>"),Ve+t.outerHTML);function Ie(t){return new Promise((e,n)=>{const o=new FileReader;o.onload=i=>{e(i.target.result)},o.onerror=i=>{n(i)},o.readAsDataURL(t)})}const Fe={getObjById:G,generateNewObj:St,layout:Tt,linkDiv:Ot,editTopic:Pt,createWrapper:At,createParent:Dt,createChildren:Mt,createTopic:Nt,findEle:rt,changeTheme:_t,...ae,...{},...Ee,...Ae,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(t=!1,e){const n=this.exportSvg(t,e),o=await Ie(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const a=document.createElement("canvas");a.width=r.width,a.height=r.height,a.getContext("2d").drawImage(r,0,0),a.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(t=!1,e){const n=We(this,t),o=Ge(n,e);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),init(t){if(t=JSON.parse(JSON.stringify(t)),!t||!t.nodeData)return new Error("MindElixir: `data` is required");t.direction!==void 0&&(this.direction=t.direction),this.changeTheme(t.theme||this.theme,!1),this.nodeData=t.nodeData,J(this.nodeData),this.arrows=t.arrows||[],this.summaries=t.summaries||[],this.tidyArrow(),this.toolBar&&qt(this),this.layout(),this.linkDiv(),this.toCenter()},destroy(){var t;this.disposable.forEach(e=>e()),this.el&&(this.el.innerHTML=""),this.el=void 0,this.nodeData=void 0,this.arrows=void 0,this.summaries=void 0,this.currentArrow=void 0,this.currentNodes=void 0,this.currentSummary=void 0,this.waitCopy=void 0,this.theme=void 0,this.direction=void 0,this.bus=void 0,this.container=void 0,this.map=void 0,this.lines=void 0,this.linkController=void 0,this.linkSvgGroup=void 0,this.P2=void 0,this.P3=void 0,this.line1=void 0,this.line2=void 0,this.nodes=void 0,(t=this.selection)==null||t.destroy(),this.selection=void 0}};function je({pT:t,pL:e,pW:n,pH:o,cT:i,cL:s,cW:r,cH:a,direction:f,containerHeight:d}){let p=e+n/2;const u=t+o/2;let g;f===M.LHS?g=s+r:g=s;const l=i+a/2,h=(1-Math.abs(l-u)/d)*.25*(n/2);return f===M.LHS?p=p-n/10-h:p=p+n/10+h,`M ${p} ${u} Q ${p} ${l} ${g} ${l}`}function ze({pT:t,pL:e,pW:n,pH:o,cT:i,cL:s,cW:r,cH:a,direction:f,isFirst:d}){const p=parseInt(this.container.style.getPropertyValue("--node-gap-x"));let u=0,g=0;d?u=t+o/2:u=t+o;const l=i+a;let c=0,h=0,m=0;const w=Math.abs(u-l)/300*p;return f===M.LHS?(m=e,c=m+p,h=m-p,g=s+p,`M ${c} ${u} C ${m} ${u} ${m+w} ${l} ${h} ${l} H ${g}`):(m=e+n,c=m-p,h=m+p,g=s+r-p,`M ${c} ${u} C ${m} ${u} ${m-w} ${l} ${h} ${l} H ${g}`)}const Ye="5.0.2";function Re(t){return{x:0,y:0,moved:!1,mousedown:!1,onMove(e,n){this.mousedown&&(this.moved=!0,t.move(e,n))},clear(){this.mousedown=!1,t.map.style.transition="transform 0.3s"}}}const V=document;function $({el:t,direction:e,locale:n,draggable:o,editable:i,contextMenu:s,toolBar:r,keypress:a,mouseSelectionButton:f,selectionContainer:d,before:p,newTopicName:u,allowUndo:g,generateMainBranch:l,generateSubBranch:c,overflowHidden:h,theme:m,alignment:w,scaleSensitivity:x}){let y=null;const b=Object.prototype.toString.call(t);if(b==="[object HTMLDivElement]"?y=t:b==="[object String]"&&(y=document.querySelector(t)),!y)throw new Error("MindElixir: el is not a valid element");y.style.position="relative",y.innerHTML="",this.el=y,this.disposable=[],this.before=p||{},this.locale=n||"en",this.contextMenu=s===void 0?!0:s,this.toolBar=r===void 0?!0:r,this.keypress=a===void 0?!0:a,this.mouseSelectionButton=f||0,this.direction=typeof e=="number"?e:1,this.draggable=o===void 0?!0:o,this.newTopicName=u||"new node",this.editable=i===void 0?!0:i,this.allowUndo=g===void 0?!1:g,this.scaleSensitivity=typeof x=="number"?x:.2,this.currentNodes=[],this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=l||je,this.generateSubBranch=c||ze,this.overflowHidden=h||!1,this.dragMoveHelper=Re(this),this.bus=Lt(),this.container=V.createElement("div"),this.selectionContainer=d||this.container,this.container.className="map-container";const C=window.matchMedia("(prefers-color-scheme: dark)");this.theme=m||(C.matches?K:U);const S=V.createElement("div");S.className="map-canvas",setTimeout(()=>{S.style.transition="all 0.3s"},300),this.map=S,this.container.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.el.appendChild(this.container),this.nodes=V.createElement("me-nodes"),this.lines=O("lines"),this.summarySvg=O("summary"),this.linkController=O("linkcontroller"),this.P2=V.createElement("div"),this.P3=V.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=ht(),this.line2=ht(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=O("topiclinks"),this.alignment=w??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":this.disposable.push(Et(this))}return $.prototype=Fe,Object.defineProperty($.prototype,"currentNode",{get(){return this.currentNodes[this.currentNodes.length-1]},enumerable:!0}),$.LEFT=0,$.RIGHT=1,$.SIDE=2,$.THEME=U,$.DARK_THEME=K,$.version=Ye,$.E=rt,$}();