(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".mind-elixir{--gap: 30px;--root-radius: 30px;--main-radius: 20px;--root-color: #ffffff;--root-bgcolor: #4c4f69;--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;position:relative;-webkit-tap-highlight-color:rgba(0,0,0,0);font-family:-apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}.mind-elixir .hyper-link{text-decoration:none;margin-left:.3em}.map-container{-webkit-user-select:none;user-select:none;height:100%;width:100%;overflow:scroll;font-size:15px}.map-container::-webkit-scrollbar{width:0px;height:0px}.map-container .selected{box-shadow:0 0 0 2px var(--selected)}.map-container .lhs{direction:rtl}.map-container .lhs me-tpc{direction:ltr}.map-container .map-canvas{height:20000px;width:20000px;position:relative;-webkit-user-select:none;user-select:none;transition:transform .3s;transform:scale(1);background-color:var(--bgcolor)}.map-container .map-canvas me-nodes{position:absolute;display:flex;justify-content:center;align-items:center;height:fit-content;width:fit-content}.map-container .map-canvas me-root{position:relative}.map-container .map-canvas me-root me-tpc{display:block;font-size:25px;line-height:1.2em;color:var(--root-color);padding:10px var(--gap);border-radius:var(--root-radius);white-space:pre-wrap;background-color:var(--root-bgcolor)}.map-container .map-canvas me-root me-tpc #input-box{padding:10px var(--gap)}.map-container me-main>me-wrapper{position:relative;margin:20px 65px}.map-container me-main>me-wrapper>me-parent{margin:var(--gap);padding:0}.map-container me-main>me-wrapper>me-parent>me-tpc{border-radius:var(--main-radius);background-color:var(--main-bgcolor);border:2px solid var(--main-color);color:var(--main-color);padding:8px var(--gap)}.map-container me-main>me-wrapper>me-parent>me-tpc #input-box{padding:8px var(--gap)}.map-container me-wrapper{display:block;pointer-events:none;width:fit-content}.map-container me-children,.map-container me-parent{display:inline-block;vertical-align:middle}.map-container me-parent{position:relative;cursor:pointer;padding:6px var(--gap);margin-top:10px}.map-container me-parent me-tpc{position:relative;display:block;border-radius:3px;color:var(--color);pointer-events:all;max-width:35em;white-space:pre-wrap;padding:var(--topic-padding);line-height:1.2em}.map-container me-parent me-tpc .insert-preview{position:absolute;width:100%;left:0;z-index:9}.map-container me-parent me-tpc .show{background:#7ad5ff;pointer-events:none;opacity:.7}.map-container me-parent me-tpc .before{height:14px;top:-14px}.map-container me-parent me-tpc .in{height:100%;top:0}.map-container me-parent me-tpc .after{height:14px;bottom:-14px}.map-container me-parent me-epd{position:absolute;height:18px;width:18px;opacity:.8;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdD0iMTY1NjY1NDcxNzI0MiIgY2xhc3M9Imljb24iIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIKICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+CiAgICA8cGF0aCBkPSJNNTEyIDc0LjY2NjY2N0MyNzAuOTMzMzMzIDc0LjY2NjY2NyA3NC42NjY2NjcgMjcwLjkzMzMzMyA3NC42NjY2NjcgNTEyUzI3MC45MzMzMzMgOTQ5LjMzMzMzMyA1MTIgOTQ5LjMzMzMzMyA5NDkuMzMzMzMzIDc1My4wNjY2NjcgOTQ5LjMzMzMzMyA1MTIgNzUzLjA2NjY2NyA3NC42NjY2NjcgNTEyIDc0LjY2NjY2N3oiIHN0cm9rZS13aWR0aD0iNTQiIHN0cm9rZT0nYmxhY2snIGZpbGw9J3doaXRlJyA+PC9wYXRoPgogICAgPHBhdGggZD0iTTY4Mi42NjY2NjcgNDgwaC0xMzguNjY2NjY3VjM0MS4zMzMzMzNjMC0xNy4wNjY2NjctMTQuOTMzMzMzLTMyLTMyLTMycy0zMiAxNC45MzMzMzMtMzIgMzJ2MTM4LjY2NjY2N0gzNDEuMzMzMzMzYy0xNy4wNjY2NjcgMC0zMiAxNC45MzMzMzMtMzIgMzJzMTQuOTMzMzMzIDMyIDMyIDMyaDEzOC42NjY2NjdWNjgyLjY2NjY2N2MwIDE3LjA2NjY2NyAxNC45MzMzMzMgMzIgMzIgMzJzMzItMTQuOTMzMzMzIDMyLTMydi0xMzguNjY2NjY3SDY4Mi42NjY2NjdjMTcuMDY2NjY3IDAgMzItMTQuOTMzMzMzIDMyLTMycy0xNC45MzMzMzMtMzItMzItMzJ6Ij48L3BhdGg+Cjwvc3ZnPg==);background-repeat:no-repeat;background-size:contain;background-position:center;pointer-events:all;z-index:9}.map-container me-parent me-epd.minus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdD0iMTY1NjY1NTU2NDk4NSIgY2xhc3M9Imljb24iIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIKICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+CiAgICA8cGF0aCBkPSJNNTEyIDc0LjY2NjY2N0MyNzAuOTMzMzMzIDc0LjY2NjY2NyA3NC42NjY2NjcgMjcwLjkzMzMzMyA3NC42NjY2NjcgNTEyUzI3MC45MzMzMzMgOTQ5LjMzMzMzMyA1MTIgOTQ5LjMzMzMzMyA5NDkuMzMzMzMzIDc1My4wNjY2NjcgOTQ5LjMzMzMzMyA1MTIgNzUzLjA2NjY2NyA3NC42NjY2NjcgNTEyIDc0LjY2NjY2N3oiIHN0cm9rZS13aWR0aD0iNTQiIHN0cm9rZT0nYmxhY2snIGZpbGw9J3doaXRlJyA+PC9wYXRoPgogICAgPHBhdGggZD0iTTY4Mi42NjY2NjcgNTQ0SDM0MS4zMzMzMzNjLTE3LjA2NjY2NyAwLTMyLTE0LjkzMzMzMy0zMi0zMnMxNC45MzMzMzMtMzIgMzItMzJoMzQxLjMzMzMzNGMxNy4wNjY2NjcgMCAzMiAxNC45MzMzMzMgMzIgMzJzLTE0LjkzMzMzMyAzMi0zMiAzMnoiPjwvcGF0aD4KPC9zdmc+)!important;transition:opacity .3s;opacity:0}.map-container me-parent me-epd.minus:hover{opacity:.8}.map-container .icon{width:1em;height:1em;vertical-align:-.15em;fill:currentColor;overflow:hidden}.map-container .lines,.map-container .summary,.map-container .subLines,.map-container .topiclinks,.map-container .linkcontroller{position:absolute;height:102%;width:100%;top:0;left:0}.map-container .topiclinks,.map-container .linkcontroller,.map-container .summary{pointer-events:none}.map-container .topiclinks text,.map-container .linkcontroller text,.map-container .summary text{pointer-events:all}.map-container .topiclinks .selected,.map-container .linkcontroller .selected,.map-container .summary .selected{pointer-events:none}.map-container .lines,.map-container .subLines{pointer-events:none;z-index:-1}.map-container .topiclinks *,.map-container .linkcontroller *{z-index:100}.map-container .topiclinks g{cursor:pointer}.map-container #input-box{position:absolute;top:0;left:0;padding:var(--topic-padding);color:var(--color);background-color:var(--bgcolor);width:max-content;max-width:35em;z-index:11;direction:ltr;-webkit-user-select:auto;user-select:auto;pointer-events:all}.map-container me-tpc>div,.map-container me-tpc>span,.map-container me-tpc>img{pointer-events:none}.map-container me-tpc>img{display:block;margin-bottom:8px;object-fit:cover}.map-container me-tpc>.text{display:inline-block}.map-container .circle{position:absolute;height:10px;width:10px;margin-top:-5px;margin-left:-5px;border-radius:100%;background:#757575;border:2px solid #ffffff;cursor:pointer}.map-container .tags{direction:ltr}.map-container .tags span{display:inline-block;border-radius:3px;padding:2px 4px;background:#d6f0f8;color:#276f86;margin:2px 3px 0 0;font-size:12px;line-height:1.3em}.map-container .icons{display:inline-block;direction:ltr;margin-right:10px}.map-container .icons span{display:inline-block}.map-container .mind-elixir-ghost{position:fixed;top:-100%;left:-100%;box-sizing:content-box;opacity:.5;background-color:#f6f6f6;max-width:200px;width:fit-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding:8px 16px;border-radius:6px;border:#666666 2px solid}.map-container .selection-area{background:#4f90f22d;border:1px solid #4f90f2}.mind-elixir .context-menu{position:fixed;top:0;left:0;width:100%;height:100%;z-index:99}.mind-elixir .context-menu .menu-list{position:fixed;list-style:none;margin:0;padding:0;font:300 15px Roboto,sans-serif;color:var(--panel-color);box-shadow:0 12px 15px #0003}.mind-elixir .context-menu .menu-list li{min-width:200px;overflow:hidden;white-space:nowrap;padding:10px 14px;background:var(--panel-bgcolor);border-bottom:1px solid var(--panel-border-color)}.mind-elixir .context-menu .menu-list li a{color:#333;text-decoration:none}.mind-elixir .context-menu .menu-list li.disabled{display:none;color:#5e5e5e;background-color:#f7f7f7}.mind-elixir .context-menu .menu-list li.disabled:hover{cursor:default;background-color:#f7f7f7}.mind-elixir .context-menu .menu-list li:hover{cursor:pointer;filter:brightness(.9)}.mind-elixir .context-menu .menu-list li:first-child{border-radius:5px 5px 0 0}.mind-elixir .context-menu .menu-list li:last-child{border-bottom:0;border-radius:0 0 5px 5px}.mind-elixir .context-menu .menu-list li span:last-child{float:right}.mind-elixir .tips{position:absolute;bottom:20px;left:50%;transform:translate(-50%);color:var(--panel-color);font-weight:bolder}.mind-elixir .mobile-menu{position:absolute;left:20px;bottom:70px;z-index:99;margin:0;padding:0;color:#333;border-radius:5px;box-shadow:0 12px 15px #0003;overflow:hidden}.mind-elixir .mobile-menu *{transition:color .4s,background-color .4s}.mind-elixir .mobile-menu div{float:left;text-align:center;width:30px;overflow:hidden;white-space:nowrap;padding:8px;background-color:#fff;border-bottom:1px solid #ecf0f1}.mind-elixir .mobile-menu div a{color:#333;text-decoration:none}.mind-elixir .mobile-menu div.disabled{color:#5e5e5e;background-color:#f7f7f7}.mind-elixir .mobile-menu div.disabled:hover{cursor:default;background-color:#f7f7f7}.mind-elixir .mobile-menu div:hover{cursor:pointer;background-color:#ecf0f1}.mind-elixir-toolbar{font-family:iconfont;position:absolute;color:var(--panel-color);background:var(--panel-bgcolor);padding:10px;border-radius:5px;box-shadow:0 1px 2px #0003}.mind-elixir-toolbar svg{display:inline-block}.mind-elixir-toolbar span:active{opacity:.5}.mind-elixir-toolbar.rb{right:20px;bottom:20px}.mind-elixir-toolbar.rb span+span{margin-left:10px}.mind-elixir-toolbar.lt{font-size:20px;left:20px;top:20px}.mind-elixir-toolbar.lt span{display:block}.mind-elixir-toolbar.lt span+span{margin-top:10px}")),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})(); var MindElixir=function(){"use strict";const yn="";(function(e){var t,n,o,i,s,r,l='',c=(c=document.getElementsByTagName("script"))[c.length-1].getAttribute("data-injectcss");if(c&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}function h(){s||(s=!0,o())}t=function(){var a,u,d,p;(p=document.createElement("div")).innerHTML=l,l=null,(d=p.getElementsByTagName("svg")[0])&&(d.setAttribute("aria-hidden","true"),d.style.position="absolute",d.style.width=0,d.style.height=0,d.style.overflow="hidden",a=d,(u=document.body).firstChild?(p=a,(d=u.firstChild).parentNode.insertBefore(p,d)):u.appendChild(a))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(n=function(){document.removeEventListener("DOMContentLoaded",n,!1),t()},document.addEventListener("DOMContentLoaded",n,!1)):document.attachEvent&&(o=t,i=e.document,s=!1,(r=function(){try{i.documentElement.doScroll("left")}catch{return void setTimeout(r,50)}h()})(),i.onreadystatechange=function(){i.readyState=="complete"&&(i.onreadystatechange=null,h())})})(window);const k=0,P=1,U=2,T=30,$=8,fe={name:"Latte",palette:["#dd7878","#ea76cb","#8839ef","#e64553","#fe640b","#df8e1d","#40a02b","#209fb5","#1e66f5","#7287fd"],cssVar:{"--main-color":"#444446","--main-bgcolor":"#ffffff","--color":"#777777","--bgcolor":"#f6f6f6","--panel-color":"#444446","--panel-bgcolor":"#ffffff","--panel-border-color":"#eaeaea"}},pe={name:"Dark",palette:["#848FA0","#748BE9","#D2F9FE","#4145A5","#789AFA","#706CF4","#EF987F","#775DD5","#FCEECF","#DA7FBC"],cssVar:{"--main-color":"#ffffff","--main-bgcolor":"#4c4f69","--color":"#cccccc","--bgcolor":"#252526","--panel-color":"#ffffff","--panel-bgcolor":"#2d3748","--panel-border-color":"#696969"}};function Z(e){return e.replace(/&/g,"&").replace(//Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ee=function(e,t){if(t.id===e)return t;if(t.children&&t.children.length){for(let n=0;n{if(e.parent=t,e.children)for(let n=0;n{let n=Date.now();return function(...o){Date.now()-n>=t&&(e(...o),n=Date.now())}};function ge(e,t,n,o){const i=o-t,s=e-n;let r=Math.atan(Math.abs(i)/Math.abs(s))/3.14*180;s<0&&i>0&&(r=180-r),s<0&&i<0&&(r=180+r),s>0&&i<0&&(r=360-r);const l=15,c=30,h=r+c,a=r-c;return{x1:n+Math.cos(Math.PI*h/180)*l,y1:o-Math.sin(Math.PI*h/180)*l,x2:n+Math.cos(Math.PI*a/180)*l,y2:o-Math.sin(Math.PI*a/180)*l}}function Y(){return(new Date().getTime().toString(16)+Math.random().toString(16).substr(2)).substr(2,16)}const Xe=function(){const e=Y();return{topic:this.newTopicName,id:e}};function Je(e,t){let n=!0;for(;t.parent;){if(t.parent===e){n=!1;break}t=t.parent}return n}function ve(e){return JSON.parse(JSON.stringify(e,(n,o)=>{if(n!=="parent")return o}))}const V=(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}},C=(e,t)=>{for(const n in t)e.setAttribute(n,t[n])},ce=e=>e?e.tagName==="ME-TPC":!1,L={moved:!1,mousedown:!1,onMove(e,t){if(this.mousedown){this.moved=!0;const n=e.movementX,o=e.movementY;t.scrollTo(t.scrollLeft-n,t.scrollTop-o)}},clear(){this.moved=!1,this.mousedown=!1}};function Qe(e){e.map.addEventListener("click",t=>{var o,i;if(t.button!==0)return;if((o=e.helper1)!=null&&o.moved){e.helper1.clear();return}if((i=e.helper2)!=null&&i.moved){e.helper2.clear();return}if(L.moved){L.clear();return}e.unselectNode(),e.unselectNodes(),e.unselectSummary(),e.unselectLink();const n=t.target;if(n.tagName==="ME-EPD")e.expandNode(n.previousSibling);else if(e.editable)ce(n)?e.selectNode(n,!1,t):n.tagName==="text"?n.dataset.type==="custom-link"?e.selectLink(n.parentElement):e.selectSummary(n.parentElement):n.className==="circle"||e.hideLinkController&&e.hideLinkController();else return}),e.map.addEventListener("dblclick",t=>{if(t.preventDefault(),!e.editable)return;const n=t.target;ce(n)?e.beginEdit(n):n.tagName==="text"&&(n.dataset.type==="custom-link"?e.editCutsomLinkLabel(n.parentElement):e.editSummary(n.parentElement))}),e.map.addEventListener("mousemove",t=>{t.target.contentEditable!=="true"&&L.onMove(t,e.container)}),e.map.addEventListener("mousedown",t=>{const n=e.mouseSelectionButton===0?2:0;t.button===n&&t.target.contentEditable!=="true"&&(L.moved=!1,L.mousedown=!0)}),e.map.addEventListener("mouseleave",t=>{const n=e.mouseSelectionButton===0?2:0;t.button===n&&L.clear()}),e.map.addEventListener("mouseup",t=>{const n=e.mouseSelectionButton===0?2:0;t.button===n&&L.clear()}),e.map.addEventListener("contextmenu",t=>{t.preventDefault()})}const Ze={create(){return{handlers:{},showHandler:function(){console.log(this.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{s.direction===k?o+=1:s.direction===P?i+=1:o<=i?(s.direction=k,o+=1):(s.direction=P,i+=1)})}tt(this,n,t),console.timeEnd("layout")},tt=function(e,t,n){const o=te.createElement("me-main");o.className="lhs";const i=te.createElement("me-main");i.className="rhs";for(let s=0;s{const o=(t?t.mindElixirBox:S).querySelector(`[data-nodeid=me${e}]`);if(!o)throw new Error(`FindEle: Node ${e} not found, maybe it's collapsed.`);return o},ae=function(e,t){if(e.innerHTML="",t.style&&(e.style.color=t.style.color||"",e.style.background=t.style.background||"",e.style.fontSize=t.style.fontSize+"px",e.style.fontWeight=t.style.fontWeight||"normal"),t.branchColor&&(e.style.borderColor=t.branchColor),t.image){const n=t.image;if(n.url&&n.width&&n.height){const o=S.createElement("img");o.src=n.url,o.style.width=n.width+"px",o.style.height=n.height+"px",e.appendChild(o),e.image=o}else console.warn("image url/width/height are required")}else e.image&&(e.image=void 0);{const n=S.createElement("span");n.className="text",n.textContent=t.topic,e.appendChild(n),e.text=n}if(t.hyperLink){const n=S.createElement("a");n.className="hyper-link",n.target="_blank",n.innerText="🔗",n.href=t.hyperLink,e.appendChild(n),e.linkContainer=n}else e.linkContainer&&(e.linkContainer=void 0);if(t.icons&&t.icons.length){const n=S.createElement("span");n.className="icons",n.innerHTML=t.icons.map(o=>`${Z(o)}`).join(""),e.appendChild(n),e.icons=n}else e.icons&&(e.icons=void 0);if(t.tags&&t.tags.length){const n=S.createElement("div");n.className="tags",n.innerHTML=t.tags.map(o=>`${Z(o)}`).join(""),e.appendChild(n),e.tags=n}else e.tags&&(e.tags=void 0)},ot=function(e,t){const n=S.createElement("me-wrapper"),{p:o,tpc:i}=this.createParent(e);if(n.appendChild(o),!t&&e.children&&e.children.length>0){const s=ne(e.expanded);if(o.appendChild(s),e.expanded!==!1){const r=nt(this,e.children);n.appendChild(r)}}return{grp:n,top:o,tpc:i}},it=function(e){const t=S.createElement("me-parent"),n=this.createTopic(e);return ae(n,e),t.appendChild(n),{p:t,tpc:n}},st=function(e){const t=S.createElement("me-children");return t.append(...e),t},rt=function(e){const t=S.createElement("me-tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t.draggable=this.draggable,t};function be(e){const t=S.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const lt=function(e){if(console.time("editTopic"),!e)return;const t=S.createElement("div"),n=e.text.textContent;e.appendChild(t),t.id="input-box",t.textContent=n,t.contentEditable="true",t.spellcheck=!1,t.style.cssText=`min-width:${e.offsetWidth-8}px;`,this.direction===k&&(t.style.right="0"),t.focus(),be(t),this.bus.fire("operation",{name:"beginEdit",obj:e.nodeObj}),t.addEventListener("keydown",o=>{o.stopPropagation();const i=o.key;if(i==="Enter"||i==="Tab"){if(o.shiftKey)return;o.preventDefault(),t==null||t.blur(),this.map.focus()}}),t.addEventListener("blur",()=>{var s;if(!t)return;const o=e.nodeObj,i=((s=t.textContent)==null?void 0:s.trim())||"";console.log(i),i===""?o.topic=n:o.topic=i,t.remove(),i!==n&&(e.text.textContent=o.topic,this.linkDiv(),this.bus.fire("operation",{name:"finishEdit",obj:o,origin:n}))}),console.timeEnd("editTopic")},ne=function(e){const t=S.createElement("me-epd");return t.expanded=e!==!1,t.className=e!==!1?"minus":"",t},H=document,B="http://www.w3.org/2000/svg",ct=function(e,t){const n=H.createElementNS(B,"path");return n.setAttribute("d",e),n.setAttribute("stroke",t||"#666"),n.setAttribute("fill","none"),n.setAttribute("stroke-width","3"),n},G=function(e){const t=H.createElementNS(B,"svg");return t.setAttribute("class",e),t.setAttribute("overflow","visible"),t},ye=function(){const e=H.createElementNS(B,"line");return e.setAttribute("stroke","#bbb"),e.setAttribute("fill","none"),e.setAttribute("stroke-width","2"),e},at=function(e,t){const n=H.createElementNS(B,"path");return n.setAttribute("d",e),n.setAttribute("stroke",t||"#555"),n.setAttribute("fill","none"),n.setAttribute("stroke-linecap","square"),n.setAttribute("stroke-width","2"),n},dt=function(e,t){const n={stroke:"rgb(235, 95, 82)",fill:"none","stroke-linecap":"cap","stroke-width":"2"},o=H.createElementNS(B,"g"),i=H.createElementNS(B,"path"),s=H.createElementNS(B,"path");return C(s,{d:t,...n}),C(i,{d:e,...n,"stroke-dasharray":"8,2"}),o.appendChild(i),o.appendChild(s),o},xe=function(e,t,n){if(console.time("editSummary"),!t)return;const o=document.createElement("div");e.nodes.appendChild(o);const i=t.innerHTML;o.id="input-box",o.textContent=i,o.contentEditable="true",o.spellcheck=!1;const s=t.getAttribute("x")+"px",r=t.getAttribute("y")+"px";o.style.cssText=`min-width:${100-8}px;position:absolute;left:${s};top:${r};`;const l=t.getAttribute("text-anchor");l==="end"?o.style.cssText+="transform: translate(-100%, -100%);":l==="middle"?o.style.cssText+="transform: translate(-50%, -100%);":o.style.cssText+="transform: translate(0, -100%);",o.focus(),be(o),o.addEventListener("keydown",c=>{c.stopPropagation();const h=c.key;if(h==="Enter"||h==="Tab"){if(c.shiftKey)return;c.preventDefault(),o.blur(),e.map.focus()}}),o.addEventListener("blur",()=>{o&&n(o)}),console.timeEnd("editSummary")};let Ne=we;const ht=function(e){console.time("linkDiv");const t=this.map.querySelector("me-root");this.nodes.style.top=`${1e4-this.nodes.offsetHeight/2}px`,this.nodes.style.left=`${1e4-t.offsetLeft-t.offsetWidth/2}px`;const n=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="",Ne=this.subLinkStyle===2?pt:we;for(let o=0;o0&&(i+=Ee(v,u,n))}return i};function ut({x1:e,y1:t,x2:n,y2:o}){return`M ${e} ${t} V ${o>t?o-20:o+20} C ${e} ${o} ${e} ${o} ${n>e?e+20:e-20} ${o} H ${n}`}function ft({x1:e,y1:t,x2:n,y2:o}){return`M ${e} ${t} Q ${e} ${o} ${n} ${o}`}function pt({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:l,direction:c,isFirst:h}){let a;h?a=e+o/2:a=e+o;const u=i+l;let d=0,p=0,g=0;return c==="lhs"?(d=t+T,p=s,g=s+r):c==="rhs"&&(d=t+n-T,p=s+r,g=s),ua-50?`M ${d} ${a} H ${g} V ${u} H ${p}`:u>=a?`M ${d} ${a} H ${g} V ${u-$} A ${$} ${$} 0 0 ${d>p?1:0} ${d>p?g-$:g+$} ${u} H ${p}`:`M ${d} ${a} H ${g} V ${u+$} A ${$} ${$} 0 0 ${d>p?0:1} ${d>p?g-$:g+$} ${u} H ${p}`}function we({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:l,direction:c,isFirst:h}){let a=0,u=0;h?a=e+o/2:a=e+o;const d=i+l;let p=0,g=0,m=0;const f=Math.min(Math.abs(a-d)/800,1.2)*T;return c==="lhs"?(m=t,p=m+T,g=m-T,u=s+T,`M ${p} ${a} C ${m} ${a} ${m+f} ${d} ${g} ${d} H ${u}`):(m=t+n,p=m-T,g=m+T,u=s+r-T,`M ${p} ${a} C ${m} ${a} ${m-f} ${d} ${g} ${d} H ${u}`)}const Ce={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",clickTips:"请点击目标节点",summary:"摘要"},_e={cn:Ce,zh_CN:Ce,zh_TW:{addChild:"插入子節點",addParent:"插入父節點",addSibling:"插入同級節點",removeNode:"刪除節點",focus:"專注",cancelFocus:"取消專注",moveUp:"上移",moveDown:"下移",link:"連接",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",clickTips:"Please click the target node",summary:"Summary"},ru:{addChild:"Добавить дочерний элемент",addParent:"Добавить родительский элемент",addSibling:"Добавить на этом уровне",removeNode:"Удалить узел",focus:"Режим фокусировки",cancelFocus:"Отменить режим фокусировки",moveUp:"Поднять выше",moveDown:"Опустить ниже",link:"Ссылка",clickTips:"Пожалуйста, нажмите на целевой узел",summary:"Описание"},ja:{addChild:"子ノードを追加する",addParent:"親ノードを追加します",addSibling:"兄弟ノードを追加する",removeNode:"ノードを削除",focus:"集中",cancelFocus:"集中解除",moveUp:"上へ移動",moveDown:"下へ移動",link:"コネクト",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",clickTips:"Favor clicar no item alvo",summary:"Resumo"}},xn="";function mt(e,t){const n=b=>{const x=document.createElement("div");return x.innerText=b,x.className="tips",x},o=(b,x,E)=>{const _=document.createElement("li");return _.id=b,_.innerHTML=`${Z(x)}${Z(E)}`,_},i=_e[e.locale]?e.locale:"en",s=_e[i],r=o("cm-add_child",s.addChild,"tab"),l=o("cm-add_parent",s.addParent,""),c=o("cm-add_sibling",s.addSibling,"enter"),h=o("cm-remove_child",s.removeNode,"delete"),a=o("cm-fucus",s.focus,""),u=o("cm-unfucus",s.cancelFocus,""),d=o("cm-up",s.moveUp,"PgUp"),p=o("cm-down",s.moveDown,"Pgdn"),g=o("cm-down",s.link,""),m=o("cm-down",s.summary,""),f=document.createElement("ul");if(f.className="menu-list",f.appendChild(r),f.appendChild(l),f.appendChild(c),f.appendChild(h),(!t||t.focus)&&(f.appendChild(a),f.appendChild(u)),f.appendChild(d),f.appendChild(p),f.appendChild(m),(!t||t.link)&&f.appendChild(g),t&&t.extend)for(let b=0;b{x.onclick(_)}}const v=document.createElement("div");v.className="context-menu",v.appendChild(f),v.hidden=!0,e.container.append(v);let y=!0;e.container.oncontextmenu=function(b){if(b.preventDefault(),!e.editable)return;const x=b.target;if(ce(x)){x.parentElement.tagName==="ME-ROOT"?y=!0:y=!1,y?(a.className="disabled",d.className="disabled",p.className="disabled",l.className="disabled",c.className="disabled",h.className="disabled"):(a.className="",d.className="",p.className="",l.className="",c.className="",h.className=""),e.currentNodes||e.selectNode(x),v.hidden=!1,L.mousedown&&(L.mousedown=!1),f.style.top="",f.style.bottom="",f.style.left="",f.style.right="";const E=f.getBoundingClientRect(),_=f.offsetHeight,q=f.offsetWidth,Q=b.clientY-E.top,F=b.clientX-E.left;_+Q>window.innerHeight?(f.style.top="",f.style.bottom="0px"):(f.style.bottom="",f.style.top=Q+15+"px"),q+F>window.innerWidth?(f.style.left="",f.style.right="0px"):(f.style.right="",f.style.left=F+10+"px")}},v.onclick=b=>{b.target===v&&(v.hidden=!0)},r.onclick=()=>{e.addChild(),v.hidden=!0},l.onclick=()=>{e.insertParent(),v.hidden=!0},c.onclick=()=>{y||(e.insertSibling(),v.hidden=!0)},h.onclick=()=>{y||(e.removeNode(),v.hidden=!0)},a.onclick=()=>{y||(e.focusNode(e.currentNode),v.hidden=!0)},u.onclick=()=>{e.cancelFocus(),v.hidden=!0},d.onclick=()=>{y||(e.moveUpNode(),v.hidden=!0)},p.onclick=()=>{y||(e.moveDownNode(),v.hidden=!0)},g.onclick=()=>{v.hidden=!0;const b=e.currentNode,x=n(s.clickTips);e.container.appendChild(x),e.map.addEventListener("click",E=>{E.preventDefault(),x.remove();const _=E.target;_.parentElement.tagName==="ME-PARENT"||_.parentElement.tagName==="ME-ROOT"?e.createLink(b,_):console.log("link cancel")},{once:!0})},m.onclick=()=>{v.hidden=!0,e.createSummary(),e.unselectNodes()}}const gt=e=>{const t=e.map.querySelectorAll(".lhs>me-wrapper>me-parent>me-tpc");e.selectNode(t[Math.ceil(t.length/2)-1])},vt=e=>{const t=e.map.querySelectorAll(".rhs>me-wrapper>me-parent>me-tpc");e.selectNode(t[Math.ceil(t.length/2)-1])},Se=e=>{e.selectNode(e.map.querySelector("me-root>me-tpc"))};function bt(e){const t={13:n=>{n.shiftKey?e.insertBefore():e.insertSibling()},9:()=>{e.addChild()},112:()=>{e.toCenter()},113:()=>{e.beginEdit()},38:n=>{if(n.altKey)e.moveUpNode();else{if(n.metaKey||n.ctrlKey)return e.initSide();e.selectPrevSibling()}},40:n=>{n.altKey?e.moveDownNode():e.selectNextSibling()},37:n=>{var s;if(n.metaKey||n.ctrlKey)return e.initLeft();if(!e.currentNode)return;const o=e.currentNode.nodeObj,i=e.currentNode.offsetParent.offsetParent.parentElement;e.currentNode.nodeObj.root?gt(e):i.className==="rhs"?(s=o.parent)!=null&&s.root?Se(e):e.selectParent():i.className==="lhs"&&e.selectFirstChild()},39:n=>{var s;if(n.metaKey||n.ctrlKey)return e.initRight();if(!e.currentNode)return;const o=e.currentNode.nodeObj,i=e.currentNode.offsetParent.offsetParent.parentElement;o.root?vt(e):i.className==="lhs"?(s=o.parent)!=null&&s.root?Se(e):e.selectParent():i.className==="rhs"&&e.selectFirstChild()},33(){e.moveUpNode()},34(){e.moveDownNode()},67:n=>{(n.metaKey||n.ctrlKey)&&(e.waitCopy=e.currentNode)},86:n=>{!e.waitCopy||!e.currentNode||(n.metaKey||n.ctrlKey)&&(e.copyNode(e.waitCopy,e.currentNode),e.waitCopy=null)},187:n=>{if(n.metaKey||n.ctrlKey){if(e.scaleVal>1.6)return;e.scale(e.scaleVal+=.2)}},189:n=>{if(n.metaKey||n.ctrlKey){if(e.scaleVal<.6)return;e.scale(e.scaleVal-=.2)}},48:n=>{(n.metaKey||n.ctrlKey)&&e.scale(1)}};e.map.onkeydown=n=>{if(n.preventDefault(),!!e.editable&&n.target===n.currentTarget)if(n.keyCode===8||n.keyCode===46)e.currentLink?e.removeLink():e.currentSummary?e.removeSummary(e.currentSummary.summaryObj.id):e.currentNode?e.removeNode():e.currentNodes&&e.removeNodes(e.currentNodes);else{const o=t[n.keyCode];o&&o(n)}}}const Nn="";function yt(e,t){const n=(d,p)=>{const g=document.createElement("div");return g.id=d,g.innerHTML=``,g},o=n("cm-add_child","zijiedian"),i=n("cm-add_sibling","tongjijiedian-"),s=n("cm-remove_child","shanchu2"),r=n("cm-up","rising"),l=n("cm-down","falling"),c=n("cm-edit","edit"),h=document.createElement("ul");if(h.className="menu-list",t&&t.extend)for(let d=0;d{p.onclick(m)}}const a=document.createElement("mmenu");a.className="mobile-menu",a.appendChild(o),a.appendChild(i),a.appendChild(s),a.appendChild(r),a.appendChild(l),a.appendChild(c),a.hidden=!0,e.container.append(a);let u=!0;e.bus.addListener("unselectNode",function(){a.hidden=!0}),e.bus.addListener("selectNode",function(d){a.hidden=!1,d.root?u=!0:u=!1}),a.onclick=d=>{d.target===a&&(a.hidden=!0)},o.onclick=()=>{e.addChild()},i.onclick=()=>{u||e.insertSibling()},s.onclick=()=>{u||e.removeNode()},r.onclick=d=>{u||e.moveUpNode()},l.onclick=d=>{u||e.moveDownNode()},c.onclick=d=>{e.beginEdit()}}const de=document,xt=function(e,t){if(!t)return he(e),e;const n=e.getElementsByClassName("insert-preview"),o=`insert-preview ${t} show`;if(n.length>0)n[0].className=o;else{const i=de.createElement("div");i.className=o,e.appendChild(i)}return e},he=function(e){if(!e)return;const t=e.getElementsByClassName("insert-preview");for(const n of t||[])n.remove()},ke=function(e,t){const n=t.parentElement.parentElement.contains(e);return e&&e.tagName==="ME-TPC"&&e!==t&&!n&&e.nodeObj.root!==!0},Nt=function(e){const t=document.createElement("div");return t.className="mind-elixir-ghost",e.map.appendChild(t),t};function Et(e){let t=null,n=null,o=null;const i=Nt(e),s=12;e.map.addEventListener("dragstart",r=>{var c;const l=r.target;if((l==null?void 0:l.tagName)!=="ME-TPC"){r.preventDefault();return}t=l,t.parentElement.parentElement.style.opacity="0.5",i.innerHTML=t.innerHTML,(c=r.dataTransfer)==null||c.setDragImage(i,0,0),L.clear()}),e.map.addEventListener("dragend",async r=>{if(!t)return;t.parentElement.parentElement.style.opacity="1";const l=r.target;if(l.style.opacity="",!o)return;he(o);const c=t.nodeObj;switch(n){case"before":e.moveNodeBefore(t,o),e.selectNode(w(c.id));break;case"after":e.moveNodeAfter(t,o),e.selectNode(w(c.id));break;case"in":e.moveNode(t,o);break}t=null}),e.map.addEventListener("dragover",Ge(function(r){if(!t)return;he(o);const l=de.elementFromPoint(r.clientX,r.clientY-s);if(ke(l,t)){o=l;const c=l.getBoundingClientRect().y;r.clientY>c+l.clientHeight?n="after":r.clientY>c+l.clientHeight/2&&(n="in")}else{const c=de.elementFromPoint(r.clientX,r.clientY+s);if(ke(c,t)){o=c;const h=c.getBoundingClientRect().y;r.clientYt.id)}:{type:"node",value:e.obj.id}};function Ct(e){let t=[],n=-1,o=e.getData();e.bus.addListener("operation",i=>{if(i.name==="beginEdit")return;t=t.slice(0,n+1);const s=e.getData();t.push({prev:o,currentObject:wt(i),next:s}),o=s,n=t.length-1}),e.undo=function(){if(n>-1){const i=t[n];o=i.prev,e.refresh(i.prev),i.currentObject.type==="node"&&e.selectNode(w(i.currentObject.value)),n--,console.log("current",o)}},e.redo=function(){if(n{(i.metaKey||i.ctrlKey)&&i.shiftKey&&i.key==="Z"?e.redo():(i.metaKey||i.ctrlKey)&&i.key==="z"&&e.undo()})}const En="",z=(e,t)=>{const n=document.createElement("span");return n.id=e,n.innerHTML=``,n};function _t(e){const t=document.createElement("div"),n=z("fullscreen","full"),o=z("toCenter","living"),i=z("zoomout","move"),s=z("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(s),t.className="mind-elixir-toolbar rb",n.onclick=()=>{e.container.requestFullscreen()},o.onclick=()=>{e.toCenter()},i.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-=.2)},s.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+=.2)},t}function St(e){const t=document.createElement("div"),n=z("tbltl","left"),o=z("tbltr","right"),i=z("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(i),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},i.onclick=()=>{e.initSide()},t}function kt(e){e.container.append(_t(e)),e.container.append(St(e))}/*! @viselect/vanilla v3.3.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */var Lt=Object.defineProperty,Mt=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(Mt(e,typeof t!="symbol"?t+"":t,n),n);class Tt{constructor(){N(this,"_listeners",new Map),N(this,"on",this.addEventListener),N(this,"off",this.removeEventListener),N(this,"emit",this.dispatchEvent)}addEventListener(t,n){const o=this._listeners.get(t)??new Set;return this._listeners.set(t,o),o.add(n),this}removeEventListener(t,n){var o;return(o=this._listeners.get(t))==null||o.delete(n),this}dispatchEvent(t,...n){let o=!0;for(const i of this._listeners.get(t)??[])o=i(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const Le=(e,t="px")=>typeof e=="number"?e+t:e;function j({style:e},t,n){if(typeof t=="object")for(const[o,i]of Object.entries(t))i!==void 0&&(e[o]=Le(i));else n!==void 0&&(e[t]=Le(n))}function Me(e){return(t,n,o,i={})=>{t instanceof HTMLCollection||t instanceof NodeList?t=Array.from(t):Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);for(const s of t)for(const r of n)s[e](r,o,{capture:!1,...i});return[t,n,o,i]}}const W=Me("addEventListener"),O=Me("removeEventListener"),oe=e=>{var t;const{clientX:n,clientY:o,target:i}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:i}};function Te(e,t,n="touch"){switch(n){case"center":{const o=t.left+t.width/2,i=t.top+t.height/2;return o>=e.left&&o<=e.right&&i>=e.top&&i<=e.bottom}case"cover":return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom;case"touch":return e.right>=t.left&&e.left<=t.right&&e.bottom>=t.top&&e.top<=t.bottom}}function I(e,t=document){const n=Array.isArray(e)?e:[e];let o=[];for(let i=0,s=n.length;imatchMedia("(hover: none), (pointer: coarse)").matches,Dt=()=>"safari"in window,jt=e=>{let t,n=-1,o=!1;return{next(...i){t=i,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel(){cancelAnimationFrame(n),o=!1}}},{abs:R,max:$e,min:De,ceil:je}=Math;class Oe extends Tt{constructor(t){var n,o,i,s,r;super(),N(this,"_options"),N(this,"_selection",{stored:[],selected:[],touched:[],changed:{added:[],removed:[]}}),N(this,"_area"),N(this,"_clippingElement"),N(this,"_targetElement"),N(this,"_targetRect"),N(this,"_selectables",[]),N(this,"_latestElement"),N(this,"_areaRect",new DOMRect),N(this,"_areaLocation",{y1:0,x2:0,y2:0,x1:0}),N(this,"_singleClick",!0),N(this,"_frame"),N(this,"_scrollAvailable",!0),N(this,"_scrollingActive",!1),N(this,"_scrollSpeed",{x:0,y:0}),N(this,"_scrollDelta",{x:0,y:0}),N(this,"disable",this._bindStartEvents.bind(this,!1)),N(this,"enable",this._bindStartEvents),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...t,behaviour:{overlap:"invert",intersect:"touch",...t.behaviour,startThreshold:(n=t.behaviour)!=null&&n.startThreshold?typeof t.behaviour.startThreshold=="number"?t.behaviour.startThreshold:{x:10,y:10,...t.behaviour.startThreshold}:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,...(o=t.behaviour)==null?void 0:o.scrolling,startScrollMargins:{x:0,y:0,...(s=(i=t.behaviour)==null?void 0:i.scrolling)==null?void 0:s.startScrollMargins}}},features:{range:!0,touch:!0,...t.features,singleTap:{allow:!0,intersect:"native",...(r=t.features)==null?void 0:r.singleTap}}};for(const a of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[a]=="function"&&(this[a]=this[a].bind(this));const{document:l,selectionAreaClass:c,selectionContainerClass:h}=this._options;this._area=l.createElement("div"),this._clippingElement=l.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(c),h&&this._clippingElement.classList.add(h),j(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),j(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=jt(a=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",a),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(t=!0){const{document:n,features:o}=this._options,i=t?W:O;i(n,"mousedown",this._onTapStart),o.touch&&i(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:i,target:s}=oe(t),{_options:r}=this,{document:l}=this._options,c=s.getBoundingClientRect(),h=I(r.startAreas,r.document),a=I(r.boundaries,r.document);this._targetElement=a.find(p=>Te(p.getBoundingClientRect(),c));const u=t.composedPath();if(!this._targetElement||!h.find(p=>u.includes(p))||!a.find(p=>u.includes(p))||!n&&this._emitEvent("beforestart",t)===!1)return;this._areaLocation={x1:o,y1:i,x2:0,y2:0};const d=l.scrollingElement??l.body;this._scrollDelta={x:d.scrollLeft,y:d.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),W(l,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),W(l,["mouseup","touchcancel","touchend"],this._onTapStop),W(l,"scroll",this._onScroll)}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,i=oe(t);let s;if(n==="native")s=i.target;else if(n==="touch"){this.resolveSelectables();const{x:l,y:c}=i;s=this._selectables.find(h=>{const{right:a,left:u,top:d,bottom:p}=h.getBoundingClientRect();return lu&&cd})}if(!s)return;for(this.resolveSelectables();!this._selectables.includes(s);){if(!s.parentElement)return;s=s.parentElement}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const l=this._latestElement,[c,h]=l.compareDocumentPosition(s)&4?[s,l]:[l,s],a=[...this._selectables.filter(u=>u.compareDocumentPosition(c)&4&&u.compareDocumentPosition(h)&2),c,h];this.select(a),this._latestElement=l}else r.includes(s)&&(r.length===1||t.ctrlKey||r.every(l=>this._selection.stored.includes(l)))?this.deselect(s):(this.select(s),this._latestElement=s);this._emitEvent("stop",t)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:i}}=this._options,{x1:s,y1:r}=this._areaLocation,{x:l,y:c}=oe(t);if(typeof i=="number"&&R(l+c-(s+r))>=i||typeof i=="object"&&R(l-s)>=i.x||R(c-r)>=i.y){if(O(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){O(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}W(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),j(this._area,"display","block"),I(n,o)[0].appendChild(this._clippingElement),this.resolveSelectables(),this._singleClick=!1,this._targetRect=this._targetElement.getBoundingClientRect(),this._scrollAvailable=this._targetElement.scrollHeight!==this._targetElement.clientHeight||this._targetElement.scrollWidth!==this._targetElement.clientWidth,this._scrollAvailable&&(W(o,"wheel",this._manualScroll,{passive:!1}),this._selectables=this._selectables.filter(h=>this._targetElement.contains(h))),this._setupSelectionArea(),this._emitEvent("start",t),this._onTapMove(t)}this._handleMoveEvent(t)}_setupSelectionArea(){const{_clippingElement:t,_targetElement:n,_area:o}=this,i=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(j(t,{top:i.top,left:i.left,width:i.width,height:i.height}),j(o,{marginTop:-i.top,marginLeft:-i.left})):(j(t,{top:0,left:0,width:"100%",height:"100%"}),j(o,{marginTop:0,marginLeft:0}))}_onTapMove(t){const{x:n,y:o}=oe(t),{_scrollSpeed:i,_areaLocation:s,_options:r,_frame:l}=this,{speedDivider:c}=r.behaviour.scrolling,h=this._targetElement;if(s.x2=n,s.y2=o,this._scrollAvailable&&!this._scrollingActive&&(i.y||i.x)){this._scrollingActive=!0;const a=()=>{if(!i.x&&!i.y){this._scrollingActive=!1;return}const{scrollTop:u,scrollLeft:d}=h;i.y&&(h.scrollTop+=je(i.y/c),s.y1-=h.scrollTop-u),i.x&&(h.scrollLeft+=je(i.x/c),s.x1-=h.scrollLeft-d),l.next(t),requestAnimationFrame(a)};requestAnimationFrame(a)}else l.next(t);this._handleMoveEvent(t)}_handleMoveEvent(t){const{features:n}=this._options;(n.touch&&$t()||this._scrollAvailable&&Dt())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:i}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-i,this._areaLocation.y1+=t.y-o,t.x=i,t.y=o,this._setupSelectionArea(),this._frame.next(null)}_manualScroll(t){const{manualSpeed:n}=this._options.behaviour.scrolling,o=t.deltaY?t.deltaY>0?1:-1:0,i=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=i*n,this._onTapMove(t),t.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_areaRect:o,_targetElement:i,_options:s}=this,{scrollTop:r,scrollHeight:l,clientHeight:c,scrollLeft:h,scrollWidth:a,clientWidth:u}=i,d=this._targetRect,{x1:p,y1:g}=n;let{x2:m,y2:f}=n;const{behaviour:{scrolling:{startScrollMargins:v}}}=s;md.right-v.x?(t.x=a-h-u?R(d.left+d.width-m-v.x):0,m=m>d.right?d.right:m):t.x=0,fd.bottom-v.y?(t.y=l-r-c?R(d.top+d.height-f-v.y):0,f=f>d.bottom?d.bottom:f):t.y=0;const y=De(p,m),b=De(g,f),x=$e(p,m),E=$e(g,f);o.x=y,o.y=b,o.width=x-y,o.height=E-b}_redrawSelectionArea(){const{x:t,y:n,width:o,height:i}=this._areaRect,{style:s}=this._area;s.left=`${t}px`,s.top=`${n}px`,s.width=`${o}px`,s.height=`${i}px`}_onTapStop(t,n){var o;const{document:i,features:s}=this._options,{_singleClick:r}=this;O(i,["mousemove","touchmove"],this._delayedTapMove),O(i,["touchmove","mousemove"],this._onTapMove),O(i,["mouseup","touchcancel","touchend"],this._onTapStop),O(i,"scroll",this._onScroll),this._keepSelection(),t&&r&&s.singleTap.allow?this._onSingleTap(t):!r&&!n&&(this._updateElementSelection(),this._emitEvent("stop",t)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,this._scrollAvailable&&O(i,"wheel",this._manualScroll,{passive:!0}),this._clippingElement.remove(),(o=this._frame)==null||o.cancel(),j(this._area,"display","none")}_updateElementSelection(){const{_selectables:t,_options:n,_selection:o,_areaRect:i}=this,{stored:s,selected:r,touched:l}=o,{intersect:c,overlap:h}=n.behaviour,a=h==="invert",u=[],d=[],p=[];for(let m=0;m!r.includes(m)));const g=h==="keep";for(let m=0;m!r.includes(c));switch(t.behaviour.overlap){case"drop":{n.stored=[...l,...r.filter(c=>!s.includes(c))];break}case"invert":{n.stored=[...l,...r.filter(c=>!i.removed.includes(c))];break}case"keep":{n.stored=[...r,...o.filter(c=>!r.includes(c))];break}}}trigger(t,n=!0){this._onTapStart(t,n)}resolveSelectables(){this._selectables=I(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:i,changed:s}=this._selection;s.added=[],s.removed.push(...o,...t?i:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection={stored:t?[]:i,selected:[],touched:[],changed:{added:[],removed:[]}}}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}cancel(t=!1){this._onTapStop(null,!t)}destroy(){this.cancel(),this.disable(),this._clippingElement.remove(),super.unbindAllListeners()}select(t,n=!1){const{changed:o,selected:i,stored:s}=this._selection,r=I(t,this._options.document).filter(l=>!i.includes(l)&&!s.includes(l));return s.push(...r),i.push(...r),o.added.push(...r),o.removed=[],this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)),r}deselect(t,n=!1){const{selected:o,stored:i,changed:s}=this._selection,r=I(t,this._options.document).filter(l=>o.includes(l)||i.includes(l));r.length&&(this._selection.stored=i.filter(l=>!r.includes(l)),this._selection.selected=o.filter(l=>!r.includes(l)),this._selection.changed.added=[],this._selection.changed.removed.push(...r.filter(l=>!s.removed.includes(l))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}N(Oe,"version","3.3.1");function Ot(e){const t=new Oe({selectables:[".map-container me-tpc"],boundaries:[e.container],container:"body",behaviour:{scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:10,y:10}}}}).on("beforestart",({event:n})=>{if(n.button!==e.mouseSelectionButton||n.target.tagName==="ME-TPC"||n.target.id==="input-box"||n.target.className==="circle")return!1;const o=t.getSelectionArea();return o.style.background="#4f90f22d",o.style.border="1px solid #4f90f2",o.parentElement&&(o.parentElement.style.zIndex="9999"),!0}).on("start",({event:n})=>{!n.ctrlKey&&!n.metaKey&&(e.unselectNode(),e.unselectNodes(),e.unselectSummary(),e.unselectLink(),t.clearSelection(!0,!0))}).on("move",({store:{changed:{added:n,removed:o}}})=>{L.moved=!0;for(const i of n)i.classList.add("selected");for(const i of o)i.classList.remove("selected")}).on("stop",({store:{stored:n}})=>{e.selectNodes(n)});e.selection=t}const At=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);for(let i=0;i{if(!(t==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(e){e(this)},refresh:function(e){e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.linkData=e.linkData||{},this.summaries=e.summaries||[]),D(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},selectFirstChild:function(){if(!this.currentNode)return;const e=this.currentNode.parentElement.nextSibling;if(e&&e.firstChild){const t=e.firstChild.firstChild.firstChild;this.selectNode(t)}},selectNextSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.nextSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},selectNode:function(e,t,n){if(e){if(console.time("selectNode"),typeof e=="string"){const o=w(e);return o?this.selectNode(o):void 0}this.currentNode&&(this.currentNode.className=""),e.className="selected",e.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj,n),console.timeEnd("selectNode")}},selectNodes:function(e){if(e){console.time("selectNodes");for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj)),console.timeEnd("selectNodes")}},selectParent:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return;const e=this.currentNode.parentElement.parentElement.parentElement.previousSibling;if(e){const t=e.firstChild;this.selectNode(t)}},selectPrevSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.previousSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},setLocale:function(e){this.locale=e,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const e of this.currentNodes)e.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),A=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=t.indexOf(e);return{siblings:t,index:n}};function Ht(e){const{siblings:t,index:n}=A(e),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 Bt(e){const{siblings:t,index:n}=A(e),o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function X(e){const{siblings:t,index:n}=A(e);return t.splice(n,1),t.length}function zt(e,t){const{siblings:n,index:o}=A(e);n.splice(o+1,0,t)}function Rt(e,t){const{siblings:n,index:o}=A(e);n.splice(o,0,t)}function qt(e,t){const{siblings:n,index:o}=A(e);n[o]=t,t.children=[e]}function Ft(e,t){X(e),t.children?t.children.push(e):t.children=[e]}function Vt(e,t){e.direction!==void 0&&(e.direction=t.direction),X(e);const{siblings:n,index:o}=A(t);n.splice(o,0,e)}function Wt(e,t){e.direction!==void 0&&(e.direction=t.direction),X(e);const{siblings:n,index:o}=A(t);n.splice(o+1,0,e)}const Pe=function(e,t){var n,o;if(e===k)return k;if(e===P)return P;if(e===U){const i=((n=document.querySelector(".lhs"))==null?void 0:n.childElementCount)||0,s=((o=document.querySelector(".rhs"))==null?void 0:o.childElementCount)||0;return i<=s?(t.direction=k,k):(t.direction=P,P)}},He=function(e,t){var l,c;if(!e)return null;const n=e.nodeObj;n.expanded===!1&&(this.expandNode(e,!0),e=w(n.id));const o=t||this.generateNewObj();n.children?n.children.push(o):n.children=[o],D(this.nodeData);const i=e.parentElement,{grp:s,top:r}=this.createWrapper(o);if(i.tagName==="ME-PARENT"){if(i.children[1])i.nextSibling.appendChild(s);else{const h=this.createChildren([s]);i.appendChild(ne(!0)),i.insertAdjacentElement("afterend",h)}this.linkDiv(s.offsetParent)}else i.tagName==="ME-ROOT"&&(Pe(this.direction,o)===k?(l=document.querySelector(".lhs"))==null||l.appendChild(s):(c=document.querySelector(".rhs"))==null||c.appendChild(s),this.linkDiv());return{newTop:r,newNodeObj:o}},Be=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&o.previousSibling.children[1].remove()}n.parentNode.remove()},ie=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},ze=Object.freeze(Object.defineProperty({__proto__:null,addChild:function(e,t){console.time("addChild");const n=e||this.currentNode;if(!n)return;const o=He.call(this,n,t);if(!o)return;const{newTop:i,newNodeObj:s}=o;this.bus.fire("operation",{name:"addChild",obj:s}),console.timeEnd("addChild"),t||this.editTopic(i.firstChild),this.selectNode(i.firstChild,!0)},beginEdit:function(e){const t=e||this.currentNode;t&&this.editTopic(t)},copyNode:function(e,t){console.time("copyNode");const n=ve(e.nodeObj);me(n);const o=He.call(this,t,n);if(!o)return;const{newNodeObj:i}=o;console.timeEnd("copyNode"),this.bus.fire("operation",{name:"copyNode",obj:i})},insertBefore:function(e,t){const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}const i=t||this.generateNewObj();Rt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertBefore",obj:i})},insertParent:function(e,t){const n=e||this.currentNode;if(!n)return;ie(n);const o=n.nodeObj;if(o.root===!0)return;const i=t||this.generateNewObj();qt(o,i),D(this.nodeData);const s=n.parentElement.parentElement;console.time("insertParent_DOM");const{grp:r,top:l}=this.createWrapper(i,!0);l.appendChild(ne(!0)),s.insertAdjacentElement("afterend",r);const c=this.createChildren([s]);l.insertAdjacentElement("afterend",c),this.linkDiv(),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertParent_DOM"),this.bus.fire("operation",{name:"insertParent",obj:i})},insertSibling:function(e,t){var h,a,u;const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}else if(((h=o.parent)==null?void 0:h.root)===!0&&((u=(a=o.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(w(o.parent.id));return}const i=t||this.generateNewObj();zt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode.nextSibling),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertSibling",obj:i})},moveDownNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Bt(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})},moveNode:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n==null?void 0:n.parent)==null?void 0:l.id;if(o.expanded===!1&&(this.expandNode(t,!0),e=w(n.id),t=w(o.id)),!Je(n,o)){console.warn("Invalid move");return}console.time("moveNode"),Ft(n,o),D(this.nodeData);const s=e.parentElement,r=t.parentElement;if(r.tagName==="ME-PARENT")if(ie(e),r.children[1])r.nextSibling.appendChild(s.parentElement);else{const c=this.createChildren([s.parentElement]);r.appendChild(ne(!0)),r.parentElement.insertBefore(c,r.nextSibling)}else r.tagName==="ME-ROOT"&&(Pe(this.direction,n),r.nextSibling.appendChild(s.parentElement));this.linkDiv(),this.bus.fire("operation",{name:"moveNode",obj:n,toObj:o,originParentId:i}),console.timeEnd("moveNode")},moveNodeAfter:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Wt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("afterend",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeAfter",obj:n,toObj:o,originParentId:i})},moveNodeBefore:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Vt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("beforebegin",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeBefore",obj:n,toObj:o,originParentId:i})},moveUpNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ht(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},removeNode:function(e){var r;const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;if(n.root===!0)throw new Error("Can not remove root node");const o=n.parent.children,i=o.findIndex(l=>l===n),s=X(n);if(Be(t,s),o.length!==0){const l=o[i]||o[i-1];this.selectNode(w(l.id))}else this.selectNode(w(n.parent.id));this.linkDiv(),this.bus.fire("operation",{name:"removeNode",obj:n,originIndex:i,originParentId:(r=n==null?void 0:n.parent)==null?void 0:r.id})},removeNodes:function(e){for(const t of e){const n=t.nodeObj;if(n.root===!0)continue;const o=X(n);Be(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},reshapeNode:function(e,t){console.log(t);const n=e.nodeObj,o=ve(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const i=Object.assign(n,t);ae(e,i),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:i,origin:o})},setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"})),Re={create:function(e){return{dom:e,moved:!1,mousedown:!1,handleMouseMove(t){this.mousedown&&(this.moved=!0,this.cb&&this.cb(t.movementX,t.movementY))},handleMouseDown(t){t.button===0&&(this.mousedown=!0)},handleClear(t){this.mousedown=!1},cb:null,init(t,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseleave",this.handleClear),t.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(t){t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseleave",this.handleClear),t.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function se(e,t,n){const{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=t.offsetWidth,r=t.offsetHeight,l=o+s/2,c=i+r/2,h=l+n.x,a=c+n.y;return{w:s,h:r,cx:l,cy:c,ctrlX:h,ctrlY:a}}function K(e){let t,n;const o=(e.cy-e.ctrlY)/(e.ctrlX-e.cx);return o>e.h/e.w||o<-e.h/e.w?e.cy-e.ctrlY<0?(t=e.cx-e.h/2/o,n=e.cy+e.h/2):(t=e.cx+e.h/2/o,n=e.cy-e.h/2):e.cx-e.ctrlX<0?(t=e.cx+e.w/2,n=e.cy-e.w*o/2):(t=e.cx-e.w/2,n=e.cy+e.w*o/2),{x:t,y:n}}const It=function(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return C(i,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),i.dataset.type="custom-link",i.innerHTML=e,i},Kt=function(e,t,n,o){if(!e||!t)return;const i=performance.now(),s=se(this,e,n.delta1),r=se(this,t,n.delta2),{x:l,y:c}=K(s),{ctrlX:h,ctrlY:a}=s,{ctrlX:u,ctrlY:d}=r,{x:p,y:g}=K(r),m=ge(u,d,p,g),f=dt(`M ${l} ${c} C ${h} ${a} ${u} ${d} ${p} ${g}`,`M ${m.x1} ${m.y1} L ${p} ${g} L ${m.x2} ${m.y2}`),v=l/8+h*3/8+u*3/8+p/8,y=c/8+a*3/8+d*3/8+g/8,b=It(n.label,v,y,this.theme.cssVar["--color"]);f.appendChild(b),f.linkObj=n,f.dataset.linkid=n.id,this.linkSvgGroup.appendChild(f),o||(this.linkData[n.id]=n,this.currentLink=f,this.showLinkController(n,s,r));const x=performance.now();console.log(`DrawCustomLink Execution time: ${x-i} ms`)},Ut=function(e,t){const n={id:Y(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};this.drawCustomLink(e,t,n),this.bus.fire("operation",{name:"createCustomLink",obj:n})},Yt=function(e){let t;if(e?t=e:t=this.currentLink,!t)return;this.hideLinkController();const n=t.linkObj.id;delete this.linkData[n],t.remove(),this.bus.fire("operation",{name:"removeCustomLink",obj:{id:n}})},Gt=function(e){this.currentLink=e;const t=e.linkObj,n=w(t.from),o=w(t.to),i=se(this,n,t.delta1),s=se(this,o,t.delta2);this.showLinkController(t,i,s)},Xt=function(){this.currentLink=null,this.hideLinkController()},Jt=function(){this.linkController.style.display="none",this.P2.style.display="none",this.P3.style.display="none"},Qt=function(e,t,n){var u;this.linkController.style.display="initial",this.P2.style.display="initial",this.P3.style.display="initial",this.nodes.appendChild(this.linkController),this.nodes.appendChild(this.P2),this.nodes.appendChild(this.P3);let{x:o,y:i}=K(t),{ctrlX:s,ctrlY:r}=t,{ctrlX:l,ctrlY:c}=n,{x:h,y:a}=K(n);this.P2.style.cssText=`top:${r}px;left:${s}px;`,this.P3.style.cssText=`top:${c}px;left:${l}px;`,C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),this.helper1&&(this.helper1.destory(this.map),(u=this.helper2)==null||u.destory(this.map)),this.helper1=Re.create(this.P2),this.helper2=Re.create(this.P3),this.helper1.init(this.map,(d,p)=>{var v;s=s+d/this.scaleVal,r=r+p/this.scaleVal;const g=K({...t,ctrlX:s,ctrlY:r});o=g.x,i=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8;this.P2.style.top=r+"px",this.P2.style.left=s+"px",(v=this.currentLink)==null||v.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),e.delta1.x=s-t.cx,e.delta1.y=r-t.cy}),this.helper2.init(this.map,(d,p)=>{var y,b;l=l+d/this.scaleVal,c=c+p/this.scaleVal;const g=K({...n,ctrlX:l,ctrlY:c});h=g.x,a=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8,v=ge(l,c,h,a);this.P3.style.top=c+"px",this.P3.style.left=l+"px",(y=this.currentLink)==null||y.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),(b=this.currentLink)==null||b.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${h} ${a} L ${v.x2} ${v.y2}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),e.delta2.x=l-n.cx,e.delta2.y=c-n.cy})};function Zt(){this.linkSvgGroup.innerHTML="";for(const e in this.linkData){const t=this.linkData[e];try{this.drawCustomLink(w(t.from),w(t.to),t,!0)}catch{console.warn("Node may not be expanded")}}this.nodes.appendChild(this.linkSvgGroup)}function en(e){if(console.time("editSummary"),!e)return;const t=e.children[2];console.log(t,e),xe(this,t,n=>{var s;const o=e.linkObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.label=origin:o.label=i,n.remove(),i!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditCustomLinkLabel",obj:o}))}),console.timeEnd("editSummary")}function tn(){for(const e in this.linkData){const t=this.linkData[e];(!ee(t.from,this.nodeData)||!ee(t.to,this.nodeData))&&delete this.linkData[t.id]}}const nn=Object.freeze(Object.defineProperty({__proto__:null,createLink:Ut,drawCustomLink:Kt,editCutsomLinkLabel:en,hideLinkController:Jt,removeLink:Yt,renderCustomLink:Zt,selectLink:Gt,showLinkController:Qt,tidyCustomLink:tn,unselectLink:Xt},Symbol.toStringTag,{value:"Module"})),on=function(e){var c,h;if(e.length===0)throw new Error("No selected node.");if(e.length===1){const a=e[0].nodeObj,u=e[0].nodeObj.parent;if(!u)throw new Error("Can not select root node.");const d=u.children.findIndex(p=>a===p);return{parent:u.id,start:d,end:d}}let t=0;const n=e.map(a=>{let u=a.nodeObj;const d=[];for(;u.parent;){const p=u.parent,g=p.children,m=g==null?void 0:g.indexOf(u);u=p,d.unshift({node:u,index:m})}return d.length>t&&(t=d.length),d});let o=0;e:for(;oa[o-1].index).sort(),s=i[0]||0,r=i[i.length-1]||0,l=n[0][o-1].node;if(l.root)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:s,end:r}},sn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},qe=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return C(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Fe=function(e,t,n,o,i){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return C(s,{"text-anchor":o,x:t+"",y:n+"",fill:i||"#666"}),s.innerHTML=e,s},rn=e=>w(e).parentElement.parentElement,ln=function({parent:e,start:t}){var s,r;const n=w(e),o=n.nodeObj;let i;return o.root===!0?i=(s=w(o.children[t].id).closest("me-main"))==null?void 0:s.className:i=(r=n.closest("me-main"))==null?void 0:r.className,i},Ve=function(e,t){var _;const{id:n,text:o,parent:i,start:s,end:r}=t,l=e.nodes,h=w(i).nodeObj,a=ln(t);let u=1/0,d=0,p=0,g=0;for(let q=s;q<=r;q++){const Q=(_=h.children)==null?void 0:_[q];if(!Q)return console.warn("Child not found"),e.removeSummary(n),null;const F=rn(Q.id),{offsetLeft:le,offsetTop:Ue}=V(l,F);q===s&&(p=Ue),q===r&&(g=Ue+F.offsetHeight),led&&(d=F.offsetWidth+le)}let m,f;const v=p+10,y=g+10,b=(v+y)/2,x=e.theme.cssVar["--color"];a==="lhs"?(m=qe(`M ${u+10} ${v} c -5 0 -10 5 -10 10 L ${u} ${y-10} c 0 5 5 10 10 10 M ${u} ${b} h -10`,x),f=Fe(o,u-20,b+6,"end",x)):(m=qe(`M ${d-10} ${v} c 5 0 10 5 10 10 L ${d} ${y-10} c 0 5 -5 10 -10 10 M ${d} ${b} h 10`,x),f=Fe(o,d+20,b+6,"start",x));const E=sn("s-"+n);return E.appendChild(m),E.appendChild(f),E.summaryObj=t,e.summarySvg.appendChild(E),E},cn=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let e=[];this.currentNode?e=[this.currentNode]:this.currentNodes&&(e=this.currentNodes);const{parent:t,start:n,end:o}=on(e),i={id:Y(),parent:t,start:n,end:o,text:"summary"},s=Ve(this,i);this.summaries.push(i),this.editSummary(s),this.bus.fire("operation",{name:"createSummary",obj:i})},editSummary:function(e){if(console.time("editSummary"),!e)return;const t=e.childNodes[1];xe(this,t,n=>{var s;const o=e.summaryObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.text=origin:o.text=i,n.remove(),i!==origin&&(t.innerHTML=o.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:o}))}),console.timeEnd("editSummary")},removeSummary:function(e){var n;const t=this.summaries.findIndex(o=>o.id===e);t>-1&&(this.summaries.splice(t,1),(n=document.querySelector("#s-"+e))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:e}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(e=>{try{Ve(this,e)}catch{console.warn("Node may not be expanded")}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,i=document.createElementNS("http://www.w3.org/2000/svg","rect");C(i,{x:t.x-n+"",y:t.y-n+"",width:t.width+n*2+"",height:t.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),i.classList.add("selected"),e.appendChild(i),this.currentSummary=e},unselectSummary:function(){var e,t;(t=(e=this.currentSummary)==null?void 0:e.querySelector("rect"))==null||t.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"}));function an(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");return C(n,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:e,width:t}),n}function dn(e,t){return(parseInt(e)-parseInt(t))/2}function hn(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","g");let s="";return e.text?s=e.text.textContent:s=e.childNodes[0].textContent,s.split(` `).forEach((l,c)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","text");C(h,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+dn(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),h.innerHTML=l,i.appendChild(h)}),i}function un(e,t,n,o){let i="";e.text?i=e.text.textContent:i=e.childNodes[0].textContent;const s=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");C(s,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return C(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),r.innerHTML=i,s.appendChild(r),s}function ue(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:s}=V(e.nodes,t),r=document.createElementNS("http://www.w3.org/2000/svg","rect");C(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 l=document.createElementNS("http://www.w3.org/2000/svg","g");l.appendChild(r);let c;return n?c=un(t,o,i,s):c=hn(t,o,i,s),l.appendChild(c),l}function fn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=document.createElementNS("http://www.w3.org/2000/svg","a"),r=document.createElementNS("http://www.w3.org/2000/svg","text");return C(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=t.textContent,s.appendChild(r),s.setAttribute("href",t.href),s}const re=100,pn='',We=(e,t=!1)=>{var u,d,p;const n=e.nodes,o=n.offsetHeight+re*2,i=n.offsetWidth+re*2,s=an(o+"px",i+"px"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l=document.createElementNS("http://www.w3.org/2000/svg","rect");C(l,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),s.appendChild(l),n.querySelectorAll(".subLines").forEach(g=>{const m=g.cloneNode(!0),{offsetLeft:f,offsetTop:v}=V(n,g.parentElement);m.setAttribute("x",`${f}`),m.setAttribute("y",`${v}`),r.appendChild(m)});const c=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);c&&r.appendChild(c);const h=(d=n.querySelector(".topiclinks"))==null?void 0:d.cloneNode(!0);h&&r.appendChild(h);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(g=>{r.appendChild(ue(e,g,!t))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(fn(e,g))}),C(r,{x:re+"",y:re+"",overflow:"visible"}),s.appendChild(r),pn+s.outerHTML};function mn(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=i=>{t(i.target.result)},o.onerror=i=>{n(i)},o.readAsDataURL(e)})}const gn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1){const t=We(this,e),n=new Blob([t],{type:"image/svg+xml"}),o=await mn(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(e=!1){const t=We(this,e);return new Blob([t],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function vn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Ie=Object.keys(ze),Ke={};for(let e=0;e({nodeData:{id:Y(),topic:e||"new topic",root:!0,children:[]},linkData:{}}),M}();