mind-elixir 5.0.0-beta.28 → 5.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/MindElixir.iife.js
CHANGED
|
@@ -15,4 +15,4 @@ var MindElixir=function(){"use strict";var Gn=Object.defineProperty;var Jn=(I,N,
|
|
|
15
15
|
`,je(o),e.scrollIntoView(o),o.addEventListener("keydown",r=>{r.stopPropagation();const c=r.key;if(c==="Enter"||c==="Tab"){if(r.shiftKey)return;r.preventDefault(),o.blur(),e.map.focus()}}),o.addEventListener("blur",()=>{var c;if(!o)return;const r=((c=o.textContent)==null?void 0:c.trim())||"";r===""?n.label=s:n.label=r,o.remove(),r!==s&&(t.innerHTML=n.label,e.linkDiv(),"parent"in n?e.bus.fire("operation",{name:"finishEditSummary",obj:n}):e.bus.fire("operation",{name:"finishEditArrowLabel",obj:n}))})},kt=function(e){const t=this.map.querySelector("me-root"),n=t.offsetTop,o=t.offsetLeft,s=t.offsetWidth,i=t.offsetHeight,c=this.nodes.offsetWidth;this.nodes.style.top=`${1e4-this.nodes.offsetHeight/2}px`,this.alignment==="root"?this.nodes.style.left=`${1e4-o-s/2}px`:this.nodes.style.left=`${1e4-c/2}px`;const h=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="";for(let u=0;u<h.length;u++){const l=h[u],a=l.querySelector("me-tpc"),{offsetLeft:p,offsetTop:v}=H(this.nodes,a),m=a.offsetWidth,d=a.offsetHeight,f=l.parentNode.className,g=this.generateMainBranch({pT:n,pL:o,pW:s,pH:i,cT:v,cL:p,cW:m,cH:d,direction:f,containerHeight:this.nodes.offsetHeight}),y=this.theme.palette,b=a.nodeObj.branchColor||y[u%y.length];a.style.borderColor=b,this.lines.appendChild(De(g,b,"3"));const E=l.children[0].children[1];if(E&&(E.style.top=(E.parentNode.offsetHeight-E.offsetHeight)/2+"px",f===k.LHS?E.style.left="-10px":E.style.right="-10px"),e&&e!==l)continue;const x=G("subLines"),w=l.lastChild;w.tagName==="svg"&&w.remove(),l.appendChild(x),He(this,x,b,l,f,!0)}this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},He=function(e,t,n,o,s,i){const r=o.firstChild,c=o.children[1].children;if(c.length===0)return;const h=r.offsetTop,u=r.offsetLeft,l=r.offsetWidth,a=r.offsetHeight;for(let p=0;p<c.length;p++){const v=c[p],m=v.firstChild,d=m.offsetTop,f=m.offsetLeft,g=m.offsetWidth,y=m.offsetHeight,b=m.firstChild.nodeObj.branchColor||n,E=e.generateSubBranch({pT:h,pL:u,pW:l,pH:a,cT:d,cL:f,cW:g,cH:y,direction:s,isFirst:i});t.appendChild(De(E,b,"2"));const x=m.children[1];if(x){if(x.style.bottom=-(x.offsetHeight/2)+"px",s===k.LHS?x.style.left="10px":s===k.RHS&&(x.style.right="10px"),!x.expanded)continue}else continue;He(e,t,b,v,s)}},Pe={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",clickTips:"请点击目标节点",summary:"摘要"},Be={cn:Pe,zh_CN:Pe,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"},it:{addChild:"Aggiungi figlio",addParent:"Aggiungi genitore",addSibling:"Aggiungi fratello",removeNode:"Rimuovi nodo",focus:"Modalità Focus",cancelFocus:"Annulla Modalità Focus",moveUp:"Sposta su",moveDown:"Sposta giù",link:"Collega",clickTips:"Si prega di fare clic sul nodo di destinazione",summary:"Unisci nodi"},es:{addChild:"Agregar hijo",addParent:"Agregar padre",addSibling:"Agregar hermano",removeNode:"Eliminar nodo",focus:"Modo Enfoque",cancelFocus:"Cancelar Modo Enfoque",moveUp:"Mover hacia arriba",moveDown:"Mover hacia abajo",link:"Enlace",clickTips:"Por favor haga clic en el nodo de destino",summary:"Resumen"},fr:{addChild:"Ajout enfant",addParent:"Ajout parent",addSibling:"Ajout voisin",removeNode:"Supprimer",focus:"Cibler",cancelFocus:"Retour",moveUp:"Monter",moveDown:"Descendre",link:"Lier",clickTips:"Cliquer sur le noeud cible",summary:"Annoter"},ko:{addChild:"자식 추가",addParent:"부모 추가",addSibling:"형제 추가",removeNode:"노드 삭제",focus:"포커스 모드",cancelFocus:"포커스 모드 취소",moveUp:"위로 이동",moveDown:"아래로 이동",link:"연결",clickTips:"대상 노드를 클릭하십시오",summary:"요약"}},Zn="";function Lt(e,t){t=t===!0?{focus:!0,link:!0}:t;const n=w=>{const S=document.createElement("div");return S.innerText=w,S.className="tips",S},o=(w,S,C)=>{const M=document.createElement("li");return M.id=w,M.innerHTML=`<span>${te(S)}</span><span ${C?'class="key"':""}>${te(C)}</span>`,M},s=Be[e.locale]?e.locale:"en",i=Be[s],r=o("cm-add_child",i.addChild,"Tab"),c=o("cm-add_parent",i.addParent,"Ctrl + Enter"),h=o("cm-add_sibling",i.addSibling,"Enter"),u=o("cm-remove_child",i.removeNode,"Delete"),l=o("cm-fucus",i.focus,""),a=o("cm-unfucus",i.cancelFocus,""),p=o("cm-up",i.moveUp,"PgUp"),v=o("cm-down",i.moveDown,"Pgdn"),m=o("cm-link",i.link,""),d=o("cm-link-bidirectional","Bidirectional Link",""),f=o("cm-summary",i.summary,""),g=document.createElement("ul");if(g.className="menu-list",g.appendChild(r),g.appendChild(c),g.appendChild(h),g.appendChild(u),t.focus&&(g.appendChild(l),g.appendChild(a)),g.appendChild(p),g.appendChild(v),g.appendChild(f),t.link&&(g.appendChild(m),g.appendChild(d)),t&&t.extend)for(let w=0;w<t.extend.length;w++){const S=t.extend[w],C=o(S.name,S.name,S.key||"");g.appendChild(C),C.onclick=M=>{S.onclick(M)}}const y=document.createElement("div");y.className="context-menu",y.appendChild(g),y.hidden=!0,e.container.append(y);let b=!0;const E=w=>{const S=w.target;if(Me(S)){S.parentElement.tagName==="ME-ROOT"?b=!0:b=!1,b?(l.className="disabled",p.className="disabled",v.className="disabled",c.className="disabled",h.className="disabled",u.className="disabled"):(l.className="",p.className="",v.className="",c.className="",h.className="",u.className=""),S.classList.contains("selected")||e.selectNode(S),y.hidden=!1,g.style.top="",g.style.bottom="",g.style.left="",g.style.right="";const C=g.getBoundingClientRect(),M=g.offsetHeight,R=g.offsetWidth,Y=w.clientY-C.top,K=w.clientX-C.left;M+Y>window.innerHeight?(g.style.top="",g.style.bottom="0px"):(g.style.bottom="",g.style.top=Y+15+"px"),R+K>window.innerWidth?(g.style.left="",g.style.right="0px"):(g.style.right="",g.style.left=K+10+"px")}};e.bus.addListener("showContextMenu",E),y.onclick=w=>{w.target===y&&(y.hidden=!0)},r.onclick=()=>{e.addChild(),y.hidden=!0},c.onclick=()=>{e.insertParent(),y.hidden=!0},h.onclick=()=>{b||(e.insertSibling("after"),y.hidden=!0)},u.onclick=()=>{b||(e.removeNodes(e.currentNodes||[]),y.hidden=!0)},l.onclick=()=>{b||(e.focusNode(e.currentNode),y.hidden=!0)},a.onclick=()=>{e.cancelFocus(),y.hidden=!0},p.onclick=()=>{b||(e.moveUpNode(),y.hidden=!0)},v.onclick=()=>{b||(e.moveDownNode(),y.hidden=!0)};const x=w=>{y.hidden=!0;const S=e.currentNode,C=n(i.clickTips);e.container.appendChild(C),e.map.addEventListener("click",M=>{M.preventDefault(),C.remove();const R=M.target;(R.parentElement.tagName==="ME-PARENT"||R.parentElement.tagName==="ME-ROOT")&&e.createArrow(S,R,w)},{once:!0})};return m.onclick=()=>x(),d.onclick=()=>x({bidirectional:!0}),f.onclick=()=>{y.hidden=!0,e.createSummary(),e.unselectNodes(e.currentNodes)},()=>{r.onclick=null,c.onclick=null,h.onclick=null,u.onclick=null,l.onclick=null,a.onclick=null,p.onclick=null,v.onclick=null,m.onclick=null,f.onclick=null,y.onclick=null,e.container.oncontextmenu=null}}const ve=document,At=function(e,t){if(!t)return ye(e),e;let n=e.querySelector(".insert-preview");const o=`insert-preview ${t} show`;return n||(n=ve.createElement("div"),e.appendChild(n)),n.className=o,e},ye=function(e){if(!e)return;const t=e.querySelectorAll(".insert-preview");for(const n of t||[])n.remove()},Re=function(e,t){for(const n of t){const o=n.parentElement.parentElement.contains(e);if(!(e&&e.tagName==="ME-TPC"&&e!==n&&!o&&e.nodeObj.parent))return!1}return!0},jt=function(e){const t=document.createElement("div");return t.className="mind-elixir-ghost",e.map.appendChild(t),t};class Dt{constructor(t){Q(this,"mind");Q(this,"isMoving",!1);Q(this,"interval",null);Q(this,"speed",20);this.mind=t}move(t,n){this.isMoving||(this.isMoving=!0,this.interval=setInterval(()=>{this.mind.move(t*this.speed*this.mind.scaleVal,n*this.speed*this.mind.scaleVal)},100))}stop(){this.isMoving=!1,clearInterval(this.interval)}}function Ot(e){let t=null,n=null;const o=jt(e),s=new Dt(e),i=u=>{e.selection.cancel();const l=u.target;if((l==null?void 0:l.tagName)!=="ME-TPC"){u.preventDefault();return}let a=e.currentNodes;a!=null&&a.includes(l)||(e.selectNode(l),a=e.currentNodes),e.dragged=a,a.length>1?o.innerHTML=a.length+"":o.innerHTML=l.innerHTML;for(const p of a)p.parentElement.parentElement.style.opacity="0.5";u.dataTransfer.setDragImage(o,0,0),u.dataTransfer.dropEffect="move",e.dragMoveHelper.clear()},r=u=>{const{dragged:l}=e;if(!l)return;s.stop();for(const p of l)p.parentElement.parentElement.style.opacity="1";const a=u.target;a.style.opacity="",n&&(ye(n),t==="before"?e.moveNodeBefore(l,n):t==="after"?e.moveNodeAfter(l,n):t==="in"&&e.moveNodeIn(l,n),e.dragged=null)},c=u=>{u.preventDefault();const l=12*e.scaleVal,{dragged:a}=e;if(!a)return;const p=e.container.getBoundingClientRect();u.clientX<p.x+50?s.move(1,0):u.clientX>p.x+p.width-50?s.move(-1,0):u.clientY<p.y+50?s.move(0,1):u.clientY>p.y+p.height-50?s.move(0,-1):s.stop(),ye(n);const v=ve.elementFromPoint(u.clientX,u.clientY-l);if(Re(v,a)){n=v;const m=v.getBoundingClientRect(),d=m.y;u.clientY>d+m.height?t="after":t="in"}else{const m=ve.elementFromPoint(u.clientX,u.clientY+l),d=m.getBoundingClientRect();if(Re(m,a)){n=m;const f=d.y;u.clientY<f?t="before":t="in"}else t=n=null}n&&At(n,t)};return pe([{dom:e.map,evt:"dragstart",func:i},{dom:e.map,evt:"dragend",func:r},{dom:e.map,evt:"dragover",func:c}])}const $t=function(e){return["createSummary","removeSummary","finishEditSummary"].includes(e.name)?{type:"summary",value:e.obj.id}:["createArrow","removeArrow","finishEditArrowLabel"].includes(e.name)?{type:"arrow",value:e.obj.id}:["removeNodes","copyNodes","moveNodeBefore","moveNodeAfter","moveNodeIn"].includes(e.name)?{type:"nodes",value:e.objs.map(t=>t.id)}:{type:"node",value:e.obj.id}};function Ht(e){let t=[],n=-1,o=e.getData();e.undo=function(){if(n>-1){const r=t[n];o=r.prev,e.refresh(r.prev);try{r.currentObject.type==="node"?e.selectNode(this.findEle(r.currentObject.value)):r.currentObject.type==="nodes"&&e.selectNodes(r.currentObject.value.map(c=>this.findEle(c)))}catch{}finally{n--}}},e.redo=function(){if(n<t.length-1){n++;const r=t[n];o=r.next,e.refresh(r.next),r.currentObject.type==="node"?e.selectNode(this.findEle(r.currentObject.value)):r.currentObject.type==="nodes"&&(e.unselectNodes(this.currentNodes),e.selectNodes(r.currentObject.value.map(c=>this.findEle(c))))}};const s=function(r){if(r.name==="beginEdit")return;t=t.slice(0,n+1);const c=e.getData();t.push({prev:o,currentObject:$t(r),next:c}),o=c,n=t.length-1},i=function(r){(r.metaKey||r.ctrlKey)&&(r.shiftKey&&r.key==="Z"||r.key==="y")?e.redo():(r.metaKey||r.ctrlKey)&&r.key==="z"&&e.undo()};return e.bus.addListener("operation",s),e.map.addEventListener("keydown",i),()=>{e.bus.removeListener("operation",s),e.map.removeEventListener("keydown",i)}}const Qn="",q=(e,t)=>{const n=document.createElement("span");return n.id=e,n.innerHTML=`<svg class="icon" aria-hidden="true">
|
|
16
16
|
<use xlink:href="#icon-${t}"></use>
|
|
17
17
|
</svg>`,n};function Pt(e){const t=document.createElement("div"),n=q("fullscreen","full"),o=q("toCenter","living"),s=q("zoomout","move"),i=q("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(s),t.appendChild(i),t.className="mind-elixir-toolbar rb",n.onclick=()=>{e.el.requestFullscreen()},o.onclick=()=>{e.toCenter()},s.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-.2)},i.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+.2)},t}function Bt(e){const t=document.createElement("div"),n=q("tbltl","left"),o=q("tbltr","right"),s=q("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(s),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},s.onclick=()=>{e.initSide()},t}function Rt(e){e.container.append(Pt(e)),e.container.append(Bt(e))}/*! @viselect/vanilla v3.9.0 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */class zt{constructor(){this._listeners=new Map,this.on=this.addEventListener,this.off=this.removeEventListener,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 s of this._listeners.get(t)??[])o=s(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const ze=(e,t="px")=>typeof e=="number"?e+t:e,P=({style:e},t,n)=>{if(typeof t=="object")for(const[o,s]of Object.entries(t))s!==void 0&&(e[o]=ze(s));else n!==void 0&&(e[t]=ze(n))},Fe=(e=0,t=0,n=0,o=0)=>{const s={x:e,y:t,width:n,height:o,top:t,left:e,right:e+n,bottom:t+o};return{...s,toJSON:()=>JSON.stringify(s)}},Ft=e=>{let t,n=-1,o=!1;return{next:(...s)=>{t=s,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel:()=>{cancelAnimationFrame(n),o=!1}}},qe=(e,t,n="touch")=>{switch(n){case"center":{const o=t.left+t.width/2,s=t.top+t.height/2;return o>=e.left&&o<=e.right&&s>=e.top&&s<=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}},qt=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Vt=()=>"safari"in window,be=e=>Array.isArray(e)?e:[e],Ve=e=>(t,n,o,s={})=>{(t instanceof HTMLCollection||t instanceof NodeList)&&(t=Array.from(t)),n=be(n),t=be(t);for(const i of t)if(i)for(const r of n)i[e](r,o,{capture:!1,...s})},B=Ve("addEventListener"),D=Ve("removeEventListener"),ce=e=>{var t;const{clientX:n,clientY:o,target:s}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:s}},X=(e,t=document)=>be(e).map(n=>typeof n=="string"?Array.from(t.querySelectorAll(n)):n instanceof Element?n:null).flat().filter(Boolean),Yt=(e,t)=>t.some(n=>typeof n=="number"?e.button===n:typeof n=="object"?n.button!==e.button?!1:n.modifiers.every(o=>{switch(o){case"alt":return e.altKey;case"ctrl":return e.ctrlKey||e.metaKey;case"shift":return e.shiftKey}}):!1),{abs:V,max:Ye,min:Ke,ceil:Ie}=Math,Xe=(e=[])=>({stored:e,selected:[],touched:[],changed:{added:[],removed:[]}}),We=class extends zt{constructor(t){var n,o,s,i,r;super(),this._selection=Xe(),this._targetBoundaryScrolled=!0,this._selectables=[],this._areaLocation={y1:0,x2:0,y2:0,x1:0},this._areaRect=Fe(),this._singleClick=!0,this._scrollAvailable=!0,this._scrollingActive=!1,this._scrollSpeed={x:0,y:0},this._scrollDelta={x:0,y:0},this._lastMousePosition={x:0,y:0},this.enable=this._toggleStartEvents,this.disable=this._toggleStartEvents.bind(this,!1),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...t,behaviour:{overlap:"invert",intersect:"touch",triggers:[0],...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,...(i=(s=t.behaviour)==null?void 0:s.scrolling)==null?void 0:i.startScrollMargins}}},features:{range:!0,touch:!0,deselectOnBlur:!1,...t.features,singleTap:{allow:!0,intersect:"native",...(r=t.features)==null?void 0:r.singleTap}}};for(const l of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[l]=="function"&&(this[l]=this[l].bind(this));const{document:c,selectionAreaClass:h,selectionContainerClass:u}=this._options;this._area=c.createElement("div"),this._clippingElement=c.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(h),u&&this._clippingElement.classList.add(u),P(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),P(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=Ft(l=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",l),this._redrawSelectionArea()}),this.enable()}_toggleStartEvents(t=!0){const{document:n,features:o}=this._options,s=t?B:D;s(n,"mousedown",this._onTapStart),o.touch&&s(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:s,target:i}=ce(t),{document:r,startAreas:c,boundaries:h,features:u,behaviour:l}=this._options,a=i.getBoundingClientRect();if(t instanceof MouseEvent&&!Yt(t,l.triggers))return;const p=X(c,r),v=X(h,r);this._targetElement=v.find(g=>qe(g.getBoundingClientRect(),a));const m=t.composedPath(),d=p.find(g=>m.includes(g));if(this._targetBoundary=v.find(g=>m.includes(g)),!this._targetElement||!d||!this._targetBoundary||!n&&this._emitEvent("beforestart",t)===!1)return;this._areaLocation={x1:o,y1:s,x2:0,y2:0};const f=r.scrollingElement??r.body;this._scrollDelta={x:f.scrollLeft,y:f.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),B(r,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),B(r,["mouseup","touchcancel","touchend"],this._onTapStop),B(r,"scroll",this._onScroll),u.deselectOnBlur&&(this._targetBoundaryScrolled=!1,B(this._targetBoundary,"scroll",this._onStartAreaScroll))}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,s=ce(t);let i;if(n==="native")i=s.target;else if(n==="touch"){this.resolveSelectables();const{x:c,y:h}=s;i=this._selectables.find(u=>{const{right:l,left:a,top:p,bottom:v}=u.getBoundingClientRect();return c<l&&c>a&&h<v&&h>p})}if(!i)return;for(this.resolveSelectables();!this._selectables.includes(i);)if(i.parentElement)i=i.parentElement;else{this._targetBoundaryScrolled||this.clearSelection();return}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const c=this._latestElement,[h,u]=c.compareDocumentPosition(i)&4?[i,c]:[c,i],l=[...this._selectables.filter(a=>a.compareDocumentPosition(h)&4&&a.compareDocumentPosition(u)&2),h,u];this.select(l),this._latestElement=c}else r.includes(i)&&(r.length===1||t.ctrlKey||r.every(c=>this._selection.stored.includes(c)))?this.deselect(i):(this.select(i),this._latestElement=i)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:s}}=this._options,{x1:i,y1:r}=this._areaLocation,{x:c,y:h}=ce(t);if(typeof s=="number"&&V(c+h-(i+r))>=s||typeof s=="object"&&V(c-i)>=s.x||V(h-r)>=s.y){if(D(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){D(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}B(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),P(this._area,"display","block"),X(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&&(B(this._targetElement,"wheel",this._wheelScroll,{passive:!1}),B(this._options.document,"keydown",this._keyboardScroll,{passive:!1}),this._selectables=this._selectables.filter(u=>this._targetElement.contains(u))),this._setupSelectionArea(),this._emitEvent("start",t),this._onTapMove(t)}this._handleMoveEvent(t)}_setupSelectionArea(){const{_clippingElement:t,_targetElement:n,_area:o}=this,s=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(P(t,{top:s.top,left:s.left,width:s.width,height:s.height}),P(o,{marginTop:-s.top,marginLeft:-s.left})):(P(t,{top:0,left:0,width:"100%",height:"100%"}),P(o,{marginTop:0,marginLeft:0}))}_onTapMove(t){const{_scrollSpeed:n,_areaLocation:o,_options:s,_frame:i}=this,{speedDivider:r}=s.behaviour.scrolling,c=this._targetElement,{x:h,y:u}=ce(t);if(o.x2=h,o.y2=u,this._lastMousePosition.x=h,this._lastMousePosition.y=u,this._scrollAvailable&&!this._scrollingActive&&(n.y||n.x)){this._scrollingActive=!0;const l=()=>{if(!n.x&&!n.y){this._scrollingActive=!1;return}const{scrollTop:a,scrollLeft:p}=c;n.y&&(c.scrollTop+=Ie(n.y/r),o.y1-=c.scrollTop-a),n.x&&(c.scrollLeft+=Ie(n.x/r),o.x1-=c.scrollLeft-p),i.next(t),requestAnimationFrame(l)};requestAnimationFrame(l)}else i.next(t);this._handleMoveEvent(t)}_handleMoveEvent(t){const{features:n}=this._options;(n.touch&&qt()||this._scrollAvailable&&Vt())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:s}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-s,this._areaLocation.y1+=t.y-o,t.x=s,t.y=o,this._setupSelectionArea(),this._frame.next(null)}_onStartAreaScroll(){this._targetBoundaryScrolled=!0,D(this._targetElement,"scroll",this._onStartAreaScroll)}_wheelScroll(t){const{manualSpeed:n}=this._options.behaviour.scrolling,o=t.deltaY?t.deltaY>0?1:-1:0,s=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=s*n,this._onTapMove(t),t.preventDefault()}_keyboardScroll(t){const{manualSpeed:n}=this._options.behaviour.scrolling,o=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,s=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;this._scrollSpeed.x+=Math.sign(o)*n,this._scrollSpeed.y+=Math.sign(s)*n,t.preventDefault(),this._onTapMove({clientX:this._lastMousePosition.x,clientY:this._lastMousePosition.y,preventDefault:()=>{}})}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_targetElement:o,_options:s}=this,{scrollTop:i,scrollHeight:r,clientHeight:c,scrollLeft:h,scrollWidth:u,clientWidth:l}=o,a=this._targetRect,{x1:p,y1:v}=n;let{x2:m,y2:d}=n;const{behaviour:{scrolling:{startScrollMargins:f}}}=s;m<a.left+f.x?(t.x=h?-V(a.left-m+f.x):0,m=m<a.left?a.left:m):m>a.right-f.x?(t.x=u-h-l?V(a.left+a.width-m-f.x):0,m=m>a.right?a.right:m):t.x=0,d<a.top+f.y?(t.y=i?-V(a.top-d+f.y):0,d=d<a.top?a.top:d):d>a.bottom-f.y?(t.y=r-i-c?V(a.top+a.height-d-f.y):0,d=d>a.bottom?a.bottom:d):t.y=0;const g=Ke(p,m),y=Ke(v,d),b=Ye(p,m),E=Ye(v,d);this._areaRect=Fe(g,y,b-g,E-y)}_redrawSelectionArea(){const{x:t,y:n,width:o,height:s}=this._areaRect,{style:i}=this._area;i.left=`${t}px`,i.top=`${n}px`,i.width=`${o}px`,i.height=`${s}px`}_onTapStop(t,n){var o;const{document:s,features:i}=this._options,{_singleClick:r}=this;D(this._targetElement,"scroll",this._onStartAreaScroll),D(s,["mousemove","touchmove"],this._delayedTapMove),D(s,["touchmove","mousemove"],this._onTapMove),D(s,["mouseup","touchcancel","touchend"],this._onTapStop),D(s,"scroll",this._onScroll),this._keepSelection(),t&&r&&i.singleTap.allow?this._onSingleTap(t):!r&&!n&&(this._updateElementSelection(),this._emitEvent("stop",t)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,D(this._targetElement,"wheel",this._wheelScroll,{passive:!0}),D(this._options.document,"keydown",this._keyboardScroll,{passive:!0}),this._clippingElement.remove(),(o=this._frame)==null||o.cancel(),P(this._area,"display","none")}_updateElementSelection(){const{_selectables:t,_options:n,_selection:o,_areaRect:s}=this,{stored:i,selected:r,touched:c}=o,{intersect:h,overlap:u}=n.behaviour,l=u==="invert",a=[],p=[],v=[];for(let d=0;d<t.length;d++){const f=t[d];if(qe(s,f.getBoundingClientRect(),h)){if(r.includes(f))i.includes(f)&&!c.includes(f)&&c.push(f);else if(l&&i.includes(f)){v.push(f);continue}else p.push(f);a.push(f)}}l&&p.push(...i.filter(d=>!r.includes(d)));const m=u==="keep";for(let d=0;d<r.length;d++){const f=r[d];!a.includes(f)&&!(m&&i.includes(f))&&v.push(f)}o.selected=a,o.changed={added:p,removed:v},this._latestElement=void 0}_emitEvent(t,n){return this.emit(t,{event:n,store:this._selection,selection:this})}_keepSelection(){const{_options:t,_selection:n}=this,{selected:o,changed:s,touched:i,stored:r}=n,c=o.filter(h=>!r.includes(h));switch(t.behaviour.overlap){case"drop":{n.stored=[...c,...r.filter(h=>!i.includes(h))];break}case"invert":{n.stored=[...c,...r.filter(h=>!s.removed.includes(h))];break}case"keep":{n.stored=[...r,...o.filter(h=>!r.includes(h))];break}}}trigger(t,n=!0){this._onTapStart(t,n)}resolveSelectables(){this._selectables=X(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:s,changed:i}=this._selection;i.added=[],i.removed.push(...o,...t?s:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection=Xe(t?[]:s)}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}getSelectables(){return this._selectables}setAreaLocation(t){Object.assign(this._areaLocation,t),this._redrawSelectionArea()}getAreaLocation(){return this._areaLocation}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:s,stored:i}=this._selection,r=X(t,this._options.document).filter(c=>!s.includes(c)&&!i.includes(c));return i.push(...r),s.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:s,changed:i}=this._selection,r=X(t,this._options.document).filter(c=>o.includes(c)||s.includes(c));this._selection.stored=s.filter(c=>!r.includes(c)),this._selection.selected=o.filter(c=>!r.includes(c)),this._selection.changed.added=[],this._selection.changed.removed.push(...r.filter(c=>!i.removed.includes(c))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null))}};We.version="3.9.0";let Kt=We;function It(e){const t=e.mouseSelectionButton===2?[2]:[0],n=new Kt({selectables:[".map-container me-tpc"],boundaries:[e.container],container:e.selectionContainer,features:{touch:!1},behaviour:{triggers:t,scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:10,y:10}}}}).on("beforestart",({event:o})=>{const s=o.target;if(s.id==="input-box"||s.className==="circle"||!e.map.contains(s))return!1;if(!o.ctrlKey&&!o.metaKey){if(s.tagName==="ME-TPC"&&s.classList.contains("selected"))return!1;e.clearSelection()}const i=n.getSelectionArea();return i.style.background="#4f90f22d",i.style.border="1px solid #4f90f2",i.parentElement&&(i.parentElement.style.zIndex="9999"),!0}).on("move",({store:{changed:{added:o,removed:s}}})=>{if(o.length>0||s.length>0,o.length>0){for(const i of o)i.className="selected";e.currentNodes=[...e.currentNodes,...o],e.bus.fire("selectNodes",o.map(i=>i.nodeObj))}if(s.length>0){for(const i of s)i.classList.remove("selected");e.currentNodes=e.currentNodes.filter(i=>!(s!=null&&s.includes(i))),e.bus.fire("unselectNodes",s.map(i=>i.nodeObj))}});e.selection=n}const Xt=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let s=0;s<o.length;s++){const i=o[s];this.container.style.setProperty(i,n[i])}e.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),t&&this.refresh()},W=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=(t==null?void 0:t.indexOf(e))??0;return{siblings:t,index:n}};function Wt(e){const{siblings:t,index:n}=W(e);if(t===void 0)return;const o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Ut(e){const{siblings:t,index:n}=W(e);if(t===void 0)return;const o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function Ue(e){const{siblings:t,index:n}=W(e);return t===void 0?0:(t.splice(n,1),t.length)}function Gt(e,t,n){const{siblings:o,index:s}=W(n);o!==void 0&&(t==="before"?o.splice(s,0,e):o.splice(s+1,0,e))}function Jt(e,t){const{siblings:n,index:o}=W(e);n!==void 0&&(n[o]=t,t.children=[e])}function Ge(e,t,n){var o;if(Ue(t),(o=n.parent)!=null&&o.parent||(t.direction=n.direction),e==="in")n.children?n.children.push(t):n.children=[t];else{t.direction!==void 0&&(t.direction=n.direction);const{siblings:s,index:i}=W(n);if(s===void 0)return;e==="before"?s.splice(i,0,t):s.splice(i+1,0,t)}}const Zt=function({map:e,direction:t},n){var o,s;if(t===N)return N;if(t===T)return T;if(t===ee){const i=((o=e.querySelector(".lhs"))==null?void 0:o.childElementCount)||0,r=((s=e.querySelector(".rhs"))==null?void 0:s.childElementCount)||0;return i<=r?(n.direction=N,N):(n.direction=T,T)}},Je=function(e,t,n){var i,r;const o=n.children[0].children[0],s=t.parentElement;if(s.tagName==="ME-PARENT"){if(J(o),s.children[1])s.nextSibling.appendChild(n);else{const c=e.createChildren([n]);s.appendChild(ge(!0)),s.insertAdjacentElement("afterend",c)}e.linkDiv(n.offsetParent)}else s.tagName==="ME-ROOT"&&(Zt(e,o.nodeObj)===N?(i=e.container.querySelector(".lhs"))==null||i.appendChild(n):(r=e.container.querySelector(".rhs"))==null||r.appendChild(n),e.linkDiv())},Qt=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&(o.previousSibling.children[1].remove(),o.remove())}n.parentNode.remove()},Ze={before:"beforebegin",after:"afterend"},J=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},en=function(e,t){const n=e.nodeObj,o=fe(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const s=Object.assign(n,t);me(e,s),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:s,origin:o})},xe=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=e.findEle(o.id));const s=n||e.generateNewObj();o.children?o.children.push(s):o.children=[s],$(e.nodeData);const{grp:i,top:r}=e.createWrapper(s);return Je(e,t,i),{newTop:r,newNodeObj:s}},tn=function(e,t,n){var u,l,a,p;const o=t||this.currentNode;if(!o)return;const s=o.nodeObj;if(s.parent){if(!((u=s.parent)!=null&&u.parent)&&((a=(l=s.parent)==null?void 0:l.children)==null?void 0:a.length)===1){this.addChild(this.findEle(s.parent.id),n);return}}else{this.addChild();return}const i=n||this.generateNewObj();if(!((p=s.parent)!=null&&p.parent)){const v=o.closest("me-main").className===k.LHS?N:T;i.direction=v}Gt(i,e,s),$(this.nodeData);const r=o.parentElement,{grp:c,top:h}=this.createWrapper(i);r.parentElement.insertAdjacentElement(Ze[e],c),this.linkDiv(c.offsetParent),n||this.editTopic(h.firstChild),this.selectNode(h.firstChild,!0),this.bus.fire("operation",{name:"insertSibling",type:e,obj:i})},nn=function(e,t){const n=e||this.currentNode;if(!n)return;J(n);const o=n.nodeObj;if(!o.parent)return;const s=t||this.generateNewObj();Jt(o,s),$(this.nodeData);const i=n.parentElement.parentElement,{grp:r,top:c}=this.createWrapper(s,!0);c.appendChild(ge(!0)),i.insertAdjacentElement("afterend",r);const h=this.createChildren([i]);c.insertAdjacentElement("afterend",h),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:s})},on=function(e,t){const n=e||this.currentNode;if(!n)return;const o=xe(this,n,t);if(!o)return;const{newTop:s,newNodeObj:i}=o;this.bus.fire("operation",{name:"addChild",obj:i}),t||this.editTopic(s.firstChild),this.selectNode(s.firstChild,!0)},sn=function(e,t){const n=fe(e.nodeObj);ue(n);const o=xe(this,t,n);if(!o)return;const{newNodeObj:s}=o;this.selectNode(this.findEle(s.id)),this.bus.fire("operation",{name:"copyNode",obj:s})},rn=function(e,t){e=se(e);const n=[];for(let o=0;o<e.length;o++){const s=e[o],i=fe(s.nodeObj);ue(i);const r=xe(this,t,i);if(!r)return;const{newNodeObj:c}=r;n.push(c)}this.unselectNodes(this.currentNodes),this.selectNodes(n.map(o=>this.findEle(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},cn=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Wt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},ln=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ut(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})},an=function(e){if(e.length===0)return;e=se(e);for(const n of e){const o=n.nodeObj,s=Ue(o);Qt(n,s)}const t=e[e.length-1];this.selectNode(this.findEle(t.nodeObj.parent.id)),this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(n=>n.nodeObj)})},dn=function(e,t){e=se(e);const n=t.nodeObj;n.expanded===!1&&(this.expandNode(t,!0),t=this.findEle(n.id));for(const o of e){const s=o.nodeObj;Ge("in",s,n),$(this.nodeData);const i=o.parentElement;Je(this,t,i.parentElement)}this.linkDiv(),this.bus.fire("operation",{name:"moveNodeIn",objs:e.map(o=>o.nodeObj),toObj:n})},Qe=(e,t,n,o)=>{e=se(e),t==="after"&&(e=e.reverse());const s=n.nodeObj,i=[];for(const r of e){const c=r.nodeObj;Ge(t,c,s),$(o.nodeData),J(r);const h=r.parentElement.parentNode;i.includes(h.parentElement)||i.push(h.parentElement),n.parentElement.parentNode.insertAdjacentElement(Ze[t],h)}for(const r of i)r.childElementCount===0&&r.tagName!=="ME-MAIN"&&(r.previousSibling.children[1].remove(),r.remove());o.linkDiv(),o.bus.fire("operation",{name:t==="before"?"moveNodeBefore":"moveNodeAfter",objs:e.map(r=>r.nodeObj),toObj:s})},et=Object.freeze(Object.defineProperty({__proto__:null,addChild:on,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:sn,copyNodes:rn,insertParent:nn,insertSibling:tn,moveDownNode:ln,moveNodeAfter:function(e,t){Qe(e,"after",t,this)},moveNodeBefore:function(e,t){Qe(e,"before",t,this)},moveNodeIn:dn,moveUpNode:cn,removeNodes:an,reshapeNode:en,rmSubline:J,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function hn(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const un=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:function(){this.unselectNodes(this.currentNodes),this.unselectSummary(),this.unselectArrow()},disableEdit:function(){this.editable=!1},enableEdit:function(){this.editable=!0},expandNode:function(e,t){const n=e.nodeObj;typeof t=="boolean"?n.expanded=t:n.expanded!==!1?n.expanded=!1:n.expanded=!0;const o=e.parentNode,s=o.children[1];if(s.expanded=n.expanded,s.className=n.expanded?"minus":"",J(e),n.expanded){const h=this.createChildren(n.children.map(u=>this.createWrapper(u).grp));o.parentNode.appendChild(h)}else o.parentNode.children[1].remove();this.linkDiv(e.closest("me-main > me-wrapper"));const i=e.getBoundingClientRect(),r=this.container.getBoundingClientRect();(i.bottom>r.bottom||i.top<r.top||i.right>r.right||i.left<r.left)&&this.scrollIntoView(e),this.bus.fire("expandNode",n)},expandNodeAll:function(e,t){const n=e.nodeObj,o=(s,i)=>{s.expanded=i,s.children&&s.children.forEach(r=>{o(r,i)})};typeof t=="boolean"?o(n,t):n.expanded!==!1?o(n,!1):o(n,!0),this.refresh()},focusNode:function(e){e.nodeObj.parent&&(this.clearSelection(),this.tempDirection===null&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.initRight(),this.toCenter())},getData:function(){return JSON.parse(this.getDataString())},getDataString:function(){const e=hn(this);return JSON.stringify(e,(t,n)=>{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)},move:function(e,t){const{map:n,scaleVal:o,container:s,bus:i}=this,r=n.style.transform,{x:c,y:h}=Te(r),u=c+e,l=h+t,a=(1-o)*1e4,p=0-a,v=-2e4+s.offsetWidth+a,m=-2e4+s.offsetHeight+a,d=Math.min(p,Math.max(v,u)),f=Math.min(p,Math.max(m,l));n.style.transform=`translate(${d}px, ${f}px) scale(${o})`,i.fire("move",{dx:e,dy:t})},refresh:function(e){e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.arrows=e.arrows||[],this.summaries=e.summaries||[]),$(this.nodeData),this.layout(),this.linkDiv()},scale:function(e,t={x:0,y:0}){const n=this.container.getBoundingClientRect(),o=n.width/2-1e4,s=n.height/2-1e4,i=this.scaleVal,r=this.map.style.transform,{x:c,y:h}=Te(r),u=c-(t.x-n.left-n.width/2),l=h-(t.y-n.top-n.height/2),a=(o-u)*(1-e/i),p=(s-l)*(1-e/i);this.map.style.transform=`translate(${c+a}px, ${h+p}px) scale(${e})`,this.scaleVal=e,this.bus.fire("scale",e)},scaleFit:function(){const e=this.nodes.offsetHeight/this.container.offsetHeight,t=this.nodes.offsetWidth/this.container.offsetWidth,n=1/Math.max(1,Math.max(e,t));this.scaleVal=n,this.map.style.transform="scale("+n+")",this.bus.fire("scale",n)},scrollIntoView:function(e){const t=this.container,n=e.getBoundingClientRect(),o=t.getBoundingClientRect();if(n.bottom>o.bottom||n.top<o.top||n.right>o.right||n.left<o.left){const i=n.left+n.width/2,r=n.top+n.height/2,c=o.left+o.width/2,h=o.top+o.height/2,u=i-c,l=r-h;this.move(-u,-l)}},selectNode:function(e,t,n){this.clearSelection(),this.scrollIntoView(e),this.selection.select(e),t&&this.bus.fire("selectNewNode",e.nodeObj)},selectNodes:function(e){this.selection.select(e)},setLocale:function(e){this.locale=e,this.refresh()},toCenter:function(){const e=this.container.getBoundingClientRect(),t=e.width/2-1e4,n=e.height/2-1e4;this.map.style.transform=`translate(${t}px, ${n}px) scale(${this.scaleVal})`},unselectNodes:function(e){this.selection.deselect(e)}},Symbol.toStringTag,{value:"Module"})),tt={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),this.destroy=pe([{dom:t,evt:"mousemove",func:this.handleMouseMove},{dom:t,evt:"mouseleave",func:this.handleClear},{dom:t,evt:"mouseup",func:this.handleClear},{dom:this.dom,evt:"mousedown",func:this.handleMouseDown}])},destroy:null,clear(){this.moved=!1,this.mousedown=!1}}}};function nt(e,t,n,o,s,i,r,c){return{x:e/8+n*3/8+s*3/8+r/8,y:t/8+o*3/8+i*3/8+c/8}}function fn(e,t,n){_(e,{x:t+"",y:n+""})}function le(e,t,n,o,s){_(e,{x1:t+"",y1:n+"",x2:o+"",y2:s+""})}function ot(e,t,n,o,s,i,r,c,h,u){e.line.setAttribute("d",`M ${t} ${n} C ${o} ${s} ${i} ${r} ${c} ${h}`);const l=oe(i,r,c,h);if(l&&e.arrow1.setAttribute("d",`M ${l.x1} ${l.y1} L ${c} ${h} L ${l.x2} ${l.y2}`),u.bidirectional){const v=oe(o,s,t,n);v&&e.arrow2.setAttribute("d",`M ${v.x1} ${v.y1} L ${t} ${n} L ${v.x2} ${v.y2}`)}const{x:a,y:p}=nt(t,n,o,s,i,r,c,h);fn(e.label,a,p),En(e)}function ae(e,t,n){const{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=t.offsetWidth,r=t.offsetHeight,c=o+i/2,h=s+r/2,u=c+n.x,l=h+n.y;return{w:i,h:r,cx:c,cy:h,ctrlX:u,ctrlY:l}}function U(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 pn=function(e,t,n,o){const s=document.createElementNS(L,"text");return _(s,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),s.dataset.type="custom-link",s.innerHTML=e,s},we=function(e,t,n,o,s){if(!t||!n)return;const i=ae(e,t,o.delta1),r=ae(e,n,o.delta2),{x:c,y:h}=U(i),{ctrlX:u,ctrlY:l}=i,{ctrlX:a,ctrlY:p}=r,{x:v,y:m}=U(r),d=oe(a,p,v,m);if(!d)return;const f=`M ${d.x1} ${d.y1} L ${v} ${m} L ${d.x2} ${d.y2}`;let g="";if(o.bidirectional){const w=oe(u,l,c,h);if(!w)return;g=`M ${w.x1} ${w.y1} L ${c} ${h} L ${w.x2} ${w.y2}`}const y=Tt(`M ${c} ${h} C ${u} ${l} ${a} ${p} ${v} ${m}`,f,g),{x:b,y:E}=nt(c,h,u,l,a,p,v,m),x=pn(o.label,b,E,e.theme.cssVar["--color"]);y.appendChild(x),y.label=x,y.arrowObj=o,y.dataset.linkid=o.id,e.linkSvgGroup.appendChild(y),s||(e.arrows.push(o),e.currentArrow=y,st(e,o,i,r))},mn=function(e,t,n={}){const o={id:z(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:e.offsetWidth/2+100,y:0},delta2:{x:t.offsetWidth/2+100,y:0},...n};we(this,e,t,o),this.bus.fire("operation",{name:"createArrow",obj:o})},gn=function(e){const t={...e,id:z()};we(this,this.findEle(t.from),this.findEle(t.to),t),this.bus.fire("operation",{name:"createArrow",obj:t})},vn=function(e){let t;if(e?t=e:t=this.currentArrow,!t)return;Se(this);const n=t.arrowObj.id;this.arrows=this.arrows.filter(o=>o.id!==n),t.remove(),this.bus.fire("operation",{name:"removeArrow",obj:{id:n}})},yn=function(e){this.currentArrow=e;const t=e.arrowObj,n=this.findEle(t.from),o=this.findEle(t.to),s=ae(this,n,t.delta1),i=ae(this,o,t.delta2);st(this,t,s,i)},bn=function(){Se(this),this.currentArrow=null},Ee=function(e,t){const n=document.createElementNS(L,"path");return _(n,{d:e,stroke:t,fill:"none","stroke-width":"6","stroke-linecap":"round","stroke-linejoin":"round"}),n},xn=function(e,t){const n=document.createElementNS(L,"g");n.setAttribute("class","arrow-highlight"),n.setAttribute("opacity","0.45");const o=Ee(e.line.getAttribute("d"),t);n.appendChild(o);const s=Ee(e.arrow1.getAttribute("d"),t);if(n.appendChild(s),e.arrow2.getAttribute("d")){const i=Ee(e.arrow2.getAttribute("d"),t);n.appendChild(i)}e.insertBefore(n,e.firstChild)},wn=function(e){const t=e.querySelector(".arrow-highlight");t&&t.remove()},En=function(e){const t=e.querySelector(".arrow-highlight");if(!t)return;const n=t.querySelectorAll("path");n.length>=1&&n[0].setAttribute("d",e.line.getAttribute("d")),n.length>=2&&n[1].setAttribute("d",e.arrow1.getAttribute("d")),n.length>=3&&e.arrow2.getAttribute("d")&&n[2].setAttribute("d",e.arrow2.getAttribute("d"))},Se=function(e){var t,n;(t=e.helper1)==null||t.destroy(),(n=e.helper2)==null||n.destroy(),e.linkController.style.display="none",e.P2.style.display="none",e.P3.style.display="none",e.currentArrow&&wn(e.currentArrow)},st=function(e,t,n,o){const{linkController:s,P2:i,P3:r,line1:c,line2:h,nodes:u,map:l,currentArrow:a,bus:p}=e;if(!a)return;s.style.display="initial",i.style.display="initial",r.style.display="initial",u.appendChild(s),u.appendChild(i),u.appendChild(r),xn(a,"#4dc4ff");let{x:m,y:d}=U(n),{ctrlX:f,ctrlY:g}=n,{ctrlX:y,ctrlY:b}=o,{x:E,y:x}=U(o);i.style.cssText=`top:${g}px;left:${f}px;`,r.style.cssText=`top:${b}px;left:${y}px;`,le(c,m,d,f,g),le(h,y,b,E,x),e.helper1=tt.create(i),e.helper2=tt.create(r),e.helper1.init(l,(w,S)=>{f=f+w/e.scaleVal,g=g+S/e.scaleVal;const C=U({...n,ctrlX:f,ctrlY:g});m=C.x,d=C.y,i.style.top=g+"px",i.style.left=f+"px",ot(a,m,d,f,g,y,b,E,x,t),le(c,m,d,f,g),t.delta1.x=f-n.cx,t.delta1.y=g-n.cy,p.fire("updateArrowDelta",t)}),e.helper2.init(l,(w,S)=>{y=y+w/e.scaleVal,b=b+S/e.scaleVal;const C=U({...o,ctrlX:y,ctrlY:b});E=C.x,x=C.y,r.style.top=b+"px",r.style.left=y+"px",ot(a,m,d,f,g,y,b,E,x,t),le(h,y,b,E,x),t.delta2.x=y-o.cx,t.delta2.y=b-o.cy,p.fire("updateArrowDelta",t)})};function Sn(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{we(this,this.findEle(t.from),this.findEle(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function Cn(e){if(Se(this),!e)return;const t=e.label;$e(this,t,e.arrowObj)}function Nn(){this.arrows=this.arrows.filter(e=>ne(e.from,this.nodeData)&&ne(e.to,this.nodeData))}const _n=Object.freeze(Object.defineProperty({__proto__:null,createArrow:mn,createArrowFrom:gn,editArrowLabel:Cn,removeArrow:vn,renderArrow:Sn,selectArrow:yn,tidyArrow:Nn,unselectArrow:bn},Symbol.toStringTag,{value:"Module"})),Mn=function(e){var h,u;if(e.length===0)throw new Error("No selected node.");if(e.length===1){const l=e[0].nodeObj,a=e[0].nodeObj.parent;if(!a)throw new Error("Can not select root node.");const p=a.children.findIndex(v=>l===v);return{parent:a.id,start:p,end:p}}let t=0;const n=e.map(l=>{let a=l.nodeObj;const p=[];for(;a.parent;){const v=a.parent,m=v.children,d=m==null?void 0:m.indexOf(a);a=v,p.unshift({node:a,index:d})}return p.length>t&&(t=p.length),p});let o=0;e:for(;o<t;o++){const l=(h=n[0][o])==null?void 0:h.node;for(let a=1;a<n.length;a++)if(((u=n[a][o])==null?void 0:u.node)!==l)break e}if(!o)throw new Error("Can not select root node.");const s=n.map(l=>l[o-1].index).sort(),i=s[0]||0,r=s[s.length-1]||0,c=n[0][o-1].node;if(!c.parent)throw new Error("Please select nodes in the same main topic.");return{parent:c.id,start:i,end:r}},Tn=function(e){const t=document.createElementNS(L,"g");return t.setAttribute("id",e),t},it=function(e,t){const n=document.createElementNS(L,"path");return _(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},rt=function(e,t,n,o,s){const i=document.createElementNS(L,"text");return _(i,{"text-anchor":o,x:t+"",y:n+"",fill:s||"#666"}),i.innerHTML=e,i},kn=e=>e.parentElement.parentElement,Ln=function(e,{parent:t,start:n}){const o=e.findEle(t),s=o.nodeObj;let i;return s.parent?i=o.closest("me-main").className:i=e.findEle(s.children[n].id).closest("me-main").className,i},Ce=function(e,t){var C;const{id:n,label:o,parent:s,start:i,end:r}=t,{nodes:c,theme:h,summarySvg:u}=e,a=e.findEle(s).nodeObj,p=Ln(e,t);let v=1/0,m=0,d=0,f=0;for(let M=i;M<=r;M++){const R=(C=a.children)==null?void 0:C[M];if(!R)return e.removeSummary(n),null;const Y=kn(e.findEle(R.id)),{offsetLeft:K,offsetTop:at}=H(c,Y),dt=i===r?10:20;M===i&&(d=at+dt),M===r&&(f=at+Y.offsetHeight-dt),K<v&&(v=K),Y.offsetWidth+K>m&&(m=Y.offsetWidth+K)}let g,y;const b=d+10,E=f+10,x=(b+E)/2,w=h.cssVar["--color"];p===k.LHS?(g=it(`M ${v+10} ${b} c -5 0 -10 5 -10 10 L ${v} ${E-10} c 0 5 5 10 10 10 M ${v} ${x} h -10`,w),y=rt(o,v-20,x+6,"end",w)):(g=it(`M ${m-10} ${b} c 5 0 10 5 10 10 L ${m} ${E-10} c 0 5 -5 10 -10 10 M ${m} ${x} h 10`,w),y=rt(o,m+20,x+6,"start",w));const S=Tn("s-"+n);return S.appendChild(g),S.appendChild(y),S.summaryObj=t,u.appendChild(S),S},An=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){if(!this.currentNodes)return;const{currentNodes:e,summaries:t,bus:n}=this,{parent:o,start:s,end:i}=Mn(e),r={id:z(),parent:o,start:s,end:i,label:"summary"},c=Ce(this,r);t.push(r),this.editSummary(c),n.fire("operation",{name:"createSummary",obj:r})},createSummaryFrom:function(e){const t=z(),n={...e,id:t};Ce(this,n),this.summaries.push(n),this.bus.fire("operation",{name:"createSummary",obj:n})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];$e(this,t,e.summaryObj)},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{Ce(this,e)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,s=document.createElementNS(L,"rect");_(s,{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"}),e.appendChild(s),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"})),A="http://www.w3.org/2000/svg";function jn(e,t){const n=document.createElementNS(A,"svg");return _(n,{version:"1.1",xmlns:A,height:e,width:t}),n}function Dn(e,t){return(parseInt(e)-parseInt(t))/2}function On(e,t,n,o){const s=document.createElementNS(A,"g");let i="";return e.text?i=e.text.textContent:i=e.childNodes[0].textContent,i.split(`
|
|
18
|
-
`).forEach((c,h)=>{const u=document.createElementNS(A,"text");_(u,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+Dn(t.lineHeight,t.fontSize)*(h+1)+parseFloat(t.fontSize)*(h+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),u.innerHTML=c,s.appendChild(u)}),s}function $n(e,t,n,o){var c;let s="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(A,"foreignObject");_(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return _(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=s,i.appendChild(r),i}function Hn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"rect");return _(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function de(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=H(e.nodes,t),r=document.createElementNS(A,"rect");_(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const c=document.createElementNS(A,"g");c.appendChild(r);let h;return n?h=$n(t,o,s,i):h=On(t,o,s,i),c.appendChild(h),c}function Pn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"a"),r=document.createElementNS(A,"text");return _(r,{x:o+"",y:s+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,i.appendChild(r),i.setAttribute("href",t.href),i}function Bn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"image");return _(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const he=100,Rn='<?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">',zn=(e,t=!1)=>{var a,p,v;const n=e.nodes,o=n.offsetHeight+he*2,s=n.offsetWidth+he*2,i=jn(o+"px",s+"px"),r=document.createElementNS(A,"svg"),c=document.createElementNS(A,"rect");_(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(c),n.querySelectorAll(".subLines").forEach(m=>{const d=m.cloneNode(!0),{offsetLeft:f,offsetTop:g}=H(n,m.parentElement);d.setAttribute("x",`${f}`),d.setAttribute("y",`${g}`),r.appendChild(d)});const h=(a=n.querySelector(".lines"))==null?void 0:a.cloneNode(!0);h&&r.appendChild(h);const u=(p=n.querySelector(".topiclinks"))==null?void 0:p.cloneNode(!0);u&&r.appendChild(u);const l=(v=n.querySelector(".summary"))==null?void 0:v.cloneNode(!0);return l&&r.appendChild(l),n.querySelectorAll("me-tpc").forEach(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(de(e,m,!t)):(r.appendChild(Hn(e,m)),r.appendChild(de(e,m.text,!t)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(de(e,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(de(e,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(Pn(e,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(Bn(e,m))}),_(r,{x:he+"",y:he+"",overflow:"visible"}),i.appendChild(r),i},Fn=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Rn+e.outerHTML);function qn(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Vn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await qn(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=zn(this,e),o=Fn(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function Yn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const ct=Object.keys(et),lt={};for(let e=0;e<ct.length;e++){const t=ct[e];lt[t]=Yn(et[t],t)}const Kn={getObjById:ne,generateNewObj:ht,layout:xt,linkDiv:kt,editTopic:Mt,createWrapper:St,createParent:Ct,createChildren:Nt,createTopic:_t,findEle:Ae,changeTheme:Xt,...un,...lt,..._n,...An,...Vn,init(e){if(e=JSON.parse(JSON.stringify(e)),!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,$(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Rt(this),this.keypress&&vt(this,this.keypress),this.editable&&It(this),this.contextMenu&&this.disposable.push(Lt(this,this.contextMenu)),this.draggable&&this.disposable.push(Ot(this)),this.allowUndo&&this.disposable.push(Ht(this)),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),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,(e=this.selection)==null||e.destroy(),this.selection=void 0}};function In({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,containerHeight:u}){let l=t+n/2;const a=e+o/2;let p;h===k.LHS?p=i+r:p=i;const v=s+c/2,d=(1-Math.abs(v-a)/u)*.25*(n/2);return h===k.LHS?l=l-n/10-d:l=l+n/10+d,`M ${l} ${a} Q ${l} ${v} ${p} ${v}`}function Xn({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,isFirst:u}){const l=parseInt(this.container.style.getPropertyValue("--gap"));let a=0,p=0;u?a=e+o/2:a=e+o;const v=s+c;let m=0,d=0,f=0;const g=Math.abs(a-v)/300*l;return h===k.LHS?(f=t,m=f+l,d=f-l,p=i+l,`M ${m} ${a} C ${f} ${a} ${f+g} ${v} ${d} ${v} H ${p}`):(f=t+n,m=f-l,d=f+l,p=i+r-l,`M ${m} ${a} C ${f} ${a} ${f-g} ${v} ${d} ${v} H ${p}`)}const Wn="5.0.0-beta.
|
|
18
|
+
`).forEach((c,h)=>{const u=document.createElementNS(A,"text");_(u,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+Dn(t.lineHeight,t.fontSize)*(h+1)+parseFloat(t.fontSize)*(h+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),u.innerHTML=c,s.appendChild(u)}),s}function $n(e,t,n,o){var c;let s="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(A,"foreignObject");_(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return _(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=s,i.appendChild(r),i}function Hn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"rect");return _(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function de(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=H(e.nodes,t),r=document.createElementNS(A,"rect");_(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const c=document.createElementNS(A,"g");c.appendChild(r);let h;return n?h=$n(t,o,s,i):h=On(t,o,s,i),c.appendChild(h),c}function Pn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"a"),r=document.createElementNS(A,"text");return _(r,{x:o+"",y:s+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,i.appendChild(r),i.setAttribute("href",t.href),i}function Bn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=H(e.nodes,t),i=document.createElementNS(A,"image");return _(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const he=100,Rn='<?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">',zn=(e,t=!1)=>{var a,p,v;const n=e.nodes,o=n.offsetHeight+he*2,s=n.offsetWidth+he*2,i=jn(o+"px",s+"px"),r=document.createElementNS(A,"svg"),c=document.createElementNS(A,"rect");_(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(c),n.querySelectorAll(".subLines").forEach(m=>{const d=m.cloneNode(!0),{offsetLeft:f,offsetTop:g}=H(n,m.parentElement);d.setAttribute("x",`${f}`),d.setAttribute("y",`${g}`),r.appendChild(d)});const h=(a=n.querySelector(".lines"))==null?void 0:a.cloneNode(!0);h&&r.appendChild(h);const u=(p=n.querySelector(".topiclinks"))==null?void 0:p.cloneNode(!0);u&&r.appendChild(u);const l=(v=n.querySelector(".summary"))==null?void 0:v.cloneNode(!0);return l&&r.appendChild(l),n.querySelectorAll("me-tpc").forEach(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(de(e,m,!t)):(r.appendChild(Hn(e,m)),r.appendChild(de(e,m.text,!t)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(de(e,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(de(e,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(Pn(e,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(Bn(e,m))}),_(r,{x:he+"",y:he+"",overflow:"visible"}),i.appendChild(r),i},Fn=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Rn+e.outerHTML);function qn(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Vn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await qn(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=zn(this,e),o=Fn(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function Yn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const ct=Object.keys(et),lt={};for(let e=0;e<ct.length;e++){const t=ct[e];lt[t]=Yn(et[t],t)}const Kn={getObjById:ne,generateNewObj:ht,layout:xt,linkDiv:kt,editTopic:Mt,createWrapper:St,createParent:Ct,createChildren:Nt,createTopic:_t,findEle:Ae,changeTheme:Xt,...un,...lt,..._n,...An,...Vn,init(e){if(e=JSON.parse(JSON.stringify(e)),!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,$(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Rt(this),this.keypress&&vt(this,this.keypress),this.editable&&It(this),this.contextMenu&&this.disposable.push(Lt(this,this.contextMenu)),this.draggable&&this.disposable.push(Ot(this)),this.allowUndo&&this.disposable.push(Ht(this)),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),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,(e=this.selection)==null||e.destroy(),this.selection=void 0}};function In({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,containerHeight:u}){let l=t+n/2;const a=e+o/2;let p;h===k.LHS?p=i+r:p=i;const v=s+c/2,d=(1-Math.abs(v-a)/u)*.25*(n/2);return h===k.LHS?l=l-n/10-d:l=l+n/10+d,`M ${l} ${a} Q ${l} ${v} ${p} ${v}`}function Xn({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,isFirst:u}){const l=parseInt(this.container.style.getPropertyValue("--gap"));let a=0,p=0;u?a=e+o/2:a=e+o;const v=s+c;let m=0,d=0,f=0;const g=Math.abs(a-v)/300*l;return h===k.LHS?(f=t,m=f+l,d=f-l,p=i+l,`M ${m} ${a} C ${f} ${a} ${f+g} ${v} ${d} ${v} H ${p}`):(f=t+n,m=f-l,d=f+l,p=i+r-l,`M ${m} ${a} C ${f} ${a} ${f-g} ${v} ${d} ${v} H ${p}`)}const Wn="5.0.0-beta.29";function Un(e){return{x:0,y:0,moved:!1,mousedown:!1,onMove(t){if(this.mousedown){this.moved=!0;const n=t.movementX,o=t.movementY;e.move(n,o)}},clear(){setTimeout(()=>{this.moved=!1,this.mousedown=!1,e.map.style.transition="transform 0.3s"},0)}}}const Z=document;function O({el:e,direction:t,locale:n,draggable:o,editable:s,contextMenu:i,toolBar:r,keypress:c,mouseSelectionButton:h,selectionContainer:u,before:l,newTopicName:a,allowUndo:p,generateMainBranch:v,generateSubBranch:m,overflowHidden:d,theme:f,alignment:g}){let y=null;const b=Object.prototype.toString.call(e);if(b==="[object HTMLDivElement]"?y=e:b==="[object String]"&&(y=document.querySelector(e)),!y)throw new Error("MindElixir: el is not a valid element");y.style.position="relative",y.innerHTML="",this.el=y,this.disposable=[],this.before=l||{},this.locale=n||"en",this.contextMenu=i===void 0?!0:i,this.toolBar=r===void 0?!0:r,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=h||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=a||"new node",this.editable=s===void 0?!0:s,this.allowUndo=p===void 0?!1:p,this.currentNodes=[],this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=v||In,this.generateSubBranch=m||Xn,this.overflowHidden=d||!1,this.dragMoveHelper=Un(this),this.bus=bt(),this.container=Z.createElement("div"),this.selectionContainer=u||this.container,this.container.className="map-container";const E=window.matchMedia("(prefers-color-scheme: dark)");this.theme=f||(E.matches?_e:Ne);const x=Z.createElement("div");x.className="map-canvas",setTimeout(()=>{x.style.transition="all 0.3s"},300),this.map=x,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.el.appendChild(this.container),this.nodes=Z.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=G("lines"),this.summarySvg=G("summary"),this.linkController=G("linkcontroller"),this.P2=Z.createElement("div"),this.P3=Z.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=Oe(),this.line2=Oe(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.alignment=g??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":this.disposable.push(yt(this)),this.container.addEventListener("contextmenu",w=>{if(w.preventDefault(),!this.editable)return;const S=w;setTimeout(()=>{this.dragMoveHelper.moved||this.bus.fire("showContextMenu",S)},100)})}return O.prototype=Kn,Object.defineProperty(O.prototype,"currentNode",{get(){return this.currentNodes.at(-1)},enumerable:!0}),O.LEFT=N,O.RIGHT=T,O.SIDE=ee,O.THEME=Ne,O.DARK_THEME=_e,O.version=Wn,O.E=Ae,O.new=e=>({nodeData:{id:z(),topic:e||"new topic",children:[]}}),O}();
|
package/dist/MindElixir.js
CHANGED
|
@@ -2498,7 +2498,7 @@ function jo({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
|
|
|
2498
2498
|
const g = Math.abs(a - v) / 300 * l;
|
|
2499
2499
|
return h === M.LHS ? (f = t, m = f + l, d = f - l, p = i + l, `M ${m} ${a} C ${f} ${a} ${f + g} ${v} ${d} ${v} H ${p}`) : (f = t + n, m = f - l, d = f + l, p = i + r - l, `M ${m} ${a} C ${f} ${a} ${f - g} ${v} ${d} ${v} H ${p}`);
|
|
2500
2500
|
}
|
|
2501
|
-
const Oo = "5.0.0-beta.
|
|
2501
|
+
const Oo = "5.0.0-beta.29";
|
|
2502
2502
|
function $o(e) {
|
|
2503
2503
|
return {
|
|
2504
2504
|
x: 0,
|
|
@@ -15,4 +15,4 @@ var MindElixirLite=function(){"use strict";const $e="";(function(t){var e,n,o,s,
|
|
|
15
15
|
`,ht(o),t.scrollIntoView(o),o.addEventListener("keydown",r=>{r.stopPropagation();const c=r.key;if(c==="Enter"||c==="Tab"){if(r.shiftKey)return;r.preventDefault(),o.blur(),t.map.focus()}}),o.addEventListener("blur",()=>{var c;if(!o)return;const r=((c=o.textContent)==null?void 0:c.trim())||"";r===""?n.label=s:n.label=r,o.remove(),r!==s&&(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,s=e.offsetWidth,i=e.offsetHeight,c=this.nodes.offsetWidth;this.nodes.style.top=`${1e4-this.nodes.offsetHeight/2}px`,this.alignment==="root"?this.nodes.style.left=`${1e4-o-s/2}px`:this.nodes.style.left=`${1e4-c/2}px`;const h=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="";for(let g=0;g<h.length;g++){const a=h[g],f=a.querySelector("me-tpc"),{offsetLeft:u,offsetTop:p}=k(this.nodes,f),m=f.offsetWidth,l=f.offsetHeight,d=a.parentNode.className,v=this.generateMainBranch({pT:n,pL:o,pW:s,pH:i,cT:p,cL:u,cW:m,cH:l,direction:d,containerHeight:this.nodes.offsetHeight}),y=this.theme.palette,w=f.nodeObj.branchColor||y[g%y.length];f.style.borderColor=w,this.lines.appendChild(dt(v,w,"3"));const x=a.children[0].children[1];if(x&&(x.style.top=(x.parentNode.offsetHeight-x.offsetHeight)/2+"px",d===T.LHS?x.style.left="-10px":x.style.right="-10px"),t&&t!==a)continue;const b=V("subLines"),C=a.lastChild;C.tagName==="svg"&&C.remove(),a.appendChild(b),pt(this,b,w,a,d,!0)}this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},pt=function(t,e,n,o,s,i){const r=o.firstChild,c=o.children[1].children;if(c.length===0)return;const h=r.offsetTop,g=r.offsetLeft,a=r.offsetWidth,f=r.offsetHeight;for(let u=0;u<c.length;u++){const p=c[u],m=p.firstChild,l=m.offsetTop,d=m.offsetLeft,v=m.offsetWidth,y=m.offsetHeight,w=m.firstChild.nodeObj.branchColor||n,x=t.generateSubBranch({pT:h,pL:g,pW:a,pH:f,cT:l,cL:d,cW:v,cH:y,direction:s,isFirst:i});e.appendChild(dt(x,w,"2"));const b=m.children[1];if(b){if(b.style.bottom=-(b.offsetHeight/2)+"px",s===T.LHS?b.style.left="10px":s===T.RHS&&(b.style.right="10px"),!b.expanded)continue}else continue;pt(t,e,w,p,s)}},Te="",Ne="",D=(t,e)=>{const n=document.createElement("span");return n.id=t,n.innerHTML=`<svg class="icon" aria-hidden="true">
|
|
16
16
|
<use xlink:href="#icon-${e}"></use>
|
|
17
17
|
</svg>`,n};function jt(t){const e=document.createElement("div"),n=D("fullscreen","full"),o=D("toCenter","living"),s=D("zoomout","move"),i=D("zoomin","add"),r=document.createElement("span");return r.innerText="100%",e.appendChild(n),e.appendChild(o),e.appendChild(s),e.appendChild(i),e.className="mind-elixir-toolbar rb",n.onclick=()=>{t.el.requestFullscreen()},o.onclick=()=>{t.toCenter()},s.onclick=()=>{t.scaleVal<.6||t.scale(t.scaleVal-.2)},i.onclick=()=>{t.scaleVal>1.6||t.scale(t.scaleVal+.2)},e}function qt(t){const e=document.createElement("div"),n=D("tbltl","left"),o=D("tbltr","right"),s=D("tblts","side");return e.appendChild(n),e.appendChild(o),e.appendChild(s),e.className="mind-elixir-toolbar lt",n.onclick=()=>{t.initLeft()},o.onclick=()=>{t.initRight()},s.onclick=()=>{t.initSide()},e}function _t(t){t.container.append(jt(t)),t.container.append(qt(t))}const Ft=function(t,e=!0){this.theme=t;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let s=0;s<o.length;s++){const i=o[s];this.container.style.setProperty(i,n[i])}t.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),e&&this.refresh()},Rt=function(t){const n=t.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())};function Yt(t){return{nodeData:t.isFocusMode?t.nodeDataBackup:t.nodeData,arrows:t.arrows,summaries:t.summaries,direction:t.direction,theme:t.theme}}const It=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:function(){this.unselectNodes(this.currentNodes),this.unselectSummary(),this.unselectArrow()},disableEdit:function(){this.editable=!1},enableEdit:function(){this.editable=!0},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,s=o.children[1];if(s.expanded=n.expanded,s.className=n.expanded?"minus":"",Rt(t),n.expanded){const h=this.createChildren(n.children.map(g=>this.createWrapper(g).grp));o.parentNode.appendChild(h)}else o.parentNode.children[1].remove();this.linkDiv(t.closest("me-main > me-wrapper"));const i=t.getBoundingClientRect(),r=this.container.getBoundingClientRect();(i.bottom>r.bottom||i.top<r.top||i.right>r.right||i.left<r.left)&&this.scrollIntoView(t),this.bus.fire("expandNode",n)},expandNodeAll:function(t,e){const n=t.nodeObj,o=(s,i)=>{s.expanded=i,s.children&&s.children.forEach(r=>{o(r,i)})};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:function(){return JSON.parse(this.getDataString())},getDataString:function(){const t=Yt(this);return JSON.stringify(t,(e,n)=>{if(!(e==="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(t){t(this)},move:function(t,e){const{map:n,scaleVal:o,container:s,bus:i}=this,r=n.style.transform,{x:c,y:h}=it(r),g=c+t,a=h+e,f=(1-o)*1e4,u=0-f,p=-2e4+s.offsetWidth+f,m=-2e4+s.offsetHeight+f,l=Math.min(u,Math.max(p,g)),d=Math.min(u,Math.max(m,a));n.style.transform=`translate(${l}px, ${d}px) scale(${o})`,i.fire("move",{dx:t,dy:e})},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:function(t,e={x:0,y:0}){const n=this.container.getBoundingClientRect(),o=n.width/2-1e4,s=n.height/2-1e4,i=this.scaleVal,r=this.map.style.transform,{x:c,y:h}=it(r),g=c-(e.x-n.left-n.width/2),a=h-(e.y-n.top-n.height/2),f=(o-g)*(1-t/i),u=(s-a)*(1-t/i);this.map.style.transform=`translate(${c+f}px, ${h+u}px) scale(${t})`,this.scaleVal=t,this.bus.fire("scale",t)},scaleFit: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)},scrollIntoView:function(t){const e=this.container,n=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(n.bottom>o.bottom||n.top<o.top||n.right>o.right||n.left<o.left){const i=n.left+n.width/2,r=n.top+n.height/2,c=o.left+o.width/2,h=o.top+o.height/2,g=i-c,a=r-h;this.move(-g,-a)}},selectNode:function(t,e,n){this.clearSelection(),this.scrollIntoView(t),this.selection.select(t),e&&this.bus.fire("selectNewNode",t.nodeObj)},selectNodes:function(t){this.selection.select(t)},setLocale:function(t){this.locale=t,this.refresh()},toCenter:function(){const t=this.container.getBoundingClientRect(),e=t.width/2-1e4,n=t.height/2-1e4;this.map.style.transform=`translate(${e}px, ${n}px) scale(${this.scaleVal})`},unselectNodes:function(t){this.selection.deselect(t)}},Symbol.toStringTag,{value:"Module"})),mt={create:function(t){return{dom:t,moved:!1,mousedown:!1,handleMouseMove(e){this.mousedown&&(this.moved=!0,this.cb&&this.cb(e.movementX,e.movementY))},handleMouseDown(e){e.button===0&&(this.mousedown=!0)},handleClear(e){this.mousedown=!1},cb:null,init(e,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.destroy=rt([{dom:e,evt:"mousemove",func:this.handleMouseMove},{dom:e,evt:"mouseleave",func:this.handleClear},{dom:e,evt:"mouseup",func:this.handleClear},{dom:this.dom,evt:"mousedown",func:this.handleMouseDown}])},destroy:null,clear(){this.moved=!1,this.mousedown=!1}}}};function gt(t,e,n,o,s,i,r,c){return{x:t/8+n*3/8+s*3/8+r/8,y:e/8+o*3/8+i*3/8+c/8}}function Xt(t,e,n){E(t,{x:e+"",y:n+""})}function R(t,e,n,o,s){E(t,{x1:e+"",y1:n+"",x2:o+"",y2:s+""})}function yt(t,e,n,o,s,i,r,c,h,g){t.line.setAttribute("d",`M ${e} ${n} C ${o} ${s} ${i} ${r} ${c} ${h}`);const a=_(i,r,c,h);if(a&&t.arrow1.setAttribute("d",`M ${a.x1} ${a.y1} L ${c} ${h} L ${a.x2} ${a.y2}`),g.bidirectional){const p=_(o,s,e,n);p&&t.arrow2.setAttribute("d",`M ${p.x1} ${p.y1} L ${e} ${n} L ${p.x2} ${p.y2}`)}const{x:f,y:u}=gt(e,n,o,s,i,r,c,h);Xt(t.label,f,u),ee(t)}function Y(t,e,n){const{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=e.offsetWidth,r=e.offsetHeight,c=o+i/2,h=s+r/2,g=c+n.x,a=h+n.y;return{w:i,h:r,cx:c,cy:h,ctrlX:g,ctrlY:a}}function P(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 Wt=function(t,e,n,o){const s=document.createElementNS(S,"text");return E(s,{"text-anchor":"middle",x:e+"",y:n+"",fill:o||"#666"}),s.dataset.type="custom-link",s.innerHTML=t,s},Q=function(t,e,n,o,s){if(!e||!n)return;const i=Y(t,e,o.delta1),r=Y(t,n,o.delta2),{x:c,y:h}=P(i),{ctrlX:g,ctrlY:a}=i,{ctrlX:f,ctrlY:u}=r,{x:p,y:m}=P(r),l=_(f,u,p,m);if(!l)return;const d=`M ${l.x1} ${l.y1} L ${p} ${m} L ${l.x2} ${l.y2}`;let v="";if(o.bidirectional){const C=_(g,a,c,h);if(!C)return;v=`M ${C.x1} ${C.y1} L ${c} ${h} L ${C.x2} ${C.y2}`}const y=Vt(`M ${c} ${h} C ${g} ${a} ${f} ${u} ${p} ${m}`,d,v),{x:w,y:x}=gt(c,h,g,a,f,u,p,m),b=Wt(o.label,w,x,t.theme.cssVar["--color"]);y.appendChild(b),y.label=b,y.arrowObj=o,y.dataset.linkid=o.id,t.linkSvgGroup.appendChild(y),s||(t.arrows.push(o),t.currentArrow=y,vt(t,o,i,r))},Gt=function(t,e,n={}){const o={id:z(),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})},Kt=function(t){const e={...t,id:z()};Q(this,this.findEle(e.from),this.findEle(e.to),e),this.bus.fire("operation",{name:"createArrow",obj:e})},Ut=function(t){let e;if(t?e=t:e=this.currentArrow,!e)return;tt(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}})},Jt=function(t){this.currentArrow=t;const e=t.arrowObj,n=this.findEle(e.from),o=this.findEle(e.to),s=Y(this,n,e.delta1),i=Y(this,o,e.delta2);vt(this,e,s,i)},Qt=function(){tt(this),this.currentArrow=null},Z=function(t,e){const n=document.createElementNS(S,"path");return E(n,{d:t,stroke:e,fill:"none","stroke-width":"6","stroke-linecap":"round","stroke-linejoin":"round"}),n},Zt=function(t,e){const n=document.createElementNS(S,"g");n.setAttribute("class","arrow-highlight"),n.setAttribute("opacity","0.45");const o=Z(t.line.getAttribute("d"),e);n.appendChild(o);const s=Z(t.arrow1.getAttribute("d"),e);if(n.appendChild(s),t.arrow2.getAttribute("d")){const i=Z(t.arrow2.getAttribute("d"),e);n.appendChild(i)}t.insertBefore(n,t.firstChild)},te=function(t){const e=t.querySelector(".arrow-highlight");e&&e.remove()},ee=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"))},tt=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&&te(t.currentArrow)},vt=function(t,e,n,o){const{linkController:s,P2:i,P3:r,line1:c,line2:h,nodes:g,map:a,currentArrow:f,bus:u}=t;if(!f)return;s.style.display="initial",i.style.display="initial",r.style.display="initial",g.appendChild(s),g.appendChild(i),g.appendChild(r),Zt(f,"#4dc4ff");let{x:m,y:l}=P(n),{ctrlX:d,ctrlY:v}=n,{ctrlX:y,ctrlY:w}=o,{x,y:b}=P(o);i.style.cssText=`top:${v}px;left:${d}px;`,r.style.cssText=`top:${w}px;left:${y}px;`,R(c,m,l,d,v),R(h,y,w,x,b),t.helper1=mt.create(i),t.helper2=mt.create(r),t.helper1.init(a,(C,L)=>{d=d+C/t.scaleVal,v=v+L/t.scaleVal;const A=P({...n,ctrlX:d,ctrlY:v});m=A.x,l=A.y,i.style.top=v+"px",i.style.left=d+"px",yt(f,m,l,d,v,y,w,x,b,e),R(c,m,l,d,v),e.delta1.x=d-n.cx,e.delta1.y=v-n.cy,u.fire("updateArrowDelta",e)}),t.helper2.init(a,(C,L)=>{y=y+C/t.scaleVal,w=w+L/t.scaleVal;const A=P({...o,ctrlX:y,ctrlY:w});x=A.x,b=A.y,r.style.top=w+"px",r.style.left=y+"px",yt(f,m,l,d,v,y,w,x,b,e),R(h,y,w,x,b),e.delta2.x=y-o.cx,e.delta2.y=w-o.cy,u.fire("updateArrowDelta",e)})};function ne(){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 oe(t){if(tt(this),!t)return;const e=t.label;ut(this,e,t.arrowObj)}function se(){this.arrows=this.arrows.filter(t=>q(t.from,this.nodeData)&&q(t.to,this.nodeData))}const ie=Object.freeze(Object.defineProperty({__proto__:null,createArrow:Gt,createArrowFrom:Kt,editArrowLabel:oe,removeArrow:Ut,renderArrow:ne,selectArrow:Jt,tidyArrow:se,unselectArrow:Qt},Symbol.toStringTag,{value:"Module"})),re=function(t){var h,g;if(t.length===0)throw new Error("No selected node.");if(t.length===1){const a=t[0].nodeObj,f=t[0].nodeObj.parent;if(!f)throw new Error("Can not select root node.");const u=f.children.findIndex(p=>a===p);return{parent:f.id,start:u,end:u}}let e=0;const n=t.map(a=>{let f=a.nodeObj;const u=[];for(;f.parent;){const p=f.parent,m=p.children,l=m==null?void 0:m.indexOf(f);f=p,u.unshift({node:f,index:l})}return u.length>e&&(e=u.length),u});let o=0;t:for(;o<e;o++){const a=(h=n[0][o])==null?void 0:h.node;for(let f=1;f<n.length;f++)if(((g=n[f][o])==null?void 0:g.node)!==a)break t}if(!o)throw new Error("Can not select root node.");const s=n.map(a=>a[o-1].index).sort(),i=s[0]||0,r=s[s.length-1]||0,c=n[0][o-1].node;if(!c.parent)throw new Error("Please select nodes in the same main topic.");return{parent:c.id,start:i,end:r}},ce=function(t){const e=document.createElementNS(S,"g");return e.setAttribute("id",t),e},bt=function(t,e){const n=document.createElementNS(S,"path");return E(n,{d:t,stroke:e||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},xt=function(t,e,n,o,s){const i=document.createElementNS(S,"text");return E(i,{"text-anchor":o,x:e+"",y:n+"",fill:s||"#666"}),i.innerHTML=t,i},le=t=>t.parentElement.parentElement,ae=function(t,{parent:e,start:n}){const o=t.findEle(e),s=o.nodeObj;let i;return s.parent?i=o.closest("me-main").className:i=t.findEle(s.children[n].id).closest("me-main").className,i},et=function(t,e){var A;const{id:n,label:o,parent:s,start:i,end:r}=e,{nodes:c,theme:h,summarySvg:g}=t,f=t.findEle(s).nodeObj,u=ae(t,e);let p=1/0,m=0,l=0,d=0;for(let j=i;j<=r;j++){const wt=(A=f.children)==null?void 0:A[j];if(!wt)return t.removeSummary(n),null;const W=le(t.findEle(wt.id)),{offsetLeft:G,offsetTop:Ct}=k(c,W),Et=i===r?10:20;j===i&&(l=Ct+Et),j===r&&(d=Ct+W.offsetHeight-Et),G<p&&(p=G),W.offsetWidth+G>m&&(m=W.offsetWidth+G)}let v,y;const w=l+10,x=d+10,b=(w+x)/2,C=h.cssVar["--color"];u===T.LHS?(v=bt(`M ${p+10} ${w} c -5 0 -10 5 -10 10 L ${p} ${x-10} c 0 5 5 10 10 10 M ${p} ${b} h -10`,C),y=xt(o,p-20,b+6,"end",C)):(v=bt(`M ${m-10} ${w} c 5 0 10 5 10 10 L ${m} ${x-10} c 0 5 -5 10 -10 10 M ${m} ${b} h 10`,C),y=xt(o,m+20,b+6,"start",C));const L=ce("s-"+n);return L.appendChild(v),L.appendChild(y),L.summaryObj=e,g.appendChild(L),L},he=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){if(!this.currentNodes)return;const{currentNodes:t,summaries:e,bus:n}=this,{parent:o,start:s,end:i}=re(t),r={id:z(),parent:o,start:s,end:i,label:"summary"},c=et(this,r);e.push(r),this.editSummary(c),n.fire("operation",{name:"createSummary",obj:r})},createSummaryFrom:function(t){const e=z(),n={...t,id:e};et(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];ut(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{et(this,t)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(t){const e=t.children[1].getBBox(),n=6,o=3,s=document.createElementNS(S,"rect");E(s,{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(s),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"})),M="http://www.w3.org/2000/svg";function de(t,e){const n=document.createElementNS(M,"svg");return E(n,{version:"1.1",xmlns:M,height:t,width:e}),n}function fe(t,e){return(parseInt(t)-parseInt(e))/2}function ue(t,e,n,o){const s=document.createElementNS(M,"g");let i="";return t.text?i=t.text.textContent:i=t.childNodes[0].textContent,i.split(`
|
|
18
|
-
`).forEach((c,h)=>{const g=document.createElementNS(M,"text");E(g,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+fe(e.lineHeight,e.fontSize)*(h+1)+parseFloat(e.fontSize)*(h+1)+"","text-anchor":"start","font-family":e.fontFamily,"font-size":`${e.fontSize}`,"font-weight":`${e.fontWeight}`,fill:`${e.color}`}),g.innerHTML=c,s.appendChild(g)}),s}function pe(t,e,n,o){var c;let s="";(c=t.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=t.nodeObj.dangerouslySetInnerHTML:t.text?s=t.text.textContent:s=t.childNodes[0].textContent;const i=document.createElementNS(M,"foreignObject");E(i,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+"",width:e.width,height:e.height});const r=document.createElement("div");return E(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=s,i.appendChild(r),i}function me(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"rect");return E(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function I(t,e,n=!1){const o=getComputedStyle(e),{offsetLeft:s,offsetTop:i}=k(t.nodes,e),r=document.createElementNS(M,"rect");E(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const c=document.createElementNS(M,"g");c.appendChild(r);let h;return n?h=pe(e,o,s,i):h=ue(e,o,s,i),c.appendChild(h),c}function ge(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"a"),r=document.createElementNS(M,"text");return E(r,{x:o+"",y:s+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,i.appendChild(r),i.setAttribute("href",e.href),i}function ye(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"image");return E(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:e.src}),i}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">',be=(t,e=!1)=>{var f,u,p;const n=t.nodes,o=n.offsetHeight+X*2,s=n.offsetWidth+X*2,i=de(o+"px",s+"px"),r=document.createElementNS(M,"svg"),c=document.createElementNS(M,"rect");E(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:t.theme.cssVar["--bgcolor"]}),i.appendChild(c),n.querySelectorAll(".subLines").forEach(m=>{const l=m.cloneNode(!0),{offsetLeft:d,offsetTop:v}=k(n,m.parentElement);l.setAttribute("x",`${d}`),l.setAttribute("y",`${v}`),r.appendChild(l)});const h=(f=n.querySelector(".lines"))==null?void 0:f.cloneNode(!0);h&&r.appendChild(h);const g=(u=n.querySelector(".topiclinks"))==null?void 0:u.cloneNode(!0);g&&r.appendChild(g);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(I(t,m,!e)):(r.appendChild(me(t,m)),r.appendChild(I(t,m.text,!e)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(I(t,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(I(t,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(ge(t,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(ye(t,m))}),E(r,{x:X+"",y:X+"",overflow:"visible"}),i.appendChild(r),i},xe=(t,e)=>(e&&t.insertAdjacentHTML("afterbegin","<style>"+e+"</style>"),ve+t.outerHTML);function we(t){return new Promise((e,n)=>{const o=new FileReader;o.onload=s=>{e(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(t)})}const Ce={getObjById:q,generateNewObj:St,layout:Tt,linkDiv:Ot,editTopic:Pt,createWrapper:kt,createParent:Ht,createChildren:Dt,createTopic:Bt,findEle:lt,changeTheme:Ft,...It,...{},...ie,...he,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(t=!1,e){const n=this.exportSvg(t,e),o=await we(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(t=!1,e){const n=be(this,t),o=xe(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&&_t(this),this.toCenter(),this.layout(),this.linkDiv()},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 Ee({pT:t,pL:e,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,containerHeight:g}){let a=e+n/2;const f=t+o/2;let u;h===T.LHS?u=i+r:u=i;const p=s+c/2,l=(1-Math.abs(p-f)/g)*.25*(n/2);return h===T.LHS?a=a-n/10-l:a=a+n/10+l,`M ${a} ${f} Q ${a} ${p} ${u} ${p}`}function Se({pT:t,pL:e,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,isFirst:g}){const a=parseInt(this.container.style.getPropertyValue("--gap"));let f=0,u=0;g?f=t+o/2:f=t+o;const p=s+c;let m=0,l=0,d=0;const v=Math.abs(f-p)/300*a;return h===T.LHS?(d=e,m=d+a,l=d-a,u=i+a,`M ${m} ${f} C ${d} ${f} ${d+v} ${p} ${l} ${p} H ${u}`):(d=e+n,m=d-a,l=d+a,u=i+r-a,`M ${m} ${f} C ${d} ${f} ${d-v} ${p} ${l} ${p} H ${u}`)}const Me="5.0.0-beta.
|
|
18
|
+
`).forEach((c,h)=>{const g=document.createElementNS(M,"text");E(g,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+fe(e.lineHeight,e.fontSize)*(h+1)+parseFloat(e.fontSize)*(h+1)+"","text-anchor":"start","font-family":e.fontFamily,"font-size":`${e.fontSize}`,"font-weight":`${e.fontWeight}`,fill:`${e.color}`}),g.innerHTML=c,s.appendChild(g)}),s}function pe(t,e,n,o){var c;let s="";(c=t.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=t.nodeObj.dangerouslySetInnerHTML:t.text?s=t.text.textContent:s=t.childNodes[0].textContent;const i=document.createElementNS(M,"foreignObject");E(i,{x:n+parseInt(e.paddingLeft)+"",y:o+parseInt(e.paddingTop)+"",width:e.width,height:e.height});const r=document.createElement("div");return E(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=s,i.appendChild(r),i}function me(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"rect");return E(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function I(t,e,n=!1){const o=getComputedStyle(e),{offsetLeft:s,offsetTop:i}=k(t.nodes,e),r=document.createElementNS(M,"rect");E(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const c=document.createElementNS(M,"g");c.appendChild(r);let h;return n?h=pe(e,o,s,i):h=ue(e,o,s,i),c.appendChild(h),c}function ge(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"a"),r=document.createElementNS(M,"text");return E(r,{x:o+"",y:s+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,i.appendChild(r),i.setAttribute("href",e.href),i}function ye(t,e){const n=getComputedStyle(e),{offsetLeft:o,offsetTop:s}=k(t.nodes,e),i=document.createElementNS(M,"image");return E(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:e.src}),i}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">',be=(t,e=!1)=>{var f,u,p;const n=t.nodes,o=n.offsetHeight+X*2,s=n.offsetWidth+X*2,i=de(o+"px",s+"px"),r=document.createElementNS(M,"svg"),c=document.createElementNS(M,"rect");E(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:t.theme.cssVar["--bgcolor"]}),i.appendChild(c),n.querySelectorAll(".subLines").forEach(m=>{const l=m.cloneNode(!0),{offsetLeft:d,offsetTop:v}=k(n,m.parentElement);l.setAttribute("x",`${d}`),l.setAttribute("y",`${v}`),r.appendChild(l)});const h=(f=n.querySelector(".lines"))==null?void 0:f.cloneNode(!0);h&&r.appendChild(h);const g=(u=n.querySelector(".topiclinks"))==null?void 0:u.cloneNode(!0);g&&r.appendChild(g);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(I(t,m,!e)):(r.appendChild(me(t,m)),r.appendChild(I(t,m.text,!e)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(I(t,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(I(t,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(ge(t,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(ye(t,m))}),E(r,{x:X+"",y:X+"",overflow:"visible"}),i.appendChild(r),i},xe=(t,e)=>(e&&t.insertAdjacentHTML("afterbegin","<style>"+e+"</style>"),ve+t.outerHTML);function we(t){return new Promise((e,n)=>{const o=new FileReader;o.onload=s=>{e(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(t)})}const Ce={getObjById:q,generateNewObj:St,layout:Tt,linkDiv:Ot,editTopic:Pt,createWrapper:kt,createParent:Ht,createChildren:Dt,createTopic:Bt,findEle:lt,changeTheme:Ft,...It,...{},...ie,...he,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(t=!1,e){const n=this.exportSvg(t,e),o=await we(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(t=!1,e){const n=be(this,t),o=xe(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&&_t(this),this.toCenter(),this.layout(),this.linkDiv()},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 Ee({pT:t,pL:e,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,containerHeight:g}){let a=e+n/2;const f=t+o/2;let u;h===T.LHS?u=i+r:u=i;const p=s+c/2,l=(1-Math.abs(p-f)/g)*.25*(n/2);return h===T.LHS?a=a-n/10-l:a=a+n/10+l,`M ${a} ${f} Q ${a} ${p} ${u} ${p}`}function Se({pT:t,pL:e,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:h,isFirst:g}){const a=parseInt(this.container.style.getPropertyValue("--gap"));let f=0,u=0;g?f=t+o/2:f=t+o;const p=s+c;let m=0,l=0,d=0;const v=Math.abs(f-p)/300*a;return h===T.LHS?(d=e,m=d+a,l=d-a,u=i+a,`M ${m} ${f} C ${d} ${f} ${d+v} ${p} ${l} ${p} H ${u}`):(d=e+n,m=d-a,l=d+a,u=i+r-a,`M ${m} ${f} C ${d} ${f} ${d-v} ${p} ${l} ${p} H ${u}`)}const Me="5.0.0-beta.29";function Le(t){return{x:0,y:0,moved:!1,mousedown:!1,onMove(e){if(this.mousedown){this.moved=!0;const n=e.movementX,o=e.movementY;t.move(n,o)}},clear(){setTimeout(()=>{this.moved=!1,this.mousedown=!1,t.map.style.transition="transform 0.3s"},0)}}}const O=document;function N({el:t,direction:e,locale:n,draggable:o,editable:s,contextMenu:i,toolBar:r,keypress:c,mouseSelectionButton:h,selectionContainer:g,before:a,newTopicName:f,allowUndo:u,generateMainBranch:p,generateSubBranch:m,overflowHidden:l,theme:d,alignment:v}){let y=null;const w=Object.prototype.toString.call(t);if(w==="[object HTMLDivElement]"?y=t:w==="[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=a||{},this.locale=n||"en",this.contextMenu=i===void 0?!0:i,this.toolBar=r===void 0?!0:r,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=h||0,this.direction=typeof e=="number"?e:1,this.draggable=o===void 0?!0:o,this.newTopicName=f||"new node",this.editable=s===void 0?!0:s,this.allowUndo=u===void 0?!1:u,this.currentNodes=[],this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=p||Ee,this.generateSubBranch=m||Se,this.overflowHidden=l||!1,this.dragMoveHelper=Le(this),this.bus=$t(),this.container=O.createElement("div"),this.selectionContainer=g||this.container,this.container.className="map-container";const x=window.matchMedia("(prefers-color-scheme: dark)");this.theme=d||(x.matches?ot:nt);const b=O.createElement("div");b.className="map-canvas",setTimeout(()=>{b.style.transition="all 0.3s"},300),this.map=b,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.el.appendChild(this.container),this.nodes=O.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=V("lines"),this.summarySvg=V("summary"),this.linkController=V("linkcontroller"),this.P2=O.createElement("div"),this.P3=O.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=ft(),this.line2=ft(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=V("topiclinks"),this.alignment=v??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":this.disposable.push(Lt(this)),this.container.addEventListener("contextmenu",C=>{if(C.preventDefault(),!this.editable)return;const L=C;setTimeout(()=>{this.dragMoveHelper.moved||this.bus.fire("showContextMenu",L)},100)})}return N.prototype=Ce,Object.defineProperty(N.prototype,"currentNode",{get(){return this.currentNodes.at(-1)},enumerable:!0}),N.LEFT=B,N.RIGHT=K,N.SIDE=U,N.THEME=nt,N.DARK_THEME=ot,N.version=Me,N.E=lt,N}();
|
package/dist/MindElixirLite.js
CHANGED
|
@@ -1238,7 +1238,7 @@ function rn({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
|
|
|
1238
1238
|
const v = Math.abs(f - p) / 300 * a;
|
|
1239
1239
|
return h === A.LHS ? (d = e, m = d + a, l = d - a, u = i + a, `M ${m} ${f} C ${d} ${f} ${d + v} ${p} ${l} ${p} H ${u}`) : (d = e + n, m = d - a, l = d + a, u = i + r - a, `M ${m} ${f} C ${d} ${f} ${d - v} ${p} ${l} ${p} H ${u}`);
|
|
1240
1240
|
}
|
|
1241
|
-
const cn = "5.0.0-beta.
|
|
1241
|
+
const cn = "5.0.0-beta.29";
|
|
1242
1242
|
function ln(t) {
|
|
1243
1243
|
return {
|
|
1244
1244
|
x: 0,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare namespace MindElixir {
|
|
|
97
97
|
}
|
|
98
98
|
export interface MindElixirCtor {
|
|
99
99
|
new (options: Options): MindElixirInstance;
|
|
100
|
-
E: (id: string, el
|
|
100
|
+
E: (id: string, el?: HTMLElement) => Topic;
|
|
101
101
|
new: typeof MindElixir.new;
|
|
102
102
|
version: string;
|
|
103
103
|
LEFT: typeof LEFT;
|